Compare commits

...

28 Commits

Author SHA1 Message Date
jiantw83 92f10c7970 Merge pull request '優化 Step2:改用 skill RPG 攻防腳色系統(新增 Mage 邏輯角色、Step3/4 套 Paladin 裁決人設)' (#15) from develop into master
CD / 計算版本號 (push) Successful in 2s
CD / 發布專案 (push) Successful in 5s
Reviewed-on: #15
2026-06-16 09:05:54 +00:00
jiantw83 ffc9038923 Merge pull request '優化 Step2:改用 skill RPG 攻防腳色系統(新增 Mage 邏輯角色、Step3/4 套 Paladin 裁決人設)' (#14) from feat/optimize-step2 into develop
Reviewed-on: #14
2026-06-16 09:04:08 +00:00
AI Review Bot 862f4e46ef chore: update ai-review findings [ai-review-bot][success]
AI / 計算版本號 (pull_request) Successful in 4s
AI / Code Review (pull_request) Successful in 10s
2026-06-16 09:03:46 +00:00
Jeffery 97888f8b22 chore(ai-review): 清空 findings
AI / 計算版本號 (pull_request) Successful in 3s
AI / Code Review (pull_request) Successful in 2m11s
2026-06-16 17:00:36 +08:00
Jeffery fa95a463f8 test(roles): 補 focus/personality 缺漏時的輸出防護測試 2026-06-16 17:00:29 +08:00
Jeffery 60001499da fix(腳色載入器): 壞角色檔改記錄警告並略過、快取解析結果並補 focus/personality 缺漏防護 2026-06-16 17:00:24 +08:00
jiantw83 07e38f9d45 Merge pull request 'feat: 前置驗證納入 git push 認證檢查' (#11) from develop into master
CD / 計算版本號 (push) Successful in 2s
CD / 發布專案 (push) Successful in 7s
Reviewed-on: #11
2026-06-16 06:23:51 +00:00
jiantw83 49f190e944 Merge pull request 'feat: implement Git integration for automated repository instruction syncing and commit management' (#131) from develop into master
Reviewed-on: #131
2026-05-21 04:00:28 +00:00
jiantw83 72701dee0a Merge pull request 'feat: add SKILL.md for triage-findings documentation' (#128) from develop into master
Reviewed-on: #128
2026-05-20 09:11:03 +00:00
jiantw83 503e50a2d0 Merge pull request 'feat: 將 ANTIGRAVITY 加入程式與技能' (#126) from develop into master
Reviewed-on: #126
2026-05-20 02:56:21 +00:00
jiantw83 dddcc9031b Merge pull request 'develop' (#124) from develop into master
Reviewed-on: #124
2026-05-18 03:32:00 +00:00
jiantw83 ace50037ba Merge pull request 'feat: 優化AI排除問題與過濾' (#122) from develop into master
Reviewed-on: #122
2026-05-18 02:59:46 +00:00
jiantw83 76eaff7788 Merge pull request '版本 0.1.6' (#120) from develop into master
Reviewed-on: #120
2026-05-15 15:57:20 +00:00
jiantw83 6ac8512dbc Merge pull request 'fix: remove GITEA_TOKEN from AI Code Review step and ensure master branch is ignored in pull requestsfix: remove GITEA_TOKEN from AI Code Review step and ensure master branch is ignored in pull requests' (#116) from develop into master
Reviewed-on: #116
2026-05-15 09:56:51 +00:00
jiantw83 3b8e942e7f Merge pull request 'feat: enhance findings and exclusions handling with repo state logging' (#114) from develop into master
Reviewed-on: #114
2026-05-15 09:52:26 +00:00
jiantw83 051457b11b Merge pull request 'fix: clarify stage seven push failures' (#112) from develop into master
Reviewed-on: #112
2026-05-15 06:55:50 +00:00
jiantw83 92f1c6fe82 Merge pull request 'fix: support wrapped exclusions schema' (#111) from develop into master
Reviewed-on: #111
2026-05-15 06:46:28 +00:00
jiantw83 27df6894a4 Merge pull request 'fix: write findings to review dir' (#110) from develop into master
Reviewed-on: #110
2026-05-15 06:25:29 +00:00
jiantw83 1afd978059 Merge pull request 'fix: stage generated review files' (#109) from develop into master
Reviewed-on: #109
2026-05-15 05:53:55 +00:00
jiantw83 146faca7cb Merge pull request 'docs: preserve original text in exclusions' (#108) from develop into master
Reviewed-on: #108
2026-05-15 04:51:23 +00:00
jiantw83 4c99247566 Merge pull request 'fix: sync codex skill assets' (#107) from develop into master
Reviewed-on: #107
2026-05-15 04:24:32 +00:00
jiantw83 81cbb83340 Merge pull request 'fix: package triage skills into the action image' (#106) from develop into master
Reviewed-on: #106
2026-05-15 04:00:55 +00:00
jiantw83 3f65b72cf0 Merge pull request 'fix: restore triage skill files and keep sync non-destructive' (#104) from develop into master
Reviewed-on: #104
2026-05-15 03:34:26 +00:00
jiantw83 2eb94c8f74 Merge pull request 'feat: 解決階段七commit失敗的問題' (#102) from develop into master
Reviewed-on: #102
2026-05-15 03:18:55 +00:00
jiantw83 6354c0987c Merge pull request 'chore: refine stage 7 json validation' (#98) from develop into master
Reviewed-on: #98
2026-05-14 02:42:13 +00:00
jiantw83 7df34eb1d0 Merge pull request '版本 0.0.4' (#97) from develop into master
Reviewed-on: #97
2026-05-13 06:31:30 +00:00
jiantw83 ca5d54882f Merge pull request '版本 0.0.2' (#94) from develop into master
Reviewed-on: #94
2026-05-13 02:43:10 +00:00
jiantw83 ca4664e0cc Merge pull request '發布 0.0.1' (#86) from develop into master
Reviewed-on: #86
2026-05-12 10:09:32 +00:00
3 changed files with 34 additions and 30 deletions
+3 -24
View File
@@ -1,30 +1,9 @@
[ [
{
"level": "critical",
"role": "Mage",
"location": "app/roles.js:30",
"suggestion": "在 `parseRoleFile` 函式中,`yaml.load(match[1])` 若遇到格式錯誤的 YAML 內容,會拋出未捕捉的例外,導致應用程式崩潰。應加入 `try-catch` 區塊來處理此潛在錯誤,確保即使角色定義檔有誤,系統也能穩定運行,例如回傳一個錯誤物件或記錄錯誤並跳過該檔案。",
"is_new": true
},
{
"level": "critical",
"role": "Rogue",
"location": "app/roles.js:30",
"suggestion": "「loadRole」函式每次被呼叫時,都會重新讀取並解析所有角色檔案。這會造成不必要的同步檔案 I/O 與 CPU 浪費,尤其當此函式被頻繁呼叫時,會嚴重阻塞事件迴圈。建議將「readRoleFiles()」的結果快取起來,讓「loadRole」直接從記憶體中查詢,避免重複讀取磁碟。",
"is_new": true
},
{ {
"level": "warning", "level": "warning",
"role": "Mage", "role": "Bard",
"location": "app/roles.js:60", "location": "app/comments.test.js:172",
"suggestion": "在 `buildAnalysisPrompt` 函式中,`role.focus` 屬性被直接用於字串模板。若角色定義檔中缺少 `focus` 欄位,此處將會顯示為 `負責「undefined」面向`,導致生成的提示語義不完整。建議在引用前檢查 `role.focus` 是否存在,或提供一個預設值,例如:`負責「${role.focus || '未定義'}」面向`。", "suggestion": "此處斷言使用了魔術字串 `/嚴重問題/`,就像樂譜中突然出現的無標記音符,雖能理解,卻少了點優雅與明確。建議將此字串提取為一個具名常數,或至少賦予一個描述性變數,以提升可讀性與未來維護的便利性,讓意圖更加清晰。",
"is_new": true
},
{
"level": "warning",
"role": "Mage",
"location": "app/roles.js:77",
"suggestion": "在 `getRoleIntro` 函式中,`r.focus` 和 `r.personality` 屬性被直接用於生成 Markdown 表格。若角色定義檔中缺少這些欄位,表格中將會顯示 `undefined`,影響可讀性與呈現品質。建議在引用前檢查這些屬性是否存在,並提供一個空字串或預設值,例如:`| **${badge}${r.name}** | ${r.focus || ''} | ${r.personality || ''} |`。",
"is_new": true "is_new": true
} }
] ]
+20 -6
View File
@@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { warn } from './log.js';
const ROLES_DIR = path.join(fileURLToPath(import.meta.url), '..', 'prompts', 'roles'); const ROLES_DIR = path.join(fileURLToPath(import.meta.url), '..', 'prompts', 'roles');
@@ -17,11 +18,24 @@ export function parseRoleFile(content) {
return { ...meta, body: match[2].trim() }; return { ...meta, body: match[2].trim() };
} }
let cachedRoles = null;
/**
* 讀取並解析所有角色 .md,結果快取於模組層級(單次程序生命週期內檔案不變)。
* 單一檔案解析失敗(壞 YAML、缺 frontmatter 等)時記錄警告並略過,不讓整個流程崩潰。
*/
function readRoleFiles() { function readRoleFiles() {
return fs.readdirSync(ROLES_DIR) if (cachedRoles) return cachedRoles;
.filter(f => f.endsWith('.md')) const roles = [];
.sort() for (const f of fs.readdirSync(ROLES_DIR).filter(f => f.endsWith('.md')).sort()) {
.map(f => parseRoleFile(fs.readFileSync(path.join(ROLES_DIR, f), 'utf8'))); try {
roles.push(parseRoleFile(fs.readFileSync(path.join(ROLES_DIR, f), 'utf8')));
} catch (e) {
warn(`角色檔解析失敗,已略過: ${f}${e.message}`);
}
}
cachedRoles = roles;
return cachedRoles;
} }
/** /**
@@ -44,7 +58,7 @@ export function loadRole(name) {
*/ */
export function buildAnalysisPrompt(role) { export function buildAnalysisPrompt(role) {
return [ return [
`你是 ${role.badge ? role.badge + ' ' : ''}${role.name},負責「${role.focus}」面向的程式碼審查(攻擊方)。`, `你是 ${role.badge ? role.badge + ' ' : ''}${role.name},負責「${role.focus || '綜合'}」面向的程式碼審查(攻擊方)。`,
role.personality ? `個性:${role.personality}` : '', role.personality ? `個性:${role.personality}` : '',
'', '',
role.body, role.body,
@@ -77,7 +91,7 @@ export function getRoleIntro(roles) {
]; ];
for (const r of roles) { for (const r of roles) {
const badge = r.badge ? `${r.badge} ` : ''; const badge = r.badge ? `${r.badge} ` : '';
lines.push(`| **${badge}${r.name}** | ${r.focus} | ${r.personality} |`); lines.push(`| **${badge}${r.name}** | ${r.focus || ''} | ${r.personality || ''} |`);
} }
return lines.join('\n'); return lines.join('\n');
} }
+11
View File
@@ -72,6 +72,11 @@ describe('buildAnalysisPrompt', () => {
assert.match(prompt, /審查重點:邊界與空值/); assert.match(prompt, /審查重點:邊界與空值/);
assert.match(prompt, /只回傳 JSON 陣列/); assert.match(prompt, /只回傳 JSON 陣列/);
}); });
it('falls back to a default when focus is missing instead of showing undefined', () => {
const prompt = buildAnalysisPrompt({ name: 'NoFocus', body: 'x' });
assert.doesNotMatch(prompt, /undefined/);
});
}); });
describe('getRoleIntro', () => { describe('getRoleIntro', () => {
@@ -80,4 +85,10 @@ describe('getRoleIntro', () => {
assert.match(intro, /🔮 Tester/); assert.match(intro, /🔮 Tester/);
assert.match(intro, /logic/); assert.match(intro, /logic/);
}); });
it('renders empty cells instead of undefined when focus/personality are missing', () => {
const intro = getRoleIntro([{ name: 'Bare' }]);
assert.match(intro, /Bare/);
assert.doesNotMatch(intro, /undefined/);
});
}); });