mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-06 01:54:11 +08:00
feat(workflow): add comprehensive planning, resumption, review, status, and test generation commands
- Implemented `/workflow:plan` for creating detailed implementation plans with task decomposition and context gathering. - Added `/workflow:resume` for intelligent session resumption with automatic progress analysis. - Introduced `/workflow:review` for executing the final phase of quality validation and generating review reports. - Developed `/workflow:status` to provide on-demand views of workflow status and task progress. - Created `/workflow:test-gen` to generate comprehensive test workflows based on completed implementation tasks, ensuring full test coverage.
This commit is contained in:
@@ -21,7 +21,7 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
|
||||
## Core Responsibilities
|
||||
- **Context Package Parsing**: Read and validate context-package.json
|
||||
- **Multi-Tool Orchestration**: Execute parallel analysis using Gemini/Qwen/Codex
|
||||
- **Multi-Tool Orchestration**: Execute parallel analysis using Gemini/Codex
|
||||
- **Perspective Synthesis**: Collect and organize different tool viewpoints
|
||||
- **Consensus Analysis**: Identify agreements and conflicts between tools
|
||||
- **Analysis Report Generation**: Output multi-perspective ANALYSIS_RESULTS.md (NOT implementation plan)
|
||||
@@ -36,12 +36,12 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
- **Execution Mode**: Single-round analysis, focus on existing patterns
|
||||
|
||||
**Medium Tasks (4-6 modules)**:
|
||||
- **Primary Tool**: Qwen (architecture analysis and code generation)
|
||||
- **Support Tools**: Gemini (pattern recognition) + Exa (external best practices)
|
||||
- **Execution Mode**: Two-round analysis, architecture design + implementation strategy
|
||||
- **Primary Tool**: Gemini (comprehensive analysis and architecture design)
|
||||
- **Support Tools**: Code-index + Exa (external best practices)
|
||||
- **Execution Mode**: Two-round analysis, understanding + architecture design
|
||||
|
||||
**Complex Tasks (>6 modules)**:
|
||||
- **Primary Tools**: Multi-tool collaboration (Gemini+Qwen+Codex)
|
||||
- **Primary Tools**: Multi-tool collaboration (Gemini+Codex)
|
||||
- **Analysis Strategy**: Layered analysis with progressive refinement
|
||||
- **Execution Mode**: Three-round analysis, understand + design + validate
|
||||
|
||||
@@ -50,18 +50,18 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
```json
|
||||
{
|
||||
"frontend": {
|
||||
"primary": "qwen",
|
||||
"secondary": "gemini",
|
||||
"primary": "gemini",
|
||||
"secondary": "codex",
|
||||
"focus": ["component_design", "state_management", "ui_patterns"]
|
||||
},
|
||||
"backend": {
|
||||
"primary": "codex",
|
||||
"secondary": "qwen",
|
||||
"secondary": "gemini",
|
||||
"focus": ["api_design", "data_flow", "security", "performance"]
|
||||
},
|
||||
"fullstack": {
|
||||
"primary": "gemini",
|
||||
"secondary": "qwen+codex",
|
||||
"secondary": "codex",
|
||||
"focus": ["system_architecture", "integration", "data_consistency"]
|
||||
}
|
||||
}
|
||||
@@ -106,9 +106,9 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
if [ "$complexity" = "simple" ]; then
|
||||
analysis_tools=("gemini")
|
||||
elif [ "$complexity" = "medium" ]; then
|
||||
analysis_tools=("qwen" "gemini")
|
||||
analysis_tools=("gemini")
|
||||
else
|
||||
analysis_tools=("gemini" "qwen" "codex")
|
||||
analysis_tools=("gemini" "codex")
|
||||
fi
|
||||
```
|
||||
|
||||
@@ -118,44 +118,33 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
- Optimize token usage efficiency
|
||||
|
||||
### Phase 3: Multi-Tool Analysis Execution
|
||||
1. **Gemini Analysis** (Understanding & Pattern Recognition)
|
||||
1. **Gemini Analysis** (Comprehensive Understanding & Architecture Design)
|
||||
```bash
|
||||
cd "$project_root" && ~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: Deep understanding of project architecture and existing patterns
|
||||
TASK: Analyze ${task_description}
|
||||
CONTEXT: $(cat ${context_package_path} | jq -r '.assets[] | select(.priority=="high") | .path' | head -10)
|
||||
PURPOSE: Deep understanding of project architecture, existing patterns, and design implementation architecture
|
||||
TASK: Comprehensive analysis of ${task_description}
|
||||
CONTEXT: $(cat ${context_package_path} | jq -r '.assets[] | select(.priority=="high") | .path' | head -15)
|
||||
EXPECTED:
|
||||
- Existing architecture pattern analysis
|
||||
- Relevant code component identification
|
||||
- Technical risk assessment
|
||||
- Implementation complexity evaluation
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on existing patterns and integration points
|
||||
"
|
||||
```
|
||||
|
||||
2. **Qwen Analysis** (Architecture Design & Code Generation Strategy)
|
||||
```bash
|
||||
cd "$project_root" && ~/.claude/scripts/qwen-wrapper -p "
|
||||
PURPOSE: Design implementation architecture and code structure
|
||||
TASK: Design technical implementation plan for ${task_description}
|
||||
CONTEXT: $(cat ${context_package_path} | jq -r '.assets[].path') + Gemini analysis results
|
||||
EXPECTED:
|
||||
- Detailed technical implementation architecture
|
||||
- Code organization structure recommendations
|
||||
- Interface design and data flow
|
||||
- Specific implementation steps
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) | Design based on existing architecture
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on existing patterns, integration points, and comprehensive design
|
||||
"
|
||||
```
|
||||
|
||||
3. **Codex Analysis** (Implementation Feasibility & Technical Validation)
|
||||
2. **Codex Analysis** (Implementation Feasibility & Technical Validation)
|
||||
```bash
|
||||
# Only used for complex tasks
|
||||
if [ "$complexity" = "complex" ]; then
|
||||
codex -C "$project_root" --full-auto exec "
|
||||
PURPOSE: Validate technical implementation feasibility
|
||||
TASK: Assess implementation risks and technical challenges for ${task_description}
|
||||
CONTEXT: Project codebase + Gemini and Qwen analysis results
|
||||
CONTEXT: Project codebase + Gemini analysis results
|
||||
EXPECTED: Technical feasibility report and risk assessment
|
||||
RULES: Focus on technical risks, performance impact, and maintenance costs
|
||||
" -s danger-full-access
|
||||
@@ -164,8 +153,7 @@ Intelligent analysis engine that processes standardized context packages, execut
|
||||
|
||||
### Phase 4: Multi-Perspective Analysis Integration
|
||||
1. **Tool-Specific Result Organization**
|
||||
- Organize Gemini analysis (understanding & patterns)
|
||||
- Organize Qwen analysis (architecture & design)
|
||||
- Organize Gemini analysis (comprehensive understanding, patterns & architecture design)
|
||||
- Organize Codex analysis (feasibility & validation)
|
||||
|
||||
2. **Perspective Synthesis**
|
||||
@@ -193,8 +181,8 @@ Generated ANALYSIS_RESULTS.md format (Multi-Tool Perspective Analysis):
|
||||
|
||||
## Tool-Specific Analysis
|
||||
|
||||
### 🧠 Gemini Analysis (Understanding & Pattern Recognition)
|
||||
**Focus**: Existing codebase understanding and pattern identification
|
||||
### 🧠 Gemini Analysis (Comprehensive Understanding & Architecture Design)
|
||||
**Focus**: Existing codebase understanding, pattern identification, and technical architecture design
|
||||
|
||||
#### Current Architecture Assessment
|
||||
- **Existing Patterns**: {identified_patterns}
|
||||
@@ -207,9 +195,6 @@ Generated ANALYSIS_RESULTS.md format (Multi-Tool Perspective Analysis):
|
||||
- **Dependency Impact**: {dependency_analysis}
|
||||
- **Migration Considerations**: {migration_notes}
|
||||
|
||||
### 🏗️ Qwen Analysis (Architecture Design & Code Generation)
|
||||
**Focus**: Technical architecture and implementation design
|
||||
|
||||
#### Proposed Architecture
|
||||
- **System Design**: {architectural_design}
|
||||
- **Component Structure**: {component_design}
|
||||
@@ -273,10 +258,10 @@ Generated ANALYSIS_RESULTS.md format (Multi-Tool Perspective Analysis):
|
||||
|
||||
2. **Tool Unavailability Handling**
|
||||
```bash
|
||||
# Use Qwen when Gemini is unavailable
|
||||
# Use Codex when Gemini is unavailable
|
||||
if ! command -v ~/.claude/scripts/gemini-wrapper; then
|
||||
echo "⚠️ Gemini not available, falling back to Qwen"
|
||||
analysis_tools=("qwen")
|
||||
echo "⚠️ Gemini not available, falling back to Codex"
|
||||
analysis_tools=("codex")
|
||||
fi
|
||||
```
|
||||
|
||||
|
||||
@@ -12,147 +12,185 @@ examples:
|
||||
# Context Gather Command (/context:gather)
|
||||
|
||||
## Overview
|
||||
Intelligent context collector that gathers relevant information from project codebase, documentation, and dependencies based on task descriptions, generating standardized context packages.
|
||||
Enhanced intelligent context collector that leverages Gemini and Codex CLI tools to perform deep analysis, generate improvement suggestions, design blueprints, and create comprehensive analysis documents. All outputs are systematically organized in the current session's WFS `.process` directory.
|
||||
|
||||
## Core Philosophy
|
||||
- **Intelligent Collection**: Auto-identify relevant resources based on keyword analysis
|
||||
- **Comprehensive Coverage**: Collect code, documentation, configurations, and dependencies
|
||||
- **Standardized Output**: Generate unified format context-package.json
|
||||
- **Efficient Execution**: Optimize collection strategies to avoid irrelevant information
|
||||
- **AI-Driven Analysis**: Use Gemini for architectural analysis and design blueprints
|
||||
- **Implementation Focus**: Use Codex for practical implementation planning and quality assessment
|
||||
- **Structured Output**: Generate organized analysis documents in WFS session `.process` folders
|
||||
- **Synthesis Approach**: Combine all analysis results into a final comprehensive document
|
||||
|
||||
## Core Responsibilities
|
||||
- **Keyword Extraction**: Extract core keywords from task descriptions
|
||||
- **Smart Documentation Loading**: Load relevant project documentation based on keywords
|
||||
- **Code Structure Analysis**: Analyze project structure to locate relevant code files
|
||||
- **Dependency Discovery**: Identify tech stack and dependency relationships
|
||||
- **MCP Tools Integration**: Leverage code-index and exa tools for enhanced collection
|
||||
- **Context Packaging**: Generate standardized JSON context packages
|
||||
- **Initial Context Collection**: Use MCP tools to gather relevant codebase information
|
||||
- **Gemini Analysis**: Generate deep architectural analysis and improvement suggestions
|
||||
- **Design Blueprint Creation**: Create comprehensive design blueprints using Gemini
|
||||
- **Codex Implementation Planning**: Generate practical implementation roadmaps with Codex
|
||||
- **Quality Assessment**: Perform code quality analysis and optimization recommendations
|
||||
- **Synthesis Documentation**: Combine all analysis into comprehensive final document
|
||||
- **Process Organization**: Structure all outputs in WFS session `.process` directories
|
||||
|
||||
## Execution Process
|
||||
## Enhanced CLI Execution Process
|
||||
|
||||
### Phase 1: Task Analysis
|
||||
1. **Keyword Extraction**
|
||||
- Parse task description to extract core keywords
|
||||
- Identify technical domain (auth, API, frontend, backend, etc.)
|
||||
- Determine complexity level (simple, medium, complex)
|
||||
|
||||
2. **Scope Determination**
|
||||
- Define collection scope based on keywords
|
||||
- Identify potentially involved modules and components
|
||||
- Set file type filters
|
||||
|
||||
### Phase 2: Project Structure Exploration
|
||||
1. **Architecture Analysis**
|
||||
### Phase 1: Task Analysis & Context Collection
|
||||
1. **Initial Context Gathering**
|
||||
```bash
|
||||
# Get project structure
|
||||
~/.claude/scripts/get_modules_by_depth.sh
|
||||
```
|
||||
|
||||
2. **Code File Location**
|
||||
```bash
|
||||
# Use MCP tools for precise search
|
||||
mcp__code-index__find_files(pattern="*{keywords}*")
|
||||
mcp__code-index__search_code_advanced(pattern="{keywords}", file_pattern="*.{ts,js,py,go}")
|
||||
```
|
||||
|
||||
3. **Documentation Collection**
|
||||
- Load CLAUDE.md and README.md
|
||||
- Load relevant documentation from .workflow/docs/ based on keywords
|
||||
- Collect configuration files (package.json, requirements.txt, etc.)
|
||||
|
||||
### Phase 3: Intelligent Filtering & Association
|
||||
1. **Relevance Scoring**
|
||||
- Score based on keyword match degree
|
||||
- Score based on file path relevance
|
||||
- Score based on code content relevance
|
||||
|
||||
2. **Dependency Analysis**
|
||||
- Analyze import/require statements
|
||||
- Identify inter-module dependencies
|
||||
- Determine core and optional dependencies
|
||||
|
||||
### Phase 4: External Context Enhancement (Optional)
|
||||
1. **MCP Exa Integration**
|
||||
```bash
|
||||
# Get external best practices and examples
|
||||
# Get external context if needed
|
||||
mcp__exa__get_code_context_exa(query="{task_type} {tech_stack} examples", tokensNum="dynamic")
|
||||
```
|
||||
|
||||
2. **Tech Stack Analysis**
|
||||
- Identify frameworks and libraries in use
|
||||
- Gather relevant best practices
|
||||
- Collect common patterns and examples
|
||||
2. **Session Directory Setup**
|
||||
```bash
|
||||
# Ensure session .process directory exists
|
||||
mkdir -p ".workflow/${session_id}/.process"
|
||||
```
|
||||
|
||||
### Phase 5: Context Packaging
|
||||
1. **Standardized Output**
|
||||
- Generate context-package.json
|
||||
- Organize resources by type and importance
|
||||
- Add relevance descriptions and usage recommendations
|
||||
### Phase 2: Gemini Analysis & Planning
|
||||
1. **Comprehensive Analysis with Gemini**
|
||||
```bash
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Deep analysis of task requirements and current codebase state
|
||||
TASK: Analyze task '${task_description}' and generate improvement suggestions
|
||||
CONTEXT: @{CLAUDE.md,README.md,**/*${keywords}*} Current session: ${session_id}
|
||||
EXPECTED: Detailed analysis with improvement suggestions saved to .workflow/${session_id}/.process/
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Generate specific improvement recommendations and save to improvement-suggestions.md
|
||||
" > ".workflow/${session_id}/.process/gemini-analysis.md"
|
||||
```
|
||||
|
||||
## Context Package Format
|
||||
2. **Design Blueprint Generation**
|
||||
```bash
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Create comprehensive design blueprint for task implementation
|
||||
TASK: Design architectural blueprint for '${task_description}'
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,CLAUDE.md} Previous analysis results
|
||||
EXPECTED: Complete design blueprint with component diagrams and implementation strategy
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Create detailed design blueprint and save to design-blueprint.md
|
||||
" > ".workflow/${session_id}/.process/design-blueprint.md"
|
||||
```
|
||||
|
||||
Generated context package format:
|
||||
### Phase 3: Codex Implementation Planning
|
||||
1. **Implementation Strategy with Codex**
|
||||
```bash
|
||||
codex --full-auto exec "
|
||||
PURPOSE: Generate detailed implementation plan based on analysis and design
|
||||
TASK: Create implementation roadmap for '${task_description}'
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,.workflow/${session_id}/.process/design-blueprint.md}
|
||||
EXPECTED: Step-by-step implementation plan with code examples
|
||||
RULES: Generate practical implementation plan and save to .workflow/${session_id}/.process/implementation-plan.md
|
||||
" -s danger-full-access
|
||||
```
|
||||
|
||||
2. **Code Quality Assessment**
|
||||
```bash
|
||||
codex --full-auto exec "
|
||||
PURPOSE: Assess current code quality and identify optimization opportunities
|
||||
TASK: Evaluate codebase quality related to '${task_description}'
|
||||
CONTEXT: @{**/*${keywords}*,.workflow/${session_id}/.process/design-blueprint.md}
|
||||
EXPECTED: Quality assessment report with optimization recommendations
|
||||
RULES: Focus on maintainability, performance, and security. Save to .workflow/${session_id}/.process/quality-assessment.md
|
||||
" -s danger-full-access
|
||||
```
|
||||
|
||||
### Phase 4: Synthesis & Final Analysis
|
||||
1. **Comprehensive Analysis Document Generation**
|
||||
```bash
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Synthesize all analysis results into comprehensive final document
|
||||
TASK: Combine all generated analysis documents into unified comprehensive analysis
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,.workflow/${session_id}/.process/design-blueprint.md,.workflow/${session_id}/.process/implementation-plan.md,.workflow/${session_id}/.process/quality-assessment.md}
|
||||
EXPECTED: Single comprehensive analysis document with executive summary, detailed findings, and actionable recommendations
|
||||
RULES: Create synthesis of all previous analysis. Structure: Executive Summary, Key Findings, Design Recommendations, Implementation Strategy, Quality Improvements, Next Steps
|
||||
" > ".workflow/${session_id}/.process/comprehensive-analysis.md"
|
||||
```
|
||||
|
||||
2. **Context Package Generation**
|
||||
```bash
|
||||
# Generate the final context-package.json based on all analysis
|
||||
cat > ".workflow/${session_id}/.process/context-package.json" << EOF
|
||||
{
|
||||
"metadata": {
|
||||
"task_description": "${task_description}",
|
||||
"timestamp": "$(date -Iseconds)",
|
||||
"session_id": "${session_id}",
|
||||
"analysis_files": [
|
||||
"gemini-analysis.md",
|
||||
"design-blueprint.md",
|
||||
"implementation-plan.md",
|
||||
"quality-assessment.md",
|
||||
"comprehensive-analysis.md"
|
||||
]
|
||||
},
|
||||
"generated_analysis": {
|
||||
"improvement_suggestions": ".workflow/${session_id}/.process/gemini-analysis.md",
|
||||
"design_blueprint": ".workflow/${session_id}/.process/design-blueprint.md",
|
||||
"implementation_plan": ".workflow/${session_id}/.process/implementation-plan.md",
|
||||
"quality_assessment": ".workflow/${session_id}/.process/quality-assessment.md",
|
||||
"comprehensive_analysis": ".workflow/${session_id}/.process/comprehensive-analysis.md"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
## Enhanced Context Package Format
|
||||
|
||||
Generated context package format with analysis documents:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"task_description": "Implement user authentication system",
|
||||
"timestamp": "2025-09-29T10:30:00Z",
|
||||
"keywords": ["user", "authentication", "JWT", "login"],
|
||||
"complexity": "medium",
|
||||
"tech_stack": ["typescript", "node.js", "express"],
|
||||
"session_id": "WFS-user-auth"
|
||||
"session_id": "WFS-user-auth",
|
||||
"execution_method": "gemini_codex_analysis",
|
||||
"analysis_files": [
|
||||
"gemini-analysis.md",
|
||||
"design-blueprint.md",
|
||||
"implementation-plan.md",
|
||||
"quality-assessment.md",
|
||||
"comprehensive-analysis.md"
|
||||
]
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
"type": "documentation",
|
||||
"path": "CLAUDE.md",
|
||||
"relevance": "Project development standards and conventions",
|
||||
"priority": "high"
|
||||
"generated_analysis": {
|
||||
"improvement_suggestions": {
|
||||
"file": ".workflow/WFS-user-auth/.process/gemini-analysis.md",
|
||||
"description": "Gemini-generated analysis with improvement recommendations",
|
||||
"tool": "gemini-wrapper"
|
||||
},
|
||||
{
|
||||
"type": "documentation",
|
||||
"path": ".workflow/docs/architecture/security.md",
|
||||
"relevance": "Security architecture design guidance",
|
||||
"priority": "high"
|
||||
"design_blueprint": {
|
||||
"file": ".workflow/WFS-user-auth/.process/design-blueprint.md",
|
||||
"description": "Architectural design blueprint with component diagrams",
|
||||
"tool": "gemini-wrapper"
|
||||
},
|
||||
{
|
||||
"type": "source_code",
|
||||
"path": "src/auth/AuthService.ts",
|
||||
"relevance": "Existing authentication service implementation",
|
||||
"priority": "high"
|
||||
"implementation_plan": {
|
||||
"file": ".workflow/WFS-user-auth/.process/implementation-plan.md",
|
||||
"description": "Step-by-step implementation roadmap with code examples",
|
||||
"tool": "codex"
|
||||
},
|
||||
{
|
||||
"type": "source_code",
|
||||
"path": "src/models/User.ts",
|
||||
"relevance": "User data model definition",
|
||||
"priority": "medium"
|
||||
"quality_assessment": {
|
||||
"file": ".workflow/WFS-user-auth/.process/quality-assessment.md",
|
||||
"description": "Code quality analysis and optimization recommendations",
|
||||
"tool": "codex"
|
||||
},
|
||||
{
|
||||
"type": "config",
|
||||
"path": "package.json",
|
||||
"relevance": "Project dependencies and tech stack",
|
||||
"priority": "medium"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"path": "tests/auth/*.test.ts",
|
||||
"relevance": "Authentication related test cases",
|
||||
"priority": "medium"
|
||||
"comprehensive_analysis": {
|
||||
"file": ".workflow/WFS-user-auth/.process/comprehensive-analysis.md",
|
||||
"description": "Synthesized final analysis document combining all findings",
|
||||
"tool": "gemini-wrapper"
|
||||
}
|
||||
],
|
||||
"external_context": {
|
||||
"best_practices": "Best practices retrieved from exa",
|
||||
"examples": "Relevant code examples and patterns",
|
||||
"frameworks": "Recommended frameworks and libraries"
|
||||
},
|
||||
"statistics": {
|
||||
"total_files": 15,
|
||||
"source_files": 8,
|
||||
"docs_files": 4,
|
||||
"config_files": 2,
|
||||
"test_files": 1
|
||||
}
|
||||
"process_workflow": {
|
||||
"phase_1": "Context collection with MCP tools",
|
||||
"phase_2": "Gemini analysis and design blueprint generation",
|
||||
"phase_3": "Codex implementation planning and quality assessment",
|
||||
"phase_4": "Synthesis into comprehensive analysis document"
|
||||
},
|
||||
"output_location": ".workflow/${session_id}/.process/",
|
||||
"final_deliverable": "comprehensive-analysis.md"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -251,13 +289,81 @@ rg "{keywords}" --type-add 'source:*.{ts,js,py,go}' -t source
|
||||
- MCP tool calls and traditional commands in parallel
|
||||
- Reduce I/O wait time
|
||||
|
||||
## Practical Execution Summary
|
||||
|
||||
### Quick Start CLI Commands
|
||||
```bash
|
||||
# Example usage for authentication task
|
||||
session_id="WFS-user-auth"
|
||||
task_description="Implement user authentication system"
|
||||
|
||||
# 1. Setup and context collection
|
||||
mkdir -p ".workflow/${session_id}/.process"
|
||||
~/.claude/scripts/get_modules_by_depth.sh
|
||||
|
||||
# 2. Gemini analysis and design
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Deep analysis of task requirements and current codebase state
|
||||
TASK: Analyze task '${task_description}' and generate improvement suggestions
|
||||
CONTEXT: @{CLAUDE.md,README.md,**/*auth*} Current session: ${session_id}
|
||||
EXPECTED: Detailed analysis with improvement suggestions
|
||||
RULES: Generate specific improvement recommendations and save results
|
||||
" > ".workflow/${session_id}/.process/gemini-analysis.md"
|
||||
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Create comprehensive design blueprint
|
||||
TASK: Design architectural blueprint for '${task_description}'
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,CLAUDE.md}
|
||||
EXPECTED: Complete design blueprint with component diagrams
|
||||
RULES: Create detailed design blueprint
|
||||
" > ".workflow/${session_id}/.process/design-blueprint.md"
|
||||
|
||||
# 3. Codex implementation and quality
|
||||
codex --full-auto exec "
|
||||
PURPOSE: Generate implementation plan based on analysis
|
||||
TASK: Create implementation roadmap for '${task_description}'
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,.workflow/${session_id}/.process/design-blueprint.md}
|
||||
EXPECTED: Step-by-step implementation plan with code examples
|
||||
RULES: Generate practical implementation plan and save to .workflow/${session_id}/.process/implementation-plan.md
|
||||
" -s danger-full-access
|
||||
|
||||
codex --full-auto exec "
|
||||
PURPOSE: Assess code quality and optimization opportunities
|
||||
TASK: Evaluate codebase quality related to '${task_description}'
|
||||
CONTEXT: @{**/*auth*,.workflow/${session_id}/.process/design-blueprint.md}
|
||||
EXPECTED: Quality assessment with optimization recommendations
|
||||
RULES: Save to .workflow/${session_id}/.process/quality-assessment.md
|
||||
" -s danger-full-access
|
||||
|
||||
# 4. Final synthesis
|
||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
||||
PURPOSE: Synthesize all analysis results into comprehensive document
|
||||
TASK: Combine all analysis documents into unified comprehensive analysis
|
||||
CONTEXT: @{.workflow/${session_id}/.process/gemini-analysis.md,.workflow/${session_id}/.process/design-blueprint.md,.workflow/${session_id}/.process/implementation-plan.md,.workflow/${session_id}/.process/quality-assessment.md}
|
||||
EXPECTED: Comprehensive analysis with executive summary and recommendations
|
||||
RULES: Structure: Executive Summary, Key Findings, Design Recommendations, Implementation Strategy, Quality Improvements, Next Steps
|
||||
" > ".workflow/${session_id}/.process/comprehensive-analysis.md"
|
||||
```
|
||||
|
||||
### Expected Output Structure
|
||||
```
|
||||
.workflow/${session_id}/.process/
|
||||
├── gemini-analysis.md # Improvement suggestions
|
||||
├── design-blueprint.md # Architectural design
|
||||
├── implementation-plan.md # Implementation roadmap
|
||||
├── quality-assessment.md # Code quality analysis
|
||||
├── comprehensive-analysis.md # Final synthesis document
|
||||
└── context-package.json # Metadata package
|
||||
```
|
||||
|
||||
## Success Criteria
|
||||
- Generate valid context-package.json file
|
||||
- Contains sufficient relevant information for subsequent analysis
|
||||
- Execution time controlled within 30 seconds
|
||||
- File relevance accuracy rate >80%
|
||||
- Generate comprehensive analysis documents in WFS `.process` directory
|
||||
- Produce actionable improvement suggestions and design blueprints
|
||||
- Create practical implementation plans with Codex
|
||||
- Synthesize all findings into unified comprehensive analysis
|
||||
- Complete execution within reasonable timeframe (5-10 minutes)
|
||||
|
||||
## Related Commands
|
||||
- `/analysis:run` - Consumes output of this command for analysis
|
||||
- `/workflow:plan` - Calls this command to gather context
|
||||
- `/workflow:status` - Can display context collection status
|
||||
- `/analysis:run` - Consumes output of this command for further analysis
|
||||
- `/workflow:plan` - Integrates with this command for context gathering
|
||||
- `/workflow:status` - Can display analysis generation status
|
||||
@@ -141,132 +141,96 @@ SORT recommendations BY priority_score DESC
|
||||
└── synthesis-report.md # ★ OUTPUT: Integrated synthesis with @ references
|
||||
```
|
||||
|
||||
### Core Output Documents
|
||||
### Streamlined Single-Document Output ⚠️ SIMPLIFIED STRUCTURE
|
||||
|
||||
#### synthesis-report.md Structure
|
||||
#### Output Document - Single Comprehensive Synthesis
|
||||
The synthesis process creates **one consolidated document** that integrates all role perspectives:
|
||||
|
||||
```
|
||||
.workflow/WFS-{topic-slug}/.brainstorming/
|
||||
├── topic-framework.md # Input: Framework structure
|
||||
├── [role]/analysis.md # Input: Role analyses (multiple)
|
||||
└── synthesis-specification.md # ★ OUTPUT: Complete integrated specification
|
||||
```
|
||||
|
||||
#### synthesis-specification.md Structure (Complete Specification)
|
||||
```markdown
|
||||
# [Topic] - Integrated Analysis
|
||||
# [Topic] - Integrated Implementation Specification
|
||||
|
||||
**Framework Reference**: @topic-framework.md
|
||||
**Generated**: [timestamp] | **Session**: WFS-[topic-slug]
|
||||
**Framework Reference**: @topic-framework.md | **Generated**: [timestamp] | **Session**: WFS-[topic-slug]
|
||||
**Source Integration**: All brainstorming role perspectives consolidated
|
||||
|
||||
## Executive Summary
|
||||
Brief synthesis of key insights and recommendations across all role perspectives.
|
||||
Strategic overview with key insights, breakthrough opportunities, and implementation priorities.
|
||||
|
||||
## Framework Analysis Integration
|
||||
## Requirements & Acceptance Criteria
|
||||
### Functional Requirements
|
||||
| ID | Description | Source | Priority | Acceptance | Dependencies |
|
||||
|----|-------------|--------|----------|------------|--------------|
|
||||
| FR-01 | Core feature | @role/analysis.md | High | Criteria | None |
|
||||
|
||||
### Discussion Point 1: Core Requirements
|
||||
**Framework Questions**: @topic-framework.md (Core Requirements section)
|
||||
### Non-Functional Requirements
|
||||
| ID | Description | Target | Validation |
|
||||
|----|-------------|--------|------------|
|
||||
| NFR-01 | Performance | <200ms | Testing |
|
||||
|
||||
**Role Perspectives**:
|
||||
- **System Architect**: @system-architect/analysis.md (requirements section)
|
||||
- **Product Manager**: @product-manager/analysis.md (requirements section)
|
||||
- **Security Expert**: @security-expert/analysis.md (requirements section)
|
||||
### Business Requirements
|
||||
| ID | Description | Value | Success Metric |
|
||||
|----|-------------|-------|----------------|
|
||||
| BR-01 | User engagement | High | 80% retention |
|
||||
|
||||
**Cross-Role Insights**:
|
||||
- [Consensus areas and disagreements on core requirements]
|
||||
- [Integration recommendations]
|
||||
## Design Specifications
|
||||
### UI/UX Guidelines
|
||||
**Consolidated from**: @ui-designer/analysis.md, @user-researcher/analysis.md
|
||||
- Component specifications and interaction patterns
|
||||
- Visual design system and accessibility requirements
|
||||
- User flow and interface specifications
|
||||
|
||||
### Discussion Point 2: Technical Considerations
|
||||
**Framework Questions**: @topic-framework.md (Technical Considerations section)
|
||||
### Architecture Design
|
||||
**Consolidated from**: @system-architect/analysis.md, @data-architect/analysis.md
|
||||
- System architecture and component interactions
|
||||
- Data flow and storage strategy
|
||||
- Technology stack decisions
|
||||
|
||||
**Role Perspectives**:
|
||||
- **System Architect**: @system-architect/analysis.md (technical section)
|
||||
- **Data Architect**: @data-architect/analysis.md (technical section)
|
||||
- **UI Designer**: @ui-designer/analysis.md (technical section)
|
||||
### Security Framework
|
||||
**Consolidated from**: @security-expert/analysis.md
|
||||
- Authentication and authorization patterns
|
||||
- Data protection and compliance requirements
|
||||
- Security monitoring and audit strategy
|
||||
|
||||
**Cross-Role Insights**:
|
||||
- [Technical consensus and conflicts]
|
||||
- [Implementation recommendations]
|
||||
## Implementation Roadmap
|
||||
### Development Phases
|
||||
**Phase 1** (0-3 months): Foundation and core features
|
||||
**Phase 2** (3-6 months): Advanced features and integrations
|
||||
**Phase 3** (6+ months): Optimization and innovation
|
||||
|
||||
### ⚡ Breakthrough Ideas
|
||||
**Innovation Opportunities**:
|
||||
1. **{breakthrough_idea_1}**
|
||||
- Origin: {source_role}
|
||||
- Cross-role support: {supporting_roles}
|
||||
- Innovation potential: {potential_assessment}
|
||||
### Technical Guidelines
|
||||
- Development standards and code organization
|
||||
- Testing strategy and quality assurance
|
||||
- Deployment and monitoring approach
|
||||
|
||||
2. **{breakthrough_idea_2}**
|
||||
- Origin: {source_role}
|
||||
- Cross-role support: {supporting_roles}
|
||||
- Innovation potential: {potential_assessment}
|
||||
|
||||
### 🔄 Areas of Disagreement
|
||||
**Tension Points Requiring Resolution**:
|
||||
1. **{disagreement_area_1}**
|
||||
- Conflicting views: {role1_view} vs {role2_view}
|
||||
- Root cause: {underlying_issue}
|
||||
- Resolution approach: {recommended_resolution}
|
||||
|
||||
2. **{disagreement_area_2}**
|
||||
- Conflicting views: {role1_view} vs {role2_view}
|
||||
- Root cause: {underlying_issue}
|
||||
- Resolution approach: {recommended_resolution}
|
||||
|
||||
## Comprehensive Recommendations Matrix
|
||||
|
||||
### 🎯 High Priority (Immediate Action)
|
||||
| Recommendation | Business Impact | Technical Feasibility | Implementation Effort | Risk Level | Supporting Roles |
|
||||
|----------------|-----------------|----------------------|---------------------|------------|------------------|
|
||||
| {rec_1} | High | High | Medium | Low | PM, Arch, UX |
|
||||
| {rec_2} | High | Medium | Low | Medium | BA, PM, FP |
|
||||
|
||||
### 📋 Medium Priority (Strategic Planning)
|
||||
| Recommendation | Business Impact | Technical Feasibility | Implementation Effort | Risk Level | Supporting Roles |
|
||||
|----------------|-----------------|----------------------|---------------------|------------|------------------|
|
||||
| {rec_3} | Medium | High | High | Medium | Arch, DA, Sec |
|
||||
| {rec_4} | Medium | Medium | Medium | Low | UX, UR, PM |
|
||||
|
||||
### 🔬 Research Priority (Future Investigation)
|
||||
| Recommendation | Business Impact | Technical Feasibility | Implementation Effort | Risk Level | Supporting Roles |
|
||||
|----------------|-----------------|----------------------|---------------------|------------|------------------|
|
||||
| {rec_5} | High | Unknown | High | High | IL, Arch, PM |
|
||||
| {rec_6} | Medium | Low | High | High | IL, DA, Sec |
|
||||
|
||||
## Implementation Strategy
|
||||
|
||||
### Phase 1: Foundation (0-3 months)
|
||||
- **Focus**: High-priority, low-effort recommendations
|
||||
- **Key Actions**: {action_list}
|
||||
- **Success Metrics**: {metrics_list}
|
||||
- **Required Resources**: {resource_list}
|
||||
|
||||
### Phase 2: Development (3-9 months)
|
||||
- **Focus**: Medium-priority strategic initiatives
|
||||
- **Key Actions**: {action_list}
|
||||
- **Success Metrics**: {metrics_list}
|
||||
- **Required Resources**: {resource_list}
|
||||
|
||||
### Phase 3: Innovation (9+ months)
|
||||
- **Focus**: Research and breakthrough opportunities
|
||||
- **Key Actions**: {action_list}
|
||||
- **Success Metrics**: {metrics_list}
|
||||
- **Required Resources**: {resource_list}
|
||||
|
||||
## Risk Assessment and Mitigation
|
||||
### Task Breakdown
|
||||
- Epic and feature mapping aligned with requirements
|
||||
- Sprint planning guidance with dependency management
|
||||
- Resource allocation and timeline recommendations
|
||||
|
||||
## Risk Assessment & Mitigation
|
||||
### Critical Risks Identified
|
||||
1. **{risk_1}**: {description} | Mitigation: {strategy}
|
||||
2. **{risk_2}**: {description} | Mitigation: {strategy}
|
||||
1. **Risk**: Description | **Mitigation**: Strategy
|
||||
2. **Risk**: Description | **Mitigation**: Strategy
|
||||
|
||||
### Success Factors
|
||||
- {success_factor_1}
|
||||
- {success_factor_2}
|
||||
- {success_factor_3}
|
||||
|
||||
## Next Steps and Follow-up
|
||||
### Immediate Actions Required
|
||||
### Decision Points Needing Resolution
|
||||
### Continuous Monitoring Requirements
|
||||
### Future Brainstorming Sessions Recommended
|
||||
- Key factors for implementation success
|
||||
- Continuous monitoring requirements
|
||||
- Quality gates and validation checkpoints
|
||||
|
||||
---
|
||||
*This synthesis integrates insights from {role_count} perspectives to provide comprehensive strategic guidance.*
|
||||
*Complete implementation specification consolidating all role perspectives into actionable guidance*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Status Synchronization
|
||||
### Streamlined Status Synchronization
|
||||
Upon completion, update `workflow-session.json`:
|
||||
```json
|
||||
{
|
||||
@@ -275,18 +239,22 @@ Upon completion, update `workflow-session.json`:
|
||||
"status": "completed",
|
||||
"synthesis_completed": true,
|
||||
"completed_at": "timestamp",
|
||||
"participating_roles": ["product-manager", "system-architect", "ui-designer", ...],
|
||||
"key_outputs": {
|
||||
"synthesis_report": ".workflow/WFS-{topic}/.brainstorming/synthesis-report.md",
|
||||
"action_plan": ".workflow/WFS-{topic}/.brainstorming/action-plan.md",
|
||||
"recommendations_matrix": ".workflow/WFS-{topic}/.brainstorming/recommendations-matrix.md"
|
||||
"participating_roles": ["product-manager", "system-architect", "ui-designer", "security-expert", "data-architect", ...],
|
||||
"consolidated_output": {
|
||||
"synthesis_specification": ".workflow/WFS-{topic}/.brainstorming/synthesis-specification.md"
|
||||
},
|
||||
"metrics": {
|
||||
"roles_analyzed": 9,
|
||||
"consensus_areas": 5,
|
||||
"breakthrough_ideas": 3,
|
||||
"high_priority_recommendations": 8,
|
||||
"implementation_phases": 3
|
||||
"synthesis_quality": {
|
||||
"role_integration": "complete",
|
||||
"requirement_coverage": "comprehensive",
|
||||
"implementation_readiness": "ready"
|
||||
},
|
||||
"content_metrics": {
|
||||
"roles_synthesized": 9,
|
||||
"functional_requirements": 25,
|
||||
"non_functional_requirements": 12,
|
||||
"business_requirements": 8,
|
||||
"implementation_phases": 3,
|
||||
"risk_factors_identified": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
509
.claude/commands/workflow/execute.md
Normal file
509
.claude/commands/workflow/execute.md
Normal file
@@ -0,0 +1,509 @@
|
||||
---
|
||||
name: execute
|
||||
description: Coordinate agents for existing workflow tasks with automatic discovery
|
||||
usage: /workflow:execute [--resume-session="session-id"]
|
||||
argument-hint: [--resume-session="session-id"]
|
||||
examples:
|
||||
- /workflow:execute
|
||||
- /workflow:execute --resume-session="WFS-user-auth"
|
||||
---
|
||||
|
||||
# Workflow Execute Command
|
||||
|
||||
## Overview
|
||||
Orchestrates autonomous workflow execution through systematic task discovery, agent coordination, and progress tracking. **Executes entire workflow without user interruption**, providing complete context to agents and ensuring proper flow control execution with comprehensive TodoWrite tracking.
|
||||
|
||||
**Resume Mode**: When called with `--resume-session` flag, skips discovery phase and directly enters TodoWrite generation and agent execution for the specified session.
|
||||
|
||||
## Core Rules
|
||||
**Complete entire workflow autonomously without user interruption, using TodoWrite for comprehensive progress tracking.**
|
||||
**Execute all discovered pending tasks sequentially until workflow completion or blocking dependency.**
|
||||
|
||||
## Core Responsibilities
|
||||
- **Session Discovery**: Identify and select active workflow sessions
|
||||
- **Task Dependency Resolution**: Analyze task relationships and execution order
|
||||
- **TodoWrite Progress Tracking**: Maintain real-time execution status throughout entire workflow
|
||||
- **Agent Orchestration**: Coordinate specialized agents with complete context
|
||||
- **Flow Control Execution**: Execute pre-analysis steps and context accumulation
|
||||
- **Status Synchronization**: Update task JSON files and workflow state
|
||||
- **Autonomous Completion**: Continue execution until all tasks complete or reach blocking state
|
||||
|
||||
## Execution Philosophy
|
||||
- **Discovery-first**: Auto-discover existing plans and tasks
|
||||
- **Status-aware**: Execute only ready tasks with resolved dependencies
|
||||
- **Context-rich**: Provide complete task JSON and accumulated context to agents
|
||||
- **Progress tracking**: **Continuous TodoWrite updates throughout entire workflow execution**
|
||||
- **Flow control**: Sequential step execution with variable passing
|
||||
- **Autonomous completion**: **Execute all tasks without user interruption until workflow complete**
|
||||
|
||||
## Flow Control Execution
|
||||
**[FLOW_CONTROL]** marker indicates sequential step execution required for context gathering and preparation. **These steps are executed BY THE AGENT, not by the workflow:execute command.**
|
||||
|
||||
### Flow Control Rules
|
||||
1. **Auto-trigger**: When `task.flow_control.pre_analysis` array exists in task JSON, agents execute these steps
|
||||
2. **Sequential Processing**: Agents execute steps in order, accumulating context
|
||||
3. **Variable Passing**: Agents use `[variable_name]` syntax to reference step outputs
|
||||
4. **Error Handling**: Agents follow step-specific error strategies (`fail`, `skip_optional`, `retry_once`)
|
||||
|
||||
### Execution Pattern
|
||||
```
|
||||
Step 1: load_dependencies → dependency_context
|
||||
Step 2: analyze_patterns [dependency_context] → pattern_analysis
|
||||
Step 3: implement_solution [pattern_analysis] [dependency_context] → implementation
|
||||
```
|
||||
|
||||
### Context Accumulation Process (Executed by Agents)
|
||||
- **Load Dependencies**: Agents retrieve summaries from `context.depends_on` tasks
|
||||
- **Execute Analysis**: Agents run CLI tools with accumulated context
|
||||
- **Prepare Implementation**: Agents build comprehensive context for implementation
|
||||
- **Continue Implementation**: Agents use all accumulated context for task execution
|
||||
|
||||
## Execution Lifecycle
|
||||
|
||||
### Resume Mode Detection
|
||||
**Special Flag Processing**: When `--resume-session="session-id"` is provided:
|
||||
1. **Skip Discovery Phase**: Use provided session ID directly
|
||||
2. **Load Specified Session**: Read session state from `.workflow/{session-id}/`
|
||||
3. **Direct TodoWrite Generation**: Skip to Phase 3 (Planning) immediately
|
||||
4. **Accelerated Execution**: Enter agent coordination without validation delays
|
||||
|
||||
### Phase 1: Discovery (Normal Mode Only)
|
||||
1. **Check Active Sessions**: Find `.workflow/.active-*` markers
|
||||
2. **Select Session**: If multiple found, prompt user selection
|
||||
3. **Load Session State**: Read `workflow-session.json` and `IMPL_PLAN.md`
|
||||
4. **Scan Tasks**: Analyze `.task/*.json` files for ready tasks
|
||||
|
||||
**Note**: In resume mode, this phase is completely skipped.
|
||||
|
||||
### Phase 2: Analysis (Normal Mode Only)
|
||||
1. **Dependency Resolution**: Build execution order based on `depends_on`
|
||||
2. **Status Validation**: Filter tasks with `status: "pending"` and met dependencies
|
||||
3. **Agent Assignment**: Determine agent type from `meta.agent` or `meta.type`
|
||||
4. **Context Preparation**: Load dependency summaries and inherited context
|
||||
|
||||
**Note**: In resume mode, this phase is also skipped as session analysis was already completed by `/workflow:status`.
|
||||
|
||||
### Phase 3: Planning (Resume Mode Entry Point)
|
||||
**This is where resume mode directly enters after skipping Phases 1 & 2**
|
||||
|
||||
1. **Create TodoWrite List**: Generate task list with status markers from session state
|
||||
2. **Mark Initial Status**: Set first pending task as `in_progress`
|
||||
3. **Prepare Session Context**: Inject workflow paths for agent use (using provided session-id)
|
||||
4. **Prepare Complete Task JSON**: Include pre_analysis and flow control steps for agent consumption
|
||||
5. **Validate Prerequisites**: Ensure all required context is available from existing session
|
||||
|
||||
**Resume Mode Behavior**:
|
||||
- Load existing session state directly from `.workflow/{session-id}/`
|
||||
- Use session's task files and summaries without discovery
|
||||
- Generate TodoWrite from current session progress
|
||||
- Proceed immediately to agent execution
|
||||
|
||||
### Phase 4: Execution
|
||||
1. **Pass Task with Flow Control**: Include complete task JSON with `pre_analysis` steps for agent execution
|
||||
2. **Launch Agent**: Invoke specialized agent with complete context including flow control steps
|
||||
3. **Monitor Progress**: Track agent execution and handle errors without user interruption
|
||||
4. **Collect Results**: Gather implementation results and outputs
|
||||
5. **Continue Workflow**: Automatically proceed to next pending task until completion
|
||||
|
||||
### Phase 5: Completion
|
||||
1. **Update Task Status**: Mark completed tasks in JSON files
|
||||
2. **Generate Summary**: Create task summary in `.summaries/`
|
||||
3. **Update TodoWrite**: Mark current task complete, advance to next
|
||||
4. **Synchronize State**: Update session state and workflow status
|
||||
5. **Check Workflow Complete**: Verify all tasks are completed
|
||||
6. **Auto-Complete Session**: Call `/workflow:session:complete` when all tasks finished
|
||||
|
||||
## Task Discovery & Queue Building
|
||||
|
||||
### Session Discovery Process (Normal Mode)
|
||||
```
|
||||
├── Check for .active-* markers in .workflow/
|
||||
├── If multiple active sessions found → Prompt user to select
|
||||
├── Locate selected session's workflow folder
|
||||
├── Load selected session's workflow-session.json and IMPL_PLAN.md
|
||||
├── Scan selected session's .task/ directory for task JSON files
|
||||
├── Analyze task statuses and dependencies for selected session only
|
||||
└── Build execution queue of ready tasks from selected session
|
||||
```
|
||||
|
||||
### Resume Mode Process (--resume-session flag)
|
||||
```
|
||||
├── Use provided session-id directly (skip discovery)
|
||||
├── Validate .workflow/{session-id}/ directory exists
|
||||
├── Load session's workflow-session.json and IMPL_PLAN.md directly
|
||||
├── Scan session's .task/ directory for task JSON files
|
||||
├── Use existing task statuses and dependencies (no re-analysis needed)
|
||||
└── Build execution queue from session state (prioritize pending/in-progress tasks)
|
||||
```
|
||||
|
||||
### Task Status Logic
|
||||
```
|
||||
pending + dependencies_met → executable
|
||||
completed → skip
|
||||
blocked → skip until dependencies clear
|
||||
```
|
||||
|
||||
## TodoWrite Coordination
|
||||
**Comprehensive workflow tracking** with immediate status updates throughout entire execution without user interruption:
|
||||
|
||||
#### TodoWrite Workflow Rules
|
||||
1. **Initial Creation**: Generate TodoWrite from discovered pending tasks for entire workflow
|
||||
- **Normal Mode**: Create from discovery results
|
||||
- **Resume Mode**: Create from existing session state and current progress
|
||||
2. **Single In-Progress**: Mark ONLY ONE task as `in_progress` at a time
|
||||
3. **Immediate Updates**: Update status after each task completion without user interruption
|
||||
4. **Status Synchronization**: Sync with JSON task files after updates
|
||||
5. **Continuous Tracking**: Maintain TodoWrite throughout entire workflow execution until completion
|
||||
|
||||
#### Resume Mode TodoWrite Generation
|
||||
**Special behavior when `--resume-session` flag is present**:
|
||||
- Load existing session progress from `.workflow/{session-id}/TODO_LIST.md`
|
||||
- Identify currently in-progress or next pending task
|
||||
- Generate TodoWrite starting from interruption point
|
||||
- Preserve completed task history in TodoWrite display
|
||||
- Focus on remaining pending tasks for execution
|
||||
|
||||
#### TodoWrite Tool Usage
|
||||
**Use Claude Code's built-in TodoWrite tool** to track workflow progress in real-time:
|
||||
|
||||
```javascript
|
||||
// Create initial todo list from discovered pending tasks
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Execute IMPL-1.1: Design auth schema [code-developer] [FLOW_CONTROL]",
|
||||
status: "pending",
|
||||
activeForm: "Executing IMPL-1.1: Design auth schema"
|
||||
},
|
||||
{
|
||||
content: "Execute IMPL-1.2: Implement auth logic [code-developer] [FLOW_CONTROL]",
|
||||
status: "pending",
|
||||
activeForm: "Executing IMPL-1.2: Implement auth logic"
|
||||
},
|
||||
{
|
||||
content: "Execute IMPL-2: Review implementations [code-review-agent]",
|
||||
status: "pending",
|
||||
activeForm: "Executing IMPL-2: Review implementations"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// Update status as tasks progress - ONLY ONE task should be in_progress at a time
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Execute IMPL-1.1: Design auth schema [code-developer] [FLOW_CONTROL]",
|
||||
status: "in_progress", // Mark current task as in_progress
|
||||
activeForm: "Executing IMPL-1.1: Design auth schema"
|
||||
},
|
||||
// ... other tasks remain pending
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**TodoWrite Integration Rules**:
|
||||
- **Continuous Workflow Tracking**: Use TodoWrite tool throughout entire workflow execution
|
||||
- **Real-time Updates**: Immediate progress tracking without user interruption
|
||||
- **Single Active Task**: Only ONE task marked as `in_progress` at any time
|
||||
- **Immediate Completion**: Mark tasks `completed` immediately after finishing
|
||||
- **Status Sync**: Sync TodoWrite status with JSON task files after each update
|
||||
- **Full Execution**: Continue TodoWrite tracking until all workflow tasks complete
|
||||
- **Workflow Completion Check**: When all tasks marked `completed`, auto-call `/workflow:session:complete`
|
||||
|
||||
#### TODO_LIST.md Update Timing
|
||||
- **Before Agent Launch**: Update TODO_LIST.md to mark task as `in_progress` (⚠️)
|
||||
- **After Task Complete**: Update TODO_LIST.md to mark as `completed` (✅), advance to next
|
||||
- **On Error**: Keep as `in_progress` in TODO_LIST.md, add error note
|
||||
- **Workflow Complete**: When all tasks completed, call `/workflow:session:complete`
|
||||
- **Session End**: Sync all TODO_LIST.md statuses with JSON task files
|
||||
|
||||
### 3. Agent Context Management
|
||||
**Comprehensive context preparation** for autonomous agent execution:
|
||||
|
||||
#### Context Sources (Priority Order)
|
||||
1. **Complete Task JSON**: Full task definition including all fields
|
||||
2. **Flow Control Context**: Accumulated outputs from pre_analysis steps
|
||||
3. **Dependency Summaries**: Previous task completion summaries
|
||||
4. **Session Context**: Workflow paths and session metadata
|
||||
5. **Inherited Context**: Parent task context and shared variables
|
||||
|
||||
#### Context Assembly Process
|
||||
```
|
||||
1. Load Task JSON → Base context
|
||||
2. Execute Flow Control → Accumulated context
|
||||
3. Load Dependencies → Dependency context
|
||||
4. Prepare Session Paths → Session context
|
||||
5. Combine All → Complete agent context
|
||||
```
|
||||
|
||||
#### Agent Context Package Structure
|
||||
```json
|
||||
{
|
||||
"task": { /* Complete task JSON */ },
|
||||
"flow_context": {
|
||||
"step_outputs": { "pattern_analysis": "...", "dependency_context": "..." }
|
||||
},
|
||||
"session": {
|
||||
"workflow_dir": ".workflow/WFS-session/",
|
||||
"todo_list_path": ".workflow/WFS-session/TODO_LIST.md",
|
||||
"summaries_dir": ".workflow/WFS-session/.summaries/",
|
||||
"task_json_path": ".workflow/WFS-session/.task/IMPL-1.1.json"
|
||||
},
|
||||
"dependencies": [ /* Task summaries from depends_on */ ],
|
||||
"inherited": { /* Parent task context */ }
|
||||
}
|
||||
```
|
||||
|
||||
#### Context Validation Rules
|
||||
- **Task JSON Complete**: All 5 fields present and valid
|
||||
- **Flow Control Ready**: All pre_analysis steps completed if present
|
||||
- **Dependencies Loaded**: All depends_on summaries available
|
||||
- **Session Paths Valid**: All workflow paths exist and accessible
|
||||
- **Agent Assignment**: Valid agent type specified in meta.agent
|
||||
|
||||
### 4. Agent Execution Pattern
|
||||
**Structured agent invocation** with complete context and clear instructions:
|
||||
|
||||
#### Agent Prompt Template
|
||||
```bash
|
||||
Task(subagent_type="{meta.agent}",
|
||||
prompt="**TASK EXECUTION WITH FULL JSON LOADING**
|
||||
|
||||
## STEP 1: Load Complete Task JSON
|
||||
**MANDATORY**: First load the complete task JSON from: {session.task_json_path}
|
||||
|
||||
cat {session.task_json_path}
|
||||
|
||||
**CRITICAL**: Validate all 5 required fields are present:
|
||||
- id, title, status, meta, context, flow_control
|
||||
|
||||
## STEP 2: Task Definition (From Loaded JSON)
|
||||
**ID**: Use id field from JSON
|
||||
**Title**: Use title field from JSON
|
||||
**Type**: Use meta.type field from JSON
|
||||
**Agent**: Use meta.agent field from JSON
|
||||
**Status**: Verify status is pending or active
|
||||
|
||||
## STEP 3: Flow Control Execution (if flow_control.pre_analysis exists)
|
||||
**AGENT RESPONSIBILITY**: Execute pre_analysis steps sequentially from loaded JSON:
|
||||
|
||||
For each step in flow_control.pre_analysis array:
|
||||
1. Execute step.command with variable substitution
|
||||
2. Store output to step.output_to variable
|
||||
3. Handle errors per step.on_error strategy
|
||||
4. Pass accumulated variables to next step
|
||||
|
||||
## STEP 4: Implementation Context (From JSON context field)
|
||||
**Requirements**: Use context.requirements array from JSON
|
||||
**Focus Paths**: Use context.focus_paths array from JSON
|
||||
**Acceptance Criteria**: Use context.acceptance array from JSON
|
||||
**Dependencies**: Use context.depends_on array from JSON
|
||||
**Parent Context**: Use context.inherited object from JSON
|
||||
**Target Files**: Use flow_control.target_files array from JSON
|
||||
**Implementation Approach**: Use flow_control.implementation_approach object from JSON
|
||||
|
||||
## STEP 5: Session Context (Provided by workflow:execute)
|
||||
**Workflow Directory**: {session.workflow_dir}
|
||||
**TODO List Path**: {session.todo_list_path}
|
||||
**Summaries Directory**: {session.summaries_dir}
|
||||
**Task JSON Path**: {session.task_json_path}
|
||||
**Flow Context**: {flow_context.step_outputs}
|
||||
|
||||
## STEP 6: Agent Completion Requirements
|
||||
1. **Load Task JSON**: Read and validate complete task structure
|
||||
2. **Execute Flow Control**: Run all pre_analysis steps if present
|
||||
3. **Implement Solution**: Follow implementation_approach from JSON
|
||||
4. **Update Progress**: Mark task status in JSON as completed
|
||||
5. **Update TODO List**: Update TODO_LIST.md at provided path
|
||||
6. **Generate Summary**: Create completion summary in summaries directory
|
||||
7. **Check Workflow Complete**: After task completion, check if all workflow tasks done
|
||||
8. **Auto-Complete Session**: If all tasks completed, call SlashCommand(\"/workflow:session:complete\")
|
||||
|
||||
**JSON UPDATE COMMAND**:
|
||||
Update task status to completed using jq:
|
||||
jq '.status = \"completed\"' {session.task_json_path} > temp.json && mv temp.json {session.task_json_path}
|
||||
|
||||
**WORKFLOW COMPLETION CHECK**:
|
||||
After updating task status, check if workflow is complete:
|
||||
total_tasks=\$(ls .workflow/*/\.task/*.json | wc -l)
|
||||
completed_tasks=\$(ls .workflow/*/\.summaries/*.md 2>/dev/null | wc -l)
|
||||
if [ \$total_tasks -eq \$completed_tasks ]; then
|
||||
SlashCommand(command=\"/workflow:session:complete\")
|
||||
fi"),
|
||||
description="Execute task with full JSON loading and validation")
|
||||
```
|
||||
|
||||
#### Agent JSON Loading Specification
|
||||
**MANDATORY AGENT PROTOCOL**: All agents must follow this exact loading sequence:
|
||||
|
||||
1. **JSON Loading**: First action must be `cat {session.task_json_path}`
|
||||
2. **Field Validation**: Verify all 5 required fields exist: `id`, `title`, `status`, `meta`, `context`, `flow_control`
|
||||
3. **Structure Parsing**: Parse nested fields correctly:
|
||||
- `meta.type` and `meta.agent` (NOT flat `task_type`)
|
||||
- `context.requirements`, `context.focus_paths`, `context.acceptance`
|
||||
- `context.depends_on`, `context.inherited`
|
||||
- `flow_control.pre_analysis` array, `flow_control.target_files`
|
||||
4. **Flow Control Execution**: If `flow_control.pre_analysis` exists, execute steps sequentially
|
||||
5. **Status Management**: Update JSON status upon completion
|
||||
|
||||
**JSON Field Reference**:
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-1.2",
|
||||
"title": "Task title",
|
||||
"status": "pending|active|completed|blocked",
|
||||
"meta": {
|
||||
"type": "feature|bugfix|refactor|test|docs",
|
||||
"agent": "@code-developer|@planning-agent|@code-review-test-agent"
|
||||
},
|
||||
"context": {
|
||||
"requirements": ["req1", "req2"],
|
||||
"focus_paths": ["src/path1", "src/path2"],
|
||||
"acceptance": ["criteria1", "criteria2"],
|
||||
"depends_on": ["IMPL-1.1"],
|
||||
"inherited": { "from": "parent", "context": ["info"] }
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "step_name",
|
||||
"command": "bash_command",
|
||||
"output_to": "variable",
|
||||
"on_error": "skip_optional|fail|retry_once"
|
||||
}
|
||||
],
|
||||
"implementation_approach": { "task_description": "...", "modification_points": ["..."] },
|
||||
"target_files": ["file:function:lines"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Execution Flow
|
||||
1. **Load Task JSON**: Agent reads and validates complete JSON structure
|
||||
2. **Execute Flow Control**: Agent runs pre_analysis steps if present
|
||||
3. **Prepare Implementation**: Agent uses implementation_approach from JSON
|
||||
4. **Launch Implementation**: Agent follows focus_paths and target_files
|
||||
5. **Update Status**: Agent marks JSON status as completed
|
||||
6. **Generate Summary**: Agent creates completion summary
|
||||
|
||||
#### Agent Assignment Rules
|
||||
```
|
||||
meta.agent specified → Use specified agent
|
||||
meta.agent missing → Infer from meta.type:
|
||||
- "feature" → @code-developer
|
||||
- "test" → @code-review-test-agent
|
||||
- "review" → @code-review-agent
|
||||
- "docs" → @doc-generator
|
||||
```
|
||||
|
||||
#### Error Handling During Execution
|
||||
- **Agent Failure**: Retry once with adjusted context
|
||||
- **Flow Control Error**: Skip optional steps, fail on critical
|
||||
- **Context Missing**: Reload from JSON files and retry
|
||||
- **Timeout**: Mark as blocked, continue with next task
|
||||
|
||||
## Workflow File Structure Reference
|
||||
```
|
||||
.workflow/WFS-[topic-slug]/
|
||||
├── workflow-session.json # Session state and metadata
|
||||
├── IMPL_PLAN.md # Planning document and requirements
|
||||
├── TODO_LIST.md # Progress tracking (auto-updated)
|
||||
├── .task/ # Task definitions (JSON only)
|
||||
│ ├── IMPL-1.json # Main task definitions
|
||||
│ └── IMPL-1.1.json # Subtask definitions
|
||||
├── .summaries/ # Task completion summaries
|
||||
│ ├── IMPL-1-summary.md # Task completion details
|
||||
│ └── IMPL-1.1-summary.md # Subtask completion details
|
||||
└── .process/ # Planning artifacts
|
||||
└── ANALYSIS_RESULTS.md # Planning analysis results
|
||||
```
|
||||
|
||||
## Error Handling & Recovery
|
||||
|
||||
### Discovery Phase Errors
|
||||
| Error | Cause | Resolution | Command |
|
||||
|-------|-------|------------|---------|
|
||||
| No active session | No `.active-*` markers found | Create or resume session | `/workflow:plan "project"` |
|
||||
| Multiple sessions | Multiple `.active-*` markers | Select specific session | Manual choice prompt |
|
||||
| Corrupted session | Invalid JSON files | Recreate session structure | `/workflow:session:status --validate` |
|
||||
| Missing task files | Broken task references | Regenerate tasks | `/task:create` or repair |
|
||||
|
||||
### Execution Phase Errors
|
||||
| Error | Cause | Recovery Strategy | Max Attempts |
|
||||
|-------|-------|------------------|--------------|
|
||||
| Agent failure | Agent crash/timeout | Retry with simplified context | 2 |
|
||||
| Flow control error | Command failure | Skip optional, fail critical | 1 per step |
|
||||
| Context loading error | Missing dependencies | Reload from JSON, use defaults | 3 |
|
||||
| JSON file corruption | File system issues | Restore from backup/recreate | 1 |
|
||||
|
||||
### Recovery Procedures
|
||||
|
||||
#### Session Recovery
|
||||
```bash
|
||||
# Check session integrity
|
||||
find .workflow -name ".active-*" | while read marker; do
|
||||
session=$(basename "$marker" | sed 's/^\.active-//')
|
||||
if [ ! -d ".workflow/$session" ]; then
|
||||
echo "Removing orphaned marker: $marker"
|
||||
rm "$marker"
|
||||
fi
|
||||
done
|
||||
|
||||
# Recreate corrupted session files
|
||||
if [ ! -f ".workflow/$session/workflow-session.json" ]; then
|
||||
echo '{"session_id":"'$session'","status":"active"}' > ".workflow/$session/workflow-session.json"
|
||||
fi
|
||||
```
|
||||
|
||||
#### Task Recovery
|
||||
```bash
|
||||
# Validate task JSON integrity
|
||||
for task_file in .workflow/$session/.task/*.json; do
|
||||
if ! jq empty "$task_file" 2>/dev/null; then
|
||||
echo "Corrupted task file: $task_file"
|
||||
# Backup and regenerate or restore from backup
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix missing dependencies
|
||||
missing_deps=$(jq -r '.context.depends_on[]?' .workflow/$session/.task/*.json | sort -u)
|
||||
for dep in $missing_deps; do
|
||||
if [ ! -f ".workflow/$session/.task/$dep.json" ]; then
|
||||
echo "Missing dependency: $dep - creating placeholder"
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
#### Context Recovery
|
||||
```bash
|
||||
# Reload context from available sources
|
||||
if [ -f ".workflow/$session/.process/ANALYSIS_RESULTS.md" ]; then
|
||||
echo "Reloading planning context..."
|
||||
fi
|
||||
|
||||
# Restore from documentation if available
|
||||
if [ -d ".workflow/docs/" ]; then
|
||||
echo "Using documentation context as fallback..."
|
||||
fi
|
||||
```
|
||||
|
||||
### Error Prevention
|
||||
- **Pre-flight Checks**: Validate session integrity before execution
|
||||
- **Backup Strategy**: Create task snapshots before major operations
|
||||
- **Atomic Updates**: Update JSON files atomically to prevent corruption
|
||||
- **Dependency Validation**: Check all depends_on references exist
|
||||
- **Context Verification**: Ensure all required context is available
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Basic Usage
|
||||
```bash
|
||||
/workflow:execute # Execute all pending tasks autonomously
|
||||
/workflow:session:status # Check progress
|
||||
/task:execute IMPL-1.2 # Execute specific task
|
||||
```
|
||||
|
||||
### Integration
|
||||
- **Planning**: `/workflow:plan` → `/workflow:execute` → `/workflow:review`
|
||||
- **Recovery**: `/workflow:session:tatus --validate` → `/workflow:execute`
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
---
|
||||
name: resume
|
||||
description: Intelligent workflow resumption with automatic interruption point detection
|
||||
usage: /workflow:resume [options]
|
||||
argument-hint: [--from TASK-ID] [--retry] [--skip TASK-ID] [--force]
|
||||
examples:
|
||||
- /workflow:resume
|
||||
- /workflow:resume --from impl-1.2
|
||||
- /workflow:resume --retry impl-1.1
|
||||
- /workflow:resume --skip impl-2.1 --from impl-2.2
|
||||
---
|
||||
|
||||
# Workflow Resume Command (/workflow:resume)
|
||||
|
||||
## Overview
|
||||
Intelligently resumes interrupted workflows with automatic detection of interruption points, context restoration, and flexible recovery strategies. Maintains execution continuity while adapting to various interruption scenarios.
|
||||
|
||||
## Core Principles
|
||||
**File Structure:** @~/.claude/workflows/workflow-architecture.md
|
||||
|
||||
**Dependency Context Rules:**
|
||||
- **For tasks with dependencies**: MUST read previous task summary documents before resuming
|
||||
- **Context inheritance**: Use dependency summaries to maintain consistency and avoid duplicate work
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:resume [--from TASK-ID] [--retry] [--skip TASK-ID] [--force]
|
||||
```
|
||||
|
||||
### Recovery Options
|
||||
|
||||
#### Automatic Recovery (Default)
|
||||
```bash
|
||||
/workflow:resume
|
||||
```
|
||||
**Behavior**:
|
||||
- Auto-detects interruption point from task statuses
|
||||
- Resumes from first incomplete task in dependency order
|
||||
- Rebuilds agent context automatically
|
||||
|
||||
#### Targeted Recovery
|
||||
```bash
|
||||
/workflow:resume --from impl-1.2
|
||||
```
|
||||
**Behavior**:
|
||||
- Resumes from specific task ID
|
||||
- Validates dependencies are met
|
||||
- Updates subsequent task readiness
|
||||
|
||||
#### Retry Failed Tasks
|
||||
```bash
|
||||
/workflow:resume --retry impl-1.1
|
||||
```
|
||||
**Behavior**:
|
||||
- Retries previously failed task
|
||||
- Analyzes failure context
|
||||
- Applies enhanced error handling
|
||||
|
||||
#### Skip Blocked Tasks
|
||||
```bash
|
||||
/workflow:resume --skip impl-2.1 --from impl-2.2
|
||||
```
|
||||
**Behavior**:
|
||||
- Marks specified task as skipped
|
||||
- Continues execution from target task
|
||||
- Adjusts dependency chain
|
||||
|
||||
#### Force Recovery
|
||||
```bash
|
||||
/workflow:resume --force
|
||||
```
|
||||
**Behavior**:
|
||||
- Bypasses dependency validation
|
||||
- Forces execution regardless of task states
|
||||
- For emergency recovery scenarios
|
||||
|
||||
## Interruption Detection Logic
|
||||
|
||||
### Session State Analysis
|
||||
```
|
||||
Interruption Analysis:
|
||||
├── Load active session from .workflow/.active-* marker
|
||||
├── Read workflow-session.json for last execution state
|
||||
├── Scan .task/ directory for task statuses
|
||||
├── Analyze TODO_LIST.md progress markers
|
||||
├── Check .summaries/ for completion records
|
||||
└── Detect interruption point and failure patterns
|
||||
```
|
||||
|
||||
**Detection Criteria**:
|
||||
- **Normal Interruption**: Last task marked as "in_progress" without completion
|
||||
- **Failure Interruption**: Task marked as "failed" with error context
|
||||
- **Dependency Interruption**: Tasks blocked due to failed dependencies
|
||||
- **Agent Interruption**: Agent execution terminated without status update
|
||||
|
||||
### Context Restoration Process
|
||||
```json
|
||||
{
|
||||
"interruption_analysis": {
|
||||
"session_id": "WFS-user-auth",
|
||||
"last_active_task": "impl-1.2",
|
||||
"interruption_type": "agent_timeout",
|
||||
"interruption_time": "2025-09-15T14:30:00Z",
|
||||
"affected_tasks": ["impl-1.2", "impl-1.3"],
|
||||
"pending_dependencies": [],
|
||||
"recovery_strategy": "retry_with_enhanced_context"
|
||||
},
|
||||
"execution_state": {
|
||||
"completed_tasks": ["impl-1.1"],
|
||||
"failed_tasks": [],
|
||||
"in_progress_tasks": ["impl-1.2"],
|
||||
"pending_tasks": ["impl-1.3", "impl-2.1"],
|
||||
"skipped_tasks": [],
|
||||
"blocked_tasks": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Resume Execution Flow
|
||||
|
||||
### 1. Session Discovery & Validation
|
||||
```
|
||||
Session Validation:
|
||||
├── Verify active session exists (.workflow/.active-*)
|
||||
├── Load session metadata (workflow-session.json)
|
||||
├── Validate task files integrity (.task/*.json)
|
||||
├── Check IMPL_PLAN.md consistency
|
||||
└── Rebuild execution context
|
||||
```
|
||||
|
||||
**Validation Checks**:
|
||||
- **Session Integrity**: All required files present and readable
|
||||
- **Task Consistency**: Task JSON files match TODO_LIST.md entries
|
||||
- **Dependency Chain**: Task dependencies are logically consistent
|
||||
- **Agent Context**: Previous agent outputs available in .summaries/
|
||||
|
||||
### 2. Interruption Point Analysis
|
||||
```pseudo
|
||||
function detect_interruption():
|
||||
last_execution = read_session_state()
|
||||
task_statuses = scan_task_files()
|
||||
|
||||
for task in dependency_order:
|
||||
if task.status == "in_progress" and no_completion_summary():
|
||||
return InterruptionPoint(task, "agent_interruption")
|
||||
elif task.status == "failed":
|
||||
return InterruptionPoint(task, "task_failure")
|
||||
elif task.status == "pending" and dependencies_met(task):
|
||||
return InterruptionPoint(task, "ready_to_execute")
|
||||
|
||||
return InterruptionPoint(null, "workflow_complete")
|
||||
```
|
||||
|
||||
### 3. Context Reconstruction
|
||||
**Agent Context Rebuilding**:
|
||||
```bash
|
||||
# Reconstruct complete agent context from interruption point
|
||||
Task(subagent_type="code-developer",
|
||||
prompt="[RESUME_CONTEXT] [FLOW_CONTROL] Resume impl-1.2: Implement JWT authentication
|
||||
|
||||
RESUMPTION CONTEXT:
|
||||
- Interruption Type: agent_timeout
|
||||
- Previous Attempt: 2025-09-15T14:30:00Z
|
||||
- Completed Tasks: impl-1.1 (auth schema design)
|
||||
- Current Task State: in_progress
|
||||
- Recovery Strategy: retry_with_enhanced_context
|
||||
- Interrupted at Flow Step: analyze_patterns
|
||||
|
||||
AVAILABLE CONTEXT:
|
||||
- Completed Task Summaries: .workflow/WFS-user-auth/.summaries/impl-1.1-summary.md
|
||||
- Previous Progress: Check .workflow/WFS-user-auth/TODO_LIST.md for partial completion
|
||||
- Task Definition: .workflow/WFS-user-auth/.task/impl-1.2.json
|
||||
- Session State: .workflow/WFS-user-auth/workflow-session.json
|
||||
|
||||
FLOW CONTROL RECOVERY:
|
||||
Resume from step: analyze_patterns
|
||||
$(cat .workflow/WFS-user-auth/.task/impl-1.2.json | jq -r '.flow_control.pre_analysis[] | "- Step: " + .step + " | Action: " + .action + " | Command: " + .command')
|
||||
|
||||
CONTEXT RECOVERY STEPS:
|
||||
1. MANDATORY: Read previous task summary documents for all dependencies
|
||||
2. Load dependency summaries from context.depends_on
|
||||
3. Restore previous step outputs if available
|
||||
4. Resume from interrupted flow control step
|
||||
5. Execute remaining steps with accumulated context
|
||||
6. Generate comprehensive summary with dependency outputs
|
||||
|
||||
Focus Paths: $(cat .workflow/WFS-user-auth/.task/impl-1.2.json | jq -r '.context.focus_paths[]')
|
||||
Target Files: $(cat .workflow/WFS-user-auth/.task/impl-1.2.json | jq -r '.flow_control.target_files[]')
|
||||
|
||||
IMPORTANT:
|
||||
1. Resume flow control from interrupted step with error recovery
|
||||
2. Ensure context continuity through step chain
|
||||
3. Create enhanced summary for dependent tasks
|
||||
4. Update progress tracking upon successful completion",
|
||||
|
||||
description="Resume interrupted task with flow control step recovery")
|
||||
```
|
||||
|
||||
### 4. Resume Coordination with TodoWrite
|
||||
**Always First**: Update TodoWrite with resumption plan
|
||||
```markdown
|
||||
# Workflow Resume Coordination
|
||||
*Session: WFS-[topic-slug] - RESUMPTION*
|
||||
|
||||
## Interruption Analysis
|
||||
- **Interruption Point**: impl-1.2 (JWT implementation)
|
||||
- **Interruption Type**: agent_timeout
|
||||
- **Last Activity**: 2025-09-15T14:30:00Z
|
||||
- **Recovery Strategy**: retry_with_enhanced_context
|
||||
|
||||
## Resume Execution Plan
|
||||
- [x] **TASK-001**: [Completed] Design auth schema (impl-1.1)
|
||||
- [ ] **TASK-002**: [RESUME] [Agent: code-developer] [FLOW_CONTROL] Implement JWT authentication (impl-1.2)
|
||||
- [ ] **TASK-003**: [Pending] [Agent: code-review-agent] Review implementations (impl-1.3)
|
||||
- [ ] **TASK-004**: Update session state and mark workflow complete
|
||||
|
||||
**Resume Markers**:
|
||||
- [RESUME] = Task being resumed from interruption point
|
||||
- [RETRY] = Task being retried after failure
|
||||
- [SKIP] = Task marked as skipped in recovery
|
||||
```
|
||||
|
||||
## Recovery Strategies
|
||||
|
||||
### Strategy Selection Matrix
|
||||
| Interruption Type | Default Strategy | Alternative Options |
|
||||
|------------------|------------------|-------------------|
|
||||
| Agent Timeout | retry_with_enhanced_context | skip_and_continue, manual_review |
|
||||
| Task Failure | analyze_and_retry | skip_task, force_continue |
|
||||
| Dependency Block | resolve_dependencies | skip_blockers, manual_intervention |
|
||||
| Context Loss | rebuild_full_context | partial_recovery, restart_from_checkpoint |
|
||||
|
||||
### Enhanced Context Recovery
|
||||
```bash
|
||||
# For agent timeout or context loss scenarios
|
||||
1. Load all completion summaries
|
||||
2. Analyze current codebase state
|
||||
3. Compare against expected task progress
|
||||
4. Rebuild comprehensive agent context
|
||||
5. Resume with enhanced error handling
|
||||
```
|
||||
|
||||
### Failure Analysis Recovery
|
||||
```bash
|
||||
# For task failure scenarios
|
||||
1. Parse failure logs and error context
|
||||
2. Identify root cause (code, dependency, logic)
|
||||
3. Apply targeted recovery strategy
|
||||
4. Retry with failure-specific enhancements
|
||||
5. Escalate to manual review if repeated failures
|
||||
```
|
||||
|
||||
### Dependency Resolution Recovery
|
||||
```bash
|
||||
# For dependency block scenarios
|
||||
1. Analyze blocked dependency chain
|
||||
2. Identify minimum viable completion set
|
||||
3. Offer skip options for non-critical dependencies
|
||||
4. Resume with adjusted execution plan
|
||||
```
|
||||
|
||||
## Status Synchronization
|
||||
|
||||
### Task Status Updates
|
||||
```json
|
||||
// Before resumption
|
||||
{
|
||||
"id": "impl-1.2",
|
||||
"status": "in_progress",
|
||||
"execution": {
|
||||
"attempts": 1,
|
||||
"last_attempt": "2025-09-15T14:30:00Z",
|
||||
"interruption_reason": "agent_timeout"
|
||||
}
|
||||
}
|
||||
|
||||
// After successful resumption
|
||||
{
|
||||
"id": "impl-1.2",
|
||||
"status": "completed",
|
||||
"execution": {
|
||||
"attempts": 2,
|
||||
"last_attempt": "2025-09-15T15:45:00Z",
|
||||
"completion_time": "2025-09-15T15:45:00Z",
|
||||
"recovery_strategy": "retry_with_enhanced_context"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Session State Updates
|
||||
```json
|
||||
{
|
||||
"current_phase": "EXECUTE",
|
||||
"last_execute_run": "2025-09-15T15:45:00Z",
|
||||
"resume_count": 1,
|
||||
"interruption_history": [
|
||||
{
|
||||
"timestamp": "2025-09-15T14:30:00Z",
|
||||
"reason": "agent_timeout",
|
||||
"affected_task": "impl-1.2",
|
||||
"recovery_strategy": "retry_with_enhanced_context"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling & Recovery
|
||||
|
||||
### Detection Failures
|
||||
```bash
|
||||
# No active session
|
||||
❌ No active workflow session found
|
||||
→ Use: /workflow:session:start or /workflow:plan first
|
||||
|
||||
# Corrupted session state
|
||||
⚠️ Session state corrupted or inconsistent
|
||||
→ Use: /workflow:resume --force for emergency recovery
|
||||
|
||||
# Task dependency conflicts
|
||||
❌ Task dependency chain has conflicts
|
||||
→ Use: /workflow:resume --skip [task-id] to bypass blockers
|
||||
```
|
||||
|
||||
### Recovery Failures
|
||||
```bash
|
||||
# Repeated task failures
|
||||
❌ Task impl-1.2 failed 3 times
|
||||
→ Manual Review Required: Check .summaries/impl-1.2-failure-analysis.md
|
||||
→ Use: /workflow:resume --skip impl-1.2 to continue
|
||||
|
||||
# Agent context reconstruction failures
|
||||
⚠️ Cannot rebuild agent context for impl-1.2
|
||||
→ Use: /workflow:resume --force --from impl-1.3 to skip problematic task
|
||||
|
||||
# Critical dependency failures
|
||||
❌ Critical dependency impl-1.1 failed validation
|
||||
→ Use: /workflow:plan to regenerate tasks or manual intervention required
|
||||
```
|
||||
|
||||
## Advanced Resume Features
|
||||
|
||||
### Step-Level Recovery
|
||||
- **Flow Control Interruption Detection**: Identify which flow control step was interrupted
|
||||
- **Step Context Restoration**: Restore accumulated context up to interruption point
|
||||
- **Partial Step Recovery**: Resume from specific flow control step
|
||||
- **Context Chain Validation**: Verify context continuity through step sequence
|
||||
|
||||
#### Step-Level Resume Options
|
||||
```bash
|
||||
# Resume from specific flow control step
|
||||
/workflow:resume --from-step analyze_patterns impl-1.2
|
||||
|
||||
# Retry specific step with enhanced context
|
||||
/workflow:resume --retry-step gather_context impl-1.2
|
||||
|
||||
# Skip failing step and continue with next
|
||||
/workflow:resume --skip-step analyze_patterns impl-1.2
|
||||
```
|
||||
|
||||
### Enhanced Context Recovery
|
||||
- **Dependency Summary Integration**: Automatic loading of prerequisite task summaries
|
||||
- **Variable State Restoration**: Restore step output variables from previous execution
|
||||
- **Command State Recovery**: Detect partial command execution and resume appropriately
|
||||
- **Error Context Preservation**: Maintain error information for improved retry strategies
|
||||
|
||||
### Checkpoint System
|
||||
- **Step-Level Checkpoints**: Created after each successful flow control step
|
||||
- **Context State Snapshots**: Save variable states at each checkpoint
|
||||
- **Rollback Capability**: Option to resume from previous valid step checkpoint
|
||||
|
||||
### Parallel Task Recovery
|
||||
```bash
|
||||
# Resume multiple independent tasks simultaneously
|
||||
/workflow:resume --parallel --from impl-2.1,impl-3.1
|
||||
```
|
||||
|
||||
### Resume with Analysis Refresh
|
||||
```bash
|
||||
# Resume with updated project analysis
|
||||
/workflow:resume --refresh-analysis --from impl-1.2
|
||||
```
|
||||
|
||||
### Conditional Resume
|
||||
```bash
|
||||
# Resume only if specific conditions are met
|
||||
/workflow:resume --if-dependencies-met --from impl-1.3
|
||||
```
|
||||
|
||||
## Integration Points
|
||||
|
||||
### Automatic Behaviors
|
||||
- **Interruption Detection**: Continuous monitoring during execution
|
||||
- **Context Preservation**: Automatic context saving at task boundaries
|
||||
- **Recovery Planning**: Dynamic strategy selection based on interruption type
|
||||
- **Progress Restoration**: Seamless continuation of TodoWrite coordination
|
||||
|
||||
### Next Actions
|
||||
```bash
|
||||
# After successful resumption
|
||||
/context # View updated workflow status
|
||||
/workflow:execute # Continue normal execution
|
||||
/workflow:review # Move to review phase when complete
|
||||
```
|
||||
|
||||
## Resume Command Workflow Integration
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[/workflow:resume] --> B[Detect Active Session]
|
||||
B --> C[Analyze Interruption Point]
|
||||
C --> D[Select Recovery Strategy]
|
||||
D --> E[Rebuild Agent Context]
|
||||
E --> F[Update TodoWrite Plan]
|
||||
F --> G[Execute Resume Coordination]
|
||||
G --> H[Monitor & Update Status]
|
||||
H --> I[Continue Normal Workflow]
|
||||
```
|
||||
|
||||
**System ensures**: Robust workflow continuity with intelligent interruption handling and seamless recovery integration.
|
||||
@@ -43,13 +43,16 @@ Creates implementation plans by orchestrating intelligent context gathering and
|
||||
2. **Context-Rich**: Each task includes comprehensive context for autonomous execution
|
||||
3. **Flow-Control Ready**: Pre-analysis steps and implementation approach pre-defined
|
||||
4. **Agent-Optimized**: Complete context provided for specialized agent execution
|
||||
5. **Artifacts-Integrated**: Automatically detect and reference brainstorming artifacts
|
||||
6. **Design-Context-Aware**: Ensure design documents are loaded in pre_analysis steps
|
||||
|
||||
**Automatic Task Generation Workflow**:
|
||||
1. **Parse Analysis Results**: Extract task recommendations from ANALYSIS_RESULTS.md
|
||||
2. **Extract Task Details**: Parse task ID, title, scope, complexity from structured analysis
|
||||
3. **Generate Context**: Create requirements, focus_paths, and acceptance criteria
|
||||
4. **Build Flow Control**: Define pre_analysis steps and implementation approach
|
||||
5. **Create JSON Files**: Generate individual .task/IMPL-*.json files with 5-field schema
|
||||
3. **Detect Brainstorming Artifacts**: Scan for ui-designer, system-architect, and other role outputs
|
||||
4. **Generate Context**: Create requirements, focus_paths, acceptance criteria, and artifacts references
|
||||
5. **Build Enhanced Flow Control**: Define pre_analysis steps with artifact loading and implementation approach
|
||||
6. **Create Artifact-Aware JSON Files**: Generate individual .task/IMPL-*.json files with enhanced schema
|
||||
|
||||
### Session Management ⚠️ CRITICAL
|
||||
- **Command**: Uses `/workflow:session:start` command for intelligent session discovery and creation
|
||||
@@ -65,6 +68,12 @@ Creates implementation plans by orchestrating intelligent context gathering and
|
||||
- **Usage**: `/context:gather --session WFS-[id]` and `/analysis:run --session WFS-[id]`
|
||||
- **Rule**: ALL modular commands MUST receive current session ID for context continuity
|
||||
|
||||
### Brainstorming Artifacts Integration ⚠️ NEW FEATURE
|
||||
- **Artifact Detection**: Automatically scan .brainstorming/ directory for role outputs
|
||||
- **Role-Task Mapping**: Map brainstorming roles to task types (ui-designer → UI tasks)
|
||||
- **Artifact References**: Create structured references to design documents and specifications
|
||||
- **Context Enhancement**: Load artifacts in pre_analysis steps to provide complete design context
|
||||
|
||||
|
||||
## Execution Lifecycle
|
||||
|
||||
@@ -87,10 +96,11 @@ Creates implementation plans by orchestrating intelligent context gathering and
|
||||
4. **Validation**: Verify analysis completeness and task recommendations
|
||||
|
||||
### Phase 4: Plan Assembly & Document Generation
|
||||
1. **Plan Generation**: Create IMPL_PLAN.md from analysis results
|
||||
2. **Task JSON Creation**: Generate individual task JSON files with 5-field schema
|
||||
3. **TODO List Creation**: Generate TODO_LIST.md with document format
|
||||
4. **Session Update**: Mark session as ready for execution
|
||||
1. **Artifact Detection**: Scan session for brainstorming outputs (.brainstorming/ directory)
|
||||
2. **Plan Generation**: Create IMPL_PLAN.md from analysis results and artifacts
|
||||
3. **Enhanced Task JSON Creation**: Generate task JSON files with artifacts integration
|
||||
4. **TODO List Creation**: Generate TODO_LIST.md with artifact references
|
||||
5. **Session Update**: Mark session as ready for execution with artifact context
|
||||
|
||||
## TodoWrite Progress Tracking
|
||||
**Comprehensive planning tracking** with real-time status updates throughout entire planning lifecycle:
|
||||
@@ -107,9 +117,10 @@ Creates implementation plans by orchestrating intelligent context gathering and
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{"content": "Initialize session management", "status": "pending", "activeForm": "Initializing session management"},
|
||||
{"content": "Detect and analyze brainstorming artifacts", "status": "pending", "activeForm": "Detecting and analyzing brainstorming artifacts"},
|
||||
{"content": "Gather intelligent context", "status": "pending", "activeForm": "Gathering intelligent context"},
|
||||
{"content": "Execute intelligent analysis", "status": "pending", "activeForm": "Executing intelligent analysis"},
|
||||
{"content": "Generate implementation plan and tasks", "status": "pending", "activeForm": "Generating implementation plan and tasks"}
|
||||
{"content": "Generate artifact-enhanced implementation plan and tasks", "status": "pending", "activeForm": "Generating artifact-enhanced implementation plan and tasks"}
|
||||
]
|
||||
})
|
||||
```
|
||||
@@ -145,14 +156,41 @@ TodoWrite({
|
||||
|
||||
## Reference Information
|
||||
|
||||
### Task JSON Schema (5-Field Architecture)
|
||||
Each task.json uses the workflow-architecture.md 5-field schema:
|
||||
### Enhanced Task JSON Schema (5-Field + Artifacts)
|
||||
Each task.json uses the workflow-architecture.md 5-field schema enhanced with artifacts:
|
||||
- **id**: IMPL-N[.M] format (max 2 levels)
|
||||
- **title**: Descriptive task name
|
||||
- **status**: pending|active|completed|blocked|container
|
||||
- **meta**: { type, agent }
|
||||
- **context**: { requirements, focus_paths, acceptance, parent, depends_on, inherited, shared_context }
|
||||
- **flow_control**: { pre_analysis[], implementation_approach, target_files[] }
|
||||
- **context**: { requirements, focus_paths, acceptance, parent, depends_on, inherited, shared_context, **artifacts** }
|
||||
- **flow_control**: { pre_analysis[] (with artifact loading), implementation_approach, target_files[] }
|
||||
|
||||
**Streamlined Artifacts Field with Single Synthesis Document**:
|
||||
```json
|
||||
"artifacts": [
|
||||
{
|
||||
"type": "synthesis_specification",
|
||||
"source": "brainstorm_synthesis",
|
||||
"path": ".workflow/WFS-[session]/.brainstorming/synthesis-specification.md",
|
||||
"priority": "highest",
|
||||
"contains": "complete_integrated_specification"
|
||||
},
|
||||
{
|
||||
"type": "topic_framework",
|
||||
"source": "brainstorm_framework",
|
||||
"path": ".workflow/WFS-[session]/.brainstorming/topic-framework.md",
|
||||
"priority": "medium",
|
||||
"contains": "discussion_framework_structure"
|
||||
},
|
||||
{
|
||||
"type": "individual_role_analysis",
|
||||
"source": "brainstorm_roles",
|
||||
"path": ".workflow/WFS-[session]/.brainstorming/[role]/analysis.md",
|
||||
"priority": "low",
|
||||
"contains": "role_specific_analysis_fallback"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
**MCP Tools Integration**: Enhanced with optional MCP servers for advanced analysis:
|
||||
- **Code Index MCP**: `mcp__code-index__find_files()`, `mcp__code-index__search_code_advanced()`
|
||||
@@ -170,6 +208,28 @@ The following pre_analysis steps are generated for agent execution:
|
||||
// Example pre_analysis steps generated by /workflow:plan for agent execution
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_synthesis_specification",
|
||||
"action": "Load consolidated synthesis specification from brainstorming",
|
||||
"commands": [
|
||||
"bash(ls .workflow/WFS-[session]/.brainstorming/synthesis-specification.md 2>/dev/null || echo 'synthesis specification not found')",
|
||||
"Read(.workflow/WFS-[session]/.brainstorming/synthesis-specification.md)"
|
||||
],
|
||||
"output_to": "synthesis_specification",
|
||||
"on_error": "skip_optional"
|
||||
},
|
||||
{
|
||||
"step": "load_individual_role_artifacts",
|
||||
"action": "Load individual role analyses as fallback",
|
||||
"commands": [
|
||||
"bash(find .workflow/WFS-[session]/.brainstorming/ -name 'analysis.md' 2>/dev/null | head -8)",
|
||||
"Read(.workflow/WFS-[session]/.brainstorming/ui-designer/analysis.md)",
|
||||
"Read(.workflow/WFS-[session]/.brainstorming/system-architect/analysis.md)",
|
||||
"Read(.workflow/WFS-[session]/.brainstorming/topic-framework.md)"
|
||||
],
|
||||
"output_to": "individual_artifacts",
|
||||
"on_error": "skip_optional"
|
||||
},
|
||||
{
|
||||
"step": "load_planning_context",
|
||||
"action": "Load plan-generated analysis and context",
|
||||
@@ -226,12 +286,68 @@ The following pre_analysis steps are generated for agent execution:
|
||||
"action": "Analyze existing code patterns for task context",
|
||||
"commands": [
|
||||
"bash(cd \"[task_focus_paths]\")",
|
||||
"bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze task patterns TASK: Review '[task_title]' patterns CONTEXT: Task [task_id] in [task_focus_paths] EXPECTED: Pattern analysis RULES: Focus on existing patterns\")"
|
||||
"bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze task patterns TASK: Review '[task_title]' patterns CONTEXT: Task [task_id] in [task_focus_paths], synthesis spec: [synthesis_specification], fallback artifacts: [individual_artifacts] EXPECTED: Pattern analysis integrating consolidated design specification RULES: Prioritize synthesis-specification.md over individual artifacts, align with consolidated requirements and design\")"
|
||||
],
|
||||
"output_to": "task_context",
|
||||
"on_error": "fail"
|
||||
}
|
||||
]
|
||||
],
|
||||
"implementation_approach": {
|
||||
"task_description": "Implement '[task_title]' following consolidated synthesis specification from [synthesis_specification] with fallback to [individual_artifacts]",
|
||||
"modification_points": [
|
||||
"Apply consolidated requirements and design patterns from synthesis-specification.md",
|
||||
"Follow technical guidelines and implementation roadmap from synthesis specification",
|
||||
"Integrate with existing patterns while maintaining design integrity from consolidated specification"
|
||||
],
|
||||
"logic_flow": [
|
||||
"Load consolidated synthesis specification as primary context",
|
||||
"Extract specific requirements, design patterns, and technical guidelines",
|
||||
"Analyze existing code patterns for integration with synthesized design",
|
||||
"Implement feature following consolidated specification",
|
||||
"Validate implementation against synthesized acceptance criteria"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Artifact Detection & Integration ⚠️ ENHANCED FEATURE
|
||||
|
||||
### Artifact Detection Logic
|
||||
**Automatic Brainstorming Artifact Scanning**:
|
||||
1. **Session Scan**: Check `.workflow/WFS-[session]/.brainstorming/` directory
|
||||
2. **Role Detection**: Identify completed role analyses (ui-designer, system-architect, etc.)
|
||||
3. **Artifact Mapping**: Map artifacts to relevant task types
|
||||
4. **Relevance Scoring**: Assign relevance scores based on task-artifact alignment
|
||||
|
||||
### Role-Task Mapping Rules
|
||||
**Artifact-Task Relevance Matrix**:
|
||||
- **ui-designer** → UI/Frontend/Component tasks (high relevance)
|
||||
- **system-architect** → Architecture/Backend/Database tasks (high relevance)
|
||||
- **security-expert** → Authentication/Security/Validation tasks (high relevance)
|
||||
- **data-architect** → Data/API/Analytics tasks (high relevance)
|
||||
- **product-manager** → Feature/Business Logic tasks (medium relevance)
|
||||
- **topic-framework.md** → All tasks (low-medium relevance for context)
|
||||
|
||||
### Enhanced Task Generation
|
||||
**Artifact-Enhanced Task Creation Process**:
|
||||
1. **Standard Task Generation**: Create base task from analysis results
|
||||
2. **Artifact Detection**: Scan for relevant brainstorming outputs
|
||||
3. **Context Enrichment**: Add artifacts array to task.context
|
||||
4. **Pre-Analysis Enhancement**: Insert artifact loading steps
|
||||
5. **Implementation Update**: Reference artifacts in task description and approach
|
||||
|
||||
### Artifact Loading in Pre-Analysis
|
||||
**Automatic Artifact Integration**:
|
||||
```json
|
||||
{
|
||||
"step": "load_brainstorming_artifacts",
|
||||
"action": "Load brainstorming artifacts and design documents",
|
||||
"commands": [
|
||||
"bash(find .workflow/WFS-[session]/.brainstorming/ -name 'analysis.md' 2>/dev/null | while read file; do echo \"=== $(dirname \"$file\" | xargs basename) ===\"; cat \"$file\"; echo; done)",
|
||||
"Read(.workflow/WFS-[session]/.brainstorming/topic-framework.md)"
|
||||
],
|
||||
"output_to": "brainstorming_artifacts",
|
||||
"on_error": "skip_optional"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -240,6 +356,6 @@ The following pre_analysis steps are generated for agent execution:
|
||||
|
||||
### Execution Integration
|
||||
Documents created for `/workflow:execute`:
|
||||
- **IMPL_PLAN.md**: Context loading and requirements
|
||||
- **.task/*.json**: Agent implementation context
|
||||
- **IMPL_PLAN.md**: Context loading and requirements with artifact references
|
||||
- **.task/*.json**: Agent implementation context with enhanced artifact loading
|
||||
- **TODO_LIST.md**: Status tracking (container tasks with ▸, leaf tasks with checkboxes)
|
||||
98
.claude/commands/workflow/resume.md
Normal file
98
.claude/commands/workflow/resume.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
name: resume
|
||||
description: Intelligent workflow session resumption with automatic progress analysis
|
||||
usage: /workflow:resume "<session-id>"
|
||||
argument-hint: "session-id for workflow session to resume"
|
||||
examples:
|
||||
- /workflow:resume "WFS-user-auth"
|
||||
- /workflow:resume "WFS-api-integration"
|
||||
- /workflow:resume "WFS-database-migration"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# Sequential Workflow Resume Command
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:resume "<session-id>"
|
||||
```
|
||||
|
||||
## Purpose
|
||||
**Sequential command coordination for workflow resumption** by first analyzing current session status, then continuing execution with special resume context. This command orchestrates intelligent session resumption through two-step process.
|
||||
|
||||
## Command Coordination Workflow
|
||||
|
||||
### Phase 1: Status Analysis
|
||||
1. **Call status command**: Execute `/workflow:status` to analyze current session state
|
||||
2. **Verify session information**: Check session ID, progress, and current task status
|
||||
3. **Identify resume point**: Determine where workflow was interrupted
|
||||
|
||||
### Phase 2: Resume Execution
|
||||
1. **Call execute with resume flag**: Execute `/workflow:execute --resume-session="{session-id}"`
|
||||
2. **Pass session context**: Provide analyzed session information to execute command
|
||||
3. **Direct agent execution**: Skip discovery phase, directly enter TodoWrite and agent execution
|
||||
|
||||
## Implementation Protocol
|
||||
|
||||
### Sequential Command Execution
|
||||
```bash
|
||||
# Phase 1: Analyze current session status
|
||||
SlashCommand(command="/workflow:status")
|
||||
|
||||
# Phase 2: Resume execution with special flag
|
||||
SlashCommand(command="/workflow:execute --resume-session=\"{session-id}\"")
|
||||
```
|
||||
|
||||
### Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Analyze current session status and progress",
|
||||
status: "in_progress",
|
||||
activeForm: "Analyzing session status"
|
||||
},
|
||||
{
|
||||
content: "Resume workflow execution with session context",
|
||||
status: "pending",
|
||||
activeForm: "Resuming workflow execution"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## Resume Information Flow
|
||||
|
||||
### Status Analysis Results
|
||||
The `/workflow:status` command provides:
|
||||
- **Session ID**: Current active session identifier
|
||||
- **Current Progress**: Completed, in-progress, and pending tasks
|
||||
- **Interruption Point**: Last executed task and next pending task
|
||||
- **Session State**: Overall workflow status
|
||||
|
||||
### Execute Command Context
|
||||
The special `--resume-session` flag tells `/workflow:execute`:
|
||||
- **Skip Discovery**: Don't search for sessions, use provided session ID
|
||||
- **Direct Execution**: Go straight to TodoWrite generation and agent launching
|
||||
- **Context Restoration**: Use existing session state and summaries
|
||||
- **Resume Point**: Continue from identified interruption point
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Session Validation Failures
|
||||
- **Session not found**: Report missing session, suggest available sessions
|
||||
- **Session inactive**: Recommend activating session first
|
||||
- **Status command fails**: Retry once, then report analysis failure
|
||||
|
||||
### Execute Resumption Failures
|
||||
- **No pending tasks**: Report workflow completion status
|
||||
- **Execute command fails**: Report resumption failure, suggest manual intervention
|
||||
|
||||
## Success Criteria
|
||||
1. **Status analysis complete**: Session state properly analyzed and reported
|
||||
2. **Execute command launched**: Resume execution started with proper context
|
||||
3. **Agent coordination**: TodoWrite and agent execution initiated successfully
|
||||
4. **Context preservation**: Session state and progress properly maintained
|
||||
|
||||
---
|
||||
*Sequential command coordination for workflow session resumption*
|
||||
@@ -2,184 +2,105 @@
|
||||
name: complete
|
||||
description: Mark the active workflow session as complete and remove active flag
|
||||
usage: /workflow:session:complete
|
||||
|
||||
examples:
|
||||
- /workflow:session:complete
|
||||
- /workflow:session:complete --detailed
|
||||
---
|
||||
|
||||
# Complete Workflow Session (/workflow:session:complete)
|
||||
|
||||
## Purpose
|
||||
## Overview
|
||||
Mark the currently active workflow session as complete, update its status, and remove the active flag marker.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:session:complete
|
||||
/workflow:session:complete # Complete current active session
|
||||
/workflow:session:complete --detailed # Show detailed completion summary
|
||||
```
|
||||
|
||||
## Behavior
|
||||
## Implementation Flow
|
||||
|
||||
### Session Completion Process
|
||||
1. **Locate Active Session**: Find current active session via `.workflow/.active-*` marker file
|
||||
2. **Update Session Status**: Modify `workflow-session.json` with completion data
|
||||
3. **Remove Active Flag**: Delete `.workflow/.active-[session-name]` marker file
|
||||
4. **Generate Summary**: Display completion report and statistics
|
||||
|
||||
### Status Updates
|
||||
Updates `workflow-session.json` with:
|
||||
- **status**: "completed"
|
||||
- **completed_at**: Current timestamp
|
||||
- **final_phase**: Current phase at completion
|
||||
- **completion_type**: "manual" (distinguishes from automatic completion)
|
||||
|
||||
### State Preservation
|
||||
Preserves all session data:
|
||||
- Implementation plans and documents
|
||||
- Task execution history
|
||||
- Generated artifacts and reports
|
||||
- Session configuration and metadata
|
||||
|
||||
## Completion Summary Display
|
||||
|
||||
### Session Overview
|
||||
```
|
||||
✅ Session Completed: WFS-oauth-integration
|
||||
Description: Implement OAuth2 authentication
|
||||
Created: 2025-09-07 14:30:00
|
||||
Completed: 2025-09-12 16:45:00
|
||||
Duration: 5 days, 2 hours, 15 minutes
|
||||
Final Phase: IMPLEMENTATION
|
||||
```
|
||||
|
||||
### Progress Summary
|
||||
```
|
||||
📊 Session Statistics:
|
||||
- Tasks completed: 5/5 (100%)
|
||||
- Files modified: 12
|
||||
- Tests created: 8
|
||||
- Documentation updated: 3 files
|
||||
- Average task duration: 2.5 hours
|
||||
```
|
||||
|
||||
### Generated Artifacts
|
||||
```
|
||||
📄 Session Artifacts:
|
||||
✅ IMPL_PLAN.md (Complete implementation plan)
|
||||
✅ TODO_LIST.md (Final task status)
|
||||
✅ .task/ (5 completed task files)
|
||||
📊 reports/ (Session reports available)
|
||||
```
|
||||
|
||||
### Archive Information
|
||||
```
|
||||
🗂️ Session Archive:
|
||||
Directory: .workflow/WFS-oauth-integration/
|
||||
Status: Completed and archived
|
||||
Access: Use /context WFS-oauth-integration for review
|
||||
```
|
||||
|
||||
## No Active Session
|
||||
If no active session exists:
|
||||
```
|
||||
⚠️ No Active Session to Complete
|
||||
|
||||
Available Options:
|
||||
- View all sessions: /workflow:session:list
|
||||
- Start new session: /workflow:session:start "task description"
|
||||
- Resume paused session: /workflow:session:resume
|
||||
```
|
||||
|
||||
## Next Steps Suggestions
|
||||
After completion, displays contextual actions:
|
||||
```
|
||||
🎯 What's Next:
|
||||
- View session archive: /context WFS-oauth-integration
|
||||
- Start related session: /workflow:session:start "build on OAuth work"
|
||||
- Review all sessions: /workflow:session:list
|
||||
- Create project report: /workflow/report
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Common Error Scenarios
|
||||
- **No active session**: Clear message with alternatives
|
||||
- **Corrupted session state**: Validates before completion, offers recovery
|
||||
- **File system issues**: Handles permissions and access problems
|
||||
- **Incomplete tasks**: Warns about unfinished work, allows forced completion
|
||||
|
||||
### Validation Checks
|
||||
Before completing, verifies:
|
||||
- Session directory exists and is accessible
|
||||
- `workflow-session.json` is valid and readable
|
||||
- Marker file exists and matches session
|
||||
- No critical errors in session state
|
||||
|
||||
### Forced Completion
|
||||
For problematic sessions:
|
||||
### Step 1: Find Active Session
|
||||
```bash
|
||||
# Option to force completion despite issues
|
||||
/workflow:session:complete --force
|
||||
ls .workflow/.active-* 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
## Integration with Workflow System
|
||||
|
||||
### Session Lifecycle
|
||||
Completes the session workflow:
|
||||
- INIT → PLAN → IMPLEMENT → **COMPLETE**
|
||||
- Maintains session history for reference
|
||||
- Preserves all artifacts and documentation
|
||||
|
||||
### TodoWrite Integration
|
||||
- Synchronizes final TODO state
|
||||
- Marks all remaining tasks as archived
|
||||
- Preserves task history in session directory
|
||||
|
||||
### Context System
|
||||
- Session remains accessible via `/context <session-id>`
|
||||
- All documents and reports remain available
|
||||
- Can be referenced for future sessions
|
||||
|
||||
## Command Variations
|
||||
|
||||
### Basic Completion
|
||||
### Step 2: Get Session Name
|
||||
```bash
|
||||
/workflow:session:complete
|
||||
basename .workflow/.active-WFS-session-name | sed 's/^\.active-//'
|
||||
```
|
||||
|
||||
### With Summary Options
|
||||
### Step 3: Update Session Status
|
||||
```bash
|
||||
/workflow:session:complete --detailed # Show detailed statistics
|
||||
/workflow:session:complete --quiet # Minimal output
|
||||
/workflow:session:complete --force # Force completion despite issues
|
||||
jq '.status = "completed"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
## Session State After Completion
|
||||
|
||||
### Directory Structure Preserved
|
||||
```
|
||||
.workflow/WFS-[session-name]/
|
||||
├── workflow-session.json # Updated with completion data
|
||||
├── IMPL_PLAN.md # Preserved
|
||||
├── TODO_LIST.md # Final state preserved
|
||||
├── .task/ # All task files preserved
|
||||
└── reports/ # Generated reports preserved
|
||||
### Step 4: Add Completion Timestamp
|
||||
```bash
|
||||
jq '.completed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Session JSON Example
|
||||
```json
|
||||
{
|
||||
"id": "WFS-oauth-integration",
|
||||
"description": "Implement OAuth2 authentication",
|
||||
"status": "completed",
|
||||
"created_at": "2025-09-07T14:30:00Z",
|
||||
"completed_at": "2025-09-12T16:45:00Z",
|
||||
"completion_type": "manual",
|
||||
"final_phase": "IMPLEMENTATION",
|
||||
"tasks_completed": 5,
|
||||
"tasks_total": 5
|
||||
}
|
||||
### Step 5: Count Final Statistics
|
||||
```bash
|
||||
ls .workflow/WFS-session/.task/*.json 2>/dev/null | wc -l
|
||||
ls .workflow/WFS-session/.summaries/*.md 2>/dev/null | wc -l
|
||||
```
|
||||
|
||||
---
|
||||
### Step 6: Remove Active Marker
|
||||
```bash
|
||||
rm .workflow/.active-WFS-session-name
|
||||
```
|
||||
|
||||
**Result**: Current active session is marked as complete, archived, and no longer active. All session data is preserved for future reference.
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
- **Find active session**: `ls .workflow/.active-*`
|
||||
- **Get session name**: `basename marker | sed 's/^\.active-//'`
|
||||
- **Update status**: `jq '.status = "completed"' session.json > temp.json`
|
||||
- **Add timestamp**: `jq '.completed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"'`
|
||||
- **Count tasks**: `ls .task/*.json | wc -l`
|
||||
- **Count completed**: `ls .summaries/*.md | wc -l`
|
||||
- **Remove marker**: `rm .workflow/.active-session`
|
||||
|
||||
### Completion Result
|
||||
```
|
||||
Session WFS-user-auth completed
|
||||
- Status: completed
|
||||
- Started: 2025-09-15T10:00:00Z
|
||||
- Completed: 2025-09-15T16:30:00Z
|
||||
- Duration: 6h 30m
|
||||
- Total tasks: 8
|
||||
- Completed tasks: 8
|
||||
- Success rate: 100%
|
||||
```
|
||||
|
||||
### Detailed Summary (--detailed flag)
|
||||
```
|
||||
Session Completion Summary:
|
||||
├── Session: WFS-user-auth
|
||||
├── Project: User authentication system
|
||||
├── Total time: 6h 30m
|
||||
├── Tasks completed: 8/8 (100%)
|
||||
├── Files generated: 24 files
|
||||
├── Summaries created: 8 summaries
|
||||
├── Status: All tasks completed successfully
|
||||
└── Location: .workflow/WFS-user-auth/
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
```bash
|
||||
# No active session
|
||||
ls .workflow/.active-* 2>/dev/null || echo "No active session found"
|
||||
|
||||
# Incomplete tasks
|
||||
task_count=$(ls .task/*.json | wc -l)
|
||||
summary_count=$(ls .summaries/*.md 2>/dev/null | wc -l)
|
||||
test $task_count -eq $summary_count || echo "Warning: Not all tasks completed"
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:session:list` - View all sessions including completed
|
||||
- `/workflow:session:start` - Start new session
|
||||
- `/workflow:status` - Check completion status before completing
|
||||
@@ -2,82 +2,104 @@
|
||||
name: list
|
||||
description: List all workflow sessions with status
|
||||
usage: /workflow:session:list
|
||||
examples:
|
||||
- /workflow:session:list
|
||||
---
|
||||
|
||||
# List Workflow Sessions (/workflow/session/list)
|
||||
# List Workflow Sessions (/workflow:session:list)
|
||||
|
||||
## Purpose
|
||||
## Overview
|
||||
Display all workflow sessions with their current status, progress, and metadata.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow/session/list
|
||||
/workflow:session:list # Show all sessions with status
|
||||
```
|
||||
|
||||
## Output Format
|
||||
## Implementation Flow
|
||||
|
||||
### Active Session (Highlighted)
|
||||
### Step 1: Find All Sessions
|
||||
```bash
|
||||
ls .workflow/WFS-* 2>/dev/null
|
||||
```
|
||||
|
||||
### Step 2: Check Active Session
|
||||
```bash
|
||||
ls .workflow/.active-* 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
### Step 3: Read Session Metadata
|
||||
```bash
|
||||
jq -r '.session_id, .status, .project' .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Step 4: Count Task Progress
|
||||
```bash
|
||||
ls .workflow/WFS-session/.task/*.json 2>/dev/null | wc -l
|
||||
ls .workflow/WFS-session/.summaries/*.md 2>/dev/null | wc -l
|
||||
```
|
||||
|
||||
### Step 5: Get Creation Time
|
||||
```bash
|
||||
jq -r '.created_at // "unknown"' .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
- **List sessions**: `ls .workflow/WFS-*`
|
||||
- **Find active**: `ls .workflow/.active-*`
|
||||
- **Read session data**: `jq -r '.session_id, .status' session.json`
|
||||
- **Count tasks**: `ls .task/*.json | wc -l`
|
||||
- **Count completed**: `ls .summaries/*.md | wc -l`
|
||||
- **Get timestamp**: `jq -r '.created_at' session.json`
|
||||
|
||||
## Simple Output Format
|
||||
|
||||
### Session List Display
|
||||
```
|
||||
Workflow Sessions:
|
||||
|
||||
✅ WFS-oauth-integration (ACTIVE)
|
||||
Description: Implement OAuth2 authentication
|
||||
Phase: IMPLEMENTATION
|
||||
Created: 2025-09-07 14:30:00
|
||||
Directory: .workflow/WFS-oauth-integration/
|
||||
Progress: 3/5 tasks completed
|
||||
Project: OAuth2 authentication system
|
||||
Status: active
|
||||
Progress: 3/8 tasks completed
|
||||
Created: 2025-09-15T10:30:00Z
|
||||
|
||||
⏸️ WFS-user-profile (PAUSED)
|
||||
Project: User profile management
|
||||
Status: paused
|
||||
Progress: 1/5 tasks completed
|
||||
Created: 2025-09-14T14:15:00Z
|
||||
|
||||
📁 WFS-database-migration (COMPLETED)
|
||||
Project: Database schema migration
|
||||
Status: completed
|
||||
Progress: 4/4 tasks completed
|
||||
Created: 2025-09-13T09:00:00Z
|
||||
|
||||
Total: 3 sessions (1 active, 1 paused, 1 completed)
|
||||
```
|
||||
|
||||
### Paused Sessions
|
||||
```
|
||||
⏸️ WFS-user-profile (PAUSED)
|
||||
Description: Build user profile management
|
||||
Phase: PLANNING
|
||||
Created: 2025-09-06 10:15:00
|
||||
Last active: 2025-09-07 09:20:00
|
||||
Directory: .workflow/WFS-user-profile/
|
||||
### Status Indicators
|
||||
- **✅**: Active session
|
||||
- **⏸️**: Paused session
|
||||
- **📁**: Completed session
|
||||
- **❌**: Error/corrupted session
|
||||
|
||||
### Quick Commands
|
||||
```bash
|
||||
# Count all sessions
|
||||
ls .workflow/WFS-* | wc -l
|
||||
|
||||
# Show only active
|
||||
ls .workflow/.active-* | basename | sed 's/^\.active-//'
|
||||
|
||||
# Show recent sessions
|
||||
ls -t .workflow/WFS-*/workflow-session.json | head -3
|
||||
```
|
||||
|
||||
### Completed Sessions
|
||||
```
|
||||
✅ WFS-bug-fix-123 (COMPLETED)
|
||||
Description: Fix login security vulnerability
|
||||
Completed: 2025-09-05 16:45:00
|
||||
Directory: .workflow/WFS-bug-fix-123/
|
||||
```
|
||||
|
||||
## Status Indicators
|
||||
- **✅ ACTIVE**: Currently active session (has marker file)
|
||||
- **⏸️ PAUSED**: Session paused, can be resumed
|
||||
- **✅ COMPLETED**: Session finished successfully
|
||||
- **❌ FAILED**: Session ended with errors
|
||||
- **🔄 INTERRUPTED**: Session was interrupted unexpectedly
|
||||
|
||||
## Session Discovery
|
||||
Searches for:
|
||||
- `.workflow/WFS-*` directories
|
||||
- Reads `workflow-session.json` from each
|
||||
- Checks for `.active-*` marker files
|
||||
- Sorts by last activity date
|
||||
|
||||
## Quick Actions
|
||||
For each session, shows available actions:
|
||||
- **Resume**: `/workflow/session/resume` (paused sessions)
|
||||
- **Switch**: `/workflow/session/switch <session-id>`
|
||||
- **View**: `/context <session-id>`
|
||||
|
||||
## Empty State
|
||||
If no sessions exist:
|
||||
```
|
||||
No workflow sessions found.
|
||||
|
||||
Create a new session:
|
||||
/workflow/session/start "your task description"
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
- **Directory access**: Handles permission issues
|
||||
- **Corrupted sessions**: Shows warning but continues listing
|
||||
- **Missing metadata**: Shows partial info with warnings
|
||||
|
||||
---
|
||||
|
||||
**Result**: Complete overview of all workflow sessions and their current state
|
||||
## Related Commands
|
||||
- `/workflow:session:start` - Create new session
|
||||
- `/workflow:session:switch` - Switch to different session
|
||||
- `/workflow:session:status` - Detailed session info
|
||||
@@ -2,64 +2,68 @@
|
||||
name: pause
|
||||
description: Pause the active workflow session
|
||||
usage: /workflow:session:pause
|
||||
|
||||
examples:
|
||||
- /workflow:session:pause
|
||||
---
|
||||
|
||||
# Pause Workflow Session (/workflow:session:pause)
|
||||
|
||||
## Purpose
|
||||
## Overview
|
||||
Pause the currently active workflow session, saving all state for later resumption.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:session:pause
|
||||
/workflow:session:pause # Pause current active session
|
||||
```
|
||||
|
||||
## Behavior
|
||||
## Implementation Flow
|
||||
|
||||
### State Preservation
|
||||
- Saves complete session state to `workflow-session.json`
|
||||
- Preserves context across all phases
|
||||
- Maintains TodoWrite synchronization
|
||||
- Creates checkpoint timestamp
|
||||
|
||||
### Active Session Handling
|
||||
- Removes `.workflow/.active-[session-name]` marker file
|
||||
- Session becomes paused (no longer active)
|
||||
- Other commands will work in temporary mode
|
||||
|
||||
### Context Saved
|
||||
- Current phase and progress
|
||||
- Generated documents and artifacts
|
||||
- Task execution state
|
||||
- Agent context and history
|
||||
|
||||
## Status Update
|
||||
Updates session status to:
|
||||
- **status**: "paused"
|
||||
- **paused_at**: Current timestamp
|
||||
- **resumable**: true
|
||||
|
||||
## Output
|
||||
Displays:
|
||||
- Session ID that was paused
|
||||
- Current phase and progress
|
||||
- Resume instructions
|
||||
- Session directory location
|
||||
|
||||
## Resume Instructions
|
||||
Shows how to resume:
|
||||
### Step 1: Find Active Session
|
||||
```bash
|
||||
/workflow:session:resume # Resume this session
|
||||
/workflow:session:list # View all sessions
|
||||
/workflow:session:switch <id> # Switch to different session
|
||||
ls .workflow/.active-* 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
- **No active session**: Clear message that no session is active
|
||||
- **Save errors**: Handles file system issues gracefully
|
||||
- **State corruption**: Validates session state before saving
|
||||
### Step 2: Get Session Name
|
||||
```bash
|
||||
basename .workflow/.active-WFS-session-name | sed 's/^\.active-//'
|
||||
```
|
||||
|
||||
---
|
||||
### Step 3: Update Session Status
|
||||
```bash
|
||||
jq '.status = "paused"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
**Result**: Active session is safely paused and can be resumed later
|
||||
### Step 4: Add Pause Timestamp
|
||||
```bash
|
||||
jq '.paused_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Step 5: Remove Active Marker
|
||||
```bash
|
||||
rm .workflow/.active-WFS-session-name
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
- **Find active session**: `ls .workflow/.active-*`
|
||||
- **Get session name**: `basename marker | sed 's/^\.active-//'`
|
||||
- **Update status**: `jq '.status = "paused"' session.json > temp.json`
|
||||
- **Add timestamp**: `jq '.paused_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"'`
|
||||
- **Remove marker**: `rm .workflow/.active-session`
|
||||
|
||||
### Pause Result
|
||||
```
|
||||
Session WFS-user-auth paused
|
||||
- Status: paused
|
||||
- Paused at: 2025-09-15T14:30:00Z
|
||||
- Tasks preserved: 8 tasks
|
||||
- Can resume with: /workflow:session:resume
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:session:resume` - Resume paused session
|
||||
- `/workflow:session:list` - Show all sessions including paused
|
||||
- `/workflow:session:status` - Check session state
|
||||
@@ -2,81 +2,74 @@
|
||||
name: resume
|
||||
description: Resume the most recently paused workflow session
|
||||
usage: /workflow:session:resume
|
||||
|
||||
examples:
|
||||
- /workflow:session:resume
|
||||
---
|
||||
|
||||
# Resume Workflow Session (/workflow:session:resume)
|
||||
|
||||
## Purpose
|
||||
## Overview
|
||||
Resume the most recently paused workflow session, restoring all context and state.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:session:resume
|
||||
/workflow:session:resume # Resume most recent paused session
|
||||
```
|
||||
|
||||
## Resume Logic
|
||||
## Implementation Flow
|
||||
|
||||
### Session Detection
|
||||
- Finds most recently paused session
|
||||
- Loads session state from `workflow-session.json`
|
||||
- Validates session integrity
|
||||
### Step 1: Find Paused Sessions
|
||||
```bash
|
||||
ls .workflow/WFS-* 2>/dev/null
|
||||
```
|
||||
|
||||
### State Restoration
|
||||
- Creates `.workflow/.active-[session-name]` marker file
|
||||
- Loads current phase from session state
|
||||
- Restores appropriate agent context
|
||||
- Continues from exact interruption point
|
||||
### Step 2: Check Session Status
|
||||
```bash
|
||||
jq -r '.status' .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Context Continuity
|
||||
- Restores TodoWrite state
|
||||
- Loads phase-specific context
|
||||
- Maintains full audit trail
|
||||
- Preserves document references
|
||||
### Step 3: Find Most Recent Paused
|
||||
```bash
|
||||
ls -t .workflow/WFS-*/workflow-session.json | head -1
|
||||
```
|
||||
|
||||
## Phase-Specific Resume
|
||||
### Step 4: Update Session Status
|
||||
```bash
|
||||
jq '.status = "active"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Planning Phase
|
||||
- Resumes planning document generation
|
||||
- Maintains requirement analysis progress
|
||||
- Continues task breakdown where left off
|
||||
### Step 5: Add Resume Timestamp
|
||||
```bash
|
||||
jq '.resumed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' .workflow/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Implementation Phase
|
||||
- Resumes task execution state
|
||||
- Maintains agent coordination
|
||||
- Continues from current task
|
||||
### Step 6: Create Active Marker
|
||||
```bash
|
||||
touch .workflow/.active-WFS-session-name
|
||||
```
|
||||
|
||||
### Review Phase
|
||||
- Resumes validation process
|
||||
- Maintains quality checks
|
||||
- Continues review workflow
|
||||
## Simple Bash Commands
|
||||
|
||||
## Session Validation
|
||||
Before resuming, validates:
|
||||
- Session directory exists
|
||||
- Required documents present
|
||||
- State consistency
|
||||
- No corruption detected
|
||||
### Basic Operations
|
||||
- **List sessions**: `ls .workflow/WFS-*`
|
||||
- **Check status**: `jq -r '.status' session.json`
|
||||
- **Find recent**: `ls -t .workflow/*/workflow-session.json | head -1`
|
||||
- **Update status**: `jq '.status = "active"' session.json > temp.json`
|
||||
- **Add timestamp**: `jq '.resumed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"'`
|
||||
- **Create marker**: `touch .workflow/.active-session`
|
||||
|
||||
## Output
|
||||
Displays:
|
||||
- Resumed session ID and description
|
||||
- Current phase and progress
|
||||
- Available next actions
|
||||
- Session directory location
|
||||
### Resume Result
|
||||
```
|
||||
Session WFS-user-auth resumed
|
||||
- Status: active
|
||||
- Paused at: 2025-09-15T14:30:00Z
|
||||
- Resumed at: 2025-09-15T15:45:00Z
|
||||
- Ready for: /workflow:execute
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
- **No paused sessions**: Lists available sessions to switch to
|
||||
- **Corrupted session**: Attempts recovery or suggests manual repair
|
||||
- **Directory missing**: Clear error with recovery options
|
||||
- **State inconsistency**: Validates and repairs where possible
|
||||
|
||||
## Next Actions
|
||||
After resuming:
|
||||
- Use `/context` to view current session state
|
||||
- Continue with phase-appropriate commands
|
||||
- Check TodoWrite status for next steps
|
||||
|
||||
---
|
||||
|
||||
**Result**: Previously paused session is now active and ready to continue
|
||||
## Related Commands
|
||||
- `/workflow:session:pause` - Pause current session
|
||||
- `/workflow:execute` - Continue workflow execution
|
||||
- `/workflow:session:list` - Show all sessions
|
||||
@@ -1,112 +0,0 @@
|
||||
---
|
||||
name: status
|
||||
description: Show detailed status of active workflow session
|
||||
usage: /workflow:session:status
|
||||
|
||||
---
|
||||
|
||||
# Workflow Session Status (/workflow:session:status)
|
||||
|
||||
## Purpose
|
||||
Display comprehensive status information for the currently active workflow session.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:session:status
|
||||
```
|
||||
|
||||
## Status Display
|
||||
|
||||
### Active Session Overview
|
||||
```
|
||||
🚀 Active Session: WFS-oauth-integration
|
||||
Description: Implement OAuth2 authentication
|
||||
Created: 2025-09-07 14:30:00
|
||||
Last updated: 2025-09-08 09:15:00
|
||||
Directory: .workflow/WFS-oauth-integration/
|
||||
```
|
||||
|
||||
### Phase Information
|
||||
```
|
||||
📋 Current Phase: IMPLEMENTATION
|
||||
Status: In Progress
|
||||
Started: 2025-09-07 15:00:00
|
||||
Progress: 60% complete
|
||||
|
||||
Completed Phases: ✅ INIT ✅ PLAN
|
||||
Current Phase: 🔄 IMPLEMENT
|
||||
Pending Phases: ⏳ REVIEW
|
||||
```
|
||||
|
||||
### Task Progress
|
||||
```
|
||||
📝 Task Status (3/5 completed):
|
||||
✅ IMPL-001: Setup OAuth2 client configuration
|
||||
✅ IMPL-002: Implement Google OAuth integration
|
||||
🔄 IMPL-003: Add Facebook OAuth support (IN PROGRESS)
|
||||
⏳ IMPL-004: Create user profile mapping
|
||||
⏳ IMPL-005: Add OAuth security validation
|
||||
```
|
||||
|
||||
### Document Status
|
||||
```
|
||||
📄 Generated Documents:
|
||||
✅ IMPL_PLAN.md (Complete)
|
||||
✅ TODO_LIST.md (Auto-updated)
|
||||
📝 .task/IMPL-*.json (5 tasks)
|
||||
📊 reports/ (Ready for generation)
|
||||
```
|
||||
|
||||
### Session Health
|
||||
```
|
||||
🔍 Session Health: ✅ HEALTHY
|
||||
- Marker file: ✅ Present
|
||||
- Directory: ✅ Accessible
|
||||
- State file: ✅ Valid
|
||||
- Task files: ✅ Consistent
|
||||
- Last checkpoint: 2025-09-08 09:10:00
|
||||
```
|
||||
|
||||
## No Active Session
|
||||
If no session is active:
|
||||
```
|
||||
⚠️ No Active Session
|
||||
|
||||
Available Sessions:
|
||||
- WFS-user-profile (PAUSED) - Use: /workflow/session/switch WFS-user-profile
|
||||
- WFS-bug-fix-123 (COMPLETED) - Use: /context WFS-bug-fix-123
|
||||
|
||||
Create New Session:
|
||||
/workflow:session:start "your task description"
|
||||
```
|
||||
|
||||
## Quick Actions
|
||||
Shows contextual next steps:
|
||||
```
|
||||
🎯 Suggested Actions:
|
||||
- Continue current task: /task/execute IMPL-003
|
||||
- View full context: /context
|
||||
- Execute workflow: /workflow/execute
|
||||
- Plan next steps: /workflow/plan
|
||||
```
|
||||
|
||||
## Error Detection
|
||||
Identifies common issues:
|
||||
- Missing marker file
|
||||
- Corrupted session state
|
||||
- Inconsistent task files
|
||||
- Directory permission problems
|
||||
|
||||
## Performance Info
|
||||
```
|
||||
⚡ Session Performance:
|
||||
- Tasks completed: 3/5 (60%)
|
||||
- Average task time: 2.5 hours
|
||||
- Estimated completion: 2025-09-08 14:00:00
|
||||
- Files modified: 12
|
||||
- Tests passing: 98%
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Result**: Comprehensive view of active session status and health
|
||||
@@ -2,7 +2,7 @@
|
||||
name: switch
|
||||
description: Switch to a different workflow session
|
||||
usage: /workflow:session:switch <session-id>
|
||||
|
||||
argument-hint: session-id to switch to
|
||||
examples:
|
||||
- /workflow:session:switch WFS-oauth-integration
|
||||
- /workflow:session:switch WFS-user-profile
|
||||
@@ -10,76 +10,78 @@ examples:
|
||||
|
||||
# Switch Workflow Session (/workflow:session:switch)
|
||||
|
||||
## Purpose
|
||||
## Overview
|
||||
Switch the active session to a different workflow session.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:session:switch <session-id>
|
||||
/workflow:session:switch WFS-session-name # Switch to specific session
|
||||
```
|
||||
|
||||
## Session Switching Process
|
||||
## Implementation Flow
|
||||
|
||||
### Validation
|
||||
- Verifies target session exists
|
||||
- Checks session directory integrity
|
||||
- Validates session state
|
||||
|
||||
### Active Session Handling
|
||||
- Automatically pauses currently active session
|
||||
- Saves current session state
|
||||
- Removes current `.active-*` marker file
|
||||
|
||||
### Target Session Activation
|
||||
- Creates `.active-[target-session]` marker file
|
||||
- Updates session status to "active"
|
||||
- Loads session context and state
|
||||
|
||||
### State Transition
|
||||
```
|
||||
Current Active → Paused (auto-saved)
|
||||
Target Session → Active (context loaded)
|
||||
### Step 1: Validate Target Session
|
||||
```bash
|
||||
test -d .workflow/WFS-target-session && echo "Session exists"
|
||||
```
|
||||
|
||||
## Context Loading
|
||||
After switching:
|
||||
- Loads target session's phase and progress
|
||||
- Restores appropriate agent context
|
||||
- Makes session's documents available
|
||||
- Updates TodoWrite to target session's tasks
|
||||
### Step 2: Pause Current Session
|
||||
```bash
|
||||
ls .workflow/.active-* 2>/dev/null | head -1
|
||||
jq '.status = "paused"' .workflow/current-session/workflow-session.json > temp.json
|
||||
```
|
||||
|
||||
## Output
|
||||
Displays:
|
||||
- Previous active session (now paused)
|
||||
- New active session details
|
||||
- Current phase and progress
|
||||
- Available next actions
|
||||
### Step 3: Remove Current Active Marker
|
||||
```bash
|
||||
rm .workflow/.active-* 2>/dev/null
|
||||
```
|
||||
|
||||
## Session ID Formats
|
||||
Accepts various formats:
|
||||
- Full ID: `WFS-oauth-integration`
|
||||
- Partial match: `oauth` (if unique)
|
||||
- Index from list: `1` (from session list order)
|
||||
### Step 4: Activate Target Session
|
||||
```bash
|
||||
jq '.status = "active"' .workflow/WFS-target/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-target/workflow-session.json
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
- **Session not found**: Lists available sessions
|
||||
- **Invalid session**: Shows session validation errors
|
||||
- **Already active**: No-op with confirmation message
|
||||
- **Switch failure**: Maintains current session, shows error
|
||||
### Step 5: Create New Active Marker
|
||||
```bash
|
||||
touch .workflow/.active-WFS-target-session
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
After switching, shows:
|
||||
- Session description and phase
|
||||
- Recent activity and progress
|
||||
- Suggested next commands
|
||||
- Directory location
|
||||
### Step 6: Add Switch Timestamp
|
||||
```bash
|
||||
jq '.switched_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' .workflow/WFS-target/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/WFS-target/workflow-session.json
|
||||
```
|
||||
|
||||
## Integration
|
||||
Commands executed after switch will:
|
||||
- Use new active session context
|
||||
- Save artifacts to new session directory
|
||||
- Update new session's state and progress
|
||||
## Simple Bash Commands
|
||||
|
||||
---
|
||||
### Basic Operations
|
||||
- **Check session exists**: `test -d .workflow/WFS-session`
|
||||
- **Find current active**: `ls .workflow/.active-*`
|
||||
- **Pause current**: `jq '.status = "paused"' session.json > temp.json`
|
||||
- **Remove marker**: `rm .workflow/.active-*`
|
||||
- **Activate target**: `jq '.status = "active"' target.json > temp.json`
|
||||
- **Create marker**: `touch .workflow/.active-target`
|
||||
|
||||
**Result**: Different session is now active and ready for work
|
||||
### Switch Result
|
||||
```
|
||||
Switched to session: WFS-oauth-integration
|
||||
- Previous: WFS-user-auth (paused)
|
||||
- Current: WFS-oauth-integration (active)
|
||||
- Switched at: 2025-09-15T15:45:00Z
|
||||
- Ready for: /workflow:execute
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
```bash
|
||||
# Session not found
|
||||
test -d .workflow/WFS-nonexistent || echo "Error: Session not found"
|
||||
|
||||
# No sessions available
|
||||
ls .workflow/WFS-* 2>/dev/null || echo "No sessions available"
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:session:list` - Show all available sessions
|
||||
- `/workflow:session:pause` - Pause current before switching
|
||||
- `/workflow:execute` - Continue with new active session
|
||||
129
.claude/commands/workflow/status.md
Normal file
129
.claude/commands/workflow/status.md
Normal file
@@ -0,0 +1,129 @@
|
||||
---
|
||||
name: workflow:status
|
||||
description: Generate on-demand views from JSON task data
|
||||
usage: /workflow:status [task-id]
|
||||
argument-hint: [optional: task-id]
|
||||
examples:
|
||||
- /workflow:status
|
||||
- /workflow:status impl-1
|
||||
- /workflow:status --validate
|
||||
---
|
||||
|
||||
# Workflow Status Command (/workflow:status)
|
||||
|
||||
## Overview
|
||||
Generates on-demand views from JSON task data. No synchronization needed - all views are calculated from the current state of JSON files.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:status # Show current workflow overview
|
||||
/workflow:status impl-1 # Show specific task details
|
||||
/workflow:status --validate # Validate workflow integrity
|
||||
```
|
||||
|
||||
## Implementation Flow
|
||||
|
||||
### Step 1: Find Active Session
|
||||
```bash
|
||||
ls .workflow/.active-* 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
### Step 2: Load Session Data
|
||||
```bash
|
||||
cat .workflow/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
### Step 3: Scan Task Files
|
||||
```bash
|
||||
ls .workflow/WFS-session/.task/*.json 2>/dev/null
|
||||
```
|
||||
|
||||
### Step 4: Generate Task Status
|
||||
```bash
|
||||
cat .workflow/WFS-session/.task/impl-1.json | jq -r '.status'
|
||||
```
|
||||
|
||||
### Step 5: Count Task Progress
|
||||
```bash
|
||||
ls .workflow/WFS-session/.task/*.json | wc -l
|
||||
ls .workflow/WFS-session/.summaries/*.md 2>/dev/null | wc -l
|
||||
```
|
||||
|
||||
### Step 6: Display Overview
|
||||
```markdown
|
||||
# Workflow Overview
|
||||
**Session**: WFS-session-name
|
||||
**Progress**: 3/8 tasks completed
|
||||
|
||||
## Active Tasks
|
||||
- [⚠️] impl-1: Current task in progress
|
||||
- [ ] impl-2: Next pending task
|
||||
|
||||
## Completed Tasks
|
||||
- [✅] impl-0: Setup completed
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
- **Find active session**: `ls .workflow/.active-*`
|
||||
- **Read session info**: `cat .workflow/session/workflow-session.json`
|
||||
- **List tasks**: `ls .workflow/session/.task/*.json`
|
||||
- **Check task status**: `cat task.json | jq -r '.status'`
|
||||
- **Count completed**: `ls .summaries/*.md | wc -l`
|
||||
|
||||
### Task Status Check
|
||||
- **pending**: Not started yet
|
||||
- **active**: Currently in progress
|
||||
- **completed**: Finished with summary
|
||||
- **blocked**: Waiting for dependencies
|
||||
|
||||
### Validation Commands
|
||||
```bash
|
||||
# Check session exists
|
||||
test -f .workflow/.active-* && echo "Session active"
|
||||
|
||||
# Validate task files
|
||||
for f in .workflow/session/.task/*.json; do jq empty "$f" && echo "Valid: $f"; done
|
||||
|
||||
# Check summaries match
|
||||
ls .task/*.json | wc -l
|
||||
ls .summaries/*.md | wc -l
|
||||
```
|
||||
|
||||
## Simple Output Format
|
||||
|
||||
### Default Overview
|
||||
```
|
||||
Session: WFS-user-auth
|
||||
Status: ACTIVE
|
||||
Progress: 5/12 tasks
|
||||
|
||||
Current: impl-3 (Building API endpoints)
|
||||
Next: impl-4 (Adding authentication)
|
||||
Completed: impl-1, impl-2
|
||||
```
|
||||
|
||||
### Task Details
|
||||
```
|
||||
Task: impl-1
|
||||
Title: Build authentication module
|
||||
Status: completed
|
||||
Agent: code-developer
|
||||
Created: 2025-09-15
|
||||
Completed: 2025-09-15
|
||||
Summary: .summaries/impl-1-summary.md
|
||||
```
|
||||
|
||||
### Validation Results
|
||||
```
|
||||
✅ Session file valid
|
||||
✅ 8 task files found
|
||||
✅ 3 summaries found
|
||||
⚠️ 5 tasks pending completion
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:execute` - Uses this for task discovery
|
||||
- `/workflow:resume` - Uses this for progress analysis
|
||||
- `/workflow:session:status` - Shows session metadata
|
||||
@@ -3,11 +3,45 @@
|
||||
# Location: ~/.claude/scripts/gemini-wrapper
|
||||
#
|
||||
# This wrapper automatically manages --all-files flag based on project token count
|
||||
# and provides intelligent approval mode defaults
|
||||
#
|
||||
# Usage: gemini-wrapper [all gemini options]
|
||||
#
|
||||
# Approval Mode Options:
|
||||
# --approval-mode default : Prompt for approval on each tool call (default)
|
||||
# --approval-mode auto_edit : Auto-approve edit tools, prompt for others
|
||||
# --approval-mode yolo : Auto-approve all tool calls
|
||||
#
|
||||
# Note: Executes in current working directory
|
||||
|
||||
set -e
|
||||
|
||||
# Function to show help
|
||||
show_help() {
|
||||
echo "gemini-wrapper - Token-aware wrapper for gemini command"
|
||||
echo ""
|
||||
echo "Usage: gemini-wrapper [options] [gemini options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --approval-mode <mode> Sets the approval mode for tool calls"
|
||||
echo " Available modes:"
|
||||
echo " default : Prompt for approval on each tool call (default)"
|
||||
echo " auto_edit : Auto-approve edit tools, prompt for others"
|
||||
echo " yolo : Auto-approve all tool calls"
|
||||
echo " --help Show this help message"
|
||||
echo ""
|
||||
echo "Features:"
|
||||
echo " - Automatically manages --all-files flag based on project token count"
|
||||
echo " - Intelligent approval mode detection based on task type"
|
||||
echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set GEMINI_TOKEN_LIMIT to override)"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " gemini-wrapper -p \"Analyze the codebase structure\""
|
||||
echo " gemini-wrapper --approval-mode yolo -p \"Implement user authentication\""
|
||||
echo " gemini-wrapper --approval-mode auto_edit -p \"Fix all linting errors\""
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Configuration
|
||||
DEFAULT_TOKEN_LIMIT=2000000
|
||||
TOKEN_LIMIT=${GEMINI_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT}
|
||||
@@ -88,28 +122,84 @@ count_tokens() {
|
||||
echo "$estimated_tokens $file_count"
|
||||
}
|
||||
|
||||
# Function to validate approval mode
|
||||
validate_approval_mode() {
|
||||
local mode="$1"
|
||||
case "$mode" in
|
||||
"default"|"auto_edit"|"yolo")
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}❌ Invalid approval mode: $mode${NC}" >&2
|
||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Parse arguments to check for flags
|
||||
has_all_files=false
|
||||
has_approval_mode=false
|
||||
approval_mode_value=""
|
||||
args=()
|
||||
i=0
|
||||
|
||||
# Check for existing flags
|
||||
for arg in "$@"; do
|
||||
# Parse arguments with proper handling of --approval-mode value
|
||||
args=("$@") # Start with all arguments
|
||||
parsed_args=()
|
||||
skip_next=false
|
||||
|
||||
for ((i=0; i<${#args[@]}; i++)); do
|
||||
if [[ "$skip_next" == true ]]; then
|
||||
skip_next=false
|
||||
continue
|
||||
fi
|
||||
|
||||
arg="${args[i]}"
|
||||
case "$arg" in
|
||||
"--help"|"-h")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
"--all-files")
|
||||
has_all_files=true
|
||||
args+=("$arg")
|
||||
parsed_args+=("$arg")
|
||||
;;
|
||||
--approval-mode*)
|
||||
"--approval-mode")
|
||||
has_approval_mode=true
|
||||
args+=("$arg")
|
||||
# Get the next argument as the mode value
|
||||
if [[ $((i+1)) -lt ${#args[@]} ]]; then
|
||||
approval_mode_value="${args[$((i+1))]}"
|
||||
if validate_approval_mode "$approval_mode_value"; then
|
||||
parsed_args+=("$arg" "$approval_mode_value")
|
||||
skip_next=true
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❌ --approval-mode requires a value${NC}" >&2
|
||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--approval-mode=*)
|
||||
has_approval_mode=true
|
||||
approval_mode_value="${arg#*=}"
|
||||
if validate_approval_mode "$approval_mode_value"; then
|
||||
parsed_args+=("$arg")
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
args+=("$arg")
|
||||
parsed_args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Replace args with parsed_args
|
||||
args=("${parsed_args[@]}")
|
||||
|
||||
# Analyze current working directory
|
||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||
|
||||
@@ -147,15 +237,42 @@ fi
|
||||
|
||||
# Auto-add approval-mode if not specified
|
||||
if [[ "$has_approval_mode" == false ]]; then
|
||||
# Check if this is an analysis task (contains words like "analyze", "review", "understand")
|
||||
# Intelligent approval mode detection based on prompt content
|
||||
prompt_text="${args[*]}"
|
||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine) ]]; then
|
||||
|
||||
# Analysis/Research tasks - use default (prompt for each tool)
|
||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then
|
||||
echo -e "${GREEN}📋 Analysis task detected: Adding --approval-mode default${NC}" >&2
|
||||
args=("--approval-mode" "default" "${args[@]}")
|
||||
else
|
||||
echo -e "${YELLOW}⚡ Execution task detected: Adding --approval-mode yolo${NC}" >&2
|
||||
|
||||
# Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others)
|
||||
elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then
|
||||
echo -e "${GREEN}🔧 Development task detected: Adding --approval-mode auto_edit${NC}" >&2
|
||||
args=("--approval-mode" "auto_edit" "${args[@]}")
|
||||
|
||||
# Automation/Batch tasks - use yolo (auto-approve all)
|
||||
elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then
|
||||
echo -e "${YELLOW}⚡ Automation task detected: Adding --approval-mode yolo${NC}" >&2
|
||||
args=("--approval-mode" "yolo" "${args[@]}")
|
||||
|
||||
# Default fallback - use default mode for safety
|
||||
else
|
||||
echo -e "${YELLOW}🔍 General task detected: Adding --approval-mode default${NC}" >&2
|
||||
args=("--approval-mode" "default" "${args[@]}")
|
||||
fi
|
||||
|
||||
# Show approval mode explanation
|
||||
case "${args[1]}" in
|
||||
"default")
|
||||
echo -e "${YELLOW} → Will prompt for approval on each tool call${NC}" >&2
|
||||
;;
|
||||
"auto_edit")
|
||||
echo -e "${YELLOW} → Will auto-approve edit tools, prompt for others${NC}" >&2
|
||||
;;
|
||||
"yolo")
|
||||
echo -e "${YELLOW} → Will auto-approve all tool calls${NC}" >&2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Show final command (for transparency)
|
||||
|
||||
@@ -3,11 +3,60 @@
|
||||
# Location: ~/.claude/scripts/qwen-wrapper
|
||||
#
|
||||
# This wrapper automatically manages --all-files flag based on project token count
|
||||
# and provides intelligent approval mode defaults
|
||||
#
|
||||
# Usage: qwen-wrapper [all qwen options]
|
||||
#
|
||||
# Approval Mode Options:
|
||||
# --approval-mode default : Prompt for approval on each tool call (default)
|
||||
# --approval-mode auto_edit : Auto-approve edit tools, prompt for others
|
||||
# --approval-mode yolo : Auto-approve all tool calls
|
||||
#
|
||||
# Note: Executes in current working directory
|
||||
|
||||
set -e
|
||||
|
||||
# Function to show help
|
||||
show_help() {
|
||||
echo "qwen-wrapper - Token-aware wrapper for qwen command"
|
||||
echo ""
|
||||
echo "Usage: qwen-wrapper [options] [qwen options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --approval-mode <mode> Sets the approval mode for tool calls"
|
||||
echo " Available modes:"
|
||||
echo " default : Prompt for approval on each tool call (default)"
|
||||
echo " auto_edit : Auto-approve edit tools, prompt for others"
|
||||
echo " yolo : Auto-approve all tool calls"
|
||||
echo " --help Show this help message"
|
||||
echo ""
|
||||
echo "Features:"
|
||||
echo " - Automatically manages --all-files flag based on project token count"
|
||||
echo " - Intelligent approval mode detection based on task type"
|
||||
echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set QWEN_TOKEN_LIMIT to override)"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " qwen-wrapper -p \"Analyze the codebase structure\""
|
||||
echo " qwen-wrapper --approval-mode yolo -p \"Implement user authentication\""
|
||||
echo " qwen-wrapper --approval-mode auto_edit -p \"Fix all linting errors\""
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to validate approval mode
|
||||
validate_approval_mode() {
|
||||
local mode="$1"
|
||||
case "$mode" in
|
||||
"default"|"auto_edit"|"yolo")
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}❌ Invalid approval mode: $mode${NC}" >&2
|
||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Configuration
|
||||
DEFAULT_TOKEN_LIMIT=2000000
|
||||
TOKEN_LIMIT=${QWEN_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT}
|
||||
@@ -39,25 +88,64 @@ count_tokens() {
|
||||
# Parse arguments to check for flags
|
||||
has_all_files=false
|
||||
has_approval_mode=false
|
||||
args=()
|
||||
approval_mode_value=""
|
||||
|
||||
# Check for existing flags
|
||||
for arg in "$@"; do
|
||||
# Parse arguments with proper handling of --approval-mode value
|
||||
args=("$@") # Start with all arguments
|
||||
parsed_args=()
|
||||
skip_next=false
|
||||
|
||||
for ((i=0; i<${#args[@]}; i++)); do
|
||||
if [[ "$skip_next" == true ]]; then
|
||||
skip_next=false
|
||||
continue
|
||||
fi
|
||||
|
||||
arg="${args[i]}"
|
||||
case "$arg" in
|
||||
"--help"|"-h")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
"--all-files")
|
||||
has_all_files=true
|
||||
args+=("$arg")
|
||||
parsed_args+=("$arg")
|
||||
;;
|
||||
--approval-mode*)
|
||||
"--approval-mode")
|
||||
has_approval_mode=true
|
||||
args+=("$arg")
|
||||
# Get the next argument as the mode value
|
||||
if [[ $((i+1)) -lt ${#args[@]} ]]; then
|
||||
approval_mode_value="${args[$((i+1))]}"
|
||||
if validate_approval_mode "$approval_mode_value"; then
|
||||
parsed_args+=("$arg" "$approval_mode_value")
|
||||
skip_next=true
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❌ --approval-mode requires a value${NC}" >&2
|
||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--approval-mode=*)
|
||||
has_approval_mode=true
|
||||
approval_mode_value="${arg#*=}"
|
||||
if validate_approval_mode "$approval_mode_value"; then
|
||||
parsed_args+=("$arg")
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
args+=("$arg")
|
||||
parsed_args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Replace args with parsed_args
|
||||
args=("${parsed_args[@]}")
|
||||
|
||||
# Analyze current working directory
|
||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||
|
||||
@@ -95,15 +183,42 @@ fi
|
||||
|
||||
# Auto-add approval-mode if not specified
|
||||
if [[ "$has_approval_mode" == false ]]; then
|
||||
# Check if this is an analysis task (contains words like "analyze", "review", "understand")
|
||||
# Intelligent approval mode detection based on prompt content
|
||||
prompt_text="${args[*]}"
|
||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine) ]]; then
|
||||
|
||||
# Analysis/Research tasks - use default (prompt for each tool)
|
||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then
|
||||
echo -e "${GREEN}📋 Analysis task detected: Adding --approval-mode default${NC}" >&2
|
||||
args=("--approval-mode" "default" "${args[@]}")
|
||||
else
|
||||
echo -e "${YELLOW}⚡ Execution task detected: Adding --approval-mode yolo${NC}" >&2
|
||||
|
||||
# Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others)
|
||||
elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then
|
||||
echo -e "${GREEN}🔧 Development task detected: Adding --approval-mode auto_edit${NC}" >&2
|
||||
args=("--approval-mode" "auto_edit" "${args[@]}")
|
||||
|
||||
# Automation/Batch tasks - use yolo (auto-approve all)
|
||||
elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then
|
||||
echo -e "${YELLOW}⚡ Automation task detected: Adding --approval-mode yolo${NC}" >&2
|
||||
args=("--approval-mode" "yolo" "${args[@]}")
|
||||
|
||||
# Default fallback - use default mode for safety
|
||||
else
|
||||
echo -e "${YELLOW}🔍 General task detected: Adding --approval-mode default${NC}" >&2
|
||||
args=("--approval-mode" "default" "${args[@]}")
|
||||
fi
|
||||
|
||||
# Show approval mode explanation
|
||||
case "${args[1]}" in
|
||||
"default")
|
||||
echo -e "${YELLOW} → Will prompt for approval on each tool call${NC}" >&2
|
||||
;;
|
||||
"auto_edit")
|
||||
echo -e "${YELLOW} → Will auto-approve edit tools, prompt for others${NC}" >&2
|
||||
;;
|
||||
"yolo")
|
||||
echo -e "${YELLOW} → Will auto-approve all tool calls${NC}" >&2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Show final command (for transparency)
|
||||
|
||||
@@ -32,6 +32,11 @@ type: strategic-guideline
|
||||
- **Command Examples**: `bash(cd target/directory && ~/.claude/scripts/gemini-wrapper -p "prompt")`, `bash(cd target/directory && ~/.claude/scripts/qwen-wrapper -p "prompt")`, `bash(codex -C directory --full-auto exec "task")`
|
||||
- **Override When Needed**: Specify custom timeout for longer operations
|
||||
|
||||
### Permission Framework
|
||||
- **Gemini/Qwen Write Access**: Use `--approval-mode yolo` when tools need to create/modify files
|
||||
- **Codex Write Access**: Always use `-s danger-full-access` for development and file operations
|
||||
- **Auto-approval Protocol**: Enable automatic tool approvals for autonomous workflow execution
|
||||
|
||||
## 🎯 Universal Command Template
|
||||
|
||||
### Standard Format (REQUIRED)
|
||||
|
||||
@@ -103,8 +103,8 @@ IMPL-2.1 # Subtask of IMPL-2 (dynamically created)
|
||||
- **Leaf tasks**: Only these can be executed directly
|
||||
- **Status inheritance**: Parent status derived from subtask completion
|
||||
|
||||
### Task JSON Schema
|
||||
All task files use this unified 5-field schema:
|
||||
### Enhanced Task JSON Schema
|
||||
All task files use this unified 5-field schema with optional artifacts enhancement:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -129,7 +129,16 @@ All task files use this unified 5-field schema:
|
||||
},
|
||||
"shared_context": {
|
||||
"auth_strategy": "JWT with refresh tokens"
|
||||
}
|
||||
},
|
||||
"artifacts": [
|
||||
{
|
||||
"type": "synthesis_specification",
|
||||
"source": "brainstorm_synthesis",
|
||||
"path": ".workflow/WFS-session/.brainstorming/synthesis-specification.md",
|
||||
"priority": "highest",
|
||||
"contains": "complete_integrated_specification"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"flow_control": {
|
||||
@@ -181,6 +190,22 @@ The **focus_paths** field specifies concrete project paths for task implementati
|
||||
- **Mixed types**: Can include both directories and specific files
|
||||
- **Relative paths**: From project root (e.g., `src/auth`, not `./src/auth`)
|
||||
|
||||
#### Artifacts Field ⚠️ NEW FIELD
|
||||
Optional field referencing brainstorming outputs for task execution:
|
||||
|
||||
```json
|
||||
"artifacts": [
|
||||
{
|
||||
"type": "synthesis_specification|topic_framework|individual_role_analysis",
|
||||
"source": "brainstorm_synthesis|brainstorm_framework|brainstorm_roles",
|
||||
"path": ".workflow/WFS-session/.brainstorming/document.md",
|
||||
"priority": "highest|high|medium|low"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
**Types & Priority**: synthesis_specification (highest) → topic_framework (medium) → individual_role_analysis (low)
|
||||
|
||||
#### Flow Control Configuration
|
||||
The **flow_control** field manages task execution with two main components:
|
||||
|
||||
@@ -231,6 +256,7 @@ The **flow_control** field manages task execution with two main components:
|
||||
6. **Focus Paths Structure**: context.focus_paths must contain concrete paths (no wildcards)
|
||||
7. **Flow Control Format**: pre_analysis must be array with required fields
|
||||
8. **Dependency Integrity**: All depends_on task IDs must exist as JSON files
|
||||
9. **Artifacts Structure**: context.artifacts (optional) must use valid type, priority, and path format
|
||||
|
||||
## Workflow Structure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user