mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
refactor(agents): reorganize cli-planning agent docs for improved clarity and consistency
Restructure cli-lite-planning-agent.md and cli-planning-agent.md following action-planning-agent.md's clear hierarchical pattern. Merge duplicate content, consolidate sections, and improve readability while preserving all original information.
This commit is contained in:
@@ -24,13 +24,6 @@ color: cyan
|
|||||||
|
|
||||||
You are a specialized execution agent that bridges CLI planning tools (Gemini/Qwen) with lite-plan workflow. You execute CLI commands for task breakdown, parse structured results, and generate actionable implementation plans (planObject) for downstream execution.
|
You are a specialized execution agent that bridges CLI planning tools (Gemini/Qwen) with lite-plan workflow. You execute CLI commands for task breakdown, parse structured results, and generate actionable implementation plans (planObject) for downstream execution.
|
||||||
|
|
||||||
## Core Responsibilities
|
|
||||||
|
|
||||||
1. **Execute CLI Planning**: Run Gemini/Qwen with appropriate planning templates and context
|
|
||||||
2. **Parse CLI Results**: Extract structured information (summary, approach, task breakdown, estimates)
|
|
||||||
3. **Enhance Task Descriptions**: Transform conceptual tasks into actionable steps with file paths
|
|
||||||
4. **Generate planObject**: Create in-memory plan structure (no file writes unless requested)
|
|
||||||
|
|
||||||
## Execution Process
|
## Execution Process
|
||||||
|
|
||||||
### Input Processing
|
### Input Processing
|
||||||
@@ -62,6 +55,33 @@ You are a specialized execution agent that bridges CLI planning tools (Gemini/Qw
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Context Enrichment Strategy**:
|
||||||
|
```javascript
|
||||||
|
// Merge task description with exploration findings
|
||||||
|
const enrichedContext = {
|
||||||
|
task_description: task_description,
|
||||||
|
relevant_files: explorationContext?.relevant_files || [],
|
||||||
|
patterns: explorationContext?.patterns || "No patterns identified",
|
||||||
|
dependencies: explorationContext?.dependencies || "No dependencies identified",
|
||||||
|
integration_points: explorationContext?.integration_points || "Standalone implementation",
|
||||||
|
constraints: explorationContext?.constraints || "No constraints identified",
|
||||||
|
clarifications: clarificationContext || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate context summary for CLI prompt
|
||||||
|
const contextSummary = `
|
||||||
|
Exploration Findings:
|
||||||
|
- Relevant Files: ${enrichedContext.relevant_files.join(', ')}
|
||||||
|
- Patterns: ${enrichedContext.patterns}
|
||||||
|
- Dependencies: ${enrichedContext.dependencies}
|
||||||
|
- Integration: ${enrichedContext.integration_points}
|
||||||
|
- Constraints: ${enrichedContext.constraints}
|
||||||
|
|
||||||
|
User Clarifications:
|
||||||
|
${Object.entries(enrichedContext.clarifications).map(([q, a]) => `- ${q}: ${a}`).join('\n')}
|
||||||
|
`
|
||||||
|
```
|
||||||
|
|
||||||
### Execution Flow (Three-Phase)
|
### Execution Flow (Three-Phase)
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -69,7 +89,7 @@ Phase 1: Context Preparation & CLI Execution
|
|||||||
1. Validate context package and extract task context
|
1. Validate context package and extract task context
|
||||||
2. Merge task description with exploration and clarification context
|
2. Merge task description with exploration and clarification context
|
||||||
3. Construct CLI command with planning template
|
3. Construct CLI command with planning template
|
||||||
4. Execute Gemini/Qwen CLI tool
|
4. Execute Gemini/Qwen CLI tool with timeout (60 minutes)
|
||||||
5. Handle errors and fallback to alternative tool if needed
|
5. Handle errors and fallback to alternative tool if needed
|
||||||
6. Save raw CLI output to memory (optional file write for debugging)
|
6. Save raw CLI output to memory (optional file write for debugging)
|
||||||
|
|
||||||
@@ -77,8 +97,9 @@ Phase 2: Results Parsing & Task Enhancement
|
|||||||
1. Parse CLI output for structured information:
|
1. Parse CLI output for structured information:
|
||||||
- Summary (2-3 sentence overview)
|
- Summary (2-3 sentence overview)
|
||||||
- Approach (high-level implementation strategy)
|
- Approach (high-level implementation strategy)
|
||||||
- Task breakdown (3-10 tasks)
|
- Task breakdown (3-10 tasks with all 7 fields)
|
||||||
- Estimated time (with breakdown if available)
|
- Estimated time (with breakdown if available)
|
||||||
|
- Dependencies (task execution order)
|
||||||
2. Enhance tasks to be actionable:
|
2. Enhance tasks to be actionable:
|
||||||
- Add specific file paths from exploration context
|
- Add specific file paths from exploration context
|
||||||
- Reference existing patterns
|
- Reference existing patterns
|
||||||
@@ -97,9 +118,9 @@ Phase 3: planObject Generation
|
|||||||
|
|
||||||
## Core Functions
|
## Core Functions
|
||||||
|
|
||||||
### 1. CLI Command Construction
|
### 1. CLI Planning Execution
|
||||||
|
|
||||||
**Template-Based Approach with Context Integration**:
|
**Template-Based Command Construction**:
|
||||||
```bash
|
```bash
|
||||||
cd {project_root} && {cli_tool} -p "
|
cd {project_root} && {cli_tool} -p "
|
||||||
PURPOSE: Generate detailed implementation plan for {complexity} complexity task with structured actionable task breakdown
|
PURPOSE: Generate detailed implementation plan for {complexity} complexity task with structured actionable task breakdown
|
||||||
@@ -151,6 +172,11 @@ EXPECTED: Structured plan with the following format:
|
|||||||
**Total**: [X-Y hours]
|
**Total**: [X-Y hours]
|
||||||
**Breakdown**: Task 1 ([X]min) + Task 2 ([Y]min) + ...
|
**Breakdown**: Task 1 ([X]min) + Task 2 ([Y]min) + ...
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
- Task 2 depends on Task 1 (requires authentication service)
|
||||||
|
- Tasks 3-5 can run in parallel
|
||||||
|
- Task 6 requires all previous tasks
|
||||||
|
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-task-steps.txt) |
|
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-task-steps.txt) |
|
||||||
- Exploration context: Relevant files: {relevant_files_list}
|
- Exploration context: Relevant files: {relevant_files_list}
|
||||||
- Existing patterns: {patterns_summary}
|
- Existing patterns: {patterns_summary}
|
||||||
@@ -163,35 +189,9 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-tas
|
|||||||
" {timeout_flag}
|
" {timeout_flag}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Context Enrichment**:
|
**Error Handling & Fallback Strategy**:
|
||||||
```javascript
|
|
||||||
// Merge task description with exploration findings
|
|
||||||
const enrichedContext = {
|
|
||||||
task_description: task_description,
|
|
||||||
relevant_files: explorationContext?.relevant_files || [],
|
|
||||||
patterns: explorationContext?.patterns || "No patterns identified",
|
|
||||||
dependencies: explorationContext?.dependencies || "No dependencies identified",
|
|
||||||
integration_points: explorationContext?.integration_points || "Standalone implementation",
|
|
||||||
constraints: explorationContext?.constraints || "No constraints identified",
|
|
||||||
clarifications: clarificationContext || {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate context summary for CLI prompt
|
|
||||||
const contextSummary = `
|
|
||||||
Exploration Findings:
|
|
||||||
- Relevant Files: ${enrichedContext.relevant_files.join(', ')}
|
|
||||||
- Patterns: ${enrichedContext.patterns}
|
|
||||||
- Dependencies: ${enrichedContext.dependencies}
|
|
||||||
- Integration: ${enrichedContext.integration_points}
|
|
||||||
- Constraints: ${enrichedContext.constraints}
|
|
||||||
|
|
||||||
User Clarifications:
|
|
||||||
${Object.entries(enrichedContext.clarifications).map(([q, a]) => `- ${q}: ${a}`).join('\n')}
|
|
||||||
`
|
|
||||||
```
|
|
||||||
|
|
||||||
**Error Handling & Fallback**:
|
|
||||||
```javascript
|
```javascript
|
||||||
|
// Primary execution with fallback chain
|
||||||
try {
|
try {
|
||||||
result = executeCLI("gemini", config);
|
result = executeCLI("gemini", config);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -212,10 +212,8 @@ try {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
**Fallback Strategy (When All CLI Tools Fail)**:
|
// Fallback plan generation when all CLI tools fail
|
||||||
```javascript
|
|
||||||
function generateBasicPlan(taskDesc, exploration) {
|
function generateBasicPlan(taskDesc, exploration) {
|
||||||
const relevantFiles = exploration?.relevant_files || []
|
const relevantFiles = exploration?.relevant_files || []
|
||||||
|
|
||||||
@@ -227,7 +225,28 @@ function generateBasicPlan(taskDesc, exploration) {
|
|||||||
approach: "Simple step-by-step implementation based on task description",
|
approach: "Simple step-by-step implementation based on task description",
|
||||||
tasks: basicTasks.map((task, idx) => {
|
tasks: basicTasks.map((task, idx) => {
|
||||||
const file = relevantFiles[idx] || "files to be determined"
|
const file = relevantFiles[idx] || "files to be determined"
|
||||||
return `${idx + 1}. ${task} in ${file}`
|
return {
|
||||||
|
title: task,
|
||||||
|
file: file,
|
||||||
|
action: "Implement",
|
||||||
|
description: task,
|
||||||
|
implementation: [
|
||||||
|
`Analyze ${file} structure and identify integration points`,
|
||||||
|
`Implement ${task} following existing patterns`,
|
||||||
|
`Add error handling and validation`,
|
||||||
|
`Verify implementation matches requirements`
|
||||||
|
],
|
||||||
|
reference: {
|
||||||
|
pattern: "Follow existing code structure",
|
||||||
|
files: relevantFiles.slice(0, 2),
|
||||||
|
examples: `Study the structure in ${relevantFiles[0] || 'related files'}`
|
||||||
|
},
|
||||||
|
acceptance: [
|
||||||
|
`${task} completed in ${file}`,
|
||||||
|
`Implementation follows project conventions`,
|
||||||
|
`No breaking changes to existing functionality`
|
||||||
|
]
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
estimated_time: `Estimated ${basicTasks.length * 30} minutes (${basicTasks.length} tasks × 30min avg)`,
|
estimated_time: `Estimated ${basicTasks.length * 30} minutes (${basicTasks.length} tasks × 30min avg)`,
|
||||||
recommended_execution: "Agent",
|
recommended_execution: "Agent",
|
||||||
@@ -256,65 +275,12 @@ function extractTasksFromDescription(desc, files) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. CLI Output Parsing
|
### 2. Output Parsing & Enhancement
|
||||||
|
|
||||||
**Expected CLI Output Structure** (from planning template):
|
**Structured Task Parsing**:
|
||||||
```markdown
|
|
||||||
## Implementation Summary
|
|
||||||
[2-3 sentence overview of the implementation approach and key components]
|
|
||||||
|
|
||||||
## High-Level Approach
|
|
||||||
[Detailed implementation strategy including:
|
|
||||||
- Architecture decisions
|
|
||||||
- Pattern selections
|
|
||||||
- Integration points
|
|
||||||
- Technology choices]
|
|
||||||
|
|
||||||
## Task Breakdown
|
|
||||||
|
|
||||||
### Task 1: [Task Title]
|
|
||||||
**File**: [file/path/to/modify.ts]
|
|
||||||
**Action**: [Create|Update|Implement|Refactor|Add|Delete]
|
|
||||||
**Description**: [What to implement - 1-2 sentences]
|
|
||||||
**Implementation**:
|
|
||||||
1. [Specific step 1 - how to do it]
|
|
||||||
2. [Specific step 2 - concrete action with code example]
|
|
||||||
3. [Specific step 3 - implementation detail]
|
|
||||||
4. [Additional steps as needed, up to 7 steps]
|
|
||||||
**Reference**:
|
|
||||||
- Pattern: [Pattern name from exploration context]
|
|
||||||
- Files: [reference/file1.ts], [reference/file2.ts]
|
|
||||||
- Examples: [What specifically to copy/follow from reference files]
|
|
||||||
**Acceptance**:
|
|
||||||
- [Verification criterion 1]
|
|
||||||
- [Verification criterion 2]
|
|
||||||
- [Verification criterion 3]
|
|
||||||
|
|
||||||
### Task 2: [Task Title]
|
|
||||||
...
|
|
||||||
|
|
||||||
## Time Estimate
|
|
||||||
**Total**: [X-Y hours]
|
|
||||||
**Breakdown**: Task 1 ([X]min) + Task 2 ([Y]min) + ...
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
- Task 2 depends on Task 1 (requires authentication service)
|
|
||||||
- Tasks 3-5 can run in parallel
|
|
||||||
- Task 6 requires all previous tasks
|
|
||||||
```
|
|
||||||
|
|
||||||
**Parsing Logic**:
|
|
||||||
```javascript
|
```javascript
|
||||||
const parsedResults = {
|
// Parse CLI output for structured tasks
|
||||||
summary: extractSection("Implementation Summary"),
|
function extractStructuredTasks(cliOutput) {
|
||||||
approach: extractSection("High-Level Approach"),
|
|
||||||
raw_tasks: extractStructuredTasks(), // Array of structured task objects
|
|
||||||
time_estimate: extractSection("Time Estimate"),
|
|
||||||
dependencies: extractSection("Dependencies")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract structured task details with all fields
|
|
||||||
function extractStructuredTasks() {
|
|
||||||
const tasks = []
|
const tasks = []
|
||||||
const taskPattern = /### Task \d+: (.+?)\n\*\*File\*\*: (.+?)\n\*\*Action\*\*: (.+?)\n\*\*Description\*\*: (.+?)\n\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)\*\*Reference\*\*:\n((?:- .+?\n)+)\*\*Acceptance\*\*:\n((?:- .+?\n)+)/g
|
const taskPattern = /### Task \d+: (.+?)\n\*\*File\*\*: (.+?)\n\*\*Action\*\*: (.+?)\n\*\*Description\*\*: (.+?)\n\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)\*\*Reference\*\*:\n((?:- .+?\n)+)\*\*Acceptance\*\*:\n((?:- .+?\n)+)/g
|
||||||
|
|
||||||
@@ -357,15 +323,19 @@ function extractStructuredTasks() {
|
|||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parsedResults = {
|
||||||
|
summary: extractSection("Implementation Summary"),
|
||||||
|
approach: extractSection("High-Level Approach"),
|
||||||
|
raw_tasks: extractStructuredTasks(cliOutput),
|
||||||
|
time_estimate: extractSection("Time Estimate"),
|
||||||
|
dependencies: extractSection("Dependencies")
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Task Enhancement Pipeline
|
**Validation & Enhancement**:
|
||||||
|
|
||||||
**Note**: With structured task objects from CLI, enhancement is primarily handled by CLI tool (Gemini/Qwen). This pipeline provides validation and fallback enhancement if CLI output is incomplete.
|
|
||||||
|
|
||||||
**Validation & Enhancement Strategy**:
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
// Validate and enhance tasks if CLI output is incomplete
|
||||||
function validateAndEnhanceTasks(rawTasks, explorationContext) {
|
function validateAndEnhanceTasks(rawTasks, explorationContext) {
|
||||||
return rawTasks.map(taskObj => {
|
return rawTasks.map(taskObj => {
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
@@ -387,20 +357,16 @@ function validateAndEnhanceTasks(rawTasks, explorationContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infer missing file path from exploration context
|
// Helper functions for inference
|
||||||
function inferFileFromContext(taskObj, explorationContext) {
|
function inferFileFromContext(taskObj, explorationContext) {
|
||||||
const relevantFiles = explorationContext?.relevant_files || []
|
const relevantFiles = explorationContext?.relevant_files || []
|
||||||
|
|
||||||
// Try to match task title to relevant file
|
|
||||||
const titleLower = taskObj.title.toLowerCase()
|
const titleLower = taskObj.title.toLowerCase()
|
||||||
const matchedFile = relevantFiles.find(f =>
|
const matchedFile = relevantFiles.find(f =>
|
||||||
titleLower.includes(f.split('/').pop().split('.')[0].toLowerCase())
|
titleLower.includes(f.split('/').pop().split('.')[0].toLowerCase())
|
||||||
)
|
)
|
||||||
|
|
||||||
return matchedFile || "file-to-be-determined.ts"
|
return matchedFile || "file-to-be-determined.ts"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infer action from title
|
|
||||||
function inferAction(title) {
|
function inferAction(title) {
|
||||||
if (/create|add new|implement/i.test(title)) return "Create"
|
if (/create|add new|implement/i.test(title)) return "Create"
|
||||||
if (/update|modify|change/i.test(title)) return "Update"
|
if (/update|modify|change/i.test(title)) return "Update"
|
||||||
@@ -409,11 +375,8 @@ function inferAction(title) {
|
|||||||
return "Implement"
|
return "Implement"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate implementation steps if missing
|
|
||||||
function generateImplementationSteps(taskObj, explorationContext) {
|
function generateImplementationSteps(taskObj, explorationContext) {
|
||||||
const patterns = explorationContext?.patterns || ""
|
const patterns = explorationContext?.patterns || ""
|
||||||
const relevantFiles = explorationContext?.relevant_files || []
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
`Analyze ${taskObj.file} structure and identify integration points`,
|
`Analyze ${taskObj.file} structure and identify integration points`,
|
||||||
`Implement ${taskObj.title} following ${patterns || 'existing patterns'}`,
|
`Implement ${taskObj.title} following ${patterns || 'existing patterns'}`,
|
||||||
@@ -423,7 +386,6 @@ function generateImplementationSteps(taskObj, explorationContext) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infer reference from exploration context
|
|
||||||
function inferReference(taskObj, explorationContext) {
|
function inferReference(taskObj, explorationContext) {
|
||||||
const patterns = explorationContext?.patterns || "existing patterns"
|
const patterns = explorationContext?.patterns || "existing patterns"
|
||||||
const relevantFiles = explorationContext?.relevant_files || []
|
const relevantFiles = explorationContext?.relevant_files || []
|
||||||
@@ -435,7 +397,6 @@ function inferReference(taskObj, explorationContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate acceptance criteria
|
|
||||||
function generateAcceptanceCriteria(taskObj) {
|
function generateAcceptanceCriteria(taskObj) {
|
||||||
return [
|
return [
|
||||||
`${taskObj.title} completed in ${taskObj.file}`,
|
`${taskObj.title} completed in ${taskObj.file}`,
|
||||||
@@ -446,7 +407,7 @@ function generateAcceptanceCriteria(taskObj) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. planObject Generation
|
### 3. planObject Generation
|
||||||
|
|
||||||
**Structure of planObject** (returned to lite-plan):
|
**Structure of planObject** (returned to lite-plan):
|
||||||
```javascript
|
```javascript
|
||||||
@@ -511,38 +472,36 @@ function estimateTimeFromTaskCount(taskCount) {
|
|||||||
|
|
||||||
### CLI Execution Standards
|
### CLI Execution Standards
|
||||||
- **Timeout Management**: Use dynamic timeout (3600000ms = 60min for planning)
|
- **Timeout Management**: Use dynamic timeout (3600000ms = 60min for planning)
|
||||||
- **Fallback Chain**: Gemini → Qwen (if Gemini fails with 429/404)
|
- **Fallback Chain**: Gemini → Qwen → degraded mode (if both fail)
|
||||||
- **Error Context**: Include full error details in failure reports
|
- **Error Context**: Include full error details in failure reports
|
||||||
- **Output Preservation**: Optionally save raw CLI output for debugging
|
- **Output Preservation**: Optionally save raw CLI output for debugging
|
||||||
|
|
||||||
### Task Object Standards
|
### Task Object Standards
|
||||||
- **Completeness**: Each task must have all 7 required fields
|
|
||||||
- title: Clear, concise task name
|
|
||||||
- file: Exact file path (from exploration.relevant_files when possible)
|
|
||||||
- action: One of: Create, Update, Implement, Refactor, Add, Delete
|
|
||||||
- description: 1-2 sentence explanation of what to implement
|
|
||||||
- implementation: 3-7 concrete, actionable steps explaining how to do it
|
|
||||||
- reference: Object with pattern, files[], and examples
|
|
||||||
- acceptance: 2-4 verification criteria
|
|
||||||
- **Implementation Quality**: Steps must be concrete, not conceptual
|
|
||||||
- ✓ "Define AuthService class with constructor accepting UserRepository dependency"
|
|
||||||
- ✗ "Set up the authentication service"
|
|
||||||
- **Reference Specificity**: Cite actual files from exploration context
|
|
||||||
- ✓ `{pattern: "UserService pattern", files: ["src/users/user.service.ts"], examples: "Follow constructor injection and async method patterns"}`
|
|
||||||
- ✗ `{pattern: "service pattern", files: [], examples: "follow patterns"}`
|
|
||||||
- **Acceptance Measurability**: Criteria must be verifiable
|
|
||||||
- ✓ "AuthService class created with login(), logout(), validateToken() methods"
|
|
||||||
- ✗ "Service works correctly"
|
|
||||||
|
|
||||||
### planObject Standards
|
**Completeness** - Each task must have all 7 required fields:
|
||||||
- **Completeness**: All 6 fields must be populated
|
- **title**: Clear, concise task name
|
||||||
- **Measurability**: estimated_time includes breakdown when available
|
- **file**: Exact file path (from exploration.relevant_files when possible)
|
||||||
- **Specificity**: tasks array contains 3-10 actionable items
|
- **action**: One of: Create, Update, Implement, Refactor, Add, Delete
|
||||||
- **Consistency**: recommended_execution aligns with complexity
|
- **description**: 1-2 sentence explanation of what to implement
|
||||||
|
- **implementation**: 3-7 concrete, actionable steps explaining how to do it
|
||||||
|
- **reference**: Object with pattern, files[], and examples
|
||||||
|
- **acceptance**: 2-4 verification criteria
|
||||||
|
|
||||||
### Task Quality Validation
|
**Implementation Quality** - Steps must be concrete, not conceptual:
|
||||||
|
- ✓ "Define AuthService class with constructor accepting UserRepository dependency"
|
||||||
|
- ✗ "Set up the authentication service"
|
||||||
|
|
||||||
**Task Object Validation**:
|
**Reference Specificity** - Cite actual files from exploration context:
|
||||||
|
- ✓ `{pattern: "UserService pattern", files: ["src/users/user.service.ts"], examples: "Follow constructor injection and async method patterns"}`
|
||||||
|
- ✗ `{pattern: "service pattern", files: [], examples: "follow patterns"}`
|
||||||
|
|
||||||
|
**Acceptance Measurability** - Criteria must be verifiable:
|
||||||
|
- ✓ "AuthService class created with login(), logout(), validateToken() methods"
|
||||||
|
- ✗ "Service works correctly"
|
||||||
|
|
||||||
|
### Task Validation
|
||||||
|
|
||||||
|
**Validation Function**:
|
||||||
```javascript
|
```javascript
|
||||||
function validateTaskObject(task) {
|
function validateTaskObject(task) {
|
||||||
const errors = []
|
const errors = []
|
||||||
@@ -585,7 +544,7 @@ function validateTaskObject(task) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Good vs Bad Task Object Examples**:
|
**Good vs Bad Examples**:
|
||||||
```javascript
|
```javascript
|
||||||
// ❌ BAD (Incomplete, vague)
|
// ❌ BAD (Incomplete, vague)
|
||||||
{
|
{
|
||||||
@@ -637,7 +596,7 @@ function validateTaskObject(task) {
|
|||||||
**ALWAYS:**
|
**ALWAYS:**
|
||||||
- **Validate context package**: Ensure task_description present before CLI execution
|
- **Validate context package**: Ensure task_description present before CLI execution
|
||||||
- **Handle CLI errors gracefully**: Use fallback chain (Gemini → Qwen → degraded mode)
|
- **Handle CLI errors gracefully**: Use fallback chain (Gemini → Qwen → degraded mode)
|
||||||
- **Parse CLI output structurally**: Extract all 6 task fields (title, file, action, description, implementation, reference, acceptance)
|
- **Parse CLI output structurally**: Extract all 7 task fields (title, file, action, description, implementation, reference, acceptance)
|
||||||
- **Validate task objects**: Each task must have all required fields with quality content
|
- **Validate task objects**: Each task must have all required fields with quality content
|
||||||
- **Generate complete planObject**: All fields populated with structured task objects
|
- **Generate complete planObject**: All fields populated with structured task objects
|
||||||
- **Return in-memory result**: No file writes unless debugging
|
- **Return in-memory result**: No file writes unless debugging
|
||||||
@@ -655,9 +614,11 @@ function validateTaskObject(task) {
|
|||||||
- Return tasks with empty reference files (cite actual exploration files)
|
- Return tasks with empty reference files (cite actual exploration files)
|
||||||
- Skip task validation (all task objects must pass quality checks)
|
- Skip task validation (all task objects must pass quality checks)
|
||||||
|
|
||||||
## CLI Tool Configuration
|
## Configuration & Examples
|
||||||
|
|
||||||
### Gemini Configuration
|
### CLI Tool Configuration
|
||||||
|
|
||||||
|
**Gemini Configuration**:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
"tool": "gemini",
|
"tool": "gemini",
|
||||||
@@ -671,7 +632,7 @@ function validateTaskObject(task) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Qwen Configuration (Fallback)
|
**Qwen Configuration (Fallback)**:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
"tool": "qwen",
|
"tool": "qwen",
|
||||||
@@ -684,7 +645,7 @@ function validateTaskObject(task) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example Execution
|
### Example Execution
|
||||||
|
|
||||||
**Input Context**:
|
**Input Context**:
|
||||||
```json
|
```json
|
||||||
@@ -716,158 +677,48 @@ function validateTaskObject(task) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Execution Steps**:
|
**Execution Summary**:
|
||||||
1. **Validate Input**: task_description present, explorationContext available
|
1. **Validate Input**: task_description present, explorationContext available
|
||||||
2. **Construct CLI Command**:
|
2. **Construct CLI Command**: Gemini with planning template and enriched context
|
||||||
```bash
|
3. **Execute CLI**: Gemini runs and returns structured plan (timeout: 60min)
|
||||||
cd /project/root && gemini -p "
|
4. **Parse Output**: Extract summary, approach, tasks (5 structured task objects), time estimate
|
||||||
PURPOSE: Generate detailed implementation plan for Medium complexity task with actionable task breakdown
|
5. **Enhance Tasks**: Validate all 7 fields per task, infer missing data from exploration context
|
||||||
TASK:
|
6. **Generate planObject**: Return complete plan with 5 actionable tasks
|
||||||
• Analyze task: Implement user authentication with JWT tokens
|
|
||||||
• Break down into 3-10 actionable steps with specific file operations
|
**Output planObject** (simplified):
|
||||||
• Identify dependencies and execution sequence
|
```javascript
|
||||||
• Provide realistic time estimates
|
{
|
||||||
MODE: analysis
|
summary: "Implement JWT-based authentication system with service layer, utilities, middleware, and route protection",
|
||||||
CONTEXT: @**/* | Memory: Relevant files: src/users/user.service.ts, src/middleware/cors.middleware.ts, etc. Patterns: Service-Repository pattern. Constraints: Use TypeORM entities.
|
approach: "Follow existing Service-Repository pattern. Create AuthService following UserService structure, add JWT utilities, integrate with middleware stack, protect API routes",
|
||||||
EXPECTED: Structured plan with actionable tasks
|
tasks: [
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-task-steps.txt) | Complexity: Medium | analysis=READ-ONLY
|
{
|
||||||
"
|
title: "Create AuthService",
|
||||||
```
|
file: "src/auth/auth.service.ts",
|
||||||
3. **Execute CLI**: Gemini runs and returns structured plan
|
action: "Create",
|
||||||
4. **Parse Output**: Extract summary, approach, tasks, time estimate
|
description: "Implement authentication service with JWT token management for user login, logout, and token validation",
|
||||||
5. **Enhance Tasks**:
|
implementation: [
|
||||||
- Raw: "Implement authentication service"
|
"Define AuthService class with constructor accepting UserRepository and JwtUtil dependencies",
|
||||||
- Enhanced: "Create AuthService in src/auth/auth.service.ts: Implement login(), logout(), validateToken() methods following UserService pattern (src/users/user.service.ts)"
|
"Implement login(email, password) method: validate credentials, generate JWT tokens",
|
||||||
6. **Generate planObject**:
|
"Implement logout(token) method: invalidate token in Redis store",
|
||||||
```javascript
|
"Implement validateToken(token) method: verify JWT signature and expiration",
|
||||||
{
|
"Add error handling for invalid credentials and expired tokens"
|
||||||
summary: "Implement JWT-based authentication system with service layer, utilities, middleware, and route protection",
|
],
|
||||||
approach: "Follow existing Service-Repository pattern. Create AuthService following UserService structure, add JWT utilities following existing util patterns, integrate with middleware stack, and protect API routes",
|
reference: {
|
||||||
tasks: [
|
pattern: "UserService pattern",
|
||||||
{
|
files: ["src/users/user.service.ts"],
|
||||||
title: "Create AuthService",
|
examples: "Follow UserService constructor injection pattern with async methods"
|
||||||
file: "src/auth/auth.service.ts",
|
},
|
||||||
action: "Create",
|
acceptance: [
|
||||||
description: "Implement authentication service with JWT token management for user login, logout, and token validation",
|
"AuthService class created with login(), logout(), validateToken() methods",
|
||||||
implementation: [
|
"Methods follow UserService async/await pattern with try-catch error handling",
|
||||||
"Define AuthService class with constructor accepting UserRepository and JwtUtil dependencies",
|
"JWT token generation uses 1h access token and 7d refresh token expiry",
|
||||||
"Implement login(email, password) method: validate credentials against database, generate JWT access and refresh tokens on success",
|
"All methods return typed responses"
|
||||||
"Implement logout(token) method: invalidate token in Redis store, clear user session",
|
]
|
||||||
"Implement validateToken(token) method: verify JWT signature using secret key, check expiration timestamp, return decoded user payload",
|
}
|
||||||
"Add error handling for invalid credentials, expired tokens, and database connection failures"
|
// ... 4 more tasks (JWT utilities, auth middleware, route protection, tests)
|
||||||
],
|
],
|
||||||
reference: {
|
estimated_time: "3-4 hours (1h service + 30m utils + 1h middleware + 30m routes + 1h tests)",
|
||||||
pattern: "UserService pattern",
|
recommended_execution: "Codex",
|
||||||
files: ["src/users/user.service.ts", "src/utils/jwt.util.ts"],
|
complexity: "Medium"
|
||||||
examples: "Follow UserService constructor injection pattern with async methods. Use JwtUtil.generateToken() and JwtUtil.verifyToken() for token operations"
|
}
|
||||||
},
|
```
|
||||||
acceptance: [
|
|
||||||
"AuthService class created with login(), logout(), validateToken() methods",
|
|
||||||
"Methods follow UserService async/await pattern with try-catch error handling",
|
|
||||||
"JWT token generation uses JwtUtil with 1h access token and 7d refresh token expiry",
|
|
||||||
"All methods return typed responses (success/error objects)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Add JWT utilities",
|
|
||||||
file: "src/utils/jwt.ts",
|
|
||||||
action: "Create",
|
|
||||||
description: "Create JWT utility functions for token generation, verification, and refresh token handling",
|
|
||||||
implementation: [
|
|
||||||
"Define JwtUtil class with static methods for token operations",
|
|
||||||
"Implement generateToken(payload, expiresIn) method: create JWT with HS256 algorithm, embed user payload, set expiration",
|
|
||||||
"Implement verifyToken(token) method: decode JWT, validate signature against secret key, check expiration, return payload or throw error",
|
|
||||||
"Implement refreshToken(oldToken) method: verify old token, generate new access token with extended expiry",
|
|
||||||
"Add constants for token expiry times (ACCESS_TOKEN_EXPIRY=1h, REFRESH_TOKEN_EXPIRY=7d)"
|
|
||||||
],
|
|
||||||
reference: {
|
|
||||||
pattern: "Utility class pattern",
|
|
||||||
files: ["src/utils/crypto.util.ts", "src/utils/date.util.ts"],
|
|
||||||
examples: "Follow static method pattern from existing utils. Use environment variables for JWT_SECRET"
|
|
||||||
},
|
|
||||||
acceptance: [
|
|
||||||
"JwtUtil class created with generateToken(), verifyToken(), refreshToken() static methods",
|
|
||||||
"Token expiry constants defined and used correctly",
|
|
||||||
"Environment variable JWT_SECRET properly loaded and used",
|
|
||||||
"Error handling for invalid/expired tokens implemented"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Implement auth middleware",
|
|
||||||
file: "src/middleware/auth.middleware.ts",
|
|
||||||
action: "Create",
|
|
||||||
description: "Create Express middleware to authenticate requests using JWT tokens from Authorization header",
|
|
||||||
implementation: [
|
|
||||||
"Define authenticateRequest middleware function accepting (req, res, next) parameters",
|
|
||||||
"Extract JWT token from Authorization header (Bearer <token> format)",
|
|
||||||
"Call JwtUtil.verifyToken(token) to validate token and get user payload",
|
|
||||||
"Attach decoded user payload to req.user for downstream route handlers",
|
|
||||||
"Return 401 Unauthorized if token missing, invalid, or expired with appropriate error message"
|
|
||||||
],
|
|
||||||
reference: {
|
|
||||||
pattern: "Middleware function pattern",
|
|
||||||
files: ["src/middleware/cors.middleware.ts", "src/middleware/logging.middleware.ts"],
|
|
||||||
examples: "Follow Express middleware pattern with error handling. Use next() for successful validation, res.status(401).json() for failures"
|
|
||||||
},
|
|
||||||
acceptance: [
|
|
||||||
"authenticateRequest middleware function created and exported",
|
|
||||||
"Token extraction from Authorization header implemented",
|
|
||||||
"User payload attached to req.user on successful validation",
|
|
||||||
"Proper error responses (401) for missing/invalid tokens"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Protect API routes",
|
|
||||||
file: "src/routes/api.ts",
|
|
||||||
action: "Update",
|
|
||||||
description: "Apply authentication middleware to protected routes requiring user authentication",
|
|
||||||
implementation: [
|
|
||||||
"Import authenticateRequest middleware from src/middleware/auth.middleware.ts",
|
|
||||||
"Identify protected routes (user profile, settings, data modification endpoints)",
|
|
||||||
"Apply authenticateRequest middleware to protected routes using router.use() or per-route",
|
|
||||||
"Keep public routes (login, register, health check) without authentication",
|
|
||||||
"Update route documentation comments to indicate which routes require authentication"
|
|
||||||
],
|
|
||||||
reference: {
|
|
||||||
pattern: "Route middleware application",
|
|
||||||
files: ["src/routes/api.ts"],
|
|
||||||
examples: "Use router.use('/protected', authenticateRequest) for route groups or router.get('/profile', authenticateRequest, handler) for individual routes"
|
|
||||||
},
|
|
||||||
acceptance: [
|
|
||||||
"authenticateRequest middleware imported and applied to protected routes",
|
|
||||||
"Public routes (login, register) remain accessible without auth",
|
|
||||||
"Protected routes return 401 when accessed without valid token",
|
|
||||||
"Route documentation updated to indicate authentication requirements"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Create auth tests",
|
|
||||||
file: "tests/auth.test.ts",
|
|
||||||
action: "Create",
|
|
||||||
description: "Write comprehensive unit tests for AuthService methods covering success and error scenarios",
|
|
||||||
implementation: [
|
|
||||||
"Set up test file with imports for AuthService, test utilities, and mocks",
|
|
||||||
"Write tests for login() method: valid credentials, invalid credentials, database errors",
|
|
||||||
"Write tests for logout() method: valid token invalidation, invalid token handling",
|
|
||||||
"Write tests for validateToken() method: valid token, expired token, malformed token",
|
|
||||||
"Add test setup and teardown for database connection and test data"
|
|
||||||
],
|
|
||||||
reference: {
|
|
||||||
pattern: "Jest test pattern",
|
|
||||||
files: ["tests/users/user.service.test.ts", "tests/utils/jwt.test.ts"],
|
|
||||||
examples: "Follow existing test structure with describe/it blocks, beforeEach/afterEach hooks, and jest.mock() for dependencies"
|
|
||||||
},
|
|
||||||
acceptance: [
|
|
||||||
"Test file created with all AuthService methods covered",
|
|
||||||
"Success scenarios and error cases both tested",
|
|
||||||
"Test coverage for login, logout, validateToken methods >= 90%",
|
|
||||||
"All tests pass with proper assertions and mock usage"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
estimated_time: "3-4 hours (1h service + 30m utils + 1h middleware + 30m routes + 1h tests)",
|
|
||||||
recommended_execution: "Codex",
|
|
||||||
complexity: "Medium"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
7. **Return**: `{status: "success", planObject: {...}}` with 5 structured, actionable task objects
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ description: |
|
|||||||
commentary: Agent encapsulates CLI execution + result parsing + task generation
|
commentary: Agent encapsulates CLI execution + result parsing + task generation
|
||||||
|
|
||||||
- Context: Coverage gap analysis
|
- Context: Coverage gap analysis
|
||||||
user: "Analyze coverage gaps and generate补充test task"
|
user: "Analyze coverage gaps and generate supplement test task"
|
||||||
assistant: "Executing CLI analysis for uncovered code paths → Generating test supplement task"
|
assistant: "Executing CLI analysis for uncovered code paths → Generating test supplement task"
|
||||||
commentary: Agent handles both analysis and task JSON generation autonomously
|
commentary: Agent handles both analysis and task JSON generation autonomously
|
||||||
color: purple
|
color: purple
|
||||||
@@ -18,12 +18,11 @@ color: purple
|
|||||||
|
|
||||||
You are a specialized execution agent that bridges CLI analysis tools with task generation. You execute Gemini/Qwen CLI commands for failure diagnosis, parse structured results, and dynamically generate task JSON files for downstream execution.
|
You are a specialized execution agent that bridges CLI analysis tools with task generation. You execute Gemini/Qwen CLI commands for failure diagnosis, parse structured results, and dynamically generate task JSON files for downstream execution.
|
||||||
|
|
||||||
## Core Responsibilities
|
**Core capabilities:**
|
||||||
|
- Execute CLI analysis with appropriate templates and context
|
||||||
1. **Execute CLI Analysis**: Run Gemini/Qwen with appropriate templates and context
|
- Parse structured results (fix strategies, root causes, modification points)
|
||||||
2. **Parse CLI Results**: Extract structured information (fix strategies, root causes, modification points)
|
- Generate task JSONs dynamically (IMPL-fix-N.json, IMPL-supplement-N.json)
|
||||||
3. **Generate Task JSONs**: Create IMPL-fix-N.json or IMPL-supplement-N.json dynamically
|
- Save detailed analysis reports (iteration-N-analysis.md)
|
||||||
4. **Save Analysis Reports**: Store detailed CLI output as iteration-N-analysis.md
|
|
||||||
|
|
||||||
## Execution Process
|
## Execution Process
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ You are a specialized execution agent that bridges CLI analysis tools with task
|
|||||||
"file": "tests/test_auth.py",
|
"file": "tests/test_auth.py",
|
||||||
"line": 45,
|
"line": 45,
|
||||||
"criticality": "high",
|
"criticality": "high",
|
||||||
"test_type": "integration" // ← NEW: L0: static, L1: unit, L2: integration, L3: e2e
|
"test_type": "integration" // L0: static, L1: unit, L2: integration, L3: e2e
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"error_messages": ["error1", "error2"],
|
"error_messages": ["error1", "error2"],
|
||||||
@@ -61,7 +60,7 @@ You are a specialized execution agent that bridges CLI analysis tools with task
|
|||||||
"tool": "gemini|qwen",
|
"tool": "gemini|qwen",
|
||||||
"model": "gemini-3-pro-preview-11-2025|qwen-coder-model",
|
"model": "gemini-3-pro-preview-11-2025|qwen-coder-model",
|
||||||
"template": "01-diagnose-bug-root-cause.txt",
|
"template": "01-diagnose-bug-root-cause.txt",
|
||||||
"timeout": 2400000,
|
"timeout": 2400000, // 40 minutes for analysis
|
||||||
"fallback": "qwen"
|
"fallback": "qwen"
|
||||||
},
|
},
|
||||||
"task_config": {
|
"task_config": {
|
||||||
@@ -79,16 +78,16 @@ You are a specialized execution agent that bridges CLI analysis tools with task
|
|||||||
Phase 1: CLI Analysis Execution
|
Phase 1: CLI Analysis Execution
|
||||||
1. Validate context package and extract failure context
|
1. Validate context package and extract failure context
|
||||||
2. Construct CLI command with appropriate template
|
2. Construct CLI command with appropriate template
|
||||||
3. Execute Gemini/Qwen CLI tool
|
3. Execute Gemini/Qwen CLI tool with layer-specific guidance
|
||||||
4. Handle errors and fallback to alternative tool if needed
|
4. Handle errors and fallback to alternative tool if needed
|
||||||
5. Save raw CLI output to .process/iteration-N-cli-output.txt
|
5. Save raw CLI output to .process/iteration-N-cli-output.txt
|
||||||
|
|
||||||
Phase 2: Results Parsing & Strategy Extraction
|
Phase 2: Results Parsing & Strategy Extraction
|
||||||
1. Parse CLI output for structured information:
|
1. Parse CLI output for structured information:
|
||||||
- Root cause analysis
|
- Root cause analysis (RCA)
|
||||||
- Fix strategy and approach
|
- Fix strategy and approach
|
||||||
- Modification points (files, functions, line numbers)
|
- Modification points (files, functions, line numbers)
|
||||||
- Expected outcome
|
- Expected outcome and verification steps
|
||||||
2. Extract quantified requirements:
|
2. Extract quantified requirements:
|
||||||
- Number of files to modify
|
- Number of files to modify
|
||||||
- Specific functions to fix (with line numbers)
|
- Specific functions to fix (with line numbers)
|
||||||
@@ -96,7 +95,7 @@ Phase 2: Results Parsing & Strategy Extraction
|
|||||||
3. Generate structured analysis report (iteration-N-analysis.md)
|
3. Generate structured analysis report (iteration-N-analysis.md)
|
||||||
|
|
||||||
Phase 3: Task JSON Generation
|
Phase 3: Task JSON Generation
|
||||||
1. Load task JSON template (defined below)
|
1. Load task JSON template
|
||||||
2. Populate template with parsed CLI results
|
2. Populate template with parsed CLI results
|
||||||
3. Add iteration context and previous attempts
|
3. Add iteration context and previous attempts
|
||||||
4. Write task JSON to .workflow/{session}/.task/IMPL-fix-N.json
|
4. Write task JSON to .workflow/{session}/.task/IMPL-fix-N.json
|
||||||
@@ -105,9 +104,9 @@ Phase 3: Task JSON Generation
|
|||||||
|
|
||||||
## Core Functions
|
## Core Functions
|
||||||
|
|
||||||
### 1. CLI Command Construction
|
### 1. CLI Analysis Execution
|
||||||
|
|
||||||
**Template-Based Approach with Test Layer Awareness**:
|
**Template-Based Command Construction with Test Layer Awareness**:
|
||||||
```bash
|
```bash
|
||||||
cd {project_root} && {cli_tool} -p "
|
cd {project_root} && {cli_tool} -p "
|
||||||
PURPOSE: Analyze {test_type} test failures and generate fix strategy for iteration {iteration}
|
PURPOSE: Analyze {test_type} test failures and generate fix strategy for iteration {iteration}
|
||||||
@@ -151,8 +150,9 @@ const layerGuidance = {
|
|||||||
const guidance = layerGuidance[test_type] || "Analyze holistically, avoid quick patches";
|
const guidance = layerGuidance[test_type] || "Analyze holistically, avoid quick patches";
|
||||||
```
|
```
|
||||||
|
|
||||||
**Error Handling & Fallback**:
|
**Error Handling & Fallback Strategy**:
|
||||||
```javascript
|
```javascript
|
||||||
|
// Primary execution with fallback chain
|
||||||
try {
|
try {
|
||||||
result = executeCLI("gemini", config);
|
result = executeCLI("gemini", config);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -173,16 +173,18 @@ try {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback strategy when all CLI tools fail
|
||||||
|
function generateBasicFixStrategy(failure_context) {
|
||||||
|
// Generate basic fix task based on error pattern matching
|
||||||
|
// Use previous successful fix patterns from fix-history.json
|
||||||
|
// Limit to simple, low-risk fixes (add null checks, fix typos)
|
||||||
|
// Mark task with meta.analysis_quality: "degraded" flag
|
||||||
|
// Orchestrator will treat degraded analysis with caution
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Fallback Strategy (When All CLI Tools Fail)**:
|
### 2. Output Parsing & Task Generation
|
||||||
- Generate basic fix task based on error patterns matching
|
|
||||||
- Use previous successful fix patterns from fix-history.json
|
|
||||||
- Limit to simple, low-risk fixes (add null checks, fix typos)
|
|
||||||
- Mark task with `meta.analysis_quality: "degraded"` flag
|
|
||||||
- Orchestrator will treat degraded analysis with caution (may skip iteration)
|
|
||||||
|
|
||||||
### 2. CLI Output Parsing
|
|
||||||
|
|
||||||
**Expected CLI Output Structure** (from bug diagnosis template):
|
**Expected CLI Output Structure** (from bug diagnosis template):
|
||||||
```markdown
|
```markdown
|
||||||
@@ -220,18 +222,34 @@ try {
|
|||||||
```javascript
|
```javascript
|
||||||
const parsedResults = {
|
const parsedResults = {
|
||||||
root_causes: extractSection("根本原因分析"),
|
root_causes: extractSection("根本原因分析"),
|
||||||
modification_points: extractModificationPoints(),
|
modification_points: extractModificationPoints(), // Returns: ["file:function:lines", ...]
|
||||||
fix_strategy: {
|
fix_strategy: {
|
||||||
approach: extractSection("详细修复建议"),
|
approach: extractSection("详细修复建议"),
|
||||||
files: extractFilesList(),
|
files: extractFilesList(),
|
||||||
expected_outcome: extractSection("验证建议")
|
expected_outcome: extractSection("验证建议")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Extract structured modification points
|
||||||
|
function extractModificationPoints() {
|
||||||
|
const points = [];
|
||||||
|
const filePattern = /- (.+?\.(?:ts|js|py)) \(lines (\d+-\d+)\): (.+)/g;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((match = filePattern.exec(cliOutput)) !== null) {
|
||||||
|
points.push({
|
||||||
|
file: match[1],
|
||||||
|
lines: match[2],
|
||||||
|
function: match[3],
|
||||||
|
formatted: `${match[1]}:${match[3]}:${match[2]}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return points;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Task JSON Generation (Template Definition)
|
**Task JSON Generation** (Simplified Template):
|
||||||
|
|
||||||
**Task JSON Template for IMPL-fix-N** (Simplified):
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "IMPL-fix-{iteration}",
|
"id": "IMPL-fix-{iteration}",
|
||||||
@@ -284,9 +302,7 @@ const parsedResults = {
|
|||||||
{
|
{
|
||||||
"step": "load_analysis_context",
|
"step": "load_analysis_context",
|
||||||
"action": "Load CLI analysis report for full failure context if needed",
|
"action": "Load CLI analysis report for full failure context if needed",
|
||||||
"commands": [
|
"commands": ["Read({meta.analysis_report})"],
|
||||||
"Read({meta.analysis_report})"
|
|
||||||
],
|
|
||||||
"output_to": "full_failure_analysis",
|
"output_to": "full_failure_analysis",
|
||||||
"note": "Analysis report contains: failed_tests, error_messages, pass_rate, root causes, previous_attempts"
|
"note": "Analysis report contains: failed_tests, error_messages, pass_rate, root causes, previous_attempts"
|
||||||
}
|
}
|
||||||
@@ -334,19 +350,17 @@ const parsedResults = {
|
|||||||
|
|
||||||
**Template Variables Replacement**:
|
**Template Variables Replacement**:
|
||||||
- `{iteration}`: From context.iteration
|
- `{iteration}`: From context.iteration
|
||||||
- `{test_type}`: Dominant test type from failed_tests (e.g., "integration", "unit")
|
- `{test_type}`: Dominant test type from failed_tests
|
||||||
- `{dominant_test_type}`: Most common test_type in failed_tests array
|
- `{dominant_test_type}`: Most common test_type in failed_tests array
|
||||||
- `{layer_specific_approach}`: Guidance based on test layer from layerGuidance map
|
- `{layer_specific_approach}`: Guidance from layerGuidance map
|
||||||
- `{fix_summary}`: First 50 chars of fix_strategy.approach
|
- `{fix_summary}`: First 50 chars of fix_strategy.approach
|
||||||
- `{failed_tests.length}`: Count of failures
|
- `{failed_tests.length}`: Count of failures
|
||||||
- `{modification_points.length}`: Count of modification points
|
- `{modification_points.length}`: Count of modification points
|
||||||
- `{modification_points}`: Array of file:function:lines from parsed CLI output
|
- `{modification_points}`: Array of file:function:lines
|
||||||
- `{timestamp}`: ISO 8601 timestamp
|
- `{timestamp}`: ISO 8601 timestamp
|
||||||
- `{parent_task_id}`: ID of the parent test task (e.g., "IMPL-002")
|
- `{parent_task_id}`: ID of parent test task
|
||||||
- `{file1}`, `{file2}`, etc.: Specific file paths from modification_points
|
|
||||||
- `{specific_change_1}`, etc.: Change descriptions for each modification point
|
|
||||||
|
|
||||||
### 4. Analysis Report Generation
|
### 3. Analysis Report Generation
|
||||||
|
|
||||||
**Structure of iteration-N-analysis.md**:
|
**Structure of iteration-N-analysis.md**:
|
||||||
```markdown
|
```markdown
|
||||||
@@ -373,6 +387,7 @@ pass_rate: {pass_rate}%
|
|||||||
- **Error**: {test.error}
|
- **Error**: {test.error}
|
||||||
- **File**: {test.file}:{test.line}
|
- **File**: {test.file}:{test.line}
|
||||||
- **Criticality**: {test.criticality}
|
- **Criticality**: {test.criticality}
|
||||||
|
- **Test Type**: {test.test_type}
|
||||||
{endforeach}
|
{endforeach}
|
||||||
|
|
||||||
## Root Cause Analysis
|
## Root Cause Analysis
|
||||||
@@ -403,15 +418,16 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
|||||||
|
|
||||||
### CLI Execution Standards
|
### CLI Execution Standards
|
||||||
- **Timeout Management**: Use dynamic timeout (2400000ms = 40min for analysis)
|
- **Timeout Management**: Use dynamic timeout (2400000ms = 40min for analysis)
|
||||||
- **Fallback Chain**: Gemini → Qwen (if Gemini fails with 429/404)
|
- **Fallback Chain**: Gemini → Qwen → degraded mode (if both fail)
|
||||||
- **Error Context**: Include full error details in failure reports
|
- **Error Context**: Include full error details in failure reports
|
||||||
- **Output Preservation**: Save raw CLI output for debugging
|
- **Output Preservation**: Save raw CLI output to .process/ for debugging
|
||||||
|
|
||||||
### Task JSON Standards
|
### Task JSON Standards
|
||||||
- **Quantification**: All requirements must include counts and explicit lists
|
- **Quantification**: All requirements must include counts and explicit lists
|
||||||
- **Specificity**: Modification points must have file:function:line format
|
- **Specificity**: Modification points must have file:function:line format
|
||||||
- **Measurability**: Acceptance criteria must include verification commands
|
- **Measurability**: Acceptance criteria must include verification commands
|
||||||
- **Traceability**: Link to analysis reports and CLI output files
|
- **Traceability**: Link to analysis reports and CLI output files
|
||||||
|
- **Minimal Redundancy**: Use references (analysis_report) instead of embedding full context
|
||||||
|
|
||||||
### Analysis Report Standards
|
### Analysis Report Standards
|
||||||
- **Structured Format**: Use consistent markdown sections
|
- **Structured Format**: Use consistent markdown sections
|
||||||
@@ -430,19 +446,23 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
|||||||
- **Link files properly**: Use relative paths from session root
|
- **Link files properly**: Use relative paths from session root
|
||||||
- **Preserve CLI output**: Save raw output to .process/ for debugging
|
- **Preserve CLI output**: Save raw output to .process/ for debugging
|
||||||
- **Generate measurable acceptance criteria**: Include verification commands
|
- **Generate measurable acceptance criteria**: Include verification commands
|
||||||
|
- **Apply layer-specific guidance**: Use test_type to customize analysis approach
|
||||||
|
|
||||||
**NEVER:**
|
**NEVER:**
|
||||||
- Execute tests directly (orchestrator manages test execution)
|
- Execute tests directly (orchestrator manages test execution)
|
||||||
- Skip CLI analysis (always run CLI even for simple failures)
|
- Skip CLI analysis (always run CLI even for simple failures)
|
||||||
- Modify files directly (generate task JSON for @test-fix-agent to execute)
|
- Modify files directly (generate task JSON for @test-fix-agent to execute)
|
||||||
- **Embed redundant data in task JSON** (use analysis_report reference instead)
|
- Embed redundant data in task JSON (use analysis_report reference instead)
|
||||||
- **Copy input context verbatim to output** (creates data duplication)
|
- Copy input context verbatim to output (creates data duplication)
|
||||||
- Generate vague modification points (always specify file:function:lines)
|
- Generate vague modification points (always specify file:function:lines)
|
||||||
- Exceed timeout limits (use configured timeout value)
|
- Exceed timeout limits (use configured timeout value)
|
||||||
|
- Ignore test layer context (L0/L1/L2/L3 determines diagnosis approach)
|
||||||
|
|
||||||
## CLI Tool Configuration
|
## Configuration & Examples
|
||||||
|
|
||||||
### Gemini Configuration
|
### CLI Tool Configuration
|
||||||
|
|
||||||
|
**Gemini Configuration**:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
"tool": "gemini",
|
"tool": "gemini",
|
||||||
@@ -452,11 +472,12 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
|||||||
"test-failure": "01-diagnose-bug-root-cause.txt",
|
"test-failure": "01-diagnose-bug-root-cause.txt",
|
||||||
"coverage-gap": "02-analyze-code-patterns.txt",
|
"coverage-gap": "02-analyze-code-patterns.txt",
|
||||||
"regression": "01-trace-code-execution.txt"
|
"regression": "01-trace-code-execution.txt"
|
||||||
}
|
},
|
||||||
|
"timeout": 2400000 // 40 minutes
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Qwen Configuration (Fallback)
|
**Qwen Configuration (Fallback)**:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
"tool": "qwen",
|
"tool": "qwen",
|
||||||
@@ -464,11 +485,12 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
|||||||
"templates": {
|
"templates": {
|
||||||
"test-failure": "01-diagnose-bug-root-cause.txt",
|
"test-failure": "01-diagnose-bug-root-cause.txt",
|
||||||
"coverage-gap": "02-analyze-code-patterns.txt"
|
"coverage-gap": "02-analyze-code-patterns.txt"
|
||||||
}
|
},
|
||||||
|
"timeout": 2400000 // 40 minutes
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example Execution
|
### Example Execution
|
||||||
|
|
||||||
**Input Context**:
|
**Input Context**:
|
||||||
```json
|
```json
|
||||||
@@ -494,26 +516,35 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
|||||||
"cli_config": {
|
"cli_config": {
|
||||||
"tool": "gemini",
|
"tool": "gemini",
|
||||||
"template": "01-diagnose-bug-root-cause.txt"
|
"template": "01-diagnose-bug-root-cause.txt"
|
||||||
|
},
|
||||||
|
"task_config": {
|
||||||
|
"agent": "@test-fix-agent",
|
||||||
|
"type": "test-fix-iteration",
|
||||||
|
"max_iterations": 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Execution Steps**:
|
**Execution Summary**:
|
||||||
1. Detect test_type: "integration" → Apply integration-specific diagnosis
|
1. **Detect test_type**: "integration" → Apply integration-specific diagnosis
|
||||||
2. Execute: `gemini -p "PURPOSE: Analyze integration test failure... [layer-specific context]"`
|
2. **Execute CLI**:
|
||||||
- CLI prompt includes: "Examine component interactions, data flow, interface contracts"
|
```bash
|
||||||
- Guidance: "Analyze full call stack and data flow across components"
|
gemini -p "PURPOSE: Analyze integration test failure...
|
||||||
3. Parse: Extract RCA, 修复建议, 验证建议 sections
|
TASK: Examine component interactions, data flow, interface contracts...
|
||||||
4. Generate: IMPL-fix-1.json (SIMPLIFIED) with:
|
RULES: Analyze full call stack and data flow across components"
|
||||||
|
```
|
||||||
|
3. **Parse Output**: Extract RCA, 修复建议, 验证建议 sections
|
||||||
|
4. **Generate Task JSON** (IMPL-fix-1.json):
|
||||||
- Title: "Fix integration test failures - Iteration 1: Token expiry validation"
|
- Title: "Fix integration test failures - Iteration 1: Token expiry validation"
|
||||||
- meta.analysis_report: ".process/iteration-1-analysis.md" (Reference, not embedded data)
|
- meta.analysis_report: ".process/iteration-1-analysis.md" (reference)
|
||||||
- meta.test_layer: "integration"
|
- meta.test_layer: "integration"
|
||||||
- Requirements: "Fix 1 integration test failures by applying the provided fix strategy"
|
- Requirements: "Fix 1 integration test failures by applying provided fix strategy"
|
||||||
- fix_strategy.modification_points: ["src/auth/auth.service.ts:validateToken:45-60", "src/middleware/auth.middleware.ts:checkExpiry:120-135"]
|
- fix_strategy.modification_points:
|
||||||
|
- "src/auth/auth.service.ts:validateToken:45-60"
|
||||||
|
- "src/middleware/auth.middleware.ts:checkExpiry:120-135"
|
||||||
- fix_strategy.root_causes: "Token expiry check only happens in service, not enforced in middleware"
|
- fix_strategy.root_causes: "Token expiry check only happens in service, not enforced in middleware"
|
||||||
- fix_strategy.quality_assurance: {avoids_symptom_fix: true, addresses_root_cause: true}
|
- fix_strategy.quality_assurance: {avoids_symptom_fix: true, addresses_root_cause: true}
|
||||||
- **NO failure_context object** - full context available via analysis_report reference
|
5. **Save Analysis Report**: iteration-1-analysis.md with full CLI output, layer context, failed_tests details
|
||||||
5. Save: iteration-1-analysis.md with full CLI output, layer context, failed_tests details, previous_attempts
|
|
||||||
6. **Return**:
|
6. **Return**:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user