-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,682 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
aira: | ||
gaiah: # 共通設定 | ||
run: true | ||
repo: | ||
repo_name: "IRIS" | ||
description: "I.R.I.S(Intelligent Repository Issue Solver)" | ||
private: false | ||
local: | ||
repo_dir: "C:/Prj/IRIS" | ||
no_initial_commit: false | ||
commit: | ||
commit_msg_path: ".Gaiah.md" | ||
branch_name: null | ||
|
||
dev: # 開発時の設定 (必要に応じて上書き) | ||
repo: | ||
create_repo: false | ||
local: | ||
init_repo: false | ||
commit: | ||
process_commits: true | ||
|
||
init: # 初期化時の設定 (必要に応じて上書き) | ||
repo: | ||
create_repo: true | ||
local: | ||
init_repo: true | ||
commit: | ||
process_commits: false | ||
|
||
llm: | ||
model: "gemini/gemini-1.5-pro-latest" # 利用するLLMモデル | ||
|
||
repository_summary_output_dir: .aira # リポジトリ概要の出力ディレクトリ | ||
readme_prompt_template_path: .aira/readme_prompt_template.txt # README生成のプロンプトテンプレートのパス | ||
|
||
harmon_ai: | ||
run: true | ||
environment: | ||
repo_name: "IRIS" | ||
owner_name: "Sunwood-ai-labs" | ||
package_name: "IRIS" | ||
icon_url: "https://huggingface.co/datasets/MakiAi/IconAssets/resolve/main/IRIS.png" | ||
title: "IRIS" | ||
subtitle: "~ Intelligent Repository Issue Solver ~" | ||
website_url: "https://hamaruki.com/" | ||
github_url: "https://github.com/Sunwood-ai-labs" | ||
twitter_url: "https://x.com/hAru_mAki_ch" | ||
blog_url: "https://hamaruki.com/" | ||
|
||
product: | ||
important_message_file: "important_template.md" | ||
sections_content_file: "sections_template.md" | ||
output_file: "README_template.md" | ||
cicd_file_path: "publish-to-pypi.yml" | ||
cicd_main_path: "publish-to-pypi.yml" | ||
github_cicd_dir: ".github/workflows" | ||
|
||
llm_product: | ||
sections_content_file: "sections_template_llm.md" | ||
|
||
development: | ||
output_dir: "C:/Prj/IRIS/.harmon_ai" | ||
|
||
main: | ||
main_dir: "C:/Prj/IRIS/" | ||
replace_readme: true | ||
|
||
instructions_prompt: .aira/instructions.IRIS.md | ||
|
||
# aira --mode=make --config=.aira\config.IRIS.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
aira: | ||
gaiah: # 共通設定 | ||
run: true | ||
repo: | ||
repo_name: "AIRA-Sample04" | ||
description: "" | ||
private: True | ||
local: | ||
repo_dir: "./" | ||
no_initial_commit: false | ||
commit: | ||
commit_msg_path: ".SourceSageAssets/COMMIT_CRAFT/llm_output.md" | ||
branch_name: null | ||
|
||
dev: # 開発時の設定 (必要に応じて上書き) | ||
repo: | ||
create_repo: false | ||
local: | ||
init_repo: false | ||
commit: | ||
process_commits: true | ||
|
||
# aira --mode sourcesage commit --config=.aira\config.dev.commit.yml --ss-model-name="gemini/gemini-1.5-pro-latest" --llm-output="llm_output.md" --ignore-file=".iris.SourceSageignore" | ||
# aira --mode sourcesage commit --config=.aira\config.dev.commit.yml --ss-model-name="gemini/gemini-1.5-flash-002" --llm-output="llm_output.md" | ||
# aira --mode sourcesage commit --config=.aira\config.dev.commit.yml --ss-model-name="gpt-4o-mini" --llm-output="llm_output.md" | ||
# sourcesage --ignore-file=".iris.SourceSageignore" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
from pydantic import Field | ||
from functools import lru_cache | ||
import os | ||
|
||
class Settings(BaseSettings): | ||
# 既存の設定 | ||
# LITELLM_MODEL: str = "gemini/gemini-1.5-flash-exp-0827" | ||
LITELLM_MODEL: str = "gemini/gemini-1.5-flash-002" | ||
GITHUB_TOKEN: str = Field(..., env="GITHUB_TOKEN") | ||
GITHUB_REPOSITORY: str = Field(..., env="GITHUB_REPOSITORY") | ||
ISSUE_NUMBER: int = Field(0, env="ISSUE_NUMBER") | ||
REPOSITORY_SUMMARY_PATH: str = Field("", env="REPOSITORY_SUMMARY_PATH") | ||
YOUR_PERSONAL_ACCESS_TOKEN: str = Field("", env="YOUR_PERSONAL_ACCESS_TOKEN") | ||
YOUR_PERSONAL_ACCESS_TOKEN_IRIS: str = Field("", env="YOUR_PERSONAL_ACCESS_TOKEN_IRIS") | ||
RELEASE_NOTES_DIR: str = Field(default=os.path.join(os.path.dirname(__file__), "release_notes"), env="RELEASE_NOTES_DIR") | ||
DOCS_DIR: str = Field(default="./docs", env="DOCS_DIR") | ||
|
||
# GitHub Actionsの環境変数を使用してリポジトリの可視性を取得 | ||
GITHUB_REPOSITORY_VISIBILITY: str = Field(default="public", env="GITHUB_REPOSITORY_VISIBILITY") | ||
|
||
# AWS S3関連の設定(オプショナル) | ||
USE_S3: bool = Field(default=False, env="USE_S3") | ||
AWS_ACCESS_KEY_ID: str = Field(default="", env="AWS_ACCESS_KEY_ID") | ||
AWS_SECRET_ACCESS_KEY: str = Field(default="", env="AWS_SECRET_ACCESS_KEY") | ||
AWS_REGION: str = Field(default="ap-northeast-1", env="AWS_REGION") | ||
S3_BUCKET_NAME: str = Field(default="github-release-assets", env="S3_BUCKET_NAME") | ||
|
||
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8', extra='ignore') | ||
|
||
@property | ||
def is_private_repo(self): | ||
return self.GITHUB_REPOSITORY_VISIBILITY == "private" | ||
|
||
@property | ||
def should_use_s3(self): | ||
return self.is_private_repo and self.USE_S3 and all([ | ||
self.AWS_ACCESS_KEY_ID, | ||
self.AWS_SECRET_ACCESS_KEY, | ||
self.S3_BUCKET_NAME | ||
]) | ||
|
||
@lru_cache() | ||
def get_settings(): | ||
return Settings() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
label,description | ||
bug,何かが正常に動作していません | ||
documentation,ドキュメントの改善または追加 | ||
duplicate,このイシューまたはプルリクエストは既に存在します | ||
enhancement,新機能または要望 | ||
feature,新機能または要望 | ||
good first issue,初心者に適しています | ||
help wanted,追加の注意が必要です | ||
invalid,これは適切ではないようです | ||
question,さらなる情報が必要です | ||
wontfix,これは対応されません |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ss-mode: | ||
- DocuMind | ||
docuMind-model: "XXXXX" | ||
docuMind-db: ".SourceSageAssets/DOCUMIND/Repository_summary.md" | ||
docuMind-release-report: ".SourceSageAssets/RELEASE_REPORT/Report_v0.0.0.md" | ||
docuMind-changelog: ".SourceSageAssets/Changelog/CHANGELOG_main.md" | ||
docuMind-output: ".SourceSageAssets/DOCUMIND/RELEASE_NOTES_v0.0.0.md" | ||
docuMind-prompt-output: ".SourceSageAssets/DOCUMIND/_PROMPT_v0.0.0.md" | ||
repo-name: "IRIS" | ||
repo-version: "v0.0.0" | ||
|
||
# changelog-start-tag: "v0.1.0" | ||
# changelog-end-tag: "v0.0.0" | ||
# sourcesage --ss-mode=DocuMind --yaml-file=docs\.sourcesage_releasenotes.yml | ||
# sourcesage --ss-mode=DocuMind --yaml-file=docs/.sourcesage_releasenotes_iris.yml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.git | ||
__pycache__ | ||
LICENSE | ||
output.md | ||
assets | ||
Style-Bert-VITS2 | ||
output | ||
streamlit | ||
SourceSage.md | ||
data | ||
.gitignore | ||
.SourceSageignore | ||
*.png | ||
Changelog | ||
SourceSageAssets | ||
SourceSageAssetsDemo | ||
__pycache__ | ||
.pyc | ||
**/__pycache__/** | ||
modules\__pycache__ | ||
.svg | ||
sourcesage.egg-info | ||
.pytest_cache | ||
dist | ||
build | ||
.env | ||
example | ||
|
||
.gaiah.md | ||
.Gaiah.md | ||
tmp.md | ||
tmp2.md | ||
.SourceSageAssets | ||
tests | ||
template | ||
aira.egg-info | ||
aira.Gaiah.md | ||
README_template.md | ||
output | ||
.harmon_ai | ||
pegasus_surf.egg-info | ||
.aira | ||
|
||
docs | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
litellm | ||
PyGithub | ||
google-generativeai | ||
loguru | ||
pydantic-settings | ||
pyyaml | ||
sourcesage | ||
matplotlib | ||
scipy | ||
scikit-learn | ||
webcolors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import sys | ||
import os | ||
|
||
# Add the parent directory of 'scripts' to the Python path | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
|
||
from loguru import logger | ||
from config import get_settings | ||
from services.llm_service import LLMService | ||
from services.github_service import GitHubService | ||
from services.git_service import GitService | ||
from utils.diff_utils import DiffUtils, create_comment | ||
from utils.patch_utils import apply_patch, get_patch_file_path | ||
|
||
class SuggestionApplier: | ||
def __init__(self): | ||
self.settings = get_settings() | ||
self.llm_service = LLMService() | ||
self.github_service = GitHubService() | ||
self.git_service = GitService() | ||
# self.allowed_users = self.settings.ALLOWED_USERS # 設定から許可されたユーザーのリストを取得 | ||
|
||
def run(self): | ||
logger.info("変更提案の適用処理を開始します。") | ||
|
||
issue = self.github_service.get_issue() | ||
all_comments = self.github_service.get_comments(issue) | ||
|
||
# コメントユーザーの一覧を表示 | ||
self._display_comment_users(all_comments) | ||
|
||
# 許可されたユーザーのコメントのみをフィルタリング | ||
# comments = self._filter_allowed_comments(all_comments) | ||
comments = all_comments | ||
|
||
if not self._validate_comments(comments): | ||
return | ||
|
||
previous_comment = self._find_previous_bot_comment(comments) | ||
if not previous_comment: | ||
logger.error("Error: github-actions[bot] のコメントが見つかりませんでした。") | ||
raise ValueError("github-actions[bot] のコメントが見つかりません") | ||
|
||
print(previous_comment.body) | ||
diffs = DiffUtils.extract_diff(previous_comment.body) | ||
if diffs is None: | ||
logger.error("有効なdiffを抽出できませんでした。処理を終了します。") | ||
return | ||
|
||
try: | ||
modified_files = self._process_diffs(diffs) | ||
self._create_pull_request(issue, modified_files) | ||
except Exception as e: | ||
logger.error(f"エラーが発生しました: {str(e)}") | ||
raise | ||
|
||
# def _filter_allowed_comments(self, comments): | ||
# """許可されたユーザーのコメントのみをフィルタリングする""" | ||
# return [comment for comment in comments if comment.user.login in self.allowed_users] | ||
|
||
def _display_comment_users(self, comments): | ||
"""コメントをしているユーザーの一覧を表示する""" | ||
user_list = list(set(comment.user.login for comment in comments)) | ||
logger.info(f"コメントをしているユーザーの一覧:") | ||
for user in user_list: | ||
logger.info(f"- {user}") | ||
|
||
def _validate_comments(self, comments): | ||
comment_count = len(comments) | ||
logger.info(f"イシュー #{self.settings.ISSUE_NUMBER} のコメントを {comment_count}件取得しました。") | ||
|
||
if comment_count == 0 or comments[-1].body.strip().lower() != "ok": | ||
logger.warning("最後のコメントが 'ok' ではありません。処理を終了します。") | ||
# return False | ||
return True | ||
|
||
logger.info("'ok' コメントを確認しました。") | ||
return True | ||
|
||
def _find_previous_bot_comment(self, comments, bot_name="github-actions[bot]"): | ||
logger.info("直前の github-actions[bot] のコメントを探しています。") | ||
return next((comment for comment in reversed(comments[:-1]) if comment.user.login == "Sunwood-ai-labs"), None) | ||
|
||
def _process_diffs(self, diffs): | ||
modified_files = [] | ||
for file_path, diff_content in diffs.items(): | ||
logger.info(f"{file_path} のパッチ適用を試みます。") | ||
patch_file_path = get_patch_file_path(file_path) | ||
with open(patch_file_path, 'w', encoding='utf-8') as f: | ||
f.write(diff_content) | ||
print(diff_content) | ||
if apply_patch(patch_file_path, file_path): | ||
modified_files.append(file_path) | ||
else: | ||
logger.info(f"{file_path} のパッチ適用に失敗しました。LLMを使用して変更を生成します。") | ||
self._apply_llm_changes(file_path, diff_content) | ||
modified_files.append(file_path) | ||
return modified_files | ||
|
||
def _apply_llm_changes(self, file_path, diff_content): | ||
with open(file_path, "r", encoding="utf-8") as f: | ||
original_content = f.read() | ||
modified_content = self.llm_service.apply_diff(original_content, diff_content) | ||
with open(file_path, "w", encoding="utf-8") as f: | ||
f.write(modified_content) | ||
|
||
def _create_pull_request(self, issue, modified_files): | ||
branch_name = f"suggestion-issue-{self.settings.ISSUE_NUMBER}" | ||
self.git_service.setup_credentials() | ||
self.git_service.create_branch(branch_name) | ||
self.git_service.commit_changes(modified_files, f"🤖 #{self.settings.ISSUE_NUMBER} の提案を適用") | ||
self.git_service.push_changes(branch_name) | ||
|
||
comment = create_comment(modified_files, {file: open(file, "r").read() for file in modified_files}) | ||
self.github_service.add_comment(issue, comment) | ||
logger.info(f"イシュー #{issue.number} にコメントを追加しました。") | ||
|
||
pr_title = f"イシュー #{self.settings.ISSUE_NUMBER} の提案" | ||
pr_body = f"このPRはイシュー #{self.settings.ISSUE_NUMBER} の提案を適用しています。" | ||
self.github_service.create_pull_request(pr_title, pr_body, branch_name) | ||
|
||
def main(): | ||
applier = SuggestionApplier() | ||
applier.run() | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.