workflow 変更

This commit is contained in:
nrslib 2026-01-30 01:50:25 +09:00
parent e67d2648d8
commit f7181fc00c
18 changed files with 1372 additions and 2150 deletions

View File

@ -126,7 +126,54 @@ AI is confidently wrong—code that looks plausible but doesn't work, solutions
2. Check whether each fallback has a legitimate reason 2. Check whether each fallback has a legitimate reason
3. REJECT if even one unjustified fallback exists 3. REJECT if even one unjustified fallback exists
### 7. Decision Traceability Review ### 7. Unused Code Detection
**AI tends to generate unnecessary code "for future extensibility", "for symmetry", or "just in case". Delete code that is not called anywhere at present.**
| Judgment | Criteria |
|----------|----------|
| **REJECT** | Public function/method not called from anywhere |
| **REJECT** | Setter/getter created "for symmetry" but never used |
| **REJECT** | Interface or option prepared for future extension |
| **REJECT** | Exported but grep finds no usage |
| OK | Implicitly called by framework (lifecycle hooks, etc.) |
| OK | Intentionally published as public package API |
**Verification approach:**
1. Verify with grep that no references exist to changed/deleted code
2. Verify that public module (index files, etc.) export lists match actual implementations
3. Check that old code corresponding to newly added code has been removed
### 8. Unnecessary Backward Compatibility Code Detection
**AI tends to leave unnecessary code "for backward compatibility." Don't overlook this.**
Code that should be deleted:
| Pattern | Example | Judgment |
|---------|---------|----------|
| deprecated + unused | `@deprecated` annotation with no callers | **Delete immediately** |
| Both new and old API exist | New function exists but old function remains | **Delete old** |
| Migrated wrappers | Created for compatibility but migration complete | **Delete** |
| Comments saying "delete later" | `// TODO: remove after migration` left unattended | **Delete now** |
| Excessive proxy/adapter usage | Complexity added only for backward compatibility | **Replace with simple** |
Code that should be kept:
| Pattern | Example | Judgment |
|---------|---------|----------|
| Externally published API | npm package exports | Consider carefully |
| Config file compatibility | Can read old format configs | Maintain until major version |
| During data migration | DB schema migration in progress | Maintain until migration complete |
**Decision criteria:**
1. **Are there any usage sites?** → Verify with grep/search. Delete if none
2. **Is it externally published?** → If internal only, can delete immediately
3. **Is migration complete?** → If complete, delete
**Be suspicious when AI says "for backward compatibility."** Verify if it's really needed.
### 9. Decision Traceability Review
**Verify that Coder's decision log is reasonable.** **Verify that Coder's decision log is reasonable.**

View File

@ -191,73 +191,6 @@ if (status === 'interrupted') {
} }
``` ```
**Fallback Value Overuse Detection Criteria:**
Fallback values (`??`, `||`, default arguments) silently swallow "value is missing" cases. They hide what should be errors.
| Judgment | Criteria |
|----------|----------|
| **REJECT** | Fallback hides a bug where a missing value indicates data inconsistency |
| **REJECT** | Uses meaningless values like `'unknown'`, `'default'`, `''`, `0` as cover |
| **REJECT** | All call sites rely on fallback — no one passes the actual value |
| OK | Defensive default for external input (user input, API responses) |
| OK | Reasonable initial value for optional configuration |
```typescript
// ❌ REJECT - Fallback hiding a bug
const userName = user.name ?? 'unknown'; // Missing name is data inconsistency
const stepName = step?.name ?? 'default'; // Missing step is a caller bug
// ❌ REJECT - Option that all call sites omit
function runStep(step: Step, options?: { maxRetries?: number }) {
const retries = options?.maxRetries ?? 3; // No call site passes options
}
// ✅ OK - Optional user setting with reasonable default
const logLevel = config.logLevel ?? 'info'; // Default if not in config file
const language = userPreference.lang ?? 'en'; // Default if not set
// ✅ OK - Defensive default for external API
const displayName = apiResponse.nickname ?? apiResponse.email; // Fallback if no nickname
```
**Unused Code Detection Criteria:**
AI tends to generate unnecessary code "for future extensibility", "for symmetry", or "just in case". Delete code that is not called anywhere at present.
| Judgment | Criteria |
|----------|----------|
| **REJECT** | Public function/method not called from anywhere |
| **REJECT** | Setter/getter created "for symmetry" but never used |
| **REJECT** | Interface or option prepared for future extension |
| **REJECT** | Exported but grep finds no usage |
| OK | Implicitly called by framework (lifecycle hooks, etc.) |
| OK | Intentionally published as public package API |
```typescript
// ❌ REJECT - Setter "for symmetry" (only get is used)
class WorkflowState {
private _status: Status;
getStatus(): Status { return this._status; }
setStatus(s: Status) { this._status = s; } // No one calls this
}
// ❌ REJECT - Options for "future extension"
interface EngineOptions {
maxIterations: number;
enableParallel?: boolean; // Not implemented. Not referenced anywhere
pluginHooks?: PluginHook[]; // Not implemented. No plugin system exists
}
// ❌ REJECT - Exported but unused
export function formatStepName(name: string): string { ... } // grep result: 0 hits
// ✅ OK - Called by framework
class MyComponent extends React.Component {
componentDidMount() { ... } // Called by React
}
```
**Direct State Mutation Detection Criteria:** **Direct State Mutation Detection Criteria:**
Directly mutating objects or arrays makes changes hard to track and causes unexpected side effects. Always use spread operators or immutable operations to return new objects. Directly mutating objects or arrays makes changes hard to track and causes unexpected side effects. Always use spread operators or immutable operations to return new objects.
@ -379,36 +312,7 @@ function createUser(data: UserData) {
} }
``` ```
### 7. Unnecessary Backward Compatibility Code Detection ### 7. Workaround Detection
**AI tends to leave unnecessary code "for backward compatibility." Don't overlook this.**
Code that should be deleted:
| Pattern | Example | Judgment |
|---------|---------|----------|
| deprecated + unused | `@deprecated` annotation with no callers | **Delete immediately** |
| Both new and old API exist | New function exists but old function remains | **Delete old** |
| Migrated wrappers | Created for compatibility but migration complete | **Delete** |
| Comments saying "delete later" | `// TODO: remove after migration` left unattended | **Delete now** |
| Excessive proxy/adapter usage | Complexity added only for backward compatibility | **Replace with simple** |
Code that should be kept:
| Pattern | Example | Judgment |
|---------|---------|----------|
| Externally published API | npm package exports | Consider carefully |
| Config file compatibility | Can read old format configs | Maintain until major version |
| During data migration | DB schema migration in progress | Maintain until migration complete |
**Decision criteria:**
1. **Are there any usage sites?** → Verify with grep/search. Delete if none
2. **Is it externally published?** → If internal only, can delete immediately
3. **Is migration complete?** → If complete, delete
**Be suspicious when AI says "for backward compatibility."** Verify if it's really needed.
### 8. Workaround Detection
**Don't overlook compromises made to "just make it work."** **Don't overlook compromises made to "just make it work."**
@ -423,7 +327,7 @@ Code that should be kept:
**Always point these out.** Temporary fixes become permanent. **Always point these out.** Temporary fixes become permanent.
### 9. Quality Attributes ### 8. Quality Attributes
| Attribute | Review Point | | Attribute | Review Point |
|-----------|--------------| |-----------|--------------|
@ -431,7 +335,7 @@ Code that should be kept:
| Maintainability | Easy to modify and fix | | Maintainability | Easy to modify and fix |
| Observability | Logging and monitoring enabled | | Observability | Logging and monitoring enabled |
### 10. Big Picture ### 9. Big Picture
**Caution**: Don't get lost in minor "clean code" nitpicks. **Caution**: Don't get lost in minor "clean code" nitpicks.
@ -442,7 +346,7 @@ Verify:
- Does it align with business requirements - Does it align with business requirements
- Is naming consistent with the domain - Is naming consistent with the domain
### 11. Change Scope Assessment ### 10. Change Scope Assessment
**Check change scope and include in report (non-blocking).** **Check change scope and include in report (non-blocking).**
@ -461,7 +365,7 @@ Verify:
**Include as suggestions (non-blocking):** **Include as suggestions (non-blocking):**
- If splittable, present splitting proposal - If splittable, present splitting proposal
### 12. Circular Review Detection ### 11. Circular Review Detection
When review count is provided (e.g., "Review count: 3rd"), adjust judgment accordingly. When review count is provided (e.g., "Review count: 3rd"), adjust judgment accordingly.

View File

