From 32c9595818127eb4c817bee773da8b565ff4dfc7 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 24 Nov 2025 23:09:24 +0800 Subject: [PATCH] feat: add universal @test-fix-agent invocation template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhancement: - Add dynamic prompt template for @test-fix-agent - Supports 3 task types: test-gen, test-fix, test-fix-iteration - Auto-adapts based on task.meta.type via configuration maps Template Features: - taskTypeObjective: Task-specific goals - taskTypeSpecificReads: Required file reads per type - taskTypeGuidance: Execution instructions per type - taskTypeDeliverables: Expected outputs per type - taskTypeSuccessCriteria: Completion validation per type Benefits: - Orchestrator uses single template for all task types - Claude dynamically fills in type-specific details - Reduces duplication, maintains consistency - Clear guidance for criticality assessment (high/medium/low) - Progressive testing integration (affected_only vs full_suite) Lines: +86 (429 → 515, still -35% from original 791) --- .../commands/workflow/test-cycle-execute.md | 89 ++++++++++++++++++- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/.claude/commands/workflow/test-cycle-execute.md b/.claude/commands/workflow/test-cycle-execute.md index 1f1adc0f..8631d001 100644 --- a/.claude/commands/workflow/test-cycle-execute.md +++ b/.claude/commands/workflow/test-cycle-execute.md @@ -346,9 +346,92 @@ Task( ``` **@test-fix-agent** (execution): -- Paths provided by orchestrator (task_json_path, iteration_state_path, etc.) -- Agent loads files independently -- Executes based on task.meta.type and fix_strategy +```javascript +Task( + subagent_type="test-fix-agent", + description=`Execute ${task.meta.type}: ${task.title}`, + prompt=` + ## Task Objective + ${taskTypeObjective[task.meta.type]} + + ## MANDATORY FIRST STEPS + 1. Read task JSON: ${session.task_json_path} + 2. Read iteration state: ${session.iteration_state_path} + 3. ${taskTypeSpecificReads[task.meta.type]} + + ## Session Paths + - Workflow Dir: ${session.workflow_dir} + - Task JSON: ${session.task_json_path} + - Test Results Output: ${session.test_results_path} + - Test Output Log: ${session.test_output_path} + - Iteration State: ${session.iteration_state_path} + + ## Task Type: ${task.meta.type} + ${taskTypeGuidance[task.meta.type]} + + ## Expected Deliverables + ${taskTypeDeliverables[task.meta.type]} + + ## Success Criteria + - ${taskTypeSuccessCriteria[task.meta.type]} + - Update task status in task JSON + - Save all outputs to specified paths + - Report completion to orchestrator + ` +) + +// Task Type Configurations +const taskTypeObjective = { + "test-gen": "Generate comprehensive tests based on requirements", + "test-fix": "Execute test suite and report results with criticality assessment", + "test-fix-iteration": "Apply fixes from strategy and validate with tests" +}; + +const taskTypeSpecificReads = { + "test-gen": "Read test context: ${session.test_context_path}", + "test-fix": "Read previous results (if exists): ${session.test_results_path}", + "test-fix-iteration": "Read fix strategy: ${session.analysis_path}, fix history: ${session.fix_history_path}" +}; + +const taskTypeGuidance = { + "test-gen": ` + - Review task.context.requirements for test scenarios + - Analyze codebase to understand implementation + - Generate tests covering: happy paths, edge cases, error handling + - Follow existing test patterns and framework conventions + `, + "test-fix": ` + - Run test command from task.context or project config + - Capture: pass/fail counts, error messages, stack traces + - Assess criticality for each failure: + * high: core functionality broken, security issues + * medium: feature degradation, data integrity issues + * low: edge cases, flaky tests, env-specific issues + - Save structured results to test-results.json + `, + "test-fix-iteration": ` + - Load fix_strategy from task.context.fix_strategy + - Identify modification_points: ${task.context.fix_strategy.modification_points} + - Apply surgical fixes (minimal changes) + - Test execution mode: ${task.context.fix_strategy.test_execution.mode} + * affected_only: Run ${task.context.fix_strategy.test_execution.affected_tests} + * full_suite: Run complete test suite + - If failures persist: Document in test-results.json, DO NOT analyze (orchestrator handles) + ` +}; + +const taskTypeDeliverables = { + "test-gen": "- Test files in target directories\n - Test coverage report\n - Summary in .summaries/", + "test-fix": "- test-results.json (pass_rate, criticality, failures)\n - test-output.log (full test output)\n - Summary in .summaries/", + "test-fix-iteration": "- Modified source files\n - test-results.json (updated pass_rate)\n - test-output.log\n - Summary in .summaries/" +}; + +const taskTypeSuccessCriteria = { + "test-gen": "All test files created, executable without errors, coverage documented", + "test-fix": "Test results saved with accurate pass_rate and criticality, all failures documented", + "test-fix-iteration": "Fixes applied per strategy, tests executed, results reported (pass/fail to orchestrator)" +}; +``` ### Completion Conditions