diff --git a/resources/global/en/workflows/default.yaml b/resources/global/en/workflows/default.yaml index 250a1bd..09af0ff 100644 --- a/resources/global/en/workflows/default.yaml +++ b/resources/global/en/workflows/default.yaml @@ -1,5 +1,15 @@ # Default TAKT Workflow # Plan -> Coder -> Architect Review -> AI Review -> Security Review -> Supervisor Approval +# +# Template Variables: +# {iteration} - Workflow-wide turn count (total steps executed across all agents) +# {max_iterations} - Maximum iterations allowed for the workflow +# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) +# {task} - Original user request +# {previous_response} - Output from the previous step +# {git_diff} - Current uncommitted changes (git diff) +# {user_inputs} - Accumulated user inputs during workflow +# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") name: default description: Standard development workflow with planning and specialized reviews @@ -55,7 +65,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: plan (Task Analysis) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/00-plan.md @@ -79,7 +90,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -155,7 +166,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: implement - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -174,7 +186,7 @@ steps: **Report output:** Output to the `Report Files` specified above. - If file does not exist: Create new file - - If file exists: Append with `## Iteration {iteration}` section + - If file exists: Append with `## Iteration {step_iteration}` section **Scope report format (create at implementation start):** ```markdown @@ -279,7 +291,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: review (Architecture Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/03-architect-review.md @@ -299,7 +312,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -382,7 +395,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: improve ## Architect Feedback (This is the latest instruction - prioritize this) @@ -463,7 +477,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: ai_review (AI-Generated Code Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/04-ai-review.md @@ -485,7 +500,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -564,7 +579,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: ai_fix ## AI Review Feedback (This is the latest instruction - prioritize this) @@ -640,7 +656,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: security_review - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/05-security-review.md @@ -662,7 +679,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -744,7 +761,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: security_fix ## Security Review Feedback (This is the latest instruction - prioritize this) @@ -813,7 +831,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix ## Architect Feedback (This is the latest instruction - prioritize this) @@ -893,7 +912,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: supervise (final verification) - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -921,7 +941,7 @@ steps: **Report output:** Output to the `Report Files` specified above. - If file does not exist: Create new file - - If file exists: Append with `## Iteration {iteration}` section + - If file exists: Append with `## Iteration {step_iteration}` section **Validation report format:** ```markdown diff --git a/resources/global/en/workflows/expert-review.yaml b/resources/global/en/workflows/expert-review.yaml index 93656fc..12f0c42 100644 --- a/resources/global/en/workflows/expert-review.yaml +++ b/resources/global/en/workflows/expert-review.yaml @@ -9,6 +9,16 @@ # Fix destination is determined by Coder based on change impact: # - fix_security: MINOR→security_review, MAJOR→cqrs_es_review # - fix_qa: MINOR→qa_review, SECURITY→security_review, MAJOR→cqrs_es_review +# +# Template Variables: +# {iteration} - Workflow-wide turn count (total steps executed across all agents) +# {max_iterations} - Maximum iterations allowed for the workflow +# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) +# {task} - Original user request +# {previous_response} - Output from the previous step +# {git_diff} - Current uncommitted changes (git diff) +# {user_inputs} - Accumulated user inputs during workflow +# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") name: expert-review description: CQRS+ES, Frontend, Security, QA Expert Review @@ -44,7 +54,8 @@ steps: | Requirements unclear | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: plan (Task Analysis) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/00-plan.md @@ -68,7 +79,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -129,7 +140,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: implement - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -148,7 +160,7 @@ steps: **Report output:** Output to the `Report Files` specified above. - If file does not exist: Create new file - - If file exists: Append with `## Iteration {iteration}` section + - If file exists: Append with `## Iteration {step_iteration}` section **Scope report format (create at implementation start):** ```markdown @@ -213,7 +225,8 @@ steps: | Design issues found | `[CQRS-ES:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: cqrs_es_review (CQRS+ES Expert Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/03-cqrs-es-review.md @@ -242,7 +255,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -302,7 +315,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix_cqrs_es ## CQRS+ES Review Feedback (This is the latest instruction - prioritize this) @@ -358,7 +372,8 @@ steps: | Design issues found | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: frontend_review (Frontend Expert Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/04-frontend-review.md @@ -387,7 +402,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -447,7 +462,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix_frontend ## Frontend Review Feedback (This is the latest instruction - prioritize this) @@ -503,7 +519,8 @@ steps: | Issues found | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: ai_review (AI-Generated Code Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/05-ai-review.md @@ -525,7 +542,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -588,7 +605,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: ai_fix ## AI Review Feedback (This is the latest instruction - prioritize this) @@ -642,7 +660,8 @@ steps: | Vulnerabilities found | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: security_review (Security Expert Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/06-security-review.md @@ -667,7 +686,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -729,7 +748,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix_security ## Security Review Feedback (This is the latest instruction - prioritize this) @@ -794,7 +814,8 @@ steps: | Quality issues found | `[QA:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: qa_review (QA Expert Review) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/07-qa-review.md @@ -820,7 +841,7 @@ steps: **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 + - If file exists: Append with `## Iteration {step_iteration}` section **Report format:** ```markdown @@ -882,7 +903,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix_qa ## QA Review Feedback (This is the latest instruction - prioritize this) @@ -951,7 +973,8 @@ steps: | Issues found | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: supervise (Final Review) - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -987,7 +1010,7 @@ steps: **Report output:** Output to the `Report Files` specified above. - If file does not exist: Create new file - - If file exists: Append with `## Iteration {iteration}` section + - If file exists: Append with `## Iteration {step_iteration}` section **Validation report format:** ```markdown @@ -1079,7 +1102,8 @@ steps: | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: fix_supervisor ## Supervisor Feedback (This is the latest instruction - prioritize this) diff --git a/resources/global/en/workflows/magi.yaml b/resources/global/en/workflows/magi.yaml index 56ee1f2..3d6cc20 100644 --- a/resources/global/en/workflows/magi.yaml +++ b/resources/global/en/workflows/magi.yaml @@ -1,6 +1,16 @@ # MAGI System Workflow # A deliberation workflow modeled after Evangelion's MAGI system # Three personas (scientist, nurturer, pragmatist) analyze from different perspectives and vote +# +# Template Variables: +# {iteration} - Workflow-wide turn count (total steps executed across all agents) +# {max_iterations} - Maximum iterations allowed for the workflow +# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) +# {task} - Original user request +# {previous_response} - Output from the previous step +# {git_diff} - Current uncommitted changes (git diff) +# {user_inputs} - Accumulated user inputs during workflow +# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") name: magi description: MAGI Deliberation System - Analyze from 3 perspectives and decide by majority diff --git a/resources/global/en/workflows/research.yaml b/resources/global/en/workflows/research.yaml index 985b888..eca538e 100644 --- a/resources/global/en/workflows/research.yaml +++ b/resources/global/en/workflows/research.yaml @@ -5,6 +5,16 @@ # Flow: # plan -> dig -> supervise -> COMPLETE (approved) # -> plan (rejected: restart from planning) +# +# Template Variables: +# {iteration} - Workflow-wide turn count (total steps executed across all agents) +# {max_iterations} - Maximum iterations allowed for the workflow +# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) +# {task} - Original user request +# {previous_response} - Output from the previous step +# {git_diff} - Current uncommitted changes (git diff) +# {user_inputs} - Accumulated user inputs during workflow +# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") name: research description: Research workflow - autonomously executes research without asking questions @@ -49,7 +59,8 @@ steps: ``` instruction_template: | ## Workflow Status - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: plan ## Research Request @@ -111,7 +122,8 @@ steps: ``` instruction_template: | ## Workflow Status - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: dig ## Original Research Request @@ -188,7 +200,8 @@ steps: ``` instruction_template: | ## Workflow Status - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations} (workflow-wide) + - Step Iteration: {step_iteration} (times this step has run) - Step: supervise (research quality evaluation) ## Original Research Request diff --git a/resources/global/ja/workflows/default.yaml b/resources/global/ja/workflows/default.yaml index 98777fe..e5868f8 100644 --- a/resources/global/ja/workflows/default.yaml +++ b/resources/global/ja/workflows/default.yaml @@ -1,5 +1,15 @@ # Default TAKT Workflow # Plan -> Coder -> Architect Review -> AI Review -> Security Review -> Supervisor Approval +# +# Template Variables: +# {iteration} - Workflow-wide turn count (total steps executed across all agents) +# {max_iterations} - Maximum iterations allowed for the workflow +# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) +# {task} - Original user request +# {previous_response} - Output from the previous step +# {git_diff} - Current uncommitted changes (git diff) +# {user_inputs} - Accumulated user inputs during workflow +# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") name: default description: Standard development workflow with planning and specialized reviews @@ -55,7 +65,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: plan (タスク分析) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/00-plan.md @@ -79,7 +90,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -155,7 +166,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: implement - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -174,7 +186,7 @@ steps: **レポート出力:** 上記の `Report Files` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **Scopeレポートフォーマット(実装開始時に作成):** ```markdown @@ -279,7 +291,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: review (アーキテクチャレビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/03-architect-review.md @@ -299,7 +312,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -382,7 +395,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: improve ## Architect Feedback (これが最新の指示です - 優先して対応してください) @@ -462,7 +476,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: ai_review (AI生成コードレビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/04-ai-review.md @@ -484,7 +499,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -563,7 +578,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: ai_fix ## AI Review Feedback (これが最新の指示です - 優先して対応してください) @@ -638,7 +654,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: security_review - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/05-security-review.md @@ -660,7 +677,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -742,7 +759,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: security_fix ## Security Review Feedback (これが最新の指示です - 優先して対応してください) @@ -810,7 +828,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix ## Architect Feedback (これが最新の指示です - 優先して対応してください) @@ -889,7 +908,8 @@ steps: ``` instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: supervise (final verification) - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -917,7 +937,7 @@ steps: **レポート出力:** 上記の `Report Files` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **Validationレポートフォーマット:** ```markdown diff --git a/resources/global/ja/workflows/expert-review.yaml b/resources/global/ja/workflows/expert-review.yaml index 10fb603..0e6a8bc 100644 --- a/resources/global/ja/workflows/expert-review.yaml +++ b/resources/global/ja/workflows/expert-review.yaml @@ -9,6 +9,16 @@ # 修正時の戻り先はCoderが判断: # - fix_security: MINOR→security_review, MAJOR→cqrs_es_review # - fix_qa: MINOR→qa_review, SECURITY→security_review, MAJOR→cqrs_es_review +# +# テンプレート変数: +# {iteration} - ワークフロー全体のターン数(全エージェントで実行されたステップの合計) +# {max_iterations} - ワークフローの最大イテレーション数 +# {step_iteration} - ステップごとのイテレーション数(このステップが何回実行されたか) +# {task} - 元のユーザー要求 +# {previous_response} - 前のステップの出力 +# {git_diff} - 現在のコミットされていない変更(git diff) +# {user_inputs} - ワークフロー中に蓄積されたユーザー入力 +# {report_dir} - レポートディレクトリ名(例: "20250126-143052-task-summary") name: expert-review description: CQRS+ES・フロントエンド・セキュリティ・QA専門家レビュー @@ -44,7 +54,8 @@ steps: | 要件不明確 | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: plan (タスク分析) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/00-plan.md @@ -68,7 +79,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -129,7 +140,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: implement - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -148,7 +160,7 @@ steps: **レポート出力:** 上記の `Report Files` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **Scopeレポートフォーマット(実装開始時に作成):** ```markdown @@ -213,7 +225,8 @@ steps: | 設計に問題あり | `[CQRS-ES:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: cqrs_es_review (CQRS+ES専門レビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/03-cqrs-es-review.md @@ -242,7 +255,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -302,7 +315,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix_cqrs_es ## CQRS+ES Review Feedback (これが最新の指示です - 優先して対応してください) @@ -358,7 +372,8 @@ steps: | フロントエンド設計に問題あり | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: frontend_review (フロントエンド専門レビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/04-frontend-review.md @@ -387,7 +402,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -447,7 +462,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix_frontend ## Frontend Review Feedback (これが最新の指示です - 優先して対応してください) @@ -503,7 +519,8 @@ steps: | 問題あり | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: ai_review (AI生成コードレビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/05-ai-review.md @@ -525,7 +542,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -588,7 +605,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: ai_fix ## AI Review Feedback (これが最新の指示です - 優先して対応してください) @@ -642,7 +660,8 @@ steps: | 脆弱性あり | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: security_review (セキュリティ専門レビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/06-security-review.md @@ -667,7 +686,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -729,7 +748,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix_security ## Security Review Feedback (これが最新の指示です - 優先して対応してください) @@ -794,7 +814,8 @@ steps: | 品質問題あり | `[QA:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: qa_review (QA専門レビュー) - Report Directory: .takt/reports/{report_dir}/ - Report File: .takt/reports/{report_dir}/07-qa-review.md @@ -820,7 +841,7 @@ steps: **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **レポートフォーマット:** ```markdown @@ -882,7 +903,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix_qa ## QA Review Feedback (これが最新の指示です - 優先して対応してください) @@ -951,7 +973,8 @@ steps: | 問題あり | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: supervise (最終確認) - Report Directory: .takt/reports/{report_dir}/ - Report Files: @@ -987,7 +1010,7 @@ steps: **レポート出力:** 上記の `Report Files` に出力してください。 - ファイルが存在しない場合: 新規作成 - - ファイルが存在する場合: `## Iteration {iteration}` セクションを追記 + - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 **Validationレポートフォーマット:** ```markdown @@ -1079,7 +1102,8 @@ steps: | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - - Iteration: {iteration}/{max_iterations} + - Iteration: {iteration}/{max_iterations}(ワークフロー全体) + - Step Iteration: {step_iteration}(このステップの実行回数) - Step: fix_supervisor ## Supervisor Feedback (これが最新の指示です - 優先して対応してください) diff --git a/resources/global/ja/workflows/magi.yaml b/resources/global/ja/workflows/magi.yaml index 38cc41f..678840f 100644 --- a/resources/global/ja/workflows/magi.yaml +++ b/resources/global/ja/workflows/magi.yaml @@ -1,6 +1,16 @@ # MAGI System Workflow # エヴァンゲリオンのMAGIシステムを模した合議制ワークフロー # 3つの人格(科学者・育成者・実務家)が異なる観点から分析・投票する +# +# テンプレート変数: +# {iteration} - ワークフロー全体のターン数(全エージェントで実行されたステップの合計) +# {max_iterations} - ワークフローの最大イテレーション数 +# {step_iteration} - ステップごとのイテレーション数(このステップが何回実行されたか) +# {task} - 元のユーザー要求 +# {previous_response} - 前のステップの出力 +# {git_diff} - 現在のコミットされていない変更(git diff) +# {user_inputs} - ワークフロー中に蓄積されたユーザー入力 +# {report_dir} - レポートディレクトリ名(例: "20250126-143052-task-summary") name: magi description: MAGI合議システム - 3つの観点から分析し多数決で判定 diff --git a/resources/global/ja/workflows/research.yaml b/resources/global/ja/workflows/research.yaml index 389dac8..293d618 100644 --- a/resources/global/ja/workflows/research.yaml +++ b/resources/global/ja/workflows/research.yaml @@ -5,6 +5,16 @@ # フロー: # plan -> dig -> supervise -> COMPLETE (approved) # -> plan (rejected: 計画からやり直し) +# +# テンプレート変数: +# {iteration} - ワークフロー全体のターン数(全エージェントで実行されたステップの合計) +# {max_iterations} - ワークフローの最大イテレーション数 +# {step_iteration} - ステップごとのイテレーション数(このステップが何回実行されたか) +# {task} - 元のユーザー要求 +# {previous_response} - 前のステップの出力 +# {git_diff} - 現在のコミットされていない変更(git diff) +# {user_inputs} - ワークフロー中に蓄積されたユーザー入力 +# {report_dir} - レポートディレクトリ名(例: "20250126-143052-task-summary") name: research description: 調査ワークフロー - 質問せずに自律的に調査を実行 @@ -49,7 +59,8 @@ steps: ``` instruction_template: | ## ワークフロー状況 - - イテレーション: {iteration}/{max_iterations} + - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) + - ステップ実行回数: {step_iteration}(このステップの実行回数) - ステップ: plan ## 調査依頼 @@ -111,7 +122,8 @@ steps: ``` instruction_template: | ## ワークフロー状況 - - イテレーション: {iteration}/{max_iterations} + - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) + - ステップ実行回数: {step_iteration}(このステップの実行回数) - ステップ: dig ## 元の調査依頼 @@ -188,7 +200,8 @@ steps: ``` instruction_template: | ## ワークフロー状況 - - イテレーション: {iteration}/{max_iterations} + - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) + - ステップ実行回数: {step_iteration}(このステップの実行回数) - ステップ: supervise (調査品質評価) ## 元の調査依頼 diff --git a/src/claude/client.ts b/src/claude/client.ts index aebdfb5..9feef95 100644 --- a/src/claude/client.ts +++ b/src/claude/client.ts @@ -82,7 +82,7 @@ export function getBuiltinStatusPatterns(_agentType: string): Record ): Status { if (!result.success) { @@ -92,7 +92,10 @@ function determineStatus( } return 'blocked'; } - return detectStatus(result.content, patterns); + // Use fullContent for status detection (contains all assistant messages) + // Fall back to content if fullContent is not available + const textForStatusDetection = result.fullContent || result.content; + return detectStatus(textForStatusDetection, patterns); } /** Call Claude with an agent prompt */ diff --git a/src/claude/executor.ts b/src/claude/executor.ts index 585002f..eef7f77 100644 --- a/src/claude/executor.ts +++ b/src/claude/executor.ts @@ -179,6 +179,7 @@ export async function executeClaudeQuery( success, content: finalContent.trim(), sessionId, + fullContent: accumulatedAssistantText.trim(), }; } catch (error) { unregisterQuery(queryId); diff --git a/src/claude/types.ts b/src/claude/types.ts index aba4094..3db4a84 100644 --- a/src/claude/types.ts +++ b/src/claude/types.ts @@ -104,6 +104,8 @@ export interface ClaudeResult { sessionId?: string; error?: string; interrupted?: boolean; + /** All assistant text accumulated during execution (for status detection) */ + fullContent?: string; } /** Extended result with query ID for concurrent execution */ diff --git a/src/models/types.ts b/src/models/types.ts index 88c4f08..a5b5309 100644 --- a/src/models/types.ts +++ b/src/models/types.ts @@ -115,6 +115,8 @@ export interface WorkflowState { stepOutputs: Map; userInputs: string[]; agentSessions: Map; + /** Per-step iteration counters (how many times each step has been executed) */ + stepIterations: Map; status: 'running' | 'completed' | 'aborted'; } diff --git a/src/workflow/engine.ts b/src/workflow/engine.ts index 89ec251..857dd50 100644 --- a/src/workflow/engine.ts +++ b/src/workflow/engine.ts @@ -22,6 +22,7 @@ import { createInitialState, addUserInput, getPreviousOutput, + incrementStepIteration, } from './state-manager.js'; import { generateReportDir } from '../utils/session.js'; @@ -117,11 +118,12 @@ export class WorkflowEngine extends EventEmitter { } /** Build instruction from template */ - private buildInstruction(step: WorkflowStep): string { + private buildInstruction(step: WorkflowStep, stepIteration: number): string { return buildInstructionFromTemplate(step, { task: this.task, iteration: this.state.iteration, maxIterations: this.config.maxIterations, + stepIteration, cwd: this.cwd, userInputs: this.state.userInputs, previousOutput: getPreviousOutput(this.state), @@ -140,7 +142,9 @@ export class WorkflowEngine extends EventEmitter { /** Run a single step */ private async runStep(step: WorkflowStep): Promise { - const instruction = this.buildInstruction(step); + // Increment step iteration counter before building instruction + const stepIteration = incrementStepIteration(this.state, step.name); + const instruction = this.buildInstruction(step, stepIteration); const sessionId = this.state.agentSessions.get(step.agent); const agentOptions: RunAgentOptions = { diff --git a/src/workflow/instruction-builder.ts b/src/workflow/instruction-builder.ts index fcee1b0..d8e89e4 100644 --- a/src/workflow/instruction-builder.ts +++ b/src/workflow/instruction-builder.ts @@ -14,10 +14,12 @@ import { getGitDiff } from '../agents/runner.js'; export interface InstructionContext { /** The main task/prompt */ task: string; - /** Current iteration number */ + /** Current iteration number (workflow-wide turn count) */ iteration: number; /** Maximum iterations allowed */ maxIterations: number; + /** Current step's iteration number (how many times this step has been executed) */ + stepIteration: number; /** Working directory */ cwd: string; /** User inputs accumulated during workflow */ @@ -40,8 +42,9 @@ function escapeTemplateChars(str: string): string { * * Supported placeholders: * - {task} - The main task/prompt - * - {iteration} - Current iteration number + * - {iteration} - Current iteration number (workflow-wide turn count) * - {max_iterations} - Maximum iterations allowed + * - {step_iteration} - Current step's iteration number (how many times this step has been executed) * - {previous_response} - Output from previous step (if passPreviousResponse is true) * - {git_diff} - Current git diff output * - {user_inputs} - Accumulated user inputs @@ -56,9 +59,10 @@ export function buildInstruction( // Replace {task} instruction = instruction.replace(/\{task\}/g, escapeTemplateChars(context.task)); - // Replace {iteration} and {max_iterations} + // Replace {iteration}, {max_iterations}, and {step_iteration} instruction = instruction.replace(/\{iteration\}/g, String(context.iteration)); instruction = instruction.replace(/\{max_iterations\}/g, String(context.maxIterations)); + instruction = instruction.replace(/\{step_iteration\}/g, String(context.stepIteration)); // Replace {previous_response} if (step.passPreviousResponse) { diff --git a/src/workflow/state-manager.ts b/src/workflow/state-manager.ts index 98fad70..3e2ba72 100644 --- a/src/workflow/state-manager.ts +++ b/src/workflow/state-manager.ts @@ -39,10 +39,21 @@ export function createInitialState( stepOutputs: new Map(), userInputs, agentSessions, + stepIterations: new Map(), status: 'running', }; } +/** + * Increment the iteration counter for a step and return the new value. + */ +export function incrementStepIteration(state: WorkflowState, stepName: string): number { + const current = state.stepIterations.get(stepName) ?? 0; + const next = current + 1; + state.stepIterations.set(stepName, next); + return next; +} + /** * Add user input to state with truncation and limit handling. */