@ -1,26 +1,36 @@
# Default TAKT Workflow # Default TAKT Workflow
# Plan -> Coder -> Architect Review -> AI Review -> Security Review -> Supervisor Approval # Plan -> Coder -> AI Review -> Architect Review -> Security Review -> Supervisor Approval
# #
# Template Variables: # Boilerplate sections (Workflow Context, User Request, Previous Response,
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # Additional User Inputs, Instructions heading) are auto-injected by buildInstruction().
# {max_iterations} - Maximum iterations allowed for the workflow # Only step-specific content belongs in instruction_template.
# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) #
# {task} - Original user request # Template Variables (available in instruction_template):
# {previous_response} - Output from the previous step # {iteration} - Workflow-wide turn count (total steps executed across all agents)
# {git_diff} - Current uncommitted changes (git diff) # {max_iterations} - Maximum iterations allowed for the workflow
# {user_inputs} - Accumulated user inputs during workflow # {step_iteration} - Per-step iteration count (how many times THIS step has been executed)
# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") # {previous_response} - Output from the previous step (only when pass_previous_response: true)
# {git_diff} - Current uncommitted changes (git diff)
# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary")
#
# Step-level Fields:
# report: - Report file(s) for the step (auto-injected as Report File/Files in Workflow Context)
# Single: report: 00-plan.md
# Multiple: report:
# - Scope: 01-coder-scope.md
# - Decisions: 02-coder-decisions.md
name: default name: default
description: Standard development workflow with planning and specialized reviews description: Standard development workflow with planning and specialized reviews
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
steps: steps:
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -42,20 +52,9 @@ steps:
- {Question 2} - {Question 2}
pass_previous_response: true pass_previous_response: true
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (when returned from implement) ## Previous Response (when returned from implement)
{previous_response} {previous_response}
## Instructions
Analyze the task and create an implementation plan. Analyze the task and create an implementation plan.
**Note:** If returned from implement step (Previous Response exists), **Note:** If returned from implement step (Previous Response exists),
@ -94,6 +93,9 @@ steps:
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -106,26 +108,10 @@ steps:
permission_mode: acceptEdits permission_mode: acceptEdits
rules: rules:
- condition: Implementation complete - condition: Implementation complete
next: review next: ai_review
- condition: Cannot proceed, insufficient info - condition: Cannot proceed, insufficient info
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
Follow the plan from the plan step and implement. Follow the plan from the plan step and implement.
Refer to the plan report (00-plan.md) and proceed with implementation. Refer to the plan report (00-plan.md) and proceed with implementation.
@ -163,120 +149,9 @@ steps:
- **Reason**: {Why this option was chosen} - **Reason**: {Why this option was chosen}
``` ```
- name: review
agent: ~/.takt/agents/default/architecture-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: No issues found
next: ai_review
- condition: Minor improvements needed
next: improve
- condition: Structural fix required
next: fix
instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
Focus on **architecture and design** review. Do NOT review AI-specific issues (that's the next step).
Review the changes and provide feedback.
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# Architecture Review
## Result: APPROVE / IMPROVE / REJECT
## Summary
{1-2 sentences summarizing result}
## Reviewed Perspectives
- [x] Structure & Design
- [x] Code Quality
- [x] Change Scope
## Issues (if REJECT)
| # | Location | Issue | Fix |
|---|----------|-------|-----|
| 1 | `src/file.ts:42` | Issue description | Fix method |
## Improvement Suggestions (optional, non-blocking)
- {Future improvement suggestions}
```
**Cognitive load reduction rules:**
- APPROVE + no issues -> Summary only (5 lines or less)
- APPROVE + minor suggestions -> Summary + suggestions (15 lines or less)
- REJECT -> Issues in table format (30 lines or less)
- name: improve
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: Improvements complete
next: review
- condition: Cannot proceed, insufficient info
next: plan
instruction_template: |
## Workflow Context
- 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)
{previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the Architect's improvement suggestions.
These are minor improvements, not major design issues.
Make improvements such as:
- Naming improvements
- Small refactoring
- Adding/fixing comments
- Code organization
pass_previous_response: true
- name: ai_review - name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -286,26 +161,15 @@ steps:
- WebFetch - WebFetch
rules: rules:
- condition: No AI-specific issues - condition: No AI-specific issues
next: security_review next: review
- condition: AI-specific issues found - condition: AI-specific issues found
next: ai_fix next: ai_fix
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the code for AI-specific issues: Review the code for AI-specific issues:
- Assumption validation - Assumption validation
- Plausible but wrong patterns - Plausible but wrong patterns
@ -361,21 +225,9 @@ steps:
- condition: Cannot proceed, insufficient info - condition: Cannot proceed, insufficient info
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## AI Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the AI Reviewer's feedback. **Important**: Address the AI Reviewer's feedback.
Focus on: Focus on:
- Correcting incorrect assumptions - Correcting incorrect assumptions
@ -384,8 +236,125 @@ steps:
- Removing scope creep - Removing scope creep
pass_previous_response: true pass_previous_response: true
- name: review
agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: No issues found
next: security_review
- condition: Minor improvements needed
next: improve
- condition: Structural fix required
next: fix
instruction_template: |
## Git Diff
```diff
{git_diff}
```
Focus on **architecture and design** review. Do NOT review AI-specific issues (that's the ai_review step).
Review the changes and provide feedback.
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# Architecture Review
## Result: APPROVE / IMPROVE / REJECT
## Summary
{1-2 sentences summarizing result}
## Reviewed Perspectives
- [x] Structure & Design
- [x] Code Quality
- [x] Change Scope
## Issues (if REJECT)
| # | Location | Issue | Fix |
|---|----------|-------|-----|
| 1 | `src/file.ts:42` | Issue description | Fix method |
## Improvement Suggestions (optional, non-blocking)
- {Future improvement suggestions}
```
**Cognitive load reduction rules:**
- APPROVE + no issues -> Summary only (5 lines or less)
- APPROVE + minor suggestions -> Summary + suggestions (15 lines or less)
- REJECT -> Issues in table format (30 lines or less)
- name: improve
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: Improvements complete
next: review
- condition: Cannot proceed, insufficient info
next: plan
instruction_template: |
## Architect Feedback (This is the latest instruction - prioritize this)
{previous_response}
**Important**: Address the Architect's improvement suggestions.
These are minor improvements, not major design issues.
Make improvements such as:
- Naming improvements
- Small refactoring
- Adding/fixing comments
- Code organization
pass_previous_response: true
- name: fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: Architect feedback addressed
next: review
- condition: Cannot proceed, insufficient info
next: plan
instruction_template: |
## Architect Feedback (This is the latest instruction - prioritize this)
{previous_response}
**Important**: Address the Architect's feedback.
The "Original User Request" is reference information, not the latest instruction.
Review the session conversation history and fix the issues raised by the Architect.
pass_previous_response: true
- name: security_review - name: security_review
agent: ~/.takt/agents/default/security-reviewer.md agent: ~/.takt/agents/default/security-reviewer.md
report: 05-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -399,22 +368,11 @@ steps:
- condition: Vulnerabilities require fix - condition: Vulnerabilities require fix
next: security_fix next: security_fix
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Perform security review on the changes. Check for vulnerabilities including: Perform security review on the changes. Check for vulnerabilities including:
- Injection attacks (SQL, Command, XSS) - Injection attacks (SQL, Command, XSS)
- Authentication/Authorization issues - Authentication/Authorization issues
@ -473,65 +431,18 @@ steps:
- condition: Cannot proceed, insufficient info - condition: Cannot proceed, insufficient info
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Security Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the vulnerabilities identified in the security review. **Important**: Fix the vulnerabilities identified in the security review.
Security issues require highest priority. Security issues require highest priority.
pass_previous_response: true pass_previous_response: true
- name: fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: Architect feedback addressed
next: review
- condition: Cannot proceed, insufficient info
next: plan
instruction_template: |
## Workflow Context
- 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)
{previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the Architect's feedback.
The "Original User Request" is reference information, not the latest instruction.
Review the session conversation history and fix the issues raised by the Architect.
pass_previous_response: true
- name: supervise - name: supervise
agent: ~/.takt/agents/default/supervisor.md agent: ~/.takt/agents/default/supervisor.md
report:
- Validation: 06-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -546,24 +457,11 @@ steps:
- condition: Requirements unmet, tests failing, build errors - condition: Requirements unmet, tests failing, build errors
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Validation: .takt/reports/{report_dir}/06-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Run tests, verify the build, and perform final approval. Run tests, verify the build, and perform final approval.
**Workflow Overall Review:** **Workflow Overall Review:**

View File

@ -1,14 +1,14 @@
# Expert Review Workflow # Expert CQRS Review Workflow
# Review workflow with CQRS+ES, Frontend, Security, and QA experts # Review workflow with CQRS+ES, Frontend, Security, and QA experts
# #
# Flow: # Flow:
# plan -> implement -> cqrs_es_review -> frontend_review -> ai_review -> security_review -> qa_review -> supervise -> COMPLETE # plan -> implement -> ai_review -> cqrs_es_review -> frontend_review -> security_review -> qa_review -> supervise -> COMPLETE
# ↓ ↓ ↓ ↓ ↓ ↓ # ↓ ↓ ↓ ↓
# fix_cqrs_es fix_frontend ai_fix fix_security fix_qa fix_supervisor # ai_fix fix_cqrs_es fix_frontend fix_security fix_qa fix_supervisor
# #
# Fix destination is determined by Coder based on change impact: # Fix destination is determined by Coder based on change impact:
# - fix_security: MINOR→security_review, MAJOR→cqrs_es_review # - fix_security: MINOR->security_review, MAJOR->cqrs_es_review
# - fix_qa: MINOR→qa_review, SECURITY→security_review, MAJOR→cqrs_es_review # - fix_qa: MINOR->qa_review, SECURITY->security_review, MAJOR->cqrs_es_review
# #
# Template Variables: # Template Variables:
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # {iteration} - Workflow-wide turn count (total steps executed across all agents)
@ -23,7 +23,7 @@
name: expert-cqrs name: expert-cqrs
description: CQRS+ES, Frontend, Security, QA Expert Review description: CQRS+ES, Frontend, Security, QA Expert Review
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
@ -33,6 +33,7 @@ steps:
# =========================================== # ===========================================
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -42,20 +43,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (when returned from implement) ## Previous Response (when returned from implement)
{previous_response} {previous_response}
## Instructions
Analyze the task and create an implementation plan. Analyze the task and create an implementation plan.
**Note:** If returned from implement step (Previous Response exists), **Note:** If returned from implement step (Previous Response exists),
@ -103,6 +93,9 @@ steps:
# =========================================== # ===========================================
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -113,22 +106,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
Follow the plan from the plan step and implement. Follow the plan from the plan step and implement.
Refer to the plan report (00-plan.md) and proceed with implementation. Refer to the plan report (00-plan.md) and proceed with implementation.
@ -167,15 +144,105 @@ steps:
``` ```
rules: rules:
- condition: Implementation is complete - condition: Implementation is complete
next: cqrs_es_review next: ai_review
- condition: Cannot proceed with implementation - condition: Cannot proceed with implementation
next: plan next: plan
# =========================================== # ===========================================
# Phase 2: CQRS+ES Review # Phase 2: AI Review
# =========================================== # ===========================================
- name: cqrs_es_review - name: ai_review
agent: ~/.takt/agents/expert-cqrs/cqrs-es-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Git Diff
```diff
{git_diff}
```
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues → Summary 1 line + check table only (10 lines or less)
- Issues found → + Issues in table format (25 lines or less)
rules:
- condition: No AI-specific issues found
next: cqrs_es_review
- condition: AI-specific issues detected
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## AI Review Feedback (This is the latest instruction - prioritize this)
{previous_response}
**Important**: Address the AI Reviewer's feedback.
Focus on:
- Correcting incorrect assumptions
- Fixing plausible-but-wrong implementations
- Aligning with existing codebase patterns
- Removing scope creep
pass_previous_response: true
rules:
- condition: AI Reviewer's issues have been fixed
next: ai_review
- condition: Unable to proceed with fixes
next: plan
# ===========================================
# Phase 3: CQRS+ES Review
# ===========================================
- name: cqrs_es_review
agent: ~/.takt/agents/expert-cqrs/cqrs-es-reviewer.md
report: 04-cqrs-es-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -184,22 +251,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the CQRS (Command Query Responsibility Segregation) Review the changes above from the CQRS (Command Query Responsibility Segregation)
and Event Sourcing perspective. and Event Sourcing perspective.
@ -258,21 +314,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## CQRS+ES Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the CQRS+ES expert. **Important**: Fix the issues pointed out by the CQRS+ES expert.
Areas of concern: Areas of concern:
@ -289,10 +333,11 @@ steps:
next: plan next: plan
# =========================================== # ===========================================
# Phase 3: Frontend Review # Phase 4: Frontend Review
# =========================================== # ===========================================
- name: frontend_review - name: frontend_review
agent: ~/.takt/agents/expert/frontend-reviewer.md agent: ~/.takt/agents/expert/frontend-reviewer.md
report: 05-frontend-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -301,22 +346,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the frontend development perspective. Review the changes above from the frontend development perspective.
**Review Criteria:** **Review Criteria:**
@ -359,7 +393,7 @@ steps:
``` ```
rules: rules:
- condition: Frontend design is sound with no issues - condition: Frontend design is sound with no issues
next: ai_review next: security_review
- condition: Frontend design issues found - condition: Frontend design issues found
next: fix_frontend next: fix_frontend
@ -375,21 +409,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Frontend Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the frontend expert. **Important**: Fix the issues pointed out by the frontend expert.
Areas of concern: Areas of concern:
@ -405,122 +427,12 @@ steps:
- condition: Unable to proceed with fixes - condition: Unable to proceed with fixes
next: plan next: plan
# ===========================================
# Phase 4: AI Review
# ===========================================
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues → Summary 1 line + check table only (10 lines or less)
- Issues found → + Issues in table format (25 lines or less)
rules:
- condition: No AI-specific issues found
next: security_review
- condition: AI-specific issues detected
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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)
{previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the AI Reviewer's feedback.
Focus on:
- Correcting incorrect assumptions
- Fixing plausible-but-wrong implementations
- Aligning with existing codebase patterns
- Removing scope creep
pass_previous_response: true
rules:
- condition: AI Reviewer's issues have been fixed
next: ai_review
- condition: Unable to proceed with fixes
next: plan
# =========================================== # ===========================================
# Phase 5: Security Review # Phase 5: Security Review
# =========================================== # ===========================================
- name: security_review - name: security_review
agent: ~/.takt/agents/expert/security-reviewer.md agent: ~/.takt/agents/expert/security-reviewer.md
report: 06-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -529,22 +441,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the security perspective. Review the changes above from the security perspective.
**Review Criteria:** **Review Criteria:**
@ -600,21 +501,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Security Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the security expert. **Important**: Fix the issues pointed out by the security expert.
Security issues should be addressed with highest priority. Security issues should be addressed with highest priority.
@ -645,6 +534,7 @@ steps:
# =========================================== # ===========================================
- name: qa_review - name: qa_review
agent: ~/.takt/agents/expert/qa-reviewer.md agent: ~/.takt/agents/expert/qa-reviewer.md
report: 07-qa-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -653,22 +543,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the quality assurance perspective. Review the changes above from the quality assurance perspective.
**Review Criteria:** **Review Criteria:**
@ -724,21 +603,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## QA Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the QA expert. **Important**: Fix the issues pointed out by the QA expert.
Areas of concern: Areas of concern:
@ -773,6 +640,9 @@ steps:
# =========================================== # ===========================================
- name: supervise - name: supervise
agent: ~/.takt/agents/expert/supervisor.md agent: ~/.takt/agents/expert/supervisor.md
report:
- Validation: 08-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -781,18 +651,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Validation: .takt/reports/{report_dir}/08-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
@ -800,13 +658,12 @@ steps:
## Previous Reviews Summary ## Previous Reviews Summary
Reaching this step means all the following reviews have been APPROVED: Reaching this step means all the following reviews have been APPROVED:
- AI Review: APPROVED
- CQRS+ES Review: APPROVED - CQRS+ES Review: APPROVED
- Frontend Review: APPROVED - Frontend Review: APPROVED
- AI Review: APPROVED
- Security Review: APPROVED - Security Review: APPROVED
- QA Review: APPROVED - QA Review: APPROVED
## Instructions
Run tests, verify the build, and perform final approval. Run tests, verify the build, and perform final approval.
**Workflow Overall Review:** **Workflow Overall Review:**
@ -863,9 +720,9 @@ steps:
## Review Results ## Review Results
| Review | Result | | Review | Result |
|--------|--------| |--------|--------|
| AI Review | ✅ APPROVE |
| CQRS+ES | ✅ APPROVE | | CQRS+ES | ✅ APPROVE |
| Frontend | ✅ APPROVE | | Frontend | ✅ APPROVE |
| AI Review | ✅ APPROVE |
| Security | ✅ APPROVE | | Security | ✅ APPROVE |
| QA | ✅ APPROVE | | QA | ✅ APPROVE |
| Supervisor | ✅ APPROVE | | Supervisor | ✅ APPROVE |
@ -894,21 +751,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Supervisor Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the supervisor. **Important**: Fix the issues pointed out by the supervisor.
The supervisor has identified issues from a big-picture perspective. The supervisor has identified issues from a big-picture perspective.

View File

@ -2,13 +2,16 @@
# Review workflow with Architecture, Frontend, Security, and QA experts # Review workflow with Architecture, Frontend, Security, and QA experts
# #
# Flow: # Flow:
# plan -> implement -> architect_review -> frontend_review -> ai_review -> security_review -> qa_review -> supervise -> COMPLETE # plan -> implement -> ai_review -> architect_review -> frontend_review -> security_review -> qa_review -> supervise -> COMPLETE
# ↓ ↓ ↓ ↓ ↓ ↓ # ↓ ↓ ↓ ↓ ↓ ↓ ↓
# fix_architect fix_frontend ai_fix fix_security fix_qa fix_supervisor # ai_fix fix_architect fix_frontend fix_security fix_qa fix_supervisor
#
# AI review runs immediately after implementation to catch AI-specific issues early,
# before expert reviews begin.
# #
# Fix destination is determined by Coder based on change impact: # Fix destination is determined by Coder based on change impact:
# - fix_security: MINOR→security_review, MAJOR→architect_review # - fix_security: MINOR->security_review, MAJOR->architect_review
# - fix_qa: MINOR→qa_review, SECURITY→security_review, MAJOR→architect_review # - fix_qa: MINOR->qa_review, SECURITY->security_review, MAJOR->architect_review
# #
# Template Variables: # Template Variables:
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # {iteration} - Workflow-wide turn count (total steps executed across all agents)
@ -23,7 +26,7 @@
name: expert name: expert
description: Architecture, Frontend, Security, QA Expert Review description: Architecture, Frontend, Security, QA Expert Review
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
@ -33,6 +36,7 @@ steps:
# =========================================== # ===========================================
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -42,20 +46,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (when returned from implement) ## Previous Response (when returned from implement)
{previous_response} {previous_response}
## Instructions
Analyze the task and create an implementation plan. Analyze the task and create an implementation plan.
**Note:** If returned from implement step (Previous Response exists), **Note:** If returned from implement step (Previous Response exists),
@ -66,7 +59,7 @@ steps:
2. Identify impact scope 2. Identify impact scope
3. Decide implementation approach 3. Decide implementation approach
**Report output:** Output to the `Report File` specified above. **Report output:** Output to `.takt/reports/{report_dir}/00-plan.md`.
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -103,6 +96,9 @@ steps:
# =========================================== # ===========================================
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -113,26 +109,12 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
Follow the plan from the plan step and implement. Follow the plan from the plan step and implement.
Refer to the plan report (00-plan.md) and proceed with implementation. Refer to the plan report (00-plan.md) and proceed with implementation.
**Report output:** Output to the `Report Files` specified above. **Report output:** Output to the report files specified below.
- Scope: `.takt/reports/{report_dir}/01-coder-scope.md`
- Decisions: `.takt/reports/{report_dir}/02-coder-decisions.md`
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -167,15 +149,105 @@ steps:
``` ```
rules: rules:
- condition: Implementation is complete - condition: Implementation is complete
next: architect_review next: ai_review
- condition: Cannot proceed with implementation - condition: Cannot proceed with implementation
next: plan next: plan
# =========================================== # ===========================================
# Phase 2: Architecture Review # Phase 2: AI Review
# =========================================== # ===========================================
- name: architect_review - name: ai_review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Git Diff
```diff
{git_diff}
```
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to `.takt/reports/{report_dir}/03-ai-review.md`.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues -> Summary 1 line + check table only (10 lines or less)
- Issues found -> + Issues in table format (25 lines or less)
rules:
- condition: No AI-specific issues found
next: architect_review
- condition: AI-specific issues detected
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## AI Review Feedback (This is the latest instruction - prioritize this)
{previous_response}
**Important**: Address the AI Reviewer's feedback.
Focus on:
- Correcting incorrect assumptions
- Fixing plausible-but-wrong implementations
- Aligning with existing codebase patterns
- Removing scope creep
pass_previous_response: true
rules:
- condition: AI Reviewer's issues have been fixed
next: ai_review
- condition: Unable to proceed with fixes
next: plan
# ===========================================
# Phase 3: Architecture Review
# ===========================================
- name: architect_review
agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -184,22 +256,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations} (workflow-wide)
- Step Iteration: {step_iteration} (times this step has run)
- Step: architect_review (Architecture Review)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/03-architect-review.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Focus on **architecture and design** review. Focus on **architecture and design** review.
**Review Criteria:** **Review Criteria:**
@ -210,7 +271,7 @@ steps:
- Dead code - Dead code
- Call chain verification - Call chain verification
**Report output:** Output to the `Report File` specified above. **Report output:** Output to `.takt/reports/{report_dir}/04-architect-review.md`.
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -241,9 +302,9 @@ steps:
``` ```
**Cognitive load reduction rules:** **Cognitive load reduction rules:**
- APPROVE + no issues Summary only (5 lines or less) - APPROVE + no issues -> Summary only (5 lines or less)
- APPROVE + minor suggestions Summary + suggestions (15 lines or less) - APPROVE + minor suggestions -> Summary + suggestions (15 lines or less)
- REJECT Issues in table format (30 lines or less) - REJECT -> Issues in table format (30 lines or less)
rules: rules:
- condition: No architecture or design issues found - condition: No architecture or design issues found
next: frontend_review next: frontend_review
@ -265,21 +326,9 @@ steps:
- WebFetch - WebFetch
permission_mode: acceptEdits permission_mode: acceptEdits
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations} (workflow-wide)
- Step Iteration: {step_iteration} (times this step has run)
- Step: fix_architect
## Architect Feedback (This is the latest instruction - prioritize this) ## Architect Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the Architect's feedback. **Important**: Address the Architect's feedback.
"Original User Request" is for reference; it's not the latest instruction. "Original User Request" is for reference; it's not the latest instruction.
Review the session conversation history and fix the Architect's issues. Review the session conversation history and fix the Architect's issues.
@ -291,10 +340,11 @@ steps:
next: plan next: plan
# =========================================== # ===========================================
# Phase 3: Frontend Review # Phase 4: Frontend Review
# =========================================== # ===========================================
- name: frontend_review - name: frontend_review
agent: ~/.takt/agents/expert/frontend-reviewer.md agent: ~/.takt/agents/expert/frontend-reviewer.md
report: 05-frontend-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -303,22 +353,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the frontend development perspective. Review the changes above from the frontend development perspective.
**Review Criteria:** **Review Criteria:**
@ -332,7 +371,7 @@ steps:
**Note**: If this project does not include frontend code, **Note**: If this project does not include frontend code,
approve and proceed to the next step. approve and proceed to the next step.
**Report output:** Output to the `Report File` specified above. **Report output:** Output to `.takt/reports/{report_dir}/05-frontend-review.md`.
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -361,7 +400,7 @@ steps:
``` ```
rules: rules:
- condition: Frontend design is sound with no issues - condition: Frontend design is sound with no issues
next: ai_review next: security_review
- condition: Frontend design issues found - condition: Frontend design issues found
next: fix_frontend next: fix_frontend
@ -377,21 +416,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Frontend Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the frontend expert. **Important**: Fix the issues pointed out by the frontend expert.
Areas of concern: Areas of concern:
@ -407,122 +434,12 @@ steps:
- condition: Unable to proceed with fixes - condition: Unable to proceed with fixes
next: plan next: plan
# ===========================================
# Phase 4: AI Review
# ===========================================
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues → Summary 1 line + check table only (10 lines or less)
- Issues found → + Issues in table format (25 lines or less)
rules:
- condition: No AI-specific issues found
next: security_review
- condition: AI-specific issues detected
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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)
{previous_response}
## Original User Request (Initial request from workflow start - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Address the AI Reviewer's feedback.
Focus on:
- Correcting incorrect assumptions
- Fixing plausible-but-wrong implementations
- Aligning with existing codebase patterns
- Removing scope creep
pass_previous_response: true
rules:
- condition: AI Reviewer's issues have been fixed
next: ai_review
- condition: Unable to proceed with fixes
next: plan
# =========================================== # ===========================================
# Phase 5: Security Review # Phase 5: Security Review
# =========================================== # ===========================================
- name: security_review - name: security_review
agent: ~/.takt/agents/expert/security-reviewer.md agent: ~/.takt/agents/expert/security-reviewer.md
report: 06-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -531,22 +448,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the security perspective. Review the changes above from the security perspective.
**Review Criteria:** **Review Criteria:**
@ -556,7 +462,7 @@ steps:
- Encryption appropriateness - Encryption appropriateness
- OWASP Top 10 - OWASP Top 10
**Report output:** Output to the `Report File` specified above. **Report output:** Output to `.takt/reports/{report_dir}/06-security-review.md`.
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -602,21 +508,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Security Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the security expert. **Important**: Fix the issues pointed out by the security expert.
Security issues should be addressed with highest priority. Security issues should be addressed with highest priority.
@ -647,6 +541,7 @@ steps:
# =========================================== # ===========================================
- name: qa_review - name: qa_review
agent: ~/.takt/agents/expert/qa-reviewer.md agent: ~/.takt/agents/expert/qa-reviewer.md
report: 07-qa-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -655,22 +550,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Review the changes above from the quality assurance perspective. Review the changes above from the quality assurance perspective.
**Review Criteria:** **Review Criteria:**
@ -681,7 +565,7 @@ steps:
- Logging and monitoring - Logging and monitoring
- Maintainability - Maintainability
**Report output:** Output to the `Report File` specified above. **Report output:** Output to `.takt/reports/{report_dir}/07-qa-review.md`.
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -726,21 +610,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## QA Review Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the QA expert. **Important**: Fix the issues pointed out by the QA expert.
Areas of concern: Areas of concern:
@ -775,6 +647,9 @@ steps:
# =========================================== # ===========================================
- name: supervise - name: supervise
agent: ~/.takt/agents/expert/supervisor.md agent: ~/.takt/agents/expert/supervisor.md
report:
- Validation: 08-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -783,18 +658,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Validation: .takt/reports/{report_dir}/08-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
@ -808,7 +671,6 @@ steps:
- Security Review: APPROVED - Security Review: APPROVED
- QA Review: APPROVED - QA Review: APPROVED
## Instructions
Run tests, verify the build, and perform final approval. Run tests, verify the build, and perform final approval.
**Workflow Overall Review:** **Workflow Overall Review:**
@ -819,7 +681,9 @@ steps:
**Review Reports:** Read all reports in Report Directory and **Review Reports:** Read all reports in Report Directory and
check for any unaddressed improvement suggestions. check for any unaddressed improvement suggestions.
**Report output:** Output to the `Report Files` specified above. **Report output:** Output to the report files specified below.
- Validation: `.takt/reports/{report_dir}/08-supervisor-validation.md`
- Summary: `.takt/reports/{report_dir}/summary.md`
- If file does not exist: Create new file - If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section - If file exists: Append with `## Iteration {step_iteration}` section
@ -896,21 +760,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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) ## Supervisor Feedback (This is the latest instruction - prioritize this)
{previous_response} {previous_response}
## Original User Request (Initial request - for reference)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**Important**: Fix the issues pointed out by the supervisor. **Important**: Fix the issues pointed out by the supervisor.
The supervisor has identified issues from a big-picture perspective. The supervisor has identified issues from a big-picture perspective.

