mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -186,7 +186,7 @@ if (contextPackage.brainstorm_artifacts?.role_analyses?.length > 0) {
|
||||
- Add quantified requirements and measurable acceptance criteria
|
||||
|
||||
3. Create IMPL_PLAN.md
|
||||
- Load template: Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)
|
||||
- Load template: Read(~/.ccw/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)
|
||||
- Follow template structure and validation checklist
|
||||
- Populate all 8 sections with synthesized context
|
||||
- Document CCW workflow phase progression
|
||||
@@ -661,7 +661,7 @@ The `implementation_approach` defines sequential implementation steps. Execution
|
||||
**Template-Based Generation**:
|
||||
|
||||
```
|
||||
1. Load template: Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)
|
||||
1. Load template: Read(~/.ccw/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)
|
||||
2. Populate all sections following template structure
|
||||
3. Complete template validation checklist
|
||||
4. Generate at .workflow/active/{session_id}/IMPL_PLAN.md
|
||||
@@ -852,7 +852,7 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
- **Record N+1 Context**: Update `## N+1 Context` section with key decisions and deferred items
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Apply Quantification Requirements to all requirements, acceptance criteria, and modification points
|
||||
- Load IMPL_PLAN template: `Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)` before generating IMPL_PLAN.md
|
||||
- Load IMPL_PLAN template: `Read(~/.ccw/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)` before generating IMPL_PLAN.md
|
||||
- Use provided context package: Extract all information from structured context
|
||||
- Respect memory-first rule: Use provided content (already loaded from memory/file)
|
||||
- Follow 6-field schema: All task JSONs must have id, title, status, context_package_path, meta, context, flow_control
|
||||
|
||||
@@ -14,13 +14,13 @@ You are an intelligent CLI execution specialist that autonomously orchestrates c
|
||||
2. **Qwen (Fallback)** - Same capabilities as Gemini, use when unavailable
|
||||
3. **Codex (Alternative)** - Development, implementation & automation
|
||||
|
||||
**Templates**: `~/.claude/workflows/cli-templates/prompts/`
|
||||
**Templates**: `~/.ccw/workflows/cli-templates/prompts/`
|
||||
- `analysis/` - pattern.txt, architecture.txt, code-execution-tracing.txt, security.txt, quality.txt
|
||||
- `development/` - feature.txt, refactor.txt, testing.txt, bug-diagnosis.txt
|
||||
- `planning/` - task-breakdown.txt, architecture-planning.txt
|
||||
- `memory/` - claude-module-unified.txt
|
||||
|
||||
**Reference**: See `~/.claude/workflows/intelligent-tools-strategy.md` for complete usage guide
|
||||
**Reference**: See `~/.ccw/workflows/intelligent-tools-strategy.md` for complete usage guide
|
||||
|
||||
## 5-Phase Execution Workflow
|
||||
|
||||
@@ -129,7 +129,7 @@ CONTEXT: @CLAUDE.md @src/**/* @*.ts
|
||||
CONTEXT: @**/* @../shared/**/* @../types/**/*
|
||||
```
|
||||
|
||||
**2. Template Selection** (`~/.claude/workflows/cli-templates/prompts/`):
|
||||
**2. Template Selection** (`~/.ccw/workflows/cli-templates/prompts/`):
|
||||
```
|
||||
analyze → analysis/code-execution-tracing.txt | analysis/pattern.txt
|
||||
execute → development/feature.txt
|
||||
@@ -308,7 +308,7 @@ Codex unavailable → Gemini/Qwen write mode
|
||||
|
||||
## Templates Reference
|
||||
|
||||
**Location**: `~/.claude/workflows/cli-templates/prompts/`
|
||||
**Location**: `~/.ccw/workflows/cli-templates/prompts/`
|
||||
|
||||
**Analysis** (`analysis/`):
|
||||
- `pattern.txt` - Code pattern analysis
|
||||
|
||||
@@ -77,24 +77,24 @@ if [[ -n "$TASK_JSON_TECH_STACK" ]]; then
|
||||
# Map tech stack names to guideline files
|
||||
# e.g., ["FastAPI", "SQLAlchemy"] → python-dev.md
|
||||
case "$TASK_JSON_TECH_STACK" in
|
||||
*FastAPI*|*Django*|*SQLAlchemy*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md) ;;
|
||||
*React*|*Next*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md) ;;
|
||||
*TypeScript*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md) ;;
|
||||
*FastAPI*|*Django*|*SQLAlchemy*) TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/python-dev.md) ;;
|
||||
*React*|*Next*) TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/react-dev.md) ;;
|
||||
*TypeScript*) TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/typescript-dev.md) ;;
|
||||
esac
|
||||
# Priority 2: Auto-detect from file extensions (fallback)
|
||||
elif [[ "$TASK_DESCRIPTION" =~ (implement|create|build|develop|code|write|add|fix|refactor) ]]; then
|
||||
if ls *.ts *.tsx 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/typescript-dev.md)
|
||||
elif grep -q "react" package.json 2>/dev/null; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/react-dev.md)
|
||||
elif ls *.py requirements.txt 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/python-dev.md)
|
||||
elif ls *.java pom.xml build.gradle 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/java-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/java-dev.md)
|
||||
elif ls *.go go.mod 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/go-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/go-dev.md)
|
||||
elif ls *.js package.json 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/javascript-dev.md)
|
||||
TECH_GUIDELINES=$(cat ~/.ccw/workflows/cli-templates/tech-stacks/javascript-dev.md)
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
@@ -70,7 +70,7 @@ def handle_brainstorm_assignment(prompt):
|
||||
|
||||
# Execute role template loading via $(cat template)
|
||||
if step_name == "load_role_template":
|
||||
processed_command = f"bash($(cat ~/.claude/workflows/cli-templates/planning-roles/{role}.md))"
|
||||
processed_command = f"bash($(cat ~/.ccw/workflows/cli-templates/planning-roles/{role}.md))"
|
||||
else:
|
||||
processed_command = process_context_variables(command, context_vars)
|
||||
|
||||
@@ -106,7 +106,7 @@ This agent processes **simplified inline [FLOW_CONTROL]** format from brainstorm
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load role-specific planning template
|
||||
- Command: bash($(cat "~/.claude/workflows/cli-templates/planning-roles/{role}.md"))
|
||||
- Command: bash($(cat "~/.ccw/workflows/cli-templates/planning-roles/{role}.md"))
|
||||
- Output: role_template
|
||||
|
||||
3. **load_session_metadata**
|
||||
@@ -165,7 +165,7 @@ When called, you receive:
|
||||
**Auto Brainstorm Integration**: Role assignment comes from auto.md workflow:
|
||||
1. **Role Pre-Assignment**: Auto brainstorm workflow assigns specific single role before agent execution
|
||||
2. **Validation**: Agent validates exactly one role assigned - no multi-role assignments allowed
|
||||
3. **Template Loading**: Use `$(cat ~/.claude/workflows/cli-templates/planning-roles/<assigned-role>.md)` for role template
|
||||
3. **Template Loading**: Use `$(cat ~/.ccw/workflows/cli-templates/planning-roles/<assigned-role>.md)` for role template
|
||||
4. **Output Directory**: Use designated `.brainstorming/[role]/` directory for role-specific outputs
|
||||
|
||||
### Role Options Include:
|
||||
@@ -190,7 +190,7 @@ When called, you receive:
|
||||
### Role Template Integration
|
||||
Documentation formats and structures are defined in role-specific templates loaded via:
|
||||
```bash
|
||||
$(cat ~/.claude/workflows/cli-templates/planning-roles/<assigned-role>.md)
|
||||
$(cat ~/.ccw/workflows/cli-templates/planning-roles/<assigned-role>.md)
|
||||
```
|
||||
|
||||
Each planning role template contains:
|
||||
|
||||
@@ -320,7 +320,7 @@ You execute 6 distinct task types organized into 3 patterns. Each task includes
|
||||
|
||||
### design-tokens.json
|
||||
|
||||
**Template Reference**: `~/.claude/workflows/cli-templates/ui-design/systems/design-tokens.json`
|
||||
**Template Reference**: `~/.ccw/workflows/cli-templates/ui-design/systems/design-tokens.json`
|
||||
|
||||
**Format**: W3C Design Tokens Community Group Specification
|
||||
|
||||
@@ -385,7 +385,7 @@ You execute 6 distinct task types organized into 3 patterns. Each task includes
|
||||
|
||||
### layout-templates.json
|
||||
|
||||
**Template Reference**: `~/.claude/workflows/cli-templates/ui-design/systems/layout-templates.json`
|
||||
**Template Reference**: `~/.ccw/workflows/cli-templates/ui-design/systems/layout-templates.json`
|
||||
|
||||
**Optimization**: Unified structure combining DOM and styling into single hierarchy
|
||||
|
||||
@@ -426,7 +426,7 @@ You execute 6 distinct task types organized into 3 patterns. Each task includes
|
||||
|
||||
### animation-tokens.json
|
||||
|
||||
**Template Reference**: `~/.claude/workflows/cli-templates/ui-design/systems/animation-tokens.json`
|
||||
**Template Reference**: `~/.ccw/workflows/cli-templates/ui-design/systems/animation-tokens.json`
|
||||
|
||||
**Structure Overview**:
|
||||
- **duration**: instant (0ms), fast (150ms), normal (300ms), slow (500ms), slower (1000ms)
|
||||
|
||||
@@ -134,7 +134,7 @@ Discover potential ${perspective} issues in specified module files.
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read discovery state: ${outputDir}/discovery-state.json
|
||||
2. Read schema: ~/.codex/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
2. Read schema: ~/.ccw/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
3. Analyze target files for ${perspective} concerns
|
||||
|
||||
## Output Requirements
|
||||
@@ -335,8 +335,8 @@ function getPerspectiveGuidance(perspective) {
|
||||
|
||||
| Schema | Path | Purpose |
|
||||
|--------|------|---------|
|
||||
| **Discovery State** | `~/.codex/workflows/cli-templates/schemas/discovery-state-schema.json` | Session state machine |
|
||||
| **Discovery Finding** | `~/.codex/workflows/cli-templates/schemas/discovery-finding-schema.json` | Perspective analysis results |
|
||||
| **Discovery State** | `~/.ccw/workflows/cli-templates/schemas/discovery-state-schema.json` | Session state machine |
|
||||
| **Discovery Finding** | `~/.ccw/workflows/cli-templates/schemas/discovery-finding-schema.json` | Perspective analysis results |
|
||||
|
||||
## Error Handling
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ ${summarizePreviousFindings(previousFindings, dimension.name)}
|
||||
` : ''}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read schema: ~/.codex/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
1. Read schema: ~/.ccw/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
2. Review ACE results above for starting points
|
||||
3. Explore files identified by ACE
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Before starting execution, load project context:
|
||||
|
||||
1. **Read project tech stack**: `.workflow/project-tech.json`
|
||||
2. **Read project guidelines**: `.workflow/project-guidelines.json`
|
||||
3. **Read solution schema**: `~/.claude/workflows/cli-templates/schemas/solution-schema.json`
|
||||
3. **Read solution schema**: `~/.ccw/workflows/cli-templates/schemas/solution-schema.json`
|
||||
|
||||
This ensures execution follows project conventions and patterns.
|
||||
|
||||
|
||||
@@ -63,12 +63,12 @@ const CATEGORIES = {
|
||||
**Agent-produced JSON files follow standardized schemas**:
|
||||
|
||||
1. **Dimension Results** (cli-explore-agent output from parallel reviews)
|
||||
- Schema: `~/.codex/workflows/cli-templates/schemas/review-dimension-results-schema.json`
|
||||
- Schema: `~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json`
|
||||
- Output: `{output-dir}/dimensions/{dimension}.json`
|
||||
- Contains: findings array, summary statistics, cross_references
|
||||
|
||||
2. **Deep-Dive Results** (cli-explore-agent output from iterations)
|
||||
- Schema: `~/.codex/workflows/cli-templates/schemas/review-deep-dive-results-schema.json`
|
||||
- Schema: `~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json`
|
||||
- Output: `{output-dir}/iterations/iteration-{N}-finding-{uuid}.json`
|
||||
- Contains: root_cause, remediation_plan, impact_assessment, reassessed_severity
|
||||
|
||||
@@ -93,7 +93,7 @@ dimensions.forEach(dimension => {
|
||||
2. Read review state: ${reviewStateJsonPath}
|
||||
3. Get target files: Read resolved_files from review-state.json
|
||||
4. Validate file access: bash(ls -la ${targetFiles.join(' ')})
|
||||
5. Execute: cat ~/.codex/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
5. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
6. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
7. Read: .workflow/project-guidelines.json (user-defined constraints and conventions to validate against)
|
||||
|
||||
@@ -216,7 +216,7 @@ dimensions.forEach(dimension => {
|
||||
3. Read completed task summaries: bash(find ${summariesDir} -name "IMPL-*.md" -type f)
|
||||
4. Get changed files: bash(cd ${workflowDir} && git log --since="${sessionCreatedAt}" --name-only --pretty=format: | sort -u)
|
||||
5. Read review state: ${reviewStateJsonPath}
|
||||
6. Execute: cat ~/.codex/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
6. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
7. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
8. Read: .workflow/project-guidelines.json (user-defined constraints and conventions to validate against)
|
||||
|
||||
@@ -240,7 +240,7 @@ Use **Deep Scan mode** for this review:
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex (fallback chain)
|
||||
- Template: ~/.codex/workflows/cli-templates/prompts/analysis/${dimensionTemplate}
|
||||
- Template: ~/.ccw/workflows/cli-templates/prompts/analysis/${dimensionTemplate}
|
||||
- Custom Focus: ${customFocus || 'Standard dimension analysis'}
|
||||
- Timeout: ${timeout}ms
|
||||
- Mode: analysis (READ-ONLY)
|
||||
@@ -335,7 +335,7 @@ const deepDiveAgentId = spawn_agent({
|
||||
3. Read affected file: ${file}
|
||||
4. Identify related code: bash(grep -r "import.*${basename(file)}" ${projectDir}/src --include="*.ts")
|
||||
5. Read test files: bash(find ${projectDir}/tests -name "*${basename(file, '.ts')}*" -type f)
|
||||
6. Execute: cat ~/.codex/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
6. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
7. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
8. Read: .workflow/project-guidelines.json (user-defined constraints for remediation compliance)
|
||||
|
||||
@@ -367,7 +367,7 @@ Then apply **Deep Scan mode** for semantic analysis:
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex
|
||||
- Template: ~/.codex/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Template: ~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Mode: analysis (READ-ONLY)
|
||||
|
||||
## Expected Deliverables
|
||||
|
||||
@@ -88,7 +88,7 @@ selectedFindings.forEach(finding => {
|
||||
3. Read affected file: ${finding.file}
|
||||
4. Identify related code: bash(grep -r "import.*${basename(finding.file)}" ${projectDir}/src --include="*.ts")
|
||||
5. Read test files: bash(find ${projectDir}/tests -name "*${basename(finding.file, '.ts')}*" -type f)
|
||||
6. Execute: cat ~/.codex/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
6. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
7. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
8. Read: .workflow/project-guidelines.json (user-defined constraints for remediation compliance)
|
||||
|
||||
@@ -120,7 +120,7 @@ Then apply **Deep Scan mode** for semantic analysis:
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex
|
||||
- Template: ~/.codex/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Template: ~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Mode: analysis (READ-ONLY)
|
||||
|
||||
## Expected Deliverables
|
||||
@@ -199,7 +199,7 @@ selectedFindings.forEach(finding => {
|
||||
3. Read affected file: ${finding.file}
|
||||
4. Identify related code: bash(grep -r "import.*${basename(finding.file)}" ${workflowDir}/src --include="*.ts")
|
||||
5. Read test files: bash(find ${workflowDir}/tests -name "*${basename(finding.file, '.ts')}*" -type f)
|
||||
6. Execute: cat ~/.codex/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
6. Execute: cat ~/.ccw/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
7. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
8. Read: .workflow/project-guidelines.json (user-defined constraints for remediation compliance)
|
||||
|
||||
@@ -231,7 +231,7 @@ Then apply **Deep Scan mode** for semantic analysis:
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex
|
||||
- Template: ~/.codex/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Template: ~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
|
||||
- Timeout: 2400000ms (40 minutes)
|
||||
- Mode: analysis (READ-ONLY)
|
||||
|
||||
|
||||
@@ -116,63 +116,63 @@ const roleConfig = {
|
||||
focus_area: 'User research, information architecture, user journey',
|
||||
question_categories: ['User Intent', 'Requirements', 'UX'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/ux-expert.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/ux-expert.md'
|
||||
},
|
||||
'ui-designer': {
|
||||
title: 'UI设计师',
|
||||
focus_area: 'Visual design, high-fidelity mockups, design systems',
|
||||
question_categories: ['Requirements', 'UX', 'Feasibility'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/ui-designer.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/ui-designer.md'
|
||||
},
|
||||
'system-architect': {
|
||||
title: '系统架构师',
|
||||
focus_area: 'Technical architecture, scalability, integration patterns',
|
||||
question_categories: ['Scale & Performance', 'Technical Constraints', 'Architecture Complexity', 'Non-Functional Requirements'],
|
||||
question_count: 5,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/system-architect.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/system-architect.md'
|
||||
},
|
||||
'product-manager': {
|
||||
title: '产品经理',
|
||||
focus_area: 'Product strategy, roadmap, prioritization',
|
||||
question_categories: ['User Intent', 'Requirements', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/product-manager.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/product-manager.md'
|
||||
},
|
||||
'product-owner': {
|
||||
title: '产品负责人',
|
||||
focus_area: 'Backlog management, user stories, acceptance criteria',
|
||||
question_categories: ['Requirements', 'Decisions', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/product-owner.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/product-owner.md'
|
||||
},
|
||||
'scrum-master': {
|
||||
title: '敏捷教练',
|
||||
focus_area: 'Process facilitation, impediment removal, team dynamics',
|
||||
question_categories: ['Process', 'Risk', 'Decisions'],
|
||||
question_count: 3,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/scrum-master.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/scrum-master.md'
|
||||
},
|
||||
'subject-matter-expert': {
|
||||
title: '领域专家',
|
||||
focus_area: 'Domain knowledge, business rules, compliance',
|
||||
question_categories: ['Requirements', 'Feasibility', 'Terminology'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/subject-matter-expert.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/subject-matter-expert.md'
|
||||
},
|
||||
'data-architect': {
|
||||
title: '数据架构师',
|
||||
focus_area: 'Data models, storage strategies, data flow',
|
||||
question_categories: ['Architecture', 'Scale & Performance', 'Technical Constraints', 'Feasibility'],
|
||||
question_count: 5,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/data-architect.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/data-architect.md'
|
||||
},
|
||||
'api-designer': {
|
||||
title: 'API设计师',
|
||||
focus_area: 'API contracts, versioning, integration patterns',
|
||||
question_categories: ['Architecture', 'Requirements', 'Feasibility', 'Decisions'],
|
||||
question_count: 4,
|
||||
template: '~/.codex/workflows/cli-templates/planning-roles/api-designer.md'
|
||||
template: '~/.ccw/workflows/cli-templates/planning-roles/api-designer.md'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -747,7 +747,7 @@ try {
|
||||
## Reference Information
|
||||
|
||||
### Role Template Locations
|
||||
- Templates: `~/.codex/workflows/cli-templates/planning-roles/`
|
||||
- Templates: `~/.ccw/workflows/cli-templates/planning-roles/`
|
||||
- Format: `{role-name}.md` (e.g., `ux-expert.md`, `system-architect.md`)
|
||||
|
||||
### Context Package
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
# Phase 4: Lite Execute
|
||||
# Phase 2: Lite Execute
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -46,50 +46,16 @@ Flexible task execution phase supporting three input modes: in-memory plan (from
|
||||
- Proceed to execution with `originalUserInput` included
|
||||
|
||||
**User Interaction**:
|
||||
```javascript
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
let userSelection
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Use defaults
|
||||
console.log(`[--yes] Auto-confirming execution:`)
|
||||
console.log(` - Execution method: Auto`)
|
||||
console.log(` - Code review: Skip`)
|
||||
|
||||
userSelection = {
|
||||
execution_method: "Auto",
|
||||
code_review_tool: "Skip"
|
||||
}
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
userSelection = ASK_USER([
|
||||
{
|
||||
id: "execution",
|
||||
type: "select",
|
||||
prompt: "Select execution method:",
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: "Auto-select based on complexity" }
|
||||
],
|
||||
default: "Auto"
|
||||
},
|
||||
{
|
||||
id: "review",
|
||||
type: "select",
|
||||
prompt: "Enable code review after execution?",
|
||||
options: [
|
||||
{ label: "Skip", description: "No review" },
|
||||
{ label: "Gemini Review", description: "Gemini CLI tool" },
|
||||
{ label: "Codex Review", description: "Git-aware review (prompt OR --uncommitted)" },
|
||||
{ label: "Agent Review", description: "Current agent review" }
|
||||
],
|
||||
default: "Skip"
|
||||
}
|
||||
]) // BLOCKS (wait for user response)
|
||||
}
|
||||
```
|
||||
Route by mode:
|
||||
├─ --yes mode → Auto-confirm with defaults:
|
||||
│ ├─ Execution method: Auto
|
||||
│ └─ Code review: Skip
|
||||
│
|
||||
└─ Interactive mode → ASK_USER with 2 questions:
|
||||
├─ Execution method: Agent (@code-developer) / Codex (codex CLI) / Auto (complexity-based)
|
||||
└─ Code review: Skip / Gemini Review / Codex Review (git-aware) / Agent Review
|
||||
```
|
||||
|
||||
### Mode 3: File Content
|
||||
@@ -98,47 +64,18 @@ if (autoYes) {
|
||||
|
||||
**Input**: Path to file containing task description or plan.json
|
||||
|
||||
**Step 1: Read and Detect Format**
|
||||
**Format Detection**:
|
||||
|
||||
```javascript
|
||||
fileContent = Read(filePath)
|
||||
|
||||
// Attempt JSON parsing
|
||||
try {
|
||||
jsonData = JSON.parse(fileContent)
|
||||
|
||||
// Check if plan.json from lite-plan session
|
||||
if (jsonData.summary && jsonData.approach && jsonData.tasks) {
|
||||
planObject = jsonData
|
||||
originalUserInput = jsonData.summary
|
||||
isPlanJson = true
|
||||
} else {
|
||||
// Valid JSON but not plan.json - treat as plain text
|
||||
originalUserInput = fileContent
|
||||
isPlanJson = false
|
||||
}
|
||||
} catch {
|
||||
// Not valid JSON - treat as plain text prompt
|
||||
originalUserInput = fileContent
|
||||
isPlanJson = false
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2: Create Execution Plan**
|
||||
|
||||
If `isPlanJson === true`:
|
||||
- Use `planObject` directly
|
||||
- User selects execution method and code review
|
||||
|
||||
If `isPlanJson === false`:
|
||||
- Treat file content as prompt (same behavior as Mode 2)
|
||||
- Create simple execution plan from content
|
||||
|
||||
**Step 3: User Interaction**
|
||||
|
||||
- ASK_USER: Select execution method (Agent/Codex/Auto)
|
||||
- ASK_USER: Select code review tool
|
||||
- Proceed to execution with full context
|
||||
1. Read file content
|
||||
2. Attempt JSON parsing
|
||||
├─ Valid JSON with summary + approach + tasks fields → plan.json format
|
||||
│ ├─ Use parsed data as planObject
|
||||
│ └─ Set originalUserInput = summary
|
||||
└─ Not valid JSON or missing required fields → plain text format
|
||||
└─ Set originalUserInput = file content (same as Mode 2)
|
||||
3. User selects execution method + code review (same as Mode 2)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
@@ -173,379 +110,213 @@ Output:
|
||||
### Step 1: Initialize Execution Tracking
|
||||
|
||||
**Operations**:
|
||||
- Initialize result tracking for multi-execution scenarios
|
||||
- Set up `previousExecutionResults` array for context continuity
|
||||
- Initialize `previousExecutionResults` array for context continuity
|
||||
- **In-Memory Mode**: Echo execution strategy from planning phase for transparency
|
||||
|
||||
```javascript
|
||||
// Initialize result tracking
|
||||
previousExecutionResults = []
|
||||
|
||||
// In-Memory Mode: Echo execution strategy (transparency before execution)
|
||||
if (executionContext) {
|
||||
console.log(`
|
||||
Execution Strategy (from planning phase):
|
||||
Method: ${executionContext.executionMethod}
|
||||
Review: ${executionContext.codeReviewTool}
|
||||
Tasks: ${executionContext.planObject.tasks.length}
|
||||
Complexity: ${executionContext.planObject.complexity}
|
||||
${executionContext.executorAssignments ? ` Assignments: ${JSON.stringify(executionContext.executorAssignments)}` : ''}
|
||||
`)
|
||||
}
|
||||
```
|
||||
- Display: Method, Review tool, Task count, Complexity, Executor assignments (if present)
|
||||
|
||||
### Step 2: Task Grouping & Batch Creation
|
||||
|
||||
**Dependency Analysis & Grouping Algorithm**:
|
||||
```javascript
|
||||
// Use explicit depends_on from plan.json (no inference from file/keywords)
|
||||
function extractDependencies(tasks) {
|
||||
const taskIdToIndex = {}
|
||||
tasks.forEach((t, i) => { taskIdToIndex[t.id] = i })
|
||||
**Dependency Analysis**: Use **explicit** `depends_on` from plan.json only — no inference from file paths or keywords.
|
||||
|
||||
return tasks.map((task, i) => {
|
||||
// Only use explicit depends_on from plan.json
|
||||
const deps = (task.depends_on || [])
|
||||
.map(depId => taskIdToIndex[depId])
|
||||
.filter(idx => idx !== undefined && idx < i)
|
||||
return { ...task, taskIndex: i, dependencies: deps }
|
||||
})
|
||||
}
|
||||
```
|
||||
1. Build task ID → index mapping
|
||||
|
||||
// Group into batches: maximize parallel execution
|
||||
function createExecutionCalls(tasks, executionMethod) {
|
||||
const tasksWithDeps = extractDependencies(tasks)
|
||||
const processed = new Set()
|
||||
const calls = []
|
||||
2. For each task:
|
||||
└─ Resolve depends_on IDs to task indices
|
||||
└─ Filter: only valid IDs that reference earlier tasks
|
||||
|
||||
// Phase 1: All independent tasks → single parallel batch (maximize utilization)
|
||||
const independentTasks = tasksWithDeps.filter(t => t.dependencies.length === 0)
|
||||
if (independentTasks.length > 0) {
|
||||
independentTasks.forEach(t => processed.add(t.taskIndex))
|
||||
calls.push({
|
||||
method: executionMethod,
|
||||
executionType: "parallel",
|
||||
groupId: "P1",
|
||||
taskSummary: independentTasks.map(t => t.title).join(' | '),
|
||||
tasks: independentTasks
|
||||
})
|
||||
}
|
||||
3. Group into execution batches:
|
||||
├─ Phase 1: All tasks with NO dependencies → single parallel batch
|
||||
│ └─ Mark as processed
|
||||
└─ Phase 2+: Iterative dependency resolution
|
||||
├─ Find tasks whose ALL dependencies are satisfied (processed)
|
||||
├─ Group ready tasks as batch (parallel within batch if multiple)
|
||||
├─ Mark as processed
|
||||
├─ Repeat until no tasks remain
|
||||
└─ Safety: If no ready tasks found → circular dependency warning → force remaining
|
||||
|
||||
// Phase 2: Dependent tasks → sequential batches (respect dependencies)
|
||||
let sequentialIndex = 1
|
||||
let remaining = tasksWithDeps.filter(t => !processed.has(t.taskIndex))
|
||||
4. Assign batch IDs:
|
||||
├─ Parallel batches: P1, P2, P3...
|
||||
└─ Sequential batches: S1, S2, S3...
|
||||
|
||||
while (remaining.length > 0) {
|
||||
// Find tasks whose dependencies are all satisfied
|
||||
const ready = remaining.filter(t =>
|
||||
t.dependencies.every(d => processed.has(d))
|
||||
)
|
||||
|
||||
if (ready.length === 0) {
|
||||
console.warn('Circular dependency detected, forcing remaining tasks')
|
||||
ready.push(...remaining)
|
||||
}
|
||||
|
||||
// Group ready tasks (can run in parallel within this phase)
|
||||
ready.forEach(t => processed.add(t.taskIndex))
|
||||
calls.push({
|
||||
method: executionMethod,
|
||||
executionType: ready.length > 1 ? "parallel" : "sequential",
|
||||
groupId: ready.length > 1 ? `P${calls.length + 1}` : `S${sequentialIndex++}`,
|
||||
taskSummary: ready.map(t => t.title).join(ready.length > 1 ? ' | ' : ' → '),
|
||||
tasks: ready
|
||||
})
|
||||
|
||||
remaining = remaining.filter(t => !processed.has(t.taskIndex))
|
||||
}
|
||||
|
||||
return calls
|
||||
}
|
||||
|
||||
executionCalls = createExecutionCalls(planObject.tasks, executionMethod).map(c => ({ ...c, id: `[${c.groupId}]` }))
|
||||
|
||||
TodoWrite({
|
||||
todos: executionCalls.map(c => ({
|
||||
content: `${c.executionType === "parallel" ? "⚡" : "→"} ${c.id} (${c.tasks.length} tasks)`,
|
||||
status: "pending",
|
||||
activeForm: `Executing ${c.id}`
|
||||
}))
|
||||
})
|
||||
5. Create TodoWrite list with batch indicators:
|
||||
├─ ⚡ for parallel batches (concurrent)
|
||||
└─ → for sequential batches (one-by-one)
|
||||
```
|
||||
|
||||
### Step 3: Launch Execution
|
||||
|
||||
**Executor Resolution** (任务级 executor 优先于全局设置):
|
||||
```javascript
|
||||
// 获取任务的 executor(优先使用 executorAssignments,fallback 到全局 executionMethod)
|
||||
function getTaskExecutor(task) {
|
||||
const assignments = executionContext?.executorAssignments || {}
|
||||
if (assignments[task.id]) {
|
||||
return assignments[task.id].executor // 'gemini' | 'codex' | 'agent'
|
||||
}
|
||||
// Fallback: 全局 executionMethod 映射
|
||||
const method = executionContext?.executionMethod || 'Auto'
|
||||
if (method === 'Agent') return 'agent'
|
||||
if (method === 'Codex') return 'codex'
|
||||
// Auto: 根据复杂度
|
||||
return planObject.complexity === 'Low' ? 'agent' : 'codex'
|
||||
}
|
||||
#### Executor Resolution
|
||||
|
||||
// 按 executor 分组任务
|
||||
function groupTasksByExecutor(tasks) {
|
||||
const groups = { gemini: [], codex: [], agent: [] }
|
||||
tasks.forEach(task => {
|
||||
const executor = getTaskExecutor(task)
|
||||
groups[executor].push(task)
|
||||
})
|
||||
return groups
|
||||
}
|
||||
Task-level executor assignment takes priority over global execution method:
|
||||
|
||||
```
|
||||
Resolution order (per task):
|
||||
├─ 1. executorAssignments[task.id] → use assigned executor (gemini/codex/agent)
|
||||
└─ 2. Fallback to global executionMethod:
|
||||
├─ "Agent" → agent
|
||||
├─ "Codex" → codex
|
||||
└─ "Auto" → Low complexity → agent; Medium/High → codex
|
||||
```
|
||||
|
||||
**Execution Flow**: Parallel batches concurrently → Sequential batches in order
|
||||
```javascript
|
||||
const parallel = executionCalls.filter(c => c.executionType === "parallel")
|
||||
const sequential = executionCalls.filter(c => c.executionType === "sequential")
|
||||
#### Execution Flow
|
||||
|
||||
// Phase 1: Launch all parallel batches (single message with multiple tool calls)
|
||||
if (parallel.length > 0) {
|
||||
TodoWrite({ todos: executionCalls.map(c => ({ status: c.executionType === "parallel" ? "in_progress" : "pending" })) })
|
||||
parallelResults = await Promise.all(parallel.map(c => executeBatch(c)))
|
||||
previousExecutionResults.push(...parallelResults)
|
||||
TodoWrite({ todos: executionCalls.map(c => ({ status: parallel.includes(c) ? "completed" : "pending" })) })
|
||||
}
|
||||
```
|
||||
1. Separate batches into parallel and sequential groups
|
||||
|
||||
// Phase 2: Execute sequential batches one by one
|
||||
for (const call of sequential) {
|
||||
TodoWrite({ todos: executionCalls.map(c => ({ status: c === call ? "in_progress" : "..." })) })
|
||||
result = await executeBatch(call)
|
||||
previousExecutionResults.push(result)
|
||||
TodoWrite({ todos: executionCalls.map(c => ({ status: "completed" or "pending" })) })
|
||||
}
|
||||
2. Phase 1 — Launch all parallel batches concurrently:
|
||||
├─ Update TodoWrite: all parallel → in_progress
|
||||
├─ Execute all parallel batches simultaneously (single message, multiple tool calls)
|
||||
├─ Collect results → append to previousExecutionResults
|
||||
└─ Update TodoWrite: all parallel → completed
|
||||
|
||||
3. Phase 2+ — Execute sequential batches in order:
|
||||
├─ For each sequential batch:
|
||||
│ ├─ Update TodoWrite: current batch → in_progress
|
||||
│ ├─ Execute batch
|
||||
│ ├─ Collect result → append to previousExecutionResults
|
||||
│ └─ Update TodoWrite: current batch → completed
|
||||
└─ Continue until all batches completed
|
||||
```
|
||||
|
||||
### Unified Task Prompt Builder
|
||||
|
||||
**Task Formatting Principle**: Each task is a self-contained checklist. The executor only needs to know what THIS task requires. Same template for Agent and CLI.
|
||||
Each task is formatted as a **self-contained checklist**. The executor only needs to know what THIS task requires. Same template for Agent and CLI.
|
||||
|
||||
```javascript
|
||||
function buildExecutionPrompt(batch) {
|
||||
// Task template (6 parts: Modification Points → Why → How → Reference → Risks → Done)
|
||||
const formatTask = (t) => `
|
||||
## ${t.title}
|
||||
**Prompt Structure** (assembled from batch tasks):
|
||||
|
||||
**Scope**: \`${t.scope}\` | **Action**: ${t.action}
|
||||
```
|
||||
## Goal
|
||||
{originalUserInput}
|
||||
|
||||
### Modification Points
|
||||
${t.modification_points.map(p => `- **${p.file}** → \`${p.target}\`: ${p.change}`).join('\n')}
|
||||
## Tasks
|
||||
(For each task in batch, separated by ---)
|
||||
|
||||
${t.rationale ? `
|
||||
### Why this approach (Medium/High)
|
||||
${t.rationale.chosen_approach}
|
||||
${t.rationale.decision_factors?.length > 0 ? `\nKey factors: ${t.rationale.decision_factors.join(', ')}` : ''}
|
||||
${t.rationale.tradeoffs ? `\nTradeoffs: ${t.rationale.tradeoffs}` : ''}
|
||||
` : ''}
|
||||
### {task.title}
|
||||
**Scope**: {task.scope} | **Action**: {task.action}
|
||||
|
||||
### How to do it
|
||||
${t.description}
|
||||
#### Modification Points
|
||||
- **{file}** → `{target}`: {change}
|
||||
|
||||
${t.implementation.map(step => `- ${step}`).join('\n')}
|
||||
#### Why this approach (Medium/High only)
|
||||
{rationale.chosen_approach}
|
||||
Key factors: {decision_factors}
|
||||
Tradeoffs: {tradeoffs}
|
||||
|
||||
${t.code_skeleton ? `
|
||||
### Code skeleton (High)
|
||||
${t.code_skeleton.interfaces?.length > 0 ? `**Interfaces**: ${t.code_skeleton.interfaces.map(i => `\`${i.name}\` - ${i.purpose}`).join(', ')}` : ''}
|
||||
${t.code_skeleton.key_functions?.length > 0 ? `\n**Functions**: ${t.code_skeleton.key_functions.map(f => `\`${f.signature}\` - ${f.purpose}`).join(', ')}` : ''}
|
||||
${t.code_skeleton.classes?.length > 0 ? `\n**Classes**: ${t.code_skeleton.classes.map(c => `\`${c.name}\` - ${c.purpose}`).join(', ')}` : ''}
|
||||
` : ''}
|
||||
#### How to do it
|
||||
{description}
|
||||
{implementation steps}
|
||||
|
||||
### Reference
|
||||
- Pattern: ${t.reference?.pattern || 'N/A'}
|
||||
- Files: ${t.reference?.files?.join(', ') || 'N/A'}
|
||||
${t.reference?.examples ? `- Notes: ${t.reference.examples}` : ''}
|
||||
#### Code skeleton (High only)
|
||||
Interfaces: {interfaces}
|
||||
Functions: {key_functions}
|
||||
Classes: {classes}
|
||||
|
||||
${t.risks?.length > 0 ? `
|
||||
### Risk mitigations (High)
|
||||
${t.risks.map(r => `- ${r.description} → **${r.mitigation}**`).join('\n')}
|
||||
` : ''}
|
||||
#### Reference
|
||||
- Pattern: {pattern}
|
||||
- Files: {files}
|
||||
- Notes: {examples}
|
||||
|
||||
### Done when
|
||||
${t.acceptance.map(c => `- [ ] ${c}`).join('\n')}
|
||||
${t.verification?.success_metrics?.length > 0 ? `\n**Success metrics**: ${t.verification.success_metrics.join(', ')}` : ''}`
|
||||
#### Risk mitigations (High only)
|
||||
- {risk.description} → **{risk.mitigation}**
|
||||
|
||||
// Build prompt
|
||||
const sections = []
|
||||
#### Done when
|
||||
- [ ] {acceptance criteria}
|
||||
Success metrics: {verification.success_metrics}
|
||||
|
||||
if (originalUserInput) sections.push(`## Goal\n${originalUserInput}`)
|
||||
## Context
|
||||
(Assembled from available sources, reference only)
|
||||
|
||||
sections.push(`## Tasks\n${batch.tasks.map(formatTask).join('\n\n---\n')}`)
|
||||
### Exploration Notes (Refined)
|
||||
**Read first**: {exploration_log_refined path}
|
||||
Contains: file index, task-relevant context, code reference, execution notes
|
||||
**IMPORTANT**: Use to avoid re-exploring already analyzed files
|
||||
|
||||
// Context (reference only)
|
||||
const context = []
|
||||
### Previous Work
|
||||
{previousExecutionResults summaries}
|
||||
|
||||
// Priority: reference refined exploration notes (Execute phase specific)
|
||||
if (executionContext?.session?.artifacts?.exploration_log_refined) {
|
||||
context.push(`### Exploration Notes (Refined)
|
||||
**Read first**: ${executionContext.session.artifacts.exploration_log_refined}
|
||||
### Clarifications
|
||||
{clarificationContext entries}
|
||||
|
||||
This refined notes contains only execution-relevant context:
|
||||
- Execution-relevant file index (files directly related to plan tasks)
|
||||
- Task-relevant exploration context (findings, patterns, risks per task)
|
||||
- Condensed code reference (code snippets with line numbers)
|
||||
- Execution notes (constraints, integration points, dependencies)
|
||||
### Data Flow
|
||||
{planObject.data_flow.diagram}
|
||||
|
||||
**IMPORTANT**: Use this refined notes to avoid re-exploring files. DO NOT re-read files already analyzed in the notes unless verifying specific implementation details.`)
|
||||
}
|
||||
### Artifacts
|
||||
Plan: {plan path}
|
||||
|
||||
if (previousExecutionResults.length > 0) {
|
||||
context.push(`### Previous Work\n${previousExecutionResults.map(r => `- ${r.tasksSummary}: ${r.status}`).join('\n')}`)
|
||||
}
|
||||
if (clarificationContext) {
|
||||
context.push(`### Clarifications\n${Object.entries(clarificationContext).map(([q, a]) => `- ${q}: ${a}`).join('\n')}`)
|
||||
}
|
||||
if (executionContext?.planObject?.data_flow?.diagram) {
|
||||
context.push(`### Data Flow\n${executionContext.planObject.data_flow.diagram}`)
|
||||
}
|
||||
if (executionContext?.session?.artifacts?.plan) {
|
||||
context.push(`### Artifacts\nPlan: ${executionContext.session.artifacts.plan}`)
|
||||
}
|
||||
// Project guidelines (user-defined constraints)
|
||||
context.push(`### Project Guidelines\n@.workflow/project-guidelines.json`)
|
||||
if (context.length > 0) sections.push(`## Context\n${context.join('\n\n')}`)
|
||||
### Project Guidelines
|
||||
@.workflow/project-guidelines.json
|
||||
|
||||
sections.push(`Complete each task according to its "Done when" checklist.`)
|
||||
|
||||
return sections.join('\n\n')
|
||||
}
|
||||
Complete each task according to its "Done when" checklist.
|
||||
```
|
||||
|
||||
**Option A: Agent Execution**
|
||||
#### Option A: Agent Execution
|
||||
|
||||
When to use:
|
||||
- `getTaskExecutor(task) === "agent"`
|
||||
- or `executionMethod = "Agent"` (global fallback)
|
||||
- or `executionMethod = "Auto" AND complexity = "Low"` (global fallback)
|
||||
**When to use**: `getTaskExecutor(task) === "agent"`, or global `executionMethod = "Agent"`, or `Auto AND complexity = Low`
|
||||
|
||||
```javascript
|
||||
// Step 1: Create execution agent with mandatory context reading
|
||||
const executionAgentId = spawn_agent({
|
||||
message: `
|
||||
## TASK ASSIGNMENT
|
||||
**Execution Flow**:
|
||||
|
||||
### MANDATORY FIRST STEPS (Agent Execute)
|
||||
1. **Read role definition**: ~/.codex/agents/code-developer.md (MUST read first)
|
||||
2. Read: .workflow/project-tech.json
|
||||
3. Read: .workflow/project-guidelines.json
|
||||
4. **Read refined exploration log**: ${executionContext?.session?.artifacts?.exploration_log_refined || 'N/A'}
|
||||
```
|
||||
1. Spawn code-developer agent with prompt:
|
||||
├─ MANDATORY FIRST STEPS:
|
||||
│ ├─ Read: ~/.codex/agents/code-developer.md
|
||||
│ ├─ Read: .workflow/project-tech.json
|
||||
│ ├─ Read: .workflow/project-guidelines.json
|
||||
│ └─ Read: {exploration_log_refined} (execution-relevant context)
|
||||
└─ Body: {buildExecutionPrompt(batch)}
|
||||
|
||||
**CRITICAL**: Step 4 contains execution-relevant context including:
|
||||
- Task-relevant code patterns and integration points
|
||||
- Condensed code reference (with line numbers)
|
||||
- Execution constraints and risk notes
|
||||
2. Wait for completion (timeout: 10 minutes)
|
||||
|
||||
Use the notes to avoid re-exploring files - the analysis is already done.
|
||||
3. Close agent after collection
|
||||
|
||||
---
|
||||
|
||||
${buildExecutionPrompt(batch)}
|
||||
`
|
||||
})
|
||||
|
||||
// Step 2: Wait for execution completion
|
||||
const execResult = wait({
|
||||
ids: [executionAgentId],
|
||||
timeout_ms: 600000 // 10 minutes
|
||||
})
|
||||
|
||||
// Step 3: Close execution agent
|
||||
close_agent({ id: executionAgentId })
|
||||
4. Collect result → executionResult structure
|
||||
```
|
||||
|
||||
**Result Collection**: After completion, collect result following `executionResult` structure (see Data Structures section)
|
||||
#### Option B: CLI Execution (Codex)
|
||||
|
||||
**Option B: CLI Execution (Codex)**
|
||||
**When to use**: `getTaskExecutor(task) === "codex"`, or global `executionMethod = "Codex"`, or `Auto AND complexity = Medium/High`
|
||||
|
||||
When to use:
|
||||
- `getTaskExecutor(task) === "codex"`
|
||||
- or `executionMethod = "Codex"` (global fallback)
|
||||
- or `executionMethod = "Auto" AND complexity = "Medium/High"` (global fallback)
|
||||
**Execution**:
|
||||
|
||||
```bash
|
||||
ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write
|
||||
ccw cli -p "{buildExecutionPrompt(batch)}" --tool codex --mode write --id {sessionId}-{groupId}
|
||||
```
|
||||
|
||||
**Execution with fixed IDs** (predictable ID pattern):
|
||||
```javascript
|
||||
// Launch CLI in background, wait for task hook callback
|
||||
// Generate fixed execution ID: ${sessionId}-${groupId}
|
||||
const sessionId = executionContext?.session?.id || 'standalone'
|
||||
const fixedExecutionId = `${sessionId}-${batch.groupId}` // e.g., "implement-auth-2025-12-13-P1"
|
||||
**Fixed ID Pattern**: `{sessionId}-{groupId}` (e.g., `implement-auth-2025-12-13-P1`)
|
||||
|
||||
// Check if resuming from previous failed execution
|
||||
const previousCliId = batch.resumeFromCliId || null
|
||||
**Execution Mode**: Background (`run_in_background=true`) → Stop output → Wait for task hook callback
|
||||
|
||||
// Build command with fixed ID (and optional resume for continuation)
|
||||
const cli_command = previousCliId
|
||||
? `ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId} --resume ${previousCliId}`
|
||||
: `ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId}`
|
||||
**Resume on Failure**:
|
||||
|
||||
// Execute in background, stop output and wait for task hook callback
|
||||
Bash(
|
||||
command=cli_command,
|
||||
run_in_background=true
|
||||
)
|
||||
// STOP HERE - CLI executes in background, task hook will notify on completion
|
||||
```
|
||||
If status = failed or timeout:
|
||||
├─ Display: Fixed ID, lookup command, resume command
|
||||
├─ Lookup: ccw cli detail {fixedExecutionId}
|
||||
└─ Resume: ccw cli -p "Continue tasks" --resume {fixedExecutionId} --tool codex --mode write --id {fixedExecutionId}-retry
|
||||
```
|
||||
|
||||
**Resume on Failure** (with fixed ID):
|
||||
```javascript
|
||||
// If execution failed or timed out, offer resume option
|
||||
if (bash_result.status === 'failed' || bash_result.status === 'timeout') {
|
||||
console.log(`
|
||||
Execution incomplete. Resume available:
|
||||
Fixed ID: ${fixedExecutionId}
|
||||
Lookup: ccw cli detail ${fixedExecutionId}
|
||||
Resume: ccw cli -p "Continue tasks" --resume ${fixedExecutionId} --tool codex --mode write --id ${fixedExecutionId}-retry
|
||||
`)
|
||||
#### Option C: CLI Execution (Gemini)
|
||||
|
||||
// Store for potential retry in same session
|
||||
batch.resumeFromCliId = fixedExecutionId
|
||||
}
|
||||
```
|
||||
|
||||
**Result Collection**: After completion, analyze output and collect result following `executionResult` structure (include `cliExecutionId` for resume capability)
|
||||
|
||||
**Option C: CLI Execution (Gemini)**
|
||||
|
||||
When to use: `getTaskExecutor(task) === "gemini"` (analysis tasks)
|
||||
**When to use**: `getTaskExecutor(task) === "gemini"` (analysis tasks)
|
||||
|
||||
```bash
|
||||
# Use unified buildExecutionPrompt, switch tool and mode
|
||||
ccw cli -p "${buildExecutionPrompt(batch)}" --tool gemini --mode analysis --id ${sessionId}-${batch.groupId}
|
||||
ccw cli -p "{buildExecutionPrompt(batch)}" --tool gemini --mode analysis --id {sessionId}-{groupId}
|
||||
```
|
||||
|
||||
### Step 4: Progress Tracking
|
||||
|
||||
Progress tracked at batch level (not individual task level). Icons: ⚡ (parallel, concurrent), → (sequential, one-by-one)
|
||||
Progress tracked at **batch level** (not individual task level).
|
||||
|
||||
| Icon | Meaning |
|
||||
|------|---------|
|
||||
| ⚡ | Parallel batch (concurrent execution) |
|
||||
| → | Sequential batch (one-by-one execution) |
|
||||
|
||||
### Step 5: Code Review (Optional)
|
||||
|
||||
**Skip Condition**: Only run if `codeReviewTool ≠ "Skip"`
|
||||
|
||||
**Review Focus**: Verify implementation against plan acceptance criteria and verification requirements
|
||||
- Read plan.json for task acceptance criteria and verification checklist
|
||||
- Check each acceptance criterion is fulfilled
|
||||
- Verify success metrics from verification field (Medium/High complexity)
|
||||
- Run unit/integration tests specified in verification field
|
||||
- Validate code quality and identify issues
|
||||
- Ensure alignment with planned approach and risk mitigations
|
||||
|
||||
**Operations**:
|
||||
- Agent Review: Current agent performs direct review
|
||||
- Gemini Review: Execute gemini CLI with review prompt
|
||||
- Codex Review: Two options - (A) with prompt for complex reviews, (B) `--uncommitted` flag only for quick reviews
|
||||
- Custom tool: Execute specified CLI tool (qwen, etc.)
|
||||
|
||||
**Unified Review Template** (All tools use same standard):
|
||||
**Review Focus**: Verify implementation against plan acceptance criteria and verification requirements.
|
||||
|
||||
**Review Criteria**:
|
||||
- **Acceptance Criteria**: Verify each criterion from plan.tasks[].acceptance
|
||||
@@ -553,7 +324,8 @@ Progress tracked at batch level (not individual task level). Icons: ⚡ (paralle
|
||||
- **Code Quality**: Analyze quality, identify issues, suggest improvements
|
||||
- **Plan Alignment**: Validate implementation matches planned approach and risk mitigations
|
||||
|
||||
**Shared Prompt Template** (used by all CLI tools):
|
||||
**Shared Review Prompt Template**:
|
||||
|
||||
```
|
||||
PURPOSE: Code review for implemented changes against plan acceptance criteria and verification requirements
|
||||
TASK: • Verify plan acceptance criteria fulfillment • Check verification requirements (unit tests, success metrics) • Analyze code quality • Identify issues • Suggest improvements • Validate plan adherence and risk mitigations
|
||||
@@ -568,52 +340,26 @@ EXPECTED: Quality assessment with:
|
||||
CONSTRAINTS: Focus on plan acceptance criteria, verification requirements, and plan adherence | analysis=READ-ONLY
|
||||
```
|
||||
|
||||
**Tool-Specific Execution** (Apply shared prompt template above):
|
||||
**Tool-Specific Execution**:
|
||||
|
||||
| Tool | Command | Notes |
|
||||
|------|---------|-------|
|
||||
| Agent Review | Direct review by current agent | Read plan.json, apply review criteria, report findings |
|
||||
| Gemini Review | `ccw cli -p "[review prompt]" --tool gemini --mode analysis` | Recommended |
|
||||
| Qwen Review | `ccw cli -p "[review prompt]" --tool qwen --mode analysis` | Alternative |
|
||||
| Codex Review (A) | `ccw cli -p "[review prompt]" --tool codex --mode review` | Complex reviews with focus areas |
|
||||
| Codex Review (B) | `ccw cli --tool codex --mode review --uncommitted` | Quick review, no custom prompt |
|
||||
|
||||
> **IMPORTANT**: `-p` prompt and target flags (`--uncommitted`/`--base`/`--commit`) are **mutually exclusive** for codex review.
|
||||
|
||||
**Multi-Round Review**: Generate fixed review ID (`{sessionId}-review`). If issues found, resume with follow-up:
|
||||
|
||||
```bash
|
||||
# Method 1: Agent Review (current agent)
|
||||
# - Read plan.json: ${executionContext.session.artifacts.plan}
|
||||
# - Apply unified review criteria (see Shared Prompt Template)
|
||||
# - Report findings directly
|
||||
|
||||
# Method 2: Gemini Review (recommended)
|
||||
ccw cli -p "[Shared Prompt Template with artifacts]" --tool gemini --mode analysis
|
||||
# CONTEXT includes: @**/* @${plan.json} [@${exploration.json}]
|
||||
|
||||
# Method 3: Qwen Review (alternative)
|
||||
ccw cli -p "[Shared Prompt Template with artifacts]" --tool qwen --mode analysis
|
||||
# Same prompt as Gemini, different execution engine
|
||||
|
||||
# Method 4: Codex Review (git-aware) - Two mutually exclusive options:
|
||||
|
||||
# Option A: With custom prompt (reviews uncommitted by default)
|
||||
ccw cli -p "[Shared Prompt Template with artifacts]" --tool codex --mode review
|
||||
# Use for complex reviews with specific focus areas
|
||||
|
||||
# Option B: Target flag only (no prompt allowed)
|
||||
ccw cli --tool codex --mode review --uncommitted
|
||||
# Quick review of uncommitted changes without custom instructions
|
||||
|
||||
# IMPORTANT: -p prompt and target flags (--uncommitted/--base/--commit) are MUTUALLY EXCLUSIVE
|
||||
ccw cli -p "Clarify the security concerns" --resume {reviewId} --tool gemini --mode analysis --id {reviewId}-followup
|
||||
```
|
||||
|
||||
**Multi-Round Review with Fixed IDs**:
|
||||
```javascript
|
||||
// Generate fixed review ID
|
||||
const reviewId = `${sessionId}-review`
|
||||
|
||||
// First review pass with fixed ID
|
||||
const reviewResult = Bash(`ccw cli -p "[Review prompt]" --tool gemini --mode analysis --id ${reviewId}`)
|
||||
|
||||
// If issues found, continue review dialog with fixed ID chain
|
||||
if (hasUnresolvedIssues(reviewResult)) {
|
||||
// Resume with follow-up questions
|
||||
Bash(`ccw cli -p "Clarify the security concerns you mentioned" --resume ${reviewId} --tool gemini --mode analysis --id ${reviewId}-followup`)
|
||||
}
|
||||
```
|
||||
|
||||
**Implementation Note**: Replace `[Shared Prompt Template with artifacts]` placeholder with actual template content, substituting:
|
||||
- `@{plan.json}` → `@${executionContext.session.artifacts.plan}`
|
||||
**Implementation Note**: Replace `[review prompt]` placeholder with actual Shared Review Prompt Template content, substituting:
|
||||
- `@{plan.json}` → `@{executionContext.session.artifacts.plan}`
|
||||
- `[@{exploration.json}]` → exploration files from artifacts (if exists)
|
||||
|
||||
### Step 6: Update Development Index
|
||||
@@ -623,49 +369,35 @@ if (hasUnresolvedIssues(reviewResult)) {
|
||||
**Skip Condition**: Skip if `.workflow/project-tech.json` does not exist
|
||||
|
||||
**Operations**:
|
||||
```javascript
|
||||
const projectJsonPath = '.workflow/project-tech.json'
|
||||
if (!fileExists(projectJsonPath)) return // Silent skip
|
||||
|
||||
const projectJson = JSON.parse(Read(projectJsonPath))
|
||||
```
|
||||
1. Read .workflow/project-tech.json
|
||||
└─ If not found → silent skip
|
||||
|
||||
// Initialize if needed
|
||||
if (!projectJson.development_index) {
|
||||
projectJson.development_index = { feature: [], enhancement: [], bugfix: [], refactor: [], docs: [] }
|
||||
}
|
||||
2. Initialize development_index if missing
|
||||
└─ Categories: feature, enhancement, bugfix, refactor, docs
|
||||
|
||||
// Detect category from keywords
|
||||
function detectCategory(text) {
|
||||
text = text.toLowerCase()
|
||||
if (/\b(fix|bug|error|issue|crash)\b/.test(text)) return 'bugfix'
|
||||
if (/\b(refactor|cleanup|reorganize)\b/.test(text)) return 'refactor'
|
||||
if (/\b(doc|readme|comment)\b/.test(text)) return 'docs'
|
||||
if (/\b(add|new|create|implement)\b/.test(text)) return 'feature'
|
||||
return 'enhancement'
|
||||
}
|
||||
3. Detect category from task keywords:
|
||||
├─ fix/bug/error/issue/crash → bugfix
|
||||
├─ refactor/cleanup/reorganize → refactor
|
||||
├─ doc/readme/comment → docs
|
||||
├─ add/new/create/implement → feature
|
||||
└─ (default) → enhancement
|
||||
|
||||
// Detect sub_feature from task file paths
|
||||
function detectSubFeature(tasks) {
|
||||
const dirs = tasks.map(t => t.file?.split('/').slice(-2, -1)[0]).filter(Boolean)
|
||||
const counts = dirs.reduce((a, d) => { a[d] = (a[d] || 0) + 1; return a }, {})
|
||||
return Object.entries(counts).sort((a, b) => b[1] - a[1])[0]?.[0] || 'general'
|
||||
}
|
||||
4. Detect sub_feature from task file paths
|
||||
└─ Extract parent directory names, return most frequent
|
||||
|
||||
const category = detectCategory(`${planObject.summary} ${planObject.approach}`)
|
||||
const entry = {
|
||||
title: planObject.summary.slice(0, 60),
|
||||
sub_feature: detectSubFeature(planObject.tasks),
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
description: planObject.approach.slice(0, 100),
|
||||
status: previousExecutionResults.every(r => r.status === 'completed') ? 'completed' : 'partial',
|
||||
session_id: executionContext?.session?.id || null
|
||||
}
|
||||
5. Create entry:
|
||||
├─ title: plan summary (max 60 chars)
|
||||
├─ sub_feature: detected from file paths
|
||||
├─ date: current date (YYYY-MM-DD)
|
||||
├─ description: plan approach (max 100 chars)
|
||||
├─ status: "completed" if all results completed, else "partial"
|
||||
└─ session_id: from executionContext
|
||||
|
||||
projectJson.development_index[category].push(entry)
|
||||
projectJson.statistics.last_updated = new Date().toISOString()
|
||||
Write(projectJsonPath, JSON.stringify(projectJson, null, 2))
|
||||
|
||||
console.log(`Development index: [${category}] ${entry.title}`)
|
||||
6. Append entry to development_index[category]
|
||||
7. Update statistics.last_updated timestamp
|
||||
8. Write updated project-tech.json
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
@@ -683,7 +415,7 @@ console.log(`Development index: [${category}] ${entry.title}`)
|
||||
| Empty file | File exists but no content | Error: "File is empty: {path}. Provide task description." |
|
||||
| Invalid Enhanced Task JSON | JSON missing required fields | Warning: "Missing required fields. Treating as plain text." |
|
||||
| Malformed JSON | JSON parsing fails | Treat as plain text (expected for non-JSON files) |
|
||||
| Execution failure | Agent/Codex crashes | Display error, use fixed ID `${sessionId}-${groupId}` for resume: `ccw cli -p "Continue" --resume <fixed-id> --id <fixed-id>-retry` |
|
||||
| Execution failure | Agent/Codex crashes | Display error, use fixed ID `{sessionId}-{groupId}` for resume |
|
||||
| Execution timeout | CLI exceeded timeout | Use fixed ID for resume with extended timeout |
|
||||
| Codex unavailable | Codex not installed | Show installation instructions, offer Agent execution |
|
||||
| Fixed ID not found | Custom ID lookup failed | Check `ccw cli history`, verify date directories |
|
||||
@@ -760,22 +492,23 @@ Appended to `previousExecutionResults` array for context continuity in multi-exe
|
||||
|
||||
After completion, ask user whether to expand as issue (test/enhance/refactor/doc). Selected items create new issues accordingly.
|
||||
|
||||
**Fixed ID Pattern**: `${sessionId}-${groupId}` enables predictable lookup without auto-generated timestamps.
|
||||
**Fixed ID Pattern**: `{sessionId}-{groupId}` enables predictable lookup without auto-generated timestamps.
|
||||
|
||||
**Resume Usage**: If `status` is "partial" or "failed", use `fixedCliId` to resume:
|
||||
|
||||
```bash
|
||||
# Lookup previous execution
|
||||
ccw cli detail ${fixedCliId}
|
||||
ccw cli detail {fixedCliId}
|
||||
|
||||
# Resume with new fixed ID for retry
|
||||
ccw cli -p "Continue from where we left off" --resume ${fixedCliId} --tool codex --mode write --id ${fixedCliId}-retry
|
||||
ccw cli -p "Continue from where we left off" --resume {fixedCliId} --tool codex --mode write --id {fixedCliId}-retry
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Post-Phase Update
|
||||
|
||||
After Phase 4 (Lite Execute) completes:
|
||||
After Phase 2 (Lite Execute) completes:
|
||||
- **Output Created**: Executed tasks, optional code review results, updated development index
|
||||
- **Execution Results**: `previousExecutionResults[]` with status per batch
|
||||
- **Next Action**: Workflow complete. Optionally expand to issue (test/enhance/refactor/doc)
|
||||
|
||||
@@ -156,7 +156,7 @@ Execute **${angle}** exploration for task planning context. Analyze codebase fro
|
||||
**You (cli-explore-agent) MUST execute these steps in order:**
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
|
||||
2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
|
||||
3. Execute: cat ~/.claude/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
|
||||
3. Execute: cat ~/.ccw/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
|
||||
|
||||
## Exploration Strategy (${angle} focus)
|
||||
|
||||
@@ -313,7 +313,7 @@ const conflictAgentId = spawn_agent({
|
||||
## Analysis Steps
|
||||
|
||||
### 0. Load Output Schema (MANDATORY)
|
||||
Execute: cat ~/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json
|
||||
Execute: cat ~/.ccw/workflows/cli-templates/schemas/conflict-resolution-schema.json
|
||||
|
||||
### 1. Load Context
|
||||
- Read existing files from conflict indicators
|
||||
@@ -357,7 +357,7 @@ Template per conflict:
|
||||
|
||||
### 4. Return Structured Conflict Data
|
||||
|
||||
**Schema Reference**: Execute \`cat ~/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json\` to get full schema
|
||||
**Schema Reference**: Execute \`cat ~/.ccw/workflows/cli-templates/schemas/conflict-resolution-schema.json\` to get full schema
|
||||
|
||||
Return JSON following the schema above. Key requirements:
|
||||
- Minimum 2 strategies per conflict, max 4
|
||||
|
||||
@@ -435,7 +435,7 @@ IMPORTANT: Do NOT add command field to implementation_approach steps. Execution
|
||||
|
||||
##### 2. IMPL_PLAN.md (TDD Variant)
|
||||
- **Location**: \`.workflow/active/{session-id}/IMPL_PLAN.md\`
|
||||
- **Template**: \`~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt\`
|
||||
- **Template**: \`~/.ccw/workflows/cli-templates/prompts/workflow/impl-plan-template.txt\`
|
||||
- **TDD-Specific Frontmatter**: workflow_type="tdd", tdd_workflow=true, feature_count, task_breakdown
|
||||
- **TDD Implementation Tasks Section**: Feature-by-feature with internal Red-Green-Refactor cycles
|
||||
- **Context Analysis**: Artifact references and exploration insights
|
||||
|
||||
@@ -263,7 +263,7 @@ const taskTypeSuccessCriteria = {
|
||||
## CLI Tool Configuration
|
||||
|
||||
**Fallback Chain**: Gemini → Qwen → Codex
|
||||
**Template**: `~/.codex/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt`
|
||||
**Template**: `~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt`
|
||||
**Timeout**: 40min (2400000ms)
|
||||
|
||||
**Tool Details**:
|
||||
|
||||
Reference in New Issue
Block a user