Compare commits

...

117 Commits

Author SHA1 Message Date
jiantw83 58479c7c6d refactor: rename Step4 to AI 排除問題過濾 2026-05-12 02:15:47 +00:00
AI Review Bot 0de87d6629 chore: update ai-review findings [skip ci] 2026-05-12 02:14:49 +00:00
jiantw83 bc914c401c docs: update TODO stage4 description and fix findings filename typo 2026-05-12 02:13:38 +00:00
jiantw83 27e471d9e0 feat: add AI false positive filtering in Step4 2026-05-12 02:12:26 +00:00
jiantw83 f1c21beed5 fix: use includes matching for exclusions location and suggestion 2026-05-12 02:10:47 +00:00
AI Review Bot 3c3019d1ab chore: update ai-review findings [skip ci] 2026-05-12 02:07:34 +00:00
jiantw83 41a8fe100f fix: clone repo before Step3/4 to read findings and exclusions from head branch 2026-05-12 02:06:24 +00:00
AI Review Bot c1c00449af chore: update ai-review findings [skip ci] 2026-05-12 01:49:18 +00:00
jiantw83 ef3654b091 chore: add exclusions for Rex false positive on git.js token handling 2026-05-12 01:48:00 +00:00
jiantw83 5d0c9fd691 docs: mark all TODO stages complete 2026-05-12 01:47:52 +00:00
jiantw83 5860588588 fix: align flow with README, add Step4 exclusions filter, fix step numbers 2026-05-12 01:47:43 +00:00
jiantw83 53a7ec7a3e refactor: reorganize TODO stages for clarity and accuracy in workflow steps
Co-authored-by: Copilot <copilot@github.com>
2026-05-12 01:47:43 +00:00
jiantw83 42241c5000 refactor: update processing steps in README for clarity and accuracy 2026-05-12 01:47:43 +00:00
jiantw83 1a12ec4e2e refactor: remove outdated AI Code configurations for Kilo, Roo, Cline, Continue, and Kade 2026-05-12 01:47:43 +00:00
AI Review Bot a90886e924 chore: update ai-review findings [skip ci] 2026-05-12 01:13:53 +00:00
jiantw83 57285ce145 fix: update askpass script to securely read token from env var 2026-05-12 01:12:32 +00:00
jiantw83 0aefa66224 feat: refactor commitAndPush to use a runner function and improve token security; add tests for git operations 2026-05-12 01:08:39 +00:00
jiantw83 66d93abe24 Merge pull request 'feat: master 不會觸發 review.yaml' (#66) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#66
2026-05-11 14:12:38 +00:00
AI Review Bot a4b87f9108 chore: update ai-review findings [skip ci] 2026-05-11 14:11:43 +00:00
jiantw83 09533ff741 feat: 改用分支名稱鎖定 review 工作流 2026-05-11 14:10:57 +00:00
AI Review Bot e217b18c62 chore: update ai-review findings [skip ci] 2026-05-11 14:09:25 +00:00
jiantw83 cd0ced1b7f feat: 同時只能有一個 review.yaml 執行 2026-05-11 14:08:40 +00:00
AI Review Bot 65cf45c558 chore: update ai-review findings [skip ci] 2026-05-11 14:06:55 +00:00
AI Review Bot 09c78835e7 chore: update ai-review findings [skip ci] 2026-05-11 14:06:17 +00:00
jiantw83 ec05ce7869 feat: 調整設定的順序 2026-05-11 14:06:09 +00:00
jiantw83 323be94a72 feat: master 不會觸發 review.yaml 2026-05-11 14:04:32 +00:00
jiantw83 0063f3282f Merge pull request 'refactor: 改用 execSync' (#65) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#65
2026-05-11 13:56:13 +00:00
AI Review Bot d7336dbe6c chore: update ai-review findings [skip ci] 2026-05-11 13:55:46 +00:00
jiantw83 c1f8aa3c72 feat: git 操作 clone 的 repo 2026-05-11 13:54:44 +00:00
jiantw83 8a28d1f1ef test: 修正路徑 2026-05-11 13:50:54 +00:00
jiantw83 d04f4dd2bb feat: 回復使用 spawnSync 執行指令 2026-05-11 13:47:40 +00:00
jiantw83 f5cf5950bd refactor: 改用 execSync 2026-05-11 13:29:31 +00:00
jiantw83 8c3d0d9a6d Merge pull request 'fix: add bash to Dockerfile dependencies' (#64) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#64
2026-05-11 10:54:08 +00:00
jiantw83 eae73092ad fix: streamline commitAndPush function by removing redundant code and improving error handling 2026-05-11 10:53:59 +00:00
jiantw83 69624a542e fix: refactor commitAndPush function to improve clarity and maintainability 2026-05-11 10:50:16 +00:00
jiantw83 8aa273b8bd fix: add bash to Dockerfile dependencies 2026-05-11 10:46:58 +00:00
jiantw83 3849bb2168 Merge pull request 'fix: switch Dockerfile base image to alpine and install dependencies using apk' (#63) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#63
2026-05-11 10:46:43 +00:00
jiantw83 00458d4eb2 fix: switch Dockerfile base image to alpine and install dependencies using apk 2026-05-11 10:43:58 +00:00
jiantw83 379938d6dc Merge pull request 'fix: Dockerfile 加入 git 安裝驗證,git.js 改回 git binary' (#62) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#62
2026-05-11 10:38:59 +00:00
jiantw83 894ece033b fix: Dockerfile 加入 git 安裝驗證,git.js 改回 git binary 2026-05-11 10:34:23 +00:00
jiantw83 5bf39966d0 Merge pull request 'fix: 換用 node:20 完整版(內建 git,不需要 apt-get)' (#61) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#61
2026-05-11 10:34:11 +00:00
jiantw83 fe2a513fbb fix: 修正 findings.json 路徑重複問題 2026-05-11 10:31:43 +00:00
jiantw83 2193bdd4d6 fix: 改回 Gitea API commit,修正 URL encode 與 JSON.stringify 2026-05-11 10:30:07 +00:00
jiantw83 af51ffacee fix: 換用 node:20 完整版(內建 git,不需要 apt-get) 2026-05-11 10:24:24 +00:00
jiantw83 3509a882e1 Merge pull request 'chore: add newline at end of TODO.md for better formatting' (#60) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#60
2026-05-11 10:19:46 +00:00
jiantw83 d9c55ca347 chore: add newline at end of TODO.md for better formatting 2026-05-11 10:18:34 +00:00
jiantw83 1d2e8236de Merge pull request 'chore: remove duplicate log assistance note in TODO.md' (#59) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#59
2026-05-11 10:18:13 +00:00
jiantw83 21fb9c1d94 fix: 改回 git commit/push,強制 Dockerfile rebuild 確保 git binary 存在 2026-05-11 10:15:36 +00:00
jiantw83 607c9b82ea debug: log content_len,改用 JSON.stringify 2026-05-11 10:13:57 +00:00
jiantw83 8acea007e7 chore: remove duplicate log assistance note in TODO.md 2026-05-11 10:12:47 +00:00
jiantw83 d8423c74b1 Merge pull request 'chore: remove test findings' (#58) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#58
2026-05-11 10:12:32 +00:00
jiantw83 953951145f chore: remove test findings 2026-05-11 10:11:56 +00:00
jiantw83 1576e783fb test 2026-05-11 10:11:40 +00:00
jiantw83 e017705c64 chore: remove test findings 2026-05-11 10:10:27 +00:00
jiantw83 94e974b5dc Merge pull request 'feat/refactor/kiro/1' (#57) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#57
2026-05-11 10:10:23 +00:00
jiantw83 5f77b83a0f debug: commitFile 加上詳細 log 2026-05-11 10:09:16 +00:00
jiantw83 da43cb02b0 chore: update ai-review findings [skip ci] 2026-05-11 10:08:57 +00:00
AI Review Bot 577a930438 chore: update ai-review findings [skip ci] 2026-05-11 10:08:26 +00:00
jiantw83 121f66b0b3 debug: git.js 加上參數 log 2026-05-11 10:06:28 +00:00
jiantw83 faa808bb5f test update 2026-05-11 10:06:05 +00:00
jiantw83 07df3ef4a5 test 2026-05-11 10:05:57 +00:00
jiantw83 a9a0b43ea5 Merge pull request 'debug: commit/push 失敗時顯示詳細錯誤' (#56) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#56
2026-05-11 10:04:49 +00:00
jiantw83 fc537958ca debug: commit/push 失敗時顯示詳細錯誤 2026-05-11 10:01:40 +00:00
jiantw83 aa8234b5c7 Merge pull request 'fix: commitAndPush 加上 await' (#55) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#55
2026-05-11 10:01:12 +00:00
jiantw83 1c321b7ba2 fix: commitAndPush 加上 await 2026-05-11 10:00:08 +00:00
jiantw83 b0f2d45c11 Merge pull request 'fix: add newline at end of TODO.md for proper formatting' (#54) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#54
2026-05-11 09:59:14 +00:00
jiantw83 710cd7308e fix: 改用 Gitea API commit findings.json,不依賴 git binary 2026-05-11 09:57:49 +00:00
jiantw83 59978c6fb5 fix: add newline at end of TODO.md for proper formatting 2026-05-11 09:56:10 +00:00
jiantw83 3fd9a7e13d Merge pull request 'feat: 階段五六 - findings commit/push 到來源分支,critical 問題 exit 1' (#53) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#53
2026-05-11 09:54:39 +00:00
jiantw83 519e04691d fix: git.js 改用 spawnSync 直接呼叫 git binary(避免 /bin/sh ENOENT) 2026-05-11 09:51:28 +00:00
jiantw83 5ae0549453 feat: 階段五六 - findings commit/push 到來源分支,critical 問題 exit 1 2026-05-11 09:49:07 +00:00
jiantw83 39cc5c932c Merge pull request 'feat: 階段四 - findings 寫入與 comment 依序發布(舊問題→非嚴重→嚴重)' (#52) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#52
2026-05-11 09:48:41 +00:00
jiantw83 81e38de649 feat: 階段四 - findings 寫入與 comment 依序發布(舊問題→非嚴重→嚴重) 2026-05-11 09:44:45 +00:00
jiantw83 255adbabe4 Merge pull request 'feat: 階段三 - AI 語意去重,失敗時降級保留所有問題' (#51) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#51
2026-05-11 09:44:10 +00:00
jiantw83 4a67dec32a feat: 階段三 - AI 語意去重,失敗時降級保留所有問題 2026-05-11 09:40:38 +00:00
jiantw83 a10fc8f176 Merge pull request 'feat/refactor/kiro/1' (#50) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#50
2026-05-11 09:40:12 +00:00
jiantw83 5c5660a34b feat: update OpenAI base URL to use OpenRouter API 2026-05-11 09:37:53 +00:00
jiantw83 6ecb018ef4 feat: update OpenAI base URL to use OpenRouter API 2026-05-11 09:37:01 +00:00
jiantw83 02529a4ec9 feat: update OpenAI API key in README.md 2026-05-11 09:34:43 +00:00
jiantw83 624a71836c feat: update AI Code Review step to use OpenAI API key and base URL 2026-05-11 09:31:01 +00:00
jiantw83 fb1254aa32 feat: refactor AI Code Review step to use OLLAMA_BASE_URL and OLLAMA_MODEL
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 09:10:20 +00:00
jiantw83 6eae6eb0ce feat: add OPENAI_MODEL parameter to AI Code Review step 2026-05-11 09:07:21 +00:00
jiantw83 ed1f2bea15 feat: update AI Code Review step to use DeepSeek API and correct API key
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 09:03:03 +00:00
jiantw83 9a11d25c00 revert: 移除 DeepSeek-R1 特別處理 2026-05-11 08:58:59 +00:00
jiantw83 64b904dd07 fix: 支援不接受 system role 的模型(DeepSeek-R1) 2026-05-11 08:56:48 +00:00
jiantw83 73c11129ab feat: update AI Code Review step to use new OpenAI base URL and model 2026-05-11 08:55:53 +00:00
jiantw83 7ba2af3384 feat: update OPENAI_MODEL to use DeepSeek-R1-Distill-Qwen-32B for improved performance 2026-05-11 08:54:13 +00:00
jiantw83 aca76f23af feat: add OPENAI_MODEL parameter to AI Code Review step 2026-05-11 08:53:03 +00:00
jiantw83 bdf8d8a797 feat: update AI Code Review step to use OpenAI API key and base URL 2026-05-11 08:47:34 +00:00
jiantw83 e183e31ce0 fix: 忽略 SSL 憑證驗證(支援自簽憑證的 Ollama/Gitea) 2026-05-11 08:34:04 +00:00
jiantw83 7b5decf46a feat: update AI Code Review step to use vars instead of secrets for improved flexibility 2026-05-11 08:31:02 +00:00
jiantw83 0609e7fe7f feat: update OLLAMA configuration to use vars instead of secrets for improved flexibility 2026-05-11 08:29:59 +00:00
jiantw83 d20300eec7 feat: format AI Code Review step for improved readability 2026-05-11 08:27:51 +00:00
jiantw83 a9163cdfda feat: update AI Code Review action inputs to use OLLAMA configuration and set default OpenAI base URL 2026-05-11 08:24:47 +00:00
jiantw83 06303f784a feat: update workflow configurations for version calculation and API integration 2026-05-11 08:20:57 +00:00
jiantw83 8fbdaadca3 feat: add target_commitish to version tagging step for improved accuracy 2026-05-11 08:14:41 +00:00
jiantw83 3d9700ade7 feat: refactor version tagging step in review workflow for improved clarity 2026-05-11 08:13:13 +00:00
jiantw83 88b326ba3c feat: refactor version handling in code review workflow for consistency 2026-05-11 08:12:12 +00:00
jiantw83 597fcf1f73 feat: refactor code review workflow to include version calculation step 2026-05-11 08:09:30 +00:00
jiantw83 0fae1f383c feat: add cache cleaning step to code review workflow 2026-05-11 08:03:19 +00:00
jiantw83 9ff521955f feat: add completion note to stage one in TODO 2026-05-11 07:59:30 +00:00
jiantw83 9b39908394 Merge pull request 'feat: 階段一 - 基本流程串接骨架' (#47) from feat/refactor/kiro/1 into feat/refactor/main
Reviewed-on: jiantw83/code-review#47
2026-05-11 07:53:38 +00:00
jiantw83 46dd8320d1 feat: 階段二 - Findings 產生與合併
- app/findings.js: 各角色分析 diff、讀取舊 findings、合併去重、等級排序
- app/main.js: 實作 Step2/Step3,log findings 統計
2026-05-11 07:52:21 +00:00
jiantw83 cdac64e224 feat: refactor code review workflow to remove tagging step and use dynamic branch reference 2026-05-11 07:46:59 +00:00
jiantw83 fa5a734166 fix: ensure 'name' parameter is included in the tag step of the code review workflow
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 07:39:29 +00:00
jiantw83 43e21d07cd feat: update AI code review workflow to use specific action URL and add tagging step
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 07:37:04 +00:00
jiantw83 bccf0e5b0b feat: add AI code review workflow configuration
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 07:29:52 +00:00
jiantw83 ec1f6c96e7 feat: 階段一 - 改用 Node.js 實作基本流程骨架
- Dockerfile: 改用 node:20-slim
- entrypoint.sh: 執行 app/main.js
- app/package.json: axios + js-yaml + openai
- app/config.js: 環境變數與 LLM 自動偵測(10 種服務)
- app/llm.js: OpenAI-compatible 統一介面
- app/gitea.js: PR diff 取得與 comment 發布
- app/roles.js: 從 prompts/roles/*.yaml 載入角色
- app/main.js: pipeline 骨架,log 每個主要階段
2026-05-11 07:24:47 +00:00
jiantw83 1324f1575d feat: 階段一 - 基本流程串接骨架
- 重寫 action.yaml:支援所有 LLM providers 的 inputs
- 重寫 Dockerfile:python:3.11-slim + git
- 重寫 entrypoint.sh:啟動 app/main.py
- app/config.py:環境變數與 LLM 自動偵測
- app/llm.py:OpenAI-compatible 統一介面
- app/gitea.py:PR diff 取得與 comment 發布
- app/roles.py:從 prompts/roles/*.yaml 載入角色
- app/main.py:pipeline 骨架,log 每個主要階段
- app/prompts/roles/:五個角色定義(Aria/Rex/Zara/Leo/Maya)
2026-05-11 07:23:06 +00:00
jiantw83 6e8b6492da Add initial TODO documentation for development phases and workflow processes
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 07:09:37 +00:00
jiantw83 2ec18843a3 Update README.md to clarify workflow behavior when severe issues are present 2026-05-11 07:08:59 +00:00
jiantw83 713289737a Update README.md to include instruction for placing prompts in ./app/prompts 2026-05-11 07:02:48 +00:00
jiantw83 d7ef864458 Refactor README.md to update section headers and enhance application setup instructions 2026-05-11 06:52:51 +00:00
jiantw83 86f30f3158 Refactor README.md to clarify workflow process and additional notes 2026-05-11 06:50:33 +00:00
jiantw83 02247899a3 Update README.md to clarify instructions for ai-review.yaml configuration 2026-05-11 06:42:30 +00:00
jiantw83 f158182229 Enhance README.md with detailed configuration examples for various AI Code Review services
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 06:40:55 +00:00
jiantw83 1a45c53aa2 Add README.md for AI Code Review Action documentation 2026-05-11 06:22:59 +00:00
24 changed files with 1316 additions and 31 deletions
+7
View File
@@ -0,0 +1,7 @@
[
{
"role": "Rex",
"location": "app/git.js",
"suggestion": "請避免將敏感資料(如 GITEA_TOKEN)直接寫入環境變數"
}
]
+114
View File
@@ -0,0 +1,114 @@
[
{
"level": "warning",
"role": "Rex",
"location": "app/git.js:14",
"suggestion": "在 cloneRepo 函數中,請確保 GIT_TOKEN 不會被寫入到檔案系統中,避免敏感資訊洩漏。",
"is_new": false
},
{
"level": "warning",
"role": "Leo",
"location": "app/findings.js:93",
"suggestion": "建議在 loadExclusions 函式中增加對於 JSON 格式的驗證,確保讀取的資料符合預期格式,避免潛在的錯誤。",
"is_new": false
},
{
"level": "warning",
"role": "Leo",
"location": "app/findings.js:40",
"suggestion": "在 applyExclusions 函式中,建議增加對於 findings 和 exclusions 參數的有效性檢查,以提高程式的健壯性。",
"is_new": false
},
{
"level": "warning",
"role": "Zara",
"location": "app/findings.js:40",
"suggestion": "在 applyExclusions 函數中,使用 Array.prototype.some 進行過濾時,可能會導致性能問題,特別是當 findings 和 exclusions 的數量都很大時。建議使用更高效的資料結構(如 HashSet)來加速查詢。",
"is_new": false
},
{
"level": "warning",
"role": "Maya",
"location": "app/findings.js:40",
"suggestion": "建議在 applyExclusions 函數中增加對 findings 內容的驗證,確保其格式正確,以提高測試的穩定性和可靠性。",
"is_new": false
},
{
"level": "info",
"role": "Leo",
"location": "README.md",
"suggestion": "建議在 README 中增加對於新功能(如排除問題過濾)的詳細說明,以便未來的維護者能快速了解其功能。",
"is_new": false
},
{
"level": "info",
"role": "Leo",
"location": "app/main.js",
"suggestion": "建議在 main 函式中增加對於每個步驟的詳細註解,讓未來的維護者能更容易理解程式邏輯。",
"is_new": false
},
{
"level": "info",
"role": "Zara",
"location": "app/findings.js:39",
"suggestion": "在過濾 findings 時,建議將過濾條件的邏輯提取為獨立函數,以提高可讀性和可維護性。",
"is_new": false
},
{
"level": "info",
"role": "Zara",
"location": "app/main.js:64",
"suggestion": "在讀取排除問題檔案時,建議考慮使用非同步方法(如 fs.promises.readFile)來避免阻塞事件循環,提升效能。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "README.md:8",
"suggestion": "建議將「如果PR問題表格中有嚴重問題,則不要讓 workflow 執行成功(exit 1)」的描述改為「如果 PR 問題表格中有嚴重問題,則不要讓 workflow 執行成功(exit 1)」以提高可讀性。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "TODO.md:4",
"suggestion": "建議將「階段四:findings 寫入與 comment 發布」的標題改為「階段四:排除問題過濾」,以更清楚地反映內容。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/config.js",
"suggestion": "建議在 EXCLUSIONS_PATH 的定義上方添加註解,說明該常數的用途,以提高可讀性。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/findings.js",
"suggestion": "建議在 loadExclusions 函數的開頭添加註解,說明該函數的用途,以提高可讀性。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/findings.js",
"suggestion": "建議在 applyExclusions 函數的開頭添加註解,說明該函數的用途,以提高可讀性。",
"is_new": false
},
{
"level": "info",
"role": "Maya",
"location": "app/findings.js:7",
"suggestion": "建議為 loadExclusions 和 applyExclusions 函數撰寫單元測試,以確保其功能正確並能處理邊界條件。",
"is_new": false
},
{
"level": "info",
"role": "Maya",
"location": "app/main.js:48",
"suggestion": "建議在每個主要步驟之後增加測試用例,以驗證每個步驟的輸出是否符合預期。",
"is_new": false
}
]
+4 -3
View File
@@ -1,10 +1,11 @@
name: CD
on:
push:
branches:
- master
jobs:
version:
name: "CD > 計算版本號"
name: 計算版本號
runs-on: ubuntu
outputs:
version: ${{ steps.version.outputs.version }}
@@ -13,14 +14,14 @@ jobs:
id: version
uses: https://gitea.jsc.idv.tw/actions/calculate-version@${{ vars.ACTION_CALCULATE_VERSION }}
release:
name: "CD > 發布專案"
name: 發布專案
runs-on: ubuntu
needs: version
steps:
- name: 發布專案
uses: akkuman/gitea-release-action@${{ vars.ACTION_RELEASE_VERSION }}
with:
tag_name: "v${{ needs.version.outputs.version }}"
tag_name: v${{ needs.version.outputs.version }}
- name: 清理成品
uses: https://gitea.jsc.idv.tw/actions/cleanup-release@${{ vars.ACTION_CLEANUP_RELEASE_VERSION }}
with:
+41
View File
@@ -0,0 +1,41 @@
name: AI
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
on:
pull_request:
branches-ignore:
- master
types: [opened, synchronize]
jobs:
version:
name: 計算版本號
runs-on: ubuntu
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: 計算版本號
id: version
uses: https://gitea.jsc.idv.tw/actions/calculate-version@${{ vars.ACTION_CALCULATE_VERSION }}
with:
IS_BETA: true
- name: 標註版本號
uses: akkuman/gitea-release-action@${{ vars.ACTION_RELEASE_VERSION }}
with:
name: code-review v${{ steps.version.outputs.version }}
tag_name: v${{ steps.version.outputs.version }}
target_commitish: ${{ github.head_ref }}
code-review:
name: 'Code Review'
runs-on: ubuntu
needs: [version]
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@v${{ needs.version.outputs.version }}
with:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: https://openrouter.ai/api/v1
permissions:
contents: write
pull-requests: write
issues: write
+12 -6
View File
@@ -1,10 +1,16 @@
FROM alpine:latest
FROM alpine
# 安裝必要的工具
RUN apk add --no-cache --no-check-certificate bash
RUN apk add --no-cache bash nodejs npm git \
&& node --version \
&& npm --version \
&& git --version
WORKDIR /action
COPY app/ /action/app/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN cd /action/app && npm install && \
chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
+165
View File
@@ -0,0 +1,165 @@
# 簡介
這是一個 AI Code Review Action。Gitea Workflow 可以使用此 Action 讓 AI 助理根據不同面向分析 Push Request 中變更的內容後,將問題分級 Commnet 到 Push Request 中。
# 流程(新 Push Request、新 Commit (排除 AI 助理的 Commit) 觸發)
1. 服務名稱、模型名稱、角色資訊(個性、符合個性的英文名稱、工作內容),Comment 到 Push Request
2. 每個角色個別分析 Git Diff 的內容產生新問題表格(問題等級、角色名稱、問題位置或行數、修改建議)
3. 讀取所有未解決的舊問題(問題檔案存在於使用此 Action 的專案固定位置)加上新問題後,去除重複產生本次 Push Request 的問題表格(PR問題表格)覆蓋問題檔案
4. 讀取排除問題檔案,用來過濾PR問題表格中不需要處理的問題
5. 從PR問題表格中取出所有舊問題,依照等級排序後 Comment 到 Push Request
6. 從PR問題表格中取出所有新問題,排除嚴重等級的問題後 Comment 到 Push Request
7. 從PR問題表格中取出所有新問題,將每個嚴重等級的問題 Comment 到 Push Request
8. Commit 問題檔案
9. 如果PR問題表格中有嚴重問題,則不要讓 workflow 執行成功(exit 1)
# 設計
1. Gitea 的相關參數如果 inputs 沒有定義,則從 ${{ gitea.* }} 取得
2. BASE_URL 如果 inputs 沒有定義,則使用預設值
3. Comment 加上些許 emoji 讓資訊有點活力
4. 盡量將應用程式放在 ./app,修改 entrypoint.sh 與 Dockerfile 讓程式可以正常運行
5. 將提示詞放到 ./app/prompts 內供程式讀取
# 使用說明
1. 在 Gitea 專案中建立 `.gitea/workflows` 資料夾
2.`.gitea/workflows` 資料夾中建立 `ai-review.yaml'
3.`ai-review.yaml` 中填入以下內容(選擇一個使用)
### 1. OpenAIOpenRouter
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
# Github (h3285@evertrust.com.tw)
# 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
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: https://openrouter.ai/api/v1
permissions:
contents: write
pull-requests: write
issues: write
```
### 2. Anthropic Claude
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
CLAUDE_API_KEY: ${{ secrets.CLAUDE_API_KEY }}
CLAUDE_BASE_URL: https://api.anthropic.com/v1
permissions:
contents: write
pull-requests: write
issues: write
```
### 3. Google Gemini
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GEMINI_BASE_URL: https://generativelanguage.googleapis.com/v1beta
permissions:
contents: write
pull-requests: write
issues: write
```
### 4. Amazon Q
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
AMAZONQ_API_KEY: ${{ secrets.AMAZONQ_API_KEY }}
AMAZONQ_BASE_URL: https://q.api.aws
permissions:
contents: write
pull-requests: write
issues: write
```
### 5. SonarQube
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONARQUBE_URL: https://sonarqube.example.com
permissions:
contents: write
pull-requests: write
issues: write
```
### - Ollama
```yaml
name: AI
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
name: 'Code Review'
runs-on: ubuntu
steps:
- name: AI Code Review
uses: https://gitea.jsc.idv.tw/jiantw83/code-review@${{ vars.ACTION_CODE_REVIEW_VERSION }}
with:
OLLAMA_BASE_URL: ${{ vars.OLLAMA_BASE_URL }}
OLLAMA_MODEL: ${{ vars.OLLAMA_MODEL }}
permissions:
contents: write
pull-requests: write
issues: write
```
+40
View File
@@ -0,0 +1,40 @@
# 開發階段 TODO
## 階段一:基本流程串接
- 目標:確保 action 可以被觸發,pipeline 各步驟依序執行,log 出每個主要階段的進入與完成。
- 驗收:log 中能看到每個階段(如「Step1: pipeline start」、「Step2: findings merge」等)明確訊息,且流程能走完(即使還沒產生 findings)。
- 完成
## 階段二:Findings 產生與合併
- 目標:各角色(style/security/performance/maintainability/testing)能產生 findings,並正確合併新舊 findings。
- 驗收:log 中能看到每個角色 findings 數量、合併後 findings 統計,並有「Step3: merged findings total=...」等訊息。
- 完成
## 階段三:AI 去重與角色確認
- 目標:嘗試呼叫 LLM 進行 findings 去重與角色確認,API 額度不足時要有降級處理 log。
- 驗收:log 中能看到 deduplication/resolution confirmation 成功或失敗(如 402),降級時有「保留所有問題」等明確訊息。
- 完成
## 階段四:AI 排除問題過濾
- 目標:讀取排除問題檔案(exclusions.json)進行規則過濾,並呼叫 AI 判斷剩餘問題是否為誤報或不適用,兩層過濾後產生最終問題清單。
- 驗收:log 中能看到排除問題檔案讀取成功或不存在的訊息、規則過濾數量變化,以及「AI 誤報過濾: N -> M 筆」或降級訊息。
- 完成
## 階段五:findings 寫入與 comment 發布
- 目標:findings.jsonl 正確寫入,comment 發布順序正確(舊問題→非嚴重→嚴重),每步有 log。
- 驗收:log 中能看到 findings.json 寫入、comment sync 的詳細訊息與順序。
- 完成
## 階段六:記憶區 commit/push 與錯誤處理
- 目標:記憶區能成功 commit/push,錯誤時有明確 log,流程結束有總結訊息。
- 驗收:log 有「persisted findings」、「commit=...」、「push=...」等訊息,錯誤時有「Runner failed: ...」等明確錯誤說明。
- 完成
## 階段七:阻擋嚴重問題 PR(第 8 點)
- 目標:如果 PR 問題表格中有嚴重(critical)問題,workflow 需直接 exit 1,不讓流程成功。
- 驗收:log 中能看到「critical 問題存在,workflow 結束(exit 1)」等明確訊息,且 workflow 狀態為失敗。
- 完成
---
所有階段驗收通過。
+153 -14
View File
@@ -1,20 +1,159 @@
name: 'Docker Action Template'
description: 'Docker Action 範本'
name: 'AI Code Review'
description: 'AI 多角色 Code Review Action,自動分析 PR 並發布問題 Comment'
author: 'Jeffery'
inputs:
runner_token:
description: 'Gitea Runner Token'
required: true
text:
description: '輸入的文字'
default: "Hello, World!"
outputs:
text:
description: '輸出的文字'
# Gitea 相關(可從 gitea context 自動取得)
GITEA_TOKEN:
description: 'Gitea API Token'
required: false
GITEA_SERVER_URL:
description: 'Gitea Server URL'
required: false
GITEA_REPOSITORY:
description: 'Gitea Repository (owner/repo)'
required: false
PR_NUMBER:
description: 'Pull Request Number'
required: false
PR_HEAD_BRANCH:
description: 'PR 來源分支'
required: false
PR_BASE_BRANCH:
description: 'PR 目標分支'
required: false
# OpenAI-compatible
OPENAI_API_KEY:
description: 'OpenAI / OpenRouter API Key'
required: false
OPENAI_BASE_URL:
description: 'OpenAI-compatible Base URL'
required: false
default: 'https://openrouter.ai/api/v1'
OPENAI_MODEL:
description: 'OpenAI-compatible Model Name'
required: false
# Anthropic Claude
CLAUDE_API_KEY:
description: 'Anthropic Claude API Key'
required: false
CLAUDE_BASE_URL:
description: 'Claude Base URL'
required: false
CLAUDE_MODEL:
description: 'Claude Model Name'
required: false
# Google Gemini
GEMINI_API_KEY:
description: 'Google Gemini API Key'
required: false
GEMINI_BASE_URL:
description: 'Gemini Base URL'
required: false
GEMINI_MODEL:
description: 'Gemini Model Name'
required: false
# Ollama
OLLAMA_BASE_URL:
description: 'Ollama Base URL'
required: false
OLLAMA_MODEL:
description: 'Ollama Model Name'
required: false
# Amazon Q
AMAZONQ_API_KEY:
description: 'Amazon Q API Key'
required: false
AMAZONQ_BASE_URL:
description: 'Amazon Q Base URL'
required: false
# SonarQube
SONARQUBE_TOKEN:
description: 'SonarQube Token'
required: false
SONARQUBE_URL:
description: 'SonarQube URL'
required: false
# Kilo Code
KILO_API_KEY:
description: 'Kilo Code API Key'
required: false
KILO_BASE_URL:
description: 'Kilo Code Base URL'
required: false
# Roo Code
ROO_API_KEY:
description: 'Roo Code API Key'
required: false
ROO_BASE_URL:
description: 'Roo Code Base URL'
required: false
# Cline
CLINE_API_KEY:
description: 'Cline API Key'
required: false
CLINE_BASE_URL:
description: 'Cline Base URL'
required: false
# Continue
CONTINUE_API_KEY:
description: 'Continue API Key'
required: false
CONTINUE_BASE_URL:
description: 'Continue Base URL'
required: false
# Kade
KADE_API_KEY:
description: 'Kade API Key'
required: false
KADE_BASE_URL:
description: 'Kade Base URL'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
RUNNER_TOKEN: ${{ inputs.runner_token || secrets.GITEA_TOKEN || secrets.RUNNER_TOKEN }}
# Gitea context(優先用 inputs,否則從 gitea context 取)
GITEA_TOKEN: ${{ inputs.GITEA_TOKEN || secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: ${{ inputs.GITEA_SERVER_URL || gitea.server_url }}
GITEA_REPOSITORY: ${{ inputs.GITEA_REPOSITORY || gitea.repository }}
PR_NUMBER: ${{ inputs.PR_NUMBER || gitea.event.pull_request.number }}
PR_HEAD_BRANCH: ${{ inputs.PR_HEAD_BRANCH || gitea.event.pull_request.head.ref }}
PR_BASE_BRANCH: ${{ inputs.PR_BASE_BRANCH || gitea.event.pull_request.base.ref }}
# LLM
OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ inputs.OPENAI_BASE_URL }}
OPENAI_MODEL: ${{ inputs.OPENAI_MODEL }}
CLAUDE_API_KEY: ${{ inputs.CLAUDE_API_KEY }}
CLAUDE_BASE_URL: ${{ inputs.CLAUDE_BASE_URL }}
CLAUDE_MODEL: ${{ inputs.CLAUDE_MODEL }}
GEMINI_API_KEY: ${{ inputs.GEMINI_API_KEY }}
GEMINI_BASE_URL: ${{ inputs.GEMINI_BASE_URL }}
GEMINI_MODEL: ${{ inputs.GEMINI_MODEL }}
OLLAMA_BASE_URL: ${{ inputs.OLLAMA_BASE_URL }}
OLLAMA_MODEL: ${{ inputs.OLLAMA_MODEL }}
AMAZONQ_API_KEY: ${{ inputs.AMAZONQ_API_KEY }}
AMAZONQ_BASE_URL: ${{ inputs.AMAZONQ_BASE_URL }}
SONARQUBE_TOKEN: ${{ inputs.SONARQUBE_TOKEN }}
SONARQUBE_URL: ${{ inputs.SONARQUBE_URL }}
KILO_API_KEY: ${{ inputs.KILO_API_KEY }}
KILO_BASE_URL: ${{ inputs.KILO_BASE_URL }}
ROO_API_KEY: ${{ inputs.ROO_API_KEY }}
ROO_BASE_URL: ${{ inputs.ROO_BASE_URL }}
CLINE_API_KEY: ${{ inputs.CLINE_API_KEY }}
CLINE_BASE_URL: ${{ inputs.CLINE_BASE_URL }}
CONTINUE_API_KEY: ${{ inputs.CONTINUE_API_KEY }}
CONTINUE_BASE_URL: ${{ inputs.CONTINUE_BASE_URL }}
KADE_API_KEY: ${{ inputs.KADE_API_KEY }}
KADE_BASE_URL: ${{ inputs.KADE_BASE_URL }}
+70
View File
@@ -0,0 +1,70 @@
import fs from 'fs';
import path from 'path';
import { postComment } from './gitea.js';
import { FINDINGS_PATH } from './config.js';
const LEVEL_EMOJI = { critical: '🔴', warning: '🟡', info: '🔵' };
const LEVEL_LABEL = { critical: '嚴重', warning: '警告', info: '建議' };
function findingRow(f) {
return `| ${LEVEL_EMOJI[f.level] || ''} ${LEVEL_LABEL[f.level] || f.level} | ${f.role} | ${f.location} | ${f.suggestion} |`;
}
function buildTable(findings) {
const rows = findings.map(findingRow).join('\n');
return `| 等級 | 審查員 | 位置 | 建議 |\n|------|--------|------|------|\n${rows}`;
}
/**
* 寫入 findings.json 到 workspace
*/
export function saveFindings(workspace, findings) {
const fullPath = path.join(workspace, FINDINGS_PATH);
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
fs.writeFileSync(fullPath, JSON.stringify(findings, null, 2), 'utf8');
console.log(` ✅ findings 寫入: ${fullPath} (${findings.length} 筆)`);
}
/**
* 發布所有舊問題 comment(一次發布,依等級排序)
*/
export async function postOldFindingsComment(findings) {
const old = findings.filter(f => !f.is_new);
if (old.length === 0) {
console.log(' 無舊問題,跳過');
return;
}
const body = `## 📋 舊有未解決問題(${old.length} 筆)\n\n${buildTable(old)}`;
await postComment(body);
console.log(` ✅ 舊問題 comment 發布 (${old.length} 筆)`);
}
/**
* 發布新問題中非 critical 的 comment(一次發布)
*/
export async function postNewNonCriticalComment(findings) {
const items = findings.filter(f => f.is_new && f.level !== 'critical');
if (items.length === 0) {
console.log(' 無新的非嚴重問題,跳過');
return;
}
const body = `## 🔍 新發現問題(${items.length} 筆)\n\n${buildTable(items)}`;
await postComment(body);
console.log(` ✅ 新問題(非嚴重)comment 發布 (${items.length} 筆)`);
}
/**
* 每個新 critical 問題各發一個 comment
*/
export async function postNewCriticalComments(findings) {
const criticals = findings.filter(f => f.is_new && f.level === 'critical');
if (criticals.length === 0) {
console.log(' 無新的嚴重問題,跳過');
return;
}
for (const f of criticals) {
const body = `## 🚨 嚴重問題\n\n| 審查員 | 位置 | 建議 |\n|--------|------|------|\n| ${f.role} | ${f.location} | ${f.suggestion} |`;
await postComment(body);
console.log(` ✅ 嚴重問題 comment 發布: [${f.role}] ${f.location}`);
}
}
+28
View File
@@ -0,0 +1,28 @@
export const GITEA_TOKEN = process.env.GITEA_TOKEN || '';
export const GITEA_SERVER_URL = process.env.GITEA_SERVER_URL || 'https://gitea.com';
export const GITEA_REPOSITORY = process.env.GITEA_REPOSITORY || '';
export const PR_NUMBER = process.env.PR_NUMBER || '';
export const PR_HEAD_BRANCH = process.env.PR_HEAD_BRANCH || '';
export const PR_BASE_BRANCH = process.env.PR_BASE_BRANCH || '';
export const FINDINGS_PATH = '.gitea/ai-review/findings.json';
export const EXCLUSIONS_PATH = '.gitea/ai-review/exclusions.json';
export function getLLMConfig() {
const checks = [
['openai', process.env.OPENAI_API_KEY, process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1', process.env.OPENAI_MODEL || 'gpt-4o-mini'],
['claude', process.env.CLAUDE_API_KEY, process.env.CLAUDE_BASE_URL || 'https://api.anthropic.com/v1', process.env.CLAUDE_MODEL || 'claude-3-haiku-20240307'],
['gemini', process.env.GEMINI_API_KEY, process.env.GEMINI_BASE_URL || 'https://generativelanguage.googleapis.com/v1beta', process.env.GEMINI_MODEL || 'gemini-1.5-flash'],
['ollama', 'ollama', process.env.OLLAMA_BASE_URL, process.env.OLLAMA_MODEL],
['amazonq', process.env.AMAZONQ_API_KEY, process.env.AMAZONQ_BASE_URL || 'https://q.api.aws', process.env.OPENAI_MODEL || 'amazon-q'],
['kilo', process.env.KILO_API_KEY, process.env.KILO_BASE_URL || 'https://api.kilocode.com/v1', process.env.OPENAI_MODEL || 'kilo-default'],
['roo', process.env.ROO_API_KEY, process.env.ROO_BASE_URL || 'https://api.roocode.com/v1', process.env.OPENAI_MODEL || 'roo-default'],
['cline', process.env.CLINE_API_KEY, process.env.CLINE_BASE_URL || 'https://api.cline.dev/v1', process.env.OPENAI_MODEL || 'cline-default'],
['continue', process.env.CONTINUE_API_KEY, process.env.CONTINUE_BASE_URL || 'https://api.continue.dev/v1', process.env.OPENAI_MODEL || 'continue-default'],
['kade', process.env.KADE_API_KEY, process.env.KADE_BASE_URL || 'https://api.kade.dev/v1', process.env.OPENAI_MODEL || 'kade-default'],
];
for (const [provider, key, baseURL, model] of checks) {
if (key && baseURL) return { provider, apiKey: key, baseURL, model };
}
return { provider: null, apiKey: null, baseURL: null, model: null };
}
+166
View File
@@ -0,0 +1,166 @@
import fs from 'fs';
import path from 'path';
import { chatJSON } from './llm.js';
import { FINDINGS_PATH, EXCLUSIONS_PATH } from './config.js';
const LEVELS = ['critical', 'warning', 'info'];
/**
* 用單一角色分析 diff,回傳 findings 陣列
*/
export async function analyzeWithRole(role, diff) {
console.log(` [${role.name}] 開始分析...`);
const findings = await chatJSON(role.system_prompt, `以下是 Git Diff 內容:\n\n${diff}`);
// 確保每筆都有必要欄位,並標記為新問題
const valid = findings.filter(f => f.level && f.role && f.location && f.suggestion)
.map(f => ({ ...f, is_new: true }));
console.log(` [${role.name}] 找到 ${valid.length} 個問題`);
return valid;
}
/**
* 讀取舊 findings(從 workspace 的 FINDINGS_PATH
*/
export function loadOldFindings(workspace) {
const fullPath = path.join(workspace, FINDINGS_PATH);
if (!fs.existsSync(fullPath)) {
console.log(' 舊 findings 檔案不存在,視為空');
return [];
}
try {
const data = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
const old = (Array.isArray(data) ? data : []).map(f => ({ ...f, is_new: false }));
console.log(` 讀取舊 findings: ${old.length}`);
return old;
} catch (e) {
console.log(` ⚠️ 讀取舊 findings 失敗: ${e.message},視為空`);
return [];
}
}
/**
* 合併新舊 findings,以 (role + location + suggestion前50字) 為 key 去除重複
* 舊問題保留,新問題若與舊問題重複則捨棄
*/
export function mergeFindings(oldFindings, newFindings) {
const key = f => `${f.role}|${f.location}|${String(f.suggestion).slice(0, 50)}`;
const seen = new Set(oldFindings.map(key));
const deduped = newFindings.filter(f => {
if (seen.has(key(f))) return false;
seen.add(key(f));
return true;
});
const merged = [...oldFindings, ...deduped];
console.log(` 合併結果: 舊=${oldFindings.length} 新(去重後)=${deduped.length} 總計=${merged.length}`);
return merged;
}
/**
* 依等級排序(critical > warning > info
*/
export function sortByLevel(findings) {
return [...findings].sort((a, b) => LEVELS.indexOf(a.level) - LEVELS.indexOf(b.level));
}
/**
* 呼叫 LLM 進行語意去重,回傳去重後的 findings
* 失敗時降級回傳原始 findings
*/
export async function deduplicateWithAI(findings) {
if (findings.length === 0) return findings;
const systemPrompt = `你是一位程式碼審查問題去重專家。
給你一份問題清單(JSON 陣列),請移除語意重複的問題(即使描述文字不同,但指的是同一個問題)。
保留等級較高的版本,優先保留 critical > warning > info。
只回傳去重後的 JSON 陣列,不要有其他文字。`;
const userContent = `以下是問題清單,請去除語意重複的項目:\n\n${JSON.stringify(findings, null, 2)}`;
try {
const result = await chatJSON(systemPrompt, userContent);
if (Array.isArray(result) && result.length > 0) {
console.log(` AI 去重: ${findings.length} -> ${result.length}`);
return result;
}
throw new Error('AI 回傳空陣列');
} catch (e) {
const status = e.response?.status;
if (status === 402 || status === 429) {
console.log(` ⚠️ AI 去重失敗(${status} 額度/限流),降級:保留所有問題`);
} else {
console.log(` ⚠️ AI 去重失敗(${e.message}),降級:保留所有問題`);
}
return findings;
}
}
/**
* 讀取排除問題檔案(從 workspace 的 EXCLUSIONS_PATH
* 格式:[{ role, location, suggestion }],欄位可部分省略,省略表示萬用
*/
export function loadExclusions(workspace) {
const fullPath = path.join(workspace, EXCLUSIONS_PATH);
if (!fs.existsSync(fullPath)) {
console.log(' 排除問題檔案不存在,跳過過濾');
return [];
}
try {
const data = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
const exclusions = Array.isArray(data) ? data : [];
console.log(` 讀取排除問題: ${exclusions.length}`);
return exclusions;
} catch (e) {
console.log(` ⚠️ 讀取排除問題失敗: ${e.message},跳過過濾`);
return [];
}
}
/**
* 套用排除規則,過濾掉符合排除條件的 findings
* 排除條件:role/location/suggestion 皆符合(省略的欄位視為萬用)
*/
export function applyExclusions(findings, exclusions) {
if (exclusions.length === 0) return findings;
const before = findings.length;
const filtered = findings.filter(f => !exclusions.some(ex =>
(!ex.role || ex.role === f.role) &&
(!ex.location || String(f.location).includes(ex.location)) &&
(!ex.suggestion || String(f.suggestion).includes(String(ex.suggestion).slice(0, 20)))
));
console.log(` 排除過濾: ${before} -> ${filtered.length} 筆(排除 ${before - filtered.length} 筆)`);
return filtered;
}
/**
* 呼叫 AI 判斷哪些問題是誤報或不需處理,回傳需保留的 findings
* 失敗時降級回傳原始 findings
*/
export async function filterFalsePositivesWithAI(findings) {
if (findings.length === 0) return findings;
const systemPrompt = `你是一位資深程式碼審查專家,負責判斷審查問題是否為誤報或不需處理。
給你一份問題清單(JSON 陣列),每筆包含 level、role、location、suggestion。
請移除以下類型的問題:
1. 誤報:問題描述與實際程式碼不符(例如:程式碼已正確使用環境變數或 secrets,卻被標記為硬編碼敏感資料)
2. 不適用:問題在此專案情境下不需處理(例如:CI/CD action 本來就需要透過環境變數傳遞 token)
只回傳需要保留的問題 JSON 陣列,不要有其他文字。`;
const userContent = `請判斷以下問題清單,移除誤報或不需處理的問題:\n\n${JSON.stringify(findings, null, 2)}`;
try {
const result = await chatJSON(systemPrompt, userContent);
if (Array.isArray(result)) {
console.log(` AI 誤報過濾: ${findings.length} -> ${result.length}`);
return result;
}
throw new Error('AI 回傳非陣列');
} catch (e) {
const status = e.response?.status;
if (status === 402 || status === 429) {
console.log(` ⚠️ AI 誤報過濾失敗(${status} 額度/限流),降級:保留所有問題`);
} else {
console.log(` ⚠️ AI 誤報過濾失敗(${e.message}),降級:保留所有問題`);
}
return findings;
}
}
+92
View File
@@ -0,0 +1,92 @@
import { spawnSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js';
function makeRunner(spawn) {
return function run(args, cwd, env) {
const opts = { cwd, encoding: 'utf8' };
if (env) opts.env = env;
const result = spawn('git', args, opts);
if (result.error) throw result.error;
if (result.status !== 0) throw new Error((result.stderr || result.stdout || '').trim());
return (result.stdout || '').trim();
};
}
/**
* Clone PR head branch to workspace/repo (idempotent)
*/
export function cloneRepo(workspace, _spawnSync = spawnSync) {
const run = makeRunner(_spawnSync);
const baseUrl = GITEA_SERVER_URL.replace(/\/$/, '');
const remoteUrl = `${baseUrl}/${GITEA_REPOSITORY}.git`;
const repoDir = path.join(workspace, 'repo');
const askpassScript = path.join(workspace, '.git-askpass.sh');
fs.writeFileSync(askpassScript, '#!/bin/sh\necho "$GIT_TOKEN"\n', { mode: 0o700 });
const credEnv = { ...process.env, GIT_ASKPASS: askpassScript, GIT_USERNAME: 'x-token', GIT_TOKEN: GITEA_TOKEN };
try {
if (!fs.existsSync(repoDir)) {
run(['clone', '--depth=1', '--branch', PR_HEAD_BRANCH, remoteUrl, repoDir], workspace, credEnv);
console.log(` ✅ repo cloned to ${repoDir}`);
} else {
run(['fetch', 'origin', PR_HEAD_BRANCH], repoDir, credEnv);
run(['checkout', PR_HEAD_BRANCH], repoDir);
console.log(` ✅ repo already exists, fetched latest`);
}
} finally {
try { fs.unlinkSync(askpassScript); } catch {}
}
return repoDir;
}
export async function commitAndPush(workspace, _spawnSync = spawnSync) {
const run = makeRunner(_spawnSync);
const baseUrl = GITEA_SERVER_URL.replace(/\/$/, '');
const remoteUrl = `${baseUrl}/${GITEA_REPOSITORY}.git`;
const repoDir = path.join(workspace, 'repo');
// Write a temporary askpass script that reads the token from an env var,
// so the token value never appears in the script file itself
const askpassScript = path.join(workspace, '.git-askpass.sh');
fs.writeFileSync(askpassScript, '#!/bin/sh\necho "$GIT_TOKEN"\n', { mode: 0o700 });
const credEnv = { ...process.env, GIT_ASKPASS: askpassScript, GIT_USERNAME: 'x-token', GIT_TOKEN: GITEA_TOKEN };
try {
if (!fs.existsSync(repoDir)) {
run(['clone', '--depth=1', '--branch', PR_HEAD_BRANCH, remoteUrl, repoDir], workspace, credEnv);
}
run(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
run(['config', 'user.name', 'AI Review Bot'], repoDir);
run(['fetch', 'origin', PR_HEAD_BRANCH], repoDir, credEnv);
run(['checkout', PR_HEAD_BRANCH], repoDir);
// 將 findings.json 從 workspace 複製到 clone 的 repo
const srcFindings = path.join(workspace, FINDINGS_PATH);
const destFindings = path.join(repoDir, FINDINGS_PATH);
fs.mkdirSync(path.dirname(destFindings), { recursive: true });
fs.copyFileSync(srcFindings, destFindings);
run(['add', FINDINGS_PATH], repoDir);
const status = run(['status', '--porcelain'], repoDir);
if (!status) {
console.log(' findings.json 無變更,跳過 commit');
return;
}
const out = run(['commit', '-m', 'chore: update ai-review findings [skip ci]'], repoDir);
const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
run(['push', remoteUrl, PR_HEAD_BRANCH], repoDir, credEnv);
console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH}`);
} catch (e) {
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
} finally {
try { fs.unlinkSync(askpassScript); } catch {}
}
}
+93
View File
@@ -0,0 +1,93 @@
import { describe, it, before, after, beforeEach } from 'node:test';
import assert from 'node:assert/strict';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { commitAndPush } from './git.js';
// --- helpers ---
function makeTmpWorkspace() {
const ws = fs.mkdtempSync(path.join(os.tmpdir(), 'git-test-'));
// Pre-create repo dir so clone branch is skipped
fs.mkdirSync(path.join(ws, 'repo'), { recursive: true });
// Create a findings.json to copy
const findingsDir = path.join(ws, '.gitea/ai-review');
fs.mkdirSync(findingsDir, { recursive: true });
fs.writeFileSync(path.join(findingsDir, 'findings.json'), '[]');
return ws;
}
// Default stub: all commands succeed, status returns changes
function makeSpawn(overrides = {}) {
const calls = [];
const spawn = (cmd, args, opts) => {
const key = args[0];
calls.push({ cmd, args, opts });
if (overrides[key]) return overrides[key](args, opts);
if (key === 'status') return { status: 0, stdout: 'M .gitea/ai-review/findings.json', stderr: '', error: null };
if (key === 'commit') return { status: 0, stdout: '[feature-branch abc1234] chore', stderr: '', error: null };
return { status: 0, stdout: '', stderr: '', error: null };
};
spawn.calls = calls;
return spawn;
}
describe('commitAndPush', () => {
let workspace;
before(() => { workspace = makeTmpWorkspace(); });
after(() => { fs.rmSync(workspace, { recursive: true, force: true }); });
beforeEach(() => {
// Remove leftover askpass scripts between tests
for (const f of fs.readdirSync(workspace)) {
if (f.endsWith('.git-askpass.sh')) fs.unlinkSync(path.join(workspace, f));
}
});
it('does not embed token in any git command argument', async () => {
const spawn = makeSpawn();
await commitAndPush(workspace, spawn);
for (const { args } of spawn.calls) {
assert.ok(!args.join(' ').includes('test-token'), `Token leaked in git args: ${args.join(' ')}`);
}
});
it('uses GIT_ASKPASS env for network operations (fetch, push, clone)', async () => {
const spawn = makeSpawn();
await commitAndPush(workspace, spawn);
const networkOps = ['fetch', 'push', 'clone'];
const networkCalls = spawn.calls.filter(c => networkOps.includes(c.args[0]));
assert.ok(networkCalls.length > 0, 'expected at least one network git call');
for (const { args, opts } of networkCalls) {
assert.ok(opts?.env?.GIT_ASKPASS, `GIT_ASKPASS missing for git ${args[0]}`);
}
});
it('cleans up askpass script after successful run', async () => {
await commitAndPush(workspace, makeSpawn());
const leftover = fs.readdirSync(workspace).filter(f => f.endsWith('.git-askpass.sh'));
assert.equal(leftover.length, 0, 'askpass script was not cleaned up');
});
it('cleans up askpass script even when git fails', async () => {
const failSpawn = () => ({ status: 1, stdout: '', stderr: 'fatal: error', error: null });
await commitAndPush(workspace, failSpawn);
const leftover = fs.readdirSync(workspace).filter(f => f.endsWith('.git-askpass.sh'));
assert.equal(leftover.length, 0, 'askpass script was not cleaned up after failure');
});
it('skips commit when status shows no changes', async () => {
const spawn = makeSpawn({ status: () => ({ status: 0, stdout: '', stderr: '', error: null }) });
await commitAndPush(workspace, spawn);
const commitCalled = spawn.calls.some(c => c.args[0] === 'commit');
assert.equal(commitCalled, false, 'commit should not run when there are no changes');
});
it('does not throw when git command fails', async () => {
const failSpawn = () => ({ status: 1, stdout: '', stderr: 'fatal: error', error: null });
await assert.doesNotReject(() => commitAndPush(workspace, failSpawn));
});
});
+17
View File
@@ -0,0 +1,17 @@
import axios from 'axios';
import https from 'https';
import { GITEA_TOKEN, GITEA_SERVER_URL, GITEA_REPOSITORY, PR_NUMBER } from './config.js';
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
const headers = () => ({ Authorization: `token ${GITEA_TOKEN}`, 'Content-Type': 'application/json' });
const api = (path) => `${GITEA_SERVER_URL.replace(/\/$/, '')}/api/v1${path}`;
export async function getPRDiff() {
const resp = await axios.get(api(`/repos/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}.diff`), { headers: headers(), timeout: 60000, httpsAgent });
return resp.data;
}
export async function postComment(body) {
const resp = await axios.post(api(`/repos/${GITEA_REPOSITORY}/issues/${PR_NUMBER}/comments`), { body }, { headers: headers(), timeout: 30000, httpsAgent });
return resp.data;
}
+36
View File
@@ -0,0 +1,36 @@
import axios from 'axios';
import https from 'https';
import { getLLMConfig } from './config.js';
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
export async function chat(systemPrompt, userContent) {
const { provider, apiKey, baseURL, model } = getLLMConfig();
if (!provider) throw new Error('未設定任何 LLM API Key');
console.log(` [LLM] provider=${provider} model=${model}`);
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
};
if (provider === 'claude') headers['anthropic-version'] = '2023-06-01';
const resp = await axios.post(
`${baseURL.replace(/\/$/, '')}/chat/completions`,
{ model, messages: [{ role: 'system', content: systemPrompt }, { role: 'user', content: userContent }], temperature: 0.2 },
{ headers, timeout: 120000, httpsAgent }
);
return resp.data.choices[0].message.content;
}
export async function chatJSON(systemPrompt, userContent) {
try {
let text = await chat(systemPrompt, userContent);
text = text.trim().replace(/^```[^\n]*\n?/, '').replace(/```$/, '').trim();
return JSON.parse(text);
} catch (e) {
console.log(` [LLM] 解析失敗: ${e.message}`);
return [];
}
}
+125
View File
@@ -0,0 +1,125 @@
import { GITEA_REPOSITORY, PR_NUMBER, PR_HEAD_BRANCH, PR_BASE_BRANCH, getLLMConfig } from './config.js';
import { loadRoles, getRoleIntro } from './roles.js';
import { getPRDiff, postComment } from './gitea.js';
import { analyzeWithRole, loadOldFindings, mergeFindings, sortByLevel, deduplicateWithAI, loadExclusions, applyExclusions, filterFalsePositivesWithAI } from './findings.js';
import { saveFindings, postOldFindingsComment, postNewNonCriticalComment, postNewCriticalComments } from './comments.js';
import { cloneRepo, commitAndPush } from './git.js';
const WORKSPACE = process.env.GITHUB_WORKSPACE || '/workspace';
async function main() {
console.log('='.repeat(60));
console.log('🚀 Step1: Pipeline 啟動');
console.log(` repo=${GITEA_REPOSITORY} PR=#${PR_NUMBER}`);
console.log(` ${PR_HEAD_BRANCH} -> ${PR_BASE_BRANCH}`);
// 偵測 LLM
const { provider, baseURL, model } = getLLMConfig();
if (!provider) {
console.error('❌ 未設定任何 LLM API Key,請檢查 action inputs');
process.exit(1);
}
console.log(` LLM: provider=${provider} model=${model} base_url=${baseURL}`);
// 載入角色
const roles = loadRoles();
console.log(` 已載入 ${roles.length} 個角色: [${roles.map(r => r.name).join(', ')}]`);
// 取得 PR diff
let diff;
try {
diff = await getPRDiff();
console.log(` diff 長度: ${diff.length} 字元`);
} catch (e) {
console.error(` ❌ 取得 diff 失敗: ${e.message}`);
process.exit(1);
}
if (!diff.trim()) {
console.log(' ⚠️ diff 為空,無需審查');
process.exit(0);
}
// 發布角色介紹 comment
try {
const intro = getRoleIntro(roles) + `\n\n> 🔍 服務:${provider} 模型:${model}`;
await postComment(intro);
console.log(' ✅ 角色介紹 comment 發布成功');
} catch (e) {
console.log(` ⚠️ comment 發布失敗(繼續執行): ${e.message}`);
}
console.log(' Step1 完成');
// Step2: 各角色分析 diff 產生新 findings
console.log('\n📊 Step2: Findings 產生');
const newFindings = [];
for (const role of roles) {
try {
const found = await analyzeWithRole(role, diff);
newFindings.push(...found);
} catch (e) {
console.log(` ⚠️ [${role.name}] 分析失敗(跳過): ${e.message}`);
}
}
console.log(` Step2 完成: 新 findings 總計 ${newFindings.length}`);
// Step3: 讀取舊 findings,合併去重(含 AI 語意去重)
console.log('\n🔀 Step3: Findings 合併');
// Clone repo 以讀取舊 findings 與排除清單
let repoDir;
try {
repoDir = cloneRepo(WORKSPACE);
} catch (e) {
console.log(` ⚠️ clone repo 失敗(繼續執行): ${e.message}`);
}
const oldFindings = loadOldFindings(repoDir || WORKSPACE);
const mergedFindings = mergeFindings(oldFindings, newFindings);
console.log(` Step3 merged findings total=${mergedFindings.length}`);
console.log('\n🤖 Step3b: AI 語意去重');
const deduped = await deduplicateWithAI(mergedFindings);
const sorted = sortByLevel(deduped);
console.log(` Step3b dedup findings total=${sorted.length} (critical=${sorted.filter(f=>f.level==='critical').length} warning=${sorted.filter(f=>f.level==='warning').length} info=${sorted.filter(f=>f.level==='info').length})`);
// Step4: 讀取排除問題檔案,過濾 PR 問題表格,並請 AI 判斷誤報
console.log('\n🚫 Step4: AI 排除問題過濾');
const exclusions = loadExclusions(repoDir || WORKSPACE);
const ruleFiltered = applyExclusions(sorted, exclusions);
const filtered = await filterFalsePositivesWithAI(ruleFiltered);
console.log(` Step4 完成: findings total=${filtered.length}`);
// Step5: 寫入 findings.json,依序發布 comment
console.log('\n📝 Step5: Findings 寫入與 Comment 發布');
saveFindings(WORKSPACE, filtered);
try {
await postOldFindingsComment(filtered);
await postNewNonCriticalComment(filtered);
await postNewCriticalComments(filtered);
console.log(' Step5 完成');
} catch (e) {
console.log(` ⚠️ comment 發布失敗(繼續執行): ${e.message}`);
}
// Step6: commit/push findings.json 到來源分支
console.log('\n💾 Step6: 記憶區 Commit/Push');
await commitAndPush(WORKSPACE);
// Step7: 有 critical 問題則 exit 1
console.log('\n🚦 Step7: 嚴重問題檢查');
const criticalCount = filtered.filter(f => f.level === 'critical').length;
if (criticalCount > 0) {
console.log(` ❌ 發現 ${criticalCount} 個嚴重問題,workflow 結束(exit 1`);
console.log('='.repeat(60));
process.exit(1);
}
console.log(' ✅ 無嚴重問題');
console.log('\n✅ Pipeline 完成');
console.log('='.repeat(60));
}
main().catch(e => {
console.error('❌ Runner failed:', e.message);
process.exit(1);
});
+13
View File
@@ -0,0 +1,13 @@
{
"name": "ai-code-review",
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "node --test app/git.test.js"
},
"dependencies": {
"axios": "^1.6.7",
"js-yaml": "^4.1.0",
"openai": "^4.28.0"
}
}
+23
View File
@@ -0,0 +1,23 @@
name: "Leo"
role: "可維護性審查員"
personality: "有遠見、重視長期維護成本,常常思考「六個月後的自己能看懂嗎?」"
focus: "程式碼複雜度、模組化、重複程式碼、文件完整性、錯誤處理、可測試性"
system_prompt: |
你是 Leo,一位重視長期維護成本的審查員。你的工作是審查程式碼的可維護性,包含複雜度、模組化、重複程式碼、文件完整性、錯誤處理。
請分析以下 Git Diff,找出所有可維護性相關問題。
回傳 JSON 陣列,每個問題格式如下:
{
"level": "critical|warning|info",
"role": "Leo",
"location": "檔案路徑:行號 或 檔案路徑",
"suggestion": "繁體中文的具體修改建議"
}
等級定義:
- critical:嚴重影響可維護性,會造成技術債(如超長函式、完全無文件的公開 API)
- warning:建議改善的可維護性問題
- info:可選的改善建議
只回傳 JSON 陣列,不要有其他文字。如果沒有問題,回傳空陣列 []。
+23
View File
@@ -0,0 +1,23 @@
name: "Zara"
role: "效能優化專家"
personality: "追求極致效能,對任何不必要的資源消耗都感到不舒服,喜歡用數據說話"
focus: "時間複雜度、空間複雜度、資料庫查詢效率、快取策略、不必要的重複運算"
system_prompt: |
你是 Zara,一位追求極致效能的優化專家。你的工作是審查程式碼的效能問題,包含時間複雜度、空間複雜度、資料庫查詢效率、快取策略。
請分析以下 Git Diff,找出所有效能相關問題。
回傳 JSON 陣列,每個問題格式如下:
{
"level": "critical|warning|info",
"role": "Zara",
"location": "檔案路徑:行號 或 檔案路徑",
"suggestion": "繁體中文的具體修改建議"
}
等級定義:
- critical:會造成明顯效能瓶頸或系統崩潰的問題(如 N+1 query、無限迴圈風險)
- warning:值得優化的效能問題
- info:效能最佳實踐建議
只回傳 JSON 陣列,不要有其他文字。如果沒有問題,回傳空陣列 []。
+23
View File
@@ -0,0 +1,23 @@
name: "Rex"
role: "資安審查員"
personality: "謹慎、多疑、對任何潛在風險都保持高度警覺,寧可誤報也不放過漏洞"
focus: "安全漏洞、注入攻擊、敏感資料洩漏、認證授權問題、依賴套件風險"
system_prompt: |
你是 Rex,一位謹慎的資安審查員。你的工作是審查程式碼中的安全漏洞、注入攻擊風險、敏感資料洩漏、認證授權問題。
請分析以下 Git Diff,找出所有安全相關問題。
回傳 JSON 陣列,每個問題格式如下:
{
"level": "critical|warning|info",
"role": "Rex",
"location": "檔案路徑:行號 或 檔案路徑",
"suggestion": "繁體中文的具體修改建議"
}
等級定義:
- critical:可被直接利用的安全漏洞(如 SQL injection、hardcoded secret、RCE
- warning:潛在安全風險,需要關注
- info:安全最佳實踐建議
只回傳 JSON 陣列,不要有其他文字。如果沒有問題,回傳空陣列 []。
+23
View File
@@ -0,0 +1,23 @@
name: "Aria"
role: "程式碼風格審查員"
personality: "嚴謹、注重細節、對程式碼整潔度有高度要求,說話直接但不失禮貌"
focus: "程式碼風格、命名規範、格式一致性、可讀性"
system_prompt: |
你是 Aria,一位嚴謹的程式碼風格審查員。你的工作是審查程式碼的風格、命名規範、格式一致性與可讀性。
請分析以下 Git Diff,找出所有風格相關問題。
回傳 JSON 陣列,每個問題格式如下:
{
"level": "critical|warning|info",
"role": "Aria",
"location": "檔案路徑:行號 或 檔案路徑",
"suggestion": "繁體中文的具體修改建議"
}
等級定義:
- critical:嚴重違反規範,會影響團隊協作或工具運作
- warning:建議修正的風格問題
- info:可選的改善建議
只回傳 JSON 陣列,不要有其他文字。如果沒有問題,回傳空陣列 []。
+23
View File
@@ -0,0 +1,23 @@
name: "Maya"
role: "測試品質審查員"
personality: "對測試覆蓋率有執念,相信沒有測試的程式碼等於沒有完成,溫和但堅持"
focus: "測試覆蓋率、測試品質、邊界條件、錯誤情境測試、測試可讀性"
system_prompt: |
你是 Maya,一位對測試品質有高度要求的審查員。你的工作是審查程式碼的測試覆蓋率、測試品質、邊界條件處理。
請分析以下 Git Diff,找出所有測試相關問題。
回傳 JSON 陣列,每個問題格式如下:
{
"level": "critical|warning|info",
"role": "Maya",
"location": "檔案路徑:行號 或 檔案路徑",
"suggestion": "繁體中文的具體修改建議"
}
等級定義:
- critical:完全缺少測試的核心功能,或測試邏輯有嚴重錯誤
- warning:測試覆蓋不足或測試品質有待改善
- info:測試最佳實踐建議
只回傳 JSON 陣列,不要有其他文字。如果沒有問題,回傳空陣列 []。
+20
View File
@@ -0,0 +1,20 @@
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
const ROLES_DIR = '/action/app/prompts/roles';
export function loadRoles() {
return fs.readdirSync(ROLES_DIR)
.filter(f => f.endsWith('.yaml'))
.sort()
.map(f => yaml.load(fs.readFileSync(path.join(ROLES_DIR, f), 'utf8')));
}
export function getRoleIntro(roles) {
const lines = ['## 🤖 AI Code Review 團隊', ''];
for (const r of roles) {
lines.push(`- **${r.name}** (${r.role})${r.personality}`);
}
return lines.join('\n');
}
+5 -8
View File
@@ -1,11 +1,8 @@
#!/bin/bash
set -e
echo "Gitea Server Url: $GITEA_SERVER_URL"
echo "🚀 AI Code Review Action 啟動"
echo "Repository: $GITEA_REPOSITORY"
echo "PR: #$PR_NUMBER ($PR_HEAD_BRANCH -> $PR_BASE_BRANCH)"
echo "Gitea Repository: $GITEA_REPOSITORY"
echo "Gitea Runner Token: $RUNNER_TOKEN"
echo "Input Text: $INPUT_TEXT"
echo "text=$INPUT_TEXT" >> "$GITHUB_OUTPUT"
exec node /action/app/main.js