View File

@ -1,19 +1,24 @@
# Simple TAKT Workflow # Simple TAKT Workflow
# Plan -> Coder -> Architect Review -> AI Review -> Supervisor Approval # Plan -> Implement -> AI Review -> Architect Review -> Supervisor Approval
# (Simplified version of default - removed improve, fix, ai_fix, security_review, security_fix)
# #
# Template Variables: # Template Variables (auto-injected by engine):
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # {iteration} - Workflow-wide turn count
# {max_iterations} - Maximum iterations allowed for the workflow # {max_iterations} - Maximum iterations allowed
# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) # {step_iteration} - Per-step iteration count
# {task} - Original user request # {task} - Original user request
# {previous_response} - Output from the previous step # {previous_response} - Output from the previous step
# {git_diff} - Current uncommitted changes (git diff) # {git_diff} - Current uncommitted changes (git diff)
# {user_inputs} - Accumulated user inputs during workflow # {user_inputs} - Accumulated user inputs during workflow
# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") # {report_dir} - Report directory name
#
# Auto-injected sections (do NOT include in instruction_template):
# ## Workflow Context - iteration, step_iteration, report info
# ## User Request - {task}
# ## Previous Response - {previous_response}
# ## Additional User Inputs - {user_inputs}
name: simple name: simple
description: Simplified development workflow (plan -> implement -> review -> ai_review -> supervise) description: Simplified development workflow (plan -> implement -> ai_review -> review -> supervise)
max_iterations: 20 max_iterations: 20
@ -22,6 +27,7 @@ initial_step: plan
steps: steps:
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -39,20 +45,9 @@ steps:
next: ABORT next: ABORT
pass_previous_response: true pass_previous_response: true
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (when returned from implement) ## Previous Response (when returned from implement)
{previous_response} {previous_response}
## Instructions
Analyze the task and create an implementation plan. Analyze the task and create an implementation plan.
**Note:** If returned from implement step (Previous Response exists), **Note:** If returned from implement step (Previous Response exists),
@ -91,6 +86,9 @@ steps:
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -103,26 +101,10 @@ steps:
permission_mode: acceptEdits permission_mode: acceptEdits
rules: rules:
- condition: Implementation complete - condition: Implementation complete
next: review next: ai_review
- condition: Cannot proceed, insufficient info - condition: Cannot proceed, insufficient info
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
Follow the plan from the plan step and implement. Follow the plan from the plan step and implement.
Refer to the plan report (00-plan.md) and proceed with implementation. Refer to the plan report (00-plan.md) and proceed with implementation.
@ -160,8 +142,67 @@ steps:
- **Reason**: {Why this option was chosen} - **Reason**: {Why this option was chosen}
``` ```
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: No AI-specific issues
next: review
- condition: AI-specific issues found
next: plan
instruction_template: |
## Git Diff
```diff
{git_diff}
```
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues -> Summary 1 line + check table only (10 lines or less)
- Issues found -> + Issues in table format (25 lines or less)
- name: review - name: review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -171,27 +212,16 @@ steps:
- WebFetch - WebFetch
rules: rules:
- condition: No issues found - condition: No issues found
next: ai_review next: supervise
- condition: Structural fix required - condition: Structural fix required
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions Focus on **architecture and design** review. Do NOT review AI-specific issues (that's already done).
Focus on **architecture and design** review. Do NOT review AI-specific issues (that's the next step).
Review the changes and provide feedback. Review the changes and provide feedback.
@ -230,76 +260,11 @@ steps:
- APPROVE + minor suggestions -> Summary + suggestions (15 lines or less) - APPROVE + minor suggestions -> Summary + suggestions (15 lines or less)
- REJECT -> Issues in table format (30 lines or less) - REJECT -> Issues in table format (30 lines or less)
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: No AI-specific issues
next: supervise
- condition: AI-specific issues found
next: plan
instruction_template: |
## Workflow Context
- 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
## Original User Request (Initial request from workflow start)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
Review the code for AI-specific issues:
- Assumption validation
- Plausible but wrong patterns
- Context fit with existing codebase
- Scope creep detection
**Report output:** Output to the `Report File` specified above.
- If file does not exist: Create new file
- If file exists: Append with `## Iteration {step_iteration}` section
**Report format:**
```markdown
# AI-Generated Code Review
## Result: APPROVE / REJECT
## Summary
{One sentence summarizing result}
## Verified Items
| Aspect | Result | Notes |
|--------|--------|-------|
| Assumption validity | ✅ | - |
| API/Library existence | ✅ | - |
| Context fit | ✅ | - |
| Scope | ✅ | - |
## Issues (if REJECT)
| # | Category | Location | Issue |
|---|----------|----------|-------|
| 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
```
**Cognitive load reduction rules:**
- No issues -> Summary 1 line + check table only (10 lines or less)
- Issues found -> + Issues in table format (25 lines or less)
- name: supervise - name: supervise
agent: ~/.takt/agents/default/supervisor.md agent: ~/.takt/agents/default/supervisor.md
report:
- Validation: 05-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -314,24 +279,11 @@ steps:
- condition: Requirements unmet, tests failing - condition: Requirements unmet, tests failing
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- 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:
- Validation: .takt/reports/{report_dir}/05-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
Run tests, verify the build, and perform final approval. Run tests, verify the build, and perform final approval.
**Workflow Overall Review:** **Workflow Overall Review:**
@ -388,8 +340,8 @@ steps:
## Review Results ## Review Results
| Review | Result | | Review | Result |
|--------|--------| |--------|--------|
| Architect | ✅ APPROVE |
| AI Review | ✅ APPROVE | | AI Review | ✅ APPROVE |
| Architect | ✅ APPROVE |
| Supervisor | ✅ APPROVE | | Supervisor | ✅ APPROVE |
## Verification Commands ## Verification Commands

View File

@ -149,7 +149,54 @@ AIは自信を持って間違える——もっともらしく見えるが動か
2. 各フォールバックに正当な理由があるか確認 2. 各フォールバックに正当な理由があるか確認
3. 理由なしのフォールバックが1つでもあれば REJECT 3. 理由なしのフォールバックが1つでもあれば REJECT
### 8. 決定トレーサビリティレビュー ### 8. 未使用コードの検出
**AIは「将来の拡張性」「対称性」「念のため」で不要なコードを生成しがちである。現時点で呼ばれていないコードは削除する。**
| 判定 | 基準 |
|------|------|
| **REJECT** | 現在どこからも呼ばれていないpublic関数・メソッド |
| **REJECT** | 「対称性のため」に作られたが使われていないsetter/getter |
| **REJECT** | 将来の拡張のために用意されたインターフェースやオプション |
| **REJECT** | exportされているが、grep で使用箇所が見つからない |
| OK | フレームワークが暗黙的に呼び出す(ライフサイクルフック等) |
| OK | 公開パッケージのAPIとして意図的に公開している |
**検証アプローチ:**
1. 変更・削除されたコードを参照している箇所がないか grep で確認
2. 公開モジュールindex ファイル等)のエクスポート一覧と実体が一致しているか確認
3. 新規追加されたコードに対応する古いコードが残っていないか確認
### 9. 不要な後方互換コードの検出
**AIは「後方互換のために」不要なコードを残しがちである。これを見逃さない。**
削除すべき後方互換コード:
| パターン | 例 | 判定 |
|---------|-----|------|
| deprecated + 使用箇所なし | `@deprecated` アノテーション付きで誰も使っていない | **即削除** |
| 新APIと旧API両方存在 | 新関数があるのに旧関数も残っている | 旧を**削除** |
| 移行済みのラッパー | 互換のために作ったが移行完了済み | **削除** |
| コメントで「将来削除」 | `// TODO: remove after migration` が放置 | **今すぐ削除** |
| Proxy/アダプタの過剰使用 | 後方互換のためだけに複雑化 | **シンプルに置換** |
残すべき後方互換コード:
| パターン | 例 | 判定 |
|---------|-----|------|
| 外部公開API | npm パッケージのエクスポート | 慎重に検討 |
| 設定ファイル互換 | 旧形式の設定を読める | メジャーバージョンまで維持 |
| データ移行中 | DBスキーマ移行の途中 | 移行完了まで維持 |
**判断基準:**
1. **使用箇所があるか?** → grep/検索で確認。なければ削除
2. **外部に公開しているか?** → 内部のみなら即削除可能
3. **移行は完了したか?** → 完了なら削除
**AIが「後方互換のため」と言ったら疑う。** 本当に必要か確認せよ。
### 10. 決定トレーサビリティレビュー
**Coderの決定ログが妥当か検証する。** **Coderの決定ログが妥当か検証する。**

View File

@ -191,73 +191,6 @@ if (status === 'interrupted') {
} }
``` ```
**フォールバック値の乱用の判定基準:**
フォールバック値(`??`, `||`, デフォルト引数)は「値が無いケース」を握りつぶす。本来エラーにすべき箇所を隠してしまう。
| 判定 | 基準 |
|------|------|
| **REJECT** | 値が無い状態がバグであるのにフォールバックで隠している |
| **REJECT** | `'unknown'`, `'default'`, `''`, `0` など意味のない値でごまかしている |
| **REJECT** | 全呼び出し元がフォールバックに頼り、本来の値を渡していない |
| OK | 外部入力ユーザー入力、API応答に対する防御的デフォルト |
| OK | オプショナルな設定項目に対する合理的な初期値 |
```typescript
// ❌ REJECT - バグを隠すフォールバック
const userName = user.name ?? 'unknown'; // name が無いのはデータ不整合
const stepName = step?.name ?? 'default'; // step が無いのは呼び出し元のバグ
// ❌ REJECT - 全呼び出し元が省略しているオプション
function runStep(step: Step, options?: { maxRetries?: number }) {
const retries = options?.maxRetries ?? 3; // 全呼び出し元が options を渡していない
}
// ✅ OK - ユーザー設定のオプショナルなデフォルト
const logLevel = config.logLevel ?? 'info'; // 設定ファイルに無ければ info
const language = userPreference.lang ?? 'en'; // 未設定なら英語
// ✅ OK - 外部APIの防御的デフォルト
const displayName = apiResponse.nickname ?? apiResponse.email; // ニックネーム未設定の場合
```
**未使用コードの判定基準:**
AIは「将来の拡張性」「対称性」「念のため」で不要なコードを生成しがちである。現時点で呼ばれていないコードは削除する。
| 判定 | 基準 |
|------|------|
| **REJECT** | 現在どこからも呼ばれていないpublic関数・メソッド |
| **REJECT** | 「対称性のため」に作られたが使われていないsetter/getter |
| **REJECT** | 将来の拡張のために用意されたインターフェースやオプション |
| **REJECT** | exportされているが、grep で使用箇所が見つからない |
| OK | フレームワークが暗黙的に呼び出す(ライフサイクルフック等) |
| OK | 公開パッケージのAPIとして意図的に公開している |
```typescript
// ❌ REJECT - 「対称性のため」のsettergetしか使っていない
class WorkflowState {
private _status: Status;
getStatus(): Status { return this._status; }
setStatus(s: Status) { this._status = s; } // 誰も呼んでいない
}
// ❌ REJECT - 「将来の拡張」のためのオプション
interface EngineOptions {
maxIterations: number;
enableParallel?: boolean; // 未実装。どこからも参照されていない
pluginHooks?: PluginHook[]; // 未実装。プラグイン機構は存在しない
}
// ❌ REJECT - exportされているが使われていない
export function formatStepName(name: string): string { ... } // grep 結果: 0件
// ✅ OK - フレームワークが呼ぶ
class MyComponent extends React.Component {
componentDidMount() { ... } // Reactが呼ぶ
}
```
**状態の直接変更の判定基準:** **状態の直接変更の判定基準:**
オブジェクトや配列を直接変更すると、変更の追跡が困難になり、予期しない副作用を生む。常にスプレッド演算子やイミュータブルな操作で新しいオブジェクトを返す。 オブジェクトや配列を直接変更すると、変更の追跡が困難になり、予期しない副作用を生む。常にスプレッド演算子やイミュータブルな操作で新しいオブジェクトを返す。
@ -379,35 +312,6 @@ function createUser(data: UserData) {
} }
``` ```
### 7. 不要な後方互換コードの検出
**AIは「後方互換のために」不要なコードを残しがちである。これを見逃さない。**
削除すべき後方互換コード:
| パターン | 例 | 判定 |
|---------|-----|------|
| deprecated + 使用箇所なし | `@deprecated` アノテーション付きで誰も使っていない | **即削除** |
| 新APIと旧API両方存在 | 新関数があるのに旧関数も残っている | 旧を**削除** |
| 移行済みのラッパー | 互換のために作ったが移行完了済み | **削除** |
| コメントで「将来削除」 | `// TODO: remove after migration` が放置 | **今すぐ削除** |
| Proxy/アダプタの過剰使用 | 後方互換のためだけに複雑化 | **シンプルに置換** |
残すべき後方互換コード:
| パターン | 例 | 判定 |
|---------|-----|------|
| 外部公開API | npm パッケージのエクスポート | 慎重に検討 |
| 設定ファイル互換 | 旧形式の設定を読める | メジャーバージョンまで維持 |
| データ移行中 | DBスキーマ移行の途中 | 移行完了まで維持 |
**判断基準:**
1. **使用箇所があるか?** → grep/検索で確認。なければ削除
2. **外部に公開しているか?** → 内部のみなら即削除可能
3. **移行は完了したか?** → 完了なら削除
**AIが「後方互換のため」と言ったら疑う。** 本当に必要か確認せよ。
### 7. その場しのぎの検出 ### 7. その場しのぎの検出
**「とりあえず動かす」ための妥協を見逃さない。** **「とりあえず動かす」ための妥協を見逃さない。**

