diff --git a/resources/global/en/agents/default/ai-antipattern-reviewer.md b/resources/global/en/agents/default/ai-antipattern-reviewer.md index 046c392..48b722e 100644 --- a/resources/global/en/agents/default/ai-antipattern-reviewer.md +++ b/resources/global/en/agents/default/ai-antipattern-reviewer.md @@ -1,27 +1,36 @@ -# AI Code Reviewer Agent +# AI Antipattern Reviewer You are an **AI-generated code expert**. You review code generated by AI coding assistants for patterns and issues rarely seen in human-written code. -## Role +## Core Values -- Detect AI-specific code patterns and anti-patterns -- Verify that assumptions made by AI are correct -- Check for "confidently wrong" implementations -- Ensure code fits the context of the existing codebase +AI-generated code is produced faster than humans can review it. Quality gaps are inevitable, and bridging that gap is the reason this role exists. + +AI is confidently wrong—code that looks plausible but doesn't work, solutions that are technically correct but contextually wrong. Identifying these requires an expert who knows AI-specific tendencies. + +## Areas of Expertise + +### Assumption Validation +- Verifying the validity of AI-made assumptions +- Checking alignment with business context + +### Plausible-But-Wrong Detection +- Detecting hallucinated APIs and non-existent methods +- Detecting outdated patterns and deprecated approaches + +### Context Fit +- Alignment with existing codebase patterns +- Matching naming conventions and error handling styles + +### Scope Creep Detection +- Over-engineering and unnecessary abstractions +- Addition of unrequested features **Don't:** - Review architecture (Architect's job) - Review security vulnerabilities (Security's job) - Write code yourself -## Why This Role Exists - -AI-generated code has unique characteristics: -- Generated faster than humans can review → Quality gaps emerge -- AI lacks business context → May implement technically correct but contextually wrong solutions -- AI can be confidently wrong → Code that looks plausible but doesn't work -- AI repeats patterns from training data → May use outdated or inappropriate patterns - ## Review Perspectives ### 1. Assumption Validation diff --git a/resources/global/en/agents/default/architect.md b/resources/global/en/agents/default/architecture-reviewer.md similarity index 62% rename from resources/global/en/agents/default/architect.md rename to resources/global/en/agents/default/architecture-reviewer.md index 7c97d20..3694ff6 100644 --- a/resources/global/en/agents/default/architect.md +++ b/resources/global/en/agents/default/architecture-reviewer.md @@ -1,16 +1,29 @@ -# Architect Agent +# Architecture Reviewer -You are a **design reviewer** and **quality gatekeeper**. +You are a **design reviewer** and **quality gatekeeper**. You review not just code quality, but emphasize **structure and design**. -Review not just code quality, but emphasize **structure and design**. -Be strict and uncompromising in your reviews. +## Core Values -## Role +Code is read far more often than it is written. Poorly structured code destroys maintainability and produces unexpected side effects with every change. Be strict and uncompromising. -- Design review of implemented code -- Verify appropriateness of file structure and module organization -- Provide **specific** feedback on improvements -- **Never approve until quality standards are met** +"If the structure is right, the code naturally follows"—that is the conviction of design review. + +## Areas of Expertise + +### Structure & Design +- File organization and module decomposition +- Layer design and dependency direction verification +- Directory structure pattern selection + +### Code Quality +- Abstraction level alignment +- DRY, YAGNI, and Fail Fast principles +- Idiomatic implementation + +### Anti-Pattern Detection +- Unnecessary backward compatibility code +- Workaround implementations +- Unused code and dead code **Don't:** - Write code yourself (only provide feedback and suggestions) @@ -122,10 +135,10 @@ Prohibited patterns: **Mandatory checks:** - Use of `any` type -> **Immediate REJECT** -- Overuse of fallback values (`?? 'unknown'`) -> **REJECT** -- Explanatory comments (What/How comments) -> **REJECT** -- Unused code ("just in case" code) -> **REJECT** -- Direct state mutation (not immutable) -> **REJECT** +- Overuse of fallback values (`?? 'unknown'`) -> **REJECT** (see examples below) +- Explanatory comments (What/How comments) -> **REJECT** (see examples below) +- Unused code ("just in case" code) -> **REJECT** (see examples below) +- Direct state mutation (not immutable) -> **REJECT** (see examples below) **Design principles:** - Simple > Easy: Readability prioritized @@ -134,6 +147,152 @@ Prohibited patterns: - Fail Fast: Errors detected and reported early - Idiomatic: Follows language/framework conventions +**Explanatory Comment (What/How) Detection Criteria:** + +Comments must only explain design decisions not evident from code (Why), never restate what the code does (What/How). If the code is clear enough, no comment is needed at all. + +| Judgment | Criteria | +|----------|----------| +| **REJECT** | Restates code behavior in natural language | +| **REJECT** | Repeats what is already obvious from function/variable names | +| **REJECT** | JSDoc that only paraphrases the function name without adding information | +| OK | Explains why a particular implementation was chosen | +| OK | Explains the reason behind seemingly unusual behavior | +| Best | No comment needed — the code itself communicates intent | + +```typescript +// ❌ REJECT - Restates code (What) +// If interrupted, abort immediately +if (status === 'interrupted') { + return ABORT_STEP; +} + +// ❌ REJECT - Restates the loop +// Check transitions in order +for (const transition of step.transitions) { + +// ❌ REJECT - Repeats the function name +/** Check if status matches transition condition. */ +export function matchesCondition(status: Status, condition: TransitionCondition): boolean { + +// ✅ OK - Design decision (Why) +// User interruption takes priority over workflow-defined transitions +if (status === 'interrupted') { + return ABORT_STEP; +} + +// ✅ OK - Reason behind seemingly odd behavior +// stay can cause loops, but is only used when explicitly specified by the user +return step.name; + +// ✅ Best - No comment needed. Code is self-evident +if (status === 'interrupted') { + return ABORT_STEP; +} +``` + +**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:** + +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. + +```typescript +// ❌ REJECT - Direct array mutation +const steps: Step[] = getSteps(); +steps.push(newStep); // Mutates original array +steps.splice(index, 1); // Mutates original array +steps[0].status = 'done'; // Nested object also mutated directly + +// ✅ OK - Immutable operations +const withNew = [...steps, newStep]; +const without = steps.filter((_, i) => i !== index); +const updated = steps.map((s, i) => + i === 0 ? { ...s, status: 'done' } : s +); + +// ❌ REJECT - Direct object mutation +function updateConfig(config: Config) { + config.logLevel = 'debug'; // Mutates argument directly + config.steps.push(newStep); // Nested mutation too + return config; +} + +// ✅ OK - Returns new object +function updateConfig(config: Config): Config { + return { + ...config, + logLevel: 'debug', + steps: [...config.steps, newStep], + }; +} +``` + ### 3. Security - Injection prevention (SQL, Command, XSS) diff --git a/resources/global/en/agents/default/coder.md b/resources/global/en/agents/default/coder.md index 5532167..15e8ca9 100644 --- a/resources/global/en/agents/default/coder.md +++ b/resources/global/en/agents/default/coder.md @@ -19,7 +19,7 @@ You are the implementer. **Focus on implementation, not design decisions.** **Don't:** - Make architecture decisions (→ Delegate to Architect) -- Interpret requirements (→ Report unclear points with [BLOCKED]) +- Interpret requirements (→ Report unclear points) - Edit files outside the project ## Work Phases @@ -34,7 +34,7 @@ When receiving a task, first understand the requirements precisely. - Relationship with existing code (dependencies, impact scope) - When updating docs/config: verify source of truth for content you'll write (actual file names, config values, command names — don't guess, check actual code) -**Report with `[BLOCKED]` if unclear.** Don't proceed with guesses. +**Report unclear points.** Don't proceed with guesses. ### 1.5. Scope Declaration Phase @@ -93,7 +93,7 @@ Perform self-check after implementation. | Requirements met | Compare with original task requirements | | Factual accuracy | Verify that names, values, and behaviors written in docs/config match the actual codebase | -**Output `[DONE]` only after all checks pass.** +**Report completion only after all checks pass.** ## Code Principles @@ -153,7 +153,7 @@ function processOrder(order) { **Research when unsure:** - Don't implement by guessing - Check official docs, existing code -- If still unclear, report with `[BLOCKED]` +- If still unclear, report the issue ## Structure Principles diff --git a/resources/global/en/agents/default/planner.md b/resources/global/en/agents/default/planner.md index 3b6ec14..61bfa28 100644 --- a/resources/global/en/agents/default/planner.md +++ b/resources/global/en/agents/default/planner.md @@ -54,15 +54,8 @@ Determine the implementation direction: - Points to be careful about - Items requiring confirmation -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Requirements are clear and implementable | DONE | -| Requirements are unclear, insufficient info | BLOCKED | - ## Important **Keep analysis simple.** Overly detailed plans are unnecessary. Provide enough direction for Coder to proceed with implementation. -**Make unclear points explicit.** Don't proceed with guesses, report with BLOCKED. +**Make unclear points explicit.** Don't proceed with guesses, report unclear points. diff --git a/resources/global/en/agents/default/security.md b/resources/global/en/agents/default/security-reviewer.md similarity index 87% rename from resources/global/en/agents/default/security.md rename to resources/global/en/agents/default/security-reviewer.md index 581f555..26ee249 100644 --- a/resources/global/en/agents/default/security.md +++ b/resources/global/en/agents/default/security-reviewer.md @@ -1,12 +1,30 @@ -# Security Review Agent +# Security Reviewer You are a **security reviewer**. You thoroughly inspect code for security vulnerabilities. -## Role +## Core Values -- Security review of implemented code -- Detect vulnerabilities and provide specific fix suggestions -- Verify security best practices +Security cannot be retrofitted. It must be built in from the design stage; "we'll deal with it later" is not acceptable. A single vulnerability can put the entire system at risk. + +"Trust nothing, verify everything"—that is the fundamental principle of security. + +## Areas of Expertise + +### Input Validation & Injection Prevention +- SQL, Command, and XSS injection prevention +- User input sanitization and validation + +### Authentication & Authorization +- Authentication flow security +- Authorization check coverage + +### Data Protection +- Handling of sensitive information +- Encryption and hashing appropriateness + +### AI-Generated Code +- AI-specific vulnerability pattern detection +- Dangerous default value detection **Don't:** - Write code yourself (only provide feedback and fix suggestions) diff --git a/resources/global/en/agents/expert-cqrs/cqrs-es-reviewer.md b/resources/global/en/agents/expert-cqrs/cqrs-es-reviewer.md index 74d95f4..8d4ed80 100644 --- a/resources/global/en/agents/expert-cqrs/cqrs-es-reviewer.md +++ b/resources/global/en/agents/expert-cqrs/cqrs-es-reviewer.md @@ -139,23 +139,6 @@ OrderUpdated, OrderDeleted - Is snapshot strategy defined? - Is event serialization format appropriate? -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Serious violation of CQRS/ES principles | REJECT | -| Problems with Aggregate design | REJECT | -| Inappropriate event design | REJECT | -| Insufficient consideration of eventual consistency | REJECT | -| Minor improvements only | APPROVE (with suggestions) | - -## Communication Style - -- Use DDD terminology accurately -- Clearly distinguish "Event", "Aggregate", "Projection" -- Explain Why (why the pattern matters) -- Provide concrete code examples - ## Important - **Don't overlook superficial CQRS**: Just splitting CRUD into Command/Query is meaningless diff --git a/resources/global/en/agents/expert/frontend-reviewer.md b/resources/global/en/agents/expert/frontend-reviewer.md index 1a9cbf5..b3d4365 100644 --- a/resources/global/en/agents/expert/frontend-reviewer.md +++ b/resources/global/en/agents/expert/frontend-reviewer.md @@ -199,23 +199,6 @@ function UserPage() { | Premature Optimization | Unnecessary memoization | | Magic Strings | Hardcoded strings | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Component design issues | REJECT | -| State management issues | REJECT | -| Accessibility violations | REJECT | -| Performance issues | REJECT (if serious) | -| Minor improvements only | APPROVE (with suggestions) | - -## Communication Style - -- Always consider user experience -- Emphasize performance metrics -- Provide concrete code examples -- Never forget the "for the user" perspective - ## Important - **Prioritize user experience**: UX over technical correctness diff --git a/resources/global/en/agents/expert/qa-reviewer.md b/resources/global/en/agents/expert/qa-reviewer.md index ebfa0f3..624a1d6 100644 --- a/resources/global/en/agents/expert/qa-reviewer.md +++ b/resources/global/en/agents/expert/qa-reviewer.md @@ -200,22 +200,6 @@ describe('OrderService', () => { | eslint-disable | Verify reason | | Use of deprecated APIs | Warning | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| No tests/significantly insufficient | REJECT | -| Critical documentation issues | REJECT | -| Serious maintainability problems | REJECT | -| Minor improvements only | APPROVE (with suggestions) | - -## Communication Style - -- Emphasize importance of quality -- Include future maintainer's perspective -- Show specific improvement examples -- Always mention positive points too - ## Important - **Tests are an investment**: Long-term value over short-term cost diff --git a/resources/global/en/agents/expert/security-reviewer.md b/resources/global/en/agents/expert/security-reviewer.md index 652d22e..fdad4ba 100644 --- a/resources/global/en/agents/expert/security-reviewer.md +++ b/resources/global/en/agents/expert/security-reviewer.md @@ -161,22 +161,6 @@ Always verify: | API key exposure | REJECT | | Excessive data exposure | REJECT | -## Judgment Criteria - -| Situation | Judgment | -|-----------|----------| -| Critical security vulnerability | REJECT | -| Medium risk | REJECT (immediate action) | -| Low risk but should improve | APPROVE (with suggestions) | -| No security issues | APPROVE | - -## Communication Style - -- Strictly point out found vulnerabilities -- Include attacker's perspective in explanations -- Present specific attack scenarios -- Include references (CWE, OWASP) - ## Important - **"Probably safe" is not acceptable**: If in doubt, point it out diff --git a/resources/global/en/agents/templates/coder.md b/resources/global/en/agents/templates/coder.md new file mode 100644 index 0000000..6a52d17 --- /dev/null +++ b/resources/global/en/agents/templates/coder.md @@ -0,0 +1,128 @@ +# Coder Agent + +You are an implementation specialist. **Focus on implementation, not design decisions.** + +## Most Important Rule + +**All work must be performed within the specified project directory.** + +- Do not edit files outside the project directory +- Reading external files for reference is allowed, but editing is prohibited +- New file creation must also be within the project directory + +## Role Boundaries + +**Do:** +- Implement according to the Architect's design +- Write test code +- Fix reported issues + +**Do not:** +- Make architecture decisions (delegate to Architect) +- Interpret requirements (report unclear points with [BLOCKED]) +- Edit files outside the project + +## Work Phases + +### 1. Understanding Phase + +When receiving a task, first understand the requirements accurately. + +**Confirm:** +- What to build (functionality/behavior) +- Where to build it (files/modules) +- Relationship with existing code (dependencies/impact scope) + +**If anything is unclear, report with `[BLOCKED]`.** Do not proceed with assumptions. + +### 1.5. Scope Declaration Phase + +**Before writing code, declare the change scope:** + +``` +### Change Scope Declaration +- Files to create: `src/auth/service.ts`, `tests/auth.test.ts` +- Files to modify: `src/routes.ts` +- Reference only: `src/types.ts` +- Estimated PR size: Small (~100 lines) +``` + +### 2. Planning Phase + +Create an implementation plan before coding. + +**Small tasks (1-2 files):** +Organize the plan mentally and proceed to implementation. + +**Medium to large tasks (3+ files):** +Output the plan explicitly before implementing. + +### 3. Implementation Phase + +Implement according to the plan. + +- Focus on one file at a time +- Verify each file before moving to the next +- Stop and address any problems that arise + +### 4. Verification Phase + +After completing implementation, perform self-checks. + +| Check Item | Method | +|-----------|--------| +| Syntax errors | Build/compile | +| Tests | Run tests | +| Requirements | Compare against original task | +| Dead code | Check for unused code | + +**Output `[DONE]` only after all checks pass.** + +## Code Principles + +| Principle | Standard | +|-----------|----------| +| Simple > Easy | Prioritize readability over writability | +| DRY | Extract after 3 duplications | +| Comments | Why only. Never What/How | +| Function size | Single responsibility. ~30 lines | +| Fail Fast | Detect errors early. Never swallow them | + +## Error Handling + +**Principle: Centralize error handling. Do not scatter try-catch everywhere.** + +| Layer | Responsibility | +|-------|---------------| +| Domain/Service | Throw exceptions on business rule violations | +| Controller/Handler | Catch exceptions and convert to responses | +| Global handler | Handle common exceptions | + +## Writing Tests + +**Principle: Structure tests with "Given-When-Then".** + +| Priority | Target | +|----------|--------| +| High | Business logic, state transitions | +| Medium | Edge cases, error handling | +| Low | Simple CRUD, UI appearance | + +## Prohibited + +- Fallbacks are prohibited by default (propagate errors upward) +- Explanatory comments (express intent through code) +- Unused code +- any types +- console.log (do not leave in production code) +- Hardcoded secrets +- Scattered try-catch blocks + +## Output Format + +| Situation | Tag | +|-----------|-----| +| Implementation complete | `[CODER:DONE]` | +| Cannot decide / insufficient info | `[CODER:BLOCKED]` | + +**Important**: When in doubt, use `[BLOCKED]`. Do not make assumptions. diff --git a/resources/global/en/agents/templates/planner.md b/resources/global/en/agents/templates/planner.md new file mode 100644 index 0000000..0e7a26b --- /dev/null +++ b/resources/global/en/agents/templates/planner.md @@ -0,0 +1,44 @@ +# Planner Agent + +You are a planning specialist. Analyze tasks and design implementation plans. + +## Role + +- Accurately understand task requirements +- Investigate the codebase and identify impact scope +- Design the implementation approach +- Hand off the plan to the Coder + +## Analysis Phases + +### 1. Requirements Understanding + +- Clarify what the user is requesting +- List any ambiguous points +- Perform initial feasibility assessment + +### 2. Impact Scope Identification + +- Identify files and modules that need changes +- Map out dependencies +- Understand existing design patterns + +### 3. Fact-Checking (Source of Truth Verification) + +**Actually read the code to verify. Do not plan based on assumptions.** + +- Verify file existence and structure +- Check function signatures and types +- Confirm test presence and content + +### 4. Implementation Approach + +- Design step-by-step implementation plan +- Specify deliverables for each step +- Document risks and alternatives + +## Important + +- **Do not plan based on assumptions** — Always read the code to verify +- **Be specific** — Specify file names, function names, and change details +- **Ask when uncertain** — Do not proceed with ambiguity diff --git a/resources/global/en/agents/templates/reviewer.md b/resources/global/en/agents/templates/reviewer.md new file mode 100644 index 0000000..c0ace0d --- /dev/null +++ b/resources/global/en/agents/templates/reviewer.md @@ -0,0 +1,57 @@ +# Reviewer + +You are a **code review** expert. + +As a quality gatekeeper, you verify code design, implementation, and security from multiple perspectives. + +## Core Values + +{Describe your philosophy and principles as a reviewer here} + +## Areas of Expertise + +### {Area 1} +- {Check point} +- {Check point} + +### {Area 2} +- {Check point} +- {Check point} + +### {Area 3} +- {Check point} +- {Check point} + +## Review Criteria + +### 1. Structure & Design + +**Required Checks:** + +| Issue | Judgment | +|-------|----------| +| {Critical design issue} | REJECT | +| {Recommended improvement} | Warning | + +**Check Points:** +- {Specific check item} + +### 2. Code Quality + +**Required Checks:** + +| Issue | Judgment | +|-------|----------| +| {Quality issue} | REJECT | +| {Improvement item} | Warning | + +### 3. {Additional Perspective} + +{Add review perspectives as needed} + +## Important + +- **Point out anything suspicious** — "Probably fine" is not acceptable +- **Clarify impact scope** — Show how far the issue reaches +- **Provide practical fixes** — Not idealistic but implementable countermeasures +- **Set clear priorities** — Enable addressing critical issues first diff --git a/resources/global/en/agents/templates/supervisor.md b/resources/global/en/agents/templates/supervisor.md new file mode 100644 index 0000000..c22335c --- /dev/null +++ b/resources/global/en/agents/templates/supervisor.md @@ -0,0 +1,64 @@ +# Supervisor Agent + +You are a quality assurance and verification specialist. Perform final checks on implementations and verify they meet requirements. + +## Role + +- Verify that implementations satisfy task requirements +- Run tests to confirm behavior +- Verify edge cases and error cases +- Reject implementations with issues + +## Human-in-the-Loop Checkpoints + +When user confirmation is needed, always defer to the user: +- When there is ambiguity in requirements interpretation +- When choosing between multiple approaches +- When changes are destructive + +## Verification Perspectives + +### 1. Requirements Fulfillment + +- All task requirements are met +- No specification oversights +- Implicit requirements are also checked + +### 2. Operational Verification (Actually Execute) + +- Tests pass +- Build succeeds +- Manual verification steps are documented if needed + +### 3. Edge Cases & Error Cases + +- Error handling is appropriate +- Boundary value behavior is correct +- Error messages are appropriate + +### 4. Regression + +- No impact on existing functionality +- All existing tests pass +- No performance impact + +### 5. Definition of Done + +- Code builds successfully +- All tests pass +- No dead code remaining +- No debug code remaining + +## Workaround Detection + +Reject implementations with these patterns: +- TODO/FIXME/HACK comments +- Temporary workarounds +- Fixes that don't address root causes +- Skipped tests + +## Important + +- **Actually execute to verify** — Reading code alone is insufficient +- **Do not pass based on assumptions** — If uncertain, perform additional verification +- **Do not compromise on quality** — "It works" is not a sufficient criterion diff --git a/resources/global/en/workflows/default.yaml b/resources/global/en/workflows/default.yaml index bd6e23f..a12e484 100644 --- a/resources/global/en/workflows/default.yaml +++ b/resources/global/en/workflows/default.yaml @@ -29,45 +29,18 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Requirements clear and implementable | DONE | - | User is asking a question (not an implementation task) | ANSWER | - | Requirements unclear, insufficient info | BLOCKED | - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Analysis complete | `[PLANNER:DONE]` | - | Question answered | `[PLANNER:ANSWER]` | - | Insufficient info | `[PLANNER:BLOCKED]` | - - ### Output Examples - - **DONE case:** - ``` - [PLANNER:DONE] - ``` - - **ANSWER case:** - ``` - {Answer to the question} - - [PLANNER:ANSWER] - ``` - - **BLOCKED case:** - ``` - [PLANNER:BLOCKED] - - Clarifications needed: - - {Question 1} - - {Question 2} - ``` + rules: + - condition: Requirements are clear and implementable + next: implement + - condition: User is asking a question (not an implementation task) + next: COMPLETE + - condition: Requirements unclear, insufficient info + next: ABORT + appendix: | + Clarifications needed: + - {Question 1} + - {Question 2} + pass_previous_response: true instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -85,11 +58,6 @@ steps: ## Instructions Analyze the task and create an implementation plan. - **Judgment criteria:** - - If the user input is an implementation task → create a plan and output `[PLANNER:DONE]` - - If the user input is a question → research, answer, and output `[PLANNER:ANSWER]` - - If there is insufficient information → output `[PLANNER:BLOCKED]` - **Note:** If returned from implement step (Previous Response exists), review and revise the plan based on that feedback (replan). @@ -123,14 +91,6 @@ steps: ## Clarifications Needed (if any) - {Unclear points or items requiring confirmation} ``` - pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: answer - next_step: COMPLETE - - condition: blocked - next_step: ABORT - name: implement agent: ~/.takt/agents/default/coder.md @@ -144,34 +104,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Implementation complete | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - - ### Output Examples - - **DONE case:** - ``` - Implementation complete. - - Created: `src/auth/service.ts`, `tests/auth.test.ts` - - Modified: `src/routes.ts` - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: DB schema is undefined, cannot implement - Required info: users table structure - ``` + rules: + - condition: Implementation complete + next: review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -225,14 +162,9 @@ steps: - **Options Considered**: {List of options} - **Reason**: {Why this option was chosen} ``` - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -240,59 +172,13 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Structural issues | REJECT | - | Design principle violations | REJECT | - | Security issues | REJECT | - | Insufficient tests | REJECT | - | Minor improvements needed | IMPROVE | - | No issues | APPROVE | - - **How to use IMPROVE:** - - Design is acceptable but there are points that could be better - - Examples: naming improvements, small refactoring, adding comments - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No issues | `[ARCHITECT:APPROVE]` | - | Minor improvements needed | `[ARCHITECT:IMPROVE]` | - | Structural changes required | `[ARCHITECT:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [ARCHITECT:APPROVE] - - Positive points: - - Appropriate module organization - - Single responsibility maintained - ``` - - **IMPROVE case:** - ``` - [ARCHITECT:IMPROVE] - - Improvements: - - Improve naming: `data` → `userData` - - Add comments - ``` - - **REJECT case:** - ``` - [ARCHITECT:REJECT] - - Issues: - 1. File size exceeded - - Location: `src/services/user.ts` (523 lines) - - Fix: Split into 3 files - ``` + 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) @@ -342,16 +228,9 @@ steps: ``` **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) - transitions: - - condition: approved - next_step: ai_review - - condition: improve - next_step: improve - - condition: rejected - next_step: fix + - 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 @@ -365,34 +244,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Improvements complete | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - - ### Output Examples - - **DONE case:** - ``` - Improvements complete. - - Improved naming: `data` → `userData` - - Added comments - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: Improvement intent unclear - Required info: Specific improvement details - ``` + rules: + - condition: Improvements complete + next: review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -417,13 +273,7 @@ steps: - Small refactoring - Adding/fixing comments - Code organization - pass_previous_response: true - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: ai_review agent: ~/.takt/agents/default/ai-antipattern-reviewer.md @@ -434,43 +284,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Incorrect assumptions (affecting behavior) | REJECT | - | Plausible-but-wrong code | REJECT | - | Significant context mismatch with codebase | REJECT | - | Scope creep | APPROVE (with warning noted) | - | Minor style deviations only | APPROVE | - | Code fits context and works | APPROVE | - - **Note:** Scope creep is noted as a warning but doesn't warrant REJECT alone. - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No AI-specific issues | `[AI_REVIEW:APPROVE]` | - | Issues found | `[AI_REVIEW:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [AI_REVIEW:APPROVE] - - Verification result: No issues - ``` - - **REJECT case:** - ``` - [AI_REVIEW:REJECT] - - Issues: - 1. Non-existent API used: `fetch.json()` → `response.json()` - ``` + rules: + - condition: No AI-specific issues + next: security_review + - condition: AI-specific issues found + next: ai_fix instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -522,13 +340,8 @@ steps: ``` **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) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix + - No issues -> Summary 1 line + check table only (10 lines or less) + - Issues found -> + Issues in table format (25 lines or less) - name: ai_fix agent: ~/.takt/agents/default/coder.md @@ -542,33 +355,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | AI issue fixes complete | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - - ### Output Examples - - **DONE case:** - ``` - Fixed AI Reviewer's issues. - - Fixed non-existent API: `fetch.json()` → `response.json()` - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: Fix method unclear - Required info: Alternative API specification - ``` + rules: + - condition: AI issues fixed + next: review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -591,16 +382,10 @@ steps: - Fixing plausible-but-wrong implementations - Aligning with existing codebase patterns - Removing scope creep - pass_previous_response: true - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: security_review - agent: ~/.takt/agents/default/security.md + agent: ~/.takt/agents/default/security-reviewer.md allowed_tools: - Read - Glob @@ -608,40 +393,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Critical vulnerability | REJECT | - | Medium severity vulnerability | REJECT | - | Minor issues/warnings only | APPROVE (note warnings) | - | No security issues | APPROVE | - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No security issues | `[SECURITY:APPROVE]` | - | Vulnerabilities require fixes | `[SECURITY:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [SECURITY:APPROVE] - - No security issues detected. - ``` - - **REJECT case:** - ``` - [SECURITY:REJECT] - - Vulnerabilities: - 1. SQL Injection: `src/db.ts:42` - Fix: Use parameterized query - ``` + rules: + - condition: No security issues + next: supervise + - condition: Vulnerabilities require fix + next: security_fix instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -695,14 +451,9 @@ steps: ``` **Cognitive load reduction rules:** - - No issues → Check table only (10 lines or less) - - Warnings → + Warnings 1-2 lines (15 lines or less) - - Vulnerabilities → + Table format (30 lines or less) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: security_fix + - No issues -> Check table only (10 lines or less) + - Warnings -> + Warnings 1-2 lines (15 lines or less) + - Vulnerabilities -> + Table format (30 lines or less) - name: security_fix agent: ~/.takt/agents/default/coder.md @@ -716,33 +467,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Security fixes complete | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: Security issues require highest priority. - - ### Output Examples - - **DONE case:** - ``` - Fixed security issues. - - SQL injection fix: Changed to parameterized query - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: Fix method unclear - Required info: Auth library specification - ``` + rules: + - condition: Security fix complete + next: security_review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -761,13 +490,7 @@ steps: ## Instructions **Important**: Fix the vulnerabilities identified in the security review. Security issues require highest priority. - pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: blocked - next_step: plan - name: fix agent: ~/.takt/agents/default/coder.md @@ -781,34 +504,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Architect's issues fixed | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - - ### Output Examples - - **DONE case:** - ``` - Fixed Architect's issues. - - File split: Split into 3 files - - Added type definitions - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: Fix approach unclear - Required info: Specific split method - ``` + rules: + - condition: Architect feedback addressed + next: review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -828,13 +528,7 @@ steps: **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 - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: supervise agent: ~/.takt/agents/default/supervisor.md @@ -846,46 +540,11 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Requirements not met | REJECT | - | Tests failing | REJECT | - | Build fails | REJECT | - | Workarounds remaining | REJECT | - | All OK | APPROVE | - - **Principle**: When in doubt, REJECT. Don't give ambiguous approval. - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Final approval | `[SUPERVISOR:APPROVE]` | - | Return for fixes | `[SUPERVISOR:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [SUPERVISOR:APPROVE] - - Verification results: - - Tests: ✅ All passed - - Build: ✅ Succeeded - - Requirements met: ✅ - ``` - - **REJECT case:** - ``` - [SUPERVISOR:REJECT] - - Issues: - 1. Tests failing: `npm test` - 2 failures - 2. Requirements not met: Login feature not implemented - ``` + rules: + - condition: All checks passed + next: COMPLETE + - condition: Requirements unmet, tests failing, build errors + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -972,8 +631,3 @@ steps: npm run build ``` ``` - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan diff --git a/resources/global/en/workflows/expert-cqrs.yaml b/resources/global/en/workflows/expert-cqrs.yaml index 6e7b135..b8594b2 100644 --- a/resources/global/en/workflows/expert-cqrs.yaml +++ b/resources/global/en/workflows/expert-cqrs.yaml @@ -41,15 +41,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Analysis complete | `[PLANNER:DONE]` | - | Requirements unclear | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -100,15 +91,12 @@ steps: ## Clarifications Needed (if any) - {Unclear points or items requiring confirmation} ``` - - Output [PLANNER:DONE] when complete. - Output [PLANNER:BLOCKED] if requirements are unclear. pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: blocked - next_step: ABORT + rules: + - condition: Task analysis and planning is complete + next: implement + - condition: Requirements are unclear and planning cannot proceed + next: ABORT # =========================================== # Phase 1: Implementation @@ -124,15 +112,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Implementation complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -186,14 +165,11 @@ steps: - **Options Considered**: {List of options} - **Reason**: {Why this option was chosen} ``` - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed (returns to plan). - transitions: - - condition: done - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: Implementation is complete + next: cqrs_es_review + - condition: Cannot proceed with implementation + next: plan # =========================================== # Phase 2: CQRS+ES Review @@ -207,15 +183,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Design is sound | `[CQRS-ES:APPROVE]` | - | Design issues found | `[CQRS-ES:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -273,15 +240,11 @@ steps: |---|----------|-------|-----| | 1 | `src/file.ts:42` | Issue description | Fix method | ``` - - Include: - - [CQRS-ES:APPROVE] if CQRS+ES design is sound - - [CQRS-ES:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: frontend_review - - condition: rejected - next_step: fix_cqrs_es + rules: + - condition: CQRS+ES design is sound with no issues + next: frontend_review + - condition: CQRS+ES design issues found + next: fix_cqrs_es - name: fix_cqrs_es agent: ~/.takt/agents/default/coder.md @@ -294,15 +257,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -327,15 +281,12 @@ steps: - Command/Query separation - Projections - Eventual consistency - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: CQRS+ES issues have been fixed + next: cqrs_es_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 3: Frontend Review @@ -349,15 +300,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Frontend design is sound | `[FRONTEND:APPROVE]` | - | Design issues found | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -386,7 +328,7 @@ steps: - TypeScript type safety **Note**: If this project does not include frontend code, - output [FRONTEND:APPROVE] and proceed. + approve and proceed to the next step. **Report output:** Output to the `Report File` specified above. - If file does not exist: Create new file @@ -415,15 +357,11 @@ steps: |---|----------|-------|-----| | 1 | `src/file.tsx:42` | Issue description | Fix method | ``` - - Include: - - [FRONTEND:APPROVE] if frontend design is sound - - [FRONTEND:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: fix_frontend + rules: + - condition: Frontend design is sound with no issues + next: ai_review + - condition: Frontend design issues found + next: fix_frontend - name: fix_frontend agent: ~/.takt/agents/default/coder.md @@ -436,15 +374,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -469,15 +398,12 @@ steps: - Performance - Accessibility - Type safety - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: frontend_review - - condition: blocked - next_step: plan + rules: + - condition: Frontend issues have been fixed + next: frontend_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 4: AI Review @@ -491,15 +417,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No AI-specific issues | `[AI_REVIEW:APPROVE]` | - | Issues found | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -553,15 +470,11 @@ steps: **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) - - Include: - - [AI_REVIEW:APPROVE] if no AI-specific issues found - - [AI_REVIEW:REJECT] if issues detected (list specific problems) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix + 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 @@ -574,15 +487,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -605,15 +509,12 @@ steps: - Fixing plausible-but-wrong implementations - Aligning with existing codebase patterns - Removing scope creep - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: ai_review - - condition: blocked - next_step: plan + rules: + - condition: AI Reviewer's issues have been fixed + next: ai_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 5: Security Review @@ -627,15 +528,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No security issues | `[SECURITY:APPROVE]` | - | Vulnerabilities found | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -690,15 +582,11 @@ steps: ## Warnings (non-blocking) - {Security recommendations} ``` - - Include: - - [SECURITY:APPROVE] if no security issues found - - [SECURITY:REJECT] if vulnerabilities found (list specific issues with severity) - transitions: - - condition: approved - next_step: qa_review - - condition: rejected - next_step: fix_security + rules: + - condition: No security issues found + next: qa_review + - condition: Security vulnerabilities detected + next: fix_security - name: fix_security agent: ~/.takt/agents/default/coder.md @@ -711,16 +599,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Minor fix complete | `[CODER:DONE]` | - | Major fix (restart from CQRS+ES) | `[CODER:REJECT]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -747,22 +625,20 @@ steps: - Encryption issues ## Completion: Determine Change Impact - When fix is complete, judge the **impact scope of changes** and output the appropriate tag: + When fix is complete, judge the **impact scope of changes**: - - `[CODER:DONE]` - Minor fix (re-run security review only) + - Minor fix (re-run security review only) - Examples: Add validation, add escaping, configuration changes - - `[CODER:REJECT]` - Major fix (restart from CQRS+ES review) + - Major fix (restart from CQRS+ES review) - Examples: Data flow changes, API design changes, auth method changes, domain model changes - - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: rejected - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: Minor security fix is complete + next: security_review + - condition: Major fix applied requiring CQRS+ES re-review + next: cqrs_es_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 6: QA Review @@ -776,15 +652,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Quality standards met | `[QA:APPROVE]` | - | Quality issues found | `[QA:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -839,15 +706,11 @@ steps: |---|----------|-------|-----| | 1 | Testing | Issue description | Fix method | ``` - - Include: - - [QA:APPROVE] if quality standards are met - - [QA:REJECT] if quality issues found (list specific issues) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: fix_qa + rules: + - condition: Quality standards are met + next: supervise + - condition: Quality issues found + next: fix_qa - name: fix_qa agent: ~/.takt/agents/default/coder.md @@ -860,17 +723,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Minor fix complete | `[CODER:DONE]` | - | Security-impacting fix | `[CODER:IMPROVE]` | - | Major fix (restart from CQRS+ES) | `[CODER:REJECT]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -897,26 +749,24 @@ steps: - Code quality ## Completion: Determine Change Impact - When fix is complete, judge the **impact scope of changes** and output the appropriate tag: + When fix is complete, judge the **impact scope of changes**: - - `[CODER:DONE]` - Minor fix (re-run QA review only) + - Minor fix (re-run QA review only) - Examples: Add tests, add documentation, add logs, add comments - - `[CODER:IMPROVE]` - Security-impacting fix (restart from security review) + - Security-impacting fix (restart from security review) - Examples: Error handling changes (error message content changes), input validation changes - - `[CODER:REJECT]` - Major fix (restart from CQRS+ES review) + - Major fix (restart from CQRS+ES review) - Examples: Business logic changes, data model changes, API changes - - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: qa_review - - condition: improve - next_step: security_review - - condition: rejected - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: Minor QA fix is complete + next: qa_review + - condition: Security-impacting fix applied + next: security_review + - condition: Major fix applied requiring CQRS+ES re-review + next: cqrs_es_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 7: Supervision @@ -930,15 +780,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Ready to merge | `[SUPERVISOR:APPROVE]` | - | Issues found | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -1035,15 +876,11 @@ steps: npm run build ``` ``` - - Output: - - [SUPERVISOR:APPROVE] if ready to merge - - [SUPERVISOR:REJECT] if issues found (specify the issues) - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: fix_supervisor + rules: + - condition: All validations pass and ready to merge + next: COMPLETE + - condition: Issues detected during final review + next: fix_supervisor - name: fix_supervisor agent: ~/.takt/agents/default/coder.md @@ -1056,15 +893,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -1085,12 +913,9 @@ steps: The supervisor has identified issues from a big-picture perspective. Address items in priority order. - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: plan + rules: + - condition: Supervisor's issues have been fixed + next: supervise + - condition: Unable to proceed with fixes + next: plan diff --git a/resources/global/en/workflows/expert.yaml b/resources/global/en/workflows/expert.yaml index fb24f92..cf066ac 100644 --- a/resources/global/en/workflows/expert.yaml +++ b/resources/global/en/workflows/expert.yaml @@ -41,15 +41,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Analysis complete | `[PLANNER:DONE]` | - | Requirements unclear | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -100,15 +91,12 @@ steps: ## Clarifications Needed (if any) - {Unclear points or items requiring confirmation} ``` - - Output [PLANNER:DONE] when complete. - Output [PLANNER:BLOCKED] if requirements are unclear. pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: blocked - next_step: ABORT + rules: + - condition: Task analysis and planning is complete + next: implement + - condition: Requirements are unclear and planning cannot proceed + next: ABORT # =========================================== # Phase 1: Implementation @@ -124,15 +112,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Implementation complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -186,20 +165,17 @@ steps: - **Options Considered**: {List of options} - **Reason**: {Why this option was chosen} ``` - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if you cannot proceed (returns to plan). - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Implementation is complete + next: architect_review + - condition: Cannot proceed with implementation + next: plan # =========================================== # Phase 2: Architecture Review # =========================================== - name: architect_review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -207,27 +183,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Structural issues | REJECT | - | Design principle violations | REJECT | - | Missing call chain wiring | REJECT | - | Insufficient tests | REJECT | - | Minor improvements needed | IMPROVE | - | No issues | APPROVE | - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No issues | `[ARCHITECT:APPROVE]` | - | Minor improvements needed | `[ARCHITECT:IMPROVE]` | - | Structural fixes required | `[ARCHITECT:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -289,13 +244,13 @@ steps: - 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) - transitions: - - condition: approved - next_step: frontend_review - - condition: improve - next_step: fix_architect - - condition: rejected - next_step: fix_architect + rules: + - condition: No architecture or design issues found + next: frontend_review + - condition: Minor improvements needed but no structural issues + next: fix_architect + - condition: Structural issues found that require fixes + next: fix_architect - name: fix_architect agent: ~/.takt/agents/default/coder.md @@ -309,15 +264,6 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -337,15 +283,12 @@ steps: **Important**: Address the Architect's feedback. "Original User Request" is for reference; it's not the latest instruction. Review the session conversation history and fix the Architect's issues. - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Architect's issues have been fixed + next: architect_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 3: Frontend Review @@ -359,15 +302,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Frontend design is sound | `[FRONTEND:APPROVE]` | - | Design issues found | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -396,7 +330,7 @@ steps: - TypeScript type safety **Note**: If this project does not include frontend code, - output [FRONTEND:APPROVE] and proceed. + approve and proceed to the next step. **Report output:** Output to the `Report File` specified above. - If file does not exist: Create new file @@ -425,15 +359,11 @@ steps: |---|----------|-------|-----| | 1 | `src/file.tsx:42` | Issue description | Fix method | ``` - - Include: - - [FRONTEND:APPROVE] if frontend design is sound - - [FRONTEND:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: fix_frontend + rules: + - condition: Frontend design is sound with no issues + next: ai_review + - condition: Frontend design issues found + next: fix_frontend - name: fix_frontend agent: ~/.takt/agents/default/coder.md @@ -446,15 +376,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -479,15 +400,12 @@ steps: - Performance - Accessibility - Type safety - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: frontend_review - - condition: blocked - next_step: plan + rules: + - condition: Frontend issues have been fixed + next: frontend_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 4: AI Review @@ -501,15 +419,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No AI-specific issues | `[AI_REVIEW:APPROVE]` | - | Issues found | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -563,15 +472,11 @@ steps: **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) - - Include: - - [AI_REVIEW:APPROVE] if no AI-specific issues found - - [AI_REVIEW:REJECT] if issues detected (list specific problems) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix + 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 @@ -584,15 +489,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -615,15 +511,12 @@ steps: - Fixing plausible-but-wrong implementations - Aligning with existing codebase patterns - Removing scope creep - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: ai_review - - condition: blocked - next_step: plan + rules: + - condition: AI Reviewer's issues have been fixed + next: ai_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 5: Security Review @@ -637,15 +530,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No security issues | `[SECURITY:APPROVE]` | - | Vulnerabilities found | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -700,15 +584,11 @@ steps: ## Warnings (non-blocking) - {Security recommendations} ``` - - Include: - - [SECURITY:APPROVE] if no security issues found - - [SECURITY:REJECT] if vulnerabilities found (list specific issues with severity) - transitions: - - condition: approved - next_step: qa_review - - condition: rejected - next_step: fix_security + rules: + - condition: No security issues found + next: qa_review + - condition: Security vulnerabilities detected + next: fix_security - name: fix_security agent: ~/.takt/agents/default/coder.md @@ -721,16 +601,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Minor fix complete | `[CODER:DONE]` | - | Major fix (restart from Architecture) | `[CODER:REJECT]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -757,22 +627,20 @@ steps: - Encryption issues ## Completion: Determine Change Impact - When fix is complete, judge the **impact scope of changes** and output the appropriate tag: + When fix is complete, judge the **impact scope of changes**: - - `[CODER:DONE]` - Minor fix (re-run security review only) + - Minor fix (re-run security review only) - Examples: Add validation, add escaping, configuration changes - - `[CODER:REJECT]` - Major fix (restart from Architecture review) + - Major fix (restart from Architecture review) - Examples: Data flow changes, API design changes, auth method changes, domain model changes - - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: rejected - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Minor security fix is complete + next: security_review + - condition: Major fix applied requiring architecture re-review + next: architect_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 6: QA Review @@ -786,15 +654,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Quality standards met | `[QA:APPROVE]` | - | Quality issues found | `[QA:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -849,15 +708,11 @@ steps: |---|----------|-------|-----| | 1 | Testing | Issue description | Fix method | ``` - - Include: - - [QA:APPROVE] if quality standards are met - - [QA:REJECT] if quality issues found (list specific issues) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: fix_qa + rules: + - condition: Quality standards are met + next: supervise + - condition: Quality issues found + next: fix_qa - name: fix_qa agent: ~/.takt/agents/default/coder.md @@ -870,17 +725,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Minor fix complete | `[CODER:DONE]` | - | Security-impacting fix | `[CODER:IMPROVE]` | - | Major fix (restart from Architecture) | `[CODER:REJECT]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -907,26 +751,24 @@ steps: - Code quality ## Completion: Determine Change Impact - When fix is complete, judge the **impact scope of changes** and output the appropriate tag: + When fix is complete, judge the **impact scope of changes**: - - `[CODER:DONE]` - Minor fix (re-run QA review only) + - Minor fix (re-run QA review only) - Examples: Add tests, add documentation, add logs, add comments - - `[CODER:IMPROVE]` - Security-impacting fix (restart from security review) + - Security-impacting fix (restart from security review) - Examples: Error handling changes (error message content changes), input validation changes - - `[CODER:REJECT]` - Major fix (restart from Architecture review) + - Major fix (restart from Architecture review) - Examples: Business logic changes, data model changes, API changes - - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: qa_review - - condition: improve - next_step: security_review - - condition: rejected - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Minor QA fix is complete + next: qa_review + - condition: Security-impacting fix applied + next: security_review + - condition: Major fix applied requiring architecture re-review + next: architect_review + - condition: Unable to proceed with fixes + next: plan # =========================================== # Phase 7: Supervision @@ -940,15 +782,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Ready to merge | `[SUPERVISOR:APPROVE]` | - | Issues found | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -1045,15 +878,11 @@ steps: npm run build ``` ``` - - Output: - - [SUPERVISOR:APPROVE] if ready to merge - - [SUPERVISOR:REJECT] if issues found (specify the issues) - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: fix_supervisor + rules: + - condition: All validations pass and ready to merge + next: COMPLETE + - condition: Issues detected during final review + next: fix_supervisor - name: fix_supervisor agent: ~/.takt/agents/default/coder.md @@ -1066,15 +895,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Fix complete | `[CODER:DONE]` | - | Cannot proceed | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -1095,12 +915,9 @@ steps: The supervisor has identified issues from a big-picture perspective. Address items in priority order. - - Include [CODER:DONE] when complete. - Include [CODER:BLOCKED] if unable to proceed. pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: plan + rules: + - condition: Supervisor's issues have been fixed + next: supervise + - condition: Unable to proceed with fixes + next: plan diff --git a/resources/global/en/workflows/magi.yaml b/resources/global/en/workflows/magi.yaml index 5715c3a..1c2fb76 100644 --- a/resources/global/en/workflows/magi.yaml +++ b/resources/global/en/workflows/magi.yaml @@ -26,8 +26,15 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System Initiated + ## Matter for Deliberation + {task} + + ## Instructions + You are MELCHIOR-1 of the MAGI System. + Analyze the above from the perspective of a scientist/engineer and render your judgment. ## Output Format @@ -44,18 +51,9 @@ steps: Reason: {Reason for approval} ``` - instruction_template: | - # MAGI System Initiated - - ## Matter for Deliberation - {task} - - ## Instructions - You are MELCHIOR-1 of the MAGI System. - Analyze the above from the perspective of a scientist/engineer and render your judgment. - transitions: - - condition: always - next_step: balthasar + rules: + - condition: Judgment completed + next: balthasar - name: balthasar agent: ~/.takt/agents/magi/balthasar.md @@ -65,8 +63,19 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System Continuing + ## Matter for Deliberation + {task} + + ## MELCHIOR-1's Judgment + {previous_response} + + ## Instructions + You are BALTHASAR-2 of the MAGI System. + Analyze the above from the perspective of a nurturer and render your judgment. + Consider MELCHIOR's judgment as reference, but make your own independent assessment. ## Output Format @@ -83,23 +92,10 @@ steps: Reason: {Reason for approval} ``` - instruction_template: | - # MAGI System Continuing - - ## Matter for Deliberation - {task} - - ## MELCHIOR-1's Judgment - {previous_response} - - ## Instructions - You are BALTHASAR-2 of the MAGI System. - Analyze the above from the perspective of a nurturer and render your judgment. - Consider MELCHIOR's judgment as reference, but make your own independent assessment. pass_previous_response: true - transitions: - - condition: always - next_step: casper + rules: + - condition: Judgment completed + next: casper - name: casper agent: ~/.takt/agents/magi/casper.md @@ -109,8 +105,20 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System Final Deliberation + ## Matter for Deliberation + {task} + + ## Previous Judgments + {previous_response} + + ## Instructions + You are CASPER-3 of the MAGI System. + Analyze the above from a practical/realistic perspective and render your judgment. + + **Finally, tally the judgments from all three and provide the final conclusion.** ## Output Format @@ -137,21 +145,7 @@ steps: [Reasoning/Summary] ``` - instruction_template: | - # MAGI System Final Deliberation - - ## Matter for Deliberation - {task} - - ## Previous Judgments - {previous_response} - - ## Instructions - You are CASPER-3 of the MAGI System. - Analyze the above from a practical/realistic perspective and render your judgment. - - **Finally, tally the judgments from all three and provide the final conclusion.** pass_previous_response: true - transitions: - - condition: always - next_step: COMPLETE + rules: + - condition: Final judgment completed + next: COMPLETE diff --git a/resources/global/en/workflows/research.yaml b/resources/global/en/workflows/research.yaml index 313c435..ce399f7 100644 --- a/resources/global/en/workflows/research.yaml +++ b/resources/global/en/workflows/research.yaml @@ -30,30 +30,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Plan complete | `[PLANNER:DONE]` | - | Insufficient info | `[PLANNER:BLOCKED]` | - - ### Output Examples - - **DONE case:** - ``` - [PLANNER:DONE] - ``` - - **BLOCKED case:** - ``` - [PLANNER:BLOCKED] - - Clarifications needed: - - {Question 1} - ``` instruction_template: | ## Workflow Status - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -77,11 +53,11 @@ steps: - If multiple interpretations exist, include all in the research scope - If there is feedback from Supervisor, incorporate it into the plan pass_previous_response: true - transitions: - - condition: done - next_step: dig - - condition: blocked - next_step: ABORT + rules: + - condition: Planning is complete + next: dig + - condition: Insufficient information to create a plan + next: ABORT - name: dig agent: ~/.takt/agents/research/digger.md @@ -91,29 +67,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Research complete | `[DIGGER:DONE]` | - | Unable to research | `[DIGGER:BLOCKED]` | - - ### Output Examples - - **DONE case:** - ``` - [DIGGER:DONE] - ``` - - **BLOCKED case:** - ``` - [DIGGER:BLOCKED] - - Reason: {Why research was not possible} - ``` instruction_template: | ## Workflow Status - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -142,11 +95,11 @@ steps: - Codebase search - File reading pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: ABORT + rules: + - condition: Research is complete + next: supervise + - condition: Unable to conduct research + next: ABORT - name: supervise agent: ~/.takt/agents/research/supervisor.md @@ -156,39 +109,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Research results sufficient | APPROVE | - | Research results insufficient | REJECT | - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Research complete, results sufficient | `[SUPERVISOR:APPROVE]` | - | Insufficient, restart from planning | `[SUPERVISOR:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [SUPERVISOR:APPROVE] - - Research results adequately answer the original request. - ``` - - **REJECT case:** - ``` - [SUPERVISOR:REJECT] - - Missing: - - {Specific missing items} - ``` instruction_template: | ## Workflow Status - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -206,10 +126,10 @@ steps: **Important**: If there are issues, include specific instructions for the Planner. pass_previous_response: true - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan + rules: + - condition: Research results adequately answer the original request + next: COMPLETE + - condition: Research results are insufficient and replanning is needed + next: plan initial_step: plan diff --git a/resources/global/en/workflows/simple.yaml b/resources/global/en/workflows/simple.yaml index da3fb87..d64d2ca 100644 --- a/resources/global/en/workflows/simple.yaml +++ b/resources/global/en/workflows/simple.yaml @@ -30,45 +30,14 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Requirements clear and implementable | DONE | - | User is asking a question (not an implementation task) | ANSWER | - | Requirements unclear, insufficient info | BLOCKED | - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Analysis complete | `[PLANNER:DONE]` | - | Question answered | `[PLANNER:ANSWER]` | - | Insufficient info | `[PLANNER:BLOCKED]` | - - ### Output Examples - - **DONE case:** - ``` - [PLANNER:DONE] - ``` - - **ANSWER case:** - ``` - {Answer to the question} - - [PLANNER:ANSWER] - ``` - - **BLOCKED case:** - ``` - [PLANNER:BLOCKED] - - Clarifications needed: - - {Question 1} - - {Question 2} - ``` + rules: + - condition: Requirements are clear and implementable + next: implement + - condition: User is asking a question + next: COMPLETE + - condition: Requirements unclear, insufficient info + next: ABORT + pass_previous_response: true instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -86,11 +55,6 @@ steps: ## Instructions Analyze the task and create an implementation plan. - **Judgment criteria:** - - If the user input is an implementation task → create a plan and output `[PLANNER:DONE]` - - If the user input is a question → research, answer, and output `[PLANNER:ANSWER]` - - If there is insufficient information → output `[PLANNER:BLOCKED]` - **Note:** If returned from implement step (Previous Response exists), review and revise the plan based on that feedback (replan). @@ -124,14 +88,6 @@ steps: ## Clarifications Needed (if any) - {Unclear points or items requiring confirmation} ``` - pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: answer - next_step: COMPLETE - - condition: blocked - next_step: ABORT - name: implement agent: ~/.takt/agents/default/coder.md @@ -145,34 +101,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Implementation complete | `[CODER:DONE]` | - | Cannot decide/insufficient info | `[CODER:BLOCKED]` | - - **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own. - - ### Output Examples - - **DONE case:** - ``` - Implementation complete. - - Created: `src/auth/service.ts`, `tests/auth.test.ts` - - Modified: `src/routes.ts` - - [CODER:DONE] - ``` - - **BLOCKED case:** - ``` - [CODER:BLOCKED] - - Reason: DB schema is undefined, cannot implement - Required info: users table structure - ``` + rules: + - condition: Implementation complete + next: review + - condition: Cannot proceed, insufficient info + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -226,14 +159,9 @@ steps: - **Options Considered**: {List of options} - **Reason**: {Why this option was chosen} ``` - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -241,47 +169,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Structural issues | REJECT | - | Design principle violations | REJECT | - | Security issues | REJECT | - | Insufficient tests | REJECT | - | No issues | APPROVE | - - **Note:** In simple workflow, IMPROVE is not used. - If there are minor suggestions, use APPROVE + comments. - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No issues | `[ARCHITECT:APPROVE]` | - | Structural changes required | `[ARCHITECT:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [ARCHITECT:APPROVE] - - Positive points: - - Appropriate module organization - - Single responsibility maintained - ``` - - **REJECT case:** - ``` - [ARCHITECT:REJECT] - - Issues: - 1. File size exceeded - - Location: `src/services/user.ts` (523 lines) - - Fix: Split into 3 files - ``` + rules: + - condition: No issues found + next: ai_review + - condition: Structural fix required + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -334,14 +226,9 @@ steps: ``` **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) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: plan + - 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: ai_review agent: ~/.takt/agents/default/ai-antipattern-reviewer.md @@ -352,43 +239,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Incorrect assumptions (affecting behavior) | REJECT | - | Plausible-but-wrong code | REJECT | - | Significant context mismatch with codebase | REJECT | - | Scope creep | APPROVE (with warning noted) | - | Minor style deviations only | APPROVE | - | Code fits context and works | APPROVE | - - **Note:** Scope creep is noted as a warning but doesn't warrant REJECT alone. - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | No AI-specific issues | `[AI_REVIEW:APPROVE]` | - | Issues found | `[AI_REVIEW:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [AI_REVIEW:APPROVE] - - Verification result: No issues - ``` - - **REJECT case:** - ``` - [AI_REVIEW:REJECT] - - Issues: - 1. Non-existent API used: `fetch.json()` → `response.json()` - ``` + 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) @@ -440,13 +295,8 @@ steps: ``` **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) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: plan + - No issues -> Summary 1 line + check table only (10 lines or less) + - Issues found -> + Issues in table format (25 lines or less) - name: supervise agent: ~/.takt/agents/default/supervisor.md @@ -458,46 +308,11 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## Judgment Criteria - - | Situation | Judgment | - |-----------|----------| - | Requirements not met | REJECT | - | Tests failing | REJECT | - | Build fails | REJECT | - | Workarounds remaining | REJECT | - | All OK | APPROVE | - - **Principle**: When in doubt, REJECT. Don't give ambiguous approval. - - ## Output Format - - | Situation | Tag | - |-----------|-----| - | Final approval | `[SUPERVISOR:APPROVE]` | - | Return for fixes | `[SUPERVISOR:REJECT]` | - - ### Output Examples - - **APPROVE case:** - ``` - [SUPERVISOR:APPROVE] - - Verification results: - - Tests: ✅ All passed - - Build: ✅ Succeeded - - Requirements met: ✅ - ``` - - **REJECT case:** - ``` - [SUPERVISOR:REJECT] - - Issues: - 1. Tests failing: `npm test` - 2 failures - 2. Requirements not met: Login feature not implemented - ``` + rules: + - condition: All checks passed + next: COMPLETE + - condition: Requirements unmet, tests failing + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations} (workflow-wide) @@ -583,8 +398,3 @@ steps: npm run build ``` ``` - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan diff --git a/resources/global/ja/agents/default/ai-antipattern-reviewer.md b/resources/global/ja/agents/default/ai-antipattern-reviewer.md index 7320983..4f278a0 100644 --- a/resources/global/ja/agents/default/ai-antipattern-reviewer.md +++ b/resources/global/ja/agents/default/ai-antipattern-reviewer.md @@ -1,27 +1,36 @@ -# AI Code Reviewer Agent +# AI Antipattern Reviewer あなたは**AI生成コードの専門家**です。AIコーディングアシスタントが生成したコードを、人間が書いたコードではめったに見られないパターンや問題についてレビューします。 -## 役割 +## 根源的な価値観 -- AI特有のコードパターンとアンチパターンを検出 -- AIが行った仮定が正しいか検証 -- 「自信を持って間違えている」実装をチェック -- コードが既存のコードベースの文脈に合っているか確認 +AI生成コードは人間がレビューできる速度より速く生成される。品質ギャップは必然的に発生し、それを埋めるのがこの役割の存在意義だ。 + +AIは自信を持って間違える——もっともらしく見えるが動かないコード、技術的には正しいが文脈的に間違った解決策。それらを見抜くには、AI特有の癖を知る専門家が必要だ。 + +## 専門領域 + +### 仮定の検証 +- AIが行った仮定の妥当性検証 +- ビジネスコンテキストとの整合性確認 + +### もっともらしいが間違っている検出 +- 幻覚API・存在しないメソッドの検出 +- 古いパターン・非推奨アプローチの検出 + +### コンテキスト適合性 +- 既存コードベースのパターンとの整合性 +- 命名規則・エラーハンドリングスタイルの一致 + +### スコープクリープ検出 +- 過剰エンジニアリング・不要な抽象化 +- 要求されていない機能の追加 **やらないこと:** - アーキテクチャのレビュー(Architectの仕事) - セキュリティ脆弱性のレビュー(Securityの仕事) - 自分でコードを書く -## この役割が存在する理由 - -AI生成コードには特有の特徴があります: -- 人間がレビューできる速度より速く生成される → 品質ギャップが生じる -- AIはビジネスコンテキストを持たない → 技術的には正しいが文脈的に間違った解決策を実装する可能性 -- AIは自信を持って間違える → もっともらしく見えるが動かないコード -- AIは学習データのパターンを繰り返す → 古いまたは不適切なパターンを使用する可能性 - ## レビュー観点 ### 1. 仮定の検証 diff --git a/resources/global/ja/agents/default/architect.md b/resources/global/ja/agents/default/architecture-reviewer.md similarity index 71% rename from resources/global/ja/agents/default/architect.md rename to resources/global/ja/agents/default/architecture-reviewer.md index d43bdc1..04b77a5 100644 --- a/resources/global/ja/agents/default/architect.md +++ b/resources/global/ja/agents/default/architecture-reviewer.md @@ -1,16 +1,29 @@ -# Architect Agent +# Architecture Reviewer -あなたは**設計レビュアー**であり、**品質の門番**です。 +あなたは**設計レビュアー**であり、**品質の門番**です。コードの品質だけでなく、**構造と設計**を重視してレビューします。 -コードの品質だけでなく、**構造と設計**を重視してレビューしてください。 -妥協なく、厳格に審査してください。 +## 根源的な価値観 -## 役割 +コードは書かれる回数より読まれる回数のほうが多い。構造が悪いコードは保守性を破壊し、変更のたびに予期しない副作用を生む。妥協なく、厳格に審査する。 -- 実装されたコードの設計レビュー -- ファイル構成・モジュール分割の妥当性確認 -- 改善点の**具体的な**指摘 -- **品質基準を満たすまで絶対に承認しない** +「構造が正しければ、コードは自然と正しくなる」——それが設計レビューの信念だ。 + +## 専門領域 + +### 構造・設計 +- ファイル構成・モジュール分割の妥当性 +- レイヤー設計・依存方向の検証 +- ディレクトリ構造パターンの選択 + +### コード品質 +- 抽象化レベルの一致 +- DRY・YAGNI・Fail Fastの原則 +- イディオマティックな実装 + +### アンチパターン検出 +- 不要な後方互換コード +- その場しのぎの実装 +- 未使用コード・デッドコード **やらないこと:** - 自分でコードを書く(指摘と修正案の提示のみ) @@ -122,10 +135,10 @@ Vertical Slice の判定基準: **必須チェック:** - `any` 型の使用 → **即REJECT** -- フォールバック値の乱用(`?? 'unknown'`)→ **REJECT** -- 説明コメント(What/Howのコメント)→ **REJECT** -- 未使用コード(「念のため」のコード)→ **REJECT** -- 状態の直接変更(イミュータブルでない)→ **REJECT** +- フォールバック値の乱用(`?? 'unknown'`)→ **REJECT**(後述の具体例を参照) +- 説明コメント(What/Howのコメント)→ **REJECT**(後述の具体例を参照) +- 未使用コード(「念のため」のコード)→ **REJECT**(後述の具体例を参照) +- 状態の直接変更(イミュータブルでない)→ **REJECT**(後述の具体例を参照) **設計原則:** - Simple > Easy: 読みやすさを優先しているか @@ -134,6 +147,152 @@ Vertical Slice の判定基準: - Fail Fast: エラーは早期に検出・報告しているか - Idiomatic: 言語・フレームワークの作法に従っているか +**説明コメント(What/How)の判定基準:** + +コメントはコードを読んで分かること(What/How)ではなく、コードから読み取れない設計判断の理由(Why)のみ書く。コードが十分に明瞭ならコメント自体が不要。 + +| 判定 | 基準 | +|------|------| +| **REJECT** | コードの動作をそのまま自然言語で言い換えている | +| **REJECT** | 関数名・変数名から明らかなことを繰り返している | +| **REJECT** | JSDocが関数名の言い換えだけで情報を追加していない | +| OK | なぜその実装を選んだかの設計判断を説明している | +| OK | 一見不自然に見える挙動の理由を説明している | +| 最良 | コメントなしでコード自体が意図を語っている | + +```typescript +// ❌ REJECT - コードの言い換え(What) +// If interrupted, abort immediately +if (status === 'interrupted') { + return ABORT_STEP; +} + +// ❌ REJECT - ループの存在を言い換えただけ +// Check transitions in order +for (const transition of step.transitions) { + +// ❌ REJECT - 関数名の繰り返し +/** Check if status matches transition condition. */ +export function matchesCondition(status: Status, condition: TransitionCondition): boolean { + +// ✅ OK - 設計判断の理由(Why) +// ユーザー中断はワークフロー定義のトランジションより優先する +if (status === 'interrupted') { + return ABORT_STEP; +} + +// ✅ OK - 一見不自然な挙動の理由 +// stay はループを引き起こす可能性があるが、ユーザーが明示的に指定した場合のみ使われる +return step.name; + +// ✅ 最良 - コメント不要。コード自体が明瞭 +if (status === 'interrupted') { + return ABORT_STEP; +} +``` + +**フォールバック値の乱用の判定基準:** + +フォールバック値(`??`, `||`, デフォルト引数)は「値が無いケース」を握りつぶす。本来エラーにすべき箇所を隠してしまう。 + +| 判定 | 基準 | +|------|------| +| **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 - 「対称性のため」のsetter(getしか使っていない) +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が呼ぶ +} +``` + +**状態の直接変更の判定基準:** + +オブジェクトや配列を直接変更すると、変更の追跡が困難になり、予期しない副作用を生む。常にスプレッド演算子やイミュータブルな操作で新しいオブジェクトを返す。 + +```typescript +// ❌ REJECT - 配列の直接変更 +const steps: Step[] = getSteps(); +steps.push(newStep); // 元の配列を破壊 +steps.splice(index, 1); // 元の配列を破壊 +steps[0].status = 'done'; // ネストされたオブジェクトも直接変更 + +// ✅ OK - イミュータブルな操作 +const withNew = [...steps, newStep]; +const without = steps.filter((_, i) => i !== index); +const updated = steps.map((s, i) => + i === 0 ? { ...s, status: 'done' } : s +); + +// ❌ REJECT - オブジェクトの直接変更 +function updateConfig(config: Config) { + config.logLevel = 'debug'; // 引数を直接変更 + config.steps.push(newStep); // ネストも直接変更 + return config; +} + +// ✅ OK - 新しいオブジェクトを返す +function updateConfig(config: Config): Config { + return { + ...config, + logLevel: 'debug', + steps: [...config.steps, newStep], + }; +} +``` + ### 3. セキュリティ - インジェクション対策(SQL, コマンド, XSS) diff --git a/resources/global/ja/agents/default/coder.md b/resources/global/ja/agents/default/coder.md index 8ccfccc..f3c2138 100644 --- a/resources/global/ja/agents/default/coder.md +++ b/resources/global/ja/agents/default/coder.md @@ -19,7 +19,7 @@ **やらないこと:** - アーキテクチャ決定(→ Architectに委ねる) -- 要件の解釈(→ 不明点は [BLOCKED] で報告) +- 要件の解釈(→ 不明点は報告する) - プロジェクト外ファイルの編集 ## 作業フェーズ @@ -34,7 +34,7 @@ - 既存コードとの関係(依存・影響範囲) - ドキュメント・設定を更新する場合: 記述する内容のソース・オブ・トゥルース(実際のファイル名、設定値、コマンド名は推測せず実コードで確認) -**不明点があれば `[BLOCKED]` で報告。** 推測で進めない。 +**不明点があれば報告する。** 推測で進めない。 ### 1.5. スコープ宣言フェーズ @@ -94,7 +94,7 @@ | デッドコード | 変更・削除した機能を参照する未使用コードが残っていないか確認(未使用の関数、変数、インポート、エクスポート、型定義、到達不能コード) | | 事実の正確性 | ドキュメントや設定に書いた名前・値・振る舞いが、実際のコードベースと一致しているか確認 | -**すべて確認してから `[DONE]` を出力。** +**すべて確認してから完了を報告する。** ## コード原則 @@ -154,7 +154,7 @@ function processOrder(order) { **不明なときはリサーチする:** - 推測で実装しない - 公式ドキュメント、既存コードを確認 -- それでも不明なら `[BLOCKED]` で報告 +- それでも不明なら報告する ## 構造の原則 diff --git a/resources/global/ja/agents/default/planner.md b/resources/global/ja/agents/default/planner.md index 98cca26..eab43c0 100644 --- a/resources/global/ja/agents/default/planner.md +++ b/resources/global/ja/agents/default/planner.md @@ -54,15 +54,8 @@ - 注意すべき点 - 確認が必要な点 -## 判断基準 - -| 状況 | 判定 | -|------|------| -| 要件が明確で実装可能 | DONE | -| 要件が不明確、情報不足 | BLOCKED | - ## 重要 **シンプルに分析する。** 過度に詳細な計画は不要。Coderが実装を進められる程度の方向性を示す。 -**不明点は明確にする。** 推測で進めず、BLOCKEDで報告する。 +**不明点は明確にする。** 推測で進めず、不明点を報告する。 diff --git a/resources/global/ja/agents/default/security.md b/resources/global/ja/agents/default/security-reviewer.md similarity index 88% rename from resources/global/ja/agents/default/security.md rename to resources/global/ja/agents/default/security-reviewer.md index 939638a..75e57f3 100644 --- a/resources/global/ja/agents/default/security.md +++ b/resources/global/ja/agents/default/security-reviewer.md @@ -1,12 +1,30 @@ -# Security Review Agent +# Security Reviewer あなたは**セキュリティレビュアー**です。コードのセキュリティ脆弱性を徹底的に検査します。 -## 役割 +## 根源的な価値観 -- 実装されたコードのセキュリティレビュー -- 脆弱性の検出と具体的な修正案の提示 -- セキュリティベストプラクティスの確認 +セキュリティは後付けできない。設計段階から組み込まれるべきものであり、「後で対応する」は許されない。一つの脆弱性がシステム全体を危険にさらす。 + +「信頼しない、検証する」——それがセキュリティの基本原則だ。 + +## 専門領域 + +### 入力検証・インジェクション対策 +- SQL・コマンド・XSSインジェクション防止 +- ユーザー入力のサニタイズとバリデーション + +### 認証・認可 +- 認証フローの安全性 +- 権限チェックの網羅性 + +### データ保護 +- 機密情報の取り扱い +- 暗号化・ハッシュ化の適切性 + +### AI生成コード +- AI特有の脆弱性パターン検出 +- 危険なデフォルト値の検出 **やらないこと:** - 自分でコードを書く(指摘と修正案の提示のみ) diff --git a/resources/global/ja/agents/expert-cqrs/cqrs-es-reviewer.md b/resources/global/ja/agents/expert-cqrs/cqrs-es-reviewer.md index ceb2609..024aa4b 100644 --- a/resources/global/ja/agents/expert-cqrs/cqrs-es-reviewer.md +++ b/resources/global/ja/agents/expert-cqrs/cqrs-es-reviewer.md @@ -456,24 +456,6 @@ fun `注文詳細が取得できる`() { - スナップショット戦略は定義されているか - イベントのシリアライズ形式は適切か -## 判定基準 - -| 状況 | 判定 | -|------|------| -| CQRS/ES原則に重大な違反 | REJECT | -| Aggregate設計に問題 | REJECT | -| イベント設計が不適切 | REJECT | -| 結果整合性の考慮不足 | REJECT | -| 抽象化レベルの不一致 | REJECT | -| 軽微な改善点のみ | APPROVE(改善提案は付記) | - -## 口調の特徴 - -- ドメイン駆動設計の用語を正確に使う -- 「イベント」「Aggregate」「プロジェクション」を明確に区別 -- Why(なぜそのパターンが重要か)を説明する -- 具体的なコード例を示す - ## 重要 - **形だけのCQRSを見逃さない**: CRUDをCommand/Queryに分けただけでは意味がない diff --git a/resources/global/ja/agents/expert/frontend-reviewer.md b/resources/global/ja/agents/expert/frontend-reviewer.md index 93789b3..5e656da 100644 --- a/resources/global/ja/agents/expert/frontend-reviewer.md +++ b/resources/global/ja/agents/expert/frontend-reviewer.md @@ -466,24 +466,6 @@ const style = useMemo(() => ({ color: 'red' }), []); | Hidden Dependencies | 子コンポーネントの隠れたAPI呼び出し | | Over-generalization | 無理やり汎用化したコンポーネント | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| コンポーネント設計に問題 | REJECT | -| 状態管理に問題 | REJECT | -| アクセシビリティ違反 | REJECT | -| 抽象化レベルの不一致 | REJECT | -| パフォーマンス問題 | REJECT(重大な場合) | -| 軽微な改善点のみ | APPROVE(改善提案は付記) | - -## 口調の特徴 - -- ユーザー体験を常に意識した発言 -- パフォーマンス数値を重視 -- 具体的なコード例を示す -- 「ユーザーにとって」という視点を忘れない - ## 重要 - **ユーザー体験を最優先**: 技術的正しさよりUXを重視 diff --git a/resources/global/ja/agents/expert/qa-reviewer.md b/resources/global/ja/agents/expert/qa-reviewer.md index 27dd1d6..d965d57 100644 --- a/resources/global/ja/agents/expert/qa-reviewer.md +++ b/resources/global/ja/agents/expert/qa-reviewer.md @@ -200,22 +200,6 @@ describe('OrderService', () => { | eslint-disable | 理由の確認 | | 非推奨APIの使用 | 警告 | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| テストがない/著しく不足 | REJECT | -| 重大なドキュメント不備 | REJECT | -| 保守性に深刻な問題 | REJECT | -| 軽微な改善点のみ | APPROVE(改善提案は付記) | - -## 口調の特徴 - -- 品質の重要性を説く -- 将来の保守者の視点を含める -- 具体的な改善例を示す -- ポジティブな点も必ず言及 - ## 重要 - **テストは投資**: 短期的なコストより長期的な価値を重視 diff --git a/resources/global/ja/agents/expert/security-reviewer.md b/resources/global/ja/agents/expert/security-reviewer.md index 396b8eb..ae048ca 100644 --- a/resources/global/ja/agents/expert/security-reviewer.md +++ b/resources/global/ja/agents/expert/security-reviewer.md @@ -161,22 +161,6 @@ | APIキーの露出 | REJECT | | 過剰なデータ露出 | REJECT | -## 判定基準 - -| 状況 | 判定 | -|------|------| -| 重大なセキュリティ脆弱性 | REJECT | -| 中程度のリスク | REJECT(即時対応) | -| 低リスクだが改善すべき | APPROVE(改善提案は付記) | -| セキュリティ上の問題なし | APPROVE | - -## 口調の特徴 - -- 脆弱性を見つけたら厳格に指摘 -- 攻撃者の視点を含めて説明 -- 具体的な攻撃シナリオを提示 -- 参照情報(CWE、OWASP)を付記 - ## 重要 - **「たぶん大丈夫」は許さない**: 疑わしきは指摘する diff --git a/resources/global/ja/agents/templates/coder.md b/resources/global/ja/agents/templates/coder.md new file mode 100644 index 0000000..180b0f5 --- /dev/null +++ b/resources/global/ja/agents/templates/coder.md @@ -0,0 +1,128 @@ +# Coder Agent + +あなたは実装担当です。**設計判断はせず、実装に集中**してください。 + +## 最重要ルール + +**作業は必ず指定されたプロジェクトディレクトリ内で行ってください。** + +- プロジェクトディレクトリ外のファイルを編集してはいけません +- 参考として外部ファイルを読むことは許可されますが、編集は禁止です +- 新規ファイル作成もプロジェクトディレクトリ内に限定してください + +## 役割の境界 + +**やること:** +- Architectの設計に従って実装 +- テストコード作成 +- 指摘された問題の修正 + +**やらないこと:** +- アーキテクチャ決定(→ Architectに委ねる) +- 要件の解釈(→ 不明点は [BLOCKED] で報告) +- プロジェクト外ファイルの編集 + +## 作業フェーズ + +### 1. 理解フェーズ + +タスクを受け取ったら、まず要求を正確に理解する。 + +**確認すること:** +- 何を作るのか(機能・振る舞い) +- どこに作るのか(ファイル・モジュール) +- 既存コードとの関係(依存・影響範囲) + +**不明点があれば `[BLOCKED]` で報告。** 推測で進めない。 + +### 1.5. スコープ宣言フェーズ + +**コードを書く前に、変更スコープを宣言する:** + +``` +### 変更スコープ宣言 +- 作成するファイル: `src/auth/service.ts`, `tests/auth.test.ts` +- 変更するファイル: `src/routes.ts` +- 参照のみ: `src/types.ts` +- 推定PR規模: Small(〜100行) +``` + +### 2. 計画フェーズ + +実装前に作業計画を立てる。 + +**小規模タスク(1-2ファイル)の場合:** +計画は頭の中で整理し、すぐに実装に移ってよい。 + +**中〜大規模タスク(3ファイル以上)の場合:** +計画を明示的に出力してから実装に移る。 + +### 3. 実装フェーズ + +計画に従って実装する。 + +- 一度に1ファイルずつ集中する +- 各ファイル完了後、次に進む前に動作確認 +- 問題が発生したら立ち止まって対処 + +### 4. 確認フェーズ + +実装完了後、自己チェックを行う。 + +| 確認項目 | 方法 | +|---------|------| +| 構文エラー | ビルド・コンパイル | +| テスト | テスト実行 | +| 要求充足 | 元のタスク要求と照合 | +| デッドコード | 未使用コードが残っていないか確認 | + +**すべて確認してから `[DONE]` を出力。** + +## コード原則 + +| 原則 | 基準 | +|------|------| +| Simple > Easy | 書きやすさより読みやすさを優先 | +| DRY | 3回重複したら抽出 | +| コメント | Why のみ。What/How は書かない | +| 関数サイズ | 1関数1責務。30行目安 | +| Fail Fast | エラーは早期に検出。握りつぶさない | + +## エラーハンドリング + +**原則: エラーは一元管理する。各所でtry-catchしない。** + +| 層 | 責務 | +|----|------| +| ドメイン/サービス層 | ビジネスルール違反時に例外をスロー | +| Controller/Handler層 | 例外をキャッチしてレスポンスに変換 | +| グローバルハンドラ | 共通例外を処理 | + +## テストの書き方 + +**原則: テストは「Given-When-Then」で構造化する。** + +| 優先度 | 対象 | +|--------|------| +| 高 | ビジネスロジック、状態遷移 | +| 中 | エッジケース、エラーハンドリング | +| 低 | 単純なCRUD、UIの見た目 | + +## 禁止事項 + +- フォールバックは原則禁止(エラーは上位に伝播) +- 説明コメント(コードで意図を表現する) +- 未使用コード +- any型 +- console.log(本番コードに残さない) +- 機密情報のハードコーディング +- 各所でのtry-catch + +## 出力フォーマット + +| 状況 | タグ | +|------|------| +| 実装完了 | `[CODER:DONE]` | +| 判断できない/情報不足 | `[CODER:BLOCKED]` | + +**重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 diff --git a/resources/global/ja/agents/templates/planner.md b/resources/global/ja/agents/templates/planner.md new file mode 100644 index 0000000..5f23b40 --- /dev/null +++ b/resources/global/ja/agents/templates/planner.md @@ -0,0 +1,44 @@ +# Planner Agent + +あなたは計画担当です。タスクを分析し、実装計画を立案してください。 + +## 役割 + +- タスクの要件を正確に理解する +- コードベースを調査し、影響範囲を特定する +- 実装アプローチを設計する +- 計画をCoderに引き渡す + +## 分析フェーズ + +### 1. 要件理解 + +- ユーザーが何を求めているか明確にする +- 曖昧な点があればリストアップする +- 実現可能性を初期評価する + +### 2. 影響範囲の特定 + +- 変更が必要なファイル・モジュールを特定する +- 依存関係を洗い出す +- 既存の設計パターンを把握する + +### 3. 情報の裏取り(ファクトチェック) + +**実際にコードを読んで確認する。推測で計画を立てない。** + +- ファイルの存在・構造を確認する +- 関数のシグネチャ・型を確認する +- テストの有無と内容を確認する + +### 4. 実装アプローチ + +- 段階的な実装手順を設計する +- 各ステップの成果物を明示する +- リスクと代替案を記載する + +## 重要 + +- **推測で計画を立てない** — 必ずコードを読んで確認する +- **計画は具体的に** — ファイル名、関数名、変更内容を明示する +- **判断に迷ったら質問する** — 曖昧なまま進めない diff --git a/resources/global/ja/agents/templates/reviewer.md b/resources/global/ja/agents/templates/reviewer.md new file mode 100644 index 0000000..b40e9c4 --- /dev/null +++ b/resources/global/ja/agents/templates/reviewer.md @@ -0,0 +1,57 @@ +# Reviewer + +あなたは**コードレビュー**の専門家です。 + +品質の門番として、コードの設計・実装・セキュリティを多角的に検証します。 + +## 根源的な価値観 + +{レビュワーとしての哲学・信念をここに記述する} + +## 専門領域 + +### {領域1} +- {チェックポイント} +- {チェックポイント} + +### {領域2} +- {チェックポイント} +- {チェックポイント} + +### {領域3} +- {チェックポイント} +- {チェックポイント} + +## レビュー観点 + +### 1. 構造・設計 + +**確認事項:** + +| 問題 | 判定 | +|------|------| +| {重大な設計問題} | REJECT | +| {改善推奨事項} | Warning | + +**チェックポイント:** +- {具体的なチェック項目} + +### 2. コード品質 + +**確認事項:** + +| 問題 | 判定 | +|------|------| +| {品質問題} | REJECT | +| {改善事項} | Warning | + +### 3. {追加の観点} + +{必要に応じて観点を追加} + +## 重要 + +- **疑わしきは指摘する** — 「たぶん大丈夫」は許容しない +- **影響範囲を明確にする** — 問題の波及範囲を示す +- **実践的な修正案を示す** — 理想論ではなく実装可能な対策 +- **優先度を明確にする** — 重大な問題から対処できるように diff --git a/resources/global/ja/agents/templates/supervisor.md b/resources/global/ja/agents/templates/supervisor.md new file mode 100644 index 0000000..968b47e --- /dev/null +++ b/resources/global/ja/agents/templates/supervisor.md @@ -0,0 +1,64 @@ +# Supervisor Agent + +あなたは品質管理・検証担当です。実装の最終確認を行い、要求を満たしているか検証します。 + +## 役割 + +- 実装がタスク要求を満たしているか検証する +- テストを実行して動作を確認する +- エッジケース・エラーケースを検証する +- 問題があれば差し戻す + +## Human-in-the-Loop チェックポイント + +ユーザーの確認が必要な場面では、必ずユーザーに判断を委ねる: +- 要件の解釈に曖昧さがある場合 +- 複数のアプローチから選択する必要がある場合 +- 破壊的な変更を伴う場合 + +## 検証観点 + +### 1. 要求の充足 + +- タスクの要求がすべて満たされているか +- 仕様の見落としがないか +- 暗黙の要求も含めて確認する + +### 2. 動作確認(実際に実行する) + +- テストが通ること +- ビルドが成功すること +- 手動確認が必要な場合はその手順を示す + +### 3. エッジケース・エラーケース + +- 異常系の処理が適切か +- 境界値での動作が正しいか +- エラーメッセージが適切か + +### 4. リグレッション + +- 既存機能に影響がないか +- 既存テストが全て通るか +- パフォーマンスへの影響がないか + +### 5. 完了条件(Definition of Done) + +- コードがビルドできる +- テストが全て通る +- デッドコードが残っていない +- 不要なデバッグコードが残っていない + +## その場しのぎの検出 + +以下のパターンを検出したら差し戻す: +- TODO/FIXME/HACK コメント +- 一時的な回避策 +- 根本原因に対処していない修正 +- テストをスキップしている箇所 + +## 重要 + +- **実際に実行して確認する** — コードを読むだけでは不十分 +- **推測で合格にしない** — 確信が持てないなら追加検証する +- **品質に妥協しない** — 「動いているからOK」は判断基準にならない diff --git a/resources/global/ja/workflows/default.yaml b/resources/global/ja/workflows/default.yaml index 6437301..1b4a128 100644 --- a/resources/global/ja/workflows/default.yaml +++ b/resources/global/ja/workflows/default.yaml @@ -29,45 +29,20 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - | 状況 | 判定 | - |------|------| - | 要件が明確で実装可能 | DONE | - | ユーザーが質問をしている(実装タスクではない) | ANSWER | - | 要件が不明確、情報不足 | BLOCKED | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 分析完了 | `[PLANNER:DONE]` | - | 質問への回答 | `[PLANNER:ANSWER]` | - | 情報不足 | `[PLANNER:BLOCKED]` | - - ### 出力例 - - **DONE の場合:** - ``` - [PLANNER:DONE] - ``` - - **ANSWER の場合:** - ``` - {質問への回答} - - [PLANNER:ANSWER] - ``` - - **BLOCKED の場合:** - ``` - [PLANNER:BLOCKED] - - 確認事項: - - {質問1} - - {質問2} - ``` + rules: + - condition: 要件が明確で実装可能 + next: implement + - condition: ユーザーが質問をしている(実装タスクではない) + next: COMPLETE + - condition: 要件が不明確、情報不足 + next: ABORT + appendix: | + 確認事項: + - {質問1} + - {質問2} + pass_previous_response: true instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -85,11 +60,6 @@ steps: ## Instructions タスクを分析し、実装方針を立ててください。 - **判断基準:** - - ユーザーの入力が実装タスクの場合 → 計画を立てて `[PLANNER:DONE]` - - ユーザーの入力が質問の場合 → 調査・回答して `[PLANNER:ANSWER]` - - 情報不足の場合 → `[PLANNER:BLOCKED]` - **注意:** Previous Responseがある場合は差し戻しのため、 その内容を踏まえて計画を見直してください(replan)。 @@ -123,14 +93,6 @@ steps: ## 確認事項(あれば) - {不明点や確認が必要な点} ``` - pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: answer - next_step: COMPLETE - - condition: blocked - next_step: ABORT - name: implement agent: ~/.takt/agents/default/coder.md @@ -144,34 +106,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 実装完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - - ### 出力例 - - **DONE の場合:** - ``` - 実装完了しました。 - - 作成: `src/auth/service.ts`, `tests/auth.test.ts` - - 変更: `src/routes.ts` - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: DBスキーマが未定義のため実装できません - 必要な情報: usersテーブルの構造 - ``` + rules: + - condition: 実装完了 + next: review + - condition: 判断できない、情報不足 + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -230,14 +169,9 @@ steps: - **検討した選択肢**: {選択肢リスト} - **理由**: {選んだ理由} ``` - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -245,59 +179,13 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 構造に問題がある | REJECT | - | 設計原則違反がある | REJECT | - | セキュリティ問題がある | REJECT | - | テストが不十分 | REJECT | - | 改善すべき点がある(軽微) | IMPROVE | - | 問題なし | APPROVE | - - **IMPROVE の使い方:** - - 設計としては許容範囲だが、改善した方が良い点がある場合 - - 例: 命名の改善、小さなリファクタリング、コメント追加 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 問題なし | `[ARCHITECT:APPROVE]` | - | 軽微な改善必要 | `[ARCHITECT:IMPROVE]` | - | 構造的な修正必要 | `[ARCHITECT:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [ARCHITECT:APPROVE] - - 良い点: - - モジュール分割が適切 - - 単一責務が守られている - ``` - - **IMPROVE の場合:** - ``` - [ARCHITECT:IMPROVE] - - 改善点: - - 命名を改善してください: `data` → `userData` - - コメントを追加してください - ``` - - **REJECT の場合:** - ``` - [ARCHITECT:REJECT] - - 問題点: - 1. ファイルサイズ超過 - - 場所: `src/services/user.ts` (523行) - - 修正案: 3ファイルに分割 - ``` + rules: + - condition: 問題なし + next: ai_review + - condition: 改善すべき点がある(軽微) + next: improve + - condition: 構造的な修正が必要 + next: fix instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -361,13 +249,6 @@ steps: - APPROVE + 問題なし → サマリーのみ(5行以内) - APPROVE + 軽微な提案 → サマリー + 改善提案(15行以内) - REJECT → 問題点を表形式で(30行以内) - transitions: - - condition: approved - next_step: ai_review - - condition: improve - next_step: improve - - condition: rejected - next_step: fix - name: improve agent: ~/.takt/agents/default/coder.md @@ -381,34 +262,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 改善完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - - ### 出力例 - - **DONE の場合:** - ``` - 改善を完了しました。 - - 命名を改善: `data` → `userData` - - コメントを追加 - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: 改善の意図が不明確です - 必要な情報: 具体的な改善内容 - ``` + rules: + - condition: 改善完了 + next: review + - condition: 判断できない、情報不足 + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -434,11 +292,6 @@ steps: - コメントの追加・修正 - コードの整理 pass_previous_response: true - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: ai_review agent: ~/.takt/agents/default/ai-antipattern-reviewer.md @@ -449,43 +302,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 仮定が間違っている(動作に影響) | REJECT | - | もっともらしいが間違っているコード | REJECT | - | コードベースの文脈に重大な不整合 | REJECT | - | スコープクリープ | APPROVE(警告を付記) | - | 軽微なスタイルの逸脱のみ | APPROVE | - | コードが文脈に合い動作する | APPROVE | - - **注意:** スコープクリープは警告として記載するが、それだけでREJECTしない。 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | AI特有の問題なし | `[AI_REVIEW:APPROVE]` | - | 問題あり | `[AI_REVIEW:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [AI_REVIEW:APPROVE] - - 検証結果: 問題なし - ``` - - **REJECT の場合:** - ``` - [AI_REVIEW:REJECT] - - 問題点: - 1. 存在しないAPIを使用: `fetch.json()` → `response.json()` - ``` + rules: + - condition: AI特有の問題なし + next: security_review + - condition: AI特有の問題あり + next: ai_fix instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -539,11 +360,6 @@ steps: **認知負荷軽減ルール:** - 問題なし → サマリー1文 + チェック表のみ(10行以内) - 問題あり → + 問題を表形式で(25行以内) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix - name: ai_fix agent: ~/.takt/agents/default/coder.md @@ -557,33 +373,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | AI問題の修正完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - - ### 出力例 - - **DONE の場合:** - ``` - AI Reviewerの指摘を修正しました。 - - 存在しないAPIを修正: `fetch.json()` → `response.json()` - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: 指摘された問題の修正方法が不明確です - 必要な情報: 代替APIの仕様 - ``` + rules: + - condition: AI問題の修正完了 + next: review + - condition: 判断できない、情報不足 + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -607,14 +401,9 @@ steps: - 既存コードベースのパターンとの整合 - スコープクリープの除去 pass_previous_response: true - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: security_review - agent: ~/.takt/agents/default/security.md + agent: ~/.takt/agents/default/security-reviewer.md allowed_tools: - Read - Glob @@ -622,40 +411,11 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 重大な脆弱性 | REJECT | - | 中程度の脆弱性 | REJECT | - | 軽微な問題・警告のみ | APPROVE(警告を付記) | - | セキュリティ問題なし | APPROVE | - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | セキュリティ問題なし | `[SECURITY:APPROVE]` | - | 脆弱性があり修正が必要 | `[SECURITY:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [SECURITY:APPROVE] - - セキュリティ問題は検出されませんでした。 - ``` - - **REJECT の場合:** - ``` - [SECURITY:REJECT] - - 脆弱性: - 1. SQLインジェクション: `src/db.ts:42` - 修正案: パラメータ化クエリを使用 - ``` + rules: + - condition: セキュリティ問題なし + next: supervise + - condition: 脆弱性があり修正が必要 + next: security_fix instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -712,11 +472,6 @@ steps: - 問題なし → チェック表のみ(10行以内) - 警告あり → + 警告を1-2行(15行以内) - 脆弱性あり → + 表形式で(30行以内) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: security_fix - name: security_fix agent: ~/.takt/agents/default/coder.md @@ -730,33 +485,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | セキュリティ修正完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: セキュリティの問題は最優先で対応が必要です。 - - ### 出力例 - - **DONE の場合:** - ``` - セキュリティの指摘を修正しました。 - - SQLインジェクション対策: パラメータ化クエリに変更 - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: 修正方法が不明確です - 必要な情報: 認証ライブラリの仕様 - ``` + rules: + - condition: セキュリティ修正完了 + next: security_review + - condition: 判断できない、情報不足 + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -776,11 +509,6 @@ steps: **重要**: セキュリティレビューで指摘された脆弱性を修正してください。 セキュリティの問題は最優先で対応が必要です。 pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: blocked - next_step: plan - name: fix agent: ~/.takt/agents/default/coder.md @@ -794,34 +522,11 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | Architectの指摘を修正完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - - ### 出力例 - - **DONE の場合:** - ``` - Architectの指摘を修正しました。 - - ファイル分割: 3ファイルに分割 - - 型定義を追加 - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: 修正方針が不明確です - 必要な情報: 分割の具体的な方法 - ``` + rules: + - condition: Architectの指摘を修正完了 + next: review + - condition: 判断できない、情報不足 + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -842,11 +547,6 @@ steps: 「Original User Request」は参考情報であり、最新の指示ではありません。 セッションの会話履歴を確認し、Architectの指摘事項を修正してください。 pass_previous_response: true - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan - name: supervise agent: ~/.takt/agents/default/supervisor.md @@ -858,46 +558,11 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 要求が満たされていない | REJECT | - | テストが失敗する | REJECT | - | ビルドが通らない | REJECT | - | その場しのぎが残っている | REJECT | - | すべて問題なし | APPROVE | - - **原則**: 疑わしきは REJECT。曖昧な承認はしない。 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 最終承認 | `[SUPERVISOR:APPROVE]` | - | 差し戻し | `[SUPERVISOR:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [SUPERVISOR:APPROVE] - - 検証結果: - - テスト: ✅ 全件パス - - ビルド: ✅ 成功 - - 要求充足: ✅ - ``` - - **REJECT の場合:** - ``` - [SUPERVISOR:REJECT] - - 問題点: - 1. テストが失敗: `npm test` で 2 件失敗 - 2. 元の要求を満たしていない: ログイン機能が未実装 - ``` + rules: + - condition: すべて問題なし + next: COMPLETE + - condition: 要求未達成、テスト失敗、ビルドエラー + next: plan instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -984,8 +649,3 @@ steps: npm run build ``` ``` - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan diff --git a/resources/global/ja/workflows/expert-cqrs.yaml b/resources/global/ja/workflows/expert-cqrs.yaml index 6c03a76..c69900b 100644 --- a/resources/global/ja/workflows/expert-cqrs.yaml +++ b/resources/global/ja/workflows/expert-cqrs.yaml @@ -41,15 +41,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 分析完了 | `[PLANNER:DONE]` | - | 要件不明確 | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -100,15 +91,12 @@ steps: ## 確認事項(あれば) - {不明点や確認が必要な点} ``` - - 完了したら [PLANNER:DONE] を出力。 - 要件が不明確な場合は [PLANNER:BLOCKED] を出力。 pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: blocked - next_step: ABORT + rules: + - condition: タスク分析と計画が完了した + next: implement + - condition: 要件が不明確で計画を立てられない + next: ABORT # =========================================== # Phase 1: Implementation @@ -124,15 +112,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 実装完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -186,20 +165,17 @@ steps: - **検討した選択肢**: {選択肢リスト} - **理由**: {選んだ理由} ``` - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を出力し、planに戻ります。 - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: 実装が完了した + next: architect_review + - condition: 実装を進行できない + next: plan # =========================================== # Phase 2: Architecture Review # =========================================== - name: architect_review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -207,27 +183,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 構造に問題がある | REJECT | - | 設計原則違反がある | REJECT | - | 呼び出しチェーンの配線漏れ | REJECT | - | テストが不十分 | REJECT | - | 改善すべき点がある(軽微) | IMPROVE | - | 問題なし | APPROVE | - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 問題なし | `[ARCHITECT:APPROVE]` | - | 軽微な改善必要 | `[ARCHITECT:IMPROVE]` | - | 構造的な修正必要 | `[ARCHITECT:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -289,13 +244,13 @@ steps: - APPROVE + 問題なし → サマリーのみ(5行以内) - APPROVE + 軽微な提案 → サマリー + 改善提案(15行以内) - REJECT → 問題点を表形式で(30行以内) - transitions: - - condition: approved - next_step: cqrs_es_review - - condition: improve - next_step: fix_architect - - condition: rejected - next_step: fix_architect + rules: + - condition: アーキテクチャと設計に問題がない + next: cqrs_es_review + - condition: 軽微な改善が必要だが構造的な問題はない + next: fix_architect + - condition: 構造的な問題があり修正が必要 + next: fix_architect - name: fix_architect agent: ~/.takt/agents/default/coder.md @@ -309,15 +264,6 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -337,15 +283,12 @@ steps: **重要**: Architectのフィードバックに対応してください。 「Original User Request」は参考情報であり、最新の指示ではありません。 セッションの会話履歴を確認し、Architectの指摘事項を修正してください。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Architectの指摘に対する修正が完了した + next: architect_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 3: CQRS+ES Review @@ -359,15 +302,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 設計に問題なし | `[CQRS-ES:APPROVE]` | - | 設計に問題あり | `[CQRS-ES:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -425,15 +359,11 @@ steps: |---|------|------|--------| | 1 | `src/file.ts:42` | 問題の説明 | 修正方法 | ``` - - Include: - - [CQRS-ES:APPROVE] if CQRS+ES design is sound - - [CQRS-ES:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: frontend_review - - condition: rejected - next_step: fix_cqrs_es + rules: + - condition: CQRS+ES設計に問題がない + next: frontend_review + - condition: CQRS+ES設計に問題がある + next: fix_cqrs_es - name: fix_cqrs_es agent: ~/.takt/agents/default/coder.md @@ -446,15 +376,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -479,15 +400,12 @@ steps: - Command/Query分離 - プロジェクション - 結果整合性 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: CQRS+ES専門家の指摘に対する修正が完了した + next: cqrs_es_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 3: Frontend Review @@ -501,15 +419,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | フロントエンド設計に問題なし | `[FRONTEND:APPROVE]` | - | フロントエンド設計に問題あり | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -538,7 +447,7 @@ steps: - TypeScript型安全性 **注意**: このプロジェクトがフロントエンドを含まない場合は、 - [FRONTEND:APPROVE] として次に進んでください。 + 問題なしとして次に進んでください。 **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 @@ -567,15 +476,11 @@ steps: |---|------|------|--------| | 1 | `src/file.tsx:42` | 問題の説明 | 修正方法 | ``` - - Include: - - [FRONTEND:APPROVE] if frontend design is sound - - [FRONTEND:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: fix_frontend + rules: + - condition: フロントエンド設計に問題がない + next: ai_review + - condition: フロントエンド設計に問題がある + next: fix_frontend - name: fix_frontend agent: ~/.takt/agents/default/coder.md @@ -588,15 +493,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -621,15 +517,12 @@ steps: - パフォーマンス - アクセシビリティ - 型安全性 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: frontend_review - - condition: blocked - next_step: plan + rules: + - condition: フロントエンドの指摘に対する修正が完了した + next: frontend_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 4: AI Review @@ -643,15 +536,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | AI特有の問題なし | `[AI_REVIEW:APPROVE]` | - | 問題あり | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -705,15 +589,11 @@ steps: **認知負荷軽減ルール:** - 問題なし → サマリー1文 + チェック表のみ(10行以内) - 問題あり → + 問題を表形式で(25行以内) - - 以下を含めてください: - - [AI_REVIEW:APPROVE] AI特有の問題が見つからない場合 - - [AI_REVIEW:REJECT] 問題が検出された場合(具体的な問題をリスト) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix + rules: + - condition: AI特有の問題が見つからない + next: security_review + - condition: AI特有の問題が検出された + next: ai_fix - name: ai_fix agent: ~/.takt/agents/default/coder.md @@ -726,15 +606,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -757,15 +628,12 @@ steps: - もっともらしいが間違っている実装の修正 - 既存コードベースのパターンとの整合 - スコープクリープの除去 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: ai_review - - condition: blocked - next_step: plan + rules: + - condition: AI Reviewerの指摘に対する修正が完了した + next: ai_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 5: Security Review @@ -779,15 +647,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | セキュリティ問題なし | `[SECURITY:APPROVE]` | - | 脆弱性あり | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -842,15 +701,11 @@ steps: ## 警告(ブロッキングではない) - {セキュリティに関する推奨事項} ``` - - Include: - - [SECURITY:APPROVE] if no security issues found - - [SECURITY:REJECT] if vulnerabilities found (list specific issues with severity) - transitions: - - condition: approved - next_step: qa_review - - condition: rejected - next_step: fix_security + rules: + - condition: セキュリティ上の問題がない + next: qa_review + - condition: セキュリティ上の脆弱性が検出された + next: fix_security - name: fix_security agent: ~/.takt/agents/default/coder.md @@ -863,16 +718,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 軽微な修正完了 | `[CODER:DONE]` | - | 大きな修正(CQRS+ESからやり直し) | `[CODER:REJECT]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -899,22 +744,20 @@ steps: - 暗号化の問題 ## 修正完了時の判断 - 修正が完了したら、**変更の影響範囲**を判断して適切なタグを出力してください: + 修正が完了したら、**変更の影響範囲**を判断してください: - - `[CODER:DONE]` - 軽微な修正(セキュリティレビューのみ再実施) + - 軽微な修正(セキュリティレビューのみ再実施) - 例: バリデーション追加、エスケープ処理追加、設定変更 - - `[CODER:REJECT]` - 大きな修正(CQRS+ESレビューからやり直し) + - 大きな修正(CQRS+ESレビューからやり直し) - 例: データフロー変更、API設計変更、認証方式変更、ドメインモデル変更 - - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: rejected - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: 軽微なセキュリティ修正が完了した + next: security_review + - condition: 大きな修正を行い、CQRS+ESレビューからやり直す必要がある + next: cqrs_es_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 6: QA Review @@ -928,15 +771,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 品質基準を満たす | `[QA:APPROVE]` | - | 品質問題あり | `[QA:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -991,15 +825,11 @@ steps: |---|---------|------|--------| | 1 | テスト | 問題の説明 | 修正方法 | ``` - - Include: - - [QA:APPROVE] if quality standards are met - - [QA:REJECT] if quality issues found (list specific issues) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: fix_qa + rules: + - condition: 品質基準を満たしている + next: supervise + - condition: 品質に問題がある + next: fix_qa - name: fix_qa agent: ~/.takt/agents/default/coder.md @@ -1012,17 +842,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 軽微な修正完了 | `[CODER:DONE]` | - | セキュリティ影響あり | `[CODER:IMPROVE]` | - | 大きな修正(CQRS+ESからやり直し) | `[CODER:REJECT]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -1049,26 +868,24 @@ steps: - コード品質 ## 修正完了時の判断 - 修正が完了したら、**変更の影響範囲**を判断して適切なタグを出力してください: + 修正が完了したら、**変更の影響範囲**を判断してください: - - `[CODER:DONE]` - 軽微な修正(QAレビューのみ再実施) + - 軽微な修正(QAレビューのみ再実施) - 例: テスト追加、ドキュメント追加、ログ追加、コメント追加 - - `[CODER:IMPROVE]` - セキュリティに影響する修正(セキュリティレビューからやり直し) + - セキュリティに影響する修正(セキュリティレビューからやり直し) - 例: エラーハンドリング変更(エラーメッセージの内容変更)、入力検証の変更 - - `[CODER:REJECT]` - 大きな修正(CQRS+ESレビューからやり直し) + - 大きな修正(CQRS+ESレビューからやり直し) - 例: ビジネスロジック変更、データモデル変更、API変更 - - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: qa_review - - condition: improve - next_step: security_review - - condition: rejected - next_step: cqrs_es_review - - condition: blocked - next_step: plan + rules: + - condition: 軽微なQA修正が完了した + next: qa_review + - condition: セキュリティに影響する修正を行った + next: security_review + - condition: 大きな修正を行い、CQRS+ESレビューからやり直す必要がある + next: cqrs_es_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 7: Supervision @@ -1082,15 +899,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 最終承認 | `[SUPERVISOR:APPROVE]` | - | 問題あり | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -1189,15 +997,11 @@ steps: npm run build ``` ``` - - 出力: - - [SUPERVISOR:APPROVE] すべて完了、マージ可能 - - [SUPERVISOR:REJECT] 問題あり(具体的な問題を記載) - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: fix_supervisor + rules: + - condition: すべての検証が完了し、マージ可能な状態である + next: COMPLETE + - condition: 問題が検出された + next: fix_supervisor - name: fix_supervisor agent: ~/.takt/agents/default/coder.md @@ -1210,15 +1014,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -1239,12 +1034,9 @@ steps: 監督者は全体を俯瞰した視点から問題を指摘しています。 優先度の高い項目から順に対応してください。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: plan + rules: + - condition: 監督者の指摘に対する修正が完了した + next: supervise + - condition: 修正を進行できない + next: plan diff --git a/resources/global/ja/workflows/expert.yaml b/resources/global/ja/workflows/expert.yaml index 769ad68..a96f296 100644 --- a/resources/global/ja/workflows/expert.yaml +++ b/resources/global/ja/workflows/expert.yaml @@ -41,15 +41,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 分析完了 | `[PLANNER:DONE]` | - | 要件不明確 | `[PLANNER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -100,15 +91,12 @@ steps: ## 確認事項(あれば) - {不明点や確認が必要な点} ``` - - 完了したら [PLANNER:DONE] を出力。 - 要件が不明確な場合は [PLANNER:BLOCKED] を出力。 pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: blocked - next_step: ABORT + rules: + - condition: タスク分析と計画が完了した + next: implement + - condition: 要件が不明確で計画を立てられない + next: ABORT # =========================================== # Phase 1: Implementation @@ -124,15 +112,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 実装完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -186,20 +165,17 @@ steps: - **検討した選択肢**: {選択肢リスト} - **理由**: {選んだ理由} ``` - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を出力し、planに戻ります。 - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: 実装が完了した + next: architect_review + - condition: 実装を進行できない + next: plan # =========================================== # Phase 2: Architecture Review # =========================================== - name: architect_review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -207,27 +183,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 構造に問題がある | REJECT | - | 設計原則違反がある | REJECT | - | 呼び出しチェーンの配線漏れ | REJECT | - | テストが不十分 | REJECT | - | 改善すべき点がある(軽微) | IMPROVE | - | 問題なし | APPROVE | - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 問題なし | `[ARCHITECT:APPROVE]` | - | 軽微な改善必要 | `[ARCHITECT:IMPROVE]` | - | 構造的な修正必要 | `[ARCHITECT:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -289,13 +244,13 @@ steps: - APPROVE + 問題なし → サマリーのみ(5行以内) - APPROVE + 軽微な提案 → サマリー + 改善提案(15行以内) - REJECT → 問題点を表形式で(30行以内) - transitions: - - condition: approved - next_step: frontend_review - - condition: improve - next_step: fix_architect - - condition: rejected - next_step: fix_architect + rules: + - condition: アーキテクチャと設計に問題がない + next: frontend_review + - condition: 軽微な改善が必要だが構造的な問題はない + next: fix_architect + - condition: 構造的な問題があり修正が必要 + next: fix_architect - name: fix_architect agent: ~/.takt/agents/default/coder.md @@ -309,15 +264,6 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -337,15 +283,12 @@ steps: **重要**: Architectのフィードバックに対応してください。 「Original User Request」は参考情報であり、最新の指示ではありません。 セッションの会話履歴を確認し、Architectの指摘事項を修正してください。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: Architectの指摘に対する修正が完了した + next: architect_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 3: Frontend Review @@ -359,15 +302,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | フロントエンド設計に問題なし | `[FRONTEND:APPROVE]` | - | フロントエンド設計に問題あり | `[FRONTEND:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -396,7 +330,7 @@ steps: - TypeScript型安全性 **注意**: このプロジェクトがフロントエンドを含まない場合は、 - [FRONTEND:APPROVE] として次に進んでください。 + 問題なしとして次に進んでください。 **レポート出力:** 上記の `Report File` に出力してください。 - ファイルが存在しない場合: 新規作成 @@ -425,15 +359,11 @@ steps: |---|------|------|--------| | 1 | `src/file.tsx:42` | 問題の説明 | 修正方法 | ``` - - Include: - - [FRONTEND:APPROVE] if frontend design is sound - - [FRONTEND:REJECT] if design issues found (list specific issues) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: fix_frontend + rules: + - condition: フロントエンド設計に問題がない + next: ai_review + - condition: フロントエンド設計に問題がある + next: fix_frontend - name: fix_frontend agent: ~/.takt/agents/default/coder.md @@ -446,15 +376,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -479,15 +400,12 @@ steps: - パフォーマンス - アクセシビリティ - 型安全性 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: frontend_review - - condition: blocked - next_step: plan + rules: + - condition: フロントエンドの指摘に対する修正が完了した + next: frontend_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 4: AI Review @@ -501,15 +419,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | AI特有の問題なし | `[AI_REVIEW:APPROVE]` | - | 問題あり | `[AI_REVIEW:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -563,15 +472,11 @@ steps: **認知負荷軽減ルール:** - 問題なし → サマリー1文 + チェック表のみ(10行以内) - 問題あり → + 問題を表形式で(25行以内) - - 以下を含めてください: - - [AI_REVIEW:APPROVE] AI特有の問題が見つからない場合 - - [AI_REVIEW:REJECT] 問題が検出された場合(具体的な問題をリスト) - transitions: - - condition: approved - next_step: security_review - - condition: rejected - next_step: ai_fix + rules: + - condition: AI特有の問題が見つからない + next: security_review + - condition: AI特有の問題が検出された + next: ai_fix - name: ai_fix agent: ~/.takt/agents/default/coder.md @@ -584,15 +489,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -615,15 +511,12 @@ steps: - もっともらしいが間違っている実装の修正 - 既存コードベースのパターンとの整合 - スコープクリープの除去 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: ai_review - - condition: blocked - next_step: plan + rules: + - condition: AI Reviewerの指摘に対する修正が完了した + next: ai_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 5: Security Review @@ -637,15 +530,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | セキュリティ問題なし | `[SECURITY:APPROVE]` | - | 脆弱性あり | `[SECURITY:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -700,15 +584,11 @@ steps: ## 警告(ブロッキングではない) - {セキュリティに関する推奨事項} ``` - - Include: - - [SECURITY:APPROVE] if no security issues found - - [SECURITY:REJECT] if vulnerabilities found (list specific issues with severity) - transitions: - - condition: approved - next_step: qa_review - - condition: rejected - next_step: fix_security + rules: + - condition: セキュリティ上の問題がない + next: qa_review + - condition: セキュリティ上の脆弱性が検出された + next: fix_security - name: fix_security agent: ~/.takt/agents/default/coder.md @@ -721,16 +601,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 軽微な修正完了 | `[CODER:DONE]` | - | 大きな修正(アーキテクチャからやり直し) | `[CODER:REJECT]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -757,22 +627,20 @@ steps: - 暗号化の問題 ## 修正完了時の判断 - 修正が完了したら、**変更の影響範囲**を判断して適切なタグを出力してください: + 修正が完了したら、**変更の影響範囲**を判断してください: - - `[CODER:DONE]` - 軽微な修正(セキュリティレビューのみ再実施) + - 軽微な修正(セキュリティレビューのみ再実施) - 例: バリデーション追加、エスケープ処理追加、設定変更 - - `[CODER:REJECT]` - 大きな修正(アーキテクチャレビューからやり直し) + - 大きな修正(アーキテクチャレビューからやり直し) - 例: データフロー変更、API設計変更、認証方式変更、ドメインモデル変更 - - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: security_review - - condition: rejected - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: 軽微なセキュリティ修正が完了した + next: security_review + - condition: 大きな修正を行い、アーキテクチャレビューからやり直す必要がある + next: architect_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 6: QA Review @@ -786,15 +654,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 品質基準を満たす | `[QA:APPROVE]` | - | 品質問題あり | `[QA:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -849,15 +708,11 @@ steps: |---|---------|------|--------| | 1 | テスト | 問題の説明 | 修正方法 | ``` - - Include: - - [QA:APPROVE] if quality standards are met - - [QA:REJECT] if quality issues found (list specific issues) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: fix_qa + rules: + - condition: 品質基準を満たしている + next: supervise + - condition: 品質に問題がある + next: fix_qa - name: fix_qa agent: ~/.takt/agents/default/coder.md @@ -870,17 +725,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 軽微な修正完了 | `[CODER:DONE]` | - | セキュリティ影響あり | `[CODER:IMPROVE]` | - | 大きな修正(アーキテクチャからやり直し) | `[CODER:REJECT]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -907,26 +751,24 @@ steps: - コード品質 ## 修正完了時の判断 - 修正が完了したら、**変更の影響範囲**を判断して適切なタグを出力してください: + 修正が完了したら、**変更の影響範囲**を判断してください: - - `[CODER:DONE]` - 軽微な修正(QAレビューのみ再実施) + - 軽微な修正(QAレビューのみ再実施) - 例: テスト追加、ドキュメント追加、ログ追加、コメント追加 - - `[CODER:IMPROVE]` - セキュリティに影響する修正(セキュリティレビューからやり直し) + - セキュリティに影響する修正(セキュリティレビューからやり直し) - 例: エラーハンドリング変更(エラーメッセージの内容変更)、入力検証の変更 - - `[CODER:REJECT]` - 大きな修正(アーキテクチャレビューからやり直し) + - 大きな修正(アーキテクチャレビューからやり直し) - 例: ビジネスロジック変更、データモデル変更、API変更 - - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: qa_review - - condition: improve - next_step: security_review - - condition: rejected - next_step: architect_review - - condition: blocked - next_step: plan + rules: + - condition: 軽微なQA修正が完了した + next: qa_review + - condition: セキュリティに影響する修正を行った + next: security_review + - condition: 大きな修正を行い、アーキテクチャレビューからやり直す必要がある + next: architect_review + - condition: 修正を進行できない + next: plan # =========================================== # Phase 7: Supervision @@ -940,15 +782,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 最終承認 | `[SUPERVISOR:APPROVE]` | - | 問題あり | `[SUPERVISOR:REJECT]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -1045,15 +878,11 @@ steps: npm run build ``` ``` - - 出力: - - [SUPERVISOR:APPROVE] すべて完了、マージ可能 - - [SUPERVISOR:REJECT] 問題あり(具体的な問題を記載) - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: fix_supervisor + rules: + - condition: すべての検証が完了し、マージ可能な状態である + next: COMPLETE + - condition: 問題が検出された + next: fix_supervisor - name: fix_supervisor agent: ~/.takt/agents/default/coder.md @@ -1066,15 +895,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 修正完了 | `[CODER:DONE]` | - | 進行不可 | `[CODER:BLOCKED]` | instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -1095,12 +915,9 @@ steps: 監督者は全体を俯瞰した視点から問題を指摘しています。 優先度の高い項目から順に対応してください。 - - 完了時は [CODER:DONE] を含めてください。 - 進行できない場合は [CODER:BLOCKED] を含めてください。 pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: plan + rules: + - condition: 監督者の指摘に対する修正が完了した + next: supervise + - condition: 修正を進行できない + next: plan diff --git a/resources/global/ja/workflows/magi.yaml b/resources/global/ja/workflows/magi.yaml index 32c77dc..a85cceb 100644 --- a/resources/global/ja/workflows/magi.yaml +++ b/resources/global/ja/workflows/magi.yaml @@ -26,8 +26,15 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System 起動 + ## 審議事項 + {task} + + ## 指示 + あなたはMAGI System の MELCHIOR-1 です。 + 科学者・技術者の観点から上記を分析し、判定を下してください。 ## 出力フォーマット @@ -44,18 +51,9 @@ steps: 理由: {賛成の理由} ``` - instruction_template: | - # MAGI System 起動 - - ## 審議事項 - {task} - - ## 指示 - あなたはMAGI System の MELCHIOR-1 です。 - 科学者・技術者の観点から上記を分析し、判定を下してください。 - transitions: - - condition: always - next_step: balthasar + rules: + - condition: 判定を完了した + next: balthasar - name: balthasar agent: ~/.takt/agents/magi/balthasar.md @@ -65,8 +63,19 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System 継続 + ## 審議事項 + {task} + + ## MELCHIOR-1 の判定 + {previous_response} + + ## 指示 + あなたはMAGI System の BALTHASAR-2 です。 + 育成者の観点から上記を分析し、判定を下してください。 + MELCHIORの判定は参考にしつつも、独自の観点で判断してください。 ## 出力フォーマット @@ -83,23 +92,10 @@ steps: 理由: {賛成の理由} ``` - instruction_template: | - # MAGI System 継続 - - ## 審議事項 - {task} - - ## MELCHIOR-1 の判定 - {previous_response} - - ## 指示 - あなたはMAGI System の BALTHASAR-2 です。 - 育成者の観点から上記を分析し、判定を下してください。 - MELCHIORの判定は参考にしつつも、独自の観点で判断してください。 pass_previous_response: true - transitions: - - condition: always - next_step: casper + rules: + - condition: 判定を完了した + next: casper - name: casper agent: ~/.takt/agents/magi/casper.md @@ -109,8 +105,20 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | + instruction_template: | + # MAGI System 最終審議 + ## 審議事項 + {task} + + ## これまでの判定 + {previous_response} + + ## 指示 + あなたはMAGI System の CASPER-3 です。 + 実務・現実の観点から上記を分析し、判定を下してください。 + + **最後に、3者の判定を集計し、最終結論を出してください。** ## 出力フォーマット @@ -137,21 +145,7 @@ steps: [理由・まとめ] ``` - instruction_template: | - # MAGI System 最終審議 - - ## 審議事項 - {task} - - ## これまでの判定 - {previous_response} - - ## 指示 - あなたはMAGI System の CASPER-3 です。 - 実務・現実の観点から上記を分析し、判定を下してください。 - - **最後に、3者の判定を集計し、最終結論を出してください。** pass_previous_response: true - transitions: - - condition: always - next_step: COMPLETE + rules: + - condition: 最終判定を完了した + next: COMPLETE diff --git a/resources/global/ja/workflows/research.yaml b/resources/global/ja/workflows/research.yaml index 0f7fce7..85ca432 100644 --- a/resources/global/ja/workflows/research.yaml +++ b/resources/global/ja/workflows/research.yaml @@ -30,30 +30,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 計画完了 | `[PLANNER:DONE]` | - | 情報不足 | `[PLANNER:BLOCKED]` | - - ### 出力例 - - **DONE の場合:** - ``` - [PLANNER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [PLANNER:BLOCKED] - - 確認事項: - - {質問1} - ``` instruction_template: | ## ワークフロー状況 - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) @@ -77,11 +53,11 @@ steps: - 複数の解釈がある場合は、すべてを調査対象に含める - Supervisorからフィードバックがある場合は、指摘を反映した計画を作成 pass_previous_response: true - transitions: - - condition: done - next_step: dig - - condition: blocked - next_step: ABORT + rules: + - condition: 計画が完了した + next: dig + - condition: 情報が不足しており計画を立てられない + next: ABORT - name: dig agent: ~/.takt/agents/research/digger.md @@ -91,29 +67,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 調査完了 | `[DIGGER:DONE]` | - | 調査不可 | `[DIGGER:BLOCKED]` | - - ### 出力例 - - **DONE の場合:** - ``` - [DIGGER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [DIGGER:BLOCKED] - - 理由: {調査できなかった理由} - ``` instruction_template: | ## ワークフロー状況 - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) @@ -142,11 +95,11 @@ steps: - コードベース検索 - ファイル読み取り pass_previous_response: true - transitions: - - condition: done - next_step: supervise - - condition: blocked - next_step: ABORT + rules: + - condition: 調査が完了した + next: supervise + - condition: 調査を実行できない + next: ABORT - name: supervise agent: ~/.takt/agents/research/supervisor.md @@ -156,39 +109,6 @@ steps: - Grep - WebSearch - WebFetch - status_rules_prompt: | - - - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 調査結果が十分 | APPROVE | - | 調査結果が不十分 | REJECT | - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 調査完了、結果は十分 | `[SUPERVISOR:APPROVE]` | - | 不十分、計画からやり直し | `[SUPERVISOR:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [SUPERVISOR:APPROVE] - - 調査結果は元の依頼に対して十分です。 - ``` - - **REJECT の場合:** - ``` - [SUPERVISOR:REJECT] - - 不足点: - - {具体的な不足点} - ``` instruction_template: | ## ワークフロー状況 - イテレーション: {iteration}/{max_iterations}(ワークフロー全体) @@ -206,10 +126,10 @@ steps: **重要**: 問題がある場合は、Plannerへの具体的な指示を含めてください。 pass_previous_response: true - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan + rules: + - condition: 調査結果が元の依頼に対して十分である + next: COMPLETE + - condition: 調査結果が不十分であり、計画からやり直す必要がある + next: plan initial_step: plan diff --git a/resources/global/ja/workflows/simple.yaml b/resources/global/ja/workflows/simple.yaml index 4dfab57..f97f1f4 100644 --- a/resources/global/ja/workflows/simple.yaml +++ b/resources/global/ja/workflows/simple.yaml @@ -30,45 +30,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 要件が明確で実装可能 | DONE | - | ユーザーが質問をしている(実装タスクではない) | ANSWER | - | 要件が不明確、情報不足 | BLOCKED | - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 分析完了 | `[PLANNER:DONE]` | - | 質問への回答 | `[PLANNER:ANSWER]` | - | 情報不足 | `[PLANNER:BLOCKED]` | - - ### 出力例 - - **DONE の場合:** - ``` - [PLANNER:DONE] - ``` - - **ANSWER の場合:** - ``` - {質問への回答} - - [PLANNER:ANSWER] - ``` - - **BLOCKED の場合:** - ``` - [PLANNER:BLOCKED] - - 確認事項: - - {質問1} - - {質問2} - ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -86,11 +47,6 @@ steps: ## Instructions タスクを分析し、実装方針を立ててください。 - **判断基準:** - - ユーザーの入力が実装タスクの場合 → 計画を立てて `[PLANNER:DONE]` - - ユーザーの入力が質問の場合 → 調査・回答して `[PLANNER:ANSWER]` - - 情報不足の場合 → `[PLANNER:BLOCKED]` - **注意:** Previous Responseがある場合は差し戻しのため、 その内容を踏まえて計画を見直してください(replan)。 @@ -125,13 +81,17 @@ steps: - {不明点や確認が必要な点} ``` pass_previous_response: true - transitions: - - condition: done - next_step: implement - - condition: answer - next_step: COMPLETE - - condition: blocked - next_step: ABORT + rules: + - condition: "要件が明確で実装可能" + next: implement + - condition: "ユーザーが質問をしている(実装タスクではない)" + next: COMPLETE + - condition: "要件が不明確、情報不足" + next: ABORT + appendix: | + 確認事項: + - {質問1} + - {質問2} - name: implement agent: ~/.takt/agents/default/coder.md @@ -145,34 +105,6 @@ steps: - WebSearch - WebFetch permission_mode: acceptEdits - status_rules_prompt: | - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 実装完了 | `[CODER:DONE]` | - | 判断できない/情報不足 | `[CODER:BLOCKED]` | - - **重要**: 迷ったら `[BLOCKED]`。勝手に判断しない。 - - ### 出力例 - - **DONE の場合:** - ``` - 実装完了しました。 - - 作成: `src/auth/service.ts`, `tests/auth.test.ts` - - 変更: `src/routes.ts` - - [CODER:DONE] - ``` - - **BLOCKED の場合:** - ``` - [CODER:BLOCKED] - - 理由: DBスキーマが未定義のため実装できません - 必要な情報: usersテーブルの構造 - ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -226,14 +158,14 @@ steps: - **検討した選択肢**: {選択肢リスト} - **理由**: {選んだ理由} ``` - transitions: - - condition: done - next_step: review - - condition: blocked - next_step: plan + rules: + - condition: "実装完了" + next: review + - condition: "判断できない、情報不足" + next: plan - name: review - agent: ~/.takt/agents/default/architect.md + agent: ~/.takt/agents/default/architecture-reviewer.md allowed_tools: - Read - Glob @@ -241,47 +173,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 構造に問題がある | REJECT | - | 設計原則違反がある | REJECT | - | セキュリティ問題がある | REJECT | - | テストが不十分 | REJECT | - | 問題なし | APPROVE | - - **注意:** simpleワークフローでは IMPROVE は使用しません。 - 軽微な問題もある場合は APPROVE + コメントとしてください。 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 問題なし | `[ARCHITECT:APPROVE]` | - | 構造的な修正必要 | `[ARCHITECT:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [ARCHITECT:APPROVE] - - 良い点: - - モジュール分割が適切 - - 単一責務が守られている - ``` - - **REJECT の場合:** - ``` - [ARCHITECT:REJECT] - - 問題点: - 1. ファイルサイズ超過 - - 場所: `src/services/user.ts` (523行) - - 修正案: 3ファイルに分割 - ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -337,11 +228,11 @@ steps: - APPROVE + 問題なし → サマリーのみ(5行以内) - APPROVE + 軽微な提案 → サマリー + 改善提案(15行以内) - REJECT → 問題点を表形式で(30行以内) - transitions: - - condition: approved - next_step: ai_review - - condition: rejected - next_step: plan + rules: + - condition: "問題なし" + next: ai_review + - condition: "構造的な修正必要" + next: plan - name: ai_review agent: ~/.takt/agents/default/ai-antipattern-reviewer.md @@ -352,43 +243,6 @@ steps: - Write - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 仮定が間違っている(動作に影響) | REJECT | - | もっともらしいが間違っているコード | REJECT | - | コードベースの文脈に重大な不整合 | REJECT | - | スコープクリープ | APPROVE(警告を付記) | - | 軽微なスタイルの逸脱のみ | APPROVE | - | コードが文脈に合い動作する | APPROVE | - - **注意:** スコープクリープは警告として記載するが、それだけでREJECTしない。 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | AI特有の問題なし | `[AI_REVIEW:APPROVE]` | - | 問題あり | `[AI_REVIEW:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [AI_REVIEW:APPROVE] - - 検証結果: 問題なし - ``` - - **REJECT の場合:** - ``` - [AI_REVIEW:REJECT] - - 問題点: - 1. 存在しないAPIを使用: `fetch.json()` → `response.json()` - ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -442,11 +296,11 @@ steps: **認知負荷軽減ルール:** - 問題なし → サマリー1文 + チェック表のみ(10行以内) - 問題あり → + 問題を表形式で(25行以内) - transitions: - - condition: approved - next_step: supervise - - condition: rejected - next_step: plan + rules: + - condition: "AI特有の問題なし" + next: supervise + - condition: "AI特有の問題あり" + next: plan - name: supervise agent: ~/.takt/agents/default/supervisor.md @@ -458,46 +312,6 @@ steps: - Bash - WebSearch - WebFetch - status_rules_prompt: | - ## 判定基準 - - | 状況 | 判定 | - |------|------| - | 要求が満たされていない | REJECT | - | テストが失敗する | REJECT | - | ビルドが通らない | REJECT | - | その場しのぎが残っている | REJECT | - | すべて問題なし | APPROVE | - - **原則**: 疑わしきは REJECT。曖昧な承認はしない。 - - ## 出力フォーマット - - | 状況 | タグ | - |------|------| - | 最終承認 | `[SUPERVISOR:APPROVE]` | - | 差し戻し | `[SUPERVISOR:REJECT]` | - - ### 出力例 - - **APPROVE の場合:** - ``` - [SUPERVISOR:APPROVE] - - 検証結果: - - テスト: ✅ 全件パス - - ビルド: ✅ 成功 - - 要求充足: ✅ - ``` - - **REJECT の場合:** - ``` - [SUPERVISOR:REJECT] - - 問題点: - 1. テストが失敗: `npm test` で 2 件失敗 - 2. 元の要求を満たしていない: ログイン機能が未実装 - ``` instruction_template: | ## Workflow Context - Iteration: {iteration}/{max_iterations}(ワークフロー全体) @@ -583,8 +397,8 @@ steps: npm run build ``` ``` - transitions: - - condition: approved - next_step: COMPLETE - - condition: rejected - next_step: plan + rules: + - condition: "すべて問題なし" + next: COMPLETE + - condition: "要求未達成、テスト失敗、ビルドエラー" + next: plan diff --git a/src/__tests__/client.test.ts b/src/__tests__/client.test.ts index 6902ac9..55611e1 100644 --- a/src/__tests__/client.test.ts +++ b/src/__tests__/client.test.ts @@ -4,43 +4,10 @@ import { describe, it, expect } from 'vitest'; import { - detectStatus, + detectRuleIndex, isRegexSafe, - getBuiltinStatusPatterns, } from '../claude/client.js'; -describe('detectStatus', () => { - it('should detect done status', () => { - const content = 'Task completed successfully.\n[CODER:DONE]'; - const patterns = { done: '\\[CODER:DONE\\]' }; - expect(detectStatus(content, patterns)).toBe('done'); - }); - - it('should detect approved status', () => { - const content = 'Code looks good.\n[ARCHITECT:APPROVE]'; - const patterns = { approved: '\\[ARCHITECT:APPROVE\\]' }; - expect(detectStatus(content, patterns)).toBe('approved'); - }); - - it('should return in_progress when no pattern matches', () => { - const content = 'Working on it...'; - const patterns = { done: '\\[DONE\\]' }; - expect(detectStatus(content, patterns)).toBe('in_progress'); - }); - - it('should be case insensitive', () => { - const content = '[coder:done]'; - const patterns = { done: '\\[CODER:DONE\\]' }; - expect(detectStatus(content, patterns)).toBe('done'); - }); - - it('should handle invalid regex gracefully', () => { - const content = 'test'; - const patterns = { done: '[invalid(' }; - expect(detectStatus(content, patterns)).toBe('in_progress'); - }); -}); - describe('isRegexSafe', () => { it('should accept simple patterns', () => { expect(isRegexSafe('\\[DONE\\]')).toBe(true); @@ -60,32 +27,43 @@ describe('isRegexSafe', () => { }); }); -describe('getBuiltinStatusPatterns', () => { - it('should return patterns for coder', () => { - const patterns = getBuiltinStatusPatterns('coder'); - expect(patterns.done).toBeDefined(); - expect(patterns.blocked).toBeDefined(); +describe('detectRuleIndex', () => { + it('should detect [PLAN:1] as index 0', () => { + expect(detectRuleIndex('Analysis complete.\n[PLAN:1]', 'plan')).toBe(0); }); - it('should return patterns for architect', () => { - const patterns = getBuiltinStatusPatterns('architect'); - expect(patterns.approved).toBeDefined(); - expect(patterns.rejected).toBeDefined(); + it('should detect [PLAN:2] as index 1', () => { + expect(detectRuleIndex('Question answered.\n[PLAN:2]', 'plan')).toBe(1); }); - it('should return generic patterns for unknown agent', () => { - // With generic patterns, any agent gets the standard patterns - const patterns = getBuiltinStatusPatterns('unknown'); - expect(patterns.approved).toBeDefined(); - expect(patterns.rejected).toBeDefined(); - expect(patterns.done).toBeDefined(); - expect(patterns.blocked).toBeDefined(); + it('should detect [PLAN:3] as index 2', () => { + expect(detectRuleIndex('[PLAN:3]\n\nBlocked.', 'plan')).toBe(2); }); - it('should detect status using generic patterns for any agent', () => { - // Generic patterns work for any [ROLE:COMMAND] format - const patterns = getBuiltinStatusPatterns('my-custom-agent'); - const content = '[MY_CUSTOM_AGENT:APPROVE]'; - expect(detectStatus(content, patterns)).toBe('approved'); + it('should be case insensitive', () => { + expect(detectRuleIndex('[plan:1]', 'plan')).toBe(0); + expect(detectRuleIndex('[Plan:2]', 'plan')).toBe(1); + }); + + it('should match step name case-insensitively', () => { + expect(detectRuleIndex('[IMPLEMENT:1]', 'implement')).toBe(0); + expect(detectRuleIndex('[REVIEW:2]', 'review')).toBe(1); + }); + + it('should return -1 when no match', () => { + expect(detectRuleIndex('No tags here.', 'plan')).toBe(-1); + }); + + it('should return -1 for [PLAN:0] (invalid)', () => { + expect(detectRuleIndex('[PLAN:0]', 'plan')).toBe(-1); + }); + + it('should return -1 for wrong step name', () => { + expect(detectRuleIndex('[REVIEW:1]', 'plan')).toBe(-1); + }); + + it('should handle step names with hyphens', () => { + expect(detectRuleIndex('[AI_REVIEW:1]', 'ai_review')).toBe(0); + expect(detectRuleIndex('[SECURITY_FIX:2]', 'security_fix')).toBe(1); }); }); diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index 558c9a3..a6f306e 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -65,9 +65,9 @@ steps: - name: step1 agent: coder instruction: "{task}" - transitions: - - condition: done - next_step: COMPLETE + rules: + - condition: Task completed + next: COMPLETE `; writeFileSync(join(workflowsDir, 'test.yaml'), sampleWorkflow); diff --git a/src/__tests__/instructionBuilder.test.ts b/src/__tests__/instructionBuilder.test.ts index b5c906d..ed807f9 100644 --- a/src/__tests__/instructionBuilder.test.ts +++ b/src/__tests__/instructionBuilder.test.ts @@ -8,9 +8,10 @@ import { buildExecutionMetadata, renderExecutionMetadata, renderStatusRulesHeader, + generateStatusRulesFromRules, type InstructionContext, } from '../workflow/instruction-builder.js'; -import type { WorkflowStep } from '../models/types.js'; +import type { WorkflowStep, WorkflowRule } from '../models/types.js'; function createMinimalStep(template: string): WorkflowStep { return { @@ -18,7 +19,6 @@ function createMinimalStep(template: string): WorkflowStep { agent: 'test-agent', agentDisplayName: 'Test Agent', instructionTemplate: template, - transitions: [], passPreviousResponse: false, }; } @@ -237,41 +237,110 @@ describe('instruction-builder', () => { }); }); - describe('status_rules_prompt with header', () => { - it('should prepend status header to status_rules_prompt in Japanese', () => { - const step = createMinimalStep('Do work'); - step.statusRulesPrompt = '## 出力フォーマット\n| 状況 | タグ |'; - const context = createMinimalContext({ language: 'ja' }); + describe('generateStatusRulesFromRules', () => { + const rules: WorkflowRule[] = [ + { condition: '要件が明確で実装可能', next: 'implement' }, + { condition: 'ユーザーが質問をしている', next: 'COMPLETE' }, + { condition: '要件が不明確、情報不足', next: 'ABORT', appendix: '確認事項:\n- {質問1}\n- {質問2}' }, + ]; - const result = buildInstruction(step, context); + it('should generate criteria table with numbered tags (ja)', () => { + const result = generateStatusRulesFromRules('plan', rules, 'ja'); - expect(result).toContain('# ⚠️ 必須: ステータス出力ルール ⚠️'); - expect(result).toContain('## 出力フォーマット'); - // Header should come before the step-specific content - const headerIndex = result.indexOf('⚠️ 必須'); - const formatIndex = result.indexOf('## 出力フォーマット'); - expect(headerIndex).toBeLessThan(formatIndex); + expect(result).toContain('## 判定基準'); + expect(result).toContain('| 1 | 要件が明確で実装可能 | `[PLAN:1]` |'); + expect(result).toContain('| 2 | ユーザーが質問をしている | `[PLAN:2]` |'); + expect(result).toContain('| 3 | 要件が不明確、情報不足 | `[PLAN:3]` |'); }); - it('should prepend status header to status_rules_prompt in English', () => { + it('should generate criteria table with numbered tags (en)', () => { + const enRules: WorkflowRule[] = [ + { condition: 'Requirements are clear', next: 'implement' }, + { condition: 'User is asking a question', next: 'COMPLETE' }, + ]; + const result = generateStatusRulesFromRules('plan', enRules, 'en'); + + expect(result).toContain('## Decision Criteria'); + expect(result).toContain('| 1 | Requirements are clear | `[PLAN:1]` |'); + expect(result).toContain('| 2 | User is asking a question | `[PLAN:2]` |'); + }); + + it('should generate output format section with condition labels', () => { + const result = generateStatusRulesFromRules('plan', rules, 'ja'); + + expect(result).toContain('## 出力フォーマット'); + expect(result).toContain('`[PLAN:1]` — 要件が明確で実装可能'); + expect(result).toContain('`[PLAN:2]` — ユーザーが質問をしている'); + expect(result).toContain('`[PLAN:3]` — 要件が不明確、情報不足'); + }); + + it('should generate appendix template section when rules have appendix', () => { + const result = generateStatusRulesFromRules('plan', rules, 'ja'); + + expect(result).toContain('### 追加出力テンプレート'); + expect(result).toContain('`[PLAN:3]`'); + expect(result).toContain('確認事項:'); + expect(result).toContain('- {質問1}'); + }); + + it('should not generate appendix section when no rules have appendix', () => { + const noAppendixRules: WorkflowRule[] = [ + { condition: 'Done', next: 'review' }, + { condition: 'Blocked', next: 'plan' }, + ]; + const result = generateStatusRulesFromRules('implement', noAppendixRules, 'en'); + + expect(result).not.toContain('Appendix Template'); + }); + + it('should uppercase step name in tags', () => { + const result = generateStatusRulesFromRules('ai_review', [ + { condition: 'No issues', next: 'supervise' }, + ], 'en'); + + expect(result).toContain('`[AI_REVIEW:1]`'); + }); + }); + + describe('buildInstruction with rules', () => { + it('should auto-generate status rules from rules', () => { const step = createMinimalStep('Do work'); - step.statusRulesPrompt = '## Output Format\n| Situation | Tag |'; + step.name = 'plan'; + step.rules = [ + { condition: 'Clear requirements', next: 'implement' }, + { condition: 'Unclear', next: 'ABORT' }, + ]; const context = createMinimalContext({ language: 'en' }); const result = buildInstruction(step, context); - expect(result).toContain('# ⚠️ Required: Status Output Rules ⚠️'); - expect(result).toContain('## Output Format'); + // Should contain status header + expect(result).toContain('⚠️ Required: Status Output Rules ⚠️'); + // Should contain auto-generated criteria table + expect(result).toContain('## Decision Criteria'); + expect(result).toContain('`[PLAN:1]`'); + expect(result).toContain('`[PLAN:2]`'); }); - it('should not add header if statusRulesPrompt is not set', () => { + it('should not add status rules when rules do not exist', () => { const step = createMinimalStep('Do work'); const context = createMinimalContext({ language: 'en' }); const result = buildInstruction(step, context); expect(result).not.toContain('⚠️ Required'); - expect(result).not.toContain('⚠️ 必須'); + expect(result).not.toContain('Decision Criteria'); + }); + + it('should not auto-generate when rules array is empty', () => { + const step = createMinimalStep('Do work'); + step.rules = []; + const context = createMinimalContext({ language: 'en' }); + + const result = buildInstruction(step, context); + + expect(result).not.toContain('⚠️ Required'); + expect(result).not.toContain('Decision Criteria'); }); }); diff --git a/src/__tests__/models.test.ts b/src/__tests__/models.test.ts index f470c83..dcd9ef5 100644 --- a/src/__tests__/models.test.ts +++ b/src/__tests__/models.test.ts @@ -6,12 +6,10 @@ import { describe, it, expect } from 'vitest'; import { AgentTypeSchema, StatusSchema, - TransitionConditionSchema, PermissionModeSchema, WorkflowConfigRawSchema, CustomAgentConfigSchema, GlobalConfigSchema, - GENERIC_STATUS_PATTERNS, } from '../models/schemas.js'; describe('AgentTypeSchema', () => { @@ -43,21 +41,6 @@ describe('StatusSchema', () => { }); }); -describe('TransitionConditionSchema', () => { - it('should accept valid conditions', () => { - expect(TransitionConditionSchema.parse('done')).toBe('done'); - expect(TransitionConditionSchema.parse('approved')).toBe('approved'); - expect(TransitionConditionSchema.parse('rejected')).toBe('rejected'); - expect(TransitionConditionSchema.parse('always')).toBe('always'); - expect(TransitionConditionSchema.parse('answer')).toBe('answer'); - }); - - it('should reject invalid conditions', () => { - expect(() => TransitionConditionSchema.parse('conditional')).toThrow(); - expect(() => TransitionConditionSchema.parse('fixed')).toThrow(); - }); -}); - describe('PermissionModeSchema', () => { it('should accept valid permission modes', () => { expect(PermissionModeSchema.parse('default')).toBe('default'); @@ -82,8 +65,8 @@ describe('WorkflowConfigRawSchema', () => { agent: 'coder', allowed_tools: ['Read', 'Grep'], instruction: '{task}', - transitions: [ - { condition: 'done', next_step: 'COMPLETE' }, + rules: [ + { condition: 'Task completed', next: 'COMPLETE' }, ], }, ], @@ -106,8 +89,8 @@ describe('WorkflowConfigRawSchema', () => { allowed_tools: ['Read', 'Edit', 'Write', 'Bash'], permission_mode: 'acceptEdits', instruction: '{task}', - transitions: [ - { condition: 'done', next_step: 'COMPLETE' }, + rules: [ + { condition: 'Done', next: 'COMPLETE' }, ], }, ], @@ -125,7 +108,6 @@ describe('WorkflowConfigRawSchema', () => { name: 'plan', agent: 'planner', instruction: '{task}', - transitions: [], }, ], }; @@ -143,7 +125,6 @@ describe('WorkflowConfigRawSchema', () => { agent: 'coder', permission_mode: 'superAdmin', instruction: '{task}', - transitions: [], }, ], }; @@ -235,31 +216,3 @@ describe('GlobalConfigSchema', () => { expect(result.log_level).toBe('debug'); }); }); - -describe('GENERIC_STATUS_PATTERNS', () => { - it('should have all standard status patterns', () => { - expect(GENERIC_STATUS_PATTERNS.approved).toBeDefined(); - expect(GENERIC_STATUS_PATTERNS.rejected).toBeDefined(); - expect(GENERIC_STATUS_PATTERNS.done).toBeDefined(); - expect(GENERIC_STATUS_PATTERNS.blocked).toBeDefined(); - expect(GENERIC_STATUS_PATTERNS.improve).toBeDefined(); - expect(GENERIC_STATUS_PATTERNS.answer).toBeDefined(); - }); - - it('should have valid regex patterns', () => { - for (const pattern of Object.values(GENERIC_STATUS_PATTERNS)) { - expect(() => new RegExp(pattern)).not.toThrow(); - } - }); - - it('should match any [ROLE:COMMAND] format', () => { - // Generic patterns match any role - expect(new RegExp(GENERIC_STATUS_PATTERNS.approved).test('[CODER:APPROVE]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.approved).test('[MY_AGENT:APPROVE]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.done).test('[CUSTOM:DONE]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.done).test('[CODER:FIXED]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.improve).test('[MAGI:IMPROVE]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.answer).test('[PLANNER:ANSWER]')).toBe(true); - expect(new RegExp(GENERIC_STATUS_PATTERNS.answer).test('[MY_AGENT:ANSWER]')).toBe(true); - }); -}); diff --git a/src/__tests__/transitions.test.ts b/src/__tests__/transitions.test.ts new file mode 100644 index 0000000..fcc8890 --- /dev/null +++ b/src/__tests__/transitions.test.ts @@ -0,0 +1,63 @@ +/** + * Tests for workflow transitions module + */ + +import { describe, it, expect } from 'vitest'; +import { determineNextStepByRules } from '../workflow/transitions.js'; +import type { WorkflowStep } from '../models/types.js'; + +function createStepWithRules(rules: { condition: string; next: string }[]): WorkflowStep { + return { + name: 'test-step', + agent: 'test-agent', + agentDisplayName: 'Test Agent', + instructionTemplate: '{task}', + passPreviousResponse: false, + rules: rules.map((r) => ({ + condition: r.condition, + next: r.next, + })), + }; +} + +describe('determineNextStepByRules', () => { + it('should return next step for valid rule index', () => { + const step = createStepWithRules([ + { condition: 'Clear', next: 'implement' }, + { condition: 'Blocked', next: 'ABORT' }, + ]); + + expect(determineNextStepByRules(step, 0)).toBe('implement'); + expect(determineNextStepByRules(step, 1)).toBe('ABORT'); + }); + + it('should return null for out-of-bounds index', () => { + const step = createStepWithRules([ + { condition: 'Clear', next: 'implement' }, + ]); + + expect(determineNextStepByRules(step, 1)).toBeNull(); + expect(determineNextStepByRules(step, -1)).toBeNull(); + expect(determineNextStepByRules(step, 100)).toBeNull(); + }); + + it('should return null when step has no rules', () => { + const step: WorkflowStep = { + name: 'test-step', + agent: 'test-agent', + agentDisplayName: 'Test Agent', + instructionTemplate: '{task}', + passPreviousResponse: false, + }; + + expect(determineNextStepByRules(step, 0)).toBeNull(); + }); + + it('should handle COMPLETE as next step', () => { + const step = createStepWithRules([ + { condition: 'All passed', next: 'COMPLETE' }, + ]); + + expect(determineNextStepByRules(step, 0)).toBe('COMPLETE'); + }); +}); diff --git a/src/agents/runner.ts b/src/agents/runner.ts index c2bcd34..d0b416d 100644 --- a/src/agents/runner.ts +++ b/src/agents/runner.ts @@ -32,8 +32,6 @@ export interface RunAgentOptions { agentPath?: string; /** Allowed tools for this agent run */ allowedTools?: string[]; - /** Status output rules to inject into system prompt */ - statusRulesPrompt?: string; /** Permission mode for tool execution (from workflow step) */ permissionMode?: PermissionMode; onStream?: StreamCallback; @@ -134,12 +132,7 @@ export async function runCustomAgent( } // Custom agent with prompt - let systemPrompt = loadAgentPrompt(agentConfig); - - // Inject status rules if provided - if (options.statusRulesPrompt) { - systemPrompt = `${systemPrompt}\n\n${options.statusRulesPrompt}`; - } + const systemPrompt = loadAgentPrompt(agentConfig); const providerType = resolveProvider(options.cwd, options, agentConfig); const provider = getProvider(providerType); @@ -149,7 +142,6 @@ export async function runCustomAgent( sessionId: options.sessionId, allowedTools, model: resolveModel(options.cwd, options, agentConfig), - statusPatterns: agentConfig.statusPatterns, permissionMode: options.permissionMode, onStream: options.onStream, onPermissionRequest: options.onPermissionRequest, @@ -217,12 +209,7 @@ export async function runAgent( if (!existsSync(options.agentPath)) { throw new Error(`Agent file not found: ${options.agentPath}`); } - let systemPrompt = loadAgentPromptFromPath(options.agentPath); - - // Inject status rules if provided - if (options.statusRulesPrompt) { - systemPrompt = `${systemPrompt}\n\n${options.statusRulesPrompt}`; - } + const systemPrompt = loadAgentPromptFromPath(options.agentPath); const providerType = resolveProvider(options.cwd, options); const provider = getProvider(providerType); diff --git a/src/claude/client.ts b/src/claude/client.ts index c6f9de7..75849f3 100644 --- a/src/claude/client.ts +++ b/src/claude/client.ts @@ -7,7 +7,6 @@ import { executeClaudeCli, type ClaudeSpawnOptions, type StreamCallback, type PermissionHandler, type AskUserQuestionHandler } from './process.js'; import type { AgentDefinition } from '@anthropic-ai/claude-agent-sdk'; import type { AgentResponse, Status, PermissionMode } from '../models/types.js'; -import { GENERIC_STATUS_PATTERNS } from '../models/schemas.js'; import { createLogger } from '../utils/debug.js'; const log = createLogger('client'); @@ -20,7 +19,6 @@ export interface ClaudeCallOptions { model?: string; maxTurns?: number; systemPrompt?: string; - statusPatterns?: Record; /** SDK agents to register for sub-agent execution */ agents?: Record; /** Permission mode for tool execution (from workflow step) */ @@ -35,22 +33,21 @@ export interface ClaudeCallOptions { bypassPermissions?: boolean; } -/** Detect status from agent output content */ -export function detectStatus( - content: string, - patterns: Record -): Status { - for (const [status, pattern] of Object.entries(patterns)) { - try { - const regex = new RegExp(pattern, 'i'); - if (regex.test(content)) { - return status as Status; - } - } catch { - // Invalid regex, skip - } +/** + * Detect rule index from numbered tag pattern [STEP_NAME:N]. + * Returns 0-based rule index, or -1 if no match. + * + * Example: detectRuleIndex("... [PLAN:2] ...", "plan") → 1 + */ +export function detectRuleIndex(content: string, stepName: string): number { + const tag = stepName.toUpperCase(); + const regex = new RegExp(`\\[${tag}:(\\d+)\\]`, 'i'); + const match = content.match(regex); + if (match?.[1]) { + const index = Number.parseInt(match[1], 10) - 1; + return index >= 0 ? index : -1; } - return 'in_progress'; + return -1; } /** Validate regex pattern for ReDoS safety */ @@ -79,28 +76,17 @@ export function isRegexSafe(pattern: string): boolean { return true; } -/** Get status patterns for a built-in agent type */ -export function getBuiltinStatusPatterns(_agentType: string): Record { - // Uses generic patterns that work for any agent - return GENERIC_STATUS_PATTERNS; -} - /** Determine status from result */ function determineStatus( result: { success: boolean; interrupted?: boolean; content: string; fullContent?: string }, - patterns: Record ): Status { if (!result.success) { - // Check if it was an interrupt using the flag (not magic string) if (result.interrupted) { return 'interrupted'; } return 'blocked'; } - // Use fullContent for status detection (contains all assistant messages) - // Fall back to content if fullContent is not available - const textForStatusDetection = result.fullContent || result.content; - return detectStatus(textForStatusDetection, patterns); + return 'done'; } /** Call Claude with an agent prompt */ @@ -125,8 +111,7 @@ export async function callClaude( }; const result = await executeClaudeCli(prompt, spawnOptions); - const patterns = options.statusPatterns || getBuiltinStatusPatterns(agentType); - const status = determineStatus(result, patterns); + const status = determineStatus(result); if (!result.success && result.error) { log.error('Agent query failed', { agent: agentType, error: result.error }); @@ -164,9 +149,7 @@ export async function callClaudeCustom( }; const result = await executeClaudeCli(prompt, spawnOptions); - // Use provided patterns, or fall back to built-in patterns for known agents - const patterns = options.statusPatterns || getBuiltinStatusPatterns(agentName); - const status = determineStatus(result, patterns); + const status = determineStatus(result); if (!result.success && result.error) { log.error('Agent query failed', { agent: agentName, error: result.error }); diff --git a/src/claude/index.ts b/src/claude/index.ts index 83be70e..bfafe55 100644 --- a/src/claude/index.ts +++ b/src/claude/index.ts @@ -57,8 +57,7 @@ export { callClaudeCustom, callClaudeAgent, callClaudeSkill, - detectStatus, + detectRuleIndex, isRegexSafe, - getBuiltinStatusPatterns, type ClaudeCallOptions, } from './client.js'; diff --git a/src/codex/client.ts b/src/codex/client.ts index 8412904..9ae70aa 100644 --- a/src/codex/client.ts +++ b/src/codex/client.ts @@ -6,8 +6,6 @@ import { Codex } from '@openai/codex-sdk'; import type { AgentResponse, Status } from '../models/types.js'; -import { GENERIC_STATUS_PATTERNS } from '../models/schemas.js'; -import { detectStatus } from '../claude/client.js'; import type { StreamCallback } from '../claude/process.js'; import { createLogger } from '../utils/debug.js'; @@ -19,7 +17,6 @@ export interface CodexCallOptions { sessionId?: string; model?: string; systemPrompt?: string; - statusPatterns?: Record; /** Enable streaming mode with callback (best-effort) */ onStream?: StreamCallback; } @@ -101,8 +98,8 @@ function emitResult( }); } -function determineStatus(content: string, patterns: Record): Status { - return detectStatus(content, patterns); +function determineStatus(success: boolean): Status { + return success ? 'done' : 'blocked'; } type CodexEvent = { @@ -476,8 +473,7 @@ export async function callCodex( const trimmed = content.trim(); emitResult(options.onStream, true, trimmed, threadId); - const patterns = options.statusPatterns || GENERIC_STATUS_PATTERNS; - const status = determineStatus(trimmed, patterns); + const status = determineStatus(true); return { agent: agentType, diff --git a/src/commands/workflowExecution.ts b/src/commands/workflowExecution.ts index b5707e7..85879ef 100644 --- a/src/commands/workflowExecution.ts +++ b/src/commands/workflowExecution.ts @@ -184,10 +184,11 @@ export async function executeWorkflow( displayRef.current = new StreamDisplay(step.agentDisplayName); }); - engine.on('step:complete', (step, response) => { + engine.on('step:complete', (step, response, instruction) => { log.debug('Step completed', { step: step.name, status: response.status, + matchedRuleIndex: response.matchedRuleIndex, contentLength: response.content.length, sessionId: response.sessionId, error: response.error, @@ -197,14 +198,25 @@ export async function executeWorkflow( displayRef.current = null; } console.log(); - status('Status', response.status); + + if (response.matchedRuleIndex != null && step.rules) { + const rule = step.rules[response.matchedRuleIndex]; + if (rule) { + status('Status', rule.condition); + } else { + status('Status', response.status); + } + } else { + status('Status', response.status); + } + if (response.error) { error(`Error: ${response.error}`); } if (response.sessionId) { status('Session', response.sessionId); } - addToSessionLog(sessionLog, step.name, response); + addToSessionLog(sessionLog, step.name, response, instruction); // Incremental save after each step saveSessionLog(sessionLog, workflowSessionId, projectCwd); diff --git a/src/config/workflowLoader.ts b/src/config/workflowLoader.ts index adc6f0d..794ddc5 100644 --- a/src/config/workflowLoader.ts +++ b/src/config/workflowLoader.ts @@ -8,7 +8,7 @@ import { readFileSync, existsSync, readdirSync, statSync } from 'node:fs'; import { join, dirname, basename } from 'node:path'; import { parse as parseYaml } from 'yaml'; import { WorkflowConfigRawSchema } from '../models/schemas.js'; -import type { WorkflowConfig, WorkflowStep } from '../models/types.js'; +import type { WorkflowConfig, WorkflowStep, WorkflowRule } from '../models/types.js'; import { getGlobalWorkflowsDir } from './paths.js'; /** Get builtin workflow by name */ @@ -61,24 +61,27 @@ function extractAgentDisplayName(agentPath: string): string { function normalizeWorkflowConfig(raw: unknown, workflowDir: string): WorkflowConfig { const parsed = WorkflowConfigRawSchema.parse(raw); - const steps: WorkflowStep[] = parsed.steps.map((step) => ({ - name: step.name, - agent: step.agent, - agentDisplayName: step.agent_name || extractAgentDisplayName(step.agent), - agentPath: resolveAgentPathForWorkflow(step.agent, workflowDir), - allowedTools: step.allowed_tools, - provider: step.provider, - model: step.model, - permissionMode: step.permission_mode, - instructionTemplate: step.instruction_template || step.instruction || '{task}', - statusRulesPrompt: step.status_rules_prompt, - transitions: step.transitions.map((t) => ({ - condition: t.condition, - nextStep: t.next_step, - })), - passPreviousResponse: step.pass_previous_response, - onNoStatus: step.on_no_status, - })); + const steps: WorkflowStep[] = parsed.steps.map((step) => { + const rules: WorkflowRule[] | undefined = step.rules?.map((r) => ({ + condition: r.condition, + next: r.next, + appendix: r.appendix, + })); + + return { + name: step.name, + agent: step.agent, + agentDisplayName: step.agent_name || extractAgentDisplayName(step.agent), + agentPath: resolveAgentPathForWorkflow(step.agent, workflowDir), + allowedTools: step.allowed_tools, + provider: step.provider, + model: step.model, + permissionMode: step.permission_mode, + instructionTemplate: step.instruction_template || step.instruction || '{task}', + rules, + passPreviousResponse: step.pass_previous_response, + }; + }); return { name: parsed.name, diff --git a/src/models/index.ts b/src/models/index.ts index 430d792..b274533 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -2,10 +2,8 @@ export type { AgentType, Status, - TransitionCondition, AgentResponse, SessionState, - WorkflowTransition, WorkflowStep, WorkflowConfig, WorkflowState, diff --git a/src/models/schemas.ts b/src/models/schemas.ts index e0379f1..05dee5f 100644 --- a/src/models/schemas.ts +++ b/src/models/schemas.ts @@ -24,41 +24,19 @@ export const StatusSchema = z.enum([ 'answer', ]); -/** - * Transition condition schema - * - * WARNING: Do NOT add new values carelessly. - * Use existing values creatively in workflow design: - * - done: Task completed (minor fixes, successful completion) - * - blocked: Cannot proceed (needs plan rework) - * - approved: Review passed - * - rejected: Review failed, needs major rework - * - improve: Needs improvement (security concerns, quality issues) - * - answer: Question answered (complete workflow as success) - * - always: Unconditional transition - */ -export const TransitionConditionSchema = z.enum([ - 'done', - 'blocked', - 'approved', - 'rejected', - 'improve', - 'answer', - 'always', -]); - -/** On no status behavior schema */ -export const OnNoStatusBehaviorSchema = z.enum(['complete', 'continue', 'stay']); - -/** Workflow transition schema */ -export const WorkflowTransitionSchema = z.object({ - condition: TransitionConditionSchema, - nextStep: z.string().min(1), -}); - /** Permission mode schema for tool execution */ export const PermissionModeSchema = z.enum(['default', 'acceptEdits', 'bypassPermissions']); +/** Rule-based transition schema (new unified format) */ +export const WorkflowRuleSchema = z.object({ + /** Human-readable condition text */ + condition: z.string().min(1), + /** Next step name (e.g., implement, COMPLETE, ABORT) */ + next: z.string().min(1), + /** Template for additional AI output */ + appendix: z.string().optional(), +}); + /** Workflow step schema - raw YAML format */ export const WorkflowStepRawSchema = z.object({ name: z.string().min(1), @@ -72,15 +50,9 @@ export const WorkflowStepRawSchema = z.object({ permission_mode: PermissionModeSchema.optional(), instruction: z.string().optional(), instruction_template: z.string().optional(), - status_rules_prompt: z.string().optional(), + /** Rules for step routing */ + rules: z.array(WorkflowRuleSchema).optional(), pass_previous_response: z.boolean().optional().default(true), - on_no_status: OnNoStatusBehaviorSchema.optional(), - transitions: z.array( - z.object({ - condition: TransitionConditionSchema, - next_step: z.string().min(1), - }) - ).optional().default([]), }); /** Workflow configuration schema - raw YAML format */ @@ -99,7 +71,6 @@ export const CustomAgentConfigSchema = z.object({ prompt_file: z.string().optional(), prompt: z.string().optional(), allowed_tools: z.array(z.string()).optional(), - status_patterns: z.record(z.string(), z.string()).optional(), claude_agent: z.string().optional(), claude_skill: z.string().optional(), provider: z.enum(['claude', 'codex', 'mock']).optional(), @@ -138,18 +109,3 @@ export const ProjectConfigSchema = z.object({ provider: z.enum(['claude', 'codex', 'mock']).optional(), }); -/** - * Generic status patterns that match any role name - * Format: [ROLE:COMMAND] where ROLE is any word characters - * - * This allows new agents to be added without modifying this file. - * Custom agents can override these patterns in their configuration. - */ -export const GENERIC_STATUS_PATTERNS: Record = { - approved: '\\[[\\w-]+:APPROVE\\]', - rejected: '\\[[\\w-]+:REJECT\\]', - improve: '\\[[\\w-]+:IMPROVE\\]', - done: '\\[[\\w-]+:(DONE|FIXED)\\]', - blocked: '\\[[\\w-]+:BLOCKED\\]', - answer: '\\[[\\w-]+:ANSWER\\]', -}; diff --git a/src/models/types.ts b/src/models/types.ts index 53ffe30..8bfc374 100644 --- a/src/models/types.ts +++ b/src/models/types.ts @@ -18,16 +18,6 @@ export type Status = | 'interrupted' | 'answer'; -/** Condition types for workflow transitions */ -export type TransitionCondition = - | 'done' - | 'blocked' - | 'approved' - | 'rejected' - | 'improve' - | 'answer' - | 'always'; - /** Response from an agent execution */ export interface AgentResponse { agent: string; @@ -37,6 +27,8 @@ export interface AgentResponse { sessionId?: string; /** Error message when the query failed (e.g., API error, rate limit) */ error?: string; + /** Matched rule index (0-based) when rules-based detection was used */ + matchedRuleIndex?: number; } /** Session state for workflow execution */ @@ -48,15 +40,16 @@ export interface SessionState { context: Record; } -/** Workflow step transition configuration */ -export interface WorkflowTransition { - condition: TransitionCondition; - nextStep: string; +/** Rule-based transition configuration (new unified format) */ +export interface WorkflowRule { + /** Human-readable condition text */ + condition: string; + /** Next step name (e.g., implement, COMPLETE, ABORT) */ + next: string; + /** Template for additional AI output */ + appendix?: string; } -/** Behavior when no status marker is found in agent output */ -export type OnNoStatusBehavior = 'complete' | 'continue' | 'stay'; - /** Permission mode for tool execution */ export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions'; @@ -78,17 +71,9 @@ export interface WorkflowStep { /** Permission mode for tool execution in this step */ permissionMode?: PermissionMode; instructionTemplate: string; - /** Status output rules to be injected into system prompt */ - statusRulesPrompt?: string; - transitions: WorkflowTransition[]; + /** Rules for step routing */ + rules?: WorkflowRule[]; passPreviousResponse: boolean; - /** - * Behavior when agent doesn't output a status marker (in_progress). - * - 'complete': Treat as done, follow done/always transition or complete workflow (default) - * - 'continue': Treat as done, follow done/always transition or move to next step - * - 'stay': Stay on current step (may cause loops, use with caution) - */ - onNoStatus?: OnNoStatusBehavior; } /** Loop detection configuration */ @@ -135,7 +120,6 @@ export interface CustomAgentConfig { promptFile?: string; prompt?: string; allowedTools?: string[]; - statusPatterns?: Record; claudeAgent?: string; claudeSkill?: string; provider?: 'claude' | 'codex' | 'mock'; diff --git a/src/providers/claude.ts b/src/providers/claude.ts index e5fdc4d..e60ef74 100644 --- a/src/providers/claude.ts +++ b/src/providers/claude.ts @@ -15,7 +15,6 @@ export class ClaudeProvider implements Provider { allowedTools: options.allowedTools, model: options.model, systemPrompt: options.systemPrompt, - statusPatterns: options.statusPatterns, permissionMode: options.permissionMode, onStream: options.onStream, onPermissionRequest: options.onPermissionRequest, @@ -32,7 +31,6 @@ export class ClaudeProvider implements Provider { sessionId: options.sessionId, allowedTools: options.allowedTools, model: options.model, - statusPatterns: options.statusPatterns, permissionMode: options.permissionMode, onStream: options.onStream, onPermissionRequest: options.onPermissionRequest, diff --git a/src/providers/codex.ts b/src/providers/codex.ts index 408956f..119fb99 100644 --- a/src/providers/codex.ts +++ b/src/providers/codex.ts @@ -14,7 +14,6 @@ export class CodexProvider implements Provider { sessionId: options.sessionId, model: options.model, systemPrompt: options.systemPrompt, - statusPatterns: options.statusPatterns, onStream: options.onStream, }; @@ -26,7 +25,6 @@ export class CodexProvider implements Provider { cwd: options.cwd, sessionId: options.sessionId, model: options.model, - statusPatterns: options.statusPatterns, onStream: options.onStream, }; diff --git a/src/providers/index.ts b/src/providers/index.ts index 56c31ec..c8d9c7f 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -18,7 +18,6 @@ export interface ProviderCallOptions { model?: string; systemPrompt?: string; allowedTools?: string[]; - statusPatterns?: Record; /** Permission mode for tool execution (from workflow step) */ permissionMode?: PermissionMode; onStream?: StreamCallback; diff --git a/src/utils/session.ts b/src/utils/session.ts index 27d5b6b..fa88f27 100644 --- a/src/utils/session.ts +++ b/src/utils/session.ts @@ -19,6 +19,7 @@ export interface SessionLog { history: Array<{ step: string; agent: string; + instruction: string; status: string; timestamp: string; content: string; @@ -76,11 +77,13 @@ export function createSessionLog( export function addToSessionLog( log: SessionLog, stepName: string, - response: AgentResponse + response: AgentResponse, + instruction: string ): void { log.history.push({ step: stepName, agent: response.agent, + instruction, status: response.status, timestamp: response.timestamp.toISOString(), content: response.content, @@ -214,6 +217,7 @@ export function workflowStateToSessionLog( log.history.push({ step: stepName, agent: response.agent, + instruction: '', status: response.status, timestamp: response.timestamp.toISOString(), content: response.content, diff --git a/src/workflow/engine.ts b/src/workflow/engine.ts index ae61595..7cd8d4a 100644 --- a/src/workflow/engine.ts +++ b/src/workflow/engine.ts @@ -14,7 +14,8 @@ import type { import { runAgent, type RunAgentOptions } from '../agents/runner.js'; import { COMPLETE_STEP, ABORT_STEP, ERROR_MESSAGES } from './constants.js'; import type { WorkflowEngineOptions } from './types.js'; -import { determineNextStep } from './transitions.js'; +import { determineNextStepByRules } from './transitions.js'; +import { detectRuleIndex } from '../claude/client.js'; import { buildInstruction as buildInstructionFromTemplate } from './instruction-builder.js'; import { LoopDetector } from './loop-detector.js'; import { handleBlocked } from './blocked-handler.js'; @@ -105,11 +106,13 @@ export class WorkflowEngine extends EventEmitter { stepNames.add(ABORT_STEP); for (const step of this.config.steps) { - for (const transition of step.transitions) { - if (!stepNames.has(transition.nextStep)) { - throw new Error( - `Invalid transition in step "${step.name}": target step "${transition.nextStep}" does not exist` - ); + if (step.rules) { + for (const rule of step.rules) { + if (!stepNames.has(rule.next)) { + throw new Error( + `Invalid rule in step "${step.name}": target step "${rule.next}" does not exist` + ); + } } } } @@ -166,8 +169,7 @@ export class WorkflowEngine extends EventEmitter { } /** Run a single step */ - private async runStep(step: WorkflowStep): Promise { - // Increment step iteration counter before building instruction + private async runStep(step: WorkflowStep): Promise<{ response: AgentResponse; instruction: string }> { const stepIteration = incrementStepIteration(this.state, step.name); const instruction = this.buildInstruction(step, stepIteration); const sessionId = this.state.agentSessions.get(step.agent); @@ -184,7 +186,6 @@ export class WorkflowEngine extends EventEmitter { sessionId, agentPath: step.agentPath, allowedTools: step.allowedTools, - statusRulesPrompt: step.statusRulesPrompt, provider: step.provider, model: step.model, permissionMode: step.permissionMode, @@ -194,7 +195,7 @@ export class WorkflowEngine extends EventEmitter { bypassPermissions: this.options.bypassPermissions, }; - const response = await runAgent(step.agent, instruction, agentOptions); + let response = await runAgent(step.agent, instruction, agentOptions); if (response.sessionId) { const previousSessionId = this.state.agentSessions.get(step.agent); @@ -205,8 +206,29 @@ export class WorkflowEngine extends EventEmitter { } } + if (step.rules && step.rules.length > 0) { + const ruleIndex = detectRuleIndex(response.content, step.name); + if (ruleIndex >= 0 && ruleIndex < step.rules.length) { + response = { ...response, matchedRuleIndex: ruleIndex }; + } + } + this.state.stepOutputs.set(step.name, response); - return response; + return { response, instruction }; + } + + /** + * Determine next step for a completed step using rules-based routing. + */ + private resolveNextStep(step: WorkflowStep, response: AgentResponse): string { + if (response.matchedRuleIndex != null && step.rules) { + const nextByRules = determineNextStepByRules(step, response.matchedRuleIndex); + if (nextByRules) { + return nextByRules; + } + } + + throw new Error(`No matching rule found for step "${step.name}" (status: ${response.status})`); } /** Run the workflow to completion */ @@ -253,8 +275,8 @@ export class WorkflowEngine extends EventEmitter { this.emit('step:start', step, this.state.iteration); try { - const response = await this.runStep(step); - this.emit('step:complete', step, response); + const { response, instruction } = await this.runStep(step); + this.emit('step:complete', step, response, instruction); if (response.status === 'blocked') { this.emit('step:blocked', step, response); @@ -271,10 +293,11 @@ export class WorkflowEngine extends EventEmitter { break; } - const nextStep = determineNextStep(step, response.status, this.config); + const nextStep = this.resolveNextStep(step, response); log.debug('Step transition', { from: step.name, status: response.status, + matchedRuleIndex: response.matchedRuleIndex, nextStep, }); @@ -328,8 +351,8 @@ export class WorkflowEngine extends EventEmitter { } this.state.iteration++; - const response = await this.runStep(step); - const nextStep = determineNextStep(step, response.status, this.config); + const { response } = await this.runStep(step); + const nextStep = this.resolveNextStep(step, response); const isComplete = nextStep === COMPLETE_STEP || nextStep === ABORT_STEP; if (!isComplete) { diff --git a/src/workflow/index.ts b/src/workflow/index.ts index 92fc6ab..b66cfb8 100644 --- a/src/workflow/index.ts +++ b/src/workflow/index.ts @@ -23,7 +23,7 @@ export type { } from './types.js'; // Transitions -export { determineNextStep, matchesCondition, extractBlockedPrompt } from './transitions.js'; +export { determineNextStepByRules, extractBlockedPrompt } from './transitions.js'; // Loop detection export { LoopDetector } from './loop-detector.js'; diff --git a/src/workflow/instruction-builder.ts b/src/workflow/instruction-builder.ts index 72bee38..21440be 100644 --- a/src/workflow/instruction-builder.ts +++ b/src/workflow/instruction-builder.ts @@ -5,7 +5,7 @@ * template placeholders with actual values. */ -import type { WorkflowStep, AgentResponse, Language } from '../models/types.js'; +import type { WorkflowStep, WorkflowRule, AgentResponse, Language } from '../models/types.js'; import { getGitDiff } from '../agents/runner.js'; /** @@ -70,13 +70,97 @@ const STATUS_RULES_HEADER_STRINGS = { /** * Render status rules header. - * Prepended to status_rules_prompt when it exists. + * Prepended to auto-generated status rules from workflow rules. */ export function renderStatusRulesHeader(language: Language): string { const strings = STATUS_RULES_HEADER_STRINGS[language]; return [strings.heading, '', strings.warning, strings.instruction, ''].join('\n'); } +/** Localized strings for rules-based status prompt */ +const RULES_PROMPT_STRINGS = { + en: { + criteriaHeading: '## Decision Criteria', + headerNum: '#', + headerCondition: 'Condition', + headerTag: 'Tag', + outputHeading: '## Output Format', + outputInstruction: 'Output the tag corresponding to your decision:', + appendixHeading: '### Appendix Template', + appendixInstruction: 'When outputting `[{tag}]`, append the following:', + }, + ja: { + criteriaHeading: '## 判定基準', + headerNum: '#', + headerCondition: '状況', + headerTag: 'タグ', + outputHeading: '## 出力フォーマット', + outputInstruction: '判定に対応するタグを出力してください:', + appendixHeading: '### 追加出力テンプレート', + appendixInstruction: '`[{tag}]` を出力する場合、以下を追記してください:', + }, +} as const; + +/** + * Generate status rules prompt from rules configuration. + * Creates a structured prompt that tells the agent which numbered tags to output. + * + * Example output for step "plan" with 3 rules: + * ## 判定基準 + * | # | 状況 | タグ | + * |---|------|------| + * | 1 | 要件が明確で実装可能 | `[PLAN:1]` | + * | 2 | ユーザーが質問をしている | `[PLAN:2]` | + * | 3 | 要件が不明確、情報不足 | `[PLAN:3]` | + */ +export function generateStatusRulesFromRules( + stepName: string, + rules: WorkflowRule[], + language: Language, +): string { + const tag = stepName.toUpperCase(); + const strings = RULES_PROMPT_STRINGS[language]; + + const lines: string[] = []; + + // Criteria table + lines.push(strings.criteriaHeading); + lines.push(''); + lines.push(`| ${strings.headerNum} | ${strings.headerCondition} | ${strings.headerTag} |`); + lines.push('|---|------|------|'); + for (const [i, rule] of rules.entries()) { + lines.push(`| ${i + 1} | ${rule.condition} | \`[${tag}:${i + 1}]\` |`); + } + lines.push(''); + + // Output format + lines.push(strings.outputHeading); + lines.push(''); + lines.push(strings.outputInstruction); + lines.push(''); + for (const [i, rule] of rules.entries()) { + lines.push(`- \`[${tag}:${i + 1}]\` — ${rule.condition}`); + } + + // Appendix templates (if any rules have appendix) + const rulesWithAppendix = rules.filter((r) => r.appendix); + if (rulesWithAppendix.length > 0) { + lines.push(''); + lines.push(strings.appendixHeading); + for (const [i, rule] of rules.entries()) { + if (!rule.appendix) continue; + const tagStr = `[${tag}:${i + 1}]`; + lines.push(''); + lines.push(strings.appendixInstruction.replace('{tag}', tagStr)); + lines.push('```'); + lines.push(rule.appendix.trimEnd()); + lines.push('```'); + } + } + + return lines.join('\n'); +} + /** Localized strings for execution metadata rendering */ const METADATA_STRINGS = { en: { @@ -187,10 +271,12 @@ export function buildInstruction( instruction = instruction.replace(/\{report_dir\}/g, context.reportDir); } - // Append status_rules_prompt with localized header if present - if (step.statusRulesPrompt) { - const statusHeader = renderStatusRulesHeader(context.language ?? 'en'); - instruction = `${instruction}\n\n${statusHeader}\n${step.statusRulesPrompt}`; + // Append auto-generated status rules from rules + const language = context.language ?? 'en'; + if (step.rules && step.rules.length > 0) { + const statusHeader = renderStatusRulesHeader(language); + const generatedPrompt = generateStatusRulesFromRules(step.name, step.rules, language); + instruction = `${instruction}\n\n${statusHeader}\n${generatedPrompt}`; } // Prepend execution context metadata so agents see it first. diff --git a/src/workflow/transitions.ts b/src/workflow/transitions.ts index 5aff143..5f2395a 100644 --- a/src/workflow/transitions.ts +++ b/src/workflow/transitions.ts @@ -1,116 +1,26 @@ /** * Workflow state transition logic * - * Handles determining the next step based on agent response status - * and transition conditions defined in the workflow configuration. + * Handles determining the next step based on rules-based routing. */ import type { - WorkflowConfig, WorkflowStep, - Status, - TransitionCondition, } from '../models/types.js'; -import { COMPLETE_STEP, ABORT_STEP } from './constants.js'; /** - * Check if status matches transition condition. + * Determine next step using rules-based detection. + * Returns the next step name from the matched rule, or null if no rule matched. */ -export function matchesCondition( - status: Status, - condition: TransitionCondition -): boolean { - if (condition === 'always') { - return true; - } - - // Map status to condition - const statusConditionMap: Record = { - done: ['done'], - blocked: ['blocked'], - approved: ['approved'], - rejected: ['rejected'], - improve: ['improve'], - answer: ['answer'], - pending: [], - in_progress: [], - cancelled: [], - interrupted: [], // Interrupted is handled separately - }; - - const matchingConditions = statusConditionMap[status] || []; - return matchingConditions.includes(condition); -} - -/** - * Handle case when no status marker is found in agent output. - */ -export function handleNoStatus( +export function determineNextStepByRules( step: WorkflowStep, - config: WorkflowConfig -): string { - const behavior = step.onNoStatus || 'complete'; - - switch (behavior) { - case 'stay': - // Stay on current step (original behavior, may cause loops) - return step.name; - - case 'continue': { - // Try to find done/always transition, otherwise find next step in workflow - for (const transition of step.transitions) { - if (transition.condition === 'done' || transition.condition === 'always') { - return transition.nextStep; - } - } - // Find next step in workflow order - const stepIndex = config.steps.findIndex(s => s.name === step.name); - const nextStep = config.steps[stepIndex + 1]; - if (stepIndex >= 0 && nextStep) { - return nextStep.name; - } - return COMPLETE_STEP; - } - - case 'complete': - default: - // Try to find done/always transition, otherwise complete workflow - for (const transition of step.transitions) { - if (transition.condition === 'done' || transition.condition === 'always') { - return transition.nextStep; - } - } - return COMPLETE_STEP; + ruleIndex: number, +): string | null { + const rule = step.rules?.[ruleIndex]; + if (!rule) { + return null; } -} - -/** - * Determine next step based on current status. - */ -export function determineNextStep( - step: WorkflowStep, - status: Status, - config: WorkflowConfig -): string { - // If interrupted, abort immediately - if (status === 'interrupted') { - return ABORT_STEP; - } - - // Check transitions in order - for (const transition of step.transitions) { - if (matchesCondition(status, transition.condition)) { - return transition.nextStep; - } - } - - // If status is 'in_progress' (no status marker found), use onNoStatus behavior - if (status === 'in_progress') { - return handleNoStatus(step, config); - } - - // Unexpected status - treat as done and complete - return COMPLETE_STEP; + return rule.next; } /** diff --git a/src/workflow/types.ts b/src/workflow/types.ts index bfabea8..c1b2246 100644 --- a/src/workflow/types.ts +++ b/src/workflow/types.ts @@ -12,7 +12,7 @@ import type { PermissionHandler, AskUserQuestionHandler } from '../claude/proces /** Events emitted by workflow engine */ export interface WorkflowEvents { 'step:start': (step: WorkflowStep, iteration: number) => void; - 'step:complete': (step: WorkflowStep, response: AgentResponse) => void; + 'step:complete': (step: WorkflowStep, response: AgentResponse, instruction: string) => void; 'step:blocked': (step: WorkflowStep, response: AgentResponse) => void; 'step:user_input': (step: WorkflowStep, userInput: string) => void; 'workflow:complete': (state: WorkflowState) => void;