From d8133bbc8c2c1962b22eb4f1f6987facc53094a0 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Mon, 26 Jan 2026 23:03:23 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=B3=E3=83=97=E3=83=88?= =?UTF-8?q?=E3=82=92=E3=83=94=E3=83=A5=E3=82=A2=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/en/agents/default/ai-reviewer.md | 20 - .../global/en/agents/default/architect.md | 60 --- resources/global/en/agents/default/coder.md | 39 -- resources/global/en/agents/default/planner.md | 23 -- .../global/en/agents/default/security.md | 16 - .../global/en/agents/default/supervisor.md | 19 - resources/global/en/workflows/default.yaml | 173 +++++++-- .../global/ja/agents/default/ai-reviewer.md | 20 - .../global/ja/agents/default/architect.md | 60 --- resources/global/ja/agents/default/coder.md | 42 +-- resources/global/ja/agents/default/planner.md | 23 -- .../global/ja/agents/default/security.md | 16 - .../global/ja/agents/default/supervisor.md | 19 - resources/global/ja/workflows/default.yaml | 345 ++++++++++++++++-- src/agents/runner.ts | 18 +- src/config/workflowLoader.ts | 1 + src/models/schemas.ts | 1 + src/models/types.ts | 2 + src/workflow/engine.ts | 1 + src/workflow/instruction-builder.ts | 5 + 20 files changed, 481 insertions(+), 422 deletions(-) diff --git a/resources/global/en/agents/default/ai-reviewer.md b/resources/global/en/agents/default/ai-reviewer.md index 66f0db2..dfc065e 100644 --- a/resources/global/en/agents/default/ai-reviewer.md +++ b/resources/global/en/agents/default/ai-reviewer.md @@ -107,26 +107,6 @@ AI-generated code has unique characteristics: | Alternatives considered | Were other approaches evaluated? | | Assumptions explicit | Are assumptions stated and reasonable? | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Incorrect assumptions (affecting behavior) | REJECT | -| Plausible-but-wrong code | REJECT | -| Significant context mismatch with codebase | REJECT | -| Scope creep | APPROVE (with warning noted) | -| Minor style deviations only | APPROVE | -| Code fits context and works | APPROVE | - -**Note:** Scope creep is noted as a warning but doesn't warrant REJECT alone. Some tasks require large changes. - -## Output Format - -| Situation | Tag | -|-----------|-----| -| No AI-specific issues | `[AI_REVIEW:APPROVE]` | -| Issues found | `[AI_REVIEW:REJECT]` | - ## Important **Focus on AI-specific issues.** Don't duplicate what Architect or Security reviewers will check. diff --git a/resources/global/en/agents/default/architect.md b/resources/global/en/agents/default/architect.md index 608b9fe..2d3ce4f 100644 --- a/resources/global/en/agents/default/architect.md +++ b/resources/global/en/agents/default/architect.md @@ -268,66 +268,6 @@ Alternatives: **Point**: Rather than repeating "fix this again", step back and suggest a different path. -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Structural issues | REJECT | -| Design principle violations | REJECT | -| Security issues | REJECT | -| Insufficient tests | REJECT | -| Improvements needed (non-blocking but should be addressed) | IMPROVE | -| No issues | APPROVE | - -**How to use IMPROVE:** -- Design is acceptable but there are points that could be better -- Minor issues you want fixed before proceeding to next step -- Examples: naming improvements, small refactoring, adding comments - -## Output Format - -| Situation | Tag | -|-----------|-----| -| No issues | `[ARCHITECT:APPROVE]` | -| Improvements needed (minor) | `[ARCHITECT:IMPROVE]` | -| Issues require fixes | `[ARCHITECT:REJECT]` | - -### Output Examples - -**REJECT case:** - -``` -[ARCHITECT:REJECT] - -### Issues - -1. **File Size Exceeded** - - Location: `src/services/user.ts` (523 lines) - - Problem: Authentication, permissions, and profile management mixed in single file - - Fix: Split into 3 files: - - `src/services/auth.ts` - Authentication - - `src/services/permission.ts` - Permissions - - `src/services/profile.ts` - Profile - -2. **Fallback Value Overuse** - - Location: `src/api/handler.ts:42` - - Problem: `user.name ?? 'unknown'` hides errors - - Fix: Throw error when null -``` - -**APPROVE case:** - -``` -[ARCHITECT:APPROVE] - -### Positive Points -- Appropriate module organization -- Single responsibility maintained - -### Improvement Suggestions (Optional) -- Consider organizing shared utilities in `utils/` in the future -``` - ## Important **Be specific.** These are prohibited: diff --git a/resources/global/en/agents/default/coder.md b/resources/global/en/agents/default/coder.md index 1aa84a7..a905df2 100644 --- a/resources/global/en/agents/default/coder.md +++ b/resources/global/en/agents/default/coder.md @@ -144,42 +144,3 @@ Perform self-check after implementation. - **console.log** - Don't leave in production code - **Hardcoded secrets** -## Output Format - -Always include these tags when work is complete: - -| Situation | Tag | -|-----------|-----| -| Implementation complete | `[CODER:DONE]` | -| Architect's feedback addressed | `[CODER:FIXED]` | -| Cannot decide/insufficient info | `[CODER:BLOCKED]` | - -**Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - -### Output Examples - -**On implementation complete:** -``` -Implementation complete. -- Created: `src/auth/service.ts`, `tests/auth.test.ts` -- Modified: `src/routes.ts` - -[CODER:DONE] -``` - -**On blocked:** -``` -[CODER:BLOCKED] -Reason: Cannot implement because DB schema is undefined -Required info: users table structure -``` - -**On fix complete:** -``` -Fixed 3 issues from Architect. -- Added type definitions -- Fixed error handling -- Added test cases - -[CODER:FIXED] -``` diff --git a/resources/global/en/agents/default/planner.md b/resources/global/en/agents/default/planner.md index 48373c7..ebed782 100644 --- a/resources/global/en/agents/default/planner.md +++ b/resources/global/en/agents/default/planner.md @@ -48,29 +48,6 @@ Determine the implementation direction: | Requirements are clear and implementable | DONE | | Requirements are unclear, insufficient info | BLOCKED | -## Output Format - -| Situation | Tag | -|-----------|-----| -| Analysis complete | `[PLANNER:DONE]` | -| Insufficient info | `[PLANNER:BLOCKED]` | - -### DONE Output Structure - -``` -[PLANNER:DONE] -``` - -### BLOCKED Output Structure - -``` -[PLANNER:BLOCKED] - -Clarifications needed: -- {Question 1} -- {Question 2} -``` - ## Important **Keep analysis simple.** Overly detailed plans are unnecessary. Provide enough direction for Coder to proceed with implementation. diff --git a/resources/global/en/agents/default/security.md b/resources/global/en/agents/default/security.md index 4eba245..581f555 100644 --- a/resources/global/en/agents/default/security.md +++ b/resources/global/en/agents/default/security.md @@ -170,22 +170,6 @@ if (!safePath.startsWith(path.resolve(baseDir))) { | A09 Logging Failures | Security logging | | A10 SSRF | Server-side requests | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Critical vulnerability (Immediate REJECT) | REJECT | -| Medium severity vulnerability | REJECT | -| Minor issues/warnings only | APPROVE (note warnings) | -| No security issues | APPROVE | - -## Output Format - -| Situation | Tag | -|-----------|-----| -| No security issues | `[SECURITY:APPROVE]` | -| Vulnerabilities require fixes | `[SECURITY:REJECT]` | - ## Important **Don't miss anything**: Security vulnerabilities get exploited in production. One oversight can lead to a critical incident. diff --git a/resources/global/en/agents/default/supervisor.md b/resources/global/en/agents/default/supervisor.md index e8864d6..88e7770 100644 --- a/resources/global/en/agents/default/supervisor.md +++ b/resources/global/en/agents/default/supervisor.md @@ -132,25 +132,6 @@ Check: | console.log | Forgotten debug output | | Skipped tests | `@Disabled`, `.skip()` | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Requirements not met | REJECT | -| Tests failing | REJECT | -| Build fails | REJECT | -| Workarounds remaining | REJECT | -| All OK | APPROVE | - -**Principle**: When in doubt, REJECT. Don't give ambiguous approval. - -## Output Format - -| Situation | Tag | -|-----------|-----| -| Final approval | `[SUPERVISOR:APPROVE]` | -| Return for fixes | `[SUPERVISOR:REJECT]` | - ## Important - **Actually run**: Don't just look at files, execute and verify diff --git a/resources/global/en/workflows/default.yaml b/resources/global/en/workflows/default.yaml index bf8f58a..81130be 100644 --- a/resources/global/en/workflows/default.yaml +++ b/resources/global/en/workflows/default.yaml @@ -18,6 +18,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Output analysis results with the following tags: + - [PLANNER:DONE] Analysis complete + - [PLANNER:BLOCKED] Insufficient info (list clarifications needed) instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -67,9 +73,6 @@ steps: ## Clarifications Needed (if any) - {Unclear points or items requiring confirmation} ``` - - Output [PLANNER:DONE] when complete. - Output [PLANNER:BLOCKED] if requirements are unclear. pass_previous_response: true transitions: - condition: done @@ -88,6 +91,14 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Always include these tags when work is complete: + - [CODER:DONE] Implementation complete + - [CODER:BLOCKED] Cannot decide/insufficient info + + **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -140,9 +151,6 @@ steps: - **Options Considered**: {List of options} - **Reason**: {Why this option was chosen} ``` - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed (returns to plan). transitions: - condition: done next_step: review @@ -157,6 +165,58 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## Judgment Criteria + + | Situation | Judgment | + |-----------|----------| + | Structural issues | REJECT | + | Design principle violations | REJECT | + | Security issues | REJECT | + | Insufficient tests | REJECT | + | Improvements needed (non-blocking but should be addressed) | IMPROVE | + | No issues | APPROVE | + + **How to use IMPROVE:** + - Design is acceptable but there are points that could be better + - Minor issues you want fixed before proceeding to next step + - Examples: naming improvements, small refactoring, adding comments + + ## Status Output Format + + Output review results with the following tags: + - [ARCHITECT:APPROVE] No issues + - [ARCHITECT:IMPROVE] Minor improvements needed + - [ARCHITECT:REJECT] Structural changes required + + ### Output Examples + + **REJECT case:** + ``` + [ARCHITECT:REJECT] + + ### Issues + + 1. **File Size Exceeded** + - Location: `src/services/user.ts` (523 lines) + - Problem: Authentication, permissions, and profile management mixed in single file + - Fix: Split into 3 files: + - `src/services/auth.ts` - Authentication + - `src/services/permission.ts` - Permissions + - `src/services/profile.ts` - Profile + ``` + + **APPROVE case:** + ``` + [ARCHITECT:APPROVE] + + ### Positive Points + - Appropriate module organization + - Single responsibility maintained + + ### Improvement Suggestions (Optional) + - Consider organizing shared utilities in `utils/` in the future + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -175,10 +235,7 @@ steps: ## Instructions Focus on **architecture and design** review. Do NOT review AI-specific issues (that's the next step). - Review the changes and provide feedback: - - [ARCHITECT:APPROVE] if no issues - - [ARCHITECT:IMPROVE] if minor improvements needed - - [ARCHITECT:REJECT] if structural changes are needed (list specific issues) + Review the changes and provide feedback. **Report output:** Output to the `Report File` specified above. - If file does not exist: Create new file @@ -230,6 +287,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Always include these tags when work is complete: + - [CODER:DONE] Improvements complete + - [CODER:BLOCKED] Cannot decide/insufficient info instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -254,8 +317,6 @@ steps: - Adding/fixing comments - Code organization - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed. pass_previous_response: true transitions: - condition: done @@ -271,6 +332,25 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## Judgment Criteria + + | Situation | Judgment | + |-----------|----------| + | Incorrect assumptions (affecting behavior) | REJECT | + | Plausible-but-wrong code | REJECT | + | Significant context mismatch with codebase | REJECT | + | Scope creep | APPROVE (with warning noted) | + | Minor style deviations only | APPROVE | + | Code fits context and works | APPROVE | + + **Note:** Scope creep is noted as a warning but doesn't warrant REJECT alone. Some tasks require large changes. + + ## Status Output Format + + Output review results with the following tags: + - [AI_REVIEW:APPROVE] No AI-specific issues + - [AI_REVIEW:REJECT] Issues found instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -293,10 +373,6 @@ steps: - Context fit with existing codebase - Scope creep detection - Include: - - [AI_REVIEW:APPROVE] if no AI-specific issues found - - [AI_REVIEW:REJECT] if issues detected (list specific problems) - **Report output:** Output to the `Report File` specified above. - If file does not exist: Create new file - If file exists: Append with `## Iteration {iteration}` section @@ -344,6 +420,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Always include these tags when work is complete: + - [CODER:DONE] Fixes complete + - [CODER:BLOCKED] Cannot decide/insufficient info instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -366,8 +448,6 @@ steps: - Aligning with existing codebase patterns - Removing scope creep - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed. pass_previous_response: true transitions: - condition: done @@ -383,6 +463,21 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## Judgment Criteria + + | Situation | Judgment | + |-----------|----------| + | Critical vulnerability (Immediate REJECT) | REJECT | + | Medium severity vulnerability | REJECT | + | Minor issues/warnings only | APPROVE (note warnings) | + | No security issues | APPROVE | + + ## Status Output Format + + Output review results with the following tags: + - [SECURITY:APPROVE] No security issues + - [SECURITY:REJECT] Vulnerabilities require fixes instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -405,10 +500,6 @@ steps: - Data exposure risks - Cryptographic weaknesses - Include: - - [SECURITY:APPROVE] if no security issues found - - [SECURITY:REJECT] if vulnerabilities detected (list specific issues) - **Report output:** Output to the `Report File` specified above. - If file does not exist: Create new file - If file exists: Append with `## Iteration {iteration}` section @@ -459,6 +550,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Always include these tags when work is complete: + - [CODER:DONE] Security fixes complete + - [CODER:BLOCKED] Cannot decide/insufficient info instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -477,8 +574,6 @@ steps: **Important**: Fix the vulnerabilities identified in the security review. Security issues require highest priority. - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed. pass_previous_response: true transitions: - condition: done @@ -497,6 +592,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Status Output Format + + Always include these tags when work is complete: + - [CODER:DONE] Fixes complete + - [CODER:BLOCKED] Cannot decide/insufficient info instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -516,8 +617,6 @@ steps: The "Original User Request" is reference information, not the latest instruction. Review the session conversation history and fix the issues raised by the Architect. - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed. pass_previous_response: true transitions: - condition: done @@ -534,6 +633,24 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## Judgment Criteria + + | Situation | Judgment | + |-----------|----------| + | Requirements not met | REJECT | + | Tests failing | REJECT | + | Build fails | REJECT | + | Workarounds remaining | REJECT | + | All OK | APPROVE | + + **Principle**: When in doubt, REJECT. Don't give ambiguous approval. + + ## Status Output Format + + Output verification results with the following tags: + - [SUPERVISOR:APPROVE] if ready to merge + - [SUPERVISOR:REJECT] if issues found (specify the issues) instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -619,10 +736,6 @@ steps: npm run build ``` ``` - - Output: - - [SUPERVISOR:APPROVE] if ready to merge - - [SUPERVISOR:REJECT] if issues found (specify the issues) transitions: - condition: approved next_step: COMPLETE diff --git a/resources/global/ja/agents/default/ai-reviewer.md b/resources/global/ja/agents/default/ai-reviewer.md index c223398..49b5605 100644 --- a/resources/global/ja/agents/default/ai-reviewer.md +++ b/resources/global/ja/agents/default/ai-reviewer.md @@ -107,26 +107,6 @@ AI生成コードには特有の特徴があります: | 代替案が検討されている | 他のアプローチは評価されたか? | | 仮定が明示されている | 仮定は明示的で合理的か? | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| 仮定が間違っている(動作に影響) | REJECT | -| もっともらしいが間違っているコード | REJECT | -| コードベースの文脈に重大な不整合 | REJECT | -| スコープクリープ | APPROVE(警告を付記) | -| 軽微なスタイルの逸脱のみ | APPROVE | -| コードが文脈に合い動作する | APPROVE | - -**注意:** スコープクリープは警告として記載するが、それだけでREJECTしない。大きな変更が必要なタスクもある。 - -## 出力フォーマット - -| 状況 | タグ | -|------|------| -| AI特有の問題なし | `[AI_REVIEW:APPROVE]` | -| 問題あり | `[AI_REVIEW:REJECT]` | - ## 重要 **AI特有の問題に集中する。** ArchitectやSecurityレビュアーがチェックすることを重複しない。 diff --git a/resources/global/ja/agents/default/architect.md b/resources/global/ja/agents/default/architect.md index dfc1550..17eccda 100644 --- a/resources/global/ja/agents/default/architect.md +++ b/resources/global/ja/agents/default/architect.md @@ -268,66 +268,6 @@ Vertical Slice の判定基準: **ポイント**: 「もう一度修正して」と繰り返すより、立ち止まって別の道を示す。 -## 判定基準 - -| 状況 | 判定 | -|------|------| -| 構造に問題がある | REJECT | -| 設計原則違反がある | REJECT | -| セキュリティ問題がある | REJECT | -| テストが不十分 | REJECT | -| 改善すべき点がある(ブロッキングではないが対応すべき) | IMPROVE | -| 問題なし | APPROVE | - -**IMPROVEの使い方:** -- 設計としては許容範囲だが、改善した方が良い点がある場合 -- 次のステップに進む前に修正させたい軽微な問題 -- 例: 命名の改善、小さなリファクタリング、コメント追加 - -## 出力フォーマット - -| 状況 | タグ | -|------|------| -| 問題なし | `[ARCHITECT:APPROVE]` | -| 改善すべき点がある(軽微) | `[ARCHITECT:IMPROVE]` | -| 問題があり修正が必要 | `[ARCHITECT:REJECT]` | - -### 出力例 - -**REJECT の場合:** - -``` -[ARCHITECT:REJECT] - -### 問題点 - -1. **ファイルサイズ超過** - - 場所: `src/services/user.ts` (523行) - - 問題: 単一ファイルに認証・権限・プロフィール管理が混在 - - 修正案: 以下の3ファイルに分割 - - `src/services/auth.ts` - 認証 - - `src/services/permission.ts` - 権限 - - `src/services/profile.ts` - プロフィール - -2. **フォールバック値の乱用** - - 場所: `src/api/handler.ts:42` - - 問題: `user.name ?? 'unknown'` でエラーを隠蔽 - - 修正案: nullの場合はエラーをthrowする -``` - -**APPROVE の場合:** - -``` -[ARCHITECT:APPROVE] - -### 良い点 -- モジュール分割が適切 -- 単一責務が守られている - -### 改善提案(任意) -- `utils/` 内の共通処理は将来的に整理を検討 -``` - ## 重要 **具体的に指摘する。** 以下は禁止: diff --git a/resources/global/ja/agents/default/coder.md b/resources/global/ja/agents/default/coder.md index 3e705b7..56f6fc1 100644 --- a/resources/global/ja/agents/default/coder.md +++ b/resources/global/ja/agents/default/coder.md @@ -142,44 +142,4 @@ - **any型** - 型安全を破壊しない - **オブジェクト/配列の直接変更** - スプレッド演算子で新規作成 - **console.log** - 本番コードに残さない -- **機密情報のハードコーディング** - -## 出力フォーマット - -作業完了時は必ず以下のタグを含めてください: - -| 状況 | タグ | -|------|------| -| 実装完了 | `[CODER:DONE]` | -| Architectの指摘を修正完了 | `[CODER:FIXED]` | -| 判断できない/情報不足 | `[CODER:BLOCKED]` | - -**重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - -### 出力例 - -**実装完了時:** -``` -実装完了しました。 -- 作成: `src/auth/service.ts`, `tests/auth.test.ts` -- 変更: `src/routes.ts` - -[CODER:DONE] -``` - -**ブロック時:** -``` -[CODER:BLOCKED] -理由: DBスキーマが未定義のため実装できません -必要な情報: usersテーブルの構造 -``` - -**修正完了時:** -``` -Architectの指摘3点を修正しました。 -- 型定義を追加 -- エラーハンドリングを修正 -- テストケースを追加 - -[CODER:FIXED] -``` \ No newline at end of file +- **機密情報のハードコーディング** \ No newline at end of file diff --git a/resources/global/ja/agents/default/planner.md b/resources/global/ja/agents/default/planner.md index 990edea..1a83a41 100644 --- a/resources/global/ja/agents/default/planner.md +++ b/resources/global/ja/agents/default/planner.md @@ -48,29 +48,6 @@ | 要件が明確で実装可能 | DONE | | 要件が不明確、情報不足 | BLOCKED | -## 出力フォーマット - -| 状況 | タグ | -|------|------| -| 分析完了 | `[PLANNER:DONE]` | -| 情報不足 | `[PLANNER:BLOCKED]` | - -### DONE時の出力構造 - -``` -[PLANNER:DONE] -``` - -### BLOCKED時の出力構造 - -``` -[PLANNER:BLOCKED] - -確認事項: -- {質問1} -- {質問2} -``` - ## 重要 **シンプルに分析する。** 過度に詳細な計画は不要。Coderが実装を進められる程度の方向性を示す。 diff --git a/resources/global/ja/agents/default/security.md b/resources/global/ja/agents/default/security.md index 7b61f94..939638a 100644 --- a/resources/global/ja/agents/default/security.md +++ b/resources/global/ja/agents/default/security.md @@ -170,22 +170,6 @@ if (!safePath.startsWith(path.resolve(baseDir))) { | A09 Logging Failures | セキュリティログ | | A10 SSRF | サーバーサイドリクエスト | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| 重大な脆弱性(即REJECT) | REJECT | -| 中程度の脆弱性 | REJECT | -| 軽微な問題・警告のみ | APPROVE(警告を付記) | -| セキュリティ問題なし | APPROVE | - -## 出力フォーマット - -| 状況 | タグ | -|------|------| -| セキュリティ問題なし | `[SECURITY:APPROVE]` | -| 脆弱性があり修正が必要 | `[SECURITY:REJECT]` | - ## 重要 **見逃さない**: セキュリティ脆弱性は本番で攻撃される。1つの見逃しが重大なインシデントにつながる。 diff --git a/resources/global/ja/agents/default/supervisor.md b/resources/global/ja/agents/default/supervisor.md index c811666..18d41f2 100644 --- a/resources/global/ja/agents/default/supervisor.md +++ b/resources/global/ja/agents/default/supervisor.md @@ -132,25 +132,6 @@ Architectが「正しく作られているか(Verification)」を確認す | console.log | デバッグ出力の消し忘れ | | スキップされたテスト | `@Disabled`、`.skip()` | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| 要求が満たされていない | REJECT | -| テストが失敗する | REJECT | -| ビルドが通らない | REJECT | -| その場しのぎが残っている | REJECT | -| すべて問題なし | APPROVE | - -**原則**: 疑わしきは REJECT。曖昧な承認はしない。 - -## 出力フォーマット - -| 状況 | タグ | -|------|------| -| 最終承認 | `[SUPERVISOR:APPROVE]` | -| 差し戻し | `[SUPERVISOR:REJECT]` | - ## 重要 - **実際に動かす**: ファイルを見るだけでなく、実行して確認する diff --git a/resources/global/ja/workflows/default.yaml b/resources/global/ja/workflows/default.yaml index 4feb428..4a71eab 100644 --- a/resources/global/ja/workflows/default.yaml +++ b/resources/global/ja/workflows/default.yaml @@ -18,6 +18,39 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## 判断基準 + + | 状況 | 判定 | + |------|------| + | 要件が明確で実装可能 | DONE | + | 要件が不明確、情報不足 | BLOCKED | + + ## 出力フォーマット + + | 状況 | タグ | + |------|------| + | 分析完了 | `[PLANNER:DONE]` | + | 情報不足 | `[PLANNER:BLOCKED]` | + + ### DONE時の出力構造 + + ``` + [PLANNER:DONE] + ``` + + ### BLOCKED時の出力構造 + + ``` + [PLANNER:BLOCKED] + + 確認事項: + - {質問1} + - {質問2} + ``` + 分析結果を以下のタグで出力してください: + - [PLANNER:DONE] 分析完了 + - [PLANNER:BLOCKED] 情報不足(確認事項を記載) instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -67,9 +100,6 @@ steps: ## 確認事項(あれば) - {不明点や確認が必要な点} ``` - - 完了したら [PLANNER:DONE] を出力。 - 要件が不明確な場合は [PLANNER:BLOCKED] を出力。 pass_previous_response: true transitions: - condition: done @@ -88,6 +118,46 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## 出力フォーマット + + 作業完了時は必ず以下のタグを含めてください: + + | 状況 | タグ | + |------|------| + | 実装完了 | `[CODER:DONE]` | + | Architectの指摘を修正完了 | `[CODER:FIXED]` | + | 判断できない/情報不足 | `[CODER:BLOCKED]` | + + **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 + + ### 出力例 + + **実装完了時:** + ``` + 実装完了しました。 + - 作成: `src/auth/service.ts`, `tests/auth.test.ts` + - 変更: `src/routes.ts` + + [CODER:DONE] + ``` + + **ブロック時:** + ``` + [CODER:BLOCKED] + 理由: DBスキーマが未定義のため実装できません + 必要な情報: usersテーブルの構造 + ``` + + **修正完了時:** + ``` + Architectの指摘3点を修正しました。 + - 型定義を追加 + - エラーハンドリングを修正 + - テストケースを追加 + + [CODER:FIXED] + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -140,9 +210,6 @@ steps: - **検討した選択肢**: {選択肢リスト} - **理由**: {選んだ理由} ``` - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を出力し、planに戻ります。 transitions: - condition: done next_step: review @@ -157,6 +224,58 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## 判定基準 + + | 状況 | 判定 | + |------|------| + | 構造に問題がある | REJECT | + | 設計原則違反がある | REJECT | + | セキュリティ問題がある | REJECT | + | テストが不十分 | REJECT | + | 改善すべき点がある(ブロッキングではないが対応すべき) | IMPROVE | + | 問題なし | APPROVE | + + **IMPROVEの使い方:** + - 設計としては許容範囲だが、改善した方が良い点がある場合 + - 次のステップに進む前に修正させたい軽微な問題 + - 例: 命名の改善、小さなリファクタリング、コメント追加 + + ## ステータス出力形式 + + レビュー結果を以下のタグで出力してください: + - [ARCHITECT:APPROVE] 問題なし + - [ARCHITECT:IMPROVE] 軽微な改善必要 + - [ARCHITECT:REJECT] 構造的な修正必要 + + ### 出力例 + + **REJECTの場合:** + ``` + [ARCHITECT:REJECT] + + ### 問題点 + + 1. **ファイルサイズ超過** + - 場所: `src/services/user.ts` (523行) + - 問題: 単一ファイルに認証・権限・プロフィール管理が混在 + - 修正案: 以下の3ファイルに分割 + - `src/services/auth.ts` - 認証 + - `src/services/permission.ts` - 権限 + - `src/services/profile.ts` - プロフィール + ``` + + **APPROVEの場合:** + ``` + [ARCHITECT:APPROVE] + + ### 良い点 + - モジュール分割が適切 + - 単一責務が守られている + + ### 改善提案(任意) + - `utils/` 内の共通処理は将来的に整理を検討 + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -175,10 +294,7 @@ steps: ## Instructions **アーキテクチャと設計**のレビューに集中してください。AI特有の問題はレビューしないでください(次のステップで行います)。 - 変更をレビューしてフィードバックを提供してください: - - [ARCHITECT:APPROVE] 問題なしの場合 - - [ARCHITECT:IMPROVE] 改善すべき点がある場合(軽微な修正) - - [ARCHITECT:REJECT] 構造的な変更が必要な場合(具体的な問題をリスト) + 変更をレビューしてフィードバックを提供してください。 **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 @@ -230,6 +346,46 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## 出力フォーマット + + 作業完了時は必ず以下のタグを含めてください: + + | 状況 | タグ | + |------|------| + | 実装完了 | `[CODER:DONE]` | + | Architectの指摘を修正完了 | `[CODER:FIXED]` | + | 判断できない/情報不足 | `[CODER:BLOCKED]` | + + **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 + + ### 出力例 + + **実装完了時:** + ``` + 実装完了しました。 + - 作成: `src/auth/service.ts`, `tests/auth.test.ts` + - 変更: `src/routes.ts` + + [CODER:DONE] + ``` + + **ブロック時:** + ``` + [CODER:BLOCKED] + 理由: DBスキーマが未定義のため実装できません + 必要な情報: usersテーブルの構造 + ``` + + **修正完了時:** + ``` + Architectの指摘3点を修正しました。 + - 型定義を追加 + - エラーハンドリングを修正 + - テストケースを追加 + + [CODER:FIXED] + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -253,9 +409,6 @@ steps: - 小さなリファクタリング - コメントの追加・修正 - コードの整理 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true transitions: - condition: done @@ -271,6 +424,32 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## 判定基準 + + | 状況 | 判定 | + |------|------| + | 仮定が間違っている(動作に影響) | REJECT | + | もっともらしいが間違っているコード | REJECT | + | コードベースの文脈に重大な不整合 | REJECT | + | スコープクリープ | APPROVE(警告を付記) | + | 軽微なスタイルの逸脱のみ | APPROVE | + | コードが文脈に合い動作する | APPROVE | + + **注意:** スコープクリープは警告として記載するが、それだけでREJECTしない。大きな変更が必要なタスクもある。 + + ## 出力フォーマット + + | 状況 | タグ | + |------|------| + | AI特有の問題なし | `[AI_REVIEW:APPROVE]` | + | 問題あり | `[AI_REVIEW:REJECT]` | + + ## ステータス出力形式 + + レビュー結果を以下のタグで出力してください: + - [AI_REVIEW:APPROVE] AI特有の問題なし + - [AI_REVIEW:REJECT] 問題あり instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -293,10 +472,6 @@ steps: - 既存コードベースとの適合性 - スコープクリープの検出 - 以下を含めてください: - - [AI_REVIEW:APPROVE] AI特有の問題が見つからない場合 - - [AI_REVIEW:REJECT] 問題が検出された場合(具体的な問題をリスト) - **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 @@ -344,6 +519,46 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## 出力フォーマット + + 作業完了時は必ず以下のタグを含めてください: + + | 状況 | タグ | + |------|------| + | 実装完了 | `[CODER:DONE]` | + | Architectの指摘を修正完了 | `[CODER:FIXED]` | + | 判断できない/情報不足 | `[CODER:BLOCKED]` | + + **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 + + ### 出力例 + + **実装完了時:** + ``` + 実装完了しました。 + - 作成: `src/auth/service.ts`, `tests/auth.test.ts` + - 変更: `src/routes.ts` + + [CODER:DONE] + ``` + + **ブロック時:** + ``` + [CODER:BLOCKED] + 理由: DBスキーマが未定義のため実装できません + 必要な情報: usersテーブルの構造 + ``` + + **修正完了時:** + ``` + Architectの指摘3点を修正しました。 + - 型定義を追加 + - エラーハンドリングを修正 + - テストケースを追加 + + [CODER:FIXED] + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -365,9 +580,6 @@ steps: - もっともらしいが間違っている実装の修正 - 既存コードベースのパターンとの整合 - スコープクリープの除去 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true transitions: - condition: done @@ -383,6 +595,21 @@ steps: - Grep - WebSearch - WebFetch + status_rules: | + ## 判定基準 + + | 状況 | 判定 | + |------|------| + | 重大な脆弱性(即REJECT) | REJECT | + | 中程度の脆弱性 | REJECT | + | 軽微な問題・警告のみ | APPROVE(警告を付記) | + | セキュリティ問題なし | APPROVE | + + ## ステータス出力形式 + + レビュー結果を以下のタグで出力してください: + - [SECURITY:APPROVE] セキュリティ問題なし + - [SECURITY:REJECT] 脆弱性があり修正が必要(具体的な問題をリスト) instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -405,10 +632,6 @@ steps: - データ露出リスク - 暗号化の弱点 - 以下を含めてください: - - [SECURITY:APPROVE] セキュリティ問題がない場合 - - [SECURITY:REJECT] 脆弱性が検出された場合(具体的な問題をリスト) - **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 @@ -459,6 +682,12 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## ステータス出力形式 + + 作業完了時は必ず以下のタグを含めてください: + - [CODER:DONE] セキュリティ修正完了 + - [CODER:BLOCKED] 判断できない/情報不足 instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -476,9 +705,6 @@ steps: ## Instructions **重要**: セキュリティレビューで指摘された脆弱性を修正してください。 セキュリティの問題は最優先で対応が必要です。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true transitions: - condition: done @@ -497,6 +723,46 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + ## 出力フォーマット + + 作業完了時は必ず以下のタグを含めてください: + + | 状況 | タグ | + |------|------| + | 実装完了 | `[CODER:DONE]` | + | Architectの指摘を修正完了 | `[CODER:FIXED]` | + | 判断できない/情報不足 | `[CODER:BLOCKED]` | + + **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 + + ### 出力例 + + **実装完了時:** + ``` + 実装完了しました。 + - 作成: `src/auth/service.ts`, `tests/auth.test.ts` + - 変更: `src/routes.ts` + + [CODER:DONE] + ``` + + **ブロック時:** + ``` + [CODER:BLOCKED] + 理由: DBスキーマが未定義のため実装できません + 必要な情報: usersテーブルの構造 + ``` + + **修正完了時:** + ``` + Architectの指摘3点を修正しました。 + - 型定義を追加 + - エラーハンドリングを修正 + - テストケースを追加 + + [CODER:FIXED] + ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -515,9 +781,6 @@ steps: **重要**: Architectのフィードバックに対応してください。 「Original User Request」は参考情報であり、最新の指示ではありません。 セッションの会話履歴を確認し、Architectの指摘事項を修正してください。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true transitions: - condition: done @@ -534,6 +797,24 @@ steps: - Bash - WebSearch - WebFetch + status_rules: | + + | 状況 | 判定 | + |------|------| + | 要求が満たされていない | REJECT | + | テストが失敗する | REJECT | + | ビルドが通らない | REJECT | + | その場しのぎが残っている | REJECT | + | すべて問題なし | APPROVE | + + **原則**: 疑わしきは REJECT。曖昧な承認はしない。 + + ## 出力フォーマット + + | 状況 | タグ | + |------|------| + | 最終承認 | `[SUPERVISOR:APPROVE]` | + | 差し戻し | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} @@ -619,10 +900,6 @@ steps: npm run build ``` ``` - - 出力: - - [SUPERVISOR:APPROVE] すべて完了、マージ可能 - - [SUPERVISOR:REJECT] 問題あり(具体的な問題を記載) transitions: - condition: approved next_step: COMPLETE diff --git a/src/agents/runner.ts b/src/agents/runner.ts index 0d9a7c7..91d5473 100644 --- a/src/agents/runner.ts +++ b/src/agents/runner.ts @@ -31,6 +31,8 @@ export interface RunAgentOptions { agentPath?: string; /** Allowed tools for this agent run */ allowedTools?: string[]; + /** Status output rules to inject into system prompt */ + statusRules?: string; onStream?: StreamCallback; onPermissionRequest?: PermissionHandler; onAskUserQuestion?: AskUserQuestionHandler; @@ -128,7 +130,13 @@ export async function runCustomAgent( } // Custom agent with prompt - const systemPrompt = loadAgentPrompt(agentConfig); + let systemPrompt = loadAgentPrompt(agentConfig); + + // Inject status rules if provided + if (options.statusRules) { + systemPrompt = `${systemPrompt}\n\n${options.statusRules}`; + } + const tools = allowedTools; const provider = resolveProvider(options.cwd, options, agentConfig); const model = resolveModel(options.cwd, options, agentConfig); @@ -206,7 +214,13 @@ export async function runAgent( if (!existsSync(options.agentPath)) { throw new Error(`Agent file not found: ${options.agentPath}`); } - const systemPrompt = loadAgentPromptFromPath(options.agentPath); + let systemPrompt = loadAgentPromptFromPath(options.agentPath); + + // Inject status rules if provided + if (options.statusRules) { + systemPrompt = `${systemPrompt}\n\n${options.statusRules}`; + } + const tools = options.allowedTools; const provider = resolveProvider(options.cwd, options); const model = resolveModel(options.cwd, options); diff --git a/src/config/workflowLoader.ts b/src/config/workflowLoader.ts index 5e9d3f1..313b6a8 100644 --- a/src/config/workflowLoader.ts +++ b/src/config/workflowLoader.ts @@ -70,6 +70,7 @@ function normalizeWorkflowConfig(raw: unknown, workflowDir: string): WorkflowCon provider: step.provider, model: step.model, instructionTemplate: step.instruction_template || step.instruction || '{task}', + statusRules: step.status_rules, transitions: step.transitions.map((t) => ({ condition: t.condition, nextStep: t.next_step, diff --git a/src/models/schemas.ts b/src/models/schemas.ts index bf0757f..9267d91 100644 --- a/src/models/schemas.ts +++ b/src/models/schemas.ts @@ -64,6 +64,7 @@ export const WorkflowStepRawSchema = z.object({ model: z.string().optional(), instruction: z.string().optional(), instruction_template: z.string().optional(), + status_rules: z.string().optional(), pass_previous_response: z.boolean().optional().default(true), on_no_status: OnNoStatusBehaviorSchema.optional(), transitions: z.array( diff --git a/src/models/types.ts b/src/models/types.ts index dc284e4..33bac36 100644 --- a/src/models/types.ts +++ b/src/models/types.ts @@ -69,6 +69,8 @@ export interface WorkflowStep { /** Model override for this step */ model?: string; instructionTemplate: string; + /** Status output rules to be injected into system prompt */ + statusRules?: string; transitions: WorkflowTransition[]; passPreviousResponse: boolean; /** diff --git a/src/workflow/engine.ts b/src/workflow/engine.ts index 958c8f9..2c2f0b3 100644 --- a/src/workflow/engine.ts +++ b/src/workflow/engine.ts @@ -148,6 +148,7 @@ export class WorkflowEngine extends EventEmitter { sessionId, agentPath: step.agentPath, allowedTools: step.allowedTools, + statusRules: step.statusRules, provider: step.provider, model: step.model, onStream: this.options.onStream, diff --git a/src/workflow/instruction-builder.ts b/src/workflow/instruction-builder.ts index 51ef047..8f58858 100644 --- a/src/workflow/instruction-builder.ts +++ b/src/workflow/instruction-builder.ts @@ -88,5 +88,10 @@ export function buildInstruction( instruction = instruction.replace(/\{report_dir\}/g, context.reportDir); } + // Append status_rules if present + if (step.statusRules) { + instruction = `${instruction}\n\n${step.statusRules}`; + } + return instruction; }