View File

@ -1,7 +1,7 @@
# Default TAKT Workflow # Default TAKT Workflow
# Plan -> Coder -> Architect Review -> AI Review -> Security Review -> Supervisor Approval # Plan -> Implement -> AI Review -> Architect Review -> Security Review -> Supervisor Approval
# #
# Template Variables: # Template Variables (auto-injected by buildInstruction):
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # {iteration} - Workflow-wide turn count (total steps executed across all agents)
# {max_iterations} - Maximum iterations allowed for the workflow # {max_iterations} - Maximum iterations allowed for the workflow
# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) # {step_iteration} - Per-step iteration count (how many times THIS step has been executed)
@ -14,13 +14,14 @@
name: default name: default
description: Standard development workflow with planning and specialized reviews description: Standard development workflow with planning and specialized reviews
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
steps: steps:
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -44,20 +45,9 @@ steps:
- {質問2} - {質問2}
pass_previous_response: true pass_previous_response: true
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (implementからの差し戻し時) ## Previous Response (implementからの差し戻し時)
{previous_response} {previous_response}
## Instructions
タスクを分析し、実装方針を立ててください。 タスクを分析し、実装方針を立ててください。
**注意:** Previous Responseがある場合は差し戻しのため、 **注意:** Previous Responseがある場合は差し戻しのため、
@ -68,7 +58,7 @@ steps:
2. 影響範囲を特定する 2. 影響範囲を特定する
3. 実装アプローチを決める 3. 実装アプローチを決める
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** Report File に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -96,6 +86,9 @@ steps:
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -108,26 +101,10 @@ steps:
permission_mode: acceptEdits permission_mode: acceptEdits
rules: rules:
- condition: 実装完了 - condition: 実装完了
next: review next: ai_review
- condition: 判断できない、情報不足 - condition: 判断できない、情報不足
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: implement
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
planステップで立てた計画に従って実装してください。 planステップで立てた計画に従って実装してください。
計画レポート00-plan.mdを参照し、実装を進めてください。 計画レポート00-plan.mdを参照し、実装を進めてください。
@ -136,7 +113,7 @@ steps:
- 既存コードを変更した場合は該当するテストを更新 - 既存コードを変更した場合は該当するテストを更新
- テストファイルの配置: プロジェクトの規約に従う(例: `__tests__/`, `*.test.ts` - テストファイルの配置: プロジェクトの規約に従う(例: `__tests__/`, `*.test.ts`
**レポート出力:** 上記の `Report Files` に出力してください。 **レポート出力:** Report Files に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -170,8 +147,96 @@ steps:
- **理由**: {選んだ理由} - **理由**: {選んだ理由}
``` ```
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: AI特有の問題なし
next: review
- condition: AI特有の問題あり
next: ai_fix
instruction_template: |
## Git Diff
```diff
{git_diff}
```
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** Report File に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: AI問題の修正完了
next: review
- condition: 判断できない、情報不足
next: plan
instruction_template: |
## AI Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response}
**重要**: AI Reviewerのフィードバックに対応してください。
以下に集中してください:
- 間違った仮定の修正
- もっともらしいが間違っている実装の修正
- 既存コードベースのパターンとの整合
- スコープクリープの除去
pass_previous_response: true
- name: review - name: review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -181,28 +246,17 @@ steps:
- WebFetch - WebFetch
rules: rules:
- condition: 問題なし - condition: 問題なし
next: ai_review next: security_review
- condition: 改善すべき点がある(軽微) - condition: 改善すべき点がある(軽微)
next: improve next: improve
- condition: 構造的な修正が必要 - condition: 構造的な修正が必要
next: fix next: fix
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
**アーキテクチャと設計**のレビューに集中してください。AI特有の問題はレビューしないでください次のステップで行います **アーキテクチャと設計**のレビューに集中してください。AI特有の問題はレビューしないでください次のステップで行います
変更をレビューしてフィードバックを提供してください。 変更をレビューしてフィードバックを提供してください。
@ -215,7 +269,7 @@ steps:
- デッドコード - デッドコード
- 呼び出しチェーン検証 - 呼び出しチェーン検証
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** Report File に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -268,21 +322,9 @@ steps:
- condition: 判断できない、情報不足 - condition: 判断できない、情報不足
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: improve
## Architect Feedback (これが最新の指示です - 優先して対応してください) ## Architect Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: Architectの改善提案に対応してください。 **重要**: Architectの改善提案に対応してください。
これらは軽微な改善であり、設計上の大きな問題ではありません。 これらは軽微な改善であり、設計上の大きな問題ではありません。
@ -293,75 +335,7 @@ steps:
- コードの整理 - コードの整理
pass_previous_response: true pass_previous_response: true
- name: ai_review - name: fix
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
rules:
- condition: AI特有の問題なし
next: security_review
- condition: AI特有の問題あり
next: ai_fix
instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
- name: ai_fix
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
allowed_tools: allowed_tools:
- Read - Read
@ -374,36 +348,21 @@ steps:
- WebFetch - WebFetch
permission_mode: acceptEdits permission_mode: acceptEdits
rules: rules:
- condition: AI問題の修正完了 - condition: Architectの指摘を修正完了
next: review next: review
- condition: 判断できない、情報不足 - condition: 判断できない、情報不足
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context ## Architect Feedback (これが最新の指示です - 優先して対応してください)
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: ai_fix
## AI Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報) **重要**: Architectのフィードバックに対応してください。
{task} セッションの会話履歴を確認し、Architectの指摘事項を修正してください。
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: AI Reviewerのフィードバックに対応してください。
以下に集中してください:
- 間違った仮定の修正
- もっともらしいが間違っている実装の修正
- 既存コードベースのパターンとの整合
- スコープクリープの除去
pass_previous_response: true pass_previous_response: true
- name: security_review - name: security_review
agent: ~/.takt/agents/default/security-reviewer.md agent: ~/.takt/agents/default/security-reviewer.md
report: 05-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -417,29 +376,18 @@ steps:
- condition: 脆弱性があり修正が必要 - condition: 脆弱性があり修正が必要
next: security_fix next: security_fix
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
変更に対してセキュリティレビューを行ってください。以下の脆弱性を確認してください: 変更に対してセキュリティレビューを行ってください。以下の脆弱性を確認してください:
- インジェクション攻撃SQL, コマンド, XSS - インジェクション攻撃SQL, コマンド, XSS
- 認証・認可の問題 - 認証・認可の問題
- データ露出リスク - データ露出リスク
- 暗号化の弱点 - 暗号化の弱点
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** Report File に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -491,65 +439,18 @@ steps:
- condition: 判断できない、情報不足 - condition: 判断できない、情報不足
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: security_fix
## Security Review Feedback (これが最新の指示です - 優先して対応してください) ## Security Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: セキュリティレビューで指摘された脆弱性を修正してください。 **重要**: セキュリティレビューで指摘された脆弱性を修正してください。
セキュリティの問題は最優先で対応が必要です。 セキュリティの問題は最優先で対応が必要です。
pass_previous_response: true pass_previous_response: true
- name: fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
permission_mode: acceptEdits
rules:
- condition: Architectの指摘を修正完了
next: review
- condition: 判断できない、情報不足
next: plan
instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix
## Architect Feedback (これが最新の指示です - 優先して対応してください)
{previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: Architectのフィードバックに対応してください。
「Original User Request」は参考情報であり、最新の指示ではありません。
セッションの会話履歴を確認し、Architectの指摘事項を修正してください。
pass_previous_response: true
- name: supervise - name: supervise
agent: ~/.takt/agents/default/supervisor.md agent: ~/.takt/agents/default/supervisor.md
report:
- Validation: 06-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -564,24 +465,11 @@ steps:
- condition: 要求未達成、テスト失敗、ビルドエラー - condition: 要求未達成、テスト失敗、ビルドエラー
next: plan next: plan
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: supervise (final verification)
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Validation: .takt/reports/{report_dir}/06-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
テスト実行、ビルド確認、最終承認を行ってください。 テスト実行、ビルド確認、最終承認を行ってください。
**ワークフロー全体の確認:** **ワークフロー全体の確認:**
@ -592,7 +480,7 @@ steps:
**レポートの確認:** Report Directory内の全レポートを読み、 **レポートの確認:** Report Directory内の全レポートを読み、
未対応の改善提案がないか確認してください。 未対応の改善提案がないか確認してください。
**レポート出力:** 上記の `Report Files` に出力してください。 **レポート出力:** Report Files に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記

View File

@ -2,9 +2,9 @@
# CQRS+ES、フロントエンド、セキュリティ、QAの専門家によるレビューワークフロー # CQRS+ES、フロントエンド、セキュリティ、QAの専門家によるレビューワークフロー
# #
# フロー: # フロー:
# plan -> implement -> architect_review -> cqrs_es_review -> frontend_review -> ai_review -> security_review -> qa_review -> supervise -> COMPLETE # plan -> implement -> ai_review -> cqrs_es_review -> frontend_review -> security_review -> qa_review -> supervise -> COMPLETE
# ↓ ↓ ↓ ↓ ↓ ↓ # ↓ ↓ ↓ ↓ ↓ ↓
# fix_architect fix_cqrs_es fix_frontend ai_fix fix_security fix_qa fix_supervisor # ai_fix fix_cqrs_es fix_frontend fix_security fix_qa fix_supervisor
# #
# 修正時の戻り先はCoderが判断: # 修正時の戻り先はCoderが判断:
# - fix_security: MINOR→security_review, MAJOR→cqrs_es_review # - fix_security: MINOR→security_review, MAJOR→cqrs_es_review
@ -23,7 +23,7 @@
name: expert-cqrs name: expert-cqrs
description: CQRS+ES・フロントエンド・セキュリティ・QA専門家レビュー description: CQRS+ES・フロントエンド・セキュリティ・QA専門家レビュー
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
@ -33,6 +33,7 @@ steps:
# =========================================== # ===========================================
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -42,20 +43,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (implementからの差し戻し時) ## Previous Response (implementからの差し戻し時)
{previous_response} {previous_response}
## Instructions
タスクを分析し、実装方針を立ててください。 タスクを分析し、実装方針を立ててください。
**注意:** Previous Responseがある場合は差し戻しのため、 **注意:** Previous Responseがある場合は差し戻しのため、
@ -66,7 +56,7 @@ steps:
2. 影響範囲を特定する 2. 影響範囲を特定する
3. 実装アプローチを決める 3. 実装アプローチを決める
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/00-plan.md に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -103,6 +93,9 @@ steps:
# =========================================== # ===========================================
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -113,26 +106,12 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: implement
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
planステップで立てた計画に従って実装してください。 planステップで立てた計画に従って実装してください。
計画レポート00-plan.mdを参照し、実装を進めてください。 計画レポート00-plan.mdを参照し、実装を進めてください。
**レポート出力:** 上記の `Report Files` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/ に出力してください。
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -167,15 +146,16 @@ steps:
``` ```
rules: rules:
- condition: 実装が完了した - condition: 実装が完了した
next: architect_review next: ai_review
- condition: 実装を進行できない - condition: 実装を進行できない
next: plan next: plan
# =========================================== # ===========================================
# Phase 2: Architecture Review # Phase 2: AI Review
# =========================================== # ===========================================
- name: architect_review - name: ai_review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -184,75 +164,54 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: architect_review (アーキテクチャレビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/03-architect-review.md
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions AI特有の問題についてコードをレビューしてください:
**アーキテクチャと設計**のレビューに集中してください。 - 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レビュー観点:** **レポート出力:** .takt/reports/{report_dir}/03-ai-review.md に出力してください。
- 構造・設計の妥当性
- コード品質
- 変更スコープの適切性
- テストカバレッジ
- デッドコード
- 呼び出しチェーン検証
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:** **レポートフォーマット:**
```markdown ```markdown
# アーキテクチャレビュー # AI生成コードレビュー
## 結果: APPROVE / IMPROVE / REJECT ## 結果: APPROVE / REJECT
## サマリー ## サマリー
{1-2文で結果を要約} {1文で結果を要約}
## 確認した観点 ## 検証した項目
- [x] 構造・設計 | 観点 | 結果 | 備考 |
- [x] コード品質 |------|------|------|
- [x] 変更スコープ | 仮定の妥当性 | ✅ | - |
- [x] テストカバレッジ | API/ライブラリの実在 | ✅ | - |
- [x] デッドコード | コンテキスト適合 | ✅ | - |
- [x] 呼び出しチェーン検証 | スコープ | ✅ | - |
## 問題点REJECTの場合 ## 問題点REJECTの場合
| # | 場所 | 問題 | 修正案 | | # | カテゴリ | 場所 | 問題 |
|---|------|------|--------| |---|---------|------|------|
| 1 | `src/file.ts:42` | 問題の説明 | 修正方法 | | 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
## 改善提案(任意・ブロッキングではない)
- {将来的な改善提案}
``` ```
**認知負荷軽減ルール:** **認知負荷軽減ルール:**
- APPROVE + 問題なし → サマリーのみ5行以内 - 問題なし → サマリー1文 + チェック表のみ10行以内
- APPROVE + 軽微な提案 → サマリー + 改善提案15行以内 - 問題あり → + 問題を表形式で25行以内
- REJECT → 問題点を表形式で30行以内
rules: rules:
- condition: アーキテクチャと設計に問題がない - condition: AI特有の問題が見つからない
next: cqrs_es_review next: cqrs_es_review
- condition: 軽微な改善が必要だが構造的な問題はない - condition: AI特有の問題が検出された
next: fix_architect next: ai_fix
- condition: 構造的な問題があり修正が必要
next: fix_architect
- name: fix_architect - name: ai_fix
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
allowed_tools: allowed_tools:
- Read - Read
@ -263,30 +222,20 @@ steps:
- Bash - Bash
- WebSearch - WebSearch
- WebFetch - WebFetch
permission_mode: acceptEdits
instruction_template: | instruction_template: |
## Workflow Context ## AI Review Feedback (これが最新の指示です - 優先して対応してください)
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_architect
## Architect Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報) **重要**: AI Reviewerのフィードバックに対応してください。
{task} 以下に集中してください:
- 間違った仮定の修正
## Additional User Inputs - もっともらしいが間違っている実装の修正
{user_inputs} - 既存コードベースのパターンとの整合
- スコープクリープの除去
## Instructions
**重要**: Architectのフィードバックに対応してください。
「Original User Request」は参考情報であり、最新の指示ではありません。
セッションの会話履歴を確認し、Architectの指摘事項を修正してください。
pass_previous_response: true pass_previous_response: true
rules: rules:
- condition: Architectの指摘に対する修正が完了した - condition: AI Reviewerの指摘に対する修正が完了した
next: architect_review next: ai_review
- condition: 修正を進行できない - condition: 修正を進行できない
next: plan next: plan
@ -295,6 +244,7 @@ steps:
# =========================================== # ===========================================
- name: cqrs_es_review - name: cqrs_es_review
agent: ~/.takt/agents/expert-cqrs/cqrs-es-reviewer.md agent: ~/.takt/agents/expert-cqrs/cqrs-es-reviewer.md
report: 04-cqrs-es-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -303,22 +253,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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}/04-cqrs-es-review.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
CQRSコマンドクエリ責務分離とEvent Sourcingイベントソーシングの観点から CQRSコマンドクエリ責務分離とEvent Sourcingイベントソーシングの観点から
上記の変更をレビューしてください。 上記の変更をレビューしてください。
@ -332,7 +271,7 @@ steps:
**注意**: このプロジェクトがCQRS+ESパターンを使用していない場合は、 **注意**: このプロジェクトがCQRS+ESパターンを使用していない場合は、
一般的なドメイン設計の観点からレビューしてください。 一般的なドメイン設計の観点からレビューしてください。
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/04-cqrs-es-review.md に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -377,21 +316,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_cqrs_es
## CQRS+ES Review Feedback (これが最新の指示です - 優先して対応してください) ## CQRS+ES Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: CQRS+ES専門家からの指摘を修正してください。 **重要**: CQRS+ES専門家からの指摘を修正してください。
指摘されたポイント: 指摘されたポイント:
@ -408,10 +335,11 @@ steps:
next: plan next: plan
# =========================================== # ===========================================
# Phase 3: Frontend Review # Phase 4: Frontend Review
# =========================================== # ===========================================
- name: frontend_review - name: frontend_review
agent: ~/.takt/agents/expert/frontend-reviewer.md agent: ~/.takt/agents/expert/frontend-reviewer.md
report: 05-frontend-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -420,22 +348,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: frontend_review (フロントエンド専門レビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/05-frontend-review.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
フロントエンド開発の観点から上記の変更をレビューしてください。 フロントエンド開発の観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -449,7 +366,7 @@ steps:
**注意**: このプロジェクトがフロントエンドを含まない場合は、 **注意**: このプロジェクトがフロントエンドを含まない場合は、
問題なしとして次に進んでください。 問題なしとして次に進んでください。
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/05-frontend-review.md に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -478,7 +395,7 @@ steps:
``` ```
rules: rules:
- condition: フロントエンド設計に問題がない - condition: フロントエンド設計に問題がない
next: ai_review next: security_review
- condition: フロントエンド設計に問題がある - condition: フロントエンド設計に問題がある
next: fix_frontend next: fix_frontend
@ -494,21 +411,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_frontend
## Frontend Review Feedback (これが最新の指示です - 優先して対応してください) ## Frontend Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: フロントエンド専門家からの指摘を修正してください。 **重要**: フロントエンド専門家からの指摘を修正してください。
指摘されたポイント: 指摘されたポイント:
@ -524,122 +429,12 @@ steps:
- condition: 修正を進行できない - condition: 修正を進行できない
next: plan next: plan
# ===========================================
# Phase 4: AI Review
# ===========================================
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: ai_review (AI生成コードレビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/06-ai-review.md
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
rules:
- condition: AI特有の問題が見つからない
next: security_review
- condition: AI特有の問題が検出された
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: ai_fix
## AI Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: AI Reviewerのフィードバックに対応してください。
以下に集中してください:
- 間違った仮定の修正
- もっともらしいが間違っている実装の修正
- 既存コードベースのパターンとの整合
- スコープクリープの除去
pass_previous_response: true
rules:
- condition: AI Reviewerの指摘に対する修正が完了した
next: ai_review
- condition: 修正を進行できない
next: plan
# =========================================== # ===========================================
# Phase 5: Security Review # Phase 5: Security Review
# =========================================== # ===========================================
- name: security_review - name: security_review
agent: ~/.takt/agents/expert/security-reviewer.md agent: ~/.takt/agents/expert/security-reviewer.md
report: 06-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -648,22 +443,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: security_review (セキュリティ専門レビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/07-security-review.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
セキュリティの観点から上記の変更をレビューしてください。 セキュリティの観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -673,7 +457,7 @@ steps:
- 暗号化の適切性 - 暗号化の適切性
- OWASP Top 10 - OWASP Top 10
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/06-security-review.md に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -719,21 +503,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_security
## Security Review Feedback (これが最新の指示です - 優先して対応してください) ## Security Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: セキュリティ専門家からの指摘を修正してください。 **重要**: セキュリティ専門家からの指摘を修正してください。
セキュリティ問題は最優先で対応してください。 セキュリティ問題は最優先で対応してください。
@ -764,6 +536,7 @@ steps:
# =========================================== # ===========================================
- name: qa_review - name: qa_review
agent: ~/.takt/agents/expert/qa-reviewer.md agent: ~/.takt/agents/expert/qa-reviewer.md
report: 07-qa-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -772,22 +545,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: qa_review (QA専門レビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/08-qa-review.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
品質保証の観点から上記の変更をレビューしてください。 品質保証の観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -798,7 +560,7 @@ steps:
- ログとモニタリング - ログとモニタリング
- 保守性 - 保守性
**レポート出力:** 上記の `Report File` に出力してください。 **レポート出力:** .takt/reports/{report_dir}/07-qa-review.md に出力してください。
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -843,21 +605,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_qa
## QA Review Feedback (これが最新の指示です - 優先して対応してください) ## QA Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: QA専門家からの指摘を修正してください。 **重要**: QA専門家からの指摘を修正してください。
指摘されたポイント: 指摘されたポイント:
@ -892,6 +642,9 @@ steps:
# =========================================== # ===========================================
- name: supervise - name: supervise
agent: ~/.takt/agents/expert/supervisor.md agent: ~/.takt/agents/expert/supervisor.md
report:
- Validation: 08-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -900,18 +653,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: supervise (最終確認)
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Validation: .takt/reports/{report_dir}/09-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
@ -919,14 +660,12 @@ steps:
## Previous Reviews Summary ## Previous Reviews Summary
このステップに到達したということは、以下のレビューがすべてAPPROVEされています このステップに到達したということは、以下のレビューがすべてAPPROVEされています
- Architecture Review: APPROVED - AI Review: APPROVED
- CQRS+ES Review: APPROVED - CQRS+ES Review: APPROVED
- Frontend Review: APPROVED - Frontend Review: APPROVED
- AI Review: APPROVED
- Security Review: APPROVED - Security Review: APPROVED
- QA Review: APPROVED - QA Review: APPROVED
## Instructions
テスト実行、ビルド確認、最終承認を行ってください。 テスト実行、ビルド確認、最終承認を行ってください。
**ワークフロー全体の確認:** **ワークフロー全体の確認:**
@ -934,10 +673,12 @@ steps:
2. 各レビューステップの指摘が対応されているか 2. 各レビューステップの指摘が対応されているか
3. 元のタスク目的が達成されているか 3. 元のタスク目的が達成されているか
**レポートの確認:** Report Directory内の全レポートを読み、 **レポートの確認:** .takt/reports/{report_dir}/ 内の全レポートを読み、
未対応の改善提案がないか確認してください。 未対応の改善提案がないか確認してください。
**レポート出力:** 上記の `Report Files` に出力してください。 **レポート出力:**
- Validation: .takt/reports/{report_dir}/08-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
- ファイルが存在しない場合: 新規作成 - ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記 - ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
@ -983,10 +724,9 @@ steps:
## レビュー結果 ## レビュー結果
| レビュー | 結果 | | レビュー | 結果 |
|---------|------| |---------|------|
| Architecture | ✅ APPROVE | | AI Review | ✅ APPROVE |
| CQRS+ES | ✅ APPROVE | | CQRS+ES | ✅ APPROVE |
| Frontend | ✅ APPROVE | | Frontend | ✅ APPROVE |
| AI Review | ✅ APPROVE |
| Security | ✅ APPROVE | | Security | ✅ APPROVE |
| QA | ✅ APPROVE | | QA | ✅ APPROVE |
| Supervisor | ✅ APPROVE | | Supervisor | ✅ APPROVE |
@ -1015,21 +755,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_supervisor
## Supervisor Feedback (これが最新の指示です - 優先して対応してください) ## Supervisor Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: 監督者からの指摘を修正してください。 **重要**: 監督者からの指摘を修正してください。
監督者は全体を俯瞰した視点から問題を指摘しています。 監督者は全体を俯瞰した視点から問題を指摘しています。

View File

@ -2,9 +2,9 @@
# アーキテクチャ、フロントエンド、セキュリティ、QAの専門家によるレビューワークフロー # アーキテクチャ、フロントエンド、セキュリティ、QAの専門家によるレビューワークフロー
# #
# フロー: # フロー:
# plan -> implement -> architect_review -> frontend_review -> ai_review -> security_review -> qa_review -> supervise -> COMPLETE # plan -> implement -> ai_review -> architect_review -> frontend_review -> security_review -> qa_review -> supervise -> COMPLETE
# ↓ ↓ ↓ ↓ ↓ # ↓ ↓ ↓ ↓ ↓
# fix_architect fix_frontend ai_fix fix_security fix_qa fix_supervisor # ai_fix fix_architect fix_frontend fix_security fix_qa fix_supervisor
# #
# 修正時の戻り先はCoderが判断: # 修正時の戻り先はCoderが判断:
# - fix_security: MINOR→security_review, MAJOR→architect_review # - fix_security: MINOR→security_review, MAJOR→architect_review
@ -23,7 +23,7 @@
name: expert name: expert
description: アーキテクチャ・フロントエンド・セキュリティ・QA専門家レビュー description: アーキテクチャ・フロントエンド・セキュリティ・QA専門家レビュー
max_iterations: 20 max_iterations: 30
initial_step: plan initial_step: plan
@ -33,6 +33,7 @@ steps:
# =========================================== # ===========================================
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -42,20 +43,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (implementからの差し戻し時) ## Previous Response (implementからの差し戻し時)
{previous_response} {previous_response}
## Instructions
タスクを分析し、実装方針を立ててください。 タスクを分析し、実装方針を立ててください。
**注意:** Previous Responseがある場合は差し戻しのため、 **注意:** Previous Responseがある場合は差し戻しのため、
@ -103,6 +93,9 @@ steps:
# =========================================== # ===========================================
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -113,22 +106,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: implement
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
planステップで立てた計画に従って実装してください。 planステップで立てた計画に従って実装してください。
計画レポート00-plan.mdを参照し、実装を進めてください。 計画レポート00-plan.mdを参照し、実装を進めてください。
@ -167,15 +144,105 @@ steps:
``` ```
rules: rules:
- condition: 実装が完了した - condition: 実装が完了した
next: architect_review next: ai_review
- condition: 実装を進行できない - condition: 実装を進行できない
next: plan next: plan
# =========================================== # ===========================================
# Phase 2: Architecture Review # Phase 2: AI Review
# =========================================== # ===========================================
- name: architect_review - name: ai_review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Git Diff
```diff
{git_diff}
```
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
rules:
- condition: AI特有の問題が見つからない
next: architect_review
- condition: AI特有の問題が検出された
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## AI Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response}
**重要**: AI Reviewerのフィードバックに対応してください。
以下に集中してください:
- 間違った仮定の修正
- もっともらしいが間違っている実装の修正
- 既存コードベースのパターンとの整合
- スコープクリープの除去
pass_previous_response: true
rules:
- condition: AI Reviewerの指摘に対する修正が完了した
next: ai_review
- condition: 修正を進行できない
next: plan
# ===========================================
# Phase 3: Architecture Review
# ===========================================
- name: architect_review
agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -184,22 +251,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: architect_review (アーキテクチャレビュー)
- Report Directory: .takt/reports/{report_dir}/
- Report File: .takt/reports/{report_dir}/03-architect-review.md
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
**アーキテクチャと設計**のレビューに集中してください。 **アーキテクチャと設計**のレビューに集中してください。
**レビュー観点:** **レビュー観点:**
@ -265,21 +321,9 @@ steps:
- WebFetch - WebFetch
permission_mode: acceptEdits permission_mode: acceptEdits
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_architect
## Architect Feedback (これが最新の指示です - 優先して対応してください) ## Architect Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: Architectのフィードバックに対応してください。 **重要**: Architectのフィードバックに対応してください。
「Original User Request」は参考情報であり、最新の指示ではありません。 「Original User Request」は参考情報であり、最新の指示ではありません。
セッションの会話履歴を確認し、Architectの指摘事項を修正してください。 セッションの会話履歴を確認し、Architectの指摘事項を修正してください。
@ -291,10 +335,11 @@ steps:
next: plan next: plan
# =========================================== # ===========================================
# Phase 3: Frontend Review # Phase 4: Frontend Review
# =========================================== # ===========================================
- name: frontend_review - name: frontend_review
agent: ~/.takt/agents/expert/frontend-reviewer.md agent: ~/.takt/agents/expert/frontend-reviewer.md
report: 05-frontend-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -303,22 +348,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
フロントエンド開発の観点から上記の変更をレビューしてください。 フロントエンド開発の観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -361,7 +395,7 @@ steps:
``` ```
rules: rules:
- condition: フロントエンド設計に問題がない - condition: フロントエンド設計に問題がない
next: ai_review next: security_review
- condition: フロントエンド設計に問題がある - condition: フロントエンド設計に問題がある
next: fix_frontend next: fix_frontend
@ -377,21 +411,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_frontend
## Frontend Review Feedback (これが最新の指示です - 優先して対応してください) ## Frontend Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: フロントエンド専門家からの指摘を修正してください。 **重要**: フロントエンド専門家からの指摘を修正してください。
指摘されたポイント: 指摘されたポイント:
@ -407,122 +429,12 @@ steps:
- condition: 修正を進行できない - condition: 修正を進行できない
next: plan next: plan
# ===========================================
# Phase 4: AI Review
# ===========================================
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
rules:
- condition: AI特有の問題が見つからない
next: security_review
- condition: AI特有の問題が検出された
next: ai_fix
- name: ai_fix
agent: ~/.takt/agents/default/coder.md
allowed_tools:
- Read
- Glob
- Grep
- Edit
- Write
- Bash
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: ai_fix
## AI Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: AI Reviewerのフィードバックに対応してください。
以下に集中してください:
- 間違った仮定の修正
- もっともらしいが間違っている実装の修正
- 既存コードベースのパターンとの整合
- スコープクリープの除去
pass_previous_response: true
rules:
- condition: AI Reviewerの指摘に対する修正が完了した
next: ai_review
- condition: 修正を進行できない
next: plan
# =========================================== # ===========================================
# Phase 5: Security Review # Phase 5: Security Review
# =========================================== # ===========================================
- name: security_review - name: security_review
agent: ~/.takt/agents/expert/security-reviewer.md agent: ~/.takt/agents/expert/security-reviewer.md
report: 06-security-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -531,22 +443,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
セキュリティの観点から上記の変更をレビューしてください。 セキュリティの観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -602,21 +503,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_security
## Security Review Feedback (これが最新の指示です - 優先して対応してください) ## Security Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: セキュリティ専門家からの指摘を修正してください。 **重要**: セキュリティ専門家からの指摘を修正してください。
セキュリティ問題は最優先で対応してください。 セキュリティ問題は最優先で対応してください。
@ -647,6 +536,7 @@ steps:
# =========================================== # ===========================================
- name: qa_review - name: qa_review
agent: ~/.takt/agents/expert/qa-reviewer.md agent: ~/.takt/agents/expert/qa-reviewer.md
report: 07-qa-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -655,22 +545,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
品質保証の観点から上記の変更をレビューしてください。 品質保証の観点から上記の変更をレビューしてください。
**レビュー観点:** **レビュー観点:**
@ -726,21 +605,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_qa
## QA Review Feedback (これが最新の指示です - 優先して対応してください) ## QA Review Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: QA専門家からの指摘を修正してください。 **重要**: QA専門家からの指摘を修正してください。
指摘されたポイント: 指摘されたポイント:
@ -775,6 +642,9 @@ steps:
# =========================================== # ===========================================
- name: supervise - name: supervise
agent: ~/.takt/agents/expert/supervisor.md agent: ~/.takt/agents/expert/supervisor.md
report:
- Validation: 08-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -783,18 +653,6 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: supervise (最終確認)
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Validation: .takt/reports/{report_dir}/08-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
@ -802,13 +660,12 @@ steps:
## Previous Reviews Summary ## Previous Reviews Summary
このステップに到達したということは、以下のレビューがすべてAPPROVEされています このステップに到達したということは、以下のレビューがすべてAPPROVEされています
- AI Review: APPROVED
- Architecture Review: APPROVED - Architecture Review: APPROVED
- Frontend Review: APPROVED - Frontend Review: APPROVED
- AI Review: APPROVED
- Security Review: APPROVED - Security Review: APPROVED
- QA Review: APPROVED - QA Review: APPROVED
## Instructions
テスト実行、ビルド確認、最終承認を行ってください。 テスト実行、ビルド確認、最終承認を行ってください。
**ワークフロー全体の確認:** **ワークフロー全体の確認:**
@ -865,9 +722,9 @@ steps:
## レビュー結果 ## レビュー結果
| レビュー | 結果 | | レビュー | 結果 |
|---------|------| |---------|------|
| AI Review | ✅ APPROVE |
| Architecture | ✅ APPROVE | | Architecture | ✅ APPROVE |
| Frontend | ✅ APPROVE | | Frontend | ✅ APPROVE |
| AI Review | ✅ APPROVE |
| Security | ✅ APPROVE | | Security | ✅ APPROVE |
| QA | ✅ APPROVE | | QA | ✅ APPROVE |
| Supervisor | ✅ APPROVE | | Supervisor | ✅ APPROVE |
@ -896,21 +753,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: fix_supervisor
## Supervisor Feedback (これが最新の指示です - 優先して対応してください) ## Supervisor Feedback (これが最新の指示です - 優先して対応してください)
{previous_response} {previous_response}
## Original User Request (ワークフロー開始時の元の要求 - 参考情報)
{task}
## Additional User Inputs
{user_inputs}
## Instructions
**重要**: 監督者からの指摘を修正してください。 **重要**: 監督者からの指摘を修正してください。
監督者は全体を俯瞰した視点から問題を指摘しています。 監督者は全体を俯瞰した視点から問題を指摘しています。

View File

@ -1,19 +1,19 @@
# Simple TAKT Workflow # Simple TAKT Workflow
# Plan -> Coder -> Architect Review -> AI Review -> Supervisor Approval # Plan -> Implement -> AI Review -> Architect Review -> Supervisor Approval
# (defaultの簡略版 - improve, fix, ai_fix, security_review, security_fix を削除) # (defaultの簡略版 - improve, fix, ai_fix, security_review, security_fix を削除)
# #
# Template Variables: # Template Variables (auto-injected):
# {iteration} - Workflow-wide turn count (total steps executed across all agents) # {iteration} - Workflow-wide turn count (total steps executed across all agents)
# {max_iterations} - Maximum iterations allowed for the workflow # {max_iterations} - Maximum iterations allowed for the workflow
# {step_iteration} - Per-step iteration count (how many times THIS step has been executed) # {step_iteration} - Per-step iteration count (how many times THIS step has been executed)
# {task} - Original user request # {task} - Original user request (auto-injected)
# {previous_response} - Output from the previous step # {previous_response} - Output from the previous step (auto-injected)
# {git_diff} - Current uncommitted changes (git diff) # {git_diff} - Current uncommitted changes (git diff)
# {user_inputs} - Accumulated user inputs during workflow # {user_inputs} - Accumulated user inputs during workflow (auto-injected)
# {report_dir} - Report directory name (e.g., "20250126-143052-task-summary") # {report_dir} - Report directory name (e.g., "20250126-143052-task-summary")
name: simple name: simple
description: Simplified development workflow (plan -> implement -> review -> ai_review -> supervise) description: Simplified development workflow (plan -> implement -> ai_review -> review -> supervise)
max_iterations: 20 max_iterations: 20
@ -22,6 +22,7 @@ initial_step: plan
steps: steps:
- name: plan - name: plan
agent: ~/.takt/agents/default/planner.md agent: ~/.takt/agents/default/planner.md
report: 00-plan.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -31,20 +32,9 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## User Request
{task}
## Previous Response (implementからの差し戻し時) ## Previous Response (implementからの差し戻し時)
{previous_response} {previous_response}
## Instructions
タスクを分析し、実装方針を立ててください。 タスクを分析し、実装方針を立ててください。
**注意:** Previous Responseがある場合は差し戻しのため、 **注意:** Previous Responseがある場合は差し戻しのため、
@ -55,10 +45,6 @@ steps:
2. 影響範囲を特定する 2. 影響範囲を特定する
3. 実装アプローチを決める 3. 実装アプローチを決める
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:** **レポートフォーマット:**
```markdown ```markdown
# タスク計画 # タスク計画
@ -95,6 +81,9 @@ steps:
- name: implement - name: implement
agent: ~/.takt/agents/default/coder.md agent: ~/.takt/agents/default/coder.md
report:
- Scope: 01-coder-scope.md
- Decisions: 02-coder-decisions.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -106,29 +95,9 @@ steps:
- WebFetch - WebFetch
permission_mode: acceptEdits permission_mode: acceptEdits
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: implement
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Scope: .takt/reports/{report_dir}/01-coder-scope.md
- Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
## User Request
{task}
## Additional User Inputs
{user_inputs}
## Instructions
planステップで立てた計画に従って実装してください。 planステップで立てた計画に従って実装してください。
計画レポート00-plan.mdを参照し、実装を進めてください。 計画レポート00-plan.mdを参照し、実装を進めてください。
**レポート出力:** 上記の `Report Files` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**Scopeレポートフォーマット実装開始時に作成:** **Scopeレポートフォーマット実装開始時に作成:**
```markdown ```markdown
# 変更スコープ宣言 # 変更スコープ宣言
@ -160,12 +129,13 @@ steps:
``` ```
rules: rules:
- condition: "実装完了" - condition: "実装完了"
next: review next: ai_review
- condition: "判断できない、情報不足" - condition: "判断できない、情報不足"
next: plan next: plan
- name: review - name: ai_review
agent: ~/.takt/agents/default/architecture-reviewer.md agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
report: 03-ai-review.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -174,33 +144,72 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions AI特有の問題についてコードをレビューしてください:
**アーキテクチャと設計**のレビューに集中してください。AI特有の問題はレビューしないでください次のステップで行います - 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
rules:
- condition: "AI特有の問題なし"
next: review
- condition: "AI特有の問題あり"
next: plan
- name: review
agent: ~/.takt/agents/default/architecture-reviewer.md
report: 04-architect-review.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Git Diff
```diff
{git_diff}
```
**アーキテクチャと設計**のレビューに集中してください。AI特有の問題はレビューしないでください前のステップで完了済み
変更をレビューしてフィードバックを提供してください。 変更をレビューしてフィードバックを提供してください。
**注意:** simpleワークフローではIMPROVE判定は使用しません。 **注意:** simpleワークフローではIMPROVE判定は使用しません。
軽微な改善提案がある場合は APPROVE + コメントとしてください。 軽微な改善提案がある場合は APPROVE + コメントとしてください。
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:** **レポートフォーマット:**
```markdown ```markdown
# アーキテクチャレビュー # アーキテクチャレビュー
@ -230,80 +239,15 @@ steps:
- REJECT → 問題点を表形式で30行以内 - REJECT → 問題点を表形式で30行以内
rules: rules:
- condition: "問題なし" - condition: "問題なし"
next: ai_review
- condition: "構造的な修正必要"
next: plan
- name: ai_review
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
allowed_tools:
- Read
- Glob
- Grep
- Write
- WebSearch
- WebFetch
instruction_template: |
## Workflow Context
- 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
## Original User Request (ワークフロー開始時の元の要求)
{task}
## Git Diff
```diff
{git_diff}
```
## Instructions
AI特有の問題についてコードをレビューしてください:
- 仮定の検証
- もっともらしいが間違っているパターン
- 既存コードベースとの適合性
- スコープクリープの検出
**レポート出力:** 上記の `Report File` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**レポートフォーマット:**
```markdown
# AI生成コードレビュー
## 結果: APPROVE / REJECT
## サマリー
{1文で結果を要約}
## 検証した項目
| 観点 | 結果 | 備考 |
|------|------|------|
| 仮定の妥当性 | ✅ | - |
| API/ライブラリの実在 | ✅ | - |
| コンテキスト適合 | ✅ | - |
| スコープ | ✅ | - |
## 問題点REJECTの場合
| # | カテゴリ | 場所 | 問題 |
|---|---------|------|------|
| 1 | 幻覚API | `src/file.ts:23` | 存在しないメソッド |
```
**認知負荷軽減ルール:**
- 問題なし → サマリー1文 + チェック表のみ10行以内
- 問題あり → + 問題を表形式で25行以内
rules:
- condition: "AI特有の問題なし"
next: supervise next: supervise
- condition: "AI特有の問題あり" - condition: "構造的な修正必要"
next: plan next: plan
- name: supervise - name: supervise
agent: ~/.takt/agents/default/supervisor.md agent: ~/.takt/agents/default/supervisor.md
report:
- Validation: 05-supervisor-validation.md
- Summary: summary.md
allowed_tools: allowed_tools:
- Read - Read
- Glob - Glob
@ -313,24 +257,11 @@ steps:
- WebSearch - WebSearch
- WebFetch - WebFetch
instruction_template: | instruction_template: |
## Workflow Context
- Iteration: {iteration}/{max_iterations}(ワークフロー全体)
- Step Iteration: {step_iteration}(このステップの実行回数)
- Step: supervise (final verification)
- Report Directory: .takt/reports/{report_dir}/
- Report Files:
- Validation: .takt/reports/{report_dir}/05-supervisor-validation.md
- Summary: .takt/reports/{report_dir}/summary.md
## Original User Request
{task}
## Git Diff ## Git Diff
```diff ```diff
{git_diff} {git_diff}
``` ```
## Instructions
テスト実行、ビルド確認、最終承認を行ってください。 テスト実行、ビルド確認、最終承認を行ってください。
**ワークフロー全体の確認:** **ワークフロー全体の確認:**
@ -341,10 +272,6 @@ steps:
**レポートの確認:** Report Directory内の全レポートを読み、 **レポートの確認:** Report Directory内の全レポートを読み、
未対応の改善提案がないか確認してください。 未対応の改善提案がないか確認してください。
**レポート出力:** 上記の `Report Files` に出力してください。
- ファイルが存在しない場合: 新規作成
- ファイルが存在する場合: `## Iteration {step_iteration}` セクションを追記
**Validationレポートフォーマット:** **Validationレポートフォーマット:**
```markdown ```markdown
# 最終検証結果 # 最終検証結果
@ -387,8 +314,8 @@ steps:
## レビュー結果 ## レビュー結果
| レビュー | 結果 | | レビュー | 結果 |
|---------|------| |---------|------|
| Architect | ✅ APPROVE |
| AI Review | ✅ APPROVE | | AI Review | ✅ APPROVE |
| Architect | ✅ APPROVE |
| Supervisor | ✅ APPROVE | | Supervisor | ✅ APPROVE |
## 確認コマンド ## 確認コマンド

View File

@ -344,6 +344,205 @@ describe('instruction-builder', () => {
}); });
}); });
describe('auto-injected Workflow Context section', () => {
it('should include iteration, step iteration, and step name', () => {
const step = createMinimalStep('Do work');
step.name = 'implement';
const context = createMinimalContext({
iteration: 3,
maxIterations: 20,
stepIteration: 2,
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('## Workflow Context');
expect(result).toContain('- Iteration: 3/20');
expect(result).toContain('- Step Iteration: 2');
expect(result).toContain('- Step: implement');
});
it('should include single report file when report is a string', () => {
const step = createMinimalStep('Do work');
step.name = 'plan';
step.report = '00-plan.md';
const context = createMinimalContext({
reportDir: '20260129-test',
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('- Report Directory: .takt/reports/20260129-test/');
expect(result).toContain('- Report File: .takt/reports/20260129-test/00-plan.md');
expect(result).not.toContain('Report Files:');
});
it('should include multiple report files when report is ReportConfig[]', () => {
const step = createMinimalStep('Do work');
step.name = 'implement';
step.report = [
{ label: 'Scope', path: '01-scope.md' },
{ label: 'Decisions', path: '02-decisions.md' },
];
const context = createMinimalContext({
reportDir: '20260129-test',
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('- Report Directory: .takt/reports/20260129-test/');
expect(result).toContain('- Report Files:');
expect(result).toContain(' - Scope: .takt/reports/20260129-test/01-scope.md');
expect(result).toContain(' - Decisions: .takt/reports/20260129-test/02-decisions.md');
expect(result).not.toContain('Report File:');
});
it('should NOT include report info when reportDir is undefined', () => {
const step = createMinimalStep('Do work');
step.report = '00-plan.md';
const context = createMinimalContext({ language: 'en' });
const result = buildInstruction(step, context);
expect(result).toContain('## Workflow Context');
expect(result).not.toContain('Report Directory');
expect(result).not.toContain('Report File');
});
it('should NOT include report info when step has no report', () => {
const step = createMinimalStep('Do work');
const context = createMinimalContext({
reportDir: '20260129-test',
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('## Workflow Context');
expect(result).not.toContain('Report Directory');
expect(result).not.toContain('Report File');
});
it('should render Japanese step iteration suffix', () => {
const step = createMinimalStep('Do work');
const context = createMinimalContext({
stepIteration: 3,
language: 'ja',
});
const result = buildInstruction(step, context);
expect(result).toContain('- Step Iteration: 3このステップの実行回数');
});
});
describe('auto-injected User Request and Additional User Inputs sections', () => {
it('should include User Request section with task', () => {
const step = createMinimalStep('Do work');
const context = createMinimalContext({ task: 'Build the feature', language: 'en' });
const result = buildInstruction(step, context);
expect(result).toContain('## User Request\n');
});
it('should include Additional User Inputs section', () => {
const step = createMinimalStep('Do work');
const context = createMinimalContext({
userInputs: ['input1', 'input2'],
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('## Additional User Inputs\n');
});
it('should include Previous Response when passPreviousResponse is true and output exists', () => {
const step = createMinimalStep('Do work');
step.passPreviousResponse = true;
const context = createMinimalContext({
previousOutput: { content: 'Previous result', tag: '[TEST:1]' },
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).toContain('## Previous Response\n');
});
it('should NOT include Previous Response when passPreviousResponse is false', () => {
const step = createMinimalStep('Do work');
step.passPreviousResponse = false;
const context = createMinimalContext({
previousOutput: { content: 'Previous result', tag: '[TEST:1]' },
language: 'en',
});
const result = buildInstruction(step, context);
expect(result).not.toContain('## Previous Response');
});
it('should include Instructions header before template content', () => {
const step = createMinimalStep('My specific instructions here');
const context = createMinimalContext({ language: 'en' });
const result = buildInstruction(step, context);
const instructionsIdx = result.indexOf('## Instructions');
const contentIdx = result.indexOf('My specific instructions here');
expect(instructionsIdx).toBeGreaterThan(-1);
expect(contentIdx).toBeGreaterThan(instructionsIdx);
});
it('should skip auto-injected User Request when template contains {task}', () => {
const step = createMinimalStep('Process this: {task}');
const context = createMinimalContext({ task: 'My task', language: 'en' });
const result = buildInstruction(step, context);
// Auto-injected section should NOT appear
expect(result).not.toContain('## User Request');
// But template placeholder should be replaced
expect(result).toContain('Process this: My task');
});
it('should skip auto-injected Previous Response when template contains {previous_response}', () => {
const step = createMinimalStep('## Feedback\n{previous_response}\n\nFix the issues.');
step.passPreviousResponse = true;
const context = createMinimalContext({
previousOutput: { content: 'Review feedback here', tag: '[TEST:1]' },
language: 'en',
});
const result = buildInstruction(step, context);
// Auto-injected section should NOT appear
expect(result).not.toContain('## Previous Response\n');
// But template placeholder should be replaced with content
expect(result).toContain('## Feedback\nReview feedback here');
});
it('should skip auto-injected Additional User Inputs when template contains {user_inputs}', () => {
const step = createMinimalStep('Inputs: {user_inputs}');
const context = createMinimalContext({
userInputs: ['extra info'],
language: 'en',
});
const result = buildInstruction(step, context);
// Auto-injected section should NOT appear
expect(result).not.toContain('## Additional User Inputs');
// But template placeholder should be replaced
expect(result).toContain('Inputs: extra info');
});
});
describe('basic placeholder replacement', () => { describe('basic placeholder replacement', () => {
it('should replace {task} placeholder', () => { it('should replace {task} placeholder', () => {
const step = createMinimalStep('Execute: {task}'); const step = createMinimalStep('Execute: {task}');

View File

@ -8,7 +8,7 @@ import { readFileSync, existsSync, readdirSync, statSync } from 'node:fs';
import { join, dirname, basename } from 'node:path'; import { join, dirname, basename } from 'node:path';
import { parse as parseYaml } from 'yaml'; import { parse as parseYaml } from 'yaml';
import { WorkflowConfigRawSchema } from '../models/schemas.js'; import { WorkflowConfigRawSchema } from '../models/schemas.js';
import type { WorkflowConfig, WorkflowStep, WorkflowRule } from '../models/types.js'; import type { WorkflowConfig, WorkflowStep, WorkflowRule, ReportConfig } from '../models/types.js';
import { getGlobalWorkflowsDir } from './paths.js'; import { getGlobalWorkflowsDir } from './paths.js';
/** Get builtin workflow by name */ /** Get builtin workflow by name */
@ -54,6 +54,28 @@ function extractAgentDisplayName(agentPath: string): string {
return filename; return filename;
} }
/**
* Normalize the raw report field from YAML into internal format.
*
* YAML formats:
* report: "00-plan.md" string (single file)
* report: ReportConfig[] (multiple files)
* - Scope: 01-scope.md
* - Decisions: 02-decisions.md
*
* Array items are parsed as single-key objects: [{Scope: "01-scope.md"}, ...]
*/
function normalizeReport(
raw: string | Record<string, string>[] | undefined,
): string | ReportConfig[] | undefined {
if (raw == null) return undefined;
if (typeof raw === 'string') return raw;
// Convert [{Scope: "01-scope.md"}, ...] to [{label: "Scope", path: "01-scope.md"}, ...]
return raw.flatMap((entry) =>
Object.entries(entry).map(([label, path]) => ({ label, path })),
);
}
/** /**
* Convert raw YAML workflow config to internal format. * Convert raw YAML workflow config to internal format.
* Agent paths are resolved relative to the workflow directory. * Agent paths are resolved relative to the workflow directory.
@ -79,6 +101,7 @@ function normalizeWorkflowConfig(raw: unknown, workflowDir: string): WorkflowCon
permissionMode: step.permission_mode, permissionMode: step.permission_mode,
instructionTemplate: step.instruction_template || step.instruction || '{task}', instructionTemplate: step.instruction_template || step.instruction || '{task}',
rules, rules,
report: normalizeReport(step.report),
passPreviousResponse: step.pass_previous_response, passPreviousResponse: step.pass_previous_response,
}; };
}); });

View File

@ -2,6 +2,7 @@
export type { export type {
AgentType, AgentType,
Status, Status,
ReportConfig,
AgentResponse, AgentResponse,
SessionState, SessionState,
WorkflowStep, WorkflowStep,

View File

@ -27,6 +27,22 @@ export const StatusSchema = z.enum([
/** Permission mode schema for tool execution */ /** Permission mode schema for tool execution */
export const PermissionModeSchema = z.enum(['default', 'acceptEdits', 'bypassPermissions']); export const PermissionModeSchema = z.enum(['default', 'acceptEdits', 'bypassPermissions']);
/**
* Report field schema.
*
* YAML formats:
* report: 00-plan.md # single file
* report: # multiple files (label: path map entries)
* - Scope: 01-scope.md
* - Decisions: 02-decisions.md
*
* Array items are parsed as single-key objects: [{Scope: "01-scope.md"}, ...]
*/
export const ReportFieldSchema = z.union([
z.string().min(1),
z.array(z.record(z.string(), z.string())).min(1),
]);
/** Rule-based transition schema (new unified format) */ /** Rule-based transition schema (new unified format) */
export const WorkflowRuleSchema = z.object({ export const WorkflowRuleSchema = z.object({
/** Human-readable condition text */ /** Human-readable condition text */
@ -52,6 +68,8 @@ export const WorkflowStepRawSchema = z.object({
instruction_template: z.string().optional(), instruction_template: z.string().optional(),
/** Rules for step routing */ /** Rules for step routing */
rules: z.array(WorkflowRuleSchema).optional(), rules: z.array(WorkflowRuleSchema).optional(),
/** Report file(s) for this step */
report: ReportFieldSchema.optional(),
pass_previous_response: z.boolean().optional().default(true), pass_previous_response: z.boolean().optional().default(true),
}); });

View File

@ -50,6 +50,14 @@ export interface WorkflowRule {
appendix?: string; appendix?: string;
} }
/** Report file configuration for a workflow step */
export interface ReportConfig {
/** Display label (e.g., "Scope", "Decisions") */
label: string;
/** File path relative to report directory (e.g., "01-coder-scope.md") */
path: string;
}
/** Permission mode for tool execution */ /** Permission mode for tool execution */
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions'; export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions';
@ -73,6 +81,8 @@ export interface WorkflowStep {
instructionTemplate: string; instructionTemplate: string;
/** Rules for step routing */ /** Rules for step routing */
rules?: WorkflowRule[]; rules?: WorkflowRule[];
/** Report file configuration. Single string for one file, array for multiple. */
report?: string | ReportConfig[];
passPreviousResponse: boolean; passPreviousResponse: boolean;
} }

View File

@ -1,11 +1,14 @@
/** /**
* Instruction template builder for workflow steps * Instruction template builder for workflow steps
* *
* Builds the instruction string for agent execution by replacing * Builds the instruction string for agent execution by:
* template placeholders with actual values. * 1. Auto-injecting standard sections (Execution Context, Workflow Context,
* User Request, Previous Response, Additional User Inputs, Instructions header)
* 2. Replacing template placeholders with actual values
* 3. Appending auto-generated status rules from workflow rules
*/ */
import type { WorkflowStep, WorkflowRule, AgentResponse, Language } from '../models/types.js'; import type { WorkflowStep, WorkflowRule, AgentResponse, Language, ReportConfig } from '../models/types.js';
import { getGitDiff } from '../agents/runner.js'; import { getGitDiff } from '../agents/runner.js';
/** /**
@ -213,76 +216,207 @@ function escapeTemplateChars(str: string): string {
return str.replace(/\{/g, '').replace(/\}/g, ''); return str.replace(/\{/g, '').replace(/\}/g, '');
} }
/** Localized strings for auto-injected sections */
const SECTION_STRINGS = {
en: {
workflowContext: '## Workflow Context',
iteration: 'Iteration',
iterationWorkflowWide: '(workflow-wide)',
stepIteration: 'Step Iteration',
stepIterationTimes: '(times this step has run)',
step: 'Step',
reportDirectory: 'Report Directory',
reportFile: 'Report File',
reportFiles: 'Report Files',
userRequest: '## User Request',
previousResponse: '## Previous Response',
additionalUserInputs: '## Additional User Inputs',
instructions: '## Instructions',
},
ja: {
workflowContext: '## Workflow Context',
iteration: 'Iteration',
iterationWorkflowWide: '(ワークフロー全体)',
stepIteration: 'Step Iteration',
stepIterationTimes: '(このステップの実行回数)',
step: 'Step',
reportDirectory: 'Report Directory',
reportFile: 'Report File',
reportFiles: 'Report Files',
userRequest: '## User Request',
previousResponse: '## Previous Response',
additionalUserInputs: '## Additional User Inputs',
instructions: '## Instructions',
},
} as const;
/** /**
* Build instruction from template with context values. * Render the Workflow Context section.
*
* Supported placeholders:
* - {task} - The main task/prompt
* - {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
* - {report_dir} - Report directory name (e.g., "20250126-143052-task-summary")
*/ */
export function buildInstruction( function renderWorkflowContext(
step: WorkflowStep, step: WorkflowStep,
context: InstructionContext context: InstructionContext,
language: Language,
): string { ): string {
let instruction = step.instructionTemplate; const s = SECTION_STRINGS[language];
const lines: string[] = [
s.workflowContext,
`- ${s.iteration}: ${context.iteration}/${context.maxIterations}${s.iterationWorkflowWide}`,
`- ${s.stepIteration}: ${context.stepIteration}${s.stepIterationTimes}`,
`- ${s.step}: ${step.name}`,
];
// Report info (only if step has report config AND reportDir is available)
if (step.report && context.reportDir) {
lines.push(`- ${s.reportDirectory}: .takt/reports/${context.reportDir}/`);
if (typeof step.report === 'string') {
// Single file
lines.push(`- ${s.reportFile}: .takt/reports/${context.reportDir}/${step.report}`);
} else {
// Multiple files
lines.push(`- ${s.reportFiles}:`);
for (const file of step.report as ReportConfig[]) {
lines.push(` - ${file.label}: .takt/reports/${context.reportDir}/${file.path}`);
}
}
}
return lines.join('\n');
}
/**
* Replace template placeholders in the instruction_template body.
*
* These placeholders may still be used in instruction_template for
* backward compatibility or special cases (e.g., {git_diff} in review steps).
*/
function replaceTemplatePlaceholders(
template: string,
step: WorkflowStep,
context: InstructionContext,
): string {
let result = template;
// These placeholders are also covered by auto-injected sections
// (User Request, Previous Response, Additional User Inputs), but kept here
// for backward compatibility with workflows that still embed them in
// instruction_template (e.g., research.yaml, magi.yaml).
// New workflows should NOT use {task} or {user_inputs} in instruction_template
// since they are auto-injected as separate sections.
// Replace {task} // Replace {task}
instruction = instruction.replace(/\{task\}/g, escapeTemplateChars(context.task)); result = result.replace(/\{task\}/g, escapeTemplateChars(context.task));
// Replace {iteration}, {max_iterations}, and {step_iteration} // Replace {iteration}, {max_iterations}, and {step_iteration}
instruction = instruction.replace(/\{iteration\}/g, String(context.iteration)); result = result.replace(/\{iteration\}/g, String(context.iteration));
instruction = instruction.replace(/\{max_iterations\}/g, String(context.maxIterations)); result = result.replace(/\{max_iterations\}/g, String(context.maxIterations));
instruction = instruction.replace(/\{step_iteration\}/g, String(context.stepIteration)); result = result.replace(/\{step_iteration\}/g, String(context.stepIteration));
// Replace {previous_response} // Replace {previous_response}
if (step.passPreviousResponse) { if (step.passPreviousResponse) {
if (context.previousOutput) { if (context.previousOutput) {
instruction = instruction.replace( result = result.replace(
/\{previous_response\}/g, /\{previous_response\}/g,
escapeTemplateChars(context.previousOutput.content) escapeTemplateChars(context.previousOutput.content),
); );
} else { } else {
instruction = instruction.replace(/\{previous_response\}/g, ''); result = result.replace(/\{previous_response\}/g, '');
} }
} }
// Replace {git_diff} // Replace {git_diff}
const gitDiff = getGitDiff(context.cwd); const gitDiff = getGitDiff(context.cwd);
instruction = instruction.replace(/\{git_diff\}/g, gitDiff); result = result.replace(/\{git_diff\}/g, gitDiff);
// Replace {user_inputs} // Replace {user_inputs}
const userInputsStr = context.userInputs.join('\n'); const userInputsStr = context.userInputs.join('\n');
instruction = instruction.replace( result = result.replace(
/\{user_inputs\}/g, /\{user_inputs\}/g,
escapeTemplateChars(userInputsStr) escapeTemplateChars(userInputsStr),
); );
// Replace {report_dir} with the directory name, keeping paths relative. // Replace {report_dir}
// In worktree mode, a symlink from cwd/.takt/reports → projectCwd/.takt/reports
// ensures the relative path resolves correctly without embedding absolute paths
// that could cause agents to operate on the wrong repository.
if (context.reportDir) { if (context.reportDir) {
instruction = instruction.replace(/\{report_dir\}/g, context.reportDir); result = result.replace(/\{report_dir\}/g, context.reportDir);
} }
// Append auto-generated status rules from rules return result;
}
/**
* Build instruction from template with context values.
*
* Generates a complete instruction by auto-injecting standard sections
* around the step-specific instruction_template content:
*
* 1. Execution Context (working directory, rules) always
* 2. Workflow Context (iteration, step, report info) always
* 3. User Request ({task}) unless template contains {task}
* 4. Previous Response if passPreviousResponse and has content, unless template contains {previous_response}
* 5. Additional User Inputs unless template contains {user_inputs}
* 6. Instructions header + instruction_template content always
* 7. Status Output Rules if rules exist
*
* Template placeholders ({task}, {git_diff}, etc.) are still replaced
* within the instruction_template body for backward compatibility.
* When a placeholder is present in the template, the corresponding
* auto-injected section is skipped to avoid duplication.
*/
export function buildInstruction(
step: WorkflowStep,
context: InstructionContext,
): string {
const language = context.language ?? 'en'; const language = context.language ?? 'en';
const s = SECTION_STRINGS[language];
const sections: string[] = [];
// 1. Execution context metadata (working directory + rules)
const metadata = buildExecutionMetadata(context);
sections.push(renderExecutionMetadata(metadata));
// 2. Workflow Context (iteration, step, report info)
sections.push(renderWorkflowContext(step, context, language));
// Skip auto-injection for sections whose placeholders exist in the template,
// to avoid duplicate content. Templates using placeholders handle their own layout.
const tmpl = step.instructionTemplate;
const hasTaskPlaceholder = tmpl.includes('{task}');
const hasPreviousResponsePlaceholder = tmpl.includes('{previous_response}');
const hasUserInputsPlaceholder = tmpl.includes('{user_inputs}');
// 3. User Request (skip if template embeds {task} directly)
if (!hasTaskPlaceholder) {
sections.push(`${s.userRequest}\n${escapeTemplateChars(context.task)}`);
}
// 4. Previous Response (skip if template embeds {previous_response} directly)
if (step.passPreviousResponse && context.previousOutput && !hasPreviousResponsePlaceholder) {
sections.push(
`${s.previousResponse}\n${escapeTemplateChars(context.previousOutput.content)}`,
);
}
// 5. Additional User Inputs (skip if template embeds {user_inputs} directly)
if (!hasUserInputsPlaceholder) {
const userInputsStr = context.userInputs.join('\n');
sections.push(`${s.additionalUserInputs}\n${escapeTemplateChars(userInputsStr)}`);
}
// 6. Instructions header + instruction_template content
const processedTemplate = replaceTemplatePlaceholders(
step.instructionTemplate,
step,
context,
);
sections.push(`${s.instructions}\n${processedTemplate}`);
// 7. Status rules (auto-generated from rules)
if (step.rules && step.rules.length > 0) { if (step.rules && step.rules.length > 0) {
const statusHeader = renderStatusRulesHeader(language); const statusHeader = renderStatusRulesHeader(language);
const generatedPrompt = generateStatusRulesFromRules(step.name, step.rules, language); const generatedPrompt = generateStatusRulesFromRules(step.name, step.rules, language);
instruction = `${instruction}\n\n${statusHeader}\n${generatedPrompt}`; sections.push(`${statusHeader}\n${generatedPrompt}`);
} }
// Prepend execution context metadata so agents see it first. return sections.join('\n\n');
// Now language-aware, so no need to hide it at the end.
const metadata = buildExecutionMetadata(context);
instruction = `${renderExecutionMetadata(metadata)}\n${instruction}`;
return instruction;
} }