mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-06 01:54:11 +08:00
Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a578450c | ||
|
|
d5199ad2d4 | ||
|
|
f3c773a81e | ||
|
|
875b1f19bd | ||
|
|
c08f5382d3 | ||
|
|
21d764127f | ||
|
|
860dbdab56 | ||
|
|
113dce55c5 | ||
|
|
0b791c03cf | ||
|
|
bbc94fb73a | ||
|
|
f5e435f791 | ||
|
|
86d5be8288 | ||
|
|
9762445876 | ||
|
|
b791c09476 | ||
|
|
26283e7a5a | ||
|
|
1040459fef | ||
|
|
0fe8c18a82 | ||
|
|
0086413f95 | ||
|
|
8ff698ae73 | ||
|
|
8cdd6a8b5f | ||
|
|
b86a8afd8b | ||
|
|
53bd5a6d4b | ||
|
|
3a7bbe0e42 | ||
|
|
04a84f9893 | ||
|
|
11638facf7 | ||
|
|
4d93ffb06c | ||
|
|
204cb20617 | ||
|
|
63f0daebbb | ||
|
|
6ac041c1d8 | ||
|
|
279adfd391 | ||
|
|
0a07138c27 | ||
|
|
a5d9e8ca87 | ||
|
|
502c8a09a1 | ||
|
|
ed0255b8a2 | ||
|
|
6e94fc0740 | ||
|
|
b361a8c041 | ||
|
|
24dad8cefd | ||
|
|
071c98d89c | ||
|
|
994718dee2 | ||
|
|
3998d24e32 | ||
|
|
29274ee943 | ||
|
|
46d5739935 | ||
|
|
152cab2b7e | ||
|
|
0cc5101c0e | ||
|
|
4c78f53bcc | ||
|
|
cc5a5716cf | ||
|
|
af05874510 | ||
|
|
7a40f16235 | ||
|
|
8d178feaac | ||
|
|
b3c47294e7 | ||
|
|
9989cfcf21 | ||
|
|
1b6ace0447 | ||
|
|
a3b303d8e3 | ||
|
|
0c1c87f704 | ||
|
|
985085c624 | ||
|
|
7c16cc6427 | ||
|
|
6875108dda | ||
|
|
9cff6f5f43 | ||
|
|
fe2536d4cd | ||
|
|
16f27c080a | ||
|
|
874b70726d | ||
|
|
862365ffaf | ||
|
|
b8c807b2f9 | ||
|
|
7ea6362c50 | ||
|
|
b435391f17 | ||
|
|
88ff109ac4 | ||
|
|
261196a804 | ||
|
|
ea6cb8440f | ||
|
|
bf896342f4 | ||
|
|
f2b0a5bbc9 | ||
|
|
cf5fecd66d | ||
|
|
86d469ccc9 | ||
|
|
357d3524f5 | ||
|
|
4334162ddf | ||
|
|
2dcd1637f0 | ||
|
|
38e1cdc737 | ||
|
|
097a7346b9 | ||
|
|
9df8063fbd | ||
|
|
d00f0bc7ca | ||
|
|
24efef7f17 | ||
|
|
44b8269a74 | ||
|
|
dd51837bbc |
@@ -9,12 +9,7 @@
|
||||
|
||||
**Strictly follow the cli-tools.json configuration**
|
||||
|
||||
Available CLI endpoints are dynamically defined by the config file:
|
||||
- Built-in tools and their enable/disable status
|
||||
- Custom API endpoints registered via the Dashboard
|
||||
- Managed through the CCW Dashboard Status page
|
||||
|
||||
|
||||
Available CLI endpoints are dynamically defined by the config file
|
||||
## Tool Execution
|
||||
|
||||
- **Context Requirements**: @~/.claude/workflows/context-tools.md
|
||||
@@ -25,9 +20,12 @@ Available CLI endpoints are dynamically defined by the config file:
|
||||
- **TaskOutput usage**: Only use `TaskOutput({ task_id: "xxx", block: false })` + sleep loop to poll completion status. NEVER read intermediate output during agent/CLI execution - wait for final result only
|
||||
|
||||
### CLI Tool Calls (ccw cli)
|
||||
- **Default: `run_in_background: true`** - Unless otherwise specified, always use background execution for CLI calls:
|
||||
- **Default: Use Bash `run_in_background: true`** - Unless otherwise specified, always execute CLI calls in background using Bash tool's background mode:
|
||||
```
|
||||
Bash({ command: "ccw cli -p '...' --tool gemini", run_in_background: true })
|
||||
Bash({
|
||||
command: "ccw cli -p '...' --tool gemini",
|
||||
run_in_background: true // Bash tool parameter, not ccw cli parameter
|
||||
})
|
||||
```
|
||||
- **After CLI call**: Stop output immediately - let CLI execute in background. **DO NOT use TaskOutput polling** - wait for hook callback to receive results
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"interval": "manual",
|
||||
"tool": "gemini"
|
||||
}
|
||||
@@ -55,6 +55,17 @@ color: yellow
|
||||
**Step-by-step execution**:
|
||||
|
||||
```
|
||||
0. Load planning notes → Extract phase-level constraints (NEW)
|
||||
Commands: Read('.workflow/active/{session-id}/planning-notes.md')
|
||||
Output: Consolidated constraints from all workflow phases
|
||||
Structure:
|
||||
- User Intent: Original GOAL, KEY_CONSTRAINTS
|
||||
- Context Findings: Critical files, architecture notes, constraints
|
||||
- Conflict Decisions: Resolved conflicts, modified artifacts
|
||||
- Consolidated Constraints: Numbered list of ALL constraints (Phase 1-3)
|
||||
|
||||
USAGE: This is the PRIMARY source of constraints. All task generation MUST respect these constraints.
|
||||
|
||||
1. Load session metadata → Extract user input
|
||||
- User description: Original task/feature requirements
|
||||
- Project scope: User-specified boundaries and goals
|
||||
@@ -299,25 +310,22 @@ function computeCliStrategy(task, allTasks) {
|
||||
|
||||
**execution_config Alignment Rules** (MANDATORY):
|
||||
```
|
||||
userConfig.executionMethod → meta.execution_config + implementation_approach
|
||||
userConfig.executionMethod → meta.execution_config
|
||||
|
||||
"agent" →
|
||||
meta.execution_config = { method: "agent", cli_tool: null, enable_resume: false }
|
||||
implementation_approach steps: NO command field (agent direct execution)
|
||||
|
||||
"hybrid" →
|
||||
meta.execution_config = { method: "hybrid", cli_tool: userConfig.preferredCliTool }
|
||||
implementation_approach steps: command field ONLY on complex steps
|
||||
Execution: Agent executes pre_analysis, then directly implements implementation_approach
|
||||
|
||||
"cli" →
|
||||
meta.execution_config = { method: "cli", cli_tool: userConfig.preferredCliTool }
|
||||
implementation_approach steps: command field on ALL steps
|
||||
meta.execution_config = { method: "cli", cli_tool: userConfig.preferredCliTool, enable_resume: true }
|
||||
Execution: Agent executes pre_analysis, then hands off context + implementation_approach to CLI
|
||||
|
||||
"hybrid" →
|
||||
meta.execution_config = { method: "hybrid", cli_tool: userConfig.preferredCliTool, enable_resume: true }
|
||||
Execution: Agent decides which tasks to handoff to CLI based on complexity
|
||||
```
|
||||
|
||||
**Consistency Check**: `meta.execution_config.method` MUST match presence of `command` fields:
|
||||
- `method: "agent"` → 0 steps have command field
|
||||
- `method: "hybrid"` → some steps have command field
|
||||
- `method: "cli"` → all steps have command field
|
||||
**Note**: implementation_approach steps NO LONGER contain `command` fields. CLI execution is controlled by task-level `meta.execution_config` only.
|
||||
|
||||
**Test Task Extensions** (for type="test-gen" or type="test-fix"):
|
||||
|
||||
@@ -638,32 +646,6 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
|
||||
"output": "implementation"
|
||||
},
|
||||
|
||||
// === CLI MODE: Command Execution (optional command field) ===
|
||||
{
|
||||
"step": 3,
|
||||
"title": "Execute implementation using CLI tool",
|
||||
"description": "Use Codex/Gemini for complex autonomous execution",
|
||||
"command": "ccw cli -p '[prompt]' --tool codex --mode write --cd [path]",
|
||||
"modification_points": ["[Same as default mode]"],
|
||||
"logic_flow": ["[Same as default mode]"],
|
||||
"depends_on": [1, 2],
|
||||
"output": "cli_implementation",
|
||||
"cli_output_id": "step3_cli_id" // Store execution ID for resume
|
||||
},
|
||||
|
||||
// === CLI MODE with Resume: Continue from previous CLI execution ===
|
||||
{
|
||||
"step": 4,
|
||||
"title": "Continue implementation with context",
|
||||
"description": "Resume from previous step with accumulated context",
|
||||
"command": "ccw cli -p '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode write",
|
||||
"resume_from": "step3_cli_id", // Reference previous step's CLI ID
|
||||
"modification_points": ["[Continue from step 3]"],
|
||||
"logic_flow": ["[Build on previous output]"],
|
||||
"depends_on": [3],
|
||||
"output": "continued_implementation",
|
||||
"cli_output_id": "step4_cli_id"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
@@ -785,13 +767,13 @@ Generate at `.workflow/active/{session_id}/TODO_LIST.md`:
|
||||
Use `analysis_results.complexity` or task count to determine structure:
|
||||
|
||||
**Single Module Mode**:
|
||||
- **Simple Tasks** (≤5 tasks): Flat structure
|
||||
- **Medium Tasks** (6-12 tasks): Flat structure
|
||||
- **Complex Tasks** (>12 tasks): Re-scope required (maximum 12 tasks hard limit)
|
||||
- **Simple Tasks** (≤4 tasks): Flat structure
|
||||
- **Medium Tasks** (5-8 tasks): Flat structure
|
||||
- **Complex Tasks** (>8 tasks): Re-scope required (maximum 8 tasks hard limit)
|
||||
|
||||
**Multi-Module Mode** (N+1 parallel planning):
|
||||
- **Per-module limit**: ≤9 tasks per module
|
||||
- **Total limit**: Sum of all module tasks ≤27 (3 modules × 9 tasks)
|
||||
- **Per-module limit**: ≤6 tasks per module
|
||||
- **Total limit**: No total limit (each module independently capped at 6 tasks)
|
||||
- **Task ID format**: `IMPL-{prefix}{seq}` (e.g., IMPL-A1, IMPL-B1)
|
||||
- **Structure**: Hierarchical by module in IMPL_PLAN.md and TODO_LIST.md
|
||||
|
||||
@@ -855,6 +837,7 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
### 3.3 Guidelines Checklist
|
||||
|
||||
**ALWAYS:**
|
||||
- **Load planning-notes.md FIRST**: Read planning-notes.md before context-package.json. Use its Consolidated Constraints as primary constraint source for all task generation
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Apply Quantification Requirements to all requirements, acceptance criteria, and modification points
|
||||
- Load IMPL_PLAN template: `Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)` before generating IMPL_PLAN.md
|
||||
@@ -865,7 +848,7 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
- **Compute CLI execution strategy**: Based on `depends_on`, set `cli_execution.strategy` (new/resume/fork/merge_fork)
|
||||
- Map artifacts: Use artifacts_inventory to populate task.context.artifacts array
|
||||
- Add MCP integration: Include MCP tool steps in flow_control.pre_analysis when capabilities available
|
||||
- Validate task count: Maximum 12 tasks hard limit, request re-scope if exceeded
|
||||
- Validate task count: Maximum 8 tasks (single module) or 6 tasks per module (multi-module), request re-scope if exceeded
|
||||
- Use session paths: Construct all paths using provided session_id
|
||||
- Link documents properly: Use correct linking format (📋 for JSON, ✅ for summaries)
|
||||
- Run validation checklist: Verify all quantification requirements before finalizing task JSONs
|
||||
@@ -879,7 +862,7 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
- Load files directly (use provided context package instead)
|
||||
- Assume default locations (always use session_id in paths)
|
||||
- Create circular dependencies in task.depends_on
|
||||
- Exceed 12 tasks without re-scoping
|
||||
- Exceed 8 tasks (single module) or 6 tasks per module (multi-module) without re-scoping
|
||||
- Skip artifact integration when artifacts_inventory is provided
|
||||
- Ignore MCP capabilities when available
|
||||
- Use fixed pre-analysis steps without task-specific adaptation
|
||||
|
||||
@@ -13,6 +13,8 @@ color: cyan
|
||||
|
||||
You are a generic planning agent that generates structured plan JSON for lite workflows. Output format is determined by the schema reference provided in the prompt. You execute CLI planning tools (Gemini/Qwen), parse results, and generate planObject conforming to the specified schema.
|
||||
|
||||
**CRITICAL**: After generating plan.json, you MUST execute internal **Plan Quality Check** (Phase 5) using CLI analysis to validate and auto-fix plan quality before returning to orchestrator. Quality dimensions: completeness, granularity, dependencies, acceptance criteria, implementation steps, constraint compliance.
|
||||
|
||||
|
||||
## Input Context
|
||||
|
||||
@@ -72,7 +74,22 @@ Phase 4: planObject Generation
|
||||
├─ Build planObject conforming to schema
|
||||
├─ Assign CLI execution IDs and strategies
|
||||
├─ Generate flow_control from depends_on
|
||||
└─ Return to orchestrator
|
||||
└─ Write initial plan.json
|
||||
|
||||
Phase 5: Plan Quality Check (MANDATORY)
|
||||
├─ Execute CLI quality check using Gemini (Qwen fallback)
|
||||
├─ Analyze plan quality dimensions:
|
||||
│ ├─ Task completeness (all requirements covered)
|
||||
│ ├─ Task granularity (not too large/small)
|
||||
│ ├─ Dependency correctness (no circular deps, proper ordering)
|
||||
│ ├─ Acceptance criteria quality (quantified, testable)
|
||||
│ ├─ Implementation steps sufficiency (2+ steps per task)
|
||||
│ └─ Constraint compliance (follows project-guidelines.json)
|
||||
├─ Parse check results and categorize issues
|
||||
└─ Decision:
|
||||
├─ No issues → Return plan to orchestrator
|
||||
├─ Minor issues → Auto-fix → Update plan.json → Return
|
||||
└─ Critical issues → Report → Suggest regeneration
|
||||
```
|
||||
|
||||
## CLI Command Template
|
||||
@@ -734,3 +751,78 @@ function validateTask(task) {
|
||||
- Skip task validation
|
||||
- **Skip CLI execution ID assignment**
|
||||
- **Ignore schema structure**
|
||||
- **Skip Phase 5 Plan Quality Check**
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Plan Quality Check (MANDATORY)
|
||||
|
||||
### Overview
|
||||
|
||||
After generating plan.json, **MUST** execute CLI quality check before returning to orchestrator. This is a mandatory step for ALL plans regardless of complexity.
|
||||
|
||||
### Quality Dimensions
|
||||
|
||||
| Dimension | Check Criteria | Critical? |
|
||||
|-----------|---------------|-----------|
|
||||
| **Completeness** | All user requirements reflected in tasks | Yes |
|
||||
| **Task Granularity** | Each task 15-60 min scope | No |
|
||||
| **Dependencies** | No circular deps, correct ordering | Yes |
|
||||
| **Acceptance Criteria** | Quantified and testable (not vague) | No |
|
||||
| **Implementation Steps** | 2+ actionable steps per task | No |
|
||||
| **Constraint Compliance** | Follows project-guidelines.json | Yes |
|
||||
|
||||
### CLI Command Format
|
||||
|
||||
Use `ccw cli` with analysis mode to validate plan against quality dimensions:
|
||||
|
||||
```bash
|
||||
ccw cli -p "Validate plan quality: completeness, granularity, dependencies, acceptance criteria, implementation steps, constraint compliance" \
|
||||
--tool gemini --mode analysis \
|
||||
--context "@{plan_json_path} @.workflow/project-guidelines.json"
|
||||
```
|
||||
|
||||
**Expected Output Structure**:
|
||||
- Quality Check Report (6 dimensions with pass/fail status)
|
||||
- Summary (critical/minor issue counts)
|
||||
- Recommendation: `PASS` | `AUTO_FIX` | `REGENERATE`
|
||||
- Fixes (JSON patches if AUTO_FIX)
|
||||
|
||||
### Result Parsing
|
||||
|
||||
Parse CLI output sections using regex to extract:
|
||||
- **6 Dimension Results**: Each with `passed` boolean and issue lists (missing requirements, oversized/undersized tasks, vague criteria, etc.)
|
||||
- **Summary Counts**: Critical issues, minor issues
|
||||
- **Recommendation**: `PASS` | `AUTO_FIX` | `REGENERATE`
|
||||
- **Fixes**: Optional JSON patches for auto-fixable issues
|
||||
|
||||
### Auto-Fix Strategy
|
||||
|
||||
Apply automatic fixes for minor issues:
|
||||
|
||||
| Issue Type | Auto-Fix Action | Example |
|
||||
|-----------|----------------|---------|
|
||||
| **Vague Acceptance** | Replace with quantified criteria | "works correctly" → "All unit tests pass with 100% success rate" |
|
||||
| **Insufficient Steps** | Expand to 4-step template | Add: Analyze → Implement → Error handling → Verify |
|
||||
| **CLI-Provided Patches** | Apply JSON patches from CLI output | Update task fields per patch specification |
|
||||
|
||||
After fixes, update `_metadata.quality_check` with fix log.
|
||||
|
||||
### Execution Flow
|
||||
|
||||
After Phase 4 planObject generation:
|
||||
|
||||
1. **Write Initial Plan** → `${sessionFolder}/plan.json`
|
||||
2. **Execute CLI Check** → Gemini (Qwen fallback)
|
||||
3. **Parse Results** → Extract recommendation and issues
|
||||
4. **Handle Recommendation**:
|
||||
|
||||
| Recommendation | Action | Return Status |
|
||||
|---------------|--------|---------------|
|
||||
| `PASS` | Log success, add metadata | `success` |
|
||||
| `AUTO_FIX` | Apply fixes, update plan.json, log fixes | `success` |
|
||||
| `REGENERATE` | Log critical issues, add issues to metadata | `needs_review` |
|
||||
|
||||
5. **Return** → Plan with `_metadata.quality_check` containing execution result
|
||||
|
||||
**CLI Fallback**: Gemini → Qwen → Skip with warning (if both fail)
|
||||
|
||||
@@ -186,34 +186,150 @@ output → Variable name to store this step's result
|
||||
|
||||
**Execution Flow**:
|
||||
```
|
||||
FOR each step in implementation_approach[] (ordered by step number):
|
||||
1. Check depends_on: Wait for all listed step numbers to complete
|
||||
2. Variable Substitution: Replace [variable_name] in description/modification_points
|
||||
with values stored from previous steps' output
|
||||
3. Execute step (choose one):
|
||||
// Read task-level execution config (Single Source of Truth)
|
||||
const executionMethod = task.meta?.execution_config?.method || 'agent';
|
||||
const cliTool = task.meta?.execution_config?.cli_tool || getDefaultCliTool(); // See ~/.claude/cli-tools.json
|
||||
|
||||
IF step.command exists:
|
||||
→ Execute the CLI command via Bash tool
|
||||
→ Capture output
|
||||
// Phase 1: Execute pre_analysis (always by Agent)
|
||||
const preAnalysisResults = {};
|
||||
for (const step of task.flow_control.pre_analysis || []) {
|
||||
const result = executePreAnalysisStep(step);
|
||||
preAnalysisResults[step.output_to] = result;
|
||||
}
|
||||
|
||||
ELSE (no command - Agent direct implementation):
|
||||
→ Read modification_points[] as list of files to create/modify
|
||||
→ Read logic_flow[] as implementation sequence
|
||||
→ For each file in modification_points:
|
||||
• If "Create new file: path" → Use Write tool to create
|
||||
• If "Modify file: path" → Use Edit tool to modify
|
||||
• If "Add to file: path" → Use Edit tool to append
|
||||
→ Follow logic_flow sequence for implementation logic
|
||||
→ Use [focus_paths] from context as working directory scope
|
||||
// Phase 2: Determine execution mode
|
||||
const hasLegacyCommands = task.flow_control.implementation_approach
|
||||
.some(step => step.command);
|
||||
|
||||
4. Store result in [step.output] variable for later steps
|
||||
5. Mark step complete, proceed to next
|
||||
IF hasLegacyCommands:
|
||||
// Backward compatibility: Old mode with step.command fields
|
||||
FOR each step in implementation_approach[]:
|
||||
IF step.command exists:
|
||||
→ Execute via Bash: Bash({ command: step.command, timeout: 3600000 })
|
||||
ELSE:
|
||||
→ Agent direct implementation
|
||||
|
||||
ELSE IF executionMethod === 'cli':
|
||||
// New mode: CLI Handoff
|
||||
→ const cliPrompt = buildCliHandoffPrompt(preAnalysisResults, task)
|
||||
→ const cliCommand = buildCliCommand(task, cliTool, cliPrompt)
|
||||
→ Bash({ command: cliCommand, run_in_background: false, timeout: 3600000 })
|
||||
|
||||
ELSE IF executionMethod === 'hybrid':
|
||||
// Hybrid mode: Agent decides based on task complexity
|
||||
→ IF task is complex (multiple files, complex logic):
|
||||
Use CLI Handoff (same as cli mode)
|
||||
ELSE:
|
||||
Use Agent direct implementation
|
||||
|
||||
ELSE (executionMethod === 'agent'):
|
||||
// Default: Agent direct implementation
|
||||
FOR each step in implementation_approach[]:
|
||||
1. Variable Substitution: Replace [variable_name] with preAnalysisResults
|
||||
2. Read modification_points[] as files to create/modify
|
||||
3. Read logic_flow[] as implementation sequence
|
||||
4. For each file in modification_points:
|
||||
• If "Create new file: path" → Use Write tool
|
||||
• If "Modify file: path" → Use Edit tool
|
||||
• If "Add to file: path" → Use Edit tool (append)
|
||||
5. Follow logic_flow sequence
|
||||
6. Use [focus_paths] from context as working directory scope
|
||||
7. Store result in [step.output] variable
|
||||
```
|
||||
|
||||
**CLI Command Execution (CLI Execute Mode)**:
|
||||
When step contains `command` field with Codex CLI, execute via CCW CLI. For Codex resume:
|
||||
- First task (`depends_on: []`): `ccw cli -p "..." --tool codex --mode write --cd [path]`
|
||||
- Subsequent tasks (has `depends_on`): Use CCW CLI with resume context to maintain session
|
||||
**CLI Handoff Functions**:
|
||||
|
||||
```javascript
|
||||
// Get default CLI tool from cli-tools.json
|
||||
function getDefaultCliTool() {
|
||||
// Read ~/.claude/cli-tools.json and return first enabled tool
|
||||
// Fallback order: gemini → qwen → codex (first enabled in config)
|
||||
return firstEnabledTool || 'gemini'; // System default fallback
|
||||
}
|
||||
|
||||
// Build CLI prompt from pre-analysis results and task
|
||||
function buildCliHandoffPrompt(preAnalysisResults, task) {
|
||||
const contextSection = Object.entries(preAnalysisResults)
|
||||
.map(([key, value]) => `### ${key}\n${value}`)
|
||||
.join('\n\n');
|
||||
|
||||
const approachSection = task.flow_control.implementation_approach
|
||||
.map((step, i) => `
|
||||
### Step ${step.step}: ${step.title}
|
||||
${step.description}
|
||||
|
||||
**Modification Points**:
|
||||
${step.modification_points?.map(m => `- ${m}`).join('\n') || 'N/A'}
|
||||
|
||||
**Logic Flow**:
|
||||
${step.logic_flow?.map((l, j) => `${j + 1}. ${l}`).join('\n') || 'Follow modification points'}
|
||||
`).join('\n');
|
||||
|
||||
return `
|
||||
PURPOSE: ${task.title}
|
||||
Complete implementation based on pre-analyzed context.
|
||||
|
||||
## PRE-ANALYSIS CONTEXT
|
||||
${contextSection}
|
||||
|
||||
## REQUIREMENTS
|
||||
${task.context.requirements?.map(r => `- ${r}`).join('\n') || task.context.requirements}
|
||||
|
||||
## IMPLEMENTATION APPROACH
|
||||
${approachSection}
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
${task.context.acceptance?.map(a => `- ${a}`).join('\n') || task.context.acceptance}
|
||||
|
||||
## TARGET FILES
|
||||
${task.flow_control.target_files?.map(f => `- ${f}`).join('\n') || 'See modification points above'}
|
||||
|
||||
MODE: write
|
||||
CONSTRAINTS: Follow existing patterns | No breaking changes
|
||||
`.trim();
|
||||
}
|
||||
|
||||
// Build CLI command with resume strategy
|
||||
function buildCliCommand(task, cliTool, cliPrompt) {
|
||||
const cli = task.cli_execution || {};
|
||||
const escapedPrompt = cliPrompt.replace(/"/g, '\\"');
|
||||
const baseCmd = `ccw cli -p "${escapedPrompt}"`;
|
||||
|
||||
switch (cli.strategy) {
|
||||
case 'new':
|
||||
return `${baseCmd} --tool ${cliTool} --mode write --id ${task.cli_execution_id}`;
|
||||
case 'resume':
|
||||
return `${baseCmd} --resume ${cli.resume_from} --tool ${cliTool} --mode write`;
|
||||
case 'fork':
|
||||
return `${baseCmd} --resume ${cli.resume_from} --id ${task.cli_execution_id} --tool ${cliTool} --mode write`;
|
||||
case 'merge_fork':
|
||||
return `${baseCmd} --resume ${cli.merge_from.join(',')} --id ${task.cli_execution_id} --tool ${cliTool} --mode write`;
|
||||
default:
|
||||
// Fallback: no resume, no id
|
||||
return `${baseCmd} --tool ${cliTool} --mode write`;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Execution Config Reference** (from task.meta.execution_config):
|
||||
| Field | Values | Description |
|
||||
|-------|--------|-------------|
|
||||
| `method` | `agent` / `cli` / `hybrid` | Execution mode (default: agent) |
|
||||
| `cli_tool` | See `~/.claude/cli-tools.json` | CLI tool preference (first enabled tool as default) |
|
||||
| `enable_resume` | `true` / `false` | Enable CLI session resume |
|
||||
|
||||
**CLI Execution Reference** (from task.cli_execution):
|
||||
| Field | Values | Description |
|
||||
|-------|--------|-------------|
|
||||
| `strategy` | `new` / `resume` / `fork` / `merge_fork` | Resume strategy |
|
||||
| `resume_from` | `{session}-{task_id}` | Parent task CLI ID (resume/fork) |
|
||||
| `merge_from` | `[{id1}, {id2}]` | Parent task CLI IDs (merge_fork) |
|
||||
|
||||
**Resume Strategy Examples**:
|
||||
- **New task** (no dependencies): `--id WFS-001-IMPL-001`
|
||||
- **Resume** (single dependency, single child): `--resume WFS-001-IMPL-001`
|
||||
- **Fork** (single dependency, multiple children): `--resume WFS-001-IMPL-001 --id WFS-001-IMPL-002`
|
||||
- **Merge** (multiple dependencies): `--resume WFS-001-IMPL-001,WFS-001-IMPL-002 --id WFS-001-IMPL-003`
|
||||
|
||||
**Test-Driven Development**:
|
||||
- Write tests first (red → green → refactor)
|
||||
@@ -389,7 +505,8 @@ Before completing any task, verify:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls - agent cannot receive task hook callbacks
|
||||
- Set timeout ≥60 minutes for CLI commands (hooks don't propagate to subagents):
|
||||
```javascript
|
||||
Bash(command="ccw cli -p '...' --tool codex --mode write", timeout=3600000) // 60 min
|
||||
Bash(command="ccw cli -p '...' --tool <cli-tool> --mode write", timeout=3600000) // 60 min
|
||||
// <cli-tool>: First enabled tool from ~/.claude/cli-tools.json (e.g., gemini, qwen, codex)
|
||||
```
|
||||
|
||||
**ALWAYS:**
|
||||
|
||||
1102
.claude/commands/ccw-coordinator.md
Normal file
1102
.claude/commands/ccw-coordinator.md
Normal file
File diff suppressed because it is too large
Load Diff
832
.claude/commands/ccw-debug.md
Normal file
832
.claude/commands/ccw-debug.md
Normal file
@@ -0,0 +1,832 @@
|
||||
---
|
||||
name: ccw-debug
|
||||
description: Aggregated debug command - combines debugging diagnostics and test verification in a synergistic workflow supporting cli-quick / debug-first / test-first / bidirectional-verification modes
|
||||
argument-hint: "[--mode cli|debug|test|bidirectional] [--yes|-y] [--hotfix] \"bug description or error message\""
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), AskUserQuestion(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# CCW-Debug Aggregated Command
|
||||
|
||||
## Core Concept
|
||||
|
||||
**Aggregated Debug Command** - Combines debugging diagnostics and test verification in a synergistic workflow. Not a simple concatenation of two commands, but intelligent orchestration based on mode selection.
|
||||
|
||||
### Four Execution Modes
|
||||
|
||||
| Mode | Workflow | Use Case | Characteristics |
|
||||
|------|----------|----------|-----------------|
|
||||
| **CLI Quick** (cli) | Direct CLI Analysis → Fix Suggestions | Simple issues, quick diagnosis | Fastest, minimal workflow, recommendation-only |
|
||||
| **Debug First** (debug) | Debug → Analyze Hypotheses → Apply Fix → Test Verification | Root cause unclear, requires exploration | Starts with exploration, Gemini-assisted |
|
||||
| **Test First** (test) | Generate Tests → Execute → Analyze Failures → CLI Fixes | Code implemented, needs test validation | Driven by test coverage, auto-iterates |
|
||||
| **Bidirectional Verification** (bidirectional) | Parallel: Debug + Test → Merge Findings → Unified Fix | Complex systems, ambiguous symptoms | Parallel execution, converged insights |
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# CLI quick mode: fastest, recommendation-only (new!)
|
||||
/ccw-debug --mode cli "Login failed: token validation error"
|
||||
|
||||
# Default mode: debug-first (recommended for most scenarios)
|
||||
/ccw-debug "Login failed: token validation error"
|
||||
|
||||
# Test-first mode
|
||||
/ccw-debug --mode test "User permission check failure"
|
||||
|
||||
# Bidirectional verification mode (complex issues)
|
||||
/ccw-debug --mode bidirectional "Payment flow multiple failures"
|
||||
|
||||
# Auto mode (skip all confirmations)
|
||||
/ccw-debug --yes "Quick fix: database connection timeout"
|
||||
|
||||
# Production hotfix (minimal diagnostics)
|
||||
/ccw-debug --hotfix --yes "Production: API returns 500"
|
||||
```
|
||||
|
||||
### Mode Selection Guide
|
||||
|
||||
**Choose "CLI Quick"** when:
|
||||
- Need immediate diagnosis, not execution
|
||||
- Want quick recommendations without workflows
|
||||
- Simple issues with clear symptoms
|
||||
- Just need fix suggestions, no auto-application
|
||||
- Time is critical, prefer fast output
|
||||
- Want to review CLI analysis before action
|
||||
|
||||
**Choose "Debug First"** when:
|
||||
- Root cause is unclear
|
||||
- Error messages are incomplete or vague
|
||||
- Need to understand code execution flow
|
||||
- Issues involve multi-module interactions
|
||||
|
||||
**Choose "Test First"** when:
|
||||
- Code is fully implemented
|
||||
- Need test coverage verification
|
||||
- Have clear failure cases
|
||||
- Want automated iterative fixes
|
||||
|
||||
**Choose "Bidirectional Verification"** when:
|
||||
- System is complex (multiple subsystems)
|
||||
- Problem symptoms are ambiguous (multiple possible root causes)
|
||||
- Need multi-angle validation
|
||||
- Time allows parallel analysis
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Overall Process
|
||||
|
||||
```
|
||||
Phase 1: Intent Analysis & Mode Selection
|
||||
├─ Parse --mode flag or recommend mode
|
||||
├─ Check --hotfix and --yes flags
|
||||
└─ Determine workflow path
|
||||
|
||||
Phase 2: Initialization
|
||||
├─ CLI Quick: Lightweight init (no session directory needed)
|
||||
├─ Others: Create unified session directory (.workflow/.ccw-debug/)
|
||||
├─ Setup TodoWrite tracking
|
||||
└─ Prepare session context
|
||||
|
||||
Phase 3: Execute Corresponding Workflow
|
||||
├─ CLI Quick: ccw cli → Diagnosis Report → Optional: Escalate to debug/test/apply fix
|
||||
├─ Debug First: /workflow:debug-with-file → Fix → /workflow:test-fix-gen → /workflow:test-cycle-execute
|
||||
├─ Test First: /workflow:test-fix-gen → /workflow:test-cycle-execute → CLI analyze failures
|
||||
└─ Bidirectional: [/workflow:debug-with-file] ∥ [/workflow:test-fix-gen → test-cycle-execute]
|
||||
|
||||
Phase 4: Merge Findings (Bidirectional Mode) / Escalation Decision (CLI Mode)
|
||||
├─ CLI Quick: Present results → Ask user: Apply fix? Escalate? Done?
|
||||
├─ Bidirectional: Converge findings from both workflows
|
||||
├─ Identify consistent and conflicting root cause analyses
|
||||
└─ Generate unified fix plan
|
||||
|
||||
Phase 5: Completion & Follow-up
|
||||
├─ Generate summary report
|
||||
├─ Provide next step recommendations
|
||||
└─ Optional: Expand to issues (testing/enhancement/refactoring/documentation)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Details
|
||||
|
||||
### Mode 0: CLI Quick (Minimal Debug Method)
|
||||
|
||||
**Best For**: Fast recommendations without full workflow overhead
|
||||
|
||||
**Workflow**:
|
||||
```
|
||||
User Input → Quick Context Gather → ccw cli (Gemini/Qwen/Codex)
|
||||
↓
|
||||
Analysis Report
|
||||
↓
|
||||
Fix Recommendations
|
||||
↓
|
||||
Optional: User Decision
|
||||
┌──────────────┼──────────────┐
|
||||
↓ ↓ ↓
|
||||
Apply Fix Escalate Mode Done
|
||||
(debug/test)
|
||||
```
|
||||
|
||||
**Execution Steps**:
|
||||
|
||||
1. **Lightweight Context Gather** (Phase 2)
|
||||
```javascript
|
||||
// No session directory needed for CLI mode
|
||||
const tempContext = {
|
||||
bug_description: bug_description,
|
||||
timestamp: getUtc8ISOString(),
|
||||
mode: "cli"
|
||||
}
|
||||
|
||||
// Quick context discovery (30s max)
|
||||
// - Read error file if path provided
|
||||
// - Extract error patterns from description
|
||||
// - Identify likely affected files (basic grep)
|
||||
```
|
||||
|
||||
2. **Execute CLI Analysis** (Phase 3)
|
||||
```bash
|
||||
# Use ccw cli with bug diagnosis template
|
||||
ccw cli -p "
|
||||
PURPOSE: Quick bug diagnosis for immediate recommendations
|
||||
|
||||
TASK:
|
||||
• Analyze bug symptoms: ${bug_description}
|
||||
• Identify likely root cause
|
||||
• Provide actionable fix recommendations (code snippets if possible)
|
||||
• Assess fix confidence level
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: ${contextFiles.length > 0 ? '@' + contextFiles.join(' @') : 'Bug description only'}
|
||||
|
||||
EXPECTED:
|
||||
- Root cause hypothesis (1-2 sentences)
|
||||
- Fix strategy (immediate/comprehensive/refactor)
|
||||
- Code snippets or file modification suggestions
|
||||
- Confidence level: High/Medium/Low
|
||||
- Risk assessment
|
||||
|
||||
CONSTRAINTS: Quick analysis, 2-5 minutes max
|
||||
" --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
|
||||
```
|
||||
|
||||
3. **Present Results** (Phase 4)
|
||||
```
|
||||
## CLI Quick Analysis Complete
|
||||
|
||||
**Issue**: [bug_description]
|
||||
**Analysis Time**: [duration]
|
||||
**Confidence**: [High/Medium/Low]
|
||||
|
||||
### Root Cause
|
||||
[1-2 sentence hypothesis]
|
||||
|
||||
### Fix Strategy
|
||||
[immediate_patch | comprehensive_fix | refactor]
|
||||
|
||||
### Recommended Changes
|
||||
|
||||
**File**: src/module/file.ts
|
||||
```typescript
|
||||
// Change line 45-50
|
||||
- old code
|
||||
+ new code
|
||||
```
|
||||
|
||||
**Rationale**: [why this fix]
|
||||
**Risk**: [Low/Medium/High] - [risk description]
|
||||
|
||||
### Confidence Assessment
|
||||
- Analysis confidence: [percentage]
|
||||
- Recommendation: [apply immediately | review first | escalate to full debug]
|
||||
```
|
||||
|
||||
4. **User Decision** (Phase 5)
|
||||
```javascript
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes && confidence === 'High') {
|
||||
// Auto-apply fix
|
||||
console.log('[--yes + High confidence] Auto-applying fix...')
|
||||
applyFixFromCLIRecommendation(cliOutput)
|
||||
} else {
|
||||
// Ask user
|
||||
const decision = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `CLI analysis complete (${confidence} confidence). What next?`,
|
||||
header: "Decision",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Apply Fix", description: "Apply recommended changes immediately" },
|
||||
{ label: "Escalate to Debug", description: "Switch to debug-first for deeper analysis" },
|
||||
{ label: "Escalate to Test", description: "Switch to test-first for validation" },
|
||||
{ label: "Review Only", description: "Just review, no action" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
|
||||
if (decision === "Apply Fix") {
|
||||
applyFixFromCLIRecommendation(cliOutput)
|
||||
} else if (decision === "Escalate to Debug") {
|
||||
// Re-invoke ccw-debug with --mode debug
|
||||
SlashCommand(command=`/ccw-debug --mode debug "${bug_description}"`)
|
||||
} else if (decision === "Escalate to Test") {
|
||||
// Re-invoke ccw-debug with --mode test
|
||||
SlashCommand(command=`/ccw-debug --mode test "${bug_description}"`)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Speed**: 2-5 minutes total (fastest mode)
|
||||
- **Session**: No persistent session directory (lightweight)
|
||||
- **Output**: Recommendation report only
|
||||
- **Execution**: Optional, user-controlled
|
||||
- **Escalation**: Can upgrade to full debug/test workflows
|
||||
|
||||
**Limitations**:
|
||||
- No hypothesis iteration (single-shot analysis)
|
||||
- No automatic test generation
|
||||
- No instrumentation/logging
|
||||
- Best for clear symptoms with localized fixes
|
||||
|
||||
---
|
||||
|
||||
### Mode 1: Debug First
|
||||
|
||||
**Best For**: Issues requiring root cause exploration
|
||||
|
||||
**Workflow**:
|
||||
```
|
||||
User Input → Session Init → /workflow:debug-with-file
|
||||
↓
|
||||
Generate understanding.md + hypotheses
|
||||
↓
|
||||
User reproduces issue, analyze logs
|
||||
↓
|
||||
Gemini validates hypotheses
|
||||
↓
|
||||
Apply fix code
|
||||
↓
|
||||
/workflow:test-fix-gen
|
||||
↓
|
||||
/workflow:test-cycle-execute
|
||||
↓
|
||||
Generate unified report
|
||||
```
|
||||
|
||||
**Execution Steps**:
|
||||
|
||||
1. **Session Initialization** (Phase 2)
|
||||
```javascript
|
||||
const sessionId = `CCWD-${bugSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.ccw-debug/${sessionId}`
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
|
||||
// Record mode selection
|
||||
const modeConfig = {
|
||||
mode: "debug",
|
||||
original_input: bug_description,
|
||||
timestamp: getUtc8ISOString(),
|
||||
flags: { hotfix, autoYes }
|
||||
}
|
||||
Write(`${sessionFolder}/mode-config.json`, JSON.stringify(modeConfig, null, 2))
|
||||
```
|
||||
|
||||
2. **Start Debug** (Phase 3)
|
||||
```javascript
|
||||
SlashCommand(command=`/workflow:debug-with-file "${bug_description}"`)
|
||||
|
||||
// Update TodoWrite
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{ content: "Phase 1: Debug & Analysis", status: "completed" },
|
||||
{ content: "Phase 2: Apply Fix from Debug Findings", status: "in_progress" },
|
||||
{ content: "Phase 3: Generate & Execute Tests", status: "pending" },
|
||||
{ content: "Phase 4: Generate Report", status: "pending" }
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
3. **Apply Fix** (Handled by debug command)
|
||||
|
||||
4. **Test Generation & Execution**
|
||||
```javascript
|
||||
// Auto-continue after debug command completes
|
||||
SlashCommand(command=`/workflow:test-fix-gen "Test validation for: ${bug_description}"`)
|
||||
SlashCommand(command="/workflow:test-cycle-execute")
|
||||
```
|
||||
|
||||
5. **Generate Report** (Phase 5)
|
||||
```
|
||||
## Debug-First Workflow Completed
|
||||
|
||||
**Issue**: [bug_description]
|
||||
**Mode**: Debug First
|
||||
**Session**: [sessionId]
|
||||
|
||||
### Debug Phase Results
|
||||
- Root Cause: [extracted from understanding.md]
|
||||
- Hypothesis Confirmation: [from hypotheses.json]
|
||||
- Fixes Applied: [list of modified files]
|
||||
|
||||
### Test Phase Results
|
||||
- Tests Created: [test files generated by IMPL-001]
|
||||
- Pass Rate: [final test pass rate]
|
||||
- Iteration Count: [fix iterations]
|
||||
|
||||
### Key Findings
|
||||
- [learning points from debugging]
|
||||
- [coverage insights from testing]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Mode 2: Test First
|
||||
|
||||
**Best For**: Implemented code needing test validation
|
||||
|
||||
**Workflow**:
|
||||
```
|
||||
User Input → Session Init → /workflow:test-fix-gen
|
||||
↓
|
||||
Generate test tasks (IMPL-001, IMPL-002)
|
||||
↓
|
||||
/workflow:test-cycle-execute
|
||||
↓
|
||||
Auto-iterate: Test → Analyze Failures → CLI Fix
|
||||
↓
|
||||
Until pass rate ≥ 95%
|
||||
↓
|
||||
Generate report
|
||||
```
|
||||
|
||||
**Execution Steps**:
|
||||
|
||||
1. **Session Initialization** (Phase 2)
|
||||
```javascript
|
||||
const modeConfig = {
|
||||
mode: "test",
|
||||
original_input: bug_description,
|
||||
timestamp: getUtc8ISOString(),
|
||||
flags: { hotfix, autoYes }
|
||||
}
|
||||
```
|
||||
|
||||
2. **Generate Tests** (Phase 3)
|
||||
```javascript
|
||||
SlashCommand(command=`/workflow:test-fix-gen "${bug_description}"`)
|
||||
|
||||
// Update TodoWrite
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{ content: "Phase 1: Generate Tests", status: "completed" },
|
||||
{ content: "Phase 2: Execute & Fix Tests", status: "in_progress" },
|
||||
{ content: "Phase 3: Final Validation", status: "pending" },
|
||||
{ content: "Phase 4: Generate Report", status: "pending" }
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
3. **Execute & Iterate** (Phase 3 cont.)
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:test-cycle-execute")
|
||||
|
||||
// test-cycle-execute handles:
|
||||
// - Execute tests
|
||||
// - Analyze failures
|
||||
// - Generate fix tasks via CLI
|
||||
// - Iterate fixes until pass
|
||||
```
|
||||
|
||||
4. **Generate Report** (Phase 5)
|
||||
|
||||
---
|
||||
|
||||
### Mode 3: Bidirectional Verification
|
||||
|
||||
**Best For**: Complex systems, multi-dimensional analysis
|
||||
|
||||
**Workflow**:
|
||||
```
|
||||
User Input → Session Init → Parallel execution:
|
||||
┌──────────────────────────────┐
|
||||
│ │
|
||||
↓ ↓
|
||||
/workflow:debug-with-file /workflow:test-fix-gen
|
||||
│ │
|
||||
Generate hypotheses & understanding Generate test tasks
|
||||
│ │
|
||||
↓ ↓
|
||||
Apply debug fixes /workflow:test-cycle-execute
|
||||
│ │
|
||||
└──────────────┬───────────────┘
|
||||
↓
|
||||
Phase 4: Merge Findings
|
||||
├─ Converge root cause analyses
|
||||
├─ Identify consistency (mutual validation)
|
||||
├─ Identify conflicts (need coordination)
|
||||
└─ Generate unified report
|
||||
```
|
||||
|
||||
**Execution Steps**:
|
||||
|
||||
1. **Parallel Execution** (Phase 3)
|
||||
```javascript
|
||||
// Start debug
|
||||
const debugTask = SlashCommand(
|
||||
command=`/workflow:debug-with-file "${bug_description}"`,
|
||||
run_in_background=false
|
||||
)
|
||||
|
||||
// Start test generation (synchronous execution, SlashCommand blocks)
|
||||
const testTask = SlashCommand(
|
||||
command=`/workflow:test-fix-gen "${bug_description}"`,
|
||||
run_in_background=false
|
||||
)
|
||||
|
||||
// Execute test cycle
|
||||
const testCycleTask = SlashCommand(
|
||||
command="/workflow:test-cycle-execute",
|
||||
run_in_background=false
|
||||
)
|
||||
```
|
||||
|
||||
2. **Merge Findings** (Phase 4)
|
||||
```javascript
|
||||
// Read debug results
|
||||
const understandingMd = Read(`${debugSessionFolder}/understanding.md`)
|
||||
const hypothesesJson = JSON.parse(Read(`${debugSessionFolder}/hypotheses.json`))
|
||||
|
||||
// Read test results
|
||||
const testResultsJson = JSON.parse(Read(`${testSessionFolder}/.process/test-results.json`))
|
||||
const fixPlanJson = JSON.parse(Read(`${testSessionFolder}/.task/IMPL-002.json`))
|
||||
|
||||
// Merge analysis
|
||||
const convergence = {
|
||||
debug_root_cause: hypothesesJson.confirmed_hypothesis,
|
||||
test_failure_pattern: testResultsJson.failures,
|
||||
consistency: analyzeConsistency(debugRootCause, testFailures),
|
||||
conflicts: identifyConflicts(debugRootCause, testFailures),
|
||||
unified_root_cause: mergeRootCauses(debugRootCause, testFailures),
|
||||
recommended_fix: selectBestFix(debugRootCause, testRootCause)
|
||||
}
|
||||
```
|
||||
|
||||
3. **Generate Report** (Phase 5)
|
||||
```
|
||||
## Bidirectional Verification Workflow Completed
|
||||
|
||||
**Issue**: [bug_description]
|
||||
**Mode**: Bidirectional Verification
|
||||
|
||||
### Debug Findings
|
||||
- Root Cause (hypothesis): [from understanding.md]
|
||||
- Confidence: [from hypotheses.json]
|
||||
- Key code paths: [file:line]
|
||||
|
||||
### Test Findings
|
||||
- Failure pattern: [list of failing tests]
|
||||
- Error type: [error type]
|
||||
- Impact scope: [affected modules]
|
||||
|
||||
### Merged Analysis
|
||||
- ✓ Consistent: Both workflows identified same root cause
|
||||
- ⚠ Conflicts: [list any conflicts]
|
||||
- → Unified Root Cause: [final confirmed root cause]
|
||||
|
||||
### Recommended Fix
|
||||
- Strategy: [selected fix strategy]
|
||||
- Rationale: [why this strategy]
|
||||
- Risks: [known risks]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Command Line Interface
|
||||
|
||||
### Complete Syntax
|
||||
|
||||
```bash
|
||||
/ccw-debug [OPTIONS] <BUG_DESCRIPTION>
|
||||
|
||||
Options:
|
||||
--mode <cli|debug|test|bidirectional> Execution mode (default: debug)
|
||||
--yes, -y Auto mode (skip all confirmations)
|
||||
--hotfix, -h Production hotfix mode (only for debug mode)
|
||||
--no-tests Skip test generation in debug-first mode
|
||||
--skip-report Don't generate final report
|
||||
--resume <session-id> Resume interrupted session
|
||||
|
||||
Arguments:
|
||||
<BUG_DESCRIPTION> Issue description, error message, or .md file path
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# CLI quick mode: fastest, recommendation-only (NEW!)
|
||||
/ccw-debug --mode cli "User login timeout"
|
||||
/ccw-debug --mode cli --yes "Quick fix: API 500 error" # Auto-apply if high confidence
|
||||
|
||||
# Debug first (default)
|
||||
/ccw-debug "User login timeout"
|
||||
|
||||
# Test first
|
||||
/ccw-debug --mode test "Payment validation failure"
|
||||
|
||||
# Bidirectional verification
|
||||
/ccw-debug --mode bidirectional "Multi-module data consistency issue"
|
||||
|
||||
# Hotfix auto mode
|
||||
/ccw-debug --hotfix --yes "API 500 error"
|
||||
|
||||
# Debug first, skip tests
|
||||
/ccw-debug --no-tests "Understand code flow"
|
||||
|
||||
# Resume interrupted session
|
||||
/ccw-debug --resume CCWD-login-timeout-2025-01-27
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Structure
|
||||
|
||||
### File Organization
|
||||
|
||||
```
|
||||
.workflow/.ccw-debug/CCWD-{slug}-{date}/
|
||||
├── mode-config.json # Mode configuration and flags
|
||||
├── session-manifest.json # Session index and status
|
||||
├── final-report.md # Final report
|
||||
│
|
||||
├── debug/ # Debug workflow (if mode includes debug)
|
||||
│ ├── debug-session-id.txt
|
||||
│ ├── understanding.md
|
||||
│ ├── hypotheses.json
|
||||
│ └── debug.log
|
||||
│
|
||||
├── test/ # Test workflow (if mode includes test)
|
||||
│ ├── test-session-id.txt
|
||||
│ ├── IMPL_PLAN.md
|
||||
│ ├── test-results.json
|
||||
│ └── iteration-state.json
|
||||
│
|
||||
└── fusion/ # Fusion analysis (bidirectional mode)
|
||||
├── convergence-analysis.json
|
||||
├── consistency-report.md
|
||||
└── unified-root-cause.json
|
||||
```
|
||||
|
||||
### Session State Management
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWD-login-timeout-2025-01-27",
|
||||
"mode": "debug|test|bidirectional",
|
||||
"status": "running|completed|failed|paused",
|
||||
"phases": {
|
||||
"phase_1": { "status": "completed", "timestamp": "..." },
|
||||
"phase_2": { "status": "in_progress", "timestamp": "..." },
|
||||
"phase_3": { "status": "pending" },
|
||||
"phase_4": { "status": "pending" },
|
||||
"phase_5": { "status": "pending" }
|
||||
},
|
||||
"sub_sessions": {
|
||||
"debug_session": "DBG-...",
|
||||
"test_session": "WFS-test-..."
|
||||
},
|
||||
"artifacts": {
|
||||
"debug_understanding": "...",
|
||||
"test_results": "...",
|
||||
"fusion_analysis": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Logic
|
||||
|
||||
### Auto Mode Recommendation
|
||||
|
||||
When user doesn't specify `--mode`, recommend based on input analysis:
|
||||
|
||||
```javascript
|
||||
function recommendMode(bugDescription) {
|
||||
const indicators = {
|
||||
cli_signals: [
|
||||
/quick|fast|simple|immediate/,
|
||||
/recommendation|suggest|advice/,
|
||||
/just need|only want|quick look/,
|
||||
/straightforward|obvious|clear/
|
||||
],
|
||||
debug_signals: [
|
||||
/unclear|don't know|maybe|uncertain|why/,
|
||||
/error|crash|fail|exception|stack trace/,
|
||||
/execution flow|code path|how does/
|
||||
],
|
||||
test_signals: [
|
||||
/test|coverage|verify|pass|fail/,
|
||||
/implementation|implemented|complete/,
|
||||
/case|scenario|should/
|
||||
],
|
||||
complex_signals: [
|
||||
/multiple|all|system|integration/,
|
||||
/module|subsystem|network|distributed/,
|
||||
/concurrent|async|race/
|
||||
]
|
||||
}
|
||||
|
||||
let score = { cli: 0, debug: 0, test: 0, bidirectional: 0 }
|
||||
|
||||
// CLI signals (lightweight preference)
|
||||
for (const pattern of indicators.cli_signals) {
|
||||
if (pattern.test(bugDescription)) score.cli += 3
|
||||
}
|
||||
|
||||
// Debug signals
|
||||
for (const pattern of indicators.debug_signals) {
|
||||
if (pattern.test(bugDescription)) score.debug += 2
|
||||
}
|
||||
|
||||
// Test signals
|
||||
for (const pattern of indicators.test_signals) {
|
||||
if (pattern.test(bugDescription)) score.test += 2
|
||||
}
|
||||
|
||||
// Complex signals (prefer bidirectional for complex issues)
|
||||
for (const pattern of indicators.complex_signals) {
|
||||
if (pattern.test(bugDescription)) {
|
||||
score.bidirectional += 3
|
||||
score.cli -= 2 // Complex issues not suitable for CLI quick
|
||||
}
|
||||
}
|
||||
|
||||
// If description is short and has clear error, prefer CLI
|
||||
if (bugDescription.length < 100 && /error|fail|crash/.test(bugDescription)) {
|
||||
score.cli += 2
|
||||
}
|
||||
|
||||
// Return highest scoring mode
|
||||
return Object.entries(score).sort((a, b) => b[1] - a[1])[0][0]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### When to Use Each Mode
|
||||
|
||||
| Issue Characteristic | Recommended Mode | Rationale |
|
||||
|----------------------|-----------------|-----------|
|
||||
| Simple error, clear symptoms | CLI Quick | Fastest recommendation |
|
||||
| Incomplete error info, requires exploration | Debug First | Deep diagnostic capability |
|
||||
| Code complete, needs test coverage | Test First | Automated iterative fixes |
|
||||
| Cross-module issue, ambiguous symptoms | Bidirectional | Multi-angle insights |
|
||||
| Production failure, needs immediate guidance | CLI Quick + --yes | Fastest guidance, optional escalation |
|
||||
| Production failure, needs safe fix | Debug First + --hotfix | Minimal diagnosis time |
|
||||
| Want to understand why it failed | Debug First | Records understanding evolution |
|
||||
| Want to ensure all scenarios pass | Test First | Complete coverage-driven |
|
||||
|
||||
### Performance Tips
|
||||
|
||||
- **CLI Quick**: 2-5 minutes, no file I/O, recommendation-only
|
||||
- **Debug First**: Usually requires manual issue reproduction (after logging added), then 15-30 min
|
||||
- **Test First**: Fully automated, 20-45 min depending on test suite size
|
||||
- **Bidirectional**: Most comprehensive but slowest (parallel workflows), 30-60 min
|
||||
|
||||
### Workflow Continuity
|
||||
|
||||
- **CLI Quick**: Can escalate to debug/test/apply fix based on user decision
|
||||
- **Debug First**: Auto-launches test generation and execution after completion
|
||||
- **Test First**: With high failure rates suggests switching to debug mode for root cause
|
||||
- **Bidirectional**: Always executes complete flow
|
||||
|
||||
---
|
||||
|
||||
## Follow-up Expansion
|
||||
|
||||
After completion, offer to expand to issues:
|
||||
|
||||
```
|
||||
## Done! What's next?
|
||||
|
||||
- [ ] Create Test issue (improve test coverage)
|
||||
- [ ] Create Enhancement issue (optimize code quality)
|
||||
- [ ] Create Refactor issue (improve architecture)
|
||||
- [ ] Create Documentation issue (record learnings)
|
||||
- [ ] Don't create any issue, end workflow
|
||||
```
|
||||
|
||||
Selected items call: `/issue:new "{issue summary} - {dimension}"`
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | CLI Quick | Debug First | Test First | Bidirectional |
|
||||
|-------|-----------|-------------|-----------|---------------|
|
||||
| Session creation failed | N/A (no session) | Retry → abort | Retry → abort | Retry → abort |
|
||||
| CLI analysis failed | Retry with fallback tool → manual | N/A | N/A | N/A |
|
||||
| Diagnosis/test failed | N/A | Continue with partial results | Direct failure | Use alternate workflow results |
|
||||
| Low confidence result | Ask escalate or review | N/A | N/A | N/A |
|
||||
| Merge conflicts | N/A | N/A | N/A | Select highest confidence plan |
|
||||
| Fix application failed | Report error, no auto-retry | Request manual fix | Mark failed, request intervention | Try alternative plan |
|
||||
|
||||
---
|
||||
|
||||
## Relationship with ccw Command
|
||||
|
||||
| Feature | ccw | ccw-debug |
|
||||
|---------|-----|----------|
|
||||
| **Design** | General workflow orchestration | Debug + test aggregation |
|
||||
| **Intent Detection** | ✅ Detects task type | ✅ Detects issue type |
|
||||
| **Automation** | ✅ Auto-selects workflow | ✅ Auto-selects mode |
|
||||
| **Quick Mode** | ❌ None | ✅ CLI Quick (2-5 min) |
|
||||
| **Parallel Execution** | ❌ Sequential | ✅ Bidirectional mode parallel |
|
||||
| **Fusion Analysis** | ❌ None | ✅ Bidirectional mode fusion |
|
||||
| **Workflow Scope** | Broad (feature/bugfix/tdd/ui etc.) | Deep focus (debug + test) |
|
||||
| **CLI Integration** | Yes | Yes (4 levels: quick/deep/iterative/fusion) |
|
||||
|
||||
---
|
||||
|
||||
## Usage Recommendations
|
||||
|
||||
1. **First Time**: Use default mode (debug-first), observe workflow
|
||||
2. **Quick Decision**: Use CLI Quick (--mode cli) for immediate recommendations
|
||||
3. **Quick Fix**: Use `--hotfix --yes` for minimal diagnostics (debug mode)
|
||||
4. **Learning**: Use debug-first, read `understanding.md`
|
||||
5. **Complete Validation**: Use bidirectional for multi-dimensional insights
|
||||
6. **Auto Repair**: Use test-first for automatic iteration
|
||||
7. **Escalation**: Start with CLI Quick, escalate to other modes as needed
|
||||
|
||||
---
|
||||
|
||||
## Reference
|
||||
|
||||
### Related Commands
|
||||
|
||||
- `ccw cli` - Direct CLI analysis (used by CLI Quick mode)
|
||||
- `/workflow:debug-with-file` - Deep debug diagnostics
|
||||
- `/workflow:test-fix-gen` - Test generation
|
||||
- `/workflow:test-cycle-execute` - Test execution
|
||||
- `/workflow:lite-fix` - Lightweight fix
|
||||
- `/ccw` - General workflow orchestration
|
||||
|
||||
### Configuration Files
|
||||
|
||||
- `~/.claude/cli-tools.json` - CLI tool configuration (Gemini/Qwen/Codex)
|
||||
- `.workflow/project-tech.json` - Project technology stack
|
||||
- `.workflow/project-guidelines.json` - Project conventions
|
||||
|
||||
### CLI Tool Fallback Chain (for CLI Quick mode)
|
||||
|
||||
When CLI analysis fails, fallback order:
|
||||
1. **Gemini** (primary): `gemini-2.5-pro`
|
||||
2. **Qwen** (fallback): `coder-model`
|
||||
3. **Codex** (fallback): `gpt-5.2`
|
||||
|
||||
---
|
||||
|
||||
## Summary: Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-debug <bug_description>
|
||||
|
||||
┌─ Explicit --mode specified?
|
||||
│ ├─ YES → Use specified mode
|
||||
│ │ ├─ cli → 2-5 min analysis, optionally escalate
|
||||
│ │ ├─ debug → Full debug-with-file workflow
|
||||
│ │ ├─ test → Test-first workflow
|
||||
│ │ └─ bidirectional → Parallel debug + test
|
||||
│ │
|
||||
│ └─ NO → Auto-recommend based on bug description
|
||||
│ ├─ Keywords: "quick", "fast", "simple" → CLI Quick
|
||||
│ ├─ Keywords: "error", "crash", "exception" → Debug First (or CLI if simple)
|
||||
│ ├─ Keywords: "test", "verify", "coverage" → Test First
|
||||
│ └─ Keywords: "multiple", "system", "distributed" → Bidirectional
|
||||
│
|
||||
├─ Check --yes flag
|
||||
│ ├─ YES → Auto-confirm all decisions
|
||||
│ │ ├─ CLI mode: Auto-apply if confidence High
|
||||
│ │ └─ Others: Auto-select default options
|
||||
│ │
|
||||
│ └─ NO → Interactive mode, ask user for confirmations
|
||||
│
|
||||
├─ Check --hotfix flag (debug mode only)
|
||||
│ ├─ YES → Minimal diagnostics, fast fix
|
||||
│ └─ NO → Full analysis
|
||||
│
|
||||
└─ Execute selected mode workflow
|
||||
└─ Return results or escalation options
|
||||
```
|
||||
567
.claude/commands/ccw.md
Normal file
567
.claude/commands/ccw.md
Normal file
@@ -0,0 +1,567 @@
|
||||
---
|
||||
name: ccw
|
||||
description: Main workflow orchestrator - analyze intent, select workflow, execute command chain in main process
|
||||
argument-hint: "\"task description\""
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*)
|
||||
---
|
||||
|
||||
# CCW Command - Main Workflow Orchestrator
|
||||
|
||||
Main process orchestrator: intent analysis → workflow selection → command chain execution.
|
||||
|
||||
## Core Concept: Minimum Execution Units (最小执行单元)
|
||||
|
||||
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone.
|
||||
|
||||
**Why This Matters**:
|
||||
- **Prevents Incomplete States**: Avoid stopping after task generation without execution
|
||||
- **User Experience**: User gets complete results, not intermediate artifacts requiring manual follow-up
|
||||
- **Workflow Integrity**: Maintains logical coherence of multi-step operations
|
||||
|
||||
**Key Units in CCW**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Planning + Execution** | plan-cmd → execute-cmd | lite-plan → lite-execute |
|
||||
| **Testing** | test-gen-cmd → test-exec-cmd | test-fix-gen → test-cycle-execute |
|
||||
| **Review** | review-cmd → fix-cmd | review-session-cycle → review-cycle-fix |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. CCW automatically groups commands into minimum units - never splits them
|
||||
2. Pipeline visualization shows units with `【 】` markers
|
||||
3. Error handling preserves unit boundaries (retry/skip affects whole unit)
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Commands execute via SlashCommand in main process, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Intent → Select Workflow → [Confirm] → Execute Chain
|
||||
↓
|
||||
SlashCommand (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Next Command...
|
||||
```
|
||||
|
||||
**vs ccw-coordinator**: External CLI execution with background tasks and hook callbacks.
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Intent
|
||||
|
||||
```javascript
|
||||
function analyzeIntent(input) {
|
||||
return {
|
||||
goal: extractGoal(input),
|
||||
scope: extractScope(input),
|
||||
constraints: extractConstraints(input),
|
||||
task_type: detectTaskType(input), // bugfix|feature|tdd|review|exploration|...
|
||||
complexity: assessComplexity(input), // low|medium|high
|
||||
clarity_score: calculateClarity(input) // 0-3 (>=2 = clear)
|
||||
};
|
||||
}
|
||||
|
||||
// Task type detection (priority order)
|
||||
function detectTaskType(text) {
|
||||
const patterns = {
|
||||
'bugfix-hotfix': /urgent|production|critical/ && /fix|bug/,
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm': /brainstorm|ideation|头脑风暴|创意|发散思维|creative thinking|multi-perspective.*think|compare perspectives|探索.*可能/,
|
||||
'brainstorm-to-issue': /brainstorm.*issue|头脑风暴.*issue|idea.*issue|想法.*issue|从.*头脑风暴|convert.*brainstorm/,
|
||||
'debug-file': /debug.*document|hypothesis.*debug|troubleshoot.*track|investigate.*log|调试.*记录|假设.*验证|systematic debug|深度调试/,
|
||||
'analyze-file': /analyze.*document|explore.*concept|understand.*architecture|investigate.*discuss|collaborative analysis|分析.*讨论|深度.*理解|协作.*分析/,
|
||||
// Standard workflows
|
||||
'bugfix': /fix|bug|error|crash|fail|debug/,
|
||||
'issue-batch': /issues?|batch/ && /fix|resolve/,
|
||||
'issue-transition': /issue workflow|structured workflow|queue|multi-stage/,
|
||||
'exploration': /uncertain|explore|research|what if/,
|
||||
'quick-task': /quick|simple|small/ && /feature|function/,
|
||||
'ui-design': /ui|design|component|style/,
|
||||
'tdd': /tdd|test-driven|test first/,
|
||||
'test-fix': /test fail|fix test|failing test/,
|
||||
'review': /review|code review/,
|
||||
'documentation': /docs|documentation|readme/
|
||||
};
|
||||
for (const [type, pattern] of Object.entries(patterns)) {
|
||||
if (pattern.test(text)) return type;
|
||||
}
|
||||
return 'feature';
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: `Type: [task_type] | Goal: [goal] | Complexity: [complexity] | Clarity: [clarity_score]/3`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Requirement Clarification (if clarity_score < 2)
|
||||
|
||||
```javascript
|
||||
async function clarifyRequirements(analysis) {
|
||||
if (analysis.clarity_score >= 2) return analysis;
|
||||
|
||||
const questions = generateClarificationQuestions(analysis); // Goal, Scope, Constraints
|
||||
const answers = await AskUserQuestion({ questions });
|
||||
return updateAnalysis(analysis, answers);
|
||||
}
|
||||
```
|
||||
|
||||
**Questions**: Goal (Create/Fix/Optimize/Analyze), Scope (Single file/Module/Cross-module/System), Constraints (Backward compat/Skip tests/Urgent hotfix)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Workflow & Build Command Chain
|
||||
|
||||
```javascript
|
||||
function selectWorkflow(analysis) {
|
||||
const levelMap = {
|
||||
'bugfix-hotfix': { level: 2, flow: 'bugfix.hotfix' },
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm': { level: 4, flow: 'brainstorm-with-file' }, // Multi-perspective ideation
|
||||
'brainstorm-to-issue': { level: 4, flow: 'brainstorm-to-issue' }, // Brainstorm → Issue workflow
|
||||
'debug-file': { level: 3, flow: 'debug-with-file' }, // Hypothesis-driven debugging
|
||||
'analyze-file': { level: 3, flow: 'analyze-with-file' }, // Collaborative analysis
|
||||
// Standard workflows
|
||||
'bugfix': { level: 2, flow: 'bugfix.standard' },
|
||||
'issue-batch': { level: 'Issue', flow: 'issue' },
|
||||
'issue-transition': { level: 2.5, flow: 'rapid-to-issue' }, // Bridge workflow
|
||||
'exploration': { level: 4, flow: 'full' },
|
||||
'quick-task': { level: 1, flow: 'lite-lite-lite' },
|
||||
'ui-design': { level: analysis.complexity === 'high' ? 4 : 3, flow: 'ui' },
|
||||
'tdd': { level: 3, flow: 'tdd' },
|
||||
'test-fix': { level: 3, flow: 'test-fix-gen' },
|
||||
'review': { level: 3, flow: 'review-cycle-fix' },
|
||||
'documentation': { level: 2, flow: 'docs' },
|
||||
'feature': { level: analysis.complexity === 'high' ? 3 : 2, flow: analysis.complexity === 'high' ? 'coupled' : 'rapid' }
|
||||
};
|
||||
|
||||
const selected = levelMap[analysis.task_type] || levelMap['feature'];
|
||||
return buildCommandChain(selected, analysis);
|
||||
}
|
||||
|
||||
// Build command chain (port-based matching with Minimum Execution Units)
|
||||
function buildCommandChain(workflow, analysis) {
|
||||
const chains = {
|
||||
// Level 1 - Rapid
|
||||
'lite-lite-lite': [
|
||||
{ cmd: '/workflow:lite-lite-lite', args: `"${analysis.goal}"` }
|
||||
],
|
||||
|
||||
// Level 2 - Lightweight
|
||||
'rapid': [
|
||||
// Unit: Quick Implementation【lite-plan → lite-execute】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'quick-impl' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
// Level 2 Bridge - Lightweight to Issue Workflow
|
||||
'rapid-to-issue': [
|
||||
// Unit: Quick Implementation【lite-plan → convert-to-plan】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl-to-issue' },
|
||||
{ cmd: '/issue:convert-to-plan', args: '--latest-lite-plan -y', unit: 'quick-impl-to-issue' },
|
||||
// Auto-continue to issue workflow
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '--queue auto' }
|
||||
],
|
||||
|
||||
'bugfix.standard': [
|
||||
// Unit: Bug Fix【lite-fix → lite-execute】
|
||||
{ cmd: '/workflow:lite-fix', args: `"${analysis.goal}"`, unit: 'bug-fix' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'bug-fix' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'bugfix.hotfix': [
|
||||
{ cmd: '/workflow:lite-fix', args: `--hotfix "${analysis.goal}"` }
|
||||
],
|
||||
|
||||
'multi-cli-plan': [
|
||||
// Unit: Multi-CLI Planning【multi-cli-plan → lite-execute】
|
||||
{ cmd: '/workflow:multi-cli-plan', args: `"${analysis.goal}"`, unit: 'multi-cli' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'multi-cli' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'docs': [
|
||||
// Unit: Quick Implementation【lite-plan → lite-execute】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'quick-impl' }
|
||||
],
|
||||
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm-with-file': [
|
||||
{ cmd: '/workflow:brainstorm-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Has built-in post-completion options (create plan, create issue, deep analysis)
|
||||
],
|
||||
|
||||
// Brainstorm-to-Issue workflow (bridge from brainstorm to issue execution)
|
||||
'brainstorm-to-issue': [
|
||||
// Note: Assumes brainstorm session already exists, or run brainstorm first
|
||||
{ cmd: '/issue:from-brainstorm', args: `SESSION="${extractBrainstormSession(analysis)}" --auto` },
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '--queue auto' }
|
||||
],
|
||||
|
||||
'debug-with-file': [
|
||||
{ cmd: '/workflow:debug-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Self-contained with hypothesis-driven iteration and Gemini validation
|
||||
],
|
||||
|
||||
'analyze-with-file': [
|
||||
{ cmd: '/workflow:analyze-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Self-contained with multi-round discussion and CLI exploration
|
||||
],
|
||||
|
||||
// Level 3 - Standard
|
||||
'coupled': [
|
||||
// Unit: Verified Planning【plan → plan-verify】
|
||||
{ cmd: '/workflow:plan', args: `"${analysis.goal}"`, unit: 'verified-planning' },
|
||||
{ cmd: '/workflow:plan-verify', args: '', unit: 'verified-planning' },
|
||||
// Execution
|
||||
{ cmd: '/workflow:execute', args: '' },
|
||||
// Unit: Code Review【review-session-cycle → review-cycle-fix】
|
||||
{ cmd: '/workflow:review-session-cycle', args: '', unit: 'code-review' },
|
||||
{ cmd: '/workflow:review-cycle-fix', args: '', unit: 'code-review' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'tdd': [
|
||||
// Unit: TDD Planning + Execution【tdd-plan → execute】
|
||||
{ cmd: '/workflow:tdd-plan', args: `"${analysis.goal}"`, unit: 'tdd-planning' },
|
||||
{ cmd: '/workflow:execute', args: '', unit: 'tdd-planning' },
|
||||
// TDD Verification
|
||||
{ cmd: '/workflow:tdd-verify', args: '' }
|
||||
],
|
||||
|
||||
'test-fix-gen': [
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: `"${analysis.goal}"`, unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
'review-cycle-fix': [
|
||||
// Unit: Code Review【review-session-cycle → review-cycle-fix】
|
||||
{ cmd: '/workflow:review-session-cycle', args: '', unit: 'code-review' },
|
||||
{ cmd: '/workflow:review-cycle-fix', args: '', unit: 'code-review' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
'ui': [
|
||||
{ cmd: '/workflow:ui-design:explore-auto', args: `"${analysis.goal}"` },
|
||||
// Unit: Planning + Execution【plan → execute】
|
||||
{ cmd: '/workflow:plan', args: '', unit: 'plan-execute' },
|
||||
{ cmd: '/workflow:execute', args: '', unit: 'plan-execute' }
|
||||
],
|
||||
|
||||
// Level 4 - Brainstorm
|
||||
'full': [
|
||||
{ cmd: '/workflow:brainstorm:auto-parallel', args: `"${analysis.goal}"` },
|
||||
// Unit: Verified Planning【plan → plan-verify】
|
||||
{ cmd: '/workflow:plan', args: '', unit: 'verified-planning' },
|
||||
{ cmd: '/workflow:plan-verify', args: '', unit: 'verified-planning' },
|
||||
// Execution
|
||||
{ cmd: '/workflow:execute', args: '' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
// Issue Workflow
|
||||
'issue': [
|
||||
{ cmd: '/issue:discover', args: '' },
|
||||
{ cmd: '/issue:plan', args: '--all-pending' },
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '' }
|
||||
]
|
||||
};
|
||||
|
||||
return chains[workflow.flow] || chains['rapid'];
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: `Level [X] - [flow] | Pipeline: [...] | Commands: [1. /cmd1 2. /cmd2 ...]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```javascript
|
||||
async function getUserConfirmation(chain) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Execute this command chain?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Confirm", description: "Start" },
|
||||
{ label: "Adjust", description: "Modify" },
|
||||
{ label: "Cancel", description: "Abort" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
if (response.error === "Cancel") throw new Error("Cancelled");
|
||||
if (response.error === "Adjust") return await adjustChain(chain);
|
||||
return chain;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking
|
||||
|
||||
```javascript
|
||||
function setupTodoTracking(chain, workflow) {
|
||||
const todos = chain.map((step, i) => ({
|
||||
content: `CCW:${workflow}: [${i + 1}/${chain.length}] ${step.cmd}`,
|
||||
status: i === 0 ? 'in_progress' : 'pending',
|
||||
activeForm: `Executing ${step.cmd}`
|
||||
}));
|
||||
TodoWrite({ todos });
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: `-> CCW:rapid: [1/3] /workflow:lite-plan | CCW:rapid: [2/3] /workflow:lite-execute | ...`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Command Chain
|
||||
|
||||
```javascript
|
||||
async function executeCommandChain(chain, workflow) {
|
||||
let previousResult = null;
|
||||
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
try {
|
||||
const fullCommand = assembleCommand(chain[i], previousResult);
|
||||
const result = await SlashCommand({ command: fullCommand });
|
||||
|
||||
previousResult = { ...result, success: true };
|
||||
updateTodoStatus(i, chain.length, workflow, 'completed');
|
||||
|
||||
} catch (error) {
|
||||
const action = await handleError(chain[i], error, i);
|
||||
if (action === 'retry') {
|
||||
i--; // Retry
|
||||
} else if (action === 'abort') {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
// 'skip' - continue
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true, completed: chain.length };
|
||||
}
|
||||
|
||||
// Assemble full command with session/plan parameters
|
||||
function assembleCommand(step, previousResult) {
|
||||
let command = step.cmd;
|
||||
if (step.args) {
|
||||
command += ` ${step.args}`;
|
||||
} else if (previousResult?.session_id) {
|
||||
command += ` --session="${previousResult.session_id}"`;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
// Update TODO: mark current as complete, next as in-progress
|
||||
function updateTodoStatus(index, total, workflow, status) {
|
||||
const todos = getAllCurrentTodos();
|
||||
const updated = todos.map(todo => {
|
||||
if (todo.content.startsWith(`CCW:${workflow}:`)) {
|
||||
const stepNum = extractStepIndex(todo.content);
|
||||
if (stepNum === index + 1) return { ...todo, status };
|
||||
if (stepNum === index + 2 && status === 'completed') return { ...todo, status: 'in_progress' };
|
||||
}
|
||||
return todo;
|
||||
});
|
||||
TodoWrite({ todos: updated });
|
||||
}
|
||||
|
||||
// Error handling: Retry/Skip/Abort
|
||||
async function handleError(step, error, index) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `${step.cmd} failed: ${error.message}`,
|
||||
header: "Error",
|
||||
options: [
|
||||
{ label: "Retry", description: "Re-execute" },
|
||||
{ label: "Skip", description: "Continue next" },
|
||||
{ label: "Abort", description: "Stop" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
return { Retry: 'retry', Skip: 'skip', Abort: 'abort' }[response.Error] || 'abort';
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Summary
|
||||
|
||||
```
|
||||
User Input
|
||||
|
|
||||
Phase 1: Analyze Intent
|
||||
|-- Extract: goal, scope, constraints, task_type, complexity, clarity
|
||||
+-- If clarity < 2 -> Phase 1.5: Clarify Requirements
|
||||
|
|
||||
Phase 2: Select Workflow & Build Chain
|
||||
|-- Map task_type -> Level (1/2/3/4/Issue)
|
||||
|-- Select flow based on complexity
|
||||
+-- Build command chain (port-based)
|
||||
|
|
||||
Phase 3: User Confirmation (optional)
|
||||
|-- Show pipeline visualization
|
||||
+-- Allow adjustment
|
||||
|
|
||||
Phase 4: Setup TODO Tracking
|
||||
+-- Create todos with CCW prefix
|
||||
|
|
||||
Phase 5: Execute Command Chain
|
||||
|-- For each command:
|
||||
| |-- Assemble full command
|
||||
| |-- Execute via SlashCommand
|
||||
| |-- Update TODO status
|
||||
| +-- Handle errors (retry/skip/abort)
|
||||
+-- Return workflow result
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pipeline Examples (with Minimum Execution Units)
|
||||
|
||||
**Note**: `【 】` marks Minimum Execution Units - commands execute together as atomic groups.
|
||||
|
||||
| Input | Type | Level | Pipeline (with Units) |
|
||||
|-------|------|-------|-----------------------|
|
||||
| "Add API endpoint" | feature (low) | 2 |【lite-plan → lite-execute】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Fix login timeout" | bugfix | 2 |【lite-fix → lite-execute】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Use issue workflow" | issue-transition | 2.5 |【lite-plan → convert-to-plan】→ queue → execute |
|
||||
| "头脑风暴: 通知系统重构" | brainstorm | 4 | brainstorm-with-file → (built-in post-completion) |
|
||||
| "从头脑风暴创建 issue" | brainstorm-to-issue | 4 | from-brainstorm → queue → execute |
|
||||
| "深度调试 WebSocket 连接断开" | debug-file | 3 | debug-with-file → (hypothesis iteration) |
|
||||
| "协作分析: 认证架构优化" | analyze-file | 3 | analyze-with-file → (multi-round discussion) |
|
||||
| "OAuth2 system" | feature (high) | 3 |【plan → plan-verify】→ execute →【review-session-cycle → review-cycle-fix】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Implement with TDD" | tdd | 3 |【tdd-plan → execute】→ tdd-verify |
|
||||
| "Uncertain: real-time arch" | exploration | 4 | brainstorm:auto-parallel →【plan → plan-verify】→ execute →【test-fix-gen → test-cycle-execute】|
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Main Process Execution** - Use SlashCommand in main process, no external CLI
|
||||
2. **Intent-Driven** - Auto-select workflow based on task intent
|
||||
3. **Port-Based Chaining** - Build command chain using port matching
|
||||
4. **Minimum Execution Units** - Commands grouped into atomic units, never split (e.g., lite-plan → lite-execute)
|
||||
5. **Progressive Clarification** - Low clarity triggers clarification phase
|
||||
6. **TODO Tracking** - Use CCW prefix to isolate workflow todos
|
||||
7. **Unit-Aware Error Handling** - Retry/skip/abort affects whole unit, not individual commands
|
||||
8. **User Control** - Optional user confirmation at each phase
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
**TodoWrite-Based Tracking**: All execution state tracked via TodoWrite with `CCW:` prefix.
|
||||
|
||||
```javascript
|
||||
// Initial state
|
||||
todos = [
|
||||
{ content: "CCW:rapid: [1/3] /workflow:lite-plan", status: "in_progress" },
|
||||
{ content: "CCW:rapid: [2/3] /workflow:lite-execute", status: "pending" },
|
||||
{ content: "CCW:rapid: [3/3] /workflow:test-cycle-execute", status: "pending" }
|
||||
];
|
||||
|
||||
// After command 1 completes
|
||||
todos = [
|
||||
{ content: "CCW:rapid: [1/3] /workflow:lite-plan", status: "completed" },
|
||||
{ content: "CCW:rapid: [2/3] /workflow:lite-execute", status: "in_progress" },
|
||||
{ content: "CCW:rapid: [3/3] /workflow:test-cycle-execute", status: "pending" }
|
||||
];
|
||||
```
|
||||
|
||||
**vs ccw-coordinator**: Extensive state.json with task_id, status transitions, hook callbacks.
|
||||
|
||||
---
|
||||
|
||||
## With-File Workflows
|
||||
|
||||
**With-File workflows** provide documented exploration with multi-CLI collaboration. They are self-contained and generate comprehensive session artifacts.
|
||||
|
||||
| Workflow | Purpose | Key Features | Output Folder |
|
||||
|----------|---------|--------------|---------------|
|
||||
| **brainstorm-with-file** | Multi-perspective ideation | Gemini/Codex/Claude perspectives, diverge-converge cycles | `.workflow/.brainstorm/` |
|
||||
| **debug-with-file** | Hypothesis-driven debugging | Gemini validation, understanding evolution, NDJSON logging | `.workflow/.debug/` |
|
||||
| **analyze-with-file** | Collaborative analysis | Multi-round Q&A, CLI exploration, documented discussions | `.workflow/.analysis/` |
|
||||
|
||||
**Detection Keywords**:
|
||||
- **brainstorm**: 头脑风暴, 创意, 发散思维, multi-perspective, compare perspectives
|
||||
- **debug-file**: 深度调试, 假设验证, systematic debug, hypothesis debug
|
||||
- **analyze-file**: 协作分析, 深度理解, collaborative analysis, explore concept
|
||||
|
||||
**Characteristics**:
|
||||
1. **Self-Contained**: Each workflow handles its own iteration loop
|
||||
2. **Documented Process**: Creates evolving documents (brainstorm.md, understanding.md, discussion.md)
|
||||
3. **Multi-CLI**: Uses Gemini/Codex/Claude for different perspectives
|
||||
4. **Built-in Post-Completion**: Offers follow-up options (create plan, issue, etc.)
|
||||
|
||||
---
|
||||
|
||||
## Type Comparison: ccw vs ccw-coordinator
|
||||
|
||||
| Aspect | ccw | ccw-coordinator |
|
||||
|--------|-----|-----------------|
|
||||
| **Type** | Main process (SlashCommand) | External CLI (ccw cli + hook callbacks) |
|
||||
| **Execution** | Synchronous blocking | Async background with hook completion |
|
||||
| **Workflow** | Auto intent-based selection | Manual chain building |
|
||||
| **Intent Analysis** | 5-phase clarity check | 3-phase requirement analysis |
|
||||
| **State** | TodoWrite only (in-memory) | state.json + checkpoint/resume |
|
||||
| **Error Handling** | Retry/skip/abort (interactive) | Retry/skip/abort (via AskUser) |
|
||||
| **Use Case** | Auto workflow for any task | Manual orchestration, large chains |
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select workflow
|
||||
ccw "Add user authentication"
|
||||
|
||||
# Complex requirement (triggers clarification)
|
||||
ccw "Optimize system performance"
|
||||
|
||||
# Bug fix
|
||||
ccw "Fix memory leak in WebSocket handler"
|
||||
|
||||
# TDD development
|
||||
ccw "Implement user registration with TDD"
|
||||
|
||||
# Exploratory task
|
||||
ccw "Uncertain about architecture for real-time notifications"
|
||||
|
||||
# With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file
|
||||
ccw "从头脑风暴 BS-通知系统-2025-01-28 创建 issue" # → brainstorm-to-issue (bridge)
|
||||
ccw "深度调试: 系统随机崩溃问题" # → debug-with-file
|
||||
ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file
|
||||
```
|
||||
@@ -3,6 +3,7 @@ name: cli-init
|
||||
description: Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection
|
||||
argument-hint: "[--tool gemini|qwen|all] [--output path] [--preview]"
|
||||
allowed-tools: Bash(*), Read(*), Write(*), Glob(*)
|
||||
group: cli
|
||||
---
|
||||
|
||||
# CLI Initialization Command (/cli:cli-init)
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
---
|
||||
name: enhance-prompt
|
||||
description: Enhanced prompt transformation using session memory and intent analysis with --enhance flag detection
|
||||
argument-hint: "user input to enhance"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Systematically enhances user prompts by leveraging session memory context and intent analysis, translating ambiguous requests into actionable specifications.
|
||||
|
||||
## Core Protocol
|
||||
|
||||
**Enhancement Pipeline:**
|
||||
`Intent Translation` → `Context Integration` → `Structured Output`
|
||||
|
||||
**Context Sources:**
|
||||
- Session memory (conversation history, previous analysis)
|
||||
- Implicit technical requirements
|
||||
- User intent patterns
|
||||
|
||||
## Enhancement Rules
|
||||
|
||||
### Intent Translation
|
||||
|
||||
| User Says | Translate To | Focus |
|
||||
|-----------|--------------|-------|
|
||||
| "fix" | Debug and resolve | Root cause → preserve behavior |
|
||||
| "improve" | Enhance/optimize | Performance/readability |
|
||||
| "add" | Implement feature | Integration + edge cases |
|
||||
| "refactor" | Restructure quality | Maintain behavior |
|
||||
| "update" | Modernize | Version compatibility |
|
||||
|
||||
### Context Integration Strategy
|
||||
|
||||
**Session Memory:**
|
||||
- Reference recent conversation context
|
||||
- Reuse previously identified patterns
|
||||
- Build on established understanding
|
||||
- Infer technical requirements from discussion
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
# User: "add login"
|
||||
# Session Memory: Previous auth discussion, JWT mentioned
|
||||
# Inferred: JWT-based auth, integrate with existing session management
|
||||
# Action: Implement JWT authentication with session persistence
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```bash
|
||||
INTENT: [Clear technical goal]
|
||||
CONTEXT: [Session memory + codebase patterns]
|
||||
ACTION: [Specific implementation steps]
|
||||
ATTENTION: [Critical constraints]
|
||||
```
|
||||
|
||||
### Output Examples
|
||||
|
||||
**Example 1:**
|
||||
```bash
|
||||
# Input: "fix login button"
|
||||
INTENT: Debug non-functional login button
|
||||
CONTEXT: From session - OAuth flow discussed, known state issue
|
||||
ACTION: Check event binding → verify state updates → test auth flow
|
||||
ATTENTION: Preserve existing OAuth integration
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
```bash
|
||||
# Input: "refactor payment code"
|
||||
INTENT: Restructure payment module for maintainability
|
||||
CONTEXT: Session memory - PCI compliance requirements, Stripe integration patterns
|
||||
ACTION: Extract reusable validators → isolate payment gateway logic → maintain adapter pattern
|
||||
ATTENTION: Zero behavior change, maintain PCI compliance, full test coverage
|
||||
```
|
||||
|
||||
## Enhancement Triggers
|
||||
|
||||
- Ambiguous language: "fix", "improve", "clean up"
|
||||
- Vague requests requiring clarification
|
||||
- Complex technical requirements
|
||||
- Architecture changes
|
||||
- Critical systems: auth, payment, security
|
||||
- Multi-step refactoring
|
||||
|
||||
## Key Principles
|
||||
|
||||
1. **Session Memory First**: Leverage conversation context and established understanding
|
||||
2. **Context Reuse**: Build on previous discussions and decisions
|
||||
3. **Clear Output**: Structured, actionable specifications
|
||||
4. **Intent Clarification**: Transform vague requests into specific technical goals
|
||||
5. **Avoid Duplication**: Reference existing context, don't repeat
|
||||
718
.claude/commands/issue/convert-to-plan.md
Normal file
718
.claude/commands/issue/convert-to-plan.md
Normal file
@@ -0,0 +1,718 @@
|
||||
---
|
||||
name: convert-to-plan
|
||||
description: Convert planning artifacts (lite-plan, workflow session, markdown) to issue solutions
|
||||
argument-hint: "[-y|--yes] [--issue <id>] [--supplement] <SOURCE>"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Skip confirmation, auto-create issue and bind solution.
|
||||
|
||||
# Issue Convert-to-Plan Command (/issue:convert-to-plan)
|
||||
|
||||
## Overview
|
||||
|
||||
Converts various planning artifact formats into issue workflow solutions with intelligent detection and automatic binding.
|
||||
|
||||
**Supported Sources** (auto-detected):
|
||||
- **lite-plan**: `.workflow/.lite-plan/{slug}/plan.json`
|
||||
- **workflow-session**: `WFS-xxx` ID or `.workflow/active/{session}/` folder
|
||||
- **markdown**: Any `.md` file with implementation/task content
|
||||
- **json**: Direct JSON files matching plan-json-schema
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Convert lite-plan to new issue (auto-creates issue)
|
||||
/issue:convert-to-plan ".workflow/.lite-plan/implement-auth-2026-01-25"
|
||||
|
||||
# Convert workflow session to existing issue
|
||||
/issue:convert-to-plan WFS-auth-impl --issue GH-123
|
||||
|
||||
# Supplement existing solution with additional tasks
|
||||
/issue:convert-to-plan "./docs/additional-tasks.md" --issue ISS-001 --supplement
|
||||
|
||||
# Auto mode - skip confirmations
|
||||
/issue:convert-to-plan ".workflow/.lite-plan/my-plan" -y
|
||||
```
|
||||
|
||||
## Command Options
|
||||
|
||||
| Option | Description | Default |
|
||||
|--------|-------------|---------|
|
||||
| `<SOURCE>` | Planning artifact path or WFS-xxx ID | Required |
|
||||
| `--issue <id>` | Bind to existing issue instead of creating new | Auto-create |
|
||||
| `--supplement` | Add tasks to existing solution (requires --issue) | false |
|
||||
| `-y, --yes` | Skip all confirmations | false |
|
||||
|
||||
## Core Data Access Principle
|
||||
|
||||
**⚠️ Important**: Use CLI commands for all issue/solution operations.
|
||||
|
||||
| Operation | Correct | Incorrect |
|
||||
|-----------|---------|-----------|
|
||||
| Get issue | `ccw issue status <id> --json` | Read issues.jsonl directly |
|
||||
| Create issue | `ccw issue init <id> --title "..."` | Write to issues.jsonl |
|
||||
| Bind solution | `ccw issue bind <id> <sol-id>` | Edit issues.jsonl |
|
||||
| List solutions | `ccw issue solutions --issue <id> --brief` | Read solutions/*.jsonl |
|
||||
|
||||
## Solution Schema Reference
|
||||
|
||||
Target format for all extracted data (from solution-schema.json):
|
||||
|
||||
```typescript
|
||||
interface Solution {
|
||||
id: string; // SOL-{issue-id}-{4-char-uid}
|
||||
description?: string; // High-level summary
|
||||
approach?: string; // Technical strategy
|
||||
tasks: Task[]; // Required: at least 1 task
|
||||
exploration_context?: object; // Optional: source context
|
||||
analysis?: { risk, impact, complexity };
|
||||
score?: number; // 0.0-1.0
|
||||
is_bound: boolean;
|
||||
created_at: string;
|
||||
bound_at?: string;
|
||||
}
|
||||
|
||||
interface Task {
|
||||
id: string; // T1, T2, T3... (pattern: ^T[0-9]+$)
|
||||
title: string; // Required: action verb + target
|
||||
scope: string; // Required: module path or feature area
|
||||
action: Action; // Required: Create|Update|Implement|...
|
||||
description?: string;
|
||||
modification_points?: Array<{file, target, change}>;
|
||||
implementation: string[]; // Required: step-by-step guide
|
||||
test?: { unit?, integration?, commands?, coverage_target? };
|
||||
acceptance: { criteria: string[], verification: string[] }; // Required
|
||||
commit?: { type, scope, message_template, breaking? };
|
||||
depends_on?: string[];
|
||||
priority?: number; // 1-5 (default: 3)
|
||||
}
|
||||
|
||||
type Action = 'Create' | 'Update' | 'Implement' | 'Refactor' | 'Add' | 'Delete' | 'Configure' | 'Test' | 'Fix';
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Parse Arguments & Detect Source Type
|
||||
|
||||
```javascript
|
||||
const input = userInput.trim();
|
||||
const flags = parseFlags(userInput); // --issue, --supplement, -y/--yes
|
||||
|
||||
// Extract source path (first non-flag argument)
|
||||
const source = extractSourceArg(input);
|
||||
|
||||
// Detect source type
|
||||
function detectSourceType(source) {
|
||||
// Check for WFS-xxx pattern (workflow session ID)
|
||||
if (source.match(/^WFS-[\w-]+$/)) {
|
||||
return { type: 'workflow-session-id', path: `.workflow/active/${source}` };
|
||||
}
|
||||
|
||||
// Check if directory
|
||||
const isDir = Bash(`test -d "${source}" && echo "dir" || echo "file"`).trim() === 'dir';
|
||||
|
||||
if (isDir) {
|
||||
// Check for lite-plan indicator
|
||||
const hasPlanJson = Bash(`test -f "${source}/plan.json" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasPlanJson) {
|
||||
return { type: 'lite-plan', path: source };
|
||||
}
|
||||
|
||||
// Check for workflow session indicator
|
||||
const hasSession = Bash(`test -f "${source}/workflow-session.json" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasSession) {
|
||||
return { type: 'workflow-session', path: source };
|
||||
}
|
||||
}
|
||||
|
||||
// Check file extensions
|
||||
if (source.endsWith('.json')) {
|
||||
return { type: 'json-file', path: source };
|
||||
}
|
||||
if (source.endsWith('.md')) {
|
||||
return { type: 'markdown-file', path: source };
|
||||
}
|
||||
|
||||
// Check if path exists at all
|
||||
const exists = Bash(`test -e "${source}" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (!exists) {
|
||||
throw new Error(`E001: Source not found: ${source}`);
|
||||
}
|
||||
|
||||
return { type: 'unknown', path: source };
|
||||
}
|
||||
|
||||
const sourceInfo = detectSourceType(source);
|
||||
if (sourceInfo.type === 'unknown') {
|
||||
throw new Error(`E002: Unable to detect source format for: ${source}`);
|
||||
}
|
||||
|
||||
console.log(`Detected source type: ${sourceInfo.type}`);
|
||||
```
|
||||
|
||||
### Phase 2: Extract Data Using Format-Specific Extractor
|
||||
|
||||
```javascript
|
||||
let extracted = { title: '', approach: '', tasks: [], metadata: {} };
|
||||
|
||||
switch (sourceInfo.type) {
|
||||
case 'lite-plan':
|
||||
extracted = extractFromLitePlan(sourceInfo.path);
|
||||
break;
|
||||
case 'workflow-session':
|
||||
case 'workflow-session-id':
|
||||
extracted = extractFromWorkflowSession(sourceInfo.path);
|
||||
break;
|
||||
case 'markdown-file':
|
||||
extracted = await extractFromMarkdownAI(sourceInfo.path);
|
||||
break;
|
||||
case 'json-file':
|
||||
extracted = extractFromJsonFile(sourceInfo.path);
|
||||
break;
|
||||
}
|
||||
|
||||
// Validate extraction
|
||||
if (!extracted.tasks || extracted.tasks.length === 0) {
|
||||
throw new Error('E006: No tasks extracted from source');
|
||||
}
|
||||
|
||||
// Ensure task IDs are normalized to T1, T2, T3...
|
||||
extracted.tasks = normalizeTaskIds(extracted.tasks);
|
||||
|
||||
console.log(`Extracted: ${extracted.tasks.length} tasks`);
|
||||
```
|
||||
|
||||
#### Extractor: Lite-Plan
|
||||
|
||||
```javascript
|
||||
function extractFromLitePlan(folderPath) {
|
||||
const planJson = Read(`${folderPath}/plan.json`);
|
||||
const plan = JSON.parse(planJson);
|
||||
|
||||
return {
|
||||
title: plan.summary?.split('.')[0]?.trim() || 'Untitled Plan',
|
||||
description: plan.summary,
|
||||
approach: plan.approach,
|
||||
tasks: plan.tasks.map(t => ({
|
||||
id: t.id,
|
||||
title: t.title,
|
||||
scope: t.scope || '',
|
||||
action: t.action || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.verification ? {
|
||||
unit: t.verification.unit_tests,
|
||||
integration: t.verification.integration_tests,
|
||||
commands: t.verification.manual_checks
|
||||
} : {},
|
||||
acceptance: {
|
||||
criteria: Array.isArray(t.acceptance) ? t.acceptance : [t.acceptance || ''],
|
||||
verification: t.verification?.manual_checks || []
|
||||
},
|
||||
depends_on: t.depends_on || [],
|
||||
priority: 3
|
||||
})),
|
||||
metadata: {
|
||||
source_type: 'lite-plan',
|
||||
source_path: folderPath,
|
||||
complexity: plan.complexity,
|
||||
estimated_time: plan.estimated_time,
|
||||
exploration_angles: plan._metadata?.exploration_angles || [],
|
||||
original_timestamp: plan._metadata?.timestamp
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: Workflow Session
|
||||
|
||||
```javascript
|
||||
function extractFromWorkflowSession(sessionPath) {
|
||||
// Load session metadata
|
||||
const sessionJson = Read(`${sessionPath}/workflow-session.json`);
|
||||
const session = JSON.parse(sessionJson);
|
||||
|
||||
// Load IMPL_PLAN.md for approach (if exists)
|
||||
let approach = '';
|
||||
const implPlanPath = `${sessionPath}/IMPL_PLAN.md`;
|
||||
const hasImplPlan = Bash(`test -f "${implPlanPath}" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasImplPlan) {
|
||||
const implPlan = Read(implPlanPath);
|
||||
// Extract overview/approach section
|
||||
const overviewMatch = implPlan.match(/##\s*(?:Overview|Approach|Strategy)\s*\n([\s\S]*?)(?=\n##|$)/i);
|
||||
approach = overviewMatch?.[1]?.trim() || implPlan.split('\n').slice(0, 10).join('\n');
|
||||
}
|
||||
|
||||
// Load all task JSONs from .task folder
|
||||
const taskFiles = Glob({ pattern: `${sessionPath}/.task/IMPL-*.json` });
|
||||
const tasks = taskFiles.map(f => {
|
||||
const taskJson = Read(f);
|
||||
const task = JSON.parse(taskJson);
|
||||
return {
|
||||
id: task.id?.replace(/^IMPL-0*/, 'T') || 'T1', // IMPL-001 → T1
|
||||
title: task.title,
|
||||
scope: task.scope || inferScopeFromTask(task),
|
||||
action: capitalizeAction(task.type) || 'Implement',
|
||||
description: task.description,
|
||||
modification_points: task.implementation?.modification_points || [],
|
||||
implementation: task.implementation?.steps || [],
|
||||
test: task.implementation?.test || {},
|
||||
acceptance: {
|
||||
criteria: task.acceptance_criteria || [],
|
||||
verification: task.verification_steps || []
|
||||
},
|
||||
commit: task.commit,
|
||||
depends_on: (task.depends_on || []).map(d => d.replace(/^IMPL-0*/, 'T')),
|
||||
priority: task.priority || 3
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title: session.name || session.description?.split('.')[0] || 'Workflow Session',
|
||||
description: session.description || session.name,
|
||||
approach: approach || session.description,
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'workflow-session',
|
||||
source_path: sessionPath,
|
||||
session_id: session.id,
|
||||
created_at: session.created_at
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function inferScopeFromTask(task) {
|
||||
if (task.implementation?.modification_points?.length) {
|
||||
const files = task.implementation.modification_points.map(m => m.file);
|
||||
// Find common directory prefix
|
||||
const dirs = files.map(f => f.split('/').slice(0, -1).join('/'));
|
||||
return [...new Set(dirs)][0] || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function capitalizeAction(type) {
|
||||
if (!type) return 'Implement';
|
||||
const map = { feature: 'Implement', bugfix: 'Fix', refactor: 'Refactor', test: 'Test', docs: 'Update' };
|
||||
return map[type.toLowerCase()] || type.charAt(0).toUpperCase() + type.slice(1);
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: Markdown (AI-Assisted via Gemini)
|
||||
|
||||
```javascript
|
||||
async function extractFromMarkdownAI(filePath) {
|
||||
const fileContent = Read(filePath);
|
||||
|
||||
// Use Gemini CLI for intelligent extraction
|
||||
const cliPrompt = `PURPOSE: Extract implementation plan from markdown document for issue solution conversion. Must output ONLY valid JSON.
|
||||
TASK: • Analyze document structure • Identify title/summary • Extract approach/strategy section • Parse tasks from any format (lists, tables, sections, code blocks) • Normalize each task to solution schema
|
||||
MODE: analysis
|
||||
CONTEXT: Document content provided below
|
||||
EXPECTED: Valid JSON object with format:
|
||||
{
|
||||
"title": "extracted title",
|
||||
"approach": "extracted approach/strategy",
|
||||
"tasks": [
|
||||
{
|
||||
"id": "T1",
|
||||
"title": "task title",
|
||||
"scope": "module or feature area",
|
||||
"action": "Implement|Update|Create|Fix|Refactor|Add|Delete|Configure|Test",
|
||||
"description": "what to do",
|
||||
"implementation": ["step 1", "step 2"],
|
||||
"acceptance": ["criteria 1", "criteria 2"]
|
||||
}
|
||||
]
|
||||
}
|
||||
CONSTRAINTS: Output ONLY valid JSON - no markdown, no explanation | Action must be one of: Create, Update, Implement, Refactor, Add, Delete, Configure, Test, Fix | Tasks must have id, title, scope, action, implementation (array), acceptance (array)
|
||||
|
||||
DOCUMENT CONTENT:
|
||||
${fileContent}`;
|
||||
|
||||
// Execute Gemini CLI
|
||||
const result = Bash(`ccw cli -p '${cliPrompt.replace(/'/g, "'\\''")}' --tool gemini --mode analysis`, { timeout: 120000 });
|
||||
|
||||
// Parse JSON from result (may be wrapped in markdown code block)
|
||||
let jsonText = result.trim();
|
||||
const jsonMatch = jsonText.match(/```(?:json)?\s*([\s\S]*?)```/);
|
||||
if (jsonMatch) {
|
||||
jsonText = jsonMatch[1].trim();
|
||||
}
|
||||
|
||||
try {
|
||||
const extracted = JSON.parse(jsonText);
|
||||
|
||||
// Normalize tasks
|
||||
const tasks = (extracted.tasks || []).map((t, i) => ({
|
||||
id: t.id || `T${i + 1}`,
|
||||
title: t.title || 'Untitled task',
|
||||
scope: t.scope || '',
|
||||
action: validateAction(t.action) || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.test || {},
|
||||
acceptance: {
|
||||
criteria: Array.isArray(t.acceptance) ? t.acceptance : [t.acceptance || ''],
|
||||
verification: t.verification || []
|
||||
},
|
||||
depends_on: t.depends_on || [],
|
||||
priority: t.priority || 3
|
||||
}));
|
||||
|
||||
return {
|
||||
title: extracted.title || 'Extracted Plan',
|
||||
description: extracted.summary || extracted.title,
|
||||
approach: extracted.approach || '',
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'markdown',
|
||||
source_path: filePath,
|
||||
extraction_method: 'gemini-ai'
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
// Provide more context for debugging
|
||||
throw new Error(`E005: Failed to extract tasks from markdown. Gemini response was not valid JSON. Error: ${e.message}. Response preview: ${jsonText.substring(0, 200)}...`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateAction(action) {
|
||||
const validActions = ['Create', 'Update', 'Implement', 'Refactor', 'Add', 'Delete', 'Configure', 'Test', 'Fix'];
|
||||
if (!action) return null;
|
||||
const normalized = action.charAt(0).toUpperCase() + action.slice(1).toLowerCase();
|
||||
return validActions.includes(normalized) ? normalized : null;
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: JSON File
|
||||
|
||||
```javascript
|
||||
function extractFromJsonFile(filePath) {
|
||||
const content = Read(filePath);
|
||||
const plan = JSON.parse(content);
|
||||
|
||||
// Detect if it's already solution format or plan format
|
||||
if (plan.tasks && Array.isArray(plan.tasks)) {
|
||||
// Map tasks to normalized format
|
||||
const tasks = plan.tasks.map((t, i) => ({
|
||||
id: t.id || `T${i + 1}`,
|
||||
title: t.title,
|
||||
scope: t.scope || '',
|
||||
action: t.action || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.test || t.verification || {},
|
||||
acceptance: normalizeAcceptance(t.acceptance),
|
||||
depends_on: t.depends_on || [],
|
||||
priority: t.priority || 3
|
||||
}));
|
||||
|
||||
return {
|
||||
title: plan.summary?.split('.')[0] || plan.title || 'JSON Plan',
|
||||
description: plan.summary || plan.description,
|
||||
approach: plan.approach,
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'json',
|
||||
source_path: filePath,
|
||||
complexity: plan.complexity,
|
||||
original_metadata: plan._metadata
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error('E002: JSON file does not contain valid plan structure (missing tasks array)');
|
||||
}
|
||||
|
||||
function normalizeAcceptance(acceptance) {
|
||||
if (!acceptance) return { criteria: [], verification: [] };
|
||||
if (typeof acceptance === 'object' && acceptance.criteria) return acceptance;
|
||||
if (Array.isArray(acceptance)) return { criteria: acceptance, verification: [] };
|
||||
return { criteria: [String(acceptance)], verification: [] };
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Normalize Task IDs
|
||||
|
||||
```javascript
|
||||
function normalizeTaskIds(tasks) {
|
||||
return tasks.map((t, i) => ({
|
||||
...t,
|
||||
id: `T${i + 1}`,
|
||||
// Also normalize depends_on references
|
||||
depends_on: (t.depends_on || []).map(d => {
|
||||
// Handle various ID formats: IMPL-001, T1, 1, etc.
|
||||
const num = d.match(/\d+/)?.[0];
|
||||
return num ? `T${parseInt(num)}` : d;
|
||||
})
|
||||
}));
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Resolve Issue (Create or Find)
|
||||
|
||||
```javascript
|
||||
let issueId = flags.issue;
|
||||
let existingSolution = null;
|
||||
|
||||
if (issueId) {
|
||||
// Validate issue exists
|
||||
let issueCheck;
|
||||
try {
|
||||
issueCheck = Bash(`ccw issue status ${issueId} --json 2>/dev/null`).trim();
|
||||
if (!issueCheck || issueCheck === '') {
|
||||
throw new Error('empty response');
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`E003: Issue not found: ${issueId}`);
|
||||
}
|
||||
|
||||
const issue = JSON.parse(issueCheck);
|
||||
|
||||
// Check if issue already has bound solution
|
||||
if (issue.bound_solution_id && !flags.supplement) {
|
||||
throw new Error(`E004: Issue ${issueId} already has bound solution (${issue.bound_solution_id}). Use --supplement to add tasks.`);
|
||||
}
|
||||
|
||||
// Load existing solution for supplement mode
|
||||
if (flags.supplement && issue.bound_solution_id) {
|
||||
try {
|
||||
const solResult = Bash(`ccw issue solution ${issue.bound_solution_id} --json`).trim();
|
||||
existingSolution = JSON.parse(solResult);
|
||||
console.log(`Loaded existing solution with ${existingSolution.tasks.length} tasks`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to load existing solution: ${e.message}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create new issue via ccw issue create (auto-generates correct ID)
|
||||
// Smart extraction: title from content, priority from complexity
|
||||
const title = extracted.title || 'Converted Plan';
|
||||
const context = extracted.description || extracted.approach || title;
|
||||
|
||||
// Auto-determine priority based on complexity
|
||||
const complexityMap = { high: 2, medium: 3, low: 4 };
|
||||
const priority = complexityMap[extracted.metadata.complexity?.toLowerCase()] || 3;
|
||||
|
||||
try {
|
||||
// Use heredoc to avoid shell escaping issues
|
||||
const createResult = Bash(`ccw issue create << 'EOF'
|
||||
{
|
||||
"title": ${JSON.stringify(title)},
|
||||
"context": ${JSON.stringify(context)},
|
||||
"priority": ${priority},
|
||||
"source": "converted"
|
||||
}
|
||||
EOF`).trim();
|
||||
|
||||
// Parse result to get created issue ID
|
||||
const created = JSON.parse(createResult);
|
||||
issueId = created.id;
|
||||
console.log(`Created issue: ${issueId} (priority: ${priority})`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to create issue: ${e.message}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 5: Generate Solution
|
||||
|
||||
```javascript
|
||||
// Generate solution ID
|
||||
function generateSolutionId(issueId) {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let uid = '';
|
||||
for (let i = 0; i < 4; i++) {
|
||||
uid += chars[Math.floor(Math.random() * chars.length)];
|
||||
}
|
||||
return `SOL-${issueId}-${uid}`;
|
||||
}
|
||||
|
||||
let solution;
|
||||
const solutionId = generateSolutionId(issueId);
|
||||
|
||||
if (flags.supplement && existingSolution) {
|
||||
// Supplement mode: merge with existing solution
|
||||
const maxTaskId = Math.max(...existingSolution.tasks.map(t => parseInt(t.id.slice(1))));
|
||||
|
||||
const newTasks = extracted.tasks.map((t, i) => ({
|
||||
...t,
|
||||
id: `T${maxTaskId + i + 1}`
|
||||
}));
|
||||
|
||||
solution = {
|
||||
...existingSolution,
|
||||
tasks: [...existingSolution.tasks, ...newTasks],
|
||||
approach: existingSolution.approach + '\n\n[Supplementary] ' + (extracted.approach || ''),
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
|
||||
console.log(`Supplementing: ${existingSolution.tasks.length} existing + ${newTasks.length} new = ${solution.tasks.length} total tasks`);
|
||||
} else {
|
||||
// New solution
|
||||
solution = {
|
||||
id: solutionId,
|
||||
description: extracted.description || extracted.title,
|
||||
approach: extracted.approach,
|
||||
tasks: extracted.tasks,
|
||||
exploration_context: extracted.metadata.exploration_angles ? {
|
||||
exploration_angles: extracted.metadata.exploration_angles
|
||||
} : undefined,
|
||||
analysis: {
|
||||
risk: 'medium',
|
||||
impact: 'medium',
|
||||
complexity: extracted.metadata.complexity?.toLowerCase() || 'medium'
|
||||
},
|
||||
is_bound: false,
|
||||
created_at: new Date().toISOString(),
|
||||
_conversion_metadata: {
|
||||
source_type: extracted.metadata.source_type,
|
||||
source_path: extracted.metadata.source_path,
|
||||
converted_at: new Date().toISOString()
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 6: Confirm & Persist
|
||||
|
||||
```javascript
|
||||
// Display preview
|
||||
console.log(`
|
||||
## Conversion Summary
|
||||
|
||||
**Issue**: ${issueId}
|
||||
**Solution**: ${flags.supplement ? existingSolution.id : solutionId}
|
||||
**Tasks**: ${solution.tasks.length}
|
||||
**Mode**: ${flags.supplement ? 'Supplement' : 'New'}
|
||||
|
||||
### Tasks:
|
||||
${solution.tasks.map(t => `- ${t.id}: ${t.title} [${t.action}]`).join('\n')}
|
||||
`);
|
||||
|
||||
// Confirm if not auto mode
|
||||
if (!flags.yes && !flags.y) {
|
||||
const confirm = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Create solution for issue ${issueId} with ${solution.tasks.length} tasks?`,
|
||||
header: 'Confirm',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Yes, create solution', description: 'Create and bind solution' },
|
||||
{ label: 'Cancel', description: 'Abort without changes' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
if (!confirm.answers?.['Confirm']?.includes('Yes')) {
|
||||
console.log('Cancelled.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Persist solution (following issue-plan-agent pattern)
|
||||
Bash(`mkdir -p .workflow/issues/solutions`);
|
||||
|
||||
const solutionFile = `.workflow/issues/solutions/${issueId}.jsonl`;
|
||||
|
||||
if (flags.supplement) {
|
||||
// Supplement mode: update existing solution line atomically
|
||||
try {
|
||||
const existingContent = Read(solutionFile);
|
||||
const lines = existingContent.trim().split('\n').filter(l => l);
|
||||
const updatedLines = lines.map(line => {
|
||||
const sol = JSON.parse(line);
|
||||
if (sol.id === existingSolution.id) {
|
||||
return JSON.stringify(solution);
|
||||
}
|
||||
return line;
|
||||
});
|
||||
// Atomic write: write entire content at once
|
||||
Write({ file_path: solutionFile, content: updatedLines.join('\n') + '\n' });
|
||||
console.log(`✓ Updated solution: ${existingSolution.id}`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to update solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Note: No need to rebind - solution is already bound to issue
|
||||
} else {
|
||||
// New solution: append to JSONL file (following issue-plan-agent pattern)
|
||||
try {
|
||||
const solutionLine = JSON.stringify(solution);
|
||||
|
||||
// Read existing content, append new line, write atomically
|
||||
const existing = Bash(`test -f "${solutionFile}" && cat "${solutionFile}" || echo ""`).trim();
|
||||
const newContent = existing ? existing + '\n' + solutionLine + '\n' : solutionLine + '\n';
|
||||
Write({ file_path: solutionFile, content: newContent });
|
||||
|
||||
console.log(`✓ Created solution: ${solutionId}`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to write solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Bind solution to issue
|
||||
try {
|
||||
Bash(`ccw issue bind ${issueId} ${solutionId}`);
|
||||
console.log(`✓ Bound solution to issue`);
|
||||
} catch (e) {
|
||||
// Cleanup: remove solution file on bind failure
|
||||
try {
|
||||
Bash(`rm -f "${solutionFile}"`);
|
||||
} catch (cleanupError) {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
throw new Error(`Failed to bind solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Update issue status to planned
|
||||
try {
|
||||
Bash(`ccw issue update ${issueId} --status planned`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to update issue status: ${e.message}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 7: Summary
|
||||
|
||||
```javascript
|
||||
console.log(`
|
||||
## Done
|
||||
|
||||
**Issue**: ${issueId}
|
||||
**Solution**: ${flags.supplement ? existingSolution.id : solutionId}
|
||||
**Tasks**: ${solution.tasks.length}
|
||||
**Status**: planned
|
||||
|
||||
### Next Steps:
|
||||
- \`/issue:queue\` → Form execution queue
|
||||
- \`ccw issue status ${issueId}\` → View issue details
|
||||
- \`ccw issue solution ${flags.supplement ? existingSolution.id : solutionId}\` → View solution
|
||||
`);
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Code | Resolution |
|
||||
|-------|------|------------|
|
||||
| Source not found | E001 | Check path exists |
|
||||
| Invalid source format | E002 | Verify file contains valid plan structure |
|
||||
| Issue not found | E003 | Check issue ID or omit --issue to create new |
|
||||
| Solution already bound | E004 | Use --supplement to add tasks |
|
||||
| AI extraction failed | E005 | Check markdown structure, try simpler format |
|
||||
| No tasks extracted | E006 | Source must contain at least 1 task |
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:plan` - Generate solutions from issue exploration
|
||||
- `/issue:queue` - Form execution queue from bound solutions
|
||||
- `/issue:execute` - Execute queue with DAG parallelism
|
||||
- `ccw issue status <id>` - View issue details
|
||||
- `ccw issue solution <id>` - View solution details
|
||||
382
.claude/commands/issue/from-brainstorm.md
Normal file
382
.claude/commands/issue/from-brainstorm.md
Normal file
@@ -0,0 +1,382 @@
|
||||
---
|
||||
name: from-brainstorm
|
||||
description: Convert brainstorm session ideas into issue with executable solution for parallel-dev-cycle
|
||||
argument-hint: "SESSION=\"<session-id>\" [--idea=<index>] [--auto] [-y|--yes]"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select highest-scored idea, skip confirmations, create issue directly.
|
||||
|
||||
# Issue From-Brainstorm Command (/issue:from-brainstorm)
|
||||
|
||||
## Overview
|
||||
|
||||
Bridge command that converts **brainstorm-with-file** session output into executable **issue + solution** for parallel-dev-cycle consumption.
|
||||
|
||||
**Core workflow**: Load Session → Select Idea → Convert to Issue → Generate Solution → Bind & Ready
|
||||
|
||||
**Input sources**:
|
||||
- **synthesis.json** - Main brainstorm results with top_ideas
|
||||
- **perspectives.json** - Multi-CLI perspectives (creative/pragmatic/systematic)
|
||||
- **.brainstorming/** - Synthesis artifacts (clarifications, enhancements from role analyses)
|
||||
|
||||
**Output**:
|
||||
- **Issue** (ISS-YYYYMMDD-NNN) - Full context with clarifications
|
||||
- **Solution** (SOL-{issue-id}-{uid}) - Structured tasks for parallel-dev-cycle
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Interactive mode - select idea, confirm before creation
|
||||
/issue:from-brainstorm SESSION="BS-rate-limiting-2025-01-28"
|
||||
|
||||
# Pre-select idea by index
|
||||
/issue:from-brainstorm SESSION="BS-auth-system-2025-01-28" --idea=0
|
||||
|
||||
# Auto mode - select highest scored, no confirmations
|
||||
/issue:from-brainstorm SESSION="BS-caching-2025-01-28" --auto -y
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
||||
| Argument | Required | Type | Default | Description |
|
||||
|----------|----------|------|---------|-------------|
|
||||
| SESSION | Yes | String | - | Session ID or path to `.workflow/.brainstorm/BS-xxx` |
|
||||
| --idea | No | Integer | - | Pre-select idea by index (0-based) |
|
||||
| --auto | No | Flag | false | Auto-select highest-scored idea |
|
||||
| -y, --yes | No | Flag | false | Skip all confirmations |
|
||||
|
||||
## Data Structures
|
||||
|
||||
### Issue Schema (Output)
|
||||
|
||||
```typescript
|
||||
interface Issue {
|
||||
id: string; // ISS-YYYYMMDD-NNN
|
||||
title: string; // From idea.title
|
||||
status: 'planned'; // Auto-set after solution binding
|
||||
priority: number; // 1-5 (derived from idea.score)
|
||||
context: string; // Full description with clarifications
|
||||
source: 'brainstorm';
|
||||
labels: string[]; // ['brainstorm', perspective, feasibility]
|
||||
|
||||
// Structured fields
|
||||
expected_behavior: string; // From key_strengths
|
||||
actual_behavior: string; // From main_challenges
|
||||
affected_components: string[]; // Extracted from description
|
||||
|
||||
_brainstorm_metadata: {
|
||||
session_id: string;
|
||||
idea_score: number;
|
||||
novelty: number;
|
||||
feasibility: string;
|
||||
clarifications_count: number;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Solution Schema (Output)
|
||||
|
||||
```typescript
|
||||
interface Solution {
|
||||
id: string; // SOL-{issue-id}-{4-char-uid}
|
||||
description: string; // idea.title
|
||||
approach: string; // idea.description
|
||||
tasks: Task[]; // Generated from idea.next_steps
|
||||
|
||||
analysis: {
|
||||
risk: 'low' | 'medium' | 'high';
|
||||
impact: 'low' | 'medium' | 'high';
|
||||
complexity: 'low' | 'medium' | 'high';
|
||||
};
|
||||
|
||||
is_bound: boolean; // true
|
||||
created_at: string;
|
||||
bound_at: string;
|
||||
}
|
||||
|
||||
interface Task {
|
||||
id: string; // T1, T2, T3...
|
||||
title: string; // Actionable task name
|
||||
scope: string; // design|implementation|testing|documentation
|
||||
action: string; // Implement|Design|Research|Test|Document
|
||||
description: string;
|
||||
|
||||
implementation: string[]; // Step-by-step guide
|
||||
acceptance: {
|
||||
criteria: string[]; // What defines success
|
||||
verification: string[]; // How to verify
|
||||
};
|
||||
|
||||
priority: number; // 1-5
|
||||
depends_on: string[]; // Task dependencies
|
||||
}
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Session Loading
|
||||
├─ Validate session path
|
||||
├─ Load synthesis.json (required)
|
||||
├─ Load perspectives.json (optional - multi-CLI insights)
|
||||
├─ Load .brainstorming/** (optional - synthesis artifacts)
|
||||
└─ Validate top_ideas array exists
|
||||
|
||||
Phase 2: Idea Selection
|
||||
├─ Auto mode: Select highest scored idea
|
||||
├─ Pre-selected: Use --idea=N index
|
||||
└─ Interactive: Display table, ask user to select
|
||||
|
||||
Phase 3: Enrich Issue Context
|
||||
├─ Base: idea.description + key_strengths + main_challenges
|
||||
├─ Add: Relevant clarifications (Requirements/Architecture/Feasibility)
|
||||
├─ Add: Multi-perspective insights (creative/pragmatic/systematic)
|
||||
└─ Add: Session metadata (session_id, completion date, clarification count)
|
||||
|
||||
Phase 4: Create Issue
|
||||
├─ Generate issue data with enriched context
|
||||
├─ Calculate priority from idea.score (0-10 → 1-5)
|
||||
├─ Create via: ccw issue create (heredoc for JSON)
|
||||
└─ Returns: ISS-YYYYMMDD-NNN
|
||||
|
||||
Phase 5: Generate Solution Tasks
|
||||
├─ T1: Research & Validate (if main_challenges exist)
|
||||
├─ T2: Design & Specification (if key_strengths exist)
|
||||
├─ T3+: Implementation tasks (from idea.next_steps)
|
||||
└─ Each task includes: implementation steps + acceptance criteria
|
||||
|
||||
Phase 6: Bind Solution
|
||||
├─ Write solution to .workflow/issues/solutions/{issue-id}.jsonl
|
||||
├─ Bind via: ccw issue bind {issue-id} {solution-id}
|
||||
├─ Update issue status to 'planned'
|
||||
└─ Returns: SOL-{issue-id}-{uid}
|
||||
|
||||
Phase 7: Next Steps
|
||||
└─ Offer: Form queue | Convert another idea | View details | Done
|
||||
```
|
||||
|
||||
## Context Enrichment Logic
|
||||
|
||||
### Base Context (Always Included)
|
||||
|
||||
- **Description**: `idea.description`
|
||||
- **Why This Idea**: `idea.key_strengths[]`
|
||||
- **Challenges to Address**: `idea.main_challenges[]`
|
||||
- **Implementation Steps**: `idea.next_steps[]`
|
||||
|
||||
### Enhanced Context (If Available)
|
||||
|
||||
**From Synthesis Artifacts** (`.brainstorming/*/analysis*.md`):
|
||||
- Extract clarifications matching categories: Requirements, Architecture, Feasibility
|
||||
- Format: `**{Category}** ({role}): {question} → {answer}`
|
||||
- Limit: Top 3 most relevant
|
||||
|
||||
**From Perspectives** (`perspectives.json`):
|
||||
- **Creative**: First insight from `perspectives.creative.insights[0]`
|
||||
- **Pragmatic**: First blocker from `perspectives.pragmatic.blockers[0]`
|
||||
- **Systematic**: First pattern from `perspectives.systematic.patterns[0]`
|
||||
|
||||
**Session Metadata**:
|
||||
- Session ID, Topic, Completion Date
|
||||
- Clarifications count (if synthesis artifacts loaded)
|
||||
|
||||
## Task Generation Strategy
|
||||
|
||||
### Task 1: Research & Validation
|
||||
**Trigger**: `idea.main_challenges.length > 0`
|
||||
- **Title**: "Research & Validate Approach"
|
||||
- **Scope**: design
|
||||
- **Action**: Research
|
||||
- **Implementation**: Investigate blockers, review similar implementations, validate with team
|
||||
- **Acceptance**: Blockers documented, feasibility assessed, approach validated
|
||||
|
||||
### Task 2: Design & Specification
|
||||
**Trigger**: `idea.key_strengths.length > 0`
|
||||
- **Title**: "Design & Create Specification"
|
||||
- **Scope**: design
|
||||
- **Action**: Design
|
||||
- **Implementation**: Create design doc, define success criteria, plan phases
|
||||
- **Acceptance**: Design complete, metrics defined, plan outlined
|
||||
|
||||
### Task 3+: Implementation Tasks
|
||||
**Trigger**: `idea.next_steps[]`
|
||||
- **Title**: From `next_steps[i]` (max 60 chars)
|
||||
- **Scope**: Inferred from keywords (test→testing, api→backend, ui→frontend)
|
||||
- **Action**: Detected from verbs (implement, create, update, fix, test, document)
|
||||
- **Implementation**: Execute step + follow design + write tests
|
||||
- **Acceptance**: Step implemented + tests passing + code reviewed
|
||||
|
||||
### Fallback Task
|
||||
**Trigger**: No tasks generated from above
|
||||
- **Title**: `idea.title`
|
||||
- **Scope**: implementation
|
||||
- **Action**: Implement
|
||||
- **Generic implementation + acceptance criteria**
|
||||
|
||||
## Priority Calculation
|
||||
|
||||
### Issue Priority (1-5)
|
||||
```
|
||||
idea.score: 0-10
|
||||
priority = max(1, min(5, ceil((10 - score) / 2)))
|
||||
|
||||
Examples:
|
||||
score 9-10 → priority 1 (critical)
|
||||
score 7-8 → priority 2 (high)
|
||||
score 5-6 → priority 3 (medium)
|
||||
score 3-4 → priority 4 (low)
|
||||
score 0-2 → priority 5 (lowest)
|
||||
```
|
||||
|
||||
### Task Priority (1-5)
|
||||
- Research task: 1 (highest)
|
||||
- Design task: 2
|
||||
- Implementation tasks: 3 by default, decrement for later tasks
|
||||
- Testing/documentation: 4-5
|
||||
|
||||
### Complexity Analysis
|
||||
```
|
||||
risk: main_challenges.length > 2 ? 'high' : 'medium'
|
||||
impact: score >= 8 ? 'high' : score >= 6 ? 'medium' : 'low'
|
||||
complexity: main_challenges > 3 OR tasks > 5 ? 'high'
|
||||
tasks > 3 ? 'medium' : 'low'
|
||||
```
|
||||
|
||||
## CLI Integration
|
||||
|
||||
### Issue Creation
|
||||
```bash
|
||||
# Uses heredoc to avoid shell escaping
|
||||
ccw issue create << 'EOF'
|
||||
{
|
||||
"title": "...",
|
||||
"context": "...",
|
||||
"priority": 3,
|
||||
"source": "brainstorm",
|
||||
"labels": ["brainstorm", "creative", "feasibility-high"],
|
||||
...
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
### Solution Binding
|
||||
```bash
|
||||
# Append solution to JSONL file
|
||||
echo '{"id":"SOL-xxx","tasks":[...]}' >> .workflow/issues/solutions/{issue-id}.jsonl
|
||||
|
||||
# Bind to issue
|
||||
ccw issue bind {issue-id} {solution-id}
|
||||
|
||||
# Update status
|
||||
ccw issue update {issue-id} --status planned
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Message | Resolution |
|
||||
|-------|---------|------------|
|
||||
| Session not found | synthesis.json missing | Check session ID, list available sessions |
|
||||
| No ideas | top_ideas array empty | Complete brainstorm workflow first |
|
||||
| Invalid idea index | Index out of range | Check valid range 0 to N-1 |
|
||||
| Issue creation failed | ccw issue create error | Verify CLI endpoint working |
|
||||
| Solution binding failed | Bind error | Check issue exists, retry |
|
||||
|
||||
## Examples
|
||||
|
||||
### Interactive Mode
|
||||
|
||||
```bash
|
||||
/issue:from-brainstorm SESSION="BS-rate-limiting-2025-01-28"
|
||||
|
||||
# Output:
|
||||
# | # | Title | Score | Feasibility |
|
||||
# |---|-------|-------|-------------|
|
||||
# | 0 | Token Bucket Algorithm | 8.5 | High |
|
||||
# | 1 | Sliding Window Counter | 7.2 | Medium |
|
||||
# | 2 | Fixed Window | 6.1 | High |
|
||||
|
||||
# User selects: #0
|
||||
|
||||
# Result:
|
||||
# ✓ Created issue: ISS-20250128-001
|
||||
# ✓ Created solution: SOL-ISS-20250128-001-ab3d
|
||||
# ✓ Bound solution to issue
|
||||
# → Next: /issue:queue
|
||||
```
|
||||
|
||||
### Auto Mode
|
||||
|
||||
```bash
|
||||
/issue:from-brainstorm SESSION="BS-caching-2025-01-28" --auto
|
||||
|
||||
# Result:
|
||||
# Auto-selected: Redis Cache Layer (Score: 9.2/10)
|
||||
# ✓ Created issue: ISS-20250128-002
|
||||
# ✓ Solution with 4 tasks
|
||||
# → Status: planned
|
||||
```
|
||||
|
||||
## Integration Flow
|
||||
|
||||
```
|
||||
brainstorm-with-file
|
||||
│
|
||||
├─ synthesis.json
|
||||
├─ perspectives.json
|
||||
└─ .brainstorming/** (optional)
|
||||
│
|
||||
▼
|
||||
/issue:from-brainstorm ◄─── This command
|
||||
│
|
||||
├─ ISS-YYYYMMDD-NNN (enriched issue)
|
||||
└─ SOL-{issue-id}-{uid} (structured solution)
|
||||
│
|
||||
▼
|
||||
/issue:queue
|
||||
│
|
||||
▼
|
||||
/parallel-dev-cycle
|
||||
│
|
||||
▼
|
||||
RA → EP → CD → VAS
|
||||
```
|
||||
|
||||
## Session Files Reference
|
||||
|
||||
### Input Files
|
||||
|
||||
```
|
||||
.workflow/.brainstorm/BS-{slug}-{date}/
|
||||
├── synthesis.json # REQUIRED - Top ideas with scores
|
||||
├── perspectives.json # OPTIONAL - Multi-CLI insights
|
||||
├── brainstorm.md # Reference only
|
||||
└── .brainstorming/ # OPTIONAL - Synthesis artifacts
|
||||
├── system-architect/
|
||||
│ └── analysis.md # Contains clarifications + enhancements
|
||||
├── api-designer/
|
||||
│ └── analysis.md
|
||||
└── ...
|
||||
```
|
||||
|
||||
### Output Files
|
||||
|
||||
```
|
||||
.workflow/issues/
|
||||
├── solutions/
|
||||
│ └── ISS-YYYYMMDD-001.jsonl # Created solution (JSONL)
|
||||
└── (managed by ccw issue CLI)
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:brainstorm-with-file` - Generate brainstorm sessions
|
||||
- `/workflow:brainstorm:synthesis` - Add clarifications to brainstorm
|
||||
- `/issue:new` - Create issues from GitHub or text
|
||||
- `/issue:plan` - Generate solutions via exploration
|
||||
- `/issue:queue` - Form execution queue
|
||||
- `/issue:execute` - Execute with parallel-dev-cycle
|
||||
- `ccw issue status <id>` - View issue
|
||||
- `ccw issue solution <id>` - View solution
|
||||
@@ -413,5 +413,4 @@ function parseMarkdownBody(body) {
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:plan` - Plan solution for issue
|
||||
|
||||
- `/issue:plan` - Plan solution for issue
|
||||
@@ -1,687 +0,0 @@
|
||||
---
|
||||
name: code-map-memory
|
||||
description: 3-phase orchestrator: parse feature keyword → cli-explore-agent analyzes (Deep Scan dual-source) → orchestrator generates Mermaid docs + SKILL package (skips phase 2 if exists)
|
||||
argument-hint: "\"feature-keyword\" [--regenerate] [--tool <gemini|qwen>]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*), Task(*)
|
||||
---
|
||||
|
||||
# Code Flow Mapping Generator
|
||||
|
||||
## Overview
|
||||
|
||||
**Pure Orchestrator with Agent Delegation**: Prepares context paths and delegates code flow analysis to specialized cli-explore-agent. Orchestrator transforms agent's JSON analysis into Mermaid documentation.
|
||||
|
||||
**Auto-Continue Workflow**: Runs fully autonomously once triggered. Each phase completes and automatically triggers the next phase.
|
||||
|
||||
**Execution Paths**:
|
||||
- **Full Path**: All 3 phases (no existing codemap OR `--regenerate` specified)
|
||||
- **Skip Path**: Phase 1 → Phase 3 (existing codemap found AND no `--regenerate` flag)
|
||||
- **Phase 3 Always Executes**: SKILL index is always generated or updated
|
||||
|
||||
**Agent Responsibility** (cli-explore-agent):
|
||||
- Deep code flow analysis using dual-source strategy (Bash + Gemini CLI)
|
||||
- Returns structured JSON with architecture, functions, data flow, conditionals, patterns
|
||||
- NO file writing - analysis only
|
||||
|
||||
**Orchestrator Responsibility**:
|
||||
- Provides feature keyword and analysis scope to agent
|
||||
- Transforms agent's JSON into Mermaid-enriched markdown documentation
|
||||
- Writes all files (5 docs + metadata.json + SKILL.md)
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 execution
|
||||
2. **Feature-Specific SKILL**: Each feature creates independent `.claude/skills/codemap-{feature}/` package
|
||||
3. **Specialized Agent**: Phase 2a uses cli-explore-agent for professional code analysis (Deep Scan mode)
|
||||
4. **Orchestrator Documentation**: Phase 2b transforms agent JSON into Mermaid markdown files
|
||||
5. **Auto-Continue**: After completing each phase, update TodoWrite and immediately execute next phase
|
||||
6. **No User Prompts**: Never ask user questions or wait for input between phases
|
||||
7. **Track Progress**: Update TodoWrite after EVERY phase completion before starting next phase
|
||||
8. **Multi-Level Detail**: Generate 4 levels: architecture → function → data → conditional
|
||||
|
||||
---
|
||||
|
||||
## 3-Phase Execution
|
||||
|
||||
### Phase 1: Parse Feature Keyword & Check Existing
|
||||
|
||||
**Goal**: Normalize feature keyword, check existing codemap, prepare for analysis
|
||||
|
||||
**Step 1: Parse Feature Keyword**
|
||||
```bash
|
||||
# Get feature keyword from argument
|
||||
FEATURE_KEYWORD="$1"
|
||||
|
||||
# Normalize: lowercase, spaces to hyphens
|
||||
normalized_feature=$(echo "$FEATURE_KEYWORD" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr '_' '-')
|
||||
|
||||
# Example: "User Authentication" → "user-authentication"
|
||||
# Example: "支付处理" → "支付处理" (keep non-ASCII)
|
||||
```
|
||||
|
||||
**Step 2: Set Tool Preference**
|
||||
```bash
|
||||
# Default to gemini unless --tool specified
|
||||
TOOL="${tool_flag:-gemini}"
|
||||
```
|
||||
|
||||
**Step 3: Check Existing Codemap**
|
||||
```bash
|
||||
# Define codemap directory
|
||||
CODEMAP_DIR=".claude/skills/codemap-${normalized_feature}"
|
||||
|
||||
# Check if codemap exists
|
||||
bash(test -d "$CODEMAP_DIR" && echo "exists" || echo "not_exists")
|
||||
|
||||
# Count existing files
|
||||
bash(find "$CODEMAP_DIR" -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Step 4: Skip Decision**
|
||||
```javascript
|
||||
if (existing_files > 0 && !regenerate_flag) {
|
||||
SKIP_GENERATION = true
|
||||
message = "Codemap already exists, skipping Phase 2. Use --regenerate to force regeneration."
|
||||
} else if (regenerate_flag) {
|
||||
bash(rm -rf "$CODEMAP_DIR")
|
||||
SKIP_GENERATION = false
|
||||
message = "Regenerating codemap from scratch."
|
||||
} else {
|
||||
SKIP_GENERATION = false
|
||||
message = "No existing codemap found, generating new code flow analysis."
|
||||
}
|
||||
```
|
||||
|
||||
**Output Variables**:
|
||||
- `FEATURE_KEYWORD`: Original feature keyword
|
||||
- `normalized_feature`: Normalized feature name for directory
|
||||
- `CODEMAP_DIR`: `.claude/skills/codemap-{feature}`
|
||||
- `TOOL`: CLI tool to use (gemini or qwen)
|
||||
- `SKIP_GENERATION`: Boolean - whether to skip Phase 2
|
||||
|
||||
**TodoWrite**:
|
||||
- If skipping: Mark phase 1 completed, phase 2 completed, phase 3 in_progress
|
||||
- If not skipping: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Code Flow Analysis & Documentation Generation
|
||||
|
||||
**Skip Condition**: Skipped if `SKIP_GENERATION = true`
|
||||
|
||||
**Goal**: Use cli-explore-agent for professional code analysis, then orchestrator generates Mermaid documentation
|
||||
|
||||
**Architecture**: Phase 2a (Agent Analysis) → Phase 2b (Orchestrator Documentation)
|
||||
|
||||
---
|
||||
|
||||
#### Phase 2a: cli-explore-agent Analysis
|
||||
|
||||
**Purpose**: Leverage specialized cli-explore-agent for deep code flow analysis
|
||||
|
||||
**Agent Task Specification**:
|
||||
|
||||
```
|
||||
Task(
|
||||
subagent_type: "cli-explore-agent",
|
||||
description: "Analyze code flow: {FEATURE_KEYWORD}",
|
||||
prompt: "
|
||||
Perform Deep Scan analysis for feature: {FEATURE_KEYWORD}
|
||||
|
||||
**Analysis Mode**: deep-scan (Dual-source: Bash structural scan + Gemini semantic analysis)
|
||||
|
||||
**Analysis Objectives**:
|
||||
1. **Module Architecture**: Identify high-level module organization, interactions, and entry points
|
||||
2. **Function Call Chains**: Trace execution paths, call sequences, and parameter flows
|
||||
3. **Data Transformations**: Map data structure changes and transformation stages
|
||||
4. **Conditional Paths**: Document decision trees, branches, and error handling strategies
|
||||
5. **Design Patterns**: Discover architectural patterns and extract design intent
|
||||
|
||||
**Scope**:
|
||||
- Feature: {FEATURE_KEYWORD}
|
||||
- CLI Tool: {TOOL} (gemini-2.5-pro or qwen coder-model)
|
||||
- File Discovery: MCP Code Index (preferred) + rg fallback
|
||||
- Target: 5-15 most relevant files
|
||||
|
||||
**MANDATORY FIRST STEP**:
|
||||
Read: ~/.claude/workflows/cli-templates/schemas/codemap-json-schema.json
|
||||
|
||||
**Output**: Return JSON following schema exactly. NO FILE WRITING - return JSON analysis only.
|
||||
|
||||
**Critical Requirements**:
|
||||
- Use Deep Scan mode: Bash (Phase 1 - precise locations) + Gemini CLI (Phase 2 - semantic understanding) + Synthesis (Phase 3 - merge with attribution)
|
||||
- Focus exclusively on {FEATURE_KEYWORD} feature flow
|
||||
- Include file:line references for ALL findings
|
||||
- Extract design intent from code structure and comments
|
||||
- NO FILE WRITING - return JSON analysis only
|
||||
- Handle tool failures gracefully (Gemini → Qwen fallback, MCP → rg fallback)
|
||||
"
|
||||
)
|
||||
```
|
||||
|
||||
**Agent Output**: JSON analysis result with architecture, functions, data flow, conditionals, and patterns
|
||||
|
||||
---
|
||||
|
||||
#### Phase 2b: Orchestrator Documentation Generation
|
||||
|
||||
**Purpose**: Transform cli-explore-agent JSON into Mermaid-enriched documentation
|
||||
|
||||
**Input**: Agent's JSON analysis result
|
||||
|
||||
**Process**:
|
||||
|
||||
1. **Parse Agent Analysis**:
|
||||
```javascript
|
||||
const analysis = JSON.parse(agentResult)
|
||||
const { feature, files_analyzed, architecture, function_calls, data_flow, conditional_logic, design_patterns } = analysis
|
||||
```
|
||||
|
||||
2. **Generate Mermaid Diagrams from Structured Data**:
|
||||
|
||||
**a) architecture-flow.md** (~3K tokens):
|
||||
```javascript
|
||||
// Convert architecture.modules + architecture.interactions → Mermaid graph TD
|
||||
const architectureMermaid = `
|
||||
graph TD
|
||||
${architecture.modules.map(m => ` ${m.name}[${m.name}]`).join('\n')}
|
||||
${architecture.interactions.map(i => ` ${i.from} -->|${i.type}| ${i.to}`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/architecture-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: architecture
|
||||
detail: high-level module interactions
|
||||
---
|
||||
# Architecture Flow: ${feature}
|
||||
|
||||
## Overview
|
||||
${architecture.overview}
|
||||
|
||||
## Module Architecture
|
||||
${architecture.modules.map(m => `### ${m.name}\n- **File**: ${m.file}\n- **Role**: ${m.responsibility}\n- **Dependencies**: ${m.dependencies.join(', ')}`).join('\n\n')}
|
||||
|
||||
## Flow Diagram
|
||||
\`\`\`mermaid
|
||||
${architectureMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Key Interactions
|
||||
${architecture.interactions.map(i => `- **${i.from} → ${i.to}**: ${i.description}`).join('\n')}
|
||||
|
||||
## Entry Points
|
||||
${architecture.entry_points.map(e => `- **${e.function}** (${e.file}): ${e.description}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**b) function-calls.md** (~5K tokens):
|
||||
```javascript
|
||||
// Convert function_calls.sequences → Mermaid sequenceDiagram
|
||||
const sequenceMermaid = `
|
||||
sequenceDiagram
|
||||
${function_calls.sequences.map(s => ` ${s.from}->>${s.to}: ${s.method}`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/function-calls.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: function
|
||||
detail: function-level call sequences
|
||||
---
|
||||
# Function Call Chains: ${feature}
|
||||
|
||||
## Call Sequence Diagram
|
||||
\`\`\`mermaid
|
||||
${sequenceMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Detailed Call Chains
|
||||
${function_calls.call_chains.map(chain => `
|
||||
### Chain ${chain.chain_id}: ${chain.description}
|
||||
${chain.sequence.map(fn => `- **${fn.function}** (${fn.file})\n - Calls: ${fn.calls.join(', ')}`).join('\n')}
|
||||
`).join('\n')}
|
||||
|
||||
## Parameters & Returns
|
||||
${function_calls.sequences.map(s => `- **${s.method}** → Returns: ${s.returns || 'void'}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**c) data-flow.md** (~4K tokens):
|
||||
```javascript
|
||||
// Convert data_flow.transformations → Mermaid flowchart LR
|
||||
const dataFlowMermaid = `
|
||||
flowchart LR
|
||||
${data_flow.transformations.map((t, i) => ` Stage${i}[${t.from}] -->|${t.transformer}| Stage${i+1}[${t.to}]`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/data-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: data
|
||||
detail: data structure transformations
|
||||
---
|
||||
# Data Flow: ${feature}
|
||||
|
||||
## Data Transformation Diagram
|
||||
\`\`\`mermaid
|
||||
${dataFlowMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Data Structures
|
||||
${data_flow.structures.map(s => `### ${s.name} (${s.stage})\n\`\`\`json\n${JSON.stringify(s.shape, null, 2)}\n\`\`\``).join('\n\n')}
|
||||
|
||||
## Transformations
|
||||
${data_flow.transformations.map(t => `- **${t.from} → ${t.to}** via \`${t.transformer}\` (${t.file})`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**d) conditional-paths.md** (~4K tokens):
|
||||
```javascript
|
||||
// Convert conditional_logic.branches → Mermaid flowchart TD
|
||||
const conditionalMermaid = `
|
||||
flowchart TD
|
||||
Start[Entry Point]
|
||||
${conditional_logic.branches.map((b, i) => `
|
||||
Start --> Check${i}{${b.condition}}
|
||||
Check${i} -->|Yes| Path${i}A[${b.true_path}]
|
||||
Check${i} -->|No| Path${i}B[${b.false_path}]
|
||||
`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/conditional-paths.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: conditional
|
||||
detail: decision trees and error paths
|
||||
---
|
||||
# Conditional Paths: ${feature}
|
||||
|
||||
## Decision Tree
|
||||
\`\`\`mermaid
|
||||
${conditionalMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Branch Conditions
|
||||
${conditional_logic.branches.map(b => `- **${b.condition}** (${b.file})\n - True: ${b.true_path}\n - False: ${b.false_path}`).join('\n')}
|
||||
|
||||
## Error Handling
|
||||
${conditional_logic.error_handling.map(e => `- **${e.error_type}**: Handler \`${e.handler}\` (${e.file}) - Recovery: ${e.recovery}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**e) complete-flow.md** (~8K tokens):
|
||||
```javascript
|
||||
// Integrate all Mermaid diagrams
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/complete-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: complete
|
||||
detail: integrated multi-level view
|
||||
---
|
||||
# Complete Flow: ${feature}
|
||||
|
||||
## Integrated Flow Diagram
|
||||
\`\`\`mermaid
|
||||
graph TB
|
||||
subgraph Architecture
|
||||
${architecture.modules.map(m => ` ${m.name}[${m.name}]`).join('\n')}
|
||||
end
|
||||
|
||||
subgraph "Function Calls"
|
||||
${function_calls.call_chains[0]?.sequence.map(fn => ` ${fn.function}`).join('\n') || ''}
|
||||
end
|
||||
|
||||
subgraph "Data Flow"
|
||||
${data_flow.structures.map(s => ` ${s.name}[${s.name}]`).join('\n')}
|
||||
end
|
||||
\`\`\`
|
||||
|
||||
## Complete Trace
|
||||
[Comprehensive end-to-end documentation combining all analysis layers]
|
||||
|
||||
## Design Patterns Identified
|
||||
${design_patterns.map(p => `- **${p.pattern}** in ${p.location}: ${p.description}`).join('\n')}
|
||||
|
||||
## Recommendations
|
||||
${analysis.recommendations.map(r => `- ${r}`).join('\n')}
|
||||
|
||||
## Cross-References
|
||||
- [Architecture Flow](./architecture-flow.md) - High-level module structure
|
||||
- [Function Calls](./function-calls.md) - Detailed call chains
|
||||
- [Data Flow](./data-flow.md) - Data transformation stages
|
||||
- [Conditional Paths](./conditional-paths.md) - Decision trees and error handling
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
3. **Write metadata.json**:
|
||||
```javascript
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/metadata.json`,
|
||||
content: JSON.stringify({
|
||||
feature: feature,
|
||||
normalized_name: normalized_feature,
|
||||
generated_at: new Date().toISOString(),
|
||||
tool_used: analysis.analysis_metadata.tool_used,
|
||||
files_analyzed: files_analyzed.map(f => f.file),
|
||||
analysis_summary: {
|
||||
total_files: files_analyzed.length,
|
||||
modules_traced: architecture.modules.length,
|
||||
functions_traced: function_calls.call_chains.reduce((sum, c) => sum + c.sequence.length, 0),
|
||||
patterns_discovered: design_patterns.length
|
||||
}
|
||||
}, null, 2)
|
||||
})
|
||||
```
|
||||
|
||||
4. **Report Phase 2 Completion**:
|
||||
```
|
||||
Phase 2 Complete: Code flow analysis and documentation generated
|
||||
|
||||
- Agent Analysis: cli-explore-agent with {TOOL}
|
||||
- Files Analyzed: {count}
|
||||
- Documentation Generated: 5 markdown files + metadata.json
|
||||
- Location: {CODEMAP_DIR}
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- cli-explore-agent task completed successfully with JSON result
|
||||
- 5 documentation files written with valid Mermaid diagrams
|
||||
- metadata.json written with analysis summary
|
||||
- All files properly formatted and cross-referenced
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Generate SKILL.md Index
|
||||
|
||||
**Note**: This phase **ALWAYS executes** - generates or updates the SKILL index.
|
||||
|
||||
**Goal**: Read generated flow documentation and create SKILL.md index with progressive loading
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. **Verify Generated Files**:
|
||||
```bash
|
||||
bash(find "{CODEMAP_DIR}" -name "*.md" -type f | sort)
|
||||
```
|
||||
|
||||
2. **Read metadata.json**:
|
||||
```javascript
|
||||
Read({CODEMAP_DIR}/metadata.json)
|
||||
// Extract: feature, normalized_name, files_analyzed, analysis_summary
|
||||
```
|
||||
|
||||
3. **Read File Headers** (optional, first 30 lines):
|
||||
```javascript
|
||||
Read({CODEMAP_DIR}/architecture-flow.md, limit: 30)
|
||||
Read({CODEMAP_DIR}/function-calls.md, limit: 30)
|
||||
// Extract overview and diagram counts
|
||||
```
|
||||
|
||||
4. **Generate SKILL.md Index**:
|
||||
|
||||
Template structure:
|
||||
```yaml
|
||||
---
|
||||
name: codemap-{normalized_feature}
|
||||
description: Code flow mapping for {FEATURE_KEYWORD} feature (located at {project_path}). Load this SKILL when analyzing, tracing, or understanding {FEATURE_KEYWORD} execution flow, especially when no relevant context exists in memory.
|
||||
version: 1.0.0
|
||||
generated_at: {ISO_TIMESTAMP}
|
||||
---
|
||||
# Code Flow Map: {FEATURE_KEYWORD}
|
||||
|
||||
## Feature: `{FEATURE_KEYWORD}`
|
||||
|
||||
**Analysis Date**: {DATE}
|
||||
**Tool Used**: {TOOL}
|
||||
**Files Analyzed**: {COUNT}
|
||||
|
||||
## Progressive Loading
|
||||
|
||||
### Level 0: Quick Overview (~2K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md) - High-level module interactions
|
||||
|
||||
### Level 1: Core Flows (~10K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md) - Module architecture
|
||||
- [Function Calls](./function-calls.md) - Function call chains
|
||||
|
||||
### Level 2: Complete Analysis (~20K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md)
|
||||
- [Function Calls](./function-calls.md)
|
||||
- [Data Flow](./data-flow.md) - Data transformations
|
||||
|
||||
### Level 3: Deep Dive (~30K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md)
|
||||
- [Function Calls](./function-calls.md)
|
||||
- [Data Flow](./data-flow.md)
|
||||
- [Conditional Paths](./conditional-paths.md) - Branches and error handling
|
||||
- [Complete Flow](./complete-flow.md) - Integrated comprehensive view
|
||||
|
||||
## Usage
|
||||
|
||||
Load this SKILL package when:
|
||||
- Analyzing {FEATURE_KEYWORD} implementation
|
||||
- Tracing execution flow for debugging
|
||||
- Understanding code dependencies
|
||||
- Planning refactoring or enhancements
|
||||
|
||||
## Analysis Summary
|
||||
|
||||
- **Modules Traced**: {modules_traced}
|
||||
- **Functions Traced**: {functions_traced}
|
||||
- **Files Analyzed**: {total_files}
|
||||
|
||||
## Mermaid Diagrams Included
|
||||
|
||||
- Architecture flow diagram (graph TD)
|
||||
- Function call sequence diagram (sequenceDiagram)
|
||||
- Data transformation flowchart (flowchart LR)
|
||||
- Conditional decision tree (flowchart TD)
|
||||
- Complete integrated diagram (graph TB)
|
||||
```
|
||||
|
||||
5. **Write SKILL.md**:
|
||||
```javascript
|
||||
Write({
|
||||
file_path: `{CODEMAP_DIR}/SKILL.md`,
|
||||
content: generatedIndexMarkdown
|
||||
})
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- SKILL.md index written
|
||||
- All documentation files verified
|
||||
- Progressive loading levels (0-3) properly structured
|
||||
- Mermaid diagram references included
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed
|
||||
|
||||
**Final Report**:
|
||||
```
|
||||
Code Flow Mapping Complete
|
||||
|
||||
Feature: {FEATURE_KEYWORD}
|
||||
Location: .claude/skills/codemap-{normalized_feature}/
|
||||
|
||||
Files Generated:
|
||||
- SKILL.md (index)
|
||||
- architecture-flow.md (with Mermaid diagram)
|
||||
- function-calls.md (with Mermaid sequence diagram)
|
||||
- data-flow.md (with Mermaid flowchart)
|
||||
- conditional-paths.md (with Mermaid decision tree)
|
||||
- complete-flow.md (with integrated Mermaid diagram)
|
||||
- metadata.json
|
||||
|
||||
Analysis:
|
||||
- Files analyzed: {count}
|
||||
- Modules traced: {count}
|
||||
- Functions traced: {count}
|
||||
|
||||
Usage: Skill(command: "codemap-{normalized_feature}")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### TodoWrite Patterns
|
||||
|
||||
**Initialization** (Before Phase 1):
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "in_progress", "activeForm": "Parsing feature keyword"},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "pending", "activeForm": "Analyzing code flow"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL index"}
|
||||
]})
|
||||
```
|
||||
|
||||
**Full Path** (SKIP_GENERATION = false):
|
||||
```javascript
|
||||
// After Phase 1
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "in_progress", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", ...}
|
||||
]})
|
||||
|
||||
// After Phase 2
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", ...}
|
||||
]})
|
||||
|
||||
// After Phase 3
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", ...}
|
||||
]})
|
||||
```
|
||||
|
||||
**Skip Path** (SKIP_GENERATION = true):
|
||||
```javascript
|
||||
// After Phase 1 (skip Phase 2)
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...}, // Skipped
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", ...}
|
||||
]})
|
||||
```
|
||||
|
||||
### Execution Flow
|
||||
|
||||
**Full Path**:
|
||||
```
|
||||
User → TodoWrite Init → Phase 1 (parse) → Phase 2 (agent analyzes) → Phase 3 (write index) → Report
|
||||
```
|
||||
|
||||
**Skip Path**:
|
||||
```
|
||||
User → TodoWrite Init → Phase 1 (detect existing) → Phase 3 (update index) → Report
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Phase 1 Errors**:
|
||||
- Empty feature keyword: Report error, ask user to provide feature description
|
||||
- Invalid characters: Normalize and continue
|
||||
|
||||
**Phase 2 Errors (Agent)**:
|
||||
- Agent task fails: Retry once, report if fails again
|
||||
- No files discovered: Warn user, ask for more specific feature keyword
|
||||
- CLI failures: Agent handles internally with retries
|
||||
- Invalid Mermaid syntax: Agent validates before writing
|
||||
|
||||
**Phase 3 Errors**:
|
||||
- Write failures: Report which files failed
|
||||
- Missing files: Note in SKILL.md, suggest regeneration
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "feature-keyword" [--regenerate] [--tool <gemini|qwen>]
|
||||
```
|
||||
|
||||
**Arguments**:
|
||||
- **"feature-keyword"**: Feature or flow to analyze (required)
|
||||
- Examples: `"user authentication"`, `"payment processing"`, `"数据导入流程"`
|
||||
- Can be English, Chinese, or mixed
|
||||
- Spaces and underscores normalized to hyphens
|
||||
- **--regenerate**: Force regenerate existing codemap (deletes and recreates)
|
||||
- **--tool**: CLI tool for analysis (default: gemini)
|
||||
- `gemini`: Comprehensive flow analysis with gemini-2.5-pro
|
||||
- `qwen`: Alternative with coder-model
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
**Generated File Structure** (for all examples):
|
||||
```
|
||||
.claude/skills/codemap-{feature}/
|
||||
├── SKILL.md # Index (Phase 3)
|
||||
├── architecture-flow.md # Agent (Phase 2) - High-level flow
|
||||
├── function-calls.md # Agent (Phase 2) - Function chains
|
||||
├── data-flow.md # Agent (Phase 2) - Data transformations
|
||||
├── conditional-paths.md # Agent (Phase 2) - Branches & errors
|
||||
├── complete-flow.md # Agent (Phase 2) - Integrated view
|
||||
└── metadata.json # Agent (Phase 2)
|
||||
```
|
||||
|
||||
### Example 1: User Authentication Flow
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "user authentication"
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Normalizes to "user-authentication", checks existing codemap
|
||||
2. Phase 2: Agent discovers auth-related files, executes CLI analysis, generates 5 flow docs with Mermaid
|
||||
3. Phase 3: Generates SKILL.md index with progressive loading
|
||||
|
||||
**Output**: `.claude/skills/codemap-user-authentication/` with 6 files + metadata
|
||||
|
||||
|
||||
### Example 3: Regenerate with Qwen
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "payment processing" --regenerate --tool qwen
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Deletes existing codemap due to --regenerate
|
||||
2. Phase 2: Agent uses qwen with coder-model for fresh analysis
|
||||
3. Phase 3: Generates updated SKILL.md
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
code-map-memory (orchestrator)
|
||||
├─ Phase 1: Parse & Check (bash commands, skip decision)
|
||||
├─ Phase 2: Code Analysis & Documentation (skippable)
|
||||
│ ├─ Phase 2a: cli-explore-agent Analysis
|
||||
│ │ └─ Deep Scan: Bash structural + Gemini semantic → JSON
|
||||
│ └─ Phase 2b: Orchestrator Documentation
|
||||
│ └─ Transform JSON → 5 Mermaid markdown files + metadata.json
|
||||
└─ Phase 3: Write SKILL.md (index generation, always runs)
|
||||
|
||||
Output: .claude/skills/codemap-{feature}/
|
||||
```
|
||||
@@ -1,615 +0,0 @@
|
||||
---
|
||||
name: docs
|
||||
description: Plan documentation workflow with dynamic grouping (≤10 docs/task), generates IMPL tasks for parallel module trees, README, ARCHITECTURE, and HTTP API docs
|
||||
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]"
|
||||
---
|
||||
|
||||
# Documentation Workflow (/memory:docs)
|
||||
|
||||
## Overview
|
||||
Lightweight planner that analyzes project structure, decomposes documentation work into tasks, and generates execution plans. Does NOT generate documentation content itself - delegates to doc-generator agent.
|
||||
|
||||
**Execution Strategy**:
|
||||
- **Dynamic Task Grouping**: Level 1 tasks grouped by top-level directories with document count limit
|
||||
- **Primary constraint**: Each task generates ≤10 documents (API.md + README.md count)
|
||||
- **Optimization goal**: Prefer grouping 2 top-level directories per task for context sharing
|
||||
- **Conflict resolution**: If 2 dirs exceed 10 docs, reduce to 1 dir/task; if 1 dir exceeds 10 docs, split by subdirectories
|
||||
- **Context benefit**: Same-task directories analyzed together via single Gemini call
|
||||
- **Parallel Execution**: Multiple Level 1 tasks execute concurrently for faster completion
|
||||
- **Pre-computed Analysis**: Phase 2 performs unified analysis once, stored in `.process/` for reuse
|
||||
- **Efficient Data Loading**: All existing docs loaded once in Phase 2, shared across tasks
|
||||
|
||||
**Path Mirroring**: Documentation structure mirrors source code under `.workflow/docs/{project_name}/`
|
||||
- Example: `my_app/src/core/` → `.workflow/docs/my_app/src/core/API.md`
|
||||
|
||||
**Two Execution Modes**:
|
||||
- **Default (Agent Mode)**: CLI analyzes in `pre_analysis` (MODE=analysis), agent writes docs
|
||||
- **--cli-execute (CLI Mode)**: CLI generates docs in `implementation_approach` (MODE=write), agent executes CLI commands
|
||||
|
||||
## Path Mirroring Strategy
|
||||
|
||||
**Principle**: Documentation structure **mirrors** source code structure under project-specific directory.
|
||||
|
||||
| Source Path | Project Name | Documentation Path |
|
||||
|------------|--------------|-------------------|
|
||||
| `my_app/src/core/` | `my_app` | `.workflow/docs/my_app/src/core/API.md` |
|
||||
| `my_app/src/modules/auth/` | `my_app` | `.workflow/docs/my_app/src/modules/auth/API.md` |
|
||||
| `another_project/lib/utils/` | `another_project` | `.workflow/docs/another_project/lib/utils/API.md` |
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:docs [path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]
|
||||
```
|
||||
|
||||
- **path**: Source directory to analyze (default: current directory)
|
||||
- Specifies the source code directory to be documented
|
||||
- Documentation is generated in a separate `.workflow/docs/{project_name}/` directory at the workspace root, **not** within the source `path` itself
|
||||
- The source path's structure is mirrored within the project-specific documentation folder
|
||||
- Example: analyzing `src/modules` produces documentation at `.workflow/docs/{project_name}/src/modules/`
|
||||
- **--mode**: Documentation generation mode (default: full)
|
||||
- `full`: Complete documentation (modules + README + ARCHITECTURE + EXAMPLES + HTTP API)
|
||||
- `partial`: Module documentation only (API.md + README.md)
|
||||
- **--tool**: CLI tool selection (default: gemini)
|
||||
- `gemini`: Comprehensive documentation, pattern recognition
|
||||
- `qwen`: Architecture analysis, system design focus
|
||||
- `codex`: Implementation validation, code quality
|
||||
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
||||
|
||||
## Planning Workflow
|
||||
|
||||
### Phase 1: Initialize Session
|
||||
|
||||
```bash
|
||||
# Get target path, project name, and root
|
||||
bash(pwd && basename "$(pwd)" && git rev-parse --show-toplevel 2>/dev/null || pwd && date +%Y%m%d-%H%M%S)
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Create docs session (type: docs)
|
||||
SlashCommand(command="/workflow:session:start --type docs --new \"{project_name}-docs-{timestamp}\"")
|
||||
// Parse output to get sessionId
|
||||
```
|
||||
|
||||
```bash
|
||||
# Update workflow-session.json with docs-specific fields
|
||||
bash(jq '. + {"target_path":"{target_path}","project_root":"{project_root}","project_name":"{project_name}","mode":"full","tool":"gemini","cli_execute":false}' .workflow/active/{sessionId}/workflow-session.json > tmp.json && mv tmp.json .workflow/active/{sessionId}/workflow-session.json)
|
||||
```
|
||||
|
||||
### Phase 2: Analyze Structure
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
||||
|
||||
**Commands** (collect data with simple bash):
|
||||
|
||||
```bash
|
||||
# 1. Run folder analysis
|
||||
bash(ccw tool exec get_modules_by_depth '{}' | ccw tool exec classify_folders '{}')
|
||||
|
||||
# 2. Get top-level directories (first 2 path levels)
|
||||
bash(ccw tool exec get_modules_by_depth '{}' | ccw tool exec classify_folders '{}' | awk -F'|' '{print $1}' | sed 's|^\./||' | awk -F'/' '{if(NF>=2) print $1"/"$2; else if(NF==1) print $1}' | sort -u)
|
||||
|
||||
# 3. Find existing docs (if directory exists)
|
||||
bash(if [ -d .workflow/docs/\${project_name} ]; then find .workflow/docs/\${project_name} -type f -name "*.md" ! -path "*/README.md" ! -path "*/ARCHITECTURE.md" ! -path "*/EXAMPLES.md" ! -path "*/api/*" 2>/dev/null; fi)
|
||||
|
||||
# 4. Read existing docs content (if files exist)
|
||||
bash(if [ -d .workflow/docs/\${project_name} ]; then find .workflow/docs/\${project_name} -type f -name "*.md" ! -path "*/README.md" ! -path "*/ARCHITECTURE.md" ! -path "*/EXAMPLES.md" ! -path "*/api/*" 2>/dev/null | xargs cat 2>/dev/null; fi)
|
||||
```
|
||||
|
||||
**Data Processing**: Parse bash outputs, calculate statistics, use **Write tool** to create `${session_dir}/.process/doc-planning-data.json` with structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"generated_at": "2025-11-03T16:57:30.469669",
|
||||
"project_name": "project_name",
|
||||
"project_root": "/path/to/project"
|
||||
},
|
||||
"folder_analysis": [
|
||||
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2}
|
||||
],
|
||||
"top_level_dirs": ["src/modules", "lib/core"],
|
||||
"existing_docs": {
|
||||
"file_list": [".workflow/docs/project/src/core/API.md"],
|
||||
"content": "... existing docs content ..."
|
||||
},
|
||||
"unified_analysis": [],
|
||||
"statistics": {
|
||||
"total": 15,
|
||||
"code": 8,
|
||||
"navigation": 7,
|
||||
"top_level": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Then** use **Edit tool** to update `workflow-session.json` adding analysis field.
|
||||
|
||||
**Output**: Single `doc-planning-data.json` with all analysis data (no temp files or Python scripts).
|
||||
|
||||
**Auto-skipped**: Tests (`**/test/**`, `**/*.test.*`), Build (`**/node_modules/**`, `**/dist/**`), Config (root-level files), Vendor directories.
|
||||
|
||||
### Phase 3: Detect Update Mode
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# Count existing docs from doc-planning-data.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq '.existing_docs.file_list | length')
|
||||
```
|
||||
|
||||
**Data Processing**: Use count result, then use **Edit tool** to update `workflow-session.json`:
|
||||
- Add `"update_mode": "update"` if count > 0, else `"create"`
|
||||
- Add `"existing_docs": <count>`
|
||||
|
||||
### Phase 4: Decompose Tasks
|
||||
|
||||
**Task Hierarchy** (Dynamic based on document count):
|
||||
|
||||
```
|
||||
Small Projects (total ≤10 docs):
|
||||
Level 1: IMPL-001 (all directories in single task, shared context)
|
||||
Level 2: IMPL-002 (README, full mode only)
|
||||
Level 3: IMPL-003 (ARCHITECTURE+EXAMPLES), IMPL-004 (HTTP API, optional)
|
||||
|
||||
Medium Projects (Example: 7 top-level dirs, 18 total docs):
|
||||
Step 1: Count docs per top-level dir
|
||||
├─ dir1: 3 docs, dir2: 4 docs → Group 1 (7 docs)
|
||||
├─ dir3: 5 docs, dir4: 3 docs → Group 2 (8 docs)
|
||||
├─ dir5: 2 docs → Group 3 (2 docs, can add more)
|
||||
|
||||
Step 2: Create tasks with ≤10 docs constraint
|
||||
Level 1: IMPL-001 to IMPL-003 (parallel groups)
|
||||
├─ IMPL-001: Group 1 (dir1 + dir2, 7 docs, shared context)
|
||||
├─ IMPL-002: Group 2 (dir3 + dir4, 8 docs, shared context)
|
||||
└─ IMPL-003: Group 3 (remaining dirs, ≤10 docs)
|
||||
Level 2: IMPL-004 (README, depends on Level 1, full mode only)
|
||||
Level 3: IMPL-005 (ARCHITECTURE+EXAMPLES), IMPL-006 (HTTP API, optional)
|
||||
|
||||
Large Projects (single dir >10 docs):
|
||||
Step 1: Detect oversized directory
|
||||
└─ src/modules/: 15 subdirs → 30 docs (exceeds limit)
|
||||
|
||||
Step 2: Split by subdirectories
|
||||
Level 1: IMPL-001 to IMPL-003 (split oversized dir)
|
||||
├─ IMPL-001: src/modules/ subdirs 1-5 (10 docs)
|
||||
├─ IMPL-002: src/modules/ subdirs 6-10 (10 docs)
|
||||
└─ IMPL-003: src/modules/ subdirs 11-15 (10 docs)
|
||||
```
|
||||
|
||||
**Grouping Algorithm**:
|
||||
1. Count total docs for each top-level directory
|
||||
2. Try grouping 2 directories (optimization for context sharing)
|
||||
3. If group exceeds 10 docs, split to 1 dir/task
|
||||
4. If single dir exceeds 10 docs, split by subdirectories
|
||||
5. Create parallel Level 1 tasks with ≤10 docs each
|
||||
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# 1. Get top-level directories from doc-planning-data.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq -r '.top_level_dirs[]')
|
||||
|
||||
# 2. Get mode from workflow-session.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/workflow-session.json | jq -r '.mode // "full"')
|
||||
|
||||
# 3. Check for HTTP API
|
||||
bash(grep -r "router\.|@Get\|@Post" src/ 2>/dev/null && echo "API_FOUND" || echo "NO_API")
|
||||
```
|
||||
|
||||
**Data Processing**:
|
||||
1. Count documents for each top-level directory (from folder_analysis):
|
||||
- Code folders: 2 docs each (API.md + README.md)
|
||||
- Navigation folders: 1 doc each (README.md only)
|
||||
2. Apply grouping algorithm with ≤10 docs constraint:
|
||||
- Try grouping 2 directories, calculate total docs
|
||||
- If total ≤10 docs: create group
|
||||
- If total >10 docs: split to 1 dir/group or subdivide
|
||||
- If single dir >10 docs: split by subdirectories
|
||||
3. Use **Edit tool** to update `doc-planning-data.json` adding groups field:
|
||||
```json
|
||||
"groups": {
|
||||
"count": 3,
|
||||
"assignments": [
|
||||
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 5},
|
||||
{"group_id": "002", "directories": ["lib/core"], "doc_count": 6},
|
||||
{"group_id": "003", "directories": ["lib/helpers"], "doc_count": 3}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Task ID Calculation**:
|
||||
```bash
|
||||
group_count=$(jq '.groups.count' .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json)
|
||||
readme_id=$((group_count + 1)) # Next ID after groups
|
||||
arch_id=$((group_count + 2))
|
||||
api_id=$((group_count + 3))
|
||||
```
|
||||
|
||||
### Phase 5: Generate Task JSONs
|
||||
|
||||
**CLI Strategy**:
|
||||
|
||||
| Mode | cli_execute | Placement | CLI MODE | Approval Flag | Agent Role |
|
||||
|------|-------------|-----------|----------|---------------|------------|
|
||||
| **Agent** | false | pre_analysis | analysis | (none) | Generate docs in implementation_approach |
|
||||
| **CLI** | true | implementation_approach | write | --mode write | Execute CLI commands, validate output |
|
||||
|
||||
**Command Patterns**:
|
||||
- Gemini/Qwen: `ccw cli -p "..." --tool gemini --mode analysis --cd dir`
|
||||
- CLI Mode: `ccw cli -p "..." --tool gemini --mode write --cd dir`
|
||||
- Codex: `ccw cli -p "..." --tool codex --mode write --cd dir`
|
||||
|
||||
**Generation Process**:
|
||||
1. Read configuration values (tool, cli_execute, mode) from workflow-session.json
|
||||
2. Read group assignments from doc-planning-data.json
|
||||
3. Generate Level 1 tasks (IMPL-001 to IMPL-N, one per group)
|
||||
4. Generate Level 2+ tasks if mode=full (README, ARCHITECTURE, HTTP API)
|
||||
|
||||
## Task Templates
|
||||
|
||||
### Level 1: Module Trees Group Task (Unified)
|
||||
|
||||
**Execution Model**: Each task processes assigned directory group (max 2 directories) using pre-analyzed data from Phase 2.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${group_number}",
|
||||
"title": "Document Module Trees Group ${group_number}",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "docs-tree-group",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini",
|
||||
"cli_execute": false,
|
||||
"group_number": "${group_number}",
|
||||
"total_groups": "${total_groups}"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Process directories from group ${group_number} in doc-planning-data.json",
|
||||
"Generate docs to .workflow/docs/${project_name}/ (mirrored structure)",
|
||||
"Code folders: API.md + README.md; Navigation folders: README.md only",
|
||||
"Use pre-analyzed data from Phase 2 (no redundant analysis)"
|
||||
],
|
||||
"focus_paths": ["${group_dirs_from_json}"],
|
||||
"precomputed_data": {
|
||||
"phase2_analysis": "${session_dir}/.process/doc-planning-data.json"
|
||||
}
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_precomputed_data",
|
||||
"action": "Load Phase 2 analysis and extract group directories",
|
||||
"commands": [
|
||||
"bash(cat ${session_dir}/.process/doc-planning-data.json)",
|
||||
"bash(jq '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories' ${session_dir}/.process/doc-planning-data.json)"
|
||||
],
|
||||
"output_to": "phase2_context",
|
||||
"note": "Single JSON file contains all Phase 2 analysis results"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate documentation for assigned directory group",
|
||||
"description": "Process directories in Group ${group_number} using pre-analyzed data",
|
||||
"modification_points": [
|
||||
"Read group directories from [phase2_context].groups.assignments[${group_number}].directories",
|
||||
"For each directory: parse folder types from folder_analysis, parse structure from unified_analysis",
|
||||
"Map source_path to .workflow/docs/${project_name}/{path}",
|
||||
"Generate API.md for code folders, README.md for all folders",
|
||||
"Preserve user modifications from [phase2_context].existing_docs.content"
|
||||
],
|
||||
"logic_flow": [
|
||||
"phase2 = parse([phase2_context])",
|
||||
"dirs = phase2.groups.assignments[${group_number}].directories",
|
||||
"for dir in dirs:",
|
||||
" folder_info = find(dir, phase2.folder_analysis)",
|
||||
" outline = find(dir, phase2.unified_analysis)",
|
||||
" if folder_info.type == 'code': generate API.md + README.md",
|
||||
" elif folder_info.type == 'navigation': generate README.md only",
|
||||
" write to .workflow/docs/${project_name}/{dir}/"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "group_module_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/*/API.md",
|
||||
".workflow/docs/${project_name}/*/README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**CLI Execute Mode Note**: When `cli_execute=true`, add Step 2 in `implementation_approach`:
|
||||
```json
|
||||
{
|
||||
"step": 2,
|
||||
"title": "Batch generate documentation via CLI",
|
||||
"command": "ccw cli -p 'PURPOSE: Generate module docs\\nTASK: Create documentation\\nMODE: write\\nCONTEXT: @**/* [phase2_context]\\nEXPECTED: API.md and README.md\\nRULES: Mirror structure' --tool gemini --mode write --cd ${dirs_from_group}",
|
||||
"depends_on": [1],
|
||||
"output": "generated_docs"
|
||||
}
|
||||
```
|
||||
|
||||
### Level 2: Project README Task
|
||||
|
||||
**Task ID**: `IMPL-${readme_id}` (where `readme_id = group_count + 1`)
|
||||
**Dependencies**: Depends on all Level 1 tasks completing.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${readme_id}",
|
||||
"title": "Generate Project README",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-001", "...", "IMPL-${group_count}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_existing_readme",
|
||||
"command": "bash(cat .workflow/docs/${project_name}/README.md 2>/dev/null || echo 'No existing README')",
|
||||
"output_to": "existing_readme"
|
||||
},
|
||||
{
|
||||
"step": "load_module_docs",
|
||||
"command": "bash(find .workflow/docs/${project_name} -type f -name '*.md' ! -path '.workflow/docs/${project_name}/README.md' ! -path '.workflow/docs/${project_name}/ARCHITECTURE.md' ! -path '.workflow/docs/${project_name}/EXAMPLES.md' ! -path '.workflow/docs/${project_name}/api/*' | xargs cat)",
|
||||
"output_to": "all_module_docs"
|
||||
},
|
||||
{
|
||||
"step": "analyze_project",
|
||||
"command": "bash(ccw cli -p \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\" --tool gemini --mode analysis)",
|
||||
"output_to": "project_outline"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate project README",
|
||||
"description": "Generate project README with navigation links while preserving user modifications",
|
||||
"modification_points": [
|
||||
"Parse [project_outline] and [all_module_docs]",
|
||||
"Generate README structure with navigation links",
|
||||
"Preserve [existing_readme] user modifications"
|
||||
],
|
||||
"logic_flow": ["Parse data", "Generate README with navigation", "Preserve modifications"],
|
||||
"depends_on": [],
|
||||
"output": "project_readme"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/README.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 3: Architecture & Examples Documentation Task
|
||||
|
||||
**Task ID**: `IMPL-${arch_id}` (where `arch_id = group_count + 2`)
|
||||
**Dependencies**: Depends on Level 2 (Project README).
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${arch_id}",
|
||||
"title": "Generate Architecture & Examples Documentation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-${readme_id}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{"step": "load_existing_docs", "command": "bash(cat .workflow/docs/${project_name}/{ARCHITECTURE,EXAMPLES}.md 2>/dev/null || echo 'No existing docs')", "output_to": "existing_arch_examples"},
|
||||
{"step": "load_all_docs", "command": "bash(cat .workflow/docs/${project_name}/README.md && find .workflow/docs/${project_name} -type f -name '*.md' ! -path '*/README.md' ! -path '*/ARCHITECTURE.md' ! -path '*/EXAMPLES.md' ! -path '*/api/*' | xargs cat)", "output_to": "all_docs"},
|
||||
{"step": "analyze_architecture", "command": "bash(ccw cli -p \"PURPOSE: Analyze system architecture\\nTASK: Synthesize architectural overview and examples\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture + Examples outline\" --tool gemini --mode analysis)", "output_to": "arch_examples_outline"}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate architecture and examples documentation",
|
||||
"modification_points": [
|
||||
"Parse [arch_examples_outline] and [all_docs]",
|
||||
"Generate ARCHITECTURE.md (system design, patterns)",
|
||||
"Generate EXAMPLES.md (code snippets, usage)",
|
||||
"Preserve [existing_arch_examples] modifications"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "arch_examples_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/ARCHITECTURE.md", ".workflow/docs/${project_name}/EXAMPLES.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 4: HTTP API Documentation Task (Optional)
|
||||
|
||||
**Task ID**: `IMPL-${api_id}` (where `api_id = group_count + 3`)
|
||||
**Dependencies**: Depends on Level 3.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${api_id}",
|
||||
"title": "Generate HTTP API Documentation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-${arch_id}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{"step": "discover_api", "command": "bash(rg 'router\\.| @(Get|Post)' -g '*.{ts,js}')", "output_to": "endpoint_discovery"},
|
||||
{"step": "load_existing_api", "command": "bash(cat .workflow/docs/${project_name}/api/README.md 2>/dev/null || echo 'No existing API docs')", "output_to": "existing_api_docs"},
|
||||
{"step": "analyze_api", "command": "bash(ccw cli -p \"PURPOSE: Document HTTP API\\nTASK: Analyze endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\" --tool gemini --mode analysis)", "output_to": "api_outline"}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate HTTP API documentation",
|
||||
"modification_points": [
|
||||
"Parse [api_outline] and [endpoint_discovery]",
|
||||
"Document endpoints, request/response formats",
|
||||
"Preserve [existing_api_docs] modifications"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "api_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/api/README.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Session Structure
|
||||
|
||||
**Unified Structure** (single JSON replaces multiple text files):
|
||||
|
||||
```
|
||||
.workflow/active/
|
||||
└── WFS-docs-{timestamp}/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── IMPL_PLAN.md
|
||||
├── TODO_LIST.md
|
||||
├── .process/
|
||||
│ └── doc-planning-data.json # All Phase 2 analysis data (replaces 7+ files)
|
||||
└── .task/
|
||||
├── IMPL-001.json # Small: all modules | Large: group 1
|
||||
├── IMPL-00N.json # (Large only: groups 2-N)
|
||||
├── IMPL-{N+1}.json # README (full mode)
|
||||
├── IMPL-{N+2}.json # ARCHITECTURE+EXAMPLES (full mode)
|
||||
└── IMPL-{N+3}.json # HTTP API (optional)
|
||||
```
|
||||
|
||||
**doc-planning-data.json Structure**:
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"generated_at": "2025-11-03T16:41:06+08:00",
|
||||
"project_name": "Claude_dms3",
|
||||
"project_root": "/d/Claude_dms3"
|
||||
},
|
||||
"folder_analysis": [
|
||||
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2},
|
||||
{"path": "./src/utils", "type": "navigation", "code_count": 0, "dirs_count": 4}
|
||||
],
|
||||
"top_level_dirs": ["src/modules", "src/utils", "lib/core"],
|
||||
"existing_docs": {
|
||||
"file_list": [".workflow/docs/project/src/core/API.md"],
|
||||
"content": "... concatenated existing docs ..."
|
||||
},
|
||||
"unified_analysis": [
|
||||
{"module_path": "./src/core", "outline_summary": "Core functionality"}
|
||||
],
|
||||
"groups": {
|
||||
"count": 4,
|
||||
"assignments": [
|
||||
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 6},
|
||||
{"group_id": "002", "directories": ["lib/core", "lib/helpers"], "doc_count": 7}
|
||||
]
|
||||
},
|
||||
"statistics": {
|
||||
"total": 15,
|
||||
"code": 8,
|
||||
"navigation": 7,
|
||||
"top_level": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Workflow Session Structure** (workflow-session.json):
|
||||
```json
|
||||
{
|
||||
"session_id": "WFS-docs-{timestamp}",
|
||||
"project": "{project_name} documentation",
|
||||
"status": "planning",
|
||||
"timestamp": "2024-01-20T14:30:22+08:00",
|
||||
"path": ".",
|
||||
"target_path": "/path/to/project",
|
||||
"project_root": "/path/to/project",
|
||||
"project_name": "{project_name}",
|
||||
"mode": "full",
|
||||
"tool": "gemini",
|
||||
"cli_execute": false,
|
||||
"update_mode": "update",
|
||||
"existing_docs": 5,
|
||||
"analysis": {
|
||||
"total": "15",
|
||||
"code": "8",
|
||||
"navigation": "7",
|
||||
"top_level": "3"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Generated Documentation
|
||||
|
||||
**Structure mirrors project source directories under project-specific folder**:
|
||||
|
||||
```
|
||||
.workflow/docs/
|
||||
└── {project_name}/ # Project-specific root
|
||||
├── src/ # Mirrors src/ directory
|
||||
│ ├── modules/
|
||||
│ │ ├── README.md # Navigation
|
||||
│ │ ├── auth/
|
||||
│ │ │ ├── API.md # API signatures
|
||||
│ │ │ ├── README.md # Module docs
|
||||
│ │ │ └── middleware/
|
||||
│ │ │ ├── API.md
|
||||
│ │ │ └── README.md
|
||||
│ │ └── api/
|
||||
│ │ ├── API.md
|
||||
│ │ └── README.md
|
||||
│ └── utils/
|
||||
│ └── README.md
|
||||
├── lib/ # Mirrors lib/ directory
|
||||
│ └── core/
|
||||
│ ├── API.md
|
||||
│ └── README.md
|
||||
├── README.md # Project root
|
||||
├── ARCHITECTURE.md # System design
|
||||
├── EXAMPLES.md # Usage examples
|
||||
└── api/ # Optional
|
||||
└── README.md # HTTP API reference
|
||||
```
|
||||
|
||||
## Execution Commands
|
||||
|
||||
```bash
|
||||
# Execute entire workflow (auto-discovers active session)
|
||||
/workflow:execute
|
||||
|
||||
# Or specify session
|
||||
/workflow:execute --resume-session="WFS-docs-yyyymmdd-hhmmss"
|
||||
|
||||
# Individual task execution
|
||||
/task:execute IMPL-001
|
||||
```
|
||||
|
||||
## Template Reference
|
||||
|
||||
**Available Templates** (`~/.claude/workflows/cli-templates/prompts/documentation/`):
|
||||
- `api.txt`: Code API (Part A) + HTTP API (Part B)
|
||||
- `module-readme.txt`: Module purpose, usage, dependencies
|
||||
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
||||
- `project-readme.txt`: Project overview, getting started, navigation
|
||||
- `project-architecture.txt`: System structure, module map, design patterns
|
||||
- `project-examples.txt`: End-to-end usage examples
|
||||
|
||||
## Execution Mode Summary
|
||||
|
||||
| Mode | CLI Placement | CLI MODE | Approval Flag | Agent Role |
|
||||
|------|---------------|----------|---------------|------------|
|
||||
| **Agent (default)** | pre_analysis | analysis | (none) | Generates documentation content |
|
||||
| **CLI (--cli-execute)** | implementation_approach | write | --mode write | Executes CLI commands, validates output |
|
||||
|
||||
**Execution Flow**:
|
||||
- **Phase 2**: Unified analysis once, results in `.process/`
|
||||
- **Phase 4**: Dynamic grouping (max 2 dirs per group)
|
||||
- **Level 1**: Parallel processing for module tree groups
|
||||
- **Level 2+**: Sequential execution for project-level docs
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:execute` - Execute documentation tasks
|
||||
- `/workflow:status` - View task progress
|
||||
- `/workflow:session:complete` - Mark session complete
|
||||
@@ -1,182 +0,0 @@
|
||||
---
|
||||
name: load-skill-memory
|
||||
description: Activate SKILL package (auto-detect from paths/keywords or manual) and intelligently load documentation based on task intent keywords
|
||||
argument-hint: "[skill_name] \"task intent description\""
|
||||
allowed-tools: Bash(*), Read(*), Skill(*)
|
||||
---
|
||||
|
||||
# Memory Load SKILL Command (/memory:load-skill-memory)
|
||||
|
||||
## 1. Overview
|
||||
|
||||
The `memory:load-skill-memory` command **activates SKILL package** (auto-detect from task or manual specification) and intelligently loads documentation based on user's task intent. The system automatically determines which documentation files to read based on the intent description.
|
||||
|
||||
**Core Philosophy**:
|
||||
- **Flexible Activation**: Auto-detect skill from task description/paths, or user explicitly specifies
|
||||
- **Intent-Driven Loading**: System analyzes task intent to determine documentation scope
|
||||
- **Intelligent Selection**: Automatically chooses appropriate documentation level and modules
|
||||
- **Direct Context Loading**: Loads selected documentation into conversation memory
|
||||
|
||||
**When to Use**:
|
||||
- Manually activate a known SKILL package for a specific task
|
||||
- Load SKILL context when system hasn't auto-triggered it
|
||||
- Force reload SKILL documentation with specific intent focus
|
||||
|
||||
**Note**: Normal SKILL activation happens automatically via description triggers or path mentions (system extracts skill name from file paths for intelligent triggering). Use this command only when manual activation is needed.
|
||||
|
||||
## 2. Parameters
|
||||
|
||||
- `[skill_name]` (Optional): Name of SKILL package to activate
|
||||
- If omitted: System auto-detects from task description or file paths
|
||||
- If specified: Direct activation of named SKILL package
|
||||
- Example: `my_project`, `api_service`
|
||||
- Must match directory name under `.claude/skills/`
|
||||
|
||||
- `"task intent description"` (Required): Description of what you want to do
|
||||
- Used for both: auto-detection (if skill_name omitted) and documentation scope selection
|
||||
- **Analysis tasks**: "分析builder pattern实现", "理解参数系统架构"
|
||||
- **Modification tasks**: "修改workflow逻辑", "增强thermal template功能"
|
||||
- **Learning tasks**: "学习接口设计模式", "了解测试框架使用"
|
||||
- **With paths**: "修改D:\projects\my_project\src\auth.py的认证逻辑" (auto-extracts `my_project`)
|
||||
|
||||
## 3. Execution Flow
|
||||
|
||||
### Step 1: Determine SKILL Name (if not provided)
|
||||
|
||||
**Auto-Detection Strategy** (when skill_name parameter is omitted):
|
||||
1. **Path Extraction**: Scan task description for file paths
|
||||
- Extract potential project names from path segments
|
||||
- Example: `"修改D:\projects\my_project\src\auth.py"` → extracts `my_project`
|
||||
2. **Keyword Matching**: Match task keywords against SKILL descriptions
|
||||
- Search for project-specific terms, domain keywords
|
||||
3. **Validation**: Check if extracted name matches `.claude/skills/{skill_name}/`
|
||||
|
||||
**Result**: Either uses provided skill_name or auto-detected name for activation
|
||||
|
||||
### Step 2: Activate SKILL and Analyze Intent
|
||||
|
||||
**Activate SKILL Package**:
|
||||
```javascript
|
||||
Skill(command: "${skill_name}") // Uses provided or auto-detected name
|
||||
```
|
||||
|
||||
**What Happens After Activation**:
|
||||
1. If SKILL exists in memory: System reads `.claude/skills/${skill_name}/SKILL.md`
|
||||
2. If SKILL not found in memory: Error - SKILL package doesn't exist
|
||||
3. SKILL description triggers are loaded into memory
|
||||
4. Progressive loading mechanism becomes available
|
||||
5. Documentation structure is now accessible
|
||||
|
||||
**Intent Analysis**:
|
||||
Based on task intent description, system determines:
|
||||
- **Action type**: analyzing, modifying, learning
|
||||
- **Scope**: specific module, architecture overview, complete system
|
||||
- **Depth**: quick reference, detailed API, full documentation
|
||||
|
||||
### Step 3: Intelligent Documentation Loading
|
||||
|
||||
**Loading Strategy**:
|
||||
|
||||
The system automatically selects documentation based on intent keywords:
|
||||
|
||||
1. **Quick Understanding** ("了解", "快速理解", "什么是"):
|
||||
- Load: Level 0 (README.md only, ~2K tokens)
|
||||
- Use case: Quick overview of capabilities
|
||||
|
||||
2. **Specific Module Analysis** ("分析XXX模块", "理解XXX实现"):
|
||||
- Load: Module-specific README.md + API.md (~5K tokens)
|
||||
- Use case: Deep dive into specific component
|
||||
|
||||
3. **Architecture Review** ("架构", "设计模式", "整体结构"):
|
||||
- Load: README.md + ARCHITECTURE.md (~10K tokens)
|
||||
- Use case: System design understanding
|
||||
|
||||
4. **Implementation/Modification** ("修改", "增强", "实现"):
|
||||
- Load: Relevant module docs + EXAMPLES.md (~15K tokens)
|
||||
- Use case: Code modification with examples
|
||||
|
||||
5. **Comprehensive Learning** ("学习", "完整了解", "深入理解"):
|
||||
- Load: Level 3 (All documentation, ~40K tokens)
|
||||
- Use case: Complete system mastery
|
||||
|
||||
**Documentation Loaded into Memory**:
|
||||
After loading, the selected documentation content is available in conversation memory for subsequent operations.
|
||||
|
||||
## 4. Usage Examples
|
||||
|
||||
### Example 1: Manual Specification
|
||||
|
||||
**User Command**:
|
||||
```bash
|
||||
/memory:load-skill-memory my_project "修改认证模块增加OAuth支持"
|
||||
```
|
||||
|
||||
**Execution**:
|
||||
```javascript
|
||||
// Step 1: Use provided skill_name
|
||||
skill_name = "my_project" // Directly from parameter
|
||||
|
||||
// Step 2: Activate SKILL
|
||||
Skill(command: "my_project")
|
||||
|
||||
// Step 3: Intent Analysis
|
||||
Keywords: ["修改", "认证模块", "增加", "OAuth"]
|
||||
Action: modifying (implementation)
|
||||
Scope: auth module + examples
|
||||
|
||||
// Load documentation based on intent
|
||||
Read(.workflow/docs/my_project/auth/README.md)
|
||||
Read(.workflow/docs/my_project/auth/API.md)
|
||||
Read(.workflow/docs/my_project/EXAMPLES.md)
|
||||
```
|
||||
|
||||
### Example 2: Auto-Detection from Path
|
||||
|
||||
**User Command**:
|
||||
```bash
|
||||
/memory:load-skill-memory "修改D:\projects\my_project\src\services\api.py的接口逻辑"
|
||||
```
|
||||
|
||||
**Execution**:
|
||||
```javascript
|
||||
// Step 1: Auto-detect skill_name from path
|
||||
Path detected: "D:\projects\my_project\src\services\api.py"
|
||||
Extracted: "my_project"
|
||||
Validated: .claude/skills/my_project/ exists ✓
|
||||
skill_name = "my_project"
|
||||
|
||||
// Step 2: Activate SKILL
|
||||
Skill(command: "my_project")
|
||||
|
||||
// Step 3: Intent Analysis
|
||||
Keywords: ["修改", "services", "接口逻辑"]
|
||||
Action: modifying (implementation)
|
||||
Scope: services module + examples
|
||||
|
||||
// Load documentation based on intent
|
||||
Read(.workflow/docs/my_project/services/README.md)
|
||||
Read(.workflow/docs/my_project/services/API.md)
|
||||
Read(.workflow/docs/my_project/EXAMPLES.md)
|
||||
```
|
||||
|
||||
## 5. Intent Keyword Mapping
|
||||
|
||||
**Quick Reference**:
|
||||
- **Triggers**: "了解", "快速", "什么是", "简介"
|
||||
- **Loads**: README.md only (~2K)
|
||||
|
||||
**Module-Specific**:
|
||||
- **Triggers**: "XXX模块", "XXX组件", "分析XXX"
|
||||
- **Loads**: Module README + API (~5K)
|
||||
|
||||
**Architecture**:
|
||||
- **Triggers**: "架构", "设计", "整体结构", "系统设计"
|
||||
- **Loads**: README + ARCHITECTURE (~10K)
|
||||
|
||||
**Implementation**:
|
||||
- **Triggers**: "修改", "增强", "实现", "开发", "集成"
|
||||
- **Loads**: Relevant module + EXAMPLES (~15K)
|
||||
|
||||
**Comprehensive**:
|
||||
- **Triggers**: "完整", "深入", "全面", "学习整个"
|
||||
- **Loads**: All documentation (~40K)
|
||||
@@ -1,525 +0,0 @@
|
||||
---
|
||||
name: skill-memory
|
||||
description: 4-phase autonomous orchestrator: check docs → /memory:docs planning → /workflow:execute → generate SKILL.md with progressive loading index (skips phases 2-3 if docs exist)
|
||||
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--regenerate] [--mode <full|partial>] [--cli-execute]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
# Memory SKILL Package Generator
|
||||
|
||||
## Orchestrator Role
|
||||
|
||||
**Pure Orchestrator**: Execute documentation generation workflow, then generate SKILL.md index. Does NOT create task JSON files.
|
||||
|
||||
**Auto-Continue Workflow**: This command runs **fully autonomously** once triggered. Each phase completes and automatically triggers the next phase without user interaction.
|
||||
|
||||
**Execution Paths**:
|
||||
- **Full Path**: All 4 phases (no existing docs OR `--regenerate` specified)
|
||||
- **Skip Path**: Phase 1 → Phase 4 (existing docs found AND no `--regenerate` flag)
|
||||
- **Phase 4 Always Executes**: SKILL.md index is never skipped, always generated or updated
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 execution
|
||||
2. **No Task JSON**: This command does not create task JSON files - delegates to /memory:docs
|
||||
3. **Parse Every Output**: Extract required data from each command output (session_id, task_count, file paths)
|
||||
4. **Auto-Continue**: After completing each phase, update TodoWrite and immediately execute next phase
|
||||
5. **Track Progress**: Update TodoWrite after EVERY phase completion before starting next phase
|
||||
6. **Direct Generation**: Phase 4 directly generates SKILL.md using Write tool
|
||||
7. **No Manual Steps**: User should never be prompted for decisions between phases
|
||||
|
||||
---
|
||||
|
||||
## 4-Phase Execution
|
||||
|
||||
### Phase 1: Prepare Arguments
|
||||
|
||||
**Goal**: Parse command arguments and check existing documentation
|
||||
|
||||
**Step 1: Get Target Path and Project Name**
|
||||
```bash
|
||||
# Get current directory (or use provided path)
|
||||
bash(pwd)
|
||||
|
||||
# Get project name from directory
|
||||
bash(basename "$(pwd)")
|
||||
|
||||
# Get project root
|
||||
bash(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- `target_path`: `/d/my_project`
|
||||
- `project_name`: `my_project`
|
||||
- `project_root`: `/d/my_project`
|
||||
|
||||
**Step 2: Set Default Parameters**
|
||||
```bash
|
||||
# Default values (use these unless user specifies otherwise):
|
||||
# - tool: "gemini"
|
||||
# - mode: "full"
|
||||
# - regenerate: false (no --regenerate flag)
|
||||
# - cli_execute: false (no --cli-execute flag)
|
||||
```
|
||||
|
||||
**Step 3: Check Existing Documentation**
|
||||
```bash
|
||||
# Check if docs directory exists
|
||||
bash(test -d .workflow/docs/my_project && echo "exists" || echo "not_exists")
|
||||
|
||||
# Count existing documentation files
|
||||
bash(find .workflow/docs/my_project -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- `docs_exists`: `exists` or `not_exists`
|
||||
- `existing_docs`: `5` (or `0` if no docs)
|
||||
|
||||
**Step 4: Determine Execution Path**
|
||||
|
||||
**Decision Logic**:
|
||||
```javascript
|
||||
if (existing_docs > 0 && !regenerate_flag) {
|
||||
// Documentation exists and no regenerate flag
|
||||
SKIP_DOCS_GENERATION = true
|
||||
message = "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
} else if (regenerate_flag) {
|
||||
// Force regeneration: delete existing docs
|
||||
bash(rm -rf .workflow/docs/my_project 2>/dev/null || true)
|
||||
SKIP_DOCS_GENERATION = false
|
||||
message = "Regenerating documentation from scratch."
|
||||
} else {
|
||||
// No existing docs
|
||||
SKIP_DOCS_GENERATION = false
|
||||
message = "No existing documentation found, generating new documentation."
|
||||
}
|
||||
```
|
||||
|
||||
**Summary Variables**:
|
||||
- `PROJECT_NAME`: `my_project`
|
||||
- `TARGET_PATH`: `/d/my_project`
|
||||
- `DOCS_PATH`: `.workflow/docs/my_project`
|
||||
- `TOOL`: `gemini` (default) or user-specified
|
||||
- `MODE`: `full` (default) or user-specified
|
||||
- `CLI_EXECUTE`: `false` (default) or `true` if --cli-execute flag
|
||||
- `REGENERATE`: `false` (default) or `true` if --regenerate flag
|
||||
- `EXISTING_DOCS`: Count of existing documentation files
|
||||
- `SKIP_DOCS_GENERATION`: `true` if skipping Phase 2/3, `false` otherwise
|
||||
|
||||
**Completion & TodoWrite**:
|
||||
- If `SKIP_DOCS_GENERATION = true`: Mark phase 1 completed, phase 2&3 completed (skipped), phase 4 in_progress
|
||||
- If `SKIP_DOCS_GENERATION = false`: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**Next Action**:
|
||||
- If skipping: Display skip message → Jump to Phase 4 (SKILL.md generation)
|
||||
- If not skipping: Display preparation results → Continue to Phase 2 (documentation planning)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Call /memory:docs
|
||||
|
||||
**Skip Condition**: This phase is **skipped if SKIP_DOCS_GENERATION = true** (documentation already exists without --regenerate flag)
|
||||
|
||||
**Goal**: Trigger documentation generation workflow
|
||||
|
||||
**Command**:
|
||||
```bash
|
||||
SlashCommand(command="/memory:docs [targetPath] --tool [tool] --mode [mode] [--cli-execute]")
|
||||
```
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
/memory:docs /d/my_app --tool gemini --mode full
|
||||
/memory:docs /d/my_app --tool gemini --mode full --cli-execute
|
||||
```
|
||||
|
||||
**Note**: The `--regenerate` flag is handled in Phase 1 by deleting existing documentation. This command always calls `/memory:docs` without the regenerate flag, relying on docs.md's built-in update detection.
|
||||
|
||||
**Parse Output**:
|
||||
- Extract session ID: `WFS-docs-[timestamp]` (store as `docsSessionId`)
|
||||
- Extract task count (store as `taskCount`)
|
||||
|
||||
**Completion Criteria**:
|
||||
- `/memory:docs` command executed successfully
|
||||
- Session ID extracted and stored
|
||||
- Task count retrieved
|
||||
- Task files created in `.workflow/[docsSessionId]/.task/`
|
||||
- workflow-session.json exists
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
**Next Action**: Display docs planning results (session ID, task count) → Auto-continue to Phase 3
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Execute Documentation Generation
|
||||
|
||||
**Skip Condition**: This phase is **skipped if SKIP_DOCS_GENERATION = true** (documentation already exists without --regenerate flag)
|
||||
|
||||
**Goal**: Execute documentation generation tasks
|
||||
|
||||
**Command**:
|
||||
```bash
|
||||
SlashCommand(command="/workflow:execute")
|
||||
```
|
||||
|
||||
**Note**: `/workflow:execute` automatically discovers active session from Phase 2
|
||||
|
||||
**Completion Criteria**:
|
||||
- `/workflow:execute` command executed successfully
|
||||
- Documentation files generated in `.workflow/docs/[projectName]/`
|
||||
- All tasks marked as completed in session
|
||||
- At minimum: module documentation files exist (API.md and/or README.md)
|
||||
- For full mode: Project README, ARCHITECTURE, EXAMPLES files generated
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
|
||||
|
||||
**Next Action**: Display execution results (file count, module count) → Auto-continue to Phase 4
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Generate SKILL.md Index
|
||||
|
||||
**Note**: This phase is **NEVER skipped** - it always executes to generate or update the SKILL index.
|
||||
|
||||
**Step 1: Read Key Files** (Use Read tool)
|
||||
- `.workflow/docs/{project_name}/README.md` (required)
|
||||
- `.workflow/docs/{project_name}/ARCHITECTURE.md` (optional)
|
||||
|
||||
**Step 2: Discover Structure**
|
||||
```bash
|
||||
bash(find .workflow/docs/{project_name} -name "*.md" | sed 's|.workflow/docs/{project_name}/||' | awk -F'/' '{if(NF>=2) print $1"/"$2}' | sort -u)
|
||||
```
|
||||
|
||||
**Step 3: Generate Intelligent Description**
|
||||
|
||||
Extract from README + structure: Function (capabilities), Modules (names), Keywords (API/CLI/auth/etc.)
|
||||
|
||||
**Format**: `{Project} {core capabilities} (located at {project_path}). Load this SKILL when analyzing, modifying, or learning about {domain_description} or files under this path, especially when no relevant context exists in memory.`
|
||||
|
||||
**Key Elements**:
|
||||
- **Path Reference**: Use `TARGET_PATH` from Phase 1 for precise location identification
|
||||
- **Domain Description**: Extract human-readable domain/feature area from README (e.g., "workflow management", "thermal modeling")
|
||||
- **Trigger Optimization**: Include project path, emphasize "especially when no relevant context exists in memory"
|
||||
- **Action Coverage**: analyzing (分析), modifying (修改), learning (了解)
|
||||
|
||||
**Example**: "Workflow orchestration system with CLI tools and documentation generation (located at /d/Claude_dms3). Load this SKILL when analyzing, modifying, or learning about workflow management or files under this path, especially when no relevant context exists in memory."
|
||||
|
||||
**Step 4: Write SKILL.md** (Use Write tool)
|
||||
```bash
|
||||
bash(mkdir -p .claude/skills/{project_name})
|
||||
```
|
||||
|
||||
`.claude/skills/{project_name}/SKILL.md`:
|
||||
```yaml
|
||||
---
|
||||
name: {project_name}
|
||||
description: {intelligent description from Step 3}
|
||||
version: 1.0.0
|
||||
---
|
||||
# {Project Name} SKILL Package
|
||||
|
||||
## Documentation: `../../../.workflow/docs/{project_name}/`
|
||||
|
||||
## Progressive Loading
|
||||
### Level 0: Quick Start (~2K)
|
||||
- [README](../../../.workflow/docs/{project_name}/README.md)
|
||||
### Level 1: Core Modules (~8K)
|
||||
{Module READMEs}
|
||||
### Level 2: Complete (~25K)
|
||||
All modules + [Architecture](../../../.workflow/docs/{project_name}/ARCHITECTURE.md)
|
||||
### Level 3: Deep Dive (~40K)
|
||||
Everything + [Examples](../../../.workflow/docs/{project_name}/EXAMPLES.md)
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- SKILL.md file created at `.claude/skills/{project_name}/SKILL.md`
|
||||
- Intelligent description generated from documentation
|
||||
- Progressive loading levels (0-3) properly structured
|
||||
- Module index includes all documented modules
|
||||
- All file references use relative paths
|
||||
|
||||
**TodoWrite**: Mark phase 4 completed
|
||||
|
||||
**Final Action**: Report completion summary to user
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
SKILL Package Generation Complete
|
||||
|
||||
Project: {project_name}
|
||||
Documentation: .workflow/docs/{project_name}/ ({doc_count} files)
|
||||
SKILL Index: .claude/skills/{project_name}/SKILL.md
|
||||
|
||||
Generated:
|
||||
- {task_count} documentation tasks completed
|
||||
- SKILL.md with progressive loading (4 levels)
|
||||
- Module index with {module_count} modules
|
||||
|
||||
Usage:
|
||||
- Load Level 0: Quick project overview (~2K tokens)
|
||||
- Load Level 1: Core modules (~8K tokens)
|
||||
- Load Level 2: Complete docs (~25K tokens)
|
||||
- Load Level 3: Everything (~40K tokens)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Critical Rules
|
||||
|
||||
1. **No User Prompts Between Phases**: Never ask user questions or wait for input between phases
|
||||
2. **Immediate Phase Transition**: After TodoWrite update, immediately execute next phase command
|
||||
3. **Status-Driven Execution**: Check TodoList status after each phase:
|
||||
- If next task is "pending" → Mark it "in_progress" and execute
|
||||
- If all tasks are "completed" → Report final summary
|
||||
4. **Phase Completion Pattern**:
|
||||
```
|
||||
Phase N completes → Update TodoWrite (N=completed, N+1=in_progress) → Execute Phase N+1
|
||||
```
|
||||
|
||||
### TodoWrite Patterns
|
||||
|
||||
#### Initialization (Before Phase 1)
|
||||
|
||||
**FIRST ACTION**: Create TodoList with all 4 phases
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "in_progress", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "pending", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "pending", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
```
|
||||
|
||||
**SECOND ACTION**: Execute Phase 1 immediately
|
||||
|
||||
#### Full Path (SKIP_DOCS_GENERATION = false)
|
||||
|
||||
**After Phase 1**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "in_progress", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "pending", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 2
|
||||
```
|
||||
|
||||
**After Phase 2**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "in_progress", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 3
|
||||
```
|
||||
|
||||
**After Phase 3**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 4
|
||||
```
|
||||
|
||||
**After Phase 4**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Report completion summary to user
|
||||
```
|
||||
|
||||
#### Skip Path (SKIP_DOCS_GENERATION = true)
|
||||
|
||||
**After Phase 1** (detects existing docs, skips Phase 2 & 3):
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Display skip message: "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
// Jump directly to Phase 4
|
||||
```
|
||||
|
||||
**After Phase 4**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Report completion summary to user
|
||||
```
|
||||
|
||||
### Execution Flow Diagrams
|
||||
|
||||
#### Full Path Flow
|
||||
```
|
||||
User triggers command
|
||||
↓
|
||||
[TodoWrite] Initialize 4 phases (Phase 1 = in_progress)
|
||||
↓
|
||||
[Execute] Phase 1: Parse arguments
|
||||
↓
|
||||
[TodoWrite] Phase 1 = completed, Phase 2 = in_progress
|
||||
↓
|
||||
[Execute] Phase 2: Call /memory:docs
|
||||
↓
|
||||
[TodoWrite] Phase 2 = completed, Phase 3 = in_progress
|
||||
↓
|
||||
[Execute] Phase 3: Call /workflow:execute
|
||||
↓
|
||||
[TodoWrite] Phase 3 = completed, Phase 4 = in_progress
|
||||
↓
|
||||
[Execute] Phase 4: Generate SKILL.md
|
||||
↓
|
||||
[TodoWrite] Phase 4 = completed
|
||||
↓
|
||||
[Report] Display completion summary
|
||||
```
|
||||
|
||||
#### Skip Path Flow
|
||||
```
|
||||
User triggers command
|
||||
↓
|
||||
[TodoWrite] Initialize 4 phases (Phase 1 = in_progress)
|
||||
↓
|
||||
[Execute] Phase 1: Parse arguments, detect existing docs
|
||||
↓
|
||||
[TodoWrite] Phase 1 = completed, Phase 2&3 = completed (skipped), Phase 4 = in_progress
|
||||
↓
|
||||
[Display] Skip message: "Documentation already exists, skipping Phase 2 and Phase 3"
|
||||
↓
|
||||
[Execute] Phase 4: Generate SKILL.md (always runs)
|
||||
↓
|
||||
[TodoWrite] Phase 4 = completed
|
||||
↓
|
||||
[Report] Display completion summary
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
- If any phase fails, mark it as "in_progress" (not completed)
|
||||
- Report error details to user
|
||||
- Do NOT auto-continue to next phase on failure
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:skill-memory [path] [--tool <gemini|qwen|codex>] [--regenerate] [--mode <full|partial>] [--cli-execute]
|
||||
```
|
||||
|
||||
- **path**: Target directory (default: current directory)
|
||||
- **--tool**: CLI tool for documentation (default: gemini)
|
||||
- `gemini`: Comprehensive documentation
|
||||
- `qwen`: Architecture analysis
|
||||
- `codex`: Implementation validation
|
||||
- **--regenerate**: Force regenerate all documentation
|
||||
- When enabled: Deletes existing `.workflow/docs/{project_name}/` before regeneration
|
||||
- Ensures fresh documentation from source code
|
||||
- **--mode**: Documentation mode (default: full)
|
||||
- `full`: Complete docs (modules + README + ARCHITECTURE + EXAMPLES)
|
||||
- `partial`: Module docs only
|
||||
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
||||
- When enabled: CLI generates docs directly in implementation_approach
|
||||
- When disabled (default): Agent generates documentation content
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Generate SKILL Package (Default)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects current directory, checks existing docs
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode full` (Agent Mode)
|
||||
3. Phase 3: Executes documentation generation via `/workflow:execute`
|
||||
4. Phase 4: Generates SKILL.md at `.claude/skills/{project_name}/SKILL.md`
|
||||
|
||||
### Example 2: Regenerate with Qwen
|
||||
|
||||
```bash
|
||||
/memory:skill-memory /d/my_app --tool qwen --regenerate
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Parses target path, detects regenerate flag, deletes existing docs
|
||||
2. Phase 2: Calls `/memory:docs /d/my_app --tool qwen --mode full`
|
||||
3. Phase 3: Executes documentation regeneration
|
||||
4. Phase 4: Generates updated SKILL.md
|
||||
|
||||
### Example 3: Partial Mode (Modules Only)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory --mode partial
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects partial mode
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode partial` (Agent Mode)
|
||||
3. Phase 3: Executes module documentation only
|
||||
4. Phase 4: Generates SKILL.md with module-only index
|
||||
|
||||
### Example 4: CLI Execute Mode
|
||||
|
||||
```bash
|
||||
/memory:skill-memory --cli-execute
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects CLI execute mode
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode full --cli-execute` (CLI Mode)
|
||||
3. Phase 3: Executes CLI-based documentation generation
|
||||
4. Phase 4: Generates SKILL.md at `.claude/skills/{project_name}/SKILL.md`
|
||||
|
||||
### Example 5: Skip Path (Existing Docs)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory
|
||||
```
|
||||
|
||||
**Scenario**: Documentation already exists in `.workflow/docs/{project_name}/`
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects existing docs (5 files), sets SKIP_DOCS_GENERATION = true
|
||||
2. Display: "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
3. Phase 4: Generates or updates SKILL.md index only (~5-10x faster)
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
skill-memory (orchestrator)
|
||||
├─ Phase 1: Prepare (bash commands, skip decision)
|
||||
├─ Phase 2: /memory:docs (task planning, skippable)
|
||||
├─ Phase 3: /workflow:execute (task execution, skippable)
|
||||
└─ Phase 4: Write SKILL.md (direct file generation, always runs)
|
||||
|
||||
No task JSON created by this command
|
||||
All documentation tasks managed by /memory:docs
|
||||
Smart skip logic: 5-10x faster when docs exist
|
||||
```
|
||||
@@ -1,773 +0,0 @@
|
||||
---
|
||||
name: swagger-docs
|
||||
description: Generate complete Swagger/OpenAPI documentation following RESTful standards with global security, API details, error codes, and validation tests
|
||||
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--format <yaml|json>] [--version <v3.0|v3.1>] [--lang <zh|en>]"
|
||||
---
|
||||
|
||||
# Swagger API Documentation Workflow (/memory:swagger-docs)
|
||||
|
||||
## Overview
|
||||
|
||||
Professional Swagger/OpenAPI documentation generator that strictly follows RESTful API design standards to produce enterprise-grade API documentation.
|
||||
|
||||
**Core Features**:
|
||||
- **RESTful Standards**: Strict adherence to REST architecture and HTTP semantics
|
||||
- **Global Security**: Unified Authorization Token validation mechanism
|
||||
- **Complete API Docs**: Descriptions, methods, URLs, parameters for each endpoint
|
||||
- **Organized Structure**: Clear directory hierarchy by business domain
|
||||
- **Detailed Fields**: Type, required, example, description for each field
|
||||
- **Error Code Standards**: Unified error response format and code definitions
|
||||
- **Validation Tests**: Boundary conditions and exception handling tests
|
||||
|
||||
**Output Structure** (--lang zh):
|
||||
```
|
||||
.workflow/docs/{project_name}/api/
|
||||
├── swagger.yaml # Main OpenAPI spec file
|
||||
├── 概述/
|
||||
│ ├── README.md # API overview
|
||||
│ ├── 认证说明.md # Authentication guide
|
||||
│ ├── 错误码规范.md # Error code definitions
|
||||
│ └── 版本历史.md # Version history
|
||||
├── 用户模块/ # Grouped by business domain
|
||||
│ ├── 用户认证.md
|
||||
│ ├── 用户管理.md
|
||||
│ └── 权限控制.md
|
||||
├── 业务模块/
|
||||
│ └── ...
|
||||
└── 测试报告/
|
||||
├── 接口测试.md # API test results
|
||||
└── 边界测试.md # Boundary condition tests
|
||||
```
|
||||
|
||||
**Output Structure** (--lang en):
|
||||
```
|
||||
.workflow/docs/{project_name}/api/
|
||||
├── swagger.yaml # Main OpenAPI spec file
|
||||
├── overview/
|
||||
│ ├── README.md # API overview
|
||||
│ ├── authentication.md # Authentication guide
|
||||
│ ├── error-codes.md # Error code definitions
|
||||
│ └── changelog.md # Version history
|
||||
├── users/ # Grouped by business domain
|
||||
│ ├── authentication.md
|
||||
│ ├── management.md
|
||||
│ └── permissions.md
|
||||
├── orders/
|
||||
│ └── ...
|
||||
└── test-reports/
|
||||
├── api-tests.md # API test results
|
||||
└── boundary-tests.md # Boundary condition tests
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:swagger-docs [path] [--tool <gemini|qwen|codex>] [--format <yaml|json>] [--version <v3.0|v3.1>] [--lang <zh|en>]
|
||||
```
|
||||
|
||||
- **path**: API source code directory (default: current directory)
|
||||
- **--tool**: CLI tool selection (default: gemini)
|
||||
- `gemini`: Comprehensive analysis, pattern recognition
|
||||
- `qwen`: Architecture analysis, system design
|
||||
- `codex`: Implementation validation, code quality
|
||||
- **--format**: OpenAPI spec format (default: yaml)
|
||||
- `yaml`: YAML format (recommended, better readability)
|
||||
- `json`: JSON format
|
||||
- **--version**: OpenAPI version (default: v3.0)
|
||||
- `v3.0`: OpenAPI 3.0.x
|
||||
- `v3.1`: OpenAPI 3.1.0 (supports JSON Schema 2020-12)
|
||||
- **--lang**: Documentation language (default: zh)
|
||||
- `zh`: Chinese documentation with Chinese directory names
|
||||
- `en`: English documentation with English directory names
|
||||
|
||||
## Planning Workflow
|
||||
|
||||
### Phase 1: Initialize Session
|
||||
|
||||
```bash
|
||||
# Get project info
|
||||
bash(pwd && basename "$(pwd)" && git rev-parse --show-toplevel 2>/dev/null || pwd && date +%Y%m%d-%H%M%S)
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Create swagger-docs session
|
||||
SlashCommand(command="/workflow:session:start --type swagger-docs --new \"{project_name}-swagger-{timestamp}\"")
|
||||
// Parse output to get sessionId
|
||||
```
|
||||
|
||||
```bash
|
||||
# Update workflow-session.json
|
||||
bash(jq '. + {"target_path":"{target_path}","project_root":"{project_root}","project_name":"{project_name}","format":"yaml","openapi_version":"3.0.3","lang":"{lang}","tool":"gemini"}' .workflow/active/{sessionId}/workflow-session.json > tmp.json && mv tmp.json .workflow/active/{sessionId}/workflow-session.json)
|
||||
```
|
||||
|
||||
### Phase 2: Scan API Endpoints
|
||||
|
||||
**Discovery Patterns**: Auto-detect framework signatures and API definition styles.
|
||||
|
||||
**Supported Frameworks**:
|
||||
| Framework | Detection Pattern | Example |
|
||||
|-----------|-------------------|---------|
|
||||
| Express.js | `router.get/post/put/delete` | `router.get('/users/:id')` |
|
||||
| Fastify | `fastify.route`, `@Route` | `fastify.get('/api/users')` |
|
||||
| NestJS | `@Controller`, `@Get/@Post` | `@Get('users/:id')` |
|
||||
| Koa | `router.get`, `ctx.body` | `router.get('/users')` |
|
||||
| Hono | `app.get/post`, `c.json` | `app.get('/users/:id')` |
|
||||
| FastAPI | `@app.get`, `@router.post` | `@app.get("/users/{id}")` |
|
||||
| Flask | `@app.route`, `@bp.route` | `@app.route('/users')` |
|
||||
| Spring | `@GetMapping`, `@PostMapping` | `@GetMapping("/users/{id}")` |
|
||||
| Go Gin | `r.GET`, `r.POST` | `r.GET("/users/:id")` |
|
||||
| Go Chi | `r.Get`, `r.Post` | `r.Get("/users/{id}")` |
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# 1. Detect API framework type
|
||||
bash(
|
||||
if rg -q "@Controller|@Get|@Post|@Put|@Delete" --type ts 2>/dev/null; then echo "NESTJS";
|
||||
elif rg -q "router\.(get|post|put|delete|patch)" --type ts --type js 2>/dev/null; then echo "EXPRESS";
|
||||
elif rg -q "fastify\.(get|post|route)" --type ts --type js 2>/dev/null; then echo "FASTIFY";
|
||||
elif rg -q "@app\.(get|post|put|delete)" --type py 2>/dev/null; then echo "FASTAPI";
|
||||
elif rg -q "@GetMapping|@PostMapping|@RequestMapping" --type java 2>/dev/null; then echo "SPRING";
|
||||
elif rg -q 'r\.(GET|POST|PUT|DELETE)' --type go 2>/dev/null; then echo "GO_GIN";
|
||||
else echo "UNKNOWN"; fi
|
||||
)
|
||||
|
||||
# 2. Scan all API endpoint definitions
|
||||
bash(rg -n "(router|app|fastify)\.(get|post|put|delete|patch)|@(Get|Post|Put|Delete|Patch|Controller|RequestMapping)" --type ts --type js --type py --type java --type go -g '!*.test.*' -g '!*.spec.*' -g '!node_modules/**' 2>/dev/null | head -200)
|
||||
|
||||
# 3. Extract route paths
|
||||
bash(rg -o "['\"](/api)?/[a-zA-Z0-9/:_-]+['\"]" --type ts --type js --type py -g '!*.test.*' 2>/dev/null | sort -u | head -100)
|
||||
|
||||
# 4. Detect existing OpenAPI/Swagger files
|
||||
bash(find . -type f \( -name "swagger.yaml" -o -name "swagger.json" -o -name "openapi.yaml" -o -name "openapi.json" \) ! -path "*/node_modules/*" 2>/dev/null)
|
||||
|
||||
# 5. Extract DTO/Schema definitions
|
||||
bash(rg -n "export (interface|type|class).*Dto|@ApiProperty|class.*Schema" --type ts -g '!*.test.*' 2>/dev/null | head -100)
|
||||
```
|
||||
|
||||
**Data Processing**: Parse outputs, use **Write tool** to create `${session_dir}/.process/swagger-planning-data.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"generated_at": "2025-01-01T12:00:00+08:00",
|
||||
"project_name": "project_name",
|
||||
"project_root": "/path/to/project",
|
||||
"openapi_version": "3.0.3",
|
||||
"format": "yaml",
|
||||
"lang": "zh"
|
||||
},
|
||||
"framework": {
|
||||
"type": "NESTJS",
|
||||
"detected_patterns": ["@Controller", "@Get", "@Post"],
|
||||
"base_path": "/api/v1"
|
||||
},
|
||||
"endpoints": [
|
||||
{
|
||||
"file": "src/modules/users/users.controller.ts",
|
||||
"line": 25,
|
||||
"method": "GET",
|
||||
"path": "/api/v1/users/:id",
|
||||
"handler": "getUser",
|
||||
"controller": "UsersController"
|
||||
}
|
||||
],
|
||||
"existing_specs": {
|
||||
"found": false,
|
||||
"files": []
|
||||
},
|
||||
"dto_schemas": [
|
||||
{
|
||||
"name": "CreateUserDto",
|
||||
"file": "src/modules/users/dto/create-user.dto.ts",
|
||||
"properties": ["email", "password", "name"]
|
||||
}
|
||||
],
|
||||
"statistics": {
|
||||
"total_endpoints": 45,
|
||||
"by_method": {"GET": 20, "POST": 15, "PUT": 5, "DELETE": 5},
|
||||
"by_module": {"users": 12, "auth": 8, "orders": 15, "products": 10}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Analyze API Structure
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# 1. Analyze controller/route file structure
|
||||
bash(cat ${session_dir}/.process/swagger-planning-data.json | jq -r '.endpoints[].file' | sort -u | head -20)
|
||||
|
||||
# 2. Extract request/response types
|
||||
bash(for f in $(jq -r '.dto_schemas[].file' ${session_dir}/.process/swagger-planning-data.json | head -20); do echo "=== $f ===" && cat "$f" 2>/dev/null; done)
|
||||
|
||||
# 3. Analyze authentication middleware
|
||||
bash(rg -n "auth|guard|middleware|jwt|bearer|token" -i --type ts --type js -g '!*.test.*' -g '!node_modules/**' 2>/dev/null | head -50)
|
||||
|
||||
# 4. Detect error handling patterns
|
||||
bash(rg -n "HttpException|BadRequest|Unauthorized|Forbidden|NotFound|throw new" --type ts --type js -g '!*.test.*' 2>/dev/null | head -50)
|
||||
```
|
||||
|
||||
**Deep Analysis via Gemini CLI**:
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Analyze API structure and generate OpenAPI specification outline for comprehensive documentation
|
||||
TASK:
|
||||
• Parse all API endpoints and identify business module boundaries
|
||||
• Extract request parameters, request bodies, and response formats
|
||||
• Identify authentication mechanisms and security requirements
|
||||
• Discover error handling patterns and error codes
|
||||
• Map endpoints to logical module groups
|
||||
MODE: analysis
|
||||
CONTEXT: @src/**/*.controller.ts @src/**/*.routes.ts @src/**/*.dto.ts @src/**/middleware/**/*
|
||||
EXPECTED: JSON format API structure analysis report with modules, endpoints, security schemes, and error codes
|
||||
CONSTRAINTS: Strict RESTful standards | Identify all public endpoints | Document output language: {lang}
|
||||
" --tool gemini --mode analysis --rule analysis-code-patterns --cd {project_root}
|
||||
```
|
||||
|
||||
**Update swagger-planning-data.json** with analysis results:
|
||||
|
||||
```json
|
||||
{
|
||||
"api_structure": {
|
||||
"modules": [
|
||||
{
|
||||
"name": "Users",
|
||||
"name_zh": "用户模块",
|
||||
"base_path": "/api/v1/users",
|
||||
"endpoints": [
|
||||
{
|
||||
"path": "/api/v1/users",
|
||||
"method": "GET",
|
||||
"operation_id": "listUsers",
|
||||
"summary": "List all users",
|
||||
"summary_zh": "获取用户列表",
|
||||
"description": "Paginated list of system users with filtering by status and role",
|
||||
"description_zh": "分页获取系统用户列表,支持按状态、角色筛选",
|
||||
"tags": ["User Management"],
|
||||
"tags_zh": ["用户管理"],
|
||||
"security": ["bearerAuth"],
|
||||
"parameters": {
|
||||
"query": ["page", "limit", "status", "role"]
|
||||
},
|
||||
"responses": {
|
||||
"200": "UserListResponse",
|
||||
"401": "UnauthorizedError",
|
||||
"403": "ForbiddenError"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"security_schemes": {
|
||||
"bearerAuth": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT",
|
||||
"description": "JWT Token authentication. Add Authorization: Bearer <token> to request header"
|
||||
}
|
||||
},
|
||||
"error_codes": [
|
||||
{"code": "AUTH_001", "status": 401, "message": "Invalid or expired token", "message_zh": "Token 无效或已过期"},
|
||||
{"code": "AUTH_002", "status": 401, "message": "Authentication required", "message_zh": "未提供认证信息"},
|
||||
{"code": "AUTH_003", "status": 403, "message": "Insufficient permissions", "message_zh": "权限不足"}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Task Decomposition
|
||||
|
||||
**Task Hierarchy**:
|
||||
|
||||
```
|
||||
Level 1: Infrastructure Tasks (Parallel)
|
||||
├─ IMPL-001: Generate main OpenAPI spec file (swagger.yaml)
|
||||
├─ IMPL-002: Generate global security config and auth documentation
|
||||
└─ IMPL-003: Generate unified error code specification
|
||||
|
||||
Level 2: Module Documentation Tasks (Parallel, by business module)
|
||||
├─ IMPL-004: Users module API documentation
|
||||
├─ IMPL-005: Auth module API documentation
|
||||
├─ IMPL-006: Business module N API documentation
|
||||
└─ ...
|
||||
|
||||
Level 3: Aggregation Tasks (Depends on Level 1-2)
|
||||
├─ IMPL-N+1: Generate API overview and navigation
|
||||
└─ IMPL-N+2: Generate version history and changelog
|
||||
|
||||
Level 4: Validation Tasks (Depends on Level 1-3)
|
||||
├─ IMPL-N+3: API endpoint validation tests
|
||||
└─ IMPL-N+4: Boundary condition tests
|
||||
```
|
||||
|
||||
**Grouping Strategy**:
|
||||
1. Group by business module (users, orders, products, etc.)
|
||||
2. Maximum 10 endpoints per task
|
||||
3. Large modules (>10 endpoints) split by submodules
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# 1. Count endpoints by module
|
||||
bash(cat ${session_dir}/.process/swagger-planning-data.json | jq '.statistics.by_module')
|
||||
|
||||
# 2. Calculate task groupings
|
||||
bash(cat ${session_dir}/.process/swagger-planning-data.json | jq -r '.api_structure.modules[] | "\(.name):\(.endpoints | length)"')
|
||||
```
|
||||
|
||||
**Data Processing**: Use **Edit tool** to update `swagger-planning-data.json` with task groups:
|
||||
|
||||
```json
|
||||
{
|
||||
"task_groups": {
|
||||
"level1_count": 3,
|
||||
"level2_count": 5,
|
||||
"total_count": 12,
|
||||
"assignments": [
|
||||
{"task_id": "IMPL-001", "level": 1, "type": "openapi-spec", "title": "Generate OpenAPI main spec file"},
|
||||
{"task_id": "IMPL-002", "level": 1, "type": "security", "title": "Generate global security config"},
|
||||
{"task_id": "IMPL-003", "level": 1, "type": "error-codes", "title": "Generate error code specification"},
|
||||
{"task_id": "IMPL-004", "level": 2, "type": "module-doc", "module": "users", "endpoint_count": 12},
|
||||
{"task_id": "IMPL-005", "level": 2, "type": "module-doc", "module": "auth", "endpoint_count": 8}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 5: Generate Task JSONs
|
||||
|
||||
**Generation Process**:
|
||||
1. Read configuration values from workflow-session.json
|
||||
2. Read task groups from swagger-planning-data.json
|
||||
3. Generate Level 1 tasks (infrastructure)
|
||||
4. Generate Level 2 tasks (by module)
|
||||
5. Generate Level 3-4 tasks (aggregation and validation)
|
||||
|
||||
## Task Templates
|
||||
|
||||
### Level 1-1: OpenAPI Main Spec File
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001",
|
||||
"title": "Generate OpenAPI main specification file",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "swagger-openapi-spec",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini",
|
||||
"priority": "critical"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Generate OpenAPI 3.0.3 compliant swagger.yaml",
|
||||
"Include complete info, servers, tags, paths, components definitions",
|
||||
"Follow RESTful design standards, use {lang} for descriptions"
|
||||
],
|
||||
"precomputed_data": {
|
||||
"planning_data": "${session_dir}/.process/swagger-planning-data.json"
|
||||
}
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_analysis_data",
|
||||
"action": "Load API analysis data",
|
||||
"commands": [
|
||||
"bash(cat ${session_dir}/.process/swagger-planning-data.json)"
|
||||
],
|
||||
"output_to": "api_analysis"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate OpenAPI spec file",
|
||||
"description": "Create complete swagger.yaml specification file",
|
||||
"cli_prompt": "PURPOSE: Generate OpenAPI 3.0.3 specification file from analyzed API structure\nTASK:\n• Define openapi version: 3.0.3\n• Define info: title, description, version, contact, license\n• Define servers: development, staging, production environments\n• Define tags: organized by business modules\n• Define paths: all API endpoints with complete specifications\n• Define components: schemas, securitySchemes, parameters, responses\nMODE: write\nCONTEXT: @[api_analysis]\nEXPECTED: Complete swagger.yaml file following OpenAPI 3.0.3 specification\nCONSTRAINTS: Use {lang} for all descriptions | Strict RESTful standards\n--rule documentation-swagger-api",
|
||||
"output": "swagger.yaml"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/swagger.yaml"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 1-2: Global Security Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-002",
|
||||
"title": "Generate global security configuration and authentication guide",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "swagger-security",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Document Authorization header format in detail",
|
||||
"Describe token acquisition, refresh, and expiration mechanisms",
|
||||
"List permission requirements for each endpoint"
|
||||
]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "analyze_auth",
|
||||
"command": "bash(rg -n 'auth|guard|jwt|bearer' -i --type ts -g '!*.test.*' 2>/dev/null | head -50)",
|
||||
"output_to": "auth_patterns"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate authentication documentation",
|
||||
"cli_prompt": "PURPOSE: Generate comprehensive authentication documentation for API security\nTASK:\n• Document authentication mechanism: JWT Bearer Token\n• Explain header format: Authorization: Bearer <token>\n• Describe token lifecycle: acquisition, refresh, expiration handling\n• Define permission levels: public, user, admin, super_admin\n• Document authentication failure responses: 401/403 error handling\nMODE: write\nCONTEXT: @[auth_patterns] @src/**/auth/**/* @src/**/guard/**/*\nEXPECTED: Complete authentication guide in {lang}\nCONSTRAINTS: Include code examples | Clear step-by-step instructions\n--rule development-feature",
|
||||
"output": "{auth_doc_name}"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/{overview_dir}/{auth_doc_name}"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 1-3: Unified Error Code Specification
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-003",
|
||||
"title": "Generate unified error code specification",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "swagger-error-codes",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Define unified error response format",
|
||||
"Create categorized error code system (auth, business, system)",
|
||||
"Provide detailed description and examples for each error code"
|
||||
]
|
||||
},
|
||||
"flow_control": {
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate error code specification document",
|
||||
"cli_prompt": "PURPOSE: Generate comprehensive error code specification for consistent API error handling\nTASK:\n• Define error response format: {code, message, details, timestamp}\n• Document authentication errors (AUTH_xxx): 401/403 series\n• Document parameter errors (PARAM_xxx): 400 series\n• Document business errors (BIZ_xxx): business logic errors\n• Document system errors (SYS_xxx): 500 series\n• For each error code: HTTP status, error message, possible causes, resolution suggestions\nMODE: write\nCONTEXT: @src/**/*.exception.ts @src/**/*.filter.ts\nEXPECTED: Complete error code specification in {lang} with tables and examples\nCONSTRAINTS: Include response examples | Clear categorization\n--rule development-feature",
|
||||
"output": "{error_doc_name}"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/{overview_dir}/{error_doc_name}"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 2: Module API Documentation (Template)
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${module_task_id}",
|
||||
"title": "Generate ${module_name} API documentation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-001", "IMPL-002", "IMPL-003"],
|
||||
"meta": {
|
||||
"type": "swagger-module-doc",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini",
|
||||
"module": "${module_name}",
|
||||
"endpoint_count": "${endpoint_count}"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Complete documentation for all endpoints in this module",
|
||||
"Each endpoint: description, method, URL, parameters, responses",
|
||||
"Include success and failure response examples",
|
||||
"Mark API version and last update time"
|
||||
],
|
||||
"focus_paths": ["${module_source_paths}"]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_module_endpoints",
|
||||
"action": "Load module endpoint information",
|
||||
"commands": [
|
||||
"bash(cat ${session_dir}/.process/swagger-planning-data.json | jq '.api_structure.modules[] | select(.name == \"${module_name}\")')"
|
||||
],
|
||||
"output_to": "module_endpoints"
|
||||
},
|
||||
{
|
||||
"step": "read_source_files",
|
||||
"action": "Read module source files",
|
||||
"commands": [
|
||||
"bash(cat ${module_source_files})"
|
||||
],
|
||||
"output_to": "source_code"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate module API documentation",
|
||||
"description": "Generate complete API documentation for ${module_name}",
|
||||
"cli_prompt": "PURPOSE: Generate complete RESTful API documentation for ${module_name} module\nTASK:\n• Create module overview: purpose, use cases, prerequisites\n• Generate endpoint index: grouped by functionality\n• For each endpoint document:\n - Functional description: purpose and business context\n - Request method: GET/POST/PUT/DELETE\n - URL path: complete API path\n - Request headers: Authorization and other required headers\n - Path parameters: {id} and other path variables\n - Query parameters: pagination, filters, etc.\n - Request body: JSON Schema format\n - Response body: success and error responses\n - Field description table: type, required, example, description\n• Add usage examples: cURL, JavaScript, Python\n• Add version info: v1.0.0, last updated date\nMODE: write\nCONTEXT: @[module_endpoints] @[source_code]\nEXPECTED: Complete module API documentation in {lang} with all endpoints fully documented\nCONSTRAINTS: RESTful standards | Include all response codes\n--rule documentation-swagger-api",
|
||||
"output": "${module_doc_name}"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/${module_dir}/${module_doc_name}"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 3: API Overview and Navigation
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${overview_task_id}",
|
||||
"title": "Generate API overview and navigation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-001", "...", "IMPL-${last_module_task_id}"],
|
||||
"meta": {
|
||||
"type": "swagger-overview",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini"
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_all_docs",
|
||||
"command": "bash(find .workflow/docs/${project_name}/api -type f -name '*.md' ! -path '*/{overview_dir}/*' | xargs cat)",
|
||||
"output_to": "all_module_docs"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate API overview",
|
||||
"cli_prompt": "PURPOSE: Generate API overview document with navigation and quick start guide\nTASK:\n• Create introduction: system features, tech stack, version\n• Write quick start guide: authentication, first request example\n• Build module navigation: categorized links to all modules\n• Document environment configuration: development, staging, production\n• List SDKs and tools: client libraries, Postman collection\nMODE: write\nCONTEXT: @[all_module_docs] @.workflow/docs/${project_name}/api/swagger.yaml\nEXPECTED: Complete API overview in {lang} with navigation links\nCONSTRAINTS: Clear structure | Quick start focus\n--rule development-feature",
|
||||
"output": "README.md"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/{overview_dir}/README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 4: Validation Tasks
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${test_task_id}",
|
||||
"title": "API endpoint validation tests",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-${overview_task_id}"],
|
||||
"meta": {
|
||||
"type": "swagger-validation",
|
||||
"agent": "@test-fix-agent",
|
||||
"tool": "codex"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Validate accessibility of all endpoints",
|
||||
"Test various boundary conditions",
|
||||
"Verify exception handling"
|
||||
]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_swagger_spec",
|
||||
"command": "bash(cat .workflow/docs/${project_name}/api/swagger.yaml)",
|
||||
"output_to": "swagger_spec"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate test report",
|
||||
"cli_prompt": "PURPOSE: Generate comprehensive API test validation report\nTASK:\n• Document test environment configuration\n• Calculate endpoint coverage statistics\n• Report test results: pass/fail counts\n• Document boundary tests: parameter limits, null values, special characters\n• Document exception tests: auth failures, permission denied, resource not found\n• List issues found with recommendations\nMODE: write\nCONTEXT: @[swagger_spec]\nEXPECTED: Complete test report in {lang} with detailed results\nCONSTRAINTS: Include test cases | Clear pass/fail status\n--rule development-tests",
|
||||
"output": "{test_doc_name}"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/api/{test_dir}/{test_doc_name}"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Language-Specific Directory Mapping
|
||||
|
||||
| Component | --lang zh | --lang en |
|
||||
|-----------|-----------|-----------|
|
||||
| Overview dir | 概述 | overview |
|
||||
| Auth doc | 认证说明.md | authentication.md |
|
||||
| Error doc | 错误码规范.md | error-codes.md |
|
||||
| Changelog | 版本历史.md | changelog.md |
|
||||
| Users module | 用户模块 | users |
|
||||
| Orders module | 订单模块 | orders |
|
||||
| Products module | 商品模块 | products |
|
||||
| Test dir | 测试报告 | test-reports |
|
||||
| API test doc | 接口测试.md | api-tests.md |
|
||||
| Boundary test doc | 边界测试.md | boundary-tests.md |
|
||||
|
||||
## API Documentation Template
|
||||
|
||||
### Single Endpoint Format
|
||||
|
||||
Each endpoint must include:
|
||||
|
||||
```markdown
|
||||
### Get User Details
|
||||
|
||||
**Description**: Retrieve detailed user information by ID, including profile and permissions.
|
||||
|
||||
**Endpoint Info**:
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Method | GET |
|
||||
| URL | `/api/v1/users/{id}` |
|
||||
| Version | v1.0.0 |
|
||||
| Updated | 2025-01-01 |
|
||||
| Auth | Bearer Token |
|
||||
| Permission | user / admin |
|
||||
|
||||
**Request Headers**:
|
||||
|
||||
| Field | Type | Required | Example | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| Authorization | string | Yes | `Bearer eyJhbGc...` | JWT Token |
|
||||
| Content-Type | string | No | `application/json` | Request content type |
|
||||
|
||||
**Path Parameters**:
|
||||
|
||||
| Field | Type | Required | Example | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| id | string | Yes | `usr_123456` | Unique user identifier |
|
||||
|
||||
**Query Parameters**:
|
||||
|
||||
| Field | Type | Required | Default | Example | Description |
|
||||
|-------|------|----------|---------|---------|-------------|
|
||||
| include | string | No | - | `roles,permissions` | Related data to include |
|
||||
|
||||
**Success Response** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"id": "usr_123456",
|
||||
"email": "user@example.com",
|
||||
"name": "John Doe",
|
||||
"status": "active",
|
||||
"roles": ["user"],
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-01T00:00:00Z"
|
||||
},
|
||||
"timestamp": "2025-01-01T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
**Response Fields**:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| code | integer | Business status code, 0 = success |
|
||||
| message | string | Response message |
|
||||
| data.id | string | Unique user identifier |
|
||||
| data.email | string | User email address |
|
||||
| data.name | string | User display name |
|
||||
| data.status | string | User status: active/inactive/suspended |
|
||||
| data.roles | array | User role list |
|
||||
| data.created_at | string | Creation timestamp (ISO 8601) |
|
||||
| data.updated_at | string | Last update timestamp (ISO 8601) |
|
||||
|
||||
**Error Responses**:
|
||||
|
||||
| Status | Code | Message | Possible Cause |
|
||||
|--------|------|---------|----------------|
|
||||
| 401 | AUTH_001 | Invalid or expired token | Token format error or expired |
|
||||
| 403 | AUTH_003 | Insufficient permissions | No access to this user info |
|
||||
| 404 | USER_001 | User not found | User ID doesn't exist or deleted |
|
||||
|
||||
**Examples**:
|
||||
|
||||
```bash
|
||||
# cURL
|
||||
curl -X GET "https://api.example.com/api/v1/users/usr_123456" \
|
||||
-H "Authorization: Bearer eyJhbGc..." \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
// JavaScript (fetch)
|
||||
const response = await fetch('https://api.example.com/api/v1/users/usr_123456', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': 'Bearer eyJhbGc...',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
const data = await response.json();
|
||||
```
|
||||
```
|
||||
|
||||
## Session Structure
|
||||
|
||||
```
|
||||
.workflow/active/
|
||||
└── WFS-swagger-{timestamp}/
|
||||
├── workflow-session.json
|
||||
├── IMPL_PLAN.md
|
||||
├── TODO_LIST.md
|
||||
├── .process/
|
||||
│ └── swagger-planning-data.json
|
||||
└── .task/
|
||||
├── IMPL-001.json # OpenAPI spec
|
||||
├── IMPL-002.json # Security config
|
||||
├── IMPL-003.json # Error codes
|
||||
├── IMPL-004.json # Module 1 API
|
||||
├── ...
|
||||
├── IMPL-N+1.json # API overview
|
||||
└── IMPL-N+2.json # Validation tests
|
||||
```
|
||||
|
||||
## Execution Commands
|
||||
|
||||
```bash
|
||||
# Execute entire workflow
|
||||
/workflow:execute
|
||||
|
||||
# Specify session
|
||||
/workflow:execute --resume-session="WFS-swagger-yyyymmdd-hhmmss"
|
||||
|
||||
# Single task execution
|
||||
/task:execute IMPL-001
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:execute` - Execute documentation tasks
|
||||
- `/workflow:status` - View task progress
|
||||
- `/workflow:session:complete` - Mark session complete
|
||||
- `/memory:docs` - General documentation workflow
|
||||
@@ -1,310 +0,0 @@
|
||||
---
|
||||
name: tech-research-rules
|
||||
description: "3-phase orchestrator: extract tech stack → Exa research → generate path-conditional rules (auto-loaded by Claude Code)"
|
||||
argument-hint: "[session-id | tech-stack-name] [--regenerate] [--tool <gemini|qwen>]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*), Task(*)
|
||||
---
|
||||
|
||||
# Tech Stack Rules Generator
|
||||
|
||||
## Overview
|
||||
|
||||
**Purpose**: Generate multi-layered, path-conditional rules that Claude Code automatically loads based on file context.
|
||||
|
||||
**Output Structure**:
|
||||
```
|
||||
.claude/rules/tech/{tech-stack}/
|
||||
├── core.md # paths: **/*.{ext} - Core principles
|
||||
├── patterns.md # paths: src/**/*.{ext} - Implementation patterns
|
||||
├── testing.md # paths: **/*.{test,spec}.{ext} - Testing rules
|
||||
├── config.md # paths: *.config.* - Configuration rules
|
||||
├── api.md # paths: **/api/**/* - API rules (backend only)
|
||||
├── components.md # paths: **/components/**/* - Component rules (frontend only)
|
||||
└── metadata.json # Generation metadata
|
||||
```
|
||||
|
||||
**Templates Location**: `~/.claude/workflows/cli-templates/prompts/rules/`
|
||||
|
||||
---
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization
|
||||
2. **Path-Conditional Output**: Every rule file includes `paths` frontmatter
|
||||
3. **Template-Driven**: Agent reads templates before generating content
|
||||
4. **Agent Produces Files**: Agent writes all rule files directly
|
||||
5. **No Manual Loading**: Rules auto-activate when Claude works with matching files
|
||||
|
||||
---
|
||||
|
||||
## 3-Phase Execution
|
||||
|
||||
### Phase 1: Prepare Context & Detect Tech Stack
|
||||
|
||||
**Goal**: Detect input mode, extract tech stack info, determine file extensions
|
||||
|
||||
**Input Mode Detection**:
|
||||
```bash
|
||||
input="$1"
|
||||
|
||||
if [[ "$input" == WFS-* ]]; then
|
||||
MODE="session"
|
||||
SESSION_ID="$input"
|
||||
# Read workflow-session.json to extract tech stack
|
||||
else
|
||||
MODE="direct"
|
||||
TECH_STACK_NAME="$input"
|
||||
fi
|
||||
```
|
||||
|
||||
**Tech Stack Analysis**:
|
||||
```javascript
|
||||
// Decompose composite tech stacks
|
||||
// "typescript-react-nextjs" → ["typescript", "react", "nextjs"]
|
||||
|
||||
const TECH_EXTENSIONS = {
|
||||
"typescript": "{ts,tsx}",
|
||||
"javascript": "{js,jsx}",
|
||||
"python": "py",
|
||||
"rust": "rs",
|
||||
"go": "go",
|
||||
"java": "java",
|
||||
"csharp": "cs",
|
||||
"ruby": "rb",
|
||||
"php": "php"
|
||||
};
|
||||
|
||||
const FRAMEWORK_TYPE = {
|
||||
"react": "frontend",
|
||||
"vue": "frontend",
|
||||
"angular": "frontend",
|
||||
"nextjs": "fullstack",
|
||||
"nuxt": "fullstack",
|
||||
"fastapi": "backend",
|
||||
"express": "backend",
|
||||
"django": "backend",
|
||||
"rails": "backend"
|
||||
};
|
||||
```
|
||||
|
||||
**Check Existing Rules**:
|
||||
```bash
|
||||
normalized_name=$(echo "$TECH_STACK_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||
rules_dir=".claude/rules/tech/${normalized_name}"
|
||||
existing_count=$(find "${rules_dir}" -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Skip Decision**:
|
||||
- If `existing_count > 0` AND no `--regenerate` → `SKIP_GENERATION = true`
|
||||
- If `--regenerate` → Delete existing and regenerate
|
||||
|
||||
**Output Variables**:
|
||||
- `TECH_STACK_NAME`: Normalized name
|
||||
- `PRIMARY_LANG`: Primary language
|
||||
- `FILE_EXT`: File extension pattern
|
||||
- `FRAMEWORK_TYPE`: frontend | backend | fullstack | library
|
||||
- `COMPONENTS`: Array of tech components
|
||||
- `SKIP_GENERATION`: Boolean
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Agent Produces Path-Conditional Rules
|
||||
|
||||
**Skip Condition**: Skipped if `SKIP_GENERATION = true`
|
||||
|
||||
**Goal**: Delegate to agent for Exa research and rule file generation
|
||||
|
||||
**Template Files**:
|
||||
```
|
||||
~/.claude/workflows/cli-templates/prompts/rules/
|
||||
├── tech-rules-agent-prompt.txt # Agent instructions
|
||||
├── rule-core.txt # Core principles template
|
||||
├── rule-patterns.txt # Implementation patterns template
|
||||
├── rule-testing.txt # Testing rules template
|
||||
├── rule-config.txt # Configuration rules template
|
||||
├── rule-api.txt # API rules template (backend)
|
||||
└── rule-components.txt # Component rules template (frontend)
|
||||
```
|
||||
|
||||
**Agent Task**:
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "general-purpose",
|
||||
description: `Generate tech stack rules: ${TECH_STACK_NAME}`,
|
||||
prompt: `
|
||||
You are generating path-conditional rules for Claude Code.
|
||||
|
||||
## Context
|
||||
- Tech Stack: ${TECH_STACK_NAME}
|
||||
- Primary Language: ${PRIMARY_LANG}
|
||||
- File Extensions: ${FILE_EXT}
|
||||
- Framework Type: ${FRAMEWORK_TYPE}
|
||||
- Components: ${JSON.stringify(COMPONENTS)}
|
||||
- Output Directory: .claude/rules/tech/${TECH_STACK_NAME}/
|
||||
|
||||
## Instructions
|
||||
|
||||
Read the agent prompt template for detailed instructions.
|
||||
Use --rule rules-tech-rules-agent-prompt to load the template automatically.
|
||||
|
||||
## Execution Steps
|
||||
|
||||
1. Execute Exa research queries (see agent prompt)
|
||||
2. Read each rule template
|
||||
3. Generate rule files following template structure
|
||||
4. Write files to output directory
|
||||
5. Write metadata.json
|
||||
6. Report completion
|
||||
|
||||
## Variable Substitutions
|
||||
|
||||
Replace in templates:
|
||||
- {TECH_STACK_NAME} → ${TECH_STACK_NAME}
|
||||
- {PRIMARY_LANG} → ${PRIMARY_LANG}
|
||||
- {FILE_EXT} → ${FILE_EXT}
|
||||
- {FRAMEWORK_TYPE} → ${FRAMEWORK_TYPE}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- 4-6 rule files written with proper `paths` frontmatter
|
||||
- metadata.json written
|
||||
- Agent reports files created
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Verify & Report
|
||||
|
||||
**Goal**: Verify generated files and provide usage summary
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. **Verify Files**:
|
||||
```bash
|
||||
find ".claude/rules/tech/${TECH_STACK_NAME}" -name "*.md" -type f
|
||||
```
|
||||
|
||||
2. **Validate Frontmatter**:
|
||||
```bash
|
||||
head -5 ".claude/rules/tech/${TECH_STACK_NAME}/core.md"
|
||||
```
|
||||
|
||||
3. **Read Metadata**:
|
||||
```javascript
|
||||
Read(`.claude/rules/tech/${TECH_STACK_NAME}/metadata.json`)
|
||||
```
|
||||
|
||||
4. **Generate Summary Report**:
|
||||
```
|
||||
Tech Stack Rules Generated
|
||||
|
||||
Tech Stack: {TECH_STACK_NAME}
|
||||
Location: .claude/rules/tech/{TECH_STACK_NAME}/
|
||||
|
||||
Files Created:
|
||||
├── core.md → paths: **/*.{ext}
|
||||
├── patterns.md → paths: src/**/*.{ext}
|
||||
├── testing.md → paths: **/*.{test,spec}.{ext}
|
||||
├── config.md → paths: *.config.*
|
||||
├── api.md → paths: **/api/**/* (if backend)
|
||||
└── components.md → paths: **/components/**/* (if frontend)
|
||||
|
||||
Auto-Loading:
|
||||
- Rules apply automatically when editing matching files
|
||||
- No manual loading required
|
||||
|
||||
Example Activation:
|
||||
- Edit src/components/Button.tsx → core.md + patterns.md + components.md
|
||||
- Edit tests/api.test.ts → core.md + testing.md
|
||||
- Edit package.json → config.md
|
||||
```
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed
|
||||
|
||||
---
|
||||
|
||||
## Path Pattern Reference
|
||||
|
||||
| Pattern | Matches |
|
||||
|---------|---------|
|
||||
| `**/*.ts` | All .ts files |
|
||||
| `src/**/*` | All files under src/ |
|
||||
| `*.config.*` | Config files in root |
|
||||
| `**/*.{ts,tsx}` | .ts and .tsx files |
|
||||
|
||||
| Tech Stack | Core Pattern | Test Pattern |
|
||||
|------------|--------------|--------------|
|
||||
| TypeScript | `**/*.{ts,tsx}` | `**/*.{test,spec}.{ts,tsx}` |
|
||||
| Python | `**/*.py` | `**/test_*.py, **/*_test.py` |
|
||||
| Rust | `**/*.rs` | `**/tests/**/*.rs` |
|
||||
| Go | `**/*.go` | `**/*_test.go` |
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:tech-research [session-id | "tech-stack-name"] [--regenerate]
|
||||
```
|
||||
|
||||
**Arguments**:
|
||||
- **session-id**: `WFS-*` format - Extract from workflow session
|
||||
- **tech-stack-name**: Direct input - `"typescript"`, `"typescript-react"`
|
||||
- **--regenerate**: Force regenerate existing rules
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Single Language
|
||||
|
||||
```bash
|
||||
/memory:tech-research "typescript"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/typescript/` with 4 rule files
|
||||
|
||||
### Frontend Stack
|
||||
|
||||
```bash
|
||||
/memory:tech-research "typescript-react"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/typescript-react/` with 5 rule files (includes components.md)
|
||||
|
||||
### Backend Stack
|
||||
|
||||
```bash
|
||||
/memory:tech-research "python-fastapi"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/python-fastapi/` with 5 rule files (includes api.md)
|
||||
|
||||
### From Session
|
||||
|
||||
```bash
|
||||
/memory:tech-research WFS-user-auth-20251104
|
||||
```
|
||||
|
||||
**Workflow**: Extract tech stack from session → Generate rules
|
||||
|
||||
---
|
||||
|
||||
## Comparison: Rules vs SKILL
|
||||
|
||||
| Aspect | SKILL Memory | Rules |
|
||||
|--------|--------------|-------|
|
||||
| Loading | Manual: `Skill("tech")` | Automatic by path |
|
||||
| Scope | All files when loaded | Only matching files |
|
||||
| Granularity | Monolithic packages | Per-file-type |
|
||||
| Context | Full package | Only relevant rules |
|
||||
|
||||
**When to Use**:
|
||||
- **Rules**: Tech stack conventions per file type
|
||||
- **SKILL**: Reference docs, APIs, examples for manual lookup
|
||||
332
.claude/commands/memory/tips.md
Normal file
332
.claude/commands/memory/tips.md
Normal file
@@ -0,0 +1,332 @@
|
||||
---
|
||||
name: tips
|
||||
description: Quick note-taking command to capture ideas, snippets, reminders, and insights for later reference
|
||||
argument-hint: "<note content> [--tag <tag1,tag2>] [--context <context>]"
|
||||
allowed-tools: mcp__ccw-tools__core_memory(*), Read(*)
|
||||
examples:
|
||||
- /memory:tips "Remember to use Redis for rate limiting"
|
||||
- /memory:tips "Auth pattern: JWT with refresh tokens" --tag architecture,auth
|
||||
- /memory:tips "Bug: memory leak in WebSocket handler after 24h" --context websocket-service
|
||||
- /memory:tips "Performance: lazy loading reduced bundle by 40%" --tag performance
|
||||
---
|
||||
|
||||
# Memory Tips Command (/memory:tips)
|
||||
|
||||
## 1. Overview
|
||||
|
||||
The `memory:tips` command provides **quick note-taking** for capturing:
|
||||
- Quick ideas and insights
|
||||
- Code snippets and patterns
|
||||
- Reminders and follow-ups
|
||||
- Bug notes and debugging hints
|
||||
- Performance observations
|
||||
- Architecture decisions
|
||||
- Library/tool recommendations
|
||||
|
||||
**Core Philosophy**:
|
||||
- **Speed First**: Minimal friction for capturing thoughts
|
||||
- **Searchable**: Tagged for easy retrieval
|
||||
- **Context-Aware**: Optional context linking
|
||||
- **Lightweight**: No complex session analysis
|
||||
|
||||
## 2. Parameters
|
||||
|
||||
- `<note content>` (Required): The tip/note content to save
|
||||
- `--tag <tags>` (Optional): Comma-separated tags for categorization
|
||||
- `--context <context>` (Optional): Related context (file, module, feature)
|
||||
|
||||
**Examples**:
|
||||
```bash
|
||||
/memory:tips "Use Zod for runtime validation - better DX than class-validator"
|
||||
/memory:tips "Redis connection pool: max 10, min 2" --tag config,redis
|
||||
/memory:tips "Fix needed: race condition in payment processor" --tag bug,payment --context src/payments
|
||||
```
|
||||
|
||||
## 3. Structured Output Format
|
||||
|
||||
```markdown
|
||||
## Tip ID
|
||||
TIP-YYYYMMDD-HHMMSS
|
||||
|
||||
## Timestamp
|
||||
YYYY-MM-DD HH:MM:SS
|
||||
|
||||
## Project Root
|
||||
[Absolute path to project root, e.g., D:\Claude_dms3]
|
||||
|
||||
## Content
|
||||
[The tip/note content exactly as provided]
|
||||
|
||||
## Tags
|
||||
[Comma-separated tags, or (none)]
|
||||
|
||||
## Context
|
||||
[Optional context linking - file, module, or feature reference]
|
||||
|
||||
## Session Link
|
||||
[WFS-ID if workflow session active, otherwise (none)]
|
||||
|
||||
## Auto-Detected Context
|
||||
[Files/topics from current conversation if relevant]
|
||||
```
|
||||
|
||||
## 4. Field Definitions
|
||||
|
||||
| Field | Purpose | Example |
|
||||
|-------|---------|---------|
|
||||
| **Tip ID** | Unique identifier with timestamp | TIP-20260128-143052 |
|
||||
| **Timestamp** | When tip was created | 2026-01-28 14:30:52 |
|
||||
| **Project Root** | Current project path | D:\Claude_dms3 |
|
||||
| **Content** | The actual tip/note | "Use Redis for rate limiting" |
|
||||
| **Tags** | Categorization labels | architecture, auth, performance |
|
||||
| **Context** | Related code/feature | src/auth/**, payment-module |
|
||||
| **Session Link** | Link to workflow session | WFS-auth-20260128 |
|
||||
| **Auto-Detected Context** | Files from conversation | src/api/handler.ts |
|
||||
|
||||
## 5. Execution Flow
|
||||
|
||||
### Step 1: Parse Arguments
|
||||
|
||||
```javascript
|
||||
const parseTipsCommand = (input) => {
|
||||
// Extract note content (everything before flags)
|
||||
const contentMatch = input.match(/^"([^"]+)"|^([^\s-]+)/);
|
||||
const content = contentMatch ? (contentMatch[1] || contentMatch[2]) : '';
|
||||
|
||||
// Extract tags
|
||||
const tagsMatch = input.match(/--tag\s+([^\s-]+)/);
|
||||
const tags = tagsMatch ? tagsMatch[1].split(',').map(t => t.trim()) : [];
|
||||
|
||||
// Extract context
|
||||
const contextMatch = input.match(/--context\s+([^\s-]+)/);
|
||||
const context = contextMatch ? contextMatch[1] : '';
|
||||
|
||||
return { content, tags, context };
|
||||
};
|
||||
```
|
||||
|
||||
### Step 2: Gather Context
|
||||
|
||||
```javascript
|
||||
const gatherTipContext = async () => {
|
||||
// Get project root
|
||||
const projectRoot = process.cwd(); // or detect from environment
|
||||
|
||||
// Get current session if active
|
||||
const manifest = await mcp__ccw-tools__session_manager({
|
||||
operation: "list",
|
||||
location: "active"
|
||||
});
|
||||
const sessionId = manifest.sessions?.[0]?.id || null;
|
||||
|
||||
// Auto-detect files from recent conversation
|
||||
const recentFiles = extractRecentFilesFromConversation(); // Last 5 messages
|
||||
|
||||
return {
|
||||
projectRoot,
|
||||
sessionId,
|
||||
autoDetectedContext: recentFiles
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### Step 3: Generate Structured Text
|
||||
|
||||
```javascript
|
||||
const generateTipText = (parsed, context) => {
|
||||
const timestamp = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
||||
const tipId = `TIP-${new Date().toISOString().slice(0,10).replace(/-/g, '')}-${new Date().toTimeString().slice(0,8).replace(/:/g, '')}`;
|
||||
|
||||
return `## Tip ID
|
||||
${tipId}
|
||||
|
||||
## Timestamp
|
||||
${timestamp}
|
||||
|
||||
## Project Root
|
||||
${context.projectRoot}
|
||||
|
||||
## Content
|
||||
${parsed.content}
|
||||
|
||||
## Tags
|
||||
${parsed.tags.length > 0 ? parsed.tags.join(', ') : '(none)'}
|
||||
|
||||
## Context
|
||||
${parsed.context || '(none)'}
|
||||
|
||||
## Session Link
|
||||
${context.sessionId || '(none)'}
|
||||
|
||||
## Auto-Detected Context
|
||||
${context.autoDetectedContext.length > 0
|
||||
? context.autoDetectedContext.map(f => `- ${f}`).join('\n')
|
||||
: '(none)'}`;
|
||||
};
|
||||
```
|
||||
|
||||
### Step 4: Save to Core Memory
|
||||
|
||||
```javascript
|
||||
mcp__ccw-tools__core_memory({
|
||||
operation: "import",
|
||||
text: structuredText
|
||||
})
|
||||
```
|
||||
|
||||
**Response Format**:
|
||||
```json
|
||||
{
|
||||
"operation": "import",
|
||||
"id": "CMEM-YYYYMMDD-HHMMSS",
|
||||
"message": "Created memory: CMEM-YYYYMMDD-HHMMSS"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 5: Confirm to User
|
||||
|
||||
```
|
||||
✓ Tip saved successfully
|
||||
|
||||
ID: CMEM-YYYYMMDD-HHMMSS
|
||||
Tags: architecture, auth
|
||||
Context: src/auth/**
|
||||
|
||||
To retrieve: /memory:search "auth patterns"
|
||||
Or via MCP: core_memory(operation="search", query="auth")
|
||||
```
|
||||
|
||||
## 6. Tag Categories (Suggested)
|
||||
|
||||
**Technical**:
|
||||
- `architecture` - Design decisions and patterns
|
||||
- `performance` - Optimization insights
|
||||
- `security` - Security considerations
|
||||
- `bug` - Bug notes and fixes
|
||||
- `config` - Configuration settings
|
||||
- `api` - API design patterns
|
||||
|
||||
**Development**:
|
||||
- `testing` - Test strategies and patterns
|
||||
- `debugging` - Debugging techniques
|
||||
- `refactoring` - Refactoring notes
|
||||
- `documentation` - Doc improvements
|
||||
|
||||
**Domain Specific**:
|
||||
- `auth` - Authentication/authorization
|
||||
- `database` - Database patterns
|
||||
- `frontend` - UI/UX patterns
|
||||
- `backend` - Backend logic
|
||||
- `devops` - Infrastructure and deployment
|
||||
|
||||
**Organizational**:
|
||||
- `reminder` - Follow-up items
|
||||
- `research` - Research findings
|
||||
- `idea` - Feature ideas
|
||||
- `review` - Code review notes
|
||||
|
||||
## 7. Search Integration
|
||||
|
||||
Tips can be retrieved using:
|
||||
|
||||
```bash
|
||||
# Via command (if /memory:search exists)
|
||||
/memory:search "rate limiting"
|
||||
|
||||
# Via MCP tool
|
||||
mcp__ccw-tools__core_memory({
|
||||
operation: "search",
|
||||
query: "rate limiting",
|
||||
source_type: "core_memory",
|
||||
top_k: 10
|
||||
})
|
||||
|
||||
# Via CLI
|
||||
ccw core-memory search --query "rate limiting" --top-k 10
|
||||
```
|
||||
|
||||
## 8. Quality Checklist
|
||||
|
||||
Before saving:
|
||||
- [ ] Content is clear and actionable
|
||||
- [ ] Tags are relevant and consistent
|
||||
- [ ] Context provides enough reference
|
||||
- [ ] Auto-detected context is accurate
|
||||
- [ ] Project root is absolute path
|
||||
- [ ] Timestamp is properly formatted
|
||||
|
||||
## 9. Best Practices
|
||||
|
||||
### Good Tips Examples
|
||||
|
||||
✅ **Specific and Actionable**:
|
||||
```
|
||||
"Use connection pooling for Redis: { max: 10, min: 2, acquireTimeoutMillis: 30000 }"
|
||||
--tag config,redis
|
||||
```
|
||||
|
||||
✅ **With Context**:
|
||||
```
|
||||
"Auth middleware must validate both access and refresh tokens"
|
||||
--tag security,auth --context src/middleware/auth.ts
|
||||
```
|
||||
|
||||
✅ **Problem + Solution**:
|
||||
```
|
||||
"Memory leak fixed by unsubscribing event listeners in componentWillUnmount"
|
||||
--tag bug,react --context src/components/Chat.tsx
|
||||
```
|
||||
|
||||
### Poor Tips Examples
|
||||
|
||||
❌ **Too Vague**:
|
||||
```
|
||||
"Fix the bug" --tag bug
|
||||
```
|
||||
|
||||
❌ **Too Long** (use /memory:compact instead):
|
||||
```
|
||||
"Here's the complete implementation plan for the entire auth system... [3 paragraphs]"
|
||||
```
|
||||
|
||||
❌ **No Context**:
|
||||
```
|
||||
"Remember to update this later"
|
||||
```
|
||||
|
||||
## 10. Use Cases
|
||||
|
||||
### During Development
|
||||
```bash
|
||||
/memory:tips "JWT secret must be 256-bit minimum" --tag security,auth
|
||||
/memory:tips "Use debounce (300ms) for search input" --tag performance,ux
|
||||
```
|
||||
|
||||
### After Bug Fixes
|
||||
```bash
|
||||
/memory:tips "Race condition in payment: lock with Redis SETNX" --tag bug,payment
|
||||
```
|
||||
|
||||
### Code Review Insights
|
||||
```bash
|
||||
/memory:tips "Prefer early returns over nested ifs" --tag style,readability
|
||||
```
|
||||
|
||||
### Architecture Decisions
|
||||
```bash
|
||||
/memory:tips "Chose PostgreSQL over MongoDB for ACID compliance" --tag architecture,database
|
||||
```
|
||||
|
||||
### Library Recommendations
|
||||
```bash
|
||||
/memory:tips "Zod > Yup for TypeScript validation - better type inference" --tag library,typescript
|
||||
```
|
||||
|
||||
## 11. Notes
|
||||
|
||||
- **Frequency**: Use liberally - capture all valuable insights
|
||||
- **Retrieval**: Search by tags, content, or context
|
||||
- **Lifecycle**: Tips persist across sessions
|
||||
- **Organization**: Tags enable filtering and categorization
|
||||
- **Integration**: Can reference tips in later workflows
|
||||
- **Lightweight**: No complex session analysis required
|
||||
@@ -1,517 +0,0 @@
|
||||
---
|
||||
name: workflow-skill-memory
|
||||
description: Process WFS-* archived sessions using universal-executor agents with Gemini analysis to generate workflow-progress SKILL package (sessions-timeline, lessons, conflicts)
|
||||
argument-hint: "session <session-id> | all"
|
||||
allowed-tools: Task(*), TodoWrite(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow SKILL Memory Generator
|
||||
|
||||
## Overview
|
||||
|
||||
Generate SKILL package from archived workflow sessions using agent-driven analysis. Supports single-session incremental updates or parallel processing of all sessions.
|
||||
|
||||
**Scope**: Only processes WFS-* workflow sessions. Other session types (e.g., doc sessions) are automatically ignored.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-<session-id> # Process single WFS session
|
||||
/memory:workflow-skill-memory all # Process all WFS sessions in parallel
|
||||
```
|
||||
|
||||
## Execution Modes
|
||||
|
||||
### Mode 1: Single Session (`session <session-id>`)
|
||||
|
||||
**Purpose**: Incremental update - process one archived session and merge into existing SKILL package
|
||||
|
||||
**Workflow**:
|
||||
1. **Validate session**: Check if session exists in `.workflow/.archives/{session-id}/`
|
||||
2. **Invoke agent**: Call `universal-executor` to analyze session and update SKILL documents
|
||||
3. **Agent tasks**:
|
||||
- Read session data from `.workflow/.archives/{session-id}/`
|
||||
- Extract lessons, conflicts, and outcomes
|
||||
- Use Gemini for intelligent aggregation (optional)
|
||||
- Update or create SKILL documents using templates
|
||||
- Regenerate SKILL.md index
|
||||
|
||||
**Command Example**:
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-user-auth
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
```
|
||||
Session WFS-user-auth processed
|
||||
Updated:
|
||||
- sessions-timeline.md (1 session added)
|
||||
- lessons-learned.md (3 lessons merged)
|
||||
- conflict-patterns.md (1 conflict added)
|
||||
- SKILL.md (index regenerated)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Mode 2: All Sessions (`all`)
|
||||
|
||||
**Purpose**: Full regeneration - process all archived sessions in parallel for complete SKILL package
|
||||
|
||||
**Workflow**:
|
||||
1. **List sessions**: Read manifest.json to get all archived session IDs
|
||||
2. **Parallel invocation**: Launch multiple `universal-executor` agents in parallel (one per session)
|
||||
3. **Agent coordination**:
|
||||
- Each agent processes one session independently
|
||||
- Agents use Gemini for analysis
|
||||
- Agents collect data into JSON (no direct file writes)
|
||||
- Final aggregator agent merges results and generates SKILL documents
|
||||
|
||||
**Command Example**:
|
||||
```bash
|
||||
/memory:workflow-skill-memory all
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
```
|
||||
All sessions processed in parallel
|
||||
Sessions: 8 total
|
||||
Updated:
|
||||
- sessions-timeline.md (8 sessions)
|
||||
- lessons-learned.md (24 lessons aggregated)
|
||||
- conflict-patterns.md (12 conflicts documented)
|
||||
- SKILL.md (index regenerated)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Flow
|
||||
|
||||
### Phase 1: Validation and Setup
|
||||
|
||||
**Step 1.1: Parse Command Arguments**
|
||||
|
||||
Extract mode and session ID:
|
||||
```javascript
|
||||
if (args === "all") {
|
||||
mode = "all"
|
||||
} else if (args.startsWith("session ")) {
|
||||
mode = "session"
|
||||
session_id = args.replace("session ", "").trim()
|
||||
} else {
|
||||
ERROR = "Invalid arguments. Usage: session <session-id> | all"
|
||||
EXIT
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.2: Validate Archive Directory**
|
||||
```bash
|
||||
bash(test -d .workflow/.archives && echo "exists" || echo "missing")
|
||||
```
|
||||
|
||||
If missing, report error and exit.
|
||||
|
||||
**Step 1.3: Mode-Specific Validation**
|
||||
|
||||
**Single Session Mode**:
|
||||
```bash
|
||||
# Validate session ID format (must start with WFS-)
|
||||
if [[ ! "$session_id" =~ ^WFS- ]]; then
|
||||
ERROR = "Invalid session ID format. Only WFS-* sessions are supported"
|
||||
EXIT
|
||||
fi
|
||||
|
||||
# Check if session exists
|
||||
bash(test -d .workflow/.archives/{session_id} && echo "exists" || echo "missing")
|
||||
```
|
||||
|
||||
If missing, report error: "Session {session_id} not found in archives"
|
||||
|
||||
**All Sessions Mode**:
|
||||
```bash
|
||||
# Read manifest and filter only WFS- sessions
|
||||
bash(cat .workflow/.archives/manifest.json | jq -r '.archives[].session_id | select(startswith("WFS-"))')
|
||||
```
|
||||
|
||||
Store filtered session IDs in array. Ignore doc sessions and other non-WFS sessions.
|
||||
|
||||
**Step 1.4: TodoWrite Initialization**
|
||||
|
||||
**Single Session Mode**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Validate session existence", "status": "completed", "activeForm": "Validating session"},
|
||||
{"content": "Invoke agent to process session", "status": "in_progress", "activeForm": "Invoking agent"},
|
||||
{"content": "Verify SKILL package updated", "status": "pending", "activeForm": "Verifying update"}
|
||||
]})
|
||||
```
|
||||
|
||||
**All Sessions Mode**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Read manifest and list sessions", "status": "completed", "activeForm": "Reading manifest"},
|
||||
{"content": "Invoke agents in parallel", "status": "in_progress", "activeForm": "Invoking agents"},
|
||||
{"content": "Verify SKILL package regenerated", "status": "pending", "activeForm": "Verifying regeneration"}
|
||||
]})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Agent Invocation
|
||||
|
||||
#### Single Session Mode - Agent Task
|
||||
|
||||
Invoke `universal-executor` with session-specific task:
|
||||
|
||||
**Agent Prompt Structure**:
|
||||
```
|
||||
Task: Process Workflow Session for SKILL Package
|
||||
|
||||
Context:
|
||||
- Session ID: {session_id}
|
||||
- Session Path: .workflow/.archives/{session_id}/
|
||||
- Mode: Incremental update
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Read session data:
|
||||
- workflow-session.json (metadata)
|
||||
- IMPL_PLAN.md (implementation summary)
|
||||
- TODO_LIST.md (if exists)
|
||||
- manifest.json entry for lessons
|
||||
|
||||
2. Extract key information:
|
||||
- Description, tags, metrics
|
||||
- Lessons (successes, challenges, watch_patterns)
|
||||
- Context package path (reference only)
|
||||
- Key outcomes from IMPL_PLAN
|
||||
|
||||
3. Use Gemini for aggregation (optional):
|
||||
Command pattern:
|
||||
ccw cli -p "
|
||||
PURPOSE: Extract lessons and conflicts from workflow session
|
||||
TASK:
|
||||
• Analyze IMPL_PLAN and lessons from manifest
|
||||
• Identify success patterns and challenges
|
||||
• Extract conflict patterns with resolutions
|
||||
• Categorize by functional domain
|
||||
MODE: analysis
|
||||
CONTEXT: @IMPL_PLAN.md @workflow-session.json
|
||||
EXPECTED: Structured lessons and conflicts in JSON format
|
||||
RULES: Template reference from skill-aggregation.txt
|
||||
" --tool gemini --mode analysis --cd .workflow/.archives/{session_id}
|
||||
|
||||
3.5. **Generate SKILL.md Description** (CRITICAL for auto-loading):
|
||||
|
||||
Read skill-index.txt template Section: "Description Field Generation"
|
||||
|
||||
Execute command to get project root:
|
||||
```bash
|
||||
git rev-parse --show-toplevel # Example output: /d/Claude_dms3
|
||||
```
|
||||
|
||||
Apply description format:
|
||||
```
|
||||
Progressive workflow development history (located at {project_root}).
|
||||
Load this SKILL when continuing development, analyzing past implementations,
|
||||
or learning from workflow history, especially when no relevant context exists in memory.
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] Path uses forward slashes (not backslashes)
|
||||
- [ ] All three use cases present
|
||||
- [ ] Trigger optimization phrase included
|
||||
- [ ] Path is absolute (starts with / or drive letter)
|
||||
|
||||
4. Read templates for formatting guidance:
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-sessions-timeline.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-lessons-learned.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-conflict-patterns.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-index.txt
|
||||
|
||||
**CRITICAL**: From skill-index.txt, read these sections:
|
||||
- "Description Field Generation" - Rules for generating description
|
||||
- "Variable Substitution Guide" - All required variables
|
||||
- "Generation Instructions" - Step-by-step generation process
|
||||
- "Validation Checklist" - Final validation steps
|
||||
|
||||
5. Update SKILL documents:
|
||||
- sessions-timeline.md: Append new session, update domain grouping
|
||||
- lessons-learned.md: Merge lessons into categories, update frequencies
|
||||
- conflict-patterns.md: Add conflicts, update recurring pattern frequencies
|
||||
- SKILL.md: Regenerate index with updated counts
|
||||
|
||||
**For SKILL.md generation**:
|
||||
- Follow "Generation Instructions" from skill-index.txt (Steps 1-7)
|
||||
- Use git command for project_root: `git rev-parse --show-toplevel`
|
||||
- Apply "Description Field Generation" rules
|
||||
- Validate using "Validation Checklist"
|
||||
- Increment version (patch level)
|
||||
|
||||
6. Return result JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"session_id": "{session_id}",
|
||||
"updates": {
|
||||
"sessions_added": 1,
|
||||
"lessons_merged": count,
|
||||
"conflicts_added": count
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### All Sessions Mode - Parallel Agent Tasks
|
||||
|
||||
**Step 2.1: Launch parallel session analyzers**
|
||||
|
||||
Invoke multiple agents in parallel (one message with multiple Task calls):
|
||||
|
||||
**Per-Session Agent Prompt**:
|
||||
```
|
||||
Task: Extract Session Data for SKILL Package
|
||||
|
||||
Context:
|
||||
- Session ID: {session_id}
|
||||
- Mode: Parallel analysis (no direct file writes)
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Read session data (same as single mode)
|
||||
|
||||
2. Extract key information (same as single mode)
|
||||
|
||||
3. Use Gemini for analysis (same as single mode)
|
||||
|
||||
4. Return structured data JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"session_id": "{session_id}",
|
||||
"data": {
|
||||
"metadata": {
|
||||
"description": "...",
|
||||
"archived_at": "...",
|
||||
"tags": [...],
|
||||
"metrics": {...}
|
||||
},
|
||||
"lessons": {
|
||||
"successes": [...],
|
||||
"challenges": [...],
|
||||
"watch_patterns": [...]
|
||||
},
|
||||
"conflicts": [
|
||||
{
|
||||
"type": "architecture|dependencies|testing|performance",
|
||||
"pattern": "...",
|
||||
"resolution": "...",
|
||||
"code_impact": [...]
|
||||
}
|
||||
],
|
||||
"impl_summary": "First 200 chars of IMPL_PLAN",
|
||||
"context_package_path": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2.2: Aggregate results**
|
||||
|
||||
After all session agents complete, invoke aggregator agent:
|
||||
|
||||
**Aggregator Agent Prompt**:
|
||||
```
|
||||
Task: Aggregate Session Results and Generate SKILL Package
|
||||
|
||||
Context:
|
||||
- Mode: Full regeneration
|
||||
- Input: JSON results from {session_count} session agents
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Aggregate all session data:
|
||||
- Collect metadata from all sessions
|
||||
- Merge lessons by category
|
||||
- Group conflicts by type
|
||||
- Sort sessions by date
|
||||
|
||||
2. Use Gemini for final aggregation:
|
||||
ccw cli -p "
|
||||
PURPOSE: Aggregate lessons and conflicts from all workflow sessions
|
||||
TASK:
|
||||
• Group successes by functional domain
|
||||
• Categorize challenges by severity (HIGH/MEDIUM/LOW)
|
||||
• Identify recurring conflict patterns
|
||||
• Calculate frequencies and prioritize
|
||||
MODE: analysis
|
||||
CONTEXT: [Provide aggregated JSON data]
|
||||
EXPECTED: Final aggregated structure for SKILL documents
|
||||
RULES: Template reference from skill-aggregation.txt
|
||||
" --tool gemini --mode analysis
|
||||
|
||||
3. Read templates for formatting (same 4 templates as single mode)
|
||||
|
||||
4. Generate all SKILL documents:
|
||||
- sessions-timeline.md (all sessions, sorted by date)
|
||||
- lessons-learned.md (aggregated lessons with frequencies)
|
||||
- conflict-patterns.md (recurring patterns with resolutions)
|
||||
- SKILL.md (index with progressive loading)
|
||||
|
||||
5. Write files to .claude/skills/workflow-progress/
|
||||
|
||||
6. Return result JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"sessions_processed": count,
|
||||
"files_generated": ["SKILL.md", "sessions-timeline.md", ...],
|
||||
"summary": {
|
||||
"total_sessions": count,
|
||||
"functional_domains": [...],
|
||||
"date_range": "...",
|
||||
"lessons_count": count,
|
||||
"conflicts_count": count
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Verification
|
||||
|
||||
**Step 3.1: Check SKILL Package Files**
|
||||
```bash
|
||||
bash(ls -lh .claude/skills/workflow-progress/)
|
||||
```
|
||||
|
||||
Verify all 4 files exist:
|
||||
- SKILL.md
|
||||
- sessions-timeline.md
|
||||
- lessons-learned.md
|
||||
- conflict-patterns.md
|
||||
|
||||
**Step 3.2: TodoWrite Completion**
|
||||
|
||||
Mark all tasks as completed.
|
||||
|
||||
**Step 3.3: Display Summary**
|
||||
|
||||
**Single Session Mode**:
|
||||
```
|
||||
Session {session_id} processed successfully
|
||||
|
||||
Updated:
|
||||
- sessions-timeline.md
|
||||
- lessons-learned.md
|
||||
- conflict-patterns.md
|
||||
- SKILL.md
|
||||
|
||||
SKILL Location: .claude/skills/workflow-progress/SKILL.md
|
||||
```
|
||||
|
||||
**All Sessions Mode**:
|
||||
```
|
||||
All sessions processed in parallel
|
||||
|
||||
Sessions: {count} total
|
||||
Functional Domains: {domain_list}
|
||||
Date Range: {earliest} - {latest}
|
||||
|
||||
Generated:
|
||||
- sessions-timeline.md ({count} sessions)
|
||||
- lessons-learned.md ({lessons_count} lessons)
|
||||
- conflict-patterns.md ({conflicts_count} conflicts)
|
||||
- SKILL.md (4-level progressive loading)
|
||||
|
||||
SKILL Location: .claude/skills/workflow-progress/SKILL.md
|
||||
|
||||
Usage:
|
||||
- Level 0: Quick refresh (~2K tokens)
|
||||
- Level 1: Recent history (~8K tokens)
|
||||
- Level 2: Complete analysis (~25K tokens)
|
||||
- Level 3: Deep dive (~40K tokens)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Agent Guidelines
|
||||
|
||||
### Agent Capabilities
|
||||
|
||||
**universal-executor agents can**:
|
||||
- Read files from `.workflow/.archives/`
|
||||
- Execute bash commands
|
||||
- Call Gemini CLI for intelligent analysis
|
||||
- Read template files for formatting guidance
|
||||
- Write SKILL package files (single mode) or return JSON (parallel mode)
|
||||
- Return structured results
|
||||
|
||||
### Gemini Usage Pattern
|
||||
|
||||
**When to use Gemini**:
|
||||
- Aggregating lessons from multiple sources
|
||||
- Identifying recurring patterns
|
||||
- Classifying conflicts by type and severity
|
||||
- Extracting structured data from IMPL_PLAN
|
||||
|
||||
**Fallback Strategy**: If Gemini fails or times out, use direct file parsing with structured extraction logic.
|
||||
|
||||
---
|
||||
|
||||
## Template System
|
||||
|
||||
### Template Files
|
||||
|
||||
All templates located in: `~/.claude/workflows/cli-templates/prompts/workflow/`
|
||||
|
||||
1. **skill-sessions-timeline.txt**: Format for sessions-timeline.md
|
||||
2. **skill-lessons-learned.txt**: Format for lessons-learned.md
|
||||
3. **skill-conflict-patterns.txt**: Format for conflict-patterns.md
|
||||
4. **skill-index.txt**: Format for SKILL.md index
|
||||
5. **skill-aggregation.txt**: Rules for Gemini aggregation (existing)
|
||||
|
||||
### Template Usage in Agent
|
||||
|
||||
**Agents read templates to understand**:
|
||||
- File structure and markdown format
|
||||
- Data sources (which files to read)
|
||||
- Update strategy (incremental vs full)
|
||||
- Formatting rules and conventions
|
||||
- Aggregation logic (for Gemini)
|
||||
|
||||
**Templates are NOT shown in this command documentation** - agents read them directly as needed.
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Validation Errors
|
||||
- **No archives directory**: "Error: No workflow archives found at .workflow/.archives/"
|
||||
- **Invalid session ID format**: "Error: Invalid session ID format. Only WFS-* sessions are supported"
|
||||
- **Session not found**: "Error: Session {session_id} not found in archives"
|
||||
- **No WFS sessions in manifest**: "Error: No WFS-* workflow sessions found in manifest.json"
|
||||
|
||||
### Agent Errors
|
||||
- If agent fails, report error message from agent result
|
||||
- If Gemini times out, agents use fallback direct parsing
|
||||
- If template read fails, agents use inline format
|
||||
|
||||
### Recovery
|
||||
- Single session mode: Can be retried without affecting other sessions
|
||||
- All sessions mode: If one agent fails, others continue; retry failed sessions individually
|
||||
|
||||
|
||||
|
||||
## Integration
|
||||
|
||||
### Called by `/workflow:session:complete`
|
||||
|
||||
Automatically invoked after session archival:
|
||||
```bash
|
||||
SlashCommand(command="/memory:workflow-skill-memory session {session_id}")
|
||||
```
|
||||
|
||||
### Manual Invocation
|
||||
|
||||
Users can manually process sessions:
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-custom-feature # Single session
|
||||
/memory:workflow-skill-memory all # Full regeneration
|
||||
```
|
||||
@@ -1,208 +0,0 @@
|
||||
---
|
||||
name: breakdown
|
||||
description: Decompose complex task into subtasks with dependency mapping, creates child task JSONs with parent references and execution order
|
||||
argument-hint: "[-y|--yes] task-id"
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm breakdown, use recommended subtask structure.
|
||||
|
||||
# Task Breakdown Command (/task:breakdown)
|
||||
|
||||
## Overview
|
||||
Breaks down complex tasks into executable subtasks with context inheritance and agent assignment.
|
||||
|
||||
## Core Principles
|
||||
**File Cohesion:** Related files must stay in same task
|
||||
**10-Task Limit:** Total tasks cannot exceed 10 (triggers re-scoping)
|
||||
|
||||
## Core Features
|
||||
|
||||
**CRITICAL**: Manual breakdown with safety controls to prevent file conflicts and task limit violations.
|
||||
|
||||
### Breakdown Process
|
||||
1. **Session Check**: Verify active session contains parent task
|
||||
2. **Task Validation**: Ensure parent is `pending` status
|
||||
3. **10-Task Limit Check**: Verify breakdown won't exceed total limit
|
||||
4. **Manual Decomposition**: User defines subtasks with validation
|
||||
5. **File Conflict Detection**: Warn if same files appear in multiple subtasks
|
||||
6. **Similar Function Warning**: Alert if subtasks have overlapping functionality
|
||||
7. **Context Distribution**: Inherit parent requirements and scope
|
||||
8. **Agent Assignment**: Auto-assign agents based on subtask type
|
||||
9. **TODO_LIST Update**: Regenerate TODO_LIST.md with new structure
|
||||
|
||||
### Breakdown Rules
|
||||
- Only `pending` tasks can be broken down
|
||||
- **Manual breakdown only**: Automated breakdown disabled to prevent violations
|
||||
- Parent becomes `container` status (not executable)
|
||||
- Subtasks use format: IMPL-N.M (max 2 levels)
|
||||
- Context flows from parent to subtasks
|
||||
- All relationships tracked in JSON
|
||||
- **10-task limit enforced**: Breakdown rejected if total would exceed 10 tasks
|
||||
- **File cohesion preserved**: Same files cannot be split across subtasks
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Breakdown
|
||||
```bash
|
||||
/task:breakdown impl-1
|
||||
```
|
||||
|
||||
Interactive process:
|
||||
```
|
||||
Task: Build authentication module
|
||||
Current total tasks: 6/10
|
||||
|
||||
MANUAL BREAKDOWN REQUIRED
|
||||
Define subtasks manually (remaining capacity: 4 tasks):
|
||||
|
||||
1. Enter subtask title: User authentication core
|
||||
Focus files: models/User.js, routes/auth.js, middleware/auth.js
|
||||
|
||||
2. Enter subtask title: OAuth integration
|
||||
Focus files: services/OAuthService.js, routes/oauth.js
|
||||
|
||||
FILE CONFLICT DETECTED:
|
||||
- routes/auth.js appears in multiple subtasks
|
||||
- Recommendation: Merge related authentication routes
|
||||
|
||||
SIMILAR FUNCTIONALITY WARNING:
|
||||
- "User authentication" and "OAuth integration" both handle auth
|
||||
- Consider combining into single task
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "File conflicts and/or similar functionality detected. How do you want to proceed?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Proceed with breakdown", description: "Accept the risks and create the subtasks as defined." },
|
||||
{ label: "Restart breakdown", description: "Discard current subtasks and start over." },
|
||||
{ label: "Cancel breakdown", description: "Abort the operation and leave the parent task as is." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Proceed with breakdown"
|
||||
|
||||
Task IMPL-1 broken down:
|
||||
IMPL-1: Build authentication module (container)
|
||||
├── IMPL-1.1: User authentication core -> @code-developer
|
||||
└── IMPL-1.2: OAuth integration -> @code-developer
|
||||
|
||||
Files updated: .task/IMPL-1.json + 2 subtask files + TODO_LIST.md
|
||||
```
|
||||
|
||||
## Decomposition Logic
|
||||
|
||||
### Agent Assignment
|
||||
- **Design/Planning** → `@planning-agent`
|
||||
- **Implementation** → `@code-developer`
|
||||
- **Testing** → `@code-developer` (type: "test-gen")
|
||||
- **Test Validation** → `@test-fix-agent` (type: "test-fix")
|
||||
- **Review** → `@universal-executor` (optional)
|
||||
|
||||
### Context Inheritance
|
||||
- Subtasks inherit parent requirements
|
||||
- Scope refined for specific subtask
|
||||
- Implementation details distributed appropriately
|
||||
|
||||
## Safety Controls
|
||||
|
||||
### File Conflict Detection
|
||||
**Validates file cohesion across subtasks:**
|
||||
- Scans `focus_paths` in all subtasks
|
||||
- Warns if same file appears in multiple subtasks
|
||||
- Suggests merging subtasks with overlapping files
|
||||
- Blocks breakdown if critical conflicts detected
|
||||
|
||||
### Similar Functionality Detection
|
||||
**Prevents functional overlap:**
|
||||
- Analyzes subtask titles for similar keywords
|
||||
- Warns about potential functional redundancy
|
||||
- Suggests consolidation of related functionality
|
||||
- Examples: "user auth" + "login system" → merge recommendation
|
||||
|
||||
### 10-Task Limit Enforcement
|
||||
**Hard limit compliance:**
|
||||
- Counts current total tasks in session
|
||||
- Calculates breakdown impact on total
|
||||
- Rejects breakdown if would exceed 10 tasks
|
||||
- Suggests re-scoping if limit reached
|
||||
|
||||
### Manual Control Requirements
|
||||
**User-driven breakdown only:**
|
||||
- No automatic subtask generation
|
||||
- User must define each subtask title and scope
|
||||
- Real-time validation during input
|
||||
- Confirmation required before execution
|
||||
|
||||
## Implementation Details
|
||||
|
||||
- Complete task JSON schema
|
||||
- Implementation field structure
|
||||
- Context inheritance rules
|
||||
- Agent assignment logic
|
||||
|
||||
## Validation
|
||||
|
||||
### Pre-breakdown Checks
|
||||
1. Active session exists
|
||||
2. Task found in session
|
||||
3. Task status is `pending`
|
||||
4. Not already broken down
|
||||
5. **10-task limit compliance**: Total tasks + new subtasks ≤ 10
|
||||
6. **Manual mode enabled**: No automatic breakdown allowed
|
||||
|
||||
### Post-breakdown Actions
|
||||
1. Update parent to `container` status
|
||||
2. Create subtask JSON files
|
||||
3. Update parent subtasks list
|
||||
4. Update session stats
|
||||
5. **Regenerate TODO_LIST.md** with new hierarchy
|
||||
6. Validate file paths in focus_paths
|
||||
7. Update session task count
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Breakdown
|
||||
```bash
|
||||
/task:breakdown impl-1
|
||||
|
||||
impl-1: Build authentication (container)
|
||||
├── impl-1.1: Design schema -> @planning-agent
|
||||
├── impl-1.2: Implement logic + tests -> @code-developer
|
||||
└── impl-1.3: Execute & fix tests -> @test-fix-agent
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```bash
|
||||
# Task not found
|
||||
Task IMPL-5 not found
|
||||
|
||||
# Already broken down
|
||||
Task IMPL-1 already has subtasks
|
||||
|
||||
# Wrong status
|
||||
Cannot breakdown completed task IMPL-2
|
||||
|
||||
# 10-task limit exceeded
|
||||
Breakdown would exceed 10-task limit (current: 8, proposed: 4)
|
||||
Suggestion: Re-scope project into smaller iterations
|
||||
|
||||
# File conflicts detected
|
||||
File conflict: routes/auth.js appears in IMPL-1.1 and IMPL-1.2
|
||||
Recommendation: Merge subtasks or redistribute files
|
||||
|
||||
# Similar functionality warning
|
||||
Similar functions detected: "user login" and "authentication"
|
||||
Consider consolidating related functionality
|
||||
|
||||
# Manual breakdown required
|
||||
Automatic breakdown disabled. Use manual breakdown process.
|
||||
```
|
||||
|
||||
**System ensures**: Manual breakdown control with file cohesion enforcement, similar functionality detection, and 10-task limit compliance
|
||||
@@ -1,152 +0,0 @@
|
||||
---
|
||||
name: create
|
||||
description: Generate task JSON from natural language description with automatic file pattern detection, scope inference, and dependency analysis
|
||||
argument-hint: "\"task title\""
|
||||
---
|
||||
|
||||
# Task Create Command (/task:create)
|
||||
|
||||
## Overview
|
||||
Creates new implementation tasks with automatic context awareness and ID generation.
|
||||
|
||||
## Core Principles
|
||||
**Task System:** @~/.claude/workflows/task-core.md
|
||||
|
||||
## Core Features
|
||||
|
||||
### Automatic Behaviors
|
||||
- **ID Generation**: Auto-generates IMPL-N format (max 2 levels)
|
||||
- **Context Inheritance**: Inherits from active workflow session
|
||||
- **JSON Creation**: Creates task JSON in active session
|
||||
- **Status Setting**: Initial status = "pending"
|
||||
- **Agent Assignment**: Suggests agent based on task type
|
||||
- **Session Integration**: Updates workflow session stats
|
||||
|
||||
### Context Awareness
|
||||
- Validates active workflow session exists
|
||||
- Avoids duplicate task IDs
|
||||
- Inherits session requirements and scope
|
||||
- Suggests task relationships
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Creation
|
||||
```bash
|
||||
/task:create "Build authentication module"
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
Task created: IMPL-1
|
||||
Title: Build authentication module
|
||||
Type: feature
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
|
||||
### Task Types
|
||||
- `feature` - New functionality (default)
|
||||
- `bugfix` - Bug fixes
|
||||
- `refactor` - Code improvements
|
||||
- `test` - Test implementation
|
||||
- `docs` - Documentation
|
||||
|
||||
## Task Creation Process
|
||||
|
||||
1. **Session Validation**: Check active workflow session
|
||||
2. **ID Generation**: Auto-increment IMPL-N
|
||||
3. **Context Inheritance**: Load workflow context
|
||||
4. **Implementation Setup**: Initialize implementation field
|
||||
5. **Agent Assignment**: Select appropriate agent
|
||||
6. **File Creation**: Save JSON to .task/ directory
|
||||
7. **Session Update**: Update workflow stats
|
||||
|
||||
**Task Schema**: See @~/.claude/workflows/task-core.md for complete JSON structure
|
||||
|
||||
## Implementation Field Setup
|
||||
|
||||
### Auto-Population Strategy
|
||||
- **Detailed info**: Extract from task description and scope
|
||||
- **Missing info**: Mark `pre_analysis` as multi-step array format for later pre-analysis
|
||||
- **Basic structure**: Initialize with standard template
|
||||
|
||||
### Analysis Triggers
|
||||
When implementation details incomplete:
|
||||
```bash
|
||||
Task requires analysis for implementation details
|
||||
Suggest running: gemini analysis for file locations and dependencies
|
||||
```
|
||||
|
||||
## File Management
|
||||
|
||||
### JSON Task File
|
||||
- **Location**: `.task/IMPL-[N].json` in active session
|
||||
- **Content**: Complete task with implementation field
|
||||
- **Updates**: Session stats only
|
||||
|
||||
### Simple Process
|
||||
1. Validate session and inputs
|
||||
2. Generate task JSON
|
||||
3. Update session stats
|
||||
4. Notify completion
|
||||
|
||||
## Context Inheritance
|
||||
|
||||
Tasks inherit from:
|
||||
1. **Active Session** - Requirements and scope from workflow-session.json
|
||||
2. **Planning Document** - Context from IMPL_PLAN.md
|
||||
3. **Parent Task** - For subtasks (IMPL-N.M format)
|
||||
|
||||
## Agent Assignment
|
||||
|
||||
Based on task type and title keywords:
|
||||
- **Build/Implement** → @code-developer
|
||||
- **Design/Plan** → @planning-agent
|
||||
- **Test Generation** → @code-developer (type: "test-gen")
|
||||
- **Test Execution/Fix** → @test-fix-agent (type: "test-fix")
|
||||
- **Review/Audit** → @universal-executor (optional, only when explicitly requested)
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. **Session Check** - Active workflow session required
|
||||
2. **Duplicate Check** - Avoid similar task titles
|
||||
3. **ID Uniqueness** - Auto-increment task IDs
|
||||
4. **Schema Validation** - Ensure proper JSON structure
|
||||
|
||||
## Error Handling
|
||||
|
||||
```bash
|
||||
# No workflow session
|
||||
No active workflow found
|
||||
Use: /workflow init "project name"
|
||||
|
||||
# Duplicate task
|
||||
Similar task exists: IMPL-3
|
||||
Continue anyway? (y/n)
|
||||
|
||||
# Max depth exceeded
|
||||
Cannot create IMPL-1.2.1 (max 2 levels)
|
||||
Use: IMPL-2 for new main task
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Feature Task
|
||||
```bash
|
||||
/task:create "Implement user authentication"
|
||||
|
||||
Created IMPL-1: Implement user authentication
|
||||
Type: feature
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
|
||||
### Bug Fix
|
||||
```bash
|
||||
/task:create "Fix login validation bug" --type=bugfix
|
||||
|
||||
Created IMPL-2: Fix login validation bug
|
||||
Type: bugfix
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
@@ -1,270 +0,0 @@
|
||||
---
|
||||
name: execute
|
||||
description: Execute task JSON using appropriate agent (@doc-generator/@implementation-agent/@test-agent) with pre-analysis context loading and status tracking
|
||||
argument-hint: "task-id"
|
||||
---
|
||||
|
||||
## Command Overview: /task:execute
|
||||
|
||||
**Purpose**: Executes tasks using intelligent agent selection, context preparation, and progress tracking.
|
||||
|
||||
|
||||
## Execution Modes
|
||||
|
||||
- **auto (Default)**
|
||||
- Fully autonomous execution with automatic agent selection.
|
||||
- Provides progress updates at each checkpoint.
|
||||
- Automatically completes the task when done.
|
||||
- **guided**
|
||||
- Executes step-by-step, requiring user confirmation at each checkpoint.
|
||||
- Allows for dynamic adjustments and manual review during the process.
|
||||
- **review**
|
||||
- Optional manual review using `@universal-executor`.
|
||||
- Used only when explicitly requested by user.
|
||||
|
||||
## Agent Selection Logic
|
||||
|
||||
The system determines the appropriate agent for a task using the following logic.
|
||||
|
||||
```pseudo
|
||||
FUNCTION select_agent(task, agent_override):
|
||||
// A manual override always takes precedence.
|
||||
// Corresponds to the --agent=<agent-type> flag.
|
||||
IF agent_override IS NOT NULL:
|
||||
RETURN agent_override
|
||||
|
||||
// If no override, select based on keywords in the task title.
|
||||
ELSE:
|
||||
CASE task.title:
|
||||
WHEN CONTAINS "Build API", "Implement":
|
||||
RETURN "@code-developer"
|
||||
WHEN CONTAINS "Design schema", "Plan":
|
||||
RETURN "@planning-agent"
|
||||
WHEN CONTAINS "Write tests", "Generate tests":
|
||||
RETURN "@code-developer" // type: test-gen
|
||||
WHEN CONTAINS "Execute tests", "Fix tests", "Validate":
|
||||
RETURN "@test-fix-agent" // type: test-fix
|
||||
WHEN CONTAINS "Review code":
|
||||
RETURN "@universal-executor" // Optional manual review
|
||||
DEFAULT:
|
||||
RETURN "@code-developer" // Default agent
|
||||
END CASE
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
## Core Execution Protocol
|
||||
|
||||
`Pre-Execution` -> `Execution` -> `Post-Execution`
|
||||
|
||||
### Pre-Execution Protocol
|
||||
|
||||
`Validate Task & Dependencies` **->** `Prepare Execution Context` **->** `Coordinate with TodoWrite`
|
||||
|
||||
- **Validation**: Checks for the task's JSON file in `.task/` and resolves its dependencies.
|
||||
- **Context Preparation**: Loads task and workflow context, preparing it for the selected agent.
|
||||
- **Session Context Injection**: Provides workflow directory paths to agents for TODO_LIST.md and summary management.
|
||||
- **TodoWrite Coordination**: Generates execution Todos and checkpoints, syncing with `TODO_LIST.md`.
|
||||
|
||||
### Post-Execution Protocol
|
||||
|
||||
`Update Task Status` **->** `Generate Summary` **->** `Save Artifacts` **->** `Sync All Progress` **->** `Validate File Integrity`
|
||||
|
||||
- Updates status in the task's JSON file and `TODO_LIST.md`.
|
||||
- Creates a summary in `.summaries/`.
|
||||
- Stores outputs and syncs progress across the entire workflow session.
|
||||
|
||||
### Task & Subtask Execution Logic
|
||||
|
||||
This logic defines how single, multiple, or parent tasks are handled.
|
||||
|
||||
```pseudo
|
||||
FUNCTION execute_task_command(task_id, mode, parallel_flag):
|
||||
// Handle parent tasks by executing their subtasks.
|
||||
IF is_parent_task(task_id):
|
||||
subtasks = get_subtasks(task_id)
|
||||
EXECUTE_SUBTASK_BATCH(subtasks, mode)
|
||||
|
||||
// Handle wildcard execution (e.g., IMPL-001.*)
|
||||
ELSE IF task_id CONTAINS "*":
|
||||
subtasks = find_matching_tasks(task_id)
|
||||
IF parallel_flag IS true:
|
||||
EXECUTE_IN_PARALLEL(subtasks)
|
||||
ELSE:
|
||||
FOR each subtask in subtasks:
|
||||
EXECUTE_SINGLE_TASK(subtask, mode)
|
||||
|
||||
// Default case for a single task ID.
|
||||
ELSE:
|
||||
EXECUTE_SINGLE_TASK(task_id, mode)
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
### Error Handling & Recovery Logic
|
||||
|
||||
```pseudo
|
||||
FUNCTION pre_execution_check(task):
|
||||
// Ensure dependencies are met before starting.
|
||||
IF task.dependencies ARE NOT MET:
|
||||
LOG_ERROR("Cannot execute " + task.id)
|
||||
LOG_INFO("Blocked by: " + unmet_dependencies)
|
||||
HALT_EXECUTION()
|
||||
|
||||
FUNCTION on_execution_failure(checkpoint):
|
||||
// Provide user with recovery options upon failure.
|
||||
LOG_WARNING("Execution failed at checkpoint " + checkpoint)
|
||||
PRESENT_OPTIONS([
|
||||
"Retry from checkpoint",
|
||||
"Retry from beginning",
|
||||
"Switch to guided mode",
|
||||
"Abort execution"
|
||||
])
|
||||
AWAIT user_input
|
||||
// System performs the selected action.
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
|
||||
### Simplified Context Structure (JSON)
|
||||
|
||||
This is the simplified data structure loaded to provide context for task execution.
|
||||
|
||||
```json
|
||||
{
|
||||
"task": {
|
||||
"id": "IMPL-1",
|
||||
"title": "Build authentication module",
|
||||
"type": "feature",
|
||||
"status": "active",
|
||||
"agent": "code-developer",
|
||||
"context": {
|
||||
"requirements": ["JWT authentication", "OAuth2 support"],
|
||||
"scope": ["src/auth/*", "tests/auth/*"],
|
||||
"acceptance": ["Module handles JWT tokens", "OAuth2 flow implemented"],
|
||||
"inherited_from": "WFS-user-auth"
|
||||
},
|
||||
"relations": {
|
||||
"parent": null,
|
||||
"subtasks": ["IMPL-1.1", "IMPL-1.2"],
|
||||
"dependencies": ["IMPL-0"]
|
||||
},
|
||||
"implementation": {
|
||||
"files": [
|
||||
{
|
||||
"path": "src/auth/login.ts",
|
||||
"location": {
|
||||
"function": "authenticateUser",
|
||||
"lines": "25-65",
|
||||
"description": "Main authentication logic"
|
||||
},
|
||||
"original_code": "// Code snippet extracted via gemini analysis",
|
||||
"modifications": {
|
||||
"current_state": "Basic password authentication only",
|
||||
"proposed_changes": [
|
||||
"Add JWT token generation",
|
||||
"Implement OAuth2 callback handling",
|
||||
"Add multi-factor authentication support"
|
||||
],
|
||||
"logic_flow": [
|
||||
"validateCredentials() ───► checkUserExists()",
|
||||
"◊─── if password ───► generateJWT() ───► return token",
|
||||
"◊─── if OAuth ───► validateOAuthCode() ───► exchangeForToken()",
|
||||
"◊─── if MFA ───► sendMFACode() ───► awaitVerification()"
|
||||
],
|
||||
"reason": "Support modern authentication standards and security requirements",
|
||||
"expected_outcome": "Comprehensive authentication system supporting multiple methods"
|
||||
}
|
||||
}
|
||||
],
|
||||
"context_notes": {
|
||||
"dependencies": ["jsonwebtoken", "passport", "speakeasy"],
|
||||
"affected_modules": ["user-session", "auth-middleware", "api-routes"],
|
||||
"risks": [
|
||||
"Breaking changes to existing login endpoints",
|
||||
"Token storage and rotation complexity",
|
||||
"OAuth provider configuration dependencies"
|
||||
],
|
||||
"performance_considerations": "JWT validation adds ~10ms per request, OAuth callbacks may timeout",
|
||||
"error_handling": "Ensure sensitive authentication errors don't leak user enumeration data"
|
||||
},
|
||||
"pre_analysis": [
|
||||
{
|
||||
"action": "analyze patterns",
|
||||
"template": "~/.claude/workflows/cli-templates/prompts/analysis/02-analyze-code-patterns.txt",
|
||||
"method": "gemini"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"workflow": {
|
||||
"session": "WFS-user-auth",
|
||||
"phase": "IMPLEMENT",
|
||||
"session_context": {
|
||||
"workflow_directory": ".workflow/active/WFS-user-auth/",
|
||||
"todo_list_location": ".workflow/active/WFS-user-auth/TODO_LIST.md",
|
||||
"summaries_directory": ".workflow/active/WFS-user-auth/.summaries/",
|
||||
"task_json_location": ".workflow/active/WFS-user-auth/.task/"
|
||||
}
|
||||
},
|
||||
"execution": {
|
||||
"agent": "code-developer",
|
||||
"mode": "auto",
|
||||
"attempts": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Agent-Specific Context
|
||||
|
||||
Different agents receive context tailored to their function, including implementation details:
|
||||
|
||||
**`@code-developer`**:
|
||||
- Complete implementation.files array with file paths and locations
|
||||
- original_code snippets and proposed_changes for precise modifications
|
||||
- logic_flow diagrams for understanding data flow
|
||||
- Dependencies and affected modules for integration planning
|
||||
- Performance and error handling considerations
|
||||
|
||||
**`@planning-agent`**:
|
||||
- High-level requirements, constraints, success criteria
|
||||
- Implementation risks and mitigation strategies
|
||||
- Architecture implications from implementation.context_notes
|
||||
|
||||
**`@test-fix-agent`**:
|
||||
- Test files to execute from task.context.focus_paths
|
||||
- Source files to fix from implementation.files[].path
|
||||
- Expected behaviors from implementation.modifications.logic_flow
|
||||
- Error conditions to validate from implementation.context_notes.error_handling
|
||||
- Performance requirements from implementation.context_notes.performance_considerations
|
||||
|
||||
**`@universal-executor`**:
|
||||
- Used for optional manual reviews when explicitly requested
|
||||
- Code quality standards and implementation patterns
|
||||
- Security considerations from implementation.context_notes.risks
|
||||
- Dependency validation from implementation.context_notes.dependencies
|
||||
- Architecture compliance checks
|
||||
|
||||
### Simplified File Output
|
||||
|
||||
- **Task JSON File (`.task/<task-id>.json`)**: Updated with status and last attempt time only.
|
||||
- **Session File (`workflow-session.json`)**: Updated task stats (completed count).
|
||||
- **Summary File**: Generated in `.summaries/` upon completion (optional).
|
||||
|
||||
### Simplified Summary Template
|
||||
|
||||
Optional summary file generated at `.summaries/IMPL-[task-id]-summary.md`.
|
||||
|
||||
```markdown
|
||||
# Task Summary: IMPL-1 Build Authentication Module
|
||||
|
||||
## What Was Done
|
||||
- Created src/auth/login.ts with JWT validation
|
||||
- Added tests in tests/auth.test.ts
|
||||
|
||||
## Execution Results
|
||||
- **Agent**: code-developer
|
||||
- **Status**: completed
|
||||
|
||||
## Files Modified
|
||||
- `src/auth/login.ts` (created)
|
||||
- `tests/auth.test.ts` (created)
|
||||
```
|
||||
@@ -1,441 +0,0 @@
|
||||
---
|
||||
name: replan
|
||||
description: Update task JSON with new requirements or batch-update multiple tasks from verification report, tracks changes in task-changes.json
|
||||
argument-hint: "[-y|--yes] task-id [\"text\"|file.md] | --batch [verification-report.md]"
|
||||
allowed-tools: Read(*), Write(*), Edit(*), TodoWrite(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm updates, use recommended changes.
|
||||
|
||||
# Task Replan Command (/task:replan)
|
||||
|
||||
> **⚠️ DEPRECATION NOTICE**: This command is maintained for backward compatibility. For new workflows, use `/workflow:replan` which provides:
|
||||
> - Session-level replanning with comprehensive artifact updates
|
||||
> - Interactive boundary clarification
|
||||
> - Updates to IMPL_PLAN.md, TODO_LIST.md, and session metadata
|
||||
> - Better integration with workflow sessions
|
||||
>
|
||||
> **Migration**: Replace `/task:replan IMPL-1 "changes"` with `/workflow:replan IMPL-1 "changes"`
|
||||
|
||||
## Overview
|
||||
Replans individual tasks or batch processes multiple tasks with change tracking and backup management.
|
||||
|
||||
**Modes**:
|
||||
- **Single Task Mode**: Replan one task with specific changes
|
||||
- **Batch Mode**: Process multiple tasks from action-plan verification report
|
||||
|
||||
## Key Features
|
||||
- **Single/Batch Operations**: Single task or multiple tasks from verification report
|
||||
- **Multiple Input Sources**: Text, files, or verification report
|
||||
- **Backup Management**: Automatic backup of previous versions
|
||||
- **Change Documentation**: Track all modifications
|
||||
- **Progress Tracking**: TodoWrite integration for batch operations
|
||||
|
||||
**CRITICAL**: Validates active session before replanning
|
||||
|
||||
## Operation Modes
|
||||
|
||||
### Single Task Mode
|
||||
|
||||
#### Direct Text (Default)
|
||||
```bash
|
||||
/task:replan IMPL-1 "Add OAuth2 authentication support"
|
||||
```
|
||||
|
||||
#### File-based Input
|
||||
```bash
|
||||
/task:replan IMPL-1 updated-specs.md
|
||||
```
|
||||
Supports: .md, .txt, .json, .yaml
|
||||
|
||||
#### Interactive Mode
|
||||
```bash
|
||||
/task:replan IMPL-1 --interactive
|
||||
```
|
||||
Guided step-by-step modification process with validation
|
||||
|
||||
### Batch Mode
|
||||
|
||||
#### From Verification Report
|
||||
```bash
|
||||
/task:replan --batch ACTION_PLAN_VERIFICATION.md
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Parse verification report to extract replan recommendations
|
||||
2. Create TodoWrite task list for all modifications
|
||||
3. Process each task sequentially with confirmation
|
||||
4. Track progress and generate summary report
|
||||
|
||||
**Auto-detection**: If input file contains "Action Plan Verification Report" header, automatically enters batch mode
|
||||
|
||||
## Replanning Process
|
||||
|
||||
### Single Task Process
|
||||
|
||||
1. **Load & Validate**: Read task JSON and validate session
|
||||
2. **Parse Input**: Process changes from input source
|
||||
3. **Create Backup**: Save previous version to backup folder
|
||||
4. **Update Task**: Modify JSON structure and relationships
|
||||
5. **Save Changes**: Write updated task and increment version
|
||||
6. **Update Session**: Reflect changes in workflow stats
|
||||
|
||||
### Batch Process
|
||||
|
||||
1. **Parse Verification Report**: Extract all replan recommendations
|
||||
2. **Initialize TodoWrite**: Create task list for tracking
|
||||
3. **For Each Task**:
|
||||
- Mark todo as in_progress
|
||||
- Load and validate task JSON
|
||||
- Create backup
|
||||
- Apply recommended changes
|
||||
- Save updated task
|
||||
- Mark todo as completed
|
||||
4. **Generate Summary**: Report all changes and backup locations
|
||||
|
||||
## Backup Management
|
||||
|
||||
### Backup Tracking
|
||||
Tasks maintain backup history:
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-1",
|
||||
"version": "1.2",
|
||||
"replan_history": [
|
||||
{
|
||||
"version": "1.2",
|
||||
"reason": "Add OAuth2 support",
|
||||
"input_source": "direct_text",
|
||||
"backup_location": ".task/backup/IMPL-1-v1.1.json",
|
||||
"timestamp": "2025-10-17T10:30:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Complete schema**: See @~/.claude/workflows/task-core.md
|
||||
|
||||
### File Structure
|
||||
```
|
||||
.task/
|
||||
├── IMPL-1.json # Current version
|
||||
├── backup/
|
||||
│ ├── IMPL-1-v1.0.json # Original version
|
||||
│ ├── IMPL-1-v1.1.json # Previous backup
|
||||
│ └── IMPL-1-v1.2.json # Latest backup
|
||||
└── [new subtasks as needed]
|
||||
```
|
||||
|
||||
**Backup Naming**: `{task-id}-v{version}.json`
|
||||
|
||||
## Implementation Updates
|
||||
|
||||
### Change Detection
|
||||
Tracks modifications to:
|
||||
- Files in implementation.files array
|
||||
- Dependencies and affected modules
|
||||
- Risk assessments and performance notes
|
||||
- Logic flows and code locations
|
||||
|
||||
### Analysis Triggers
|
||||
May require gemini re-analysis when:
|
||||
- New files need code extraction
|
||||
- Function locations change
|
||||
- Dependencies require re-evaluation
|
||||
|
||||
## Document Updates
|
||||
|
||||
### Planning Document
|
||||
May update IMPL_PLAN.md sections when task structure changes significantly
|
||||
|
||||
### TODO List Sync
|
||||
If TODO_LIST.md exists, synchronizes:
|
||||
- New subtasks (with [ ] checkbox)
|
||||
- Modified tasks (marked as updated)
|
||||
- Removed subtasks (deleted from list)
|
||||
|
||||
## Change Documentation
|
||||
|
||||
### Change Summary
|
||||
Generates brief change log with:
|
||||
- Version increment (1.1 → 1.2)
|
||||
- Input source and reason
|
||||
- Key modifications made
|
||||
- Files updated/created
|
||||
- Backup location
|
||||
|
||||
## Session Updates
|
||||
|
||||
Updates workflow-session.json with:
|
||||
- Modified task tracking
|
||||
- Task count changes (if subtasks added/removed)
|
||||
- Last modification timestamps
|
||||
|
||||
## Rollback Support
|
||||
|
||||
```bash
|
||||
/task:replan IMPL-1 --rollback v1.1
|
||||
|
||||
Rollback to version 1.1:
|
||||
- Restore task from backup/.../IMPL-1-v1.1.json
|
||||
- Remove new subtasks if any
|
||||
- Update session stats
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Are you sure you want to roll back this task to a previous version?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Yes, rollback", description: "Restore the task from the selected backup." },
|
||||
{ label: "No, cancel", description: "Keep the current version of the task." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Yes, rollback"
|
||||
|
||||
Task rolled back to version 1.1
|
||||
```
|
||||
|
||||
## Batch Processing with TodoWrite
|
||||
|
||||
### Progress Tracking
|
||||
When processing multiple tasks, automatically creates TodoWrite task list:
|
||||
|
||||
```markdown
|
||||
**Batch Replan Progress**:
|
||||
- [x] IMPL-002: Add FR-12 draft saving acceptance criteria
|
||||
- [x] IMPL-003: Add FR-14 history tracking acceptance criteria
|
||||
- [ ] IMPL-004: Add FR-09 response surface explicit coverage
|
||||
- [ ] IMPL-008: Add NFR performance validation steps
|
||||
```
|
||||
|
||||
### Batch Report
|
||||
After completion, generates summary:
|
||||
```markdown
|
||||
## Batch Replan Summary
|
||||
|
||||
**Total Tasks**: 4
|
||||
**Successful**: 3
|
||||
**Failed**: 1
|
||||
**Skipped**: 0
|
||||
|
||||
### Changes Made
|
||||
- IMPL-002 v1.0 → v1.1: Added FR-12 acceptance criteria
|
||||
- IMPL-003 v1.0 → v1.1: Added FR-14 acceptance criteria
|
||||
- IMPL-004 v1.0 → v1.1: Added FR-09 explicit coverage
|
||||
|
||||
### Backups Created
|
||||
- .task/backup/IMPL-002-v1.0.json
|
||||
- .task/backup/IMPL-003-v1.0.json
|
||||
- .task/backup/IMPL-004-v1.0.json
|
||||
|
||||
### Errors
|
||||
- IMPL-008: File not found (task may have been renamed)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Single Task - Text Input
|
||||
```bash
|
||||
/task:replan IMPL-1 "Add OAuth2 authentication support"
|
||||
|
||||
Processing changes...
|
||||
Proposed updates:
|
||||
+ Add OAuth2 integration
|
||||
+ Update authentication flow
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Do you want to apply these changes to the task?",
|
||||
header: "Apply",
|
||||
options: [
|
||||
{ label: "Yes, apply", description: "Create new version with these changes." },
|
||||
{ label: "No, cancel", description: "Discard changes and keep current version." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Yes, apply"
|
||||
|
||||
Version 1.2 created
|
||||
Context updated
|
||||
Backup saved to .task/backup/IMPL-1-v1.1.json
|
||||
```
|
||||
|
||||
### Single Task - File Input
|
||||
```bash
|
||||
/task:replan IMPL-2 requirements.md
|
||||
|
||||
Loading requirements.md...
|
||||
Applying specification changes...
|
||||
|
||||
Task updated with new requirements
|
||||
Version 1.1 created
|
||||
Backup saved to .task/backup/IMPL-2-v1.0.json
|
||||
```
|
||||
|
||||
### Batch Mode - From Verification Report
|
||||
```bash
|
||||
/task:replan --batch .workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md
|
||||
|
||||
Parsing verification report...
|
||||
Found 4 tasks requiring replanning:
|
||||
- IMPL-002: Add FR-12 draft saving acceptance criteria
|
||||
- IMPL-003: Add FR-14 history tracking acceptance criteria
|
||||
- IMPL-004: Add FR-09 response surface explicit coverage
|
||||
- IMPL-008: Add NFR performance validation steps
|
||||
|
||||
Creating task tracking list...
|
||||
|
||||
Processing IMPL-002...
|
||||
Backup created: .task/backup/IMPL-002-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-003...
|
||||
Backup created: .task/backup/IMPL-003-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-004...
|
||||
Backup created: .task/backup/IMPL-004-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-008...
|
||||
Backup created: .task/backup/IMPL-008-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Batch replan completed: 4/4 successful
|
||||
Summary report saved
|
||||
```
|
||||
|
||||
### Batch Mode - Auto-detection
|
||||
```bash
|
||||
# If file contains "Action Plan Verification Report", auto-enters batch mode
|
||||
/task:replan ACTION_PLAN_VERIFICATION.md
|
||||
|
||||
Detected verification report format
|
||||
Entering batch mode...
|
||||
[same as above]
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Single Task Errors
|
||||
```bash
|
||||
# Task not found
|
||||
Task IMPL-5 not found
|
||||
Check task ID with /workflow:status
|
||||
|
||||
# Task completed
|
||||
Task IMPL-1 is completed (cannot replan)
|
||||
Create new task for additional work
|
||||
|
||||
# File not found
|
||||
File requirements.md not found
|
||||
Check file path
|
||||
|
||||
# No input provided
|
||||
Please specify changes needed
|
||||
Provide text, file, or verification report
|
||||
```
|
||||
|
||||
### Batch Mode Errors
|
||||
```bash
|
||||
# Invalid verification report
|
||||
File does not contain valid verification report format
|
||||
Check report structure or use single task mode
|
||||
|
||||
# Partial failures
|
||||
Batch completed with errors: 3/4 successful
|
||||
Review error details in summary report
|
||||
|
||||
# No replan recommendations found
|
||||
Verification report contains no replan recommendations
|
||||
Check report content or use /workflow:plan-verify first
|
||||
```
|
||||
|
||||
## Batch Mode Integration
|
||||
|
||||
### Input Format Expectations
|
||||
Batch mode parses verification reports looking for:
|
||||
|
||||
1. **Required Actions Section**: Commands like `/task:replan IMPL-X "changes"`
|
||||
2. **Findings Table**: Task IDs with recommendations
|
||||
3. **Next Actions Section**: Specific replan commands
|
||||
|
||||
**Example Patterns**:
|
||||
```markdown
|
||||
#### 1. HIGH Priority - Address FR Coverage Gaps
|
||||
/task:replan IMPL-004 "
|
||||
Add explicit acceptance criteria:
|
||||
- FR-09: Response surface 3D visualization
|
||||
"
|
||||
|
||||
#### 2. MEDIUM Priority - Enhance NFR Coverage
|
||||
/task:replan IMPL-008 "
|
||||
Add performance testing:
|
||||
- NFR-01: Load test API endpoints
|
||||
"
|
||||
```
|
||||
|
||||
### Extraction Logic
|
||||
1. Scan for `/task:replan` commands in report
|
||||
2. Extract task ID and change description
|
||||
3. Group by priority (HIGH, MEDIUM, LOW)
|
||||
4. Process in priority order with TodoWrite tracking
|
||||
|
||||
### Confirmation Behavior
|
||||
- **Default**: Confirm each task before applying
|
||||
- **With `--auto-confirm`**: Apply all changes without prompting
|
||||
```bash
|
||||
/task:replan --batch report.md --auto-confirm
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Backup Management
|
||||
```typescript
|
||||
// Backup file naming convention
|
||||
const backupPath = `.task/backup/${taskId}-v${previousVersion}.json`;
|
||||
|
||||
// Backup metadata in task JSON
|
||||
{
|
||||
"replan_history": [
|
||||
{
|
||||
"version": "1.2",
|
||||
"timestamp": "2025-10-17T10:30:00Z",
|
||||
"reason": "Add FR-09 explicit coverage",
|
||||
"input_source": "batch_verification_report",
|
||||
"backup_location": ".task/backup/IMPL-004-v1.1.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### TodoWrite Integration
|
||||
```typescript
|
||||
// Initialize tracking for batch mode
|
||||
TodoWrite({
|
||||
todos: taskList.map(task => ({
|
||||
content: `${task.id}: ${task.changeDescription}`,
|
||||
status: "pending",
|
||||
activeForm: `Replanning ${task.id}`
|
||||
}))
|
||||
});
|
||||
|
||||
// Update progress during processing
|
||||
TodoWrite({
|
||||
todos: updateTaskStatus(taskId, "in_progress")
|
||||
});
|
||||
|
||||
// Mark completed
|
||||
TodoWrite({
|
||||
todos: updateTaskStatus(taskId, "completed")
|
||||
});
|
||||
```
|
||||
@@ -1,254 +0,0 @@
|
||||
---
|
||||
name: version
|
||||
description: Display Claude Code version information and check for updates
|
||||
allowed-tools: Bash(*)
|
||||
---
|
||||
|
||||
# Version Command (/version)
|
||||
|
||||
## Purpose
|
||||
Display local and global installation versions, check for the latest updates from GitHub, and provide upgrade recommendations.
|
||||
|
||||
## Execution Flow
|
||||
1. **Local Version Check**: Read version information from `./.claude/version.json` if it exists.
|
||||
2. **Global Version Check**: Read version information from `~/.claude/version.json` if it exists.
|
||||
3. **Fetch Remote Versions**: Use GitHub API to get the latest stable release tag and the latest commit hash from the main branch.
|
||||
4. **Compare & Suggest**: Compare installed versions with the latest remote versions and provide upgrade suggestions if applicable.
|
||||
|
||||
## Step 1: Check Local Version
|
||||
|
||||
### Check if local version.json exists
|
||||
```bash
|
||||
bash(test -f ./.claude/version.json && echo "found" || echo "not_found")
|
||||
```
|
||||
|
||||
### Read local version (if exists)
|
||||
```bash
|
||||
bash(cat ./.claude/version.json)
|
||||
```
|
||||
|
||||
### Extract version with jq (preferred)
|
||||
```bash
|
||||
bash(cat ./.claude/version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
### Extract installation date
|
||||
```bash
|
||||
bash(cat ./.claude/version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Local Version: 3.2.1
|
||||
Installed: 2025-10-03T12:00:00Z
|
||||
```
|
||||
|
||||
## Step 2: Check Global Version
|
||||
|
||||
### Check if global version.json exists
|
||||
```bash
|
||||
bash(test -f ~/.claude/version.json && echo "found" || echo "not_found")
|
||||
```
|
||||
|
||||
### Read global version
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json)
|
||||
```
|
||||
|
||||
### Extract version
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
### Extract installation date
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Global Version: 3.2.1
|
||||
Installed: 2025-10-03T12:00:00Z
|
||||
```
|
||||
|
||||
## Step 3: Fetch Latest Stable Release
|
||||
|
||||
### Call GitHub API for latest release (with timeout)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract tag name (version)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract release name
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract published date
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"published_at": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Latest Stable: v3.2.2
|
||||
Release: v3.2.2: Independent Test-Gen Workflow with Cross-Session Context
|
||||
Published: 2025-10-03T04:10:08Z
|
||||
```
|
||||
|
||||
## Step 4: Fetch Latest Main Branch
|
||||
|
||||
### Call GitHub API for latest commit on main (with timeout)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit SHA (short)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit message (first line only)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit date
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"date": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Latest Dev: a03415b
|
||||
Message: feat: Add version tracking and upgrade check system
|
||||
Date: 2025-10-03T04:46:44Z
|
||||
```
|
||||
|
||||
## Step 5: Compare Versions and Suggest Upgrade
|
||||
|
||||
### Normalize versions (remove 'v' prefix)
|
||||
```bash
|
||||
bash(echo "v3.2.1" | sed 's/^v//')
|
||||
```
|
||||
|
||||
### Compare two versions
|
||||
```bash
|
||||
bash(printf "%s\n%s" "3.2.1" "3.2.2" | sort -V | tail -n 1)
|
||||
```
|
||||
|
||||
### Check if versions are equal
|
||||
```bash
|
||||
# If equal: Up to date
|
||||
# If remote newer: Upgrade available
|
||||
# If local newer: Development version
|
||||
```
|
||||
|
||||
**Output Scenarios**:
|
||||
|
||||
**Scenario 1: Up to date**
|
||||
```
|
||||
You are on the latest stable version (3.2.1)
|
||||
```
|
||||
|
||||
**Scenario 2: Upgrade available**
|
||||
```
|
||||
A newer stable version is available: v3.2.2
|
||||
Your version: 3.2.1
|
||||
|
||||
To upgrade:
|
||||
PowerShell: iex (iwr -useb https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.ps1)
|
||||
Bash: bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.sh)
|
||||
```
|
||||
|
||||
**Scenario 3: Development version**
|
||||
```
|
||||
You are running a development version (3.4.0-dev)
|
||||
This is newer than the latest stable release (v3.3.0)
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
```bash
|
||||
# Check local version file
|
||||
bash(test -f ./.claude/version.json && cat ./.claude/version.json)
|
||||
|
||||
# Check global version file
|
||||
bash(test -f ~/.claude/version.json && cat ~/.claude/version.json)
|
||||
|
||||
# Extract version from JSON
|
||||
bash(cat version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
# Extract date from JSON
|
||||
bash(cat version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
# Fetch latest release (with timeout)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
|
||||
|
||||
# Extract tag name
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
|
||||
|
||||
# Extract release name
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
|
||||
# Fetch latest commit (with timeout)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
|
||||
|
||||
# Extract commit SHA
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
|
||||
|
||||
# Extract commit message (first line)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
|
||||
|
||||
# Compare versions
|
||||
bash(printf "%s\n%s" "3.2.1" "3.2.2" | sort -V | tail -n 1)
|
||||
|
||||
# Remove 'v' prefix
|
||||
bash(echo "v3.2.1" | sed 's/^v//')
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### No installation found
|
||||
```
|
||||
WARNING: Claude Code Workflow not installed
|
||||
Install using:
|
||||
PowerShell: iex (iwr -useb https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.ps1)
|
||||
```
|
||||
|
||||
### Network error
|
||||
```
|
||||
ERROR: Could not fetch latest version from GitHub
|
||||
Check your network connection
|
||||
```
|
||||
|
||||
### Invalid version.json
|
||||
```
|
||||
ERROR: version.json is invalid or corrupted
|
||||
```
|
||||
|
||||
## Design Notes
|
||||
|
||||
- Uses simple, direct bash commands instead of complex functions
|
||||
- Each step is independent and can be executed separately
|
||||
- Fallback to grep/sed for JSON parsing (no jq dependency required)
|
||||
- Network calls use curl with error suppression and 30-second timeout
|
||||
- Version comparison uses `sort -V` for accurate semantic versioning
|
||||
- Use `/commits/main` API instead of `/branches/main` for more reliable commit info
|
||||
- Extract first line of commit message using `cut -d'\' -f1` to handle JSON escape sequences
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### GitHub API Used
|
||||
- **Latest Release**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest`
|
||||
- Fields: `tag_name`, `name`, `published_at`
|
||||
- **Latest Commit**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main`
|
||||
- Fields: `sha`, `commit.message`, `commit.author.date`
|
||||
|
||||
### Timeout Configuration
|
||||
All network calls should use `timeout: 30000` (30 seconds) to handle slow connections.
|
||||
367
.claude/commands/view.md
Normal file
367
.claude/commands/view.md
Normal file
@@ -0,0 +1,367 @@
|
||||
---
|
||||
name: ccw view
|
||||
description: Dashboard - Open CCW workflow dashboard for managing tasks and sessions
|
||||
category: general
|
||||
---
|
||||
|
||||
# CCW View Command
|
||||
|
||||
Open the CCW workflow dashboard for visualizing and managing project tasks, sessions, and workflow execution status.
|
||||
|
||||
## Description
|
||||
|
||||
`ccw view` launches an interactive web dashboard that provides:
|
||||
- **Workflow Overview**: Visualize current workflow status and command chain execution
|
||||
- **Session Management**: View and manage active workflow sessions
|
||||
- **Task Tracking**: Monitor TODO items and task progress
|
||||
- **Workspace Switching**: Switch between different project workspaces
|
||||
- **Real-time Updates**: Live updates of command execution and status
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Open dashboard for current workspace
|
||||
ccw view
|
||||
|
||||
# Specify workspace path
|
||||
ccw view --path /path/to/workspace
|
||||
|
||||
# Custom port (default: 3456)
|
||||
ccw view --port 3000
|
||||
|
||||
# Bind to specific host
|
||||
ccw view --host 0.0.0.0 --port 3456
|
||||
|
||||
# Open without launching browser
|
||||
ccw view --no-browser
|
||||
|
||||
# Show URL without opening browser
|
||||
ccw view --no-browser
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Option | Default | Description |
|
||||
|--------|---------|-------------|
|
||||
| `--path <path>` | Current directory | Workspace path to display |
|
||||
| `--port <port>` | 3456 | Server port for dashboard |
|
||||
| `--host <host>` | 127.0.0.1 | Server host/bind address |
|
||||
| `--no-browser` | false | Don't launch browser automatically |
|
||||
| `-h, --help` | - | Show help message |
|
||||
|
||||
## Features
|
||||
|
||||
### Dashboard Sections
|
||||
|
||||
#### 1. **Workflow Overview**
|
||||
- Current workflow status
|
||||
- Command chain visualization (with Minimum Execution Units marked)
|
||||
- Live progress tracking
|
||||
- Error alerts
|
||||
|
||||
#### 2. **Session Management**
|
||||
- List active sessions by type (workflow, review, tdd)
|
||||
- Session details (created time, last activity, session ID)
|
||||
- Quick actions (resume, pause, complete)
|
||||
- Session logs/history
|
||||
|
||||
#### 3. **Task Tracking**
|
||||
- TODO list with status indicators
|
||||
- Progress percentage
|
||||
- Task grouping by workflow stage
|
||||
- Quick inline task updates
|
||||
|
||||
#### 4. **Workspace Switcher**
|
||||
- Browse available workspaces
|
||||
- Switch context with one click
|
||||
- Recent workspaces list
|
||||
|
||||
#### 5. **Command History**
|
||||
- Recent commands executed
|
||||
- Execution time and status
|
||||
- Quick re-run options
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
| Shortcut | Action |
|
||||
|----------|--------|
|
||||
| `R` | Refresh dashboard |
|
||||
| `Cmd/Ctrl + J` | Jump to session search |
|
||||
| `Cmd/Ctrl + K` | Open command palette |
|
||||
| `?` | Show help |
|
||||
|
||||
## Multi-Instance Support
|
||||
|
||||
The dashboard supports multiple concurrent instances:
|
||||
|
||||
```bash
|
||||
# Terminal 1: Workspace A on port 3456
|
||||
ccw view --path ~/projects/workspace-a
|
||||
|
||||
# Terminal 2: Workspace B on port 3457
|
||||
ccw view --path ~/projects/workspace-b --port 3457
|
||||
|
||||
# Switching workspaces on the same port
|
||||
ccw view --path ~/projects/workspace-c # Auto-switches existing server
|
||||
```
|
||||
|
||||
When the server is already running and you execute `ccw view` with a different path:
|
||||
1. Detects running server on the port
|
||||
2. Sends workspace switch request
|
||||
3. Updates dashboard to new workspace
|
||||
4. Opens browser with updated context
|
||||
|
||||
## Server Lifecycle
|
||||
|
||||
### Startup
|
||||
|
||||
```
|
||||
ccw view
|
||||
├─ Check if server running on port
|
||||
│ ├─ If yes: Send switch-path request
|
||||
│ └─ If no: Start new server
|
||||
├─ Launch browser (unless --no-browser)
|
||||
└─ Display dashboard URL
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
The dashboard server continues running until:
|
||||
- User explicitly stops it (Ctrl+C)
|
||||
- All connections close after timeout
|
||||
- System shutdown
|
||||
|
||||
### Multiple Workspaces
|
||||
|
||||
Switching to a different workspace keeps the same server instance:
|
||||
```
|
||||
Server State Before: workspace-a on port 3456
|
||||
ccw view --path ~/projects/workspace-b
|
||||
Server State After: workspace-b on port 3456 (same instance)
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
# Set default port
|
||||
export CCW_VIEW_PORT=4000
|
||||
ccw view # Uses port 4000
|
||||
|
||||
# Set default host
|
||||
export CCW_VIEW_HOST=localhost
|
||||
ccw view --port 3456 # Binds to localhost:3456
|
||||
|
||||
# Disable browser launch by default
|
||||
export CCW_VIEW_NO_BROWSER=true
|
||||
ccw view # Won't auto-launch browser
|
||||
```
|
||||
|
||||
## Integration with CCW Workflows
|
||||
|
||||
The dashboard is fully integrated with CCW commands:
|
||||
|
||||
### Viewing Workflow Progress
|
||||
|
||||
```bash
|
||||
# Start a workflow
|
||||
ccw "Add user authentication"
|
||||
|
||||
# In another terminal, view progress
|
||||
ccw view # Shows execution progress in real-time
|
||||
```
|
||||
|
||||
### Session Management from Dashboard
|
||||
|
||||
- Start new session: Click "New Session" button
|
||||
- Resume paused session: Sessions list → Resume button
|
||||
- View session logs: Click session name
|
||||
- Complete session: Sessions list → Complete button
|
||||
|
||||
### Real-time Command Execution
|
||||
|
||||
- View active command chain execution
|
||||
- Watch command transition through Minimum Execution Units
|
||||
- See error alerts and recovery options
|
||||
- View command output logs
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Port Already in Use
|
||||
|
||||
```bash
|
||||
# Use different port
|
||||
ccw view --port 3457
|
||||
|
||||
# Or kill existing server
|
||||
lsof -i :3456 # Find process
|
||||
kill -9 <pid> # Kill it
|
||||
ccw view # Start fresh
|
||||
```
|
||||
|
||||
### Dashboard Not Loading
|
||||
|
||||
```bash
|
||||
# Try without browser
|
||||
ccw view --no-browser
|
||||
|
||||
# Check server logs
|
||||
tail -f ~/.ccw/logs/dashboard.log
|
||||
|
||||
# Verify network access
|
||||
curl http://localhost:3456/api/health
|
||||
```
|
||||
|
||||
### Workspace Path Not Found
|
||||
|
||||
```bash
|
||||
# Use full absolute path
|
||||
ccw view --path "$(pwd)"
|
||||
|
||||
# Or specify explicit path
|
||||
ccw view --path ~/projects/my-project
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **`/ccw`** - Main workflow orchestrator
|
||||
- **`/workflow:session:list`** - List workflow sessions
|
||||
- **`/workflow:session:resume`** - Resume paused session
|
||||
- **`/memory:compact`** - Compact session memory for dashboard display
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Dashboard View
|
||||
|
||||
```bash
|
||||
cd ~/projects/my-app
|
||||
ccw view
|
||||
# → Launches http://localhost:3456 in browser
|
||||
```
|
||||
|
||||
### Network-Accessible Dashboard
|
||||
|
||||
```bash
|
||||
# Allow remote access
|
||||
ccw view --host 0.0.0.0 --port 3000
|
||||
# → Dashboard accessible at http://machine-ip:3000
|
||||
```
|
||||
|
||||
### Multiple Workspaces on Different Ports
|
||||
|
||||
```bash
|
||||
# Terminal 1: Main project
|
||||
ccw view --path ~/projects/main --port 3456
|
||||
|
||||
# Terminal 2: Side project
|
||||
ccw view --path ~/projects/side --port 3457
|
||||
|
||||
# View both simultaneously
|
||||
# → http://localhost:3456 (main)
|
||||
# → http://localhost:3457 (side)
|
||||
```
|
||||
|
||||
### Headless Dashboard
|
||||
|
||||
```bash
|
||||
# Run dashboard without browser
|
||||
ccw view --port 3000 --no-browser
|
||||
echo "Dashboard available at http://localhost:3000"
|
||||
|
||||
# Share URL with team
|
||||
# Can be proxied through nginx/port forwarding
|
||||
```
|
||||
|
||||
### Environment-Based Configuration
|
||||
|
||||
```bash
|
||||
# Script for CI/CD
|
||||
export CCW_VIEW_HOST=0.0.0.0
|
||||
export CCW_VIEW_PORT=8080
|
||||
ccw view --path /workspace
|
||||
|
||||
# → Dashboard accessible on port 8080 to all interfaces
|
||||
```
|
||||
|
||||
## Dashboard Pages
|
||||
|
||||
### Overview Page (`/`)
|
||||
- Current workflow status
|
||||
- Active sessions summary
|
||||
- Recent commands
|
||||
- System health indicators
|
||||
|
||||
### Sessions Page (`/sessions`)
|
||||
- All sessions (grouped by type)
|
||||
- Session details and metadata
|
||||
- Session logs viewer
|
||||
- Quick actions (resume/complete)
|
||||
|
||||
### Tasks Page (`/tasks`)
|
||||
- Current TODO items
|
||||
- Progress tracking
|
||||
- Inline task editing
|
||||
- Workflow history
|
||||
|
||||
### Workspace Page (`/workspace`)
|
||||
- Current workspace info
|
||||
- Available workspaces
|
||||
- Workspace switcher
|
||||
- Workspace settings
|
||||
|
||||
### Settings Page (`/settings`)
|
||||
- Port configuration
|
||||
- Theme preferences
|
||||
- Auto-refresh settings
|
||||
- Export settings
|
||||
|
||||
## Server Health Monitoring
|
||||
|
||||
The dashboard includes health monitoring:
|
||||
|
||||
```bash
|
||||
# Check health endpoint
|
||||
curl http://localhost:3456/api/health
|
||||
# → { "status": "ok", "uptime": 12345 }
|
||||
|
||||
# Monitor metrics
|
||||
curl http://localhost:3456/api/metrics
|
||||
# → { "sessions": 3, "tasks": 15, "lastUpdate": "2025-01-29T10:30:00Z" }
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Custom Port with Dynamic Discovery
|
||||
|
||||
```bash
|
||||
# Find next available port
|
||||
available_port=$(find-available-port 3456)
|
||||
ccw view --port $available_port
|
||||
|
||||
# Display in CI/CD
|
||||
echo "Dashboard: http://localhost:$available_port"
|
||||
```
|
||||
|
||||
### Dashboard Behind Proxy
|
||||
|
||||
```bash
|
||||
# Configure nginx reverse proxy
|
||||
# Proxy http://proxy.example.com/dashboard → http://localhost:3456
|
||||
|
||||
ccw view --host 127.0.0.1 --port 3456
|
||||
|
||||
# Access via proxy
|
||||
# http://proxy.example.com/dashboard
|
||||
```
|
||||
|
||||
### Session Export from Dashboard
|
||||
|
||||
- View → Sessions → Export JSON
|
||||
- Exports session metadata and progress
|
||||
- Useful for record-keeping and reporting
|
||||
|
||||
## See Also
|
||||
|
||||
- **CCW Commands**: `/ccw` - Auto workflow orchestration
|
||||
- **Session Management**: `/workflow:session:start`, `/workflow:session:list`
|
||||
- **Task Tracking**: `TodoWrite` tool for programmatic task management
|
||||
- **Workflow Status**: `/workflow:status` for CLI-based status view
|
||||
@@ -1,485 +0,0 @@
|
||||
---
|
||||
name: plan-verify
|
||||
description: Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.
|
||||
argument-hint: "[optional: --session session-id]"
|
||||
allowed-tools: Read(*), Write(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Goal
|
||||
|
||||
Generate a comprehensive verification report that identifies inconsistencies, duplications, ambiguities, and underspecified items between action planning artifacts (`IMPL_PLAN.md`, `task.json`) and brainstorming artifacts (`role analysis documents`). This command MUST run only after `/workflow:plan` has successfully produced complete `IMPL_PLAN.md` and task JSON files.
|
||||
|
||||
**Output**: A structured Markdown report saved to `.workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md` containing:
|
||||
- Executive summary with quality gate recommendation
|
||||
- Detailed findings by severity (CRITICAL/HIGH/MEDIUM/LOW)
|
||||
- Requirements coverage analysis
|
||||
- Dependency integrity check
|
||||
- Synthesis alignment validation
|
||||
- Actionable remediation recommendations
|
||||
|
||||
## Operating Constraints
|
||||
|
||||
**STRICTLY READ-ONLY FOR SOURCE ARTIFACTS**:
|
||||
- **MUST NOT** modify `IMPL_PLAN.md`, any `task.json` files, or brainstorming artifacts
|
||||
- **MUST NOT** create or delete task files
|
||||
- **MUST ONLY** write the verification report to `.process/ACTION_PLAN_VERIFICATION.md`
|
||||
|
||||
**Synthesis Authority**: The `role analysis documents` are **authoritative** for requirements and design decisions. Any conflicts between IMPL_PLAN/tasks and synthesis are automatically CRITICAL and require adjustment of the plan/tasks—not reinterpretation of requirements.
|
||||
|
||||
**Quality Gate Authority**: The verification report provides a binding recommendation (BLOCK_EXECUTION / PROCEED_WITH_FIXES / PROCEED_WITH_CAUTION / PROCEED) based on objective severity criteria. User MUST review critical/high issues before proceeding with implementation.
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### 1. Initialize Analysis Context
|
||||
|
||||
```bash
|
||||
# Detect active workflow session
|
||||
IF --session parameter provided:
|
||||
session_id = provided session
|
||||
ELSE:
|
||||
# Auto-detect active session
|
||||
active_sessions = bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
IF active_sessions is empty:
|
||||
ERROR: "No active workflow session found. Use --session <session-id>"
|
||||
EXIT
|
||||
ELSE IF active_sessions has multiple entries:
|
||||
# Use most recently modified session
|
||||
session_id = bash(ls -td .workflow/active/WFS-*/ 2>/dev/null | head -1 | xargs basename)
|
||||
ELSE:
|
||||
session_id = basename(active_sessions[0])
|
||||
|
||||
# Derive absolute paths
|
||||
session_dir = .workflow/active/WFS-{session}
|
||||
brainstorm_dir = session_dir/.brainstorming
|
||||
task_dir = session_dir/.task
|
||||
process_dir = session_dir/.process
|
||||
session_file = session_dir/workflow-session.json
|
||||
|
||||
# Create .process directory if not exists (report output location)
|
||||
IF NOT EXISTS(process_dir):
|
||||
bash(mkdir -p "{process_dir}")
|
||||
|
||||
# Validate required artifacts
|
||||
# Note: "role analysis documents" refers to [role]/analysis.md files (e.g., product-manager/analysis.md)
|
||||
SYNTHESIS_DIR = brainstorm_dir # Contains role analysis files: */analysis.md
|
||||
IMPL_PLAN = session_dir/IMPL_PLAN.md
|
||||
TASK_FILES = Glob(task_dir/*.json)
|
||||
|
||||
# Abort if missing - in order of dependency
|
||||
SESSION_FILE_EXISTS = EXISTS(session_file)
|
||||
IF NOT SESSION_FILE_EXISTS:
|
||||
WARNING: "workflow-session.json not found. User intent alignment verification will be skipped."
|
||||
# Continue execution - this is optional context, not blocking
|
||||
|
||||
SYNTHESIS_FILES = Glob(brainstorm_dir/*/analysis.md)
|
||||
IF SYNTHESIS_FILES.count == 0:
|
||||
ERROR: "No role analysis documents found in .brainstorming/*/analysis.md. Run /workflow:brainstorm:synthesis first"
|
||||
EXIT
|
||||
|
||||
IF NOT EXISTS(IMPL_PLAN):
|
||||
ERROR: "IMPL_PLAN.md not found. Run /workflow:plan first"
|
||||
EXIT
|
||||
|
||||
IF TASK_FILES.count == 0:
|
||||
ERROR: "No task JSON files found. Run /workflow:plan first"
|
||||
EXIT
|
||||
```
|
||||
|
||||
### 2. Load Artifacts (Progressive Disclosure)
|
||||
|
||||
Load only minimal necessary context from each artifact:
|
||||
|
||||
**From workflow-session.json** (OPTIONAL - Primary Reference for User Intent):
|
||||
- **ONLY IF EXISTS**: Load user intent context
|
||||
- Original user prompt/intent (project or description field)
|
||||
- User's stated goals and objectives
|
||||
- User's scope definition
|
||||
- **IF MISSING**: Set user_intent_analysis = "SKIPPED: workflow-session.json not found"
|
||||
|
||||
**From role analysis documents** (AUTHORITATIVE SOURCE):
|
||||
- Functional Requirements (IDs, descriptions, acceptance criteria)
|
||||
- Non-Functional Requirements (IDs, targets)
|
||||
- Business Requirements (IDs, success metrics)
|
||||
- Key Architecture Decisions
|
||||
- Risk factors and mitigation strategies
|
||||
- Implementation Roadmap (high-level phases)
|
||||
|
||||
**From IMPL_PLAN.md**:
|
||||
- Summary and objectives
|
||||
- Context Analysis
|
||||
- Implementation Strategy
|
||||
- Task Breakdown Summary
|
||||
- Success Criteria
|
||||
- Brainstorming Artifacts References (if present)
|
||||
|
||||
**From task.json files**:
|
||||
- Task IDs
|
||||
- Titles and descriptions
|
||||
- Status
|
||||
- Dependencies (depends_on, blocks)
|
||||
- Context (requirements, focus_paths, acceptance, artifacts)
|
||||
- Flow control (pre_analysis, implementation_approach)
|
||||
- Meta (complexity, priority)
|
||||
|
||||
### 3. Build Semantic Models
|
||||
|
||||
Create internal representations (do not include raw artifacts in output):
|
||||
|
||||
**Requirements inventory**:
|
||||
- Each functional/non-functional/business requirement with stable ID
|
||||
- Requirement text, acceptance criteria, priority
|
||||
|
||||
**Architecture decisions inventory**:
|
||||
- ADRs from synthesis
|
||||
- Technology choices
|
||||
- Data model references
|
||||
|
||||
**Task coverage mapping**:
|
||||
- Map each task to one or more requirements (by ID reference or keyword inference)
|
||||
- Map each requirement to covering tasks
|
||||
|
||||
**Dependency graph**:
|
||||
- Task-to-task dependencies (depends_on, blocks)
|
||||
- Requirement-level dependencies (from synthesis)
|
||||
|
||||
### 4. Detection Passes (Token-Efficient Analysis)
|
||||
|
||||
**Token Budget Strategy**:
|
||||
- **Total Limit**: 50 findings maximum (aggregate remainder in overflow summary)
|
||||
- **Priority Allocation**: CRITICAL (unlimited) → HIGH (15) → MEDIUM (20) → LOW (15)
|
||||
- **Early Exit**: If CRITICAL findings > 0 in User Intent/Requirements Coverage, skip LOW/MEDIUM priority checks
|
||||
|
||||
**Execution Order** (Process in sequence; skip if token budget exhausted):
|
||||
|
||||
1. **Tier 1 (CRITICAL Path)**: A, B, C - User intent, coverage, consistency (process fully)
|
||||
2. **Tier 2 (HIGH Priority)**: D, E - Dependencies, synthesis alignment (limit 15 findings total)
|
||||
3. **Tier 3 (MEDIUM Priority)**: F - Specification quality (limit 20 findings)
|
||||
4. **Tier 4 (LOW Priority)**: G, H - Duplication, feasibility (limit 15 findings total)
|
||||
|
||||
---
|
||||
|
||||
#### A. User Intent Alignment (CRITICAL - Tier 1)
|
||||
|
||||
- **Goal Alignment**: IMPL_PLAN objectives match user's original intent
|
||||
- **Scope Drift**: Plan covers user's stated scope without unauthorized expansion
|
||||
- **Success Criteria Match**: Plan's success criteria reflect user's expectations
|
||||
- **Intent Conflicts**: Tasks contradicting user's original objectives
|
||||
|
||||
#### B. Requirements Coverage Analysis
|
||||
|
||||
- **Orphaned Requirements**: Requirements in synthesis with zero associated tasks
|
||||
- **Unmapped Tasks**: Tasks with no clear requirement linkage
|
||||
- **NFR Coverage Gaps**: Non-functional requirements (performance, security, scalability) not reflected in tasks
|
||||
|
||||
#### C. Consistency Validation
|
||||
|
||||
- **Requirement Conflicts**: Tasks contradicting synthesis requirements
|
||||
- **Architecture Drift**: IMPL_PLAN architecture not matching synthesis ADRs
|
||||
- **Terminology Drift**: Same concept named differently across IMPL_PLAN and tasks
|
||||
- **Data Model Inconsistency**: Tasks referencing entities/fields not in synthesis data model
|
||||
|
||||
#### D. Dependency Integrity
|
||||
|
||||
- **Circular Dependencies**: Task A depends on B, B depends on C, C depends on A
|
||||
- **Missing Dependencies**: Task requires outputs from another task but no explicit dependency
|
||||
- **Broken Dependencies**: Task depends on non-existent task ID
|
||||
- **Logical Ordering Issues**: Implementation tasks before foundational setup without dependency note
|
||||
|
||||
#### E. Synthesis Alignment
|
||||
|
||||
- **Priority Conflicts**: High-priority synthesis requirements mapped to low-priority tasks
|
||||
- **Success Criteria Mismatch**: IMPL_PLAN success criteria not covering synthesis acceptance criteria
|
||||
- **Risk Mitigation Gaps**: Critical risks in synthesis without corresponding mitigation tasks
|
||||
|
||||
#### F. Task Specification Quality
|
||||
|
||||
- **Ambiguous Focus Paths**: Tasks with vague or missing focus_paths
|
||||
- **Underspecified Acceptance**: Tasks without clear acceptance criteria
|
||||
- **Missing Artifacts References**: Tasks not referencing relevant brainstorming artifacts in context.artifacts
|
||||
- **Weak Flow Control**: Tasks without clear implementation_approach or pre_analysis steps
|
||||
- **Missing Target Files**: Tasks without flow_control.target_files specification
|
||||
|
||||
#### G. Duplication Detection
|
||||
|
||||
- **Overlapping Task Scope**: Multiple tasks with nearly identical descriptions
|
||||
- **Redundant Requirements Coverage**: Same requirement covered by multiple tasks without clear partitioning
|
||||
|
||||
#### H. Feasibility Assessment
|
||||
|
||||
- **Complexity Misalignment**: Task marked "simple" but requires multiple file modifications
|
||||
- **Resource Conflicts**: Parallel tasks requiring same resources/files
|
||||
- **Skill Gap Risks**: Tasks requiring skills not in team capability assessment (from synthesis)
|
||||
|
||||
### 5. Severity Assignment
|
||||
|
||||
Use this heuristic to prioritize findings:
|
||||
|
||||
- **CRITICAL**:
|
||||
- Violates user's original intent (goal misalignment, scope drift)
|
||||
- Violates synthesis authority (requirement conflict)
|
||||
- Core requirement with zero coverage
|
||||
- Circular dependencies
|
||||
- Broken dependencies
|
||||
|
||||
- **HIGH**:
|
||||
- NFR coverage gaps
|
||||
- Priority conflicts
|
||||
- Missing risk mitigation tasks
|
||||
- Ambiguous acceptance criteria
|
||||
|
||||
- **MEDIUM**:
|
||||
- Terminology drift
|
||||
- Missing artifacts references
|
||||
- Weak flow control
|
||||
- Logical ordering issues
|
||||
|
||||
- **LOW**:
|
||||
- Style/wording improvements
|
||||
- Minor redundancy not affecting execution
|
||||
|
||||
### 6. Produce Compact Analysis Report
|
||||
|
||||
**Report Generation**: Generate report content and save to file.
|
||||
|
||||
Output a Markdown report with the following structure:
|
||||
|
||||
```markdown
|
||||
## Action Plan Verification Report
|
||||
|
||||
**Session**: WFS-{session-id}
|
||||
**Generated**: {timestamp}
|
||||
**Artifacts Analyzed**: role analysis documents, IMPL_PLAN.md, {N} task files
|
||||
|
||||
---
|
||||
|
||||
### Executive Summary
|
||||
|
||||
- **Overall Risk Level**: CRITICAL | HIGH | MEDIUM | LOW
|
||||
- **Recommendation**: (See decision matrix below)
|
||||
- BLOCK_EXECUTION: Critical issues exist (must fix before proceeding)
|
||||
- PROCEED_WITH_FIXES: High issues exist, no critical (fix recommended before execution)
|
||||
- PROCEED_WITH_CAUTION: Medium issues only (proceed with awareness)
|
||||
- PROCEED: Low issues only or no issues (safe to execute)
|
||||
- **Critical Issues**: {count}
|
||||
- **High Issues**: {count}
|
||||
- **Medium Issues**: {count}
|
||||
- **Low Issues**: {count}
|
||||
|
||||
---
|
||||
|
||||
### Findings Summary
|
||||
|
||||
| ID | Category | Severity | Location(s) | Summary | Recommendation |
|
||||
|----|----------|----------|-------------|---------|----------------|
|
||||
| C1 | Coverage | CRITICAL | synthesis:FR-03 | Requirement "User auth" has zero task coverage | Add authentication implementation task |
|
||||
| H1 | Consistency | HIGH | IMPL-1.2 vs synthesis:ADR-02 | Task uses REST while synthesis specifies GraphQL | Align task with ADR-02 decision |
|
||||
| M1 | Specification | MEDIUM | IMPL-2.1 | Missing context.artifacts reference | Add @synthesis reference |
|
||||
| L1 | Duplication | LOW | IMPL-3.1, IMPL-3.2 | Similar scope | Consider merging |
|
||||
|
||||
(Add one row per finding; generate stable IDs prefixed by severity initial.)
|
||||
|
||||
---
|
||||
|
||||
### Requirements Coverage Analysis
|
||||
|
||||
| Requirement ID | Requirement Summary | Has Task? | Task IDs | Priority Match | Notes |
|
||||
|----------------|---------------------|-----------|----------|----------------|-------|
|
||||
| FR-01 | User authentication | Yes | IMPL-1.1, IMPL-1.2 | Match | Complete |
|
||||
| FR-02 | Data export | Yes | IMPL-2.3 | Mismatch | High req → Med priority task |
|
||||
| FR-03 | Profile management | No | - | - | **CRITICAL: Zero coverage** |
|
||||
| NFR-01 | Response time <200ms | No | - | - | **HIGH: No performance tasks** |
|
||||
|
||||
**Coverage Metrics**:
|
||||
- Functional Requirements: 85% (17/20 covered)
|
||||
- Non-Functional Requirements: 40% (2/5 covered)
|
||||
- Business Requirements: 100% (5/5 covered)
|
||||
|
||||
---
|
||||
|
||||
### Unmapped Tasks
|
||||
|
||||
| Task ID | Title | Issue | Recommendation |
|
||||
|---------|-------|-------|----------------|
|
||||
| IMPL-4.5 | Refactor utils | No requirement linkage | Link to technical debt or remove |
|
||||
|
||||
---
|
||||
|
||||
### Dependency Graph Issues
|
||||
|
||||
**Circular Dependencies**: None detected
|
||||
|
||||
**Broken Dependencies**:
|
||||
- IMPL-2.3 depends on "IMPL-2.4" (non-existent)
|
||||
|
||||
**Logical Ordering Issues**:
|
||||
- IMPL-5.1 (integration test) has no dependency on IMPL-1.* (implementation tasks)
|
||||
|
||||
---
|
||||
|
||||
### Synthesis Alignment Issues
|
||||
|
||||
| Issue Type | Synthesis Reference | IMPL_PLAN/Task | Impact | Recommendation |
|
||||
|------------|---------------------|----------------|--------|----------------|
|
||||
| Architecture Conflict | synthesis:ADR-01 (JWT auth) | IMPL_PLAN uses session cookies | HIGH | Update IMPL_PLAN to use JWT |
|
||||
| Priority Mismatch | synthesis:FR-02 (High) | IMPL-2.3 (Medium) | MEDIUM | Elevate task priority |
|
||||
| Missing Risk Mitigation | synthesis:Risk-03 (API rate limits) | No mitigation tasks | HIGH | Add rate limiting implementation task |
|
||||
|
||||
---
|
||||
|
||||
### Task Specification Quality Issues
|
||||
|
||||
**Missing Artifacts References**: 12 tasks lack context.artifacts
|
||||
**Weak Flow Control**: 5 tasks lack implementation_approach
|
||||
**Missing Target Files**: 8 tasks lack flow_control.target_files
|
||||
|
||||
**Sample Issues**:
|
||||
- IMPL-1.2: No context.artifacts reference to synthesis
|
||||
- IMPL-3.1: Missing flow_control.target_files specification
|
||||
- IMPL-4.2: Vague focus_paths ["src/"] - needs refinement
|
||||
|
||||
---
|
||||
|
||||
### Feasibility Concerns
|
||||
|
||||
| Concern | Tasks Affected | Issue | Recommendation |
|
||||
|---------|----------------|-------|----------------|
|
||||
| Skill Gap | IMPL-6.1, IMPL-6.2 | Requires Kubernetes expertise not in team | Add training task or external consultant |
|
||||
| Resource Conflict | IMPL-3.1, IMPL-3.2 | Both modify src/auth/service.ts in parallel | Add dependency or serialize |
|
||||
|
||||
---
|
||||
|
||||
### Metrics
|
||||
|
||||
- **Total Requirements**: 30 (20 functional, 5 non-functional, 5 business)
|
||||
- **Total Tasks**: 25
|
||||
- **Overall Coverage**: 77% (23/30 requirements with ≥1 task)
|
||||
- **Critical Issues**: 2
|
||||
- **High Issues**: 5
|
||||
- **Medium Issues**: 8
|
||||
- **Low Issues**: 3
|
||||
|
||||
---
|
||||
|
||||
### Next Actions
|
||||
|
||||
#### Action Recommendations
|
||||
|
||||
**Recommendation Decision Matrix**:
|
||||
|
||||
| Condition | Recommendation | Action |
|
||||
|-----------|----------------|--------|
|
||||
| Critical > 0 | BLOCK_EXECUTION | Must resolve all critical issues before proceeding |
|
||||
| Critical = 0, High > 0 | PROCEED_WITH_FIXES | Fix high-priority issues before execution |
|
||||
| Critical = 0, High = 0, Medium > 0 | PROCEED_WITH_CAUTION | Proceed with awareness of medium issues |
|
||||
| Only Low or None | PROCEED | Safe to execute workflow |
|
||||
|
||||
**If CRITICAL Issues Exist** (BLOCK_EXECUTION):
|
||||
- Resolve all critical issues before proceeding
|
||||
- Use TodoWrite to track required fixes
|
||||
- Fix broken dependencies and circular references first
|
||||
|
||||
**If HIGH Issues Exist** (PROCEED_WITH_FIXES):
|
||||
- Fix high-priority issues before execution
|
||||
- Use TodoWrite to systematically track and complete improvements
|
||||
|
||||
**If Only MEDIUM/LOW Issues** (PROCEED_WITH_CAUTION / PROCEED):
|
||||
- Can proceed with execution
|
||||
- Address issues during or after implementation
|
||||
|
||||
#### TodoWrite-Based Remediation Workflow
|
||||
|
||||
**Report Location**: `.workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md`
|
||||
|
||||
**Recommended Workflow**:
|
||||
1. **Create TodoWrite Task List**: Extract all findings from report
|
||||
2. **Process by Priority**: CRITICAL → HIGH → MEDIUM → LOW
|
||||
3. **Complete Each Fix**: Mark tasks as in_progress/completed as you work
|
||||
4. **Validate Changes**: Verify each modification against requirements
|
||||
|
||||
**TodoWrite Task Structure Example**:
|
||||
```markdown
|
||||
Priority Order:
|
||||
1. Fix coverage gaps (CRITICAL)
|
||||
2. Resolve consistency conflicts (CRITICAL/HIGH)
|
||||
3. Add missing specifications (MEDIUM)
|
||||
4. Improve task quality (LOW)
|
||||
```
|
||||
|
||||
**Notes**:
|
||||
- TodoWrite provides real-time progress tracking
|
||||
- Each finding becomes a trackable todo item
|
||||
- User can monitor progress throughout remediation
|
||||
- Architecture drift in IMPL_PLAN requires manual editing
|
||||
```
|
||||
|
||||
### 7. Save Report and Execute TodoWrite-Based Remediation
|
||||
|
||||
**Step 7.1: Save Analysis Report**:
|
||||
```bash
|
||||
report_path = ".workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md"
|
||||
Write(report_path, full_report_content)
|
||||
```
|
||||
|
||||
**Step 7.2: Display Report Summary to User**:
|
||||
- Show executive summary with counts
|
||||
- Display recommendation (BLOCK/PROCEED_WITH_FIXES/PROCEED_WITH_CAUTION/PROCEED)
|
||||
- List critical and high issues if any
|
||||
|
||||
**Step 7.3: After Report Generation**:
|
||||
|
||||
1. **Extract Findings**: Parse all issues by severity
|
||||
2. **Create TodoWrite Task List**: Convert findings to actionable todos
|
||||
3. **Execute Fixes**: Process each todo systematically
|
||||
4. **Update Task Files**: Apply modifications directly to task JSON files
|
||||
5. **Update IMPL_PLAN**: Apply strategic changes if needed
|
||||
|
||||
At end of report, provide remediation guidance:
|
||||
|
||||
```markdown
|
||||
### 🔧 Remediation Workflow
|
||||
|
||||
**Recommended Approach**:
|
||||
1. **Initialize TodoWrite**: Create comprehensive task list from all findings
|
||||
2. **Process by Severity**: Start with CRITICAL, then HIGH, MEDIUM, LOW
|
||||
3. **Apply Fixes Directly**: Modify task.json files and IMPL_PLAN.md as needed
|
||||
4. **Track Progress**: Mark todos as completed after each fix
|
||||
|
||||
**TodoWrite Execution Pattern**:
|
||||
```bash
|
||||
# Step 1: Create task list from verification report
|
||||
TodoWrite([
|
||||
{ content: "Fix FR-03 coverage gap - add authentication task", status: "pending", activeForm: "Fixing FR-03 coverage gap" },
|
||||
{ content: "Fix IMPL-1.2 consistency - align with ADR-02", status: "pending", activeForm: "Fixing IMPL-1.2 consistency" },
|
||||
{ content: "Add context.artifacts to IMPL-1.2", status: "pending", activeForm: "Adding context.artifacts to IMPL-1.2" },
|
||||
# ... additional todos for each finding
|
||||
])
|
||||
|
||||
# Step 2: Process each todo systematically
|
||||
# Mark as in_progress when starting
|
||||
# Apply fix using Read/Edit tools
|
||||
# Mark as completed when done
|
||||
# Move to next priority item
|
||||
```
|
||||
|
||||
**File Modification Workflow**:
|
||||
```bash
|
||||
# For task JSON modifications:
|
||||
1. Read(.workflow/active/WFS-{session}/.task/IMPL-X.Y.json)
|
||||
2. Edit() to apply fixes
|
||||
3. Mark todo as completed
|
||||
|
||||
# For IMPL_PLAN modifications:
|
||||
1. Read(.workflow/active/WFS-{session}/IMPL_PLAN.md)
|
||||
2. Edit() to apply strategic changes
|
||||
3. Mark todo as completed
|
||||
```
|
||||
|
||||
**Note**: All fixes execute immediately after user confirmation without additional commands.
|
||||
804
.claude/commands/workflow/analyze-with-file.md
Normal file
804
.claude/commands/workflow/analyze-with-file.md
Normal file
@@ -0,0 +1,804 @@
|
||||
---
|
||||
name: analyze-with-file
|
||||
description: Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding
|
||||
argument-hint: "[-y|--yes] [-c|--continue] \"topic or question\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analysis angles.
|
||||
|
||||
# Workflow Analyze-With-File Command (/workflow:analyze-with-file)
|
||||
|
||||
## Overview
|
||||
|
||||
Interactive collaborative analysis workflow with **documented discussion process**. Records understanding evolution, facilitates multi-round Q&A, and uses CLI tools (Gemini/Codex) for deep exploration.
|
||||
|
||||
**Core workflow**: Topic → Explore → Discuss → Document → Refine → Conclude
|
||||
|
||||
**Key features**:
|
||||
- **discussion.md**: Timeline of discussions and understanding evolution
|
||||
- **Multi-round Q&A**: Iterative clarification with user
|
||||
- **CLI-assisted exploration**: Gemini/Codex for codebase and concept analysis
|
||||
- **Consolidated insights**: Synthesizes discussions into actionable conclusions
|
||||
- **Flexible continuation**: Resume analysis sessions to build on previous work
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:analyze-with-file [FLAGS] <TOPIC_OR_QUESTION>
|
||||
|
||||
# Flags
|
||||
-y, --yes Skip confirmations, use recommended settings
|
||||
-c, --continue Continue existing session (auto-detected if exists)
|
||||
|
||||
# Arguments
|
||||
<topic-or-question> Analysis topic, question, or concept to explore (required)
|
||||
|
||||
# Examples
|
||||
/workflow:analyze-with-file "如何优化这个项目的认证架构"
|
||||
/workflow:analyze-with-file --continue "认证架构" # Continue existing session
|
||||
/workflow:analyze-with-file -y "性能瓶颈分析" # Auto mode
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Session Detection:
|
||||
├─ Check if analysis session exists for topic
|
||||
├─ EXISTS + discussion.md exists → Continue mode
|
||||
└─ NOT_FOUND → New session mode
|
||||
|
||||
Phase 1: Topic Understanding
|
||||
├─ Parse topic/question
|
||||
├─ Identify analysis dimensions (architecture, implementation, concept, etc.)
|
||||
├─ Initial scoping with user (AskUserQuestion)
|
||||
└─ Document initial understanding in discussion.md
|
||||
|
||||
Phase 2: CLI Exploration (Parallel)
|
||||
├─ Launch cli-explore-agent for codebase context
|
||||
├─ Use Gemini/Codex for deep analysis
|
||||
└─ Aggregate findings into exploration summary
|
||||
|
||||
Phase 3: Interactive Discussion (Multi-Round)
|
||||
├─ Present exploration findings
|
||||
├─ Facilitate Q&A with user (AskUserQuestion)
|
||||
├─ Capture user insights and requirements
|
||||
├─ Update discussion.md with each round
|
||||
└─ Repeat until user is satisfied or clarity achieved
|
||||
|
||||
Phase 4: Synthesis & Conclusion
|
||||
├─ Consolidate all insights
|
||||
├─ Update discussion.md with conclusions
|
||||
├─ Generate actionable recommendations
|
||||
└─ Optional: Create follow-up tasks or issues
|
||||
|
||||
Output:
|
||||
├─ .workflow/.analysis/{slug}-{date}/discussion.md (evolving document)
|
||||
├─ .workflow/.analysis/{slug}-{date}/explorations.json (CLI findings)
|
||||
└─ .workflow/.analysis/{slug}-{date}/conclusions.json (final synthesis)
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Mode Detection
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const topicSlug = topic_or_question.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-').substring(0, 40)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
|
||||
const sessionId = `ANL-${topicSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.analysis/${sessionId}`
|
||||
const discussionPath = `${sessionFolder}/discussion.md`
|
||||
const explorationsPath = `${sessionFolder}/explorations.json`
|
||||
const conclusionsPath = `${sessionFolder}/conclusions.json`
|
||||
|
||||
// Auto-detect mode
|
||||
const sessionExists = fs.existsSync(sessionFolder)
|
||||
const hasDiscussion = sessionExists && fs.existsSync(discussionPath)
|
||||
const forcesContinue = $ARGUMENTS.includes('--continue') || $ARGUMENTS.includes('-c')
|
||||
|
||||
const mode = (hasDiscussion || forcesContinue) ? 'continue' : 'new'
|
||||
|
||||
if (!sessionExists) {
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 1: Topic Understanding
|
||||
|
||||
**Step 1.1: Parse Topic & Identify Dimensions**
|
||||
|
||||
```javascript
|
||||
// Analyze topic to determine analysis dimensions
|
||||
const ANALYSIS_DIMENSIONS = {
|
||||
architecture: ['架构', 'architecture', 'design', 'structure', '设计'],
|
||||
implementation: ['实现', 'implement', 'code', 'coding', '代码'],
|
||||
performance: ['性能', 'performance', 'optimize', 'bottleneck', '优化'],
|
||||
security: ['安全', 'security', 'auth', 'permission', '权限'],
|
||||
concept: ['概念', 'concept', 'theory', 'principle', '原理'],
|
||||
comparison: ['比较', 'compare', 'vs', 'difference', '区别'],
|
||||
decision: ['决策', 'decision', 'choice', 'tradeoff', '选择']
|
||||
}
|
||||
|
||||
function identifyDimensions(topic) {
|
||||
const text = topic.toLowerCase()
|
||||
const matched = []
|
||||
|
||||
for (const [dimension, keywords] of Object.entries(ANALYSIS_DIMENSIONS)) {
|
||||
if (keywords.some(k => text.includes(k))) {
|
||||
matched.push(dimension)
|
||||
}
|
||||
}
|
||||
|
||||
return matched.length > 0 ? matched : ['general']
|
||||
}
|
||||
|
||||
const dimensions = identifyDimensions(topic_or_question)
|
||||
```
|
||||
|
||||
**Step 1.2: Initial Scoping (New Session Only)**
|
||||
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (mode === 'new' && !autoYes) {
|
||||
// Ask user to scope the analysis
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `分析范围: "${topic_or_question}"\n\n您想重点关注哪些方面?`,
|
||||
header: "Focus",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "代码实现", description: "分析现有代码实现" },
|
||||
{ label: "架构设计", description: "架构层面的分析" },
|
||||
{ label: "最佳实践", description: "行业最佳实践对比" },
|
||||
{ label: "问题诊断", description: "识别潜在问题" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "分析深度?",
|
||||
header: "Depth",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Quick Overview", description: "快速概览 (10-15分钟)" },
|
||||
{ label: "Standard Analysis", description: "标准分析 (30-60分钟)" },
|
||||
{ label: "Deep Dive", description: "深度分析 (1-2小时)" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.3: Create/Update discussion.md**
|
||||
|
||||
For new session:
|
||||
```markdown
|
||||
# Analysis Discussion
|
||||
|
||||
**Session ID**: ${sessionId}
|
||||
**Topic**: ${topic_or_question}
|
||||
**Started**: ${getUtc8ISOString()}
|
||||
**Dimensions**: ${dimensions.join(', ')}
|
||||
|
||||
---
|
||||
|
||||
## User Context
|
||||
|
||||
**Focus Areas**: ${userFocusAreas.join(', ')}
|
||||
**Analysis Depth**: ${analysisDepth}
|
||||
|
||||
---
|
||||
|
||||
## Discussion Timeline
|
||||
|
||||
### Round 1 - Initial Understanding (${timestamp})
|
||||
|
||||
#### Topic Analysis
|
||||
|
||||
Based on the topic "${topic_or_question}":
|
||||
|
||||
- **Primary dimensions**: ${dimensions.join(', ')}
|
||||
- **Initial scope**: ${initialScope}
|
||||
- **Key questions to explore**:
|
||||
- ${question1}
|
||||
- ${question2}
|
||||
- ${question3}
|
||||
|
||||
#### Next Steps
|
||||
|
||||
- Launch CLI exploration for codebase context
|
||||
- Gather external insights via Gemini
|
||||
- Prepare discussion points for user
|
||||
|
||||
---
|
||||
|
||||
## Current Understanding
|
||||
|
||||
${initialUnderstanding}
|
||||
```
|
||||
|
||||
For continue session, append:
|
||||
```markdown
|
||||
### Round ${n} - Continuation (${timestamp})
|
||||
|
||||
#### Previous Context
|
||||
|
||||
Resuming analysis based on prior discussion.
|
||||
|
||||
#### New Focus
|
||||
|
||||
${newFocusFromUser}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: CLI Exploration
|
||||
|
||||
**Step 2.1: Launch Parallel Explorations**
|
||||
|
||||
```javascript
|
||||
const explorationPromises = []
|
||||
|
||||
// CLI Explore Agent for codebase
|
||||
if (dimensions.includes('implementation') || dimensions.includes('architecture')) {
|
||||
explorationPromises.push(
|
||||
Task(
|
||||
subagent_type="cli-explore-agent",
|
||||
run_in_background=false,
|
||||
description=`Explore codebase: ${topicSlug}`,
|
||||
prompt=`
|
||||
## Analysis Context
|
||||
Topic: ${topic_or_question}
|
||||
Dimensions: ${dimensions.join(', ')}
|
||||
Session: ${sessionFolder}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}'
|
||||
2. Execute relevant searches based on topic keywords
|
||||
3. Read: .workflow/project-tech.json (if exists)
|
||||
|
||||
## Exploration Focus
|
||||
${dimensions.map(d => `- ${d}: Identify relevant code patterns and structures`).join('\n')}
|
||||
|
||||
## Output
|
||||
Write findings to: ${sessionFolder}/exploration-codebase.json
|
||||
|
||||
Schema:
|
||||
{
|
||||
"relevant_files": [{path, relevance, rationale}],
|
||||
"patterns": [],
|
||||
"key_findings": [],
|
||||
"questions_for_user": [],
|
||||
"_metadata": { "exploration_type": "codebase", "timestamp": "..." }
|
||||
}
|
||||
`
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// Gemini CLI for deep analysis
|
||||
explorationPromises.push(
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Analyze topic '${topic_or_question}' from ${dimensions.join(', ')} perspectives
|
||||
Success criteria: Actionable insights with clear reasoning
|
||||
|
||||
TASK:
|
||||
• Identify key considerations for this topic
|
||||
• Analyze common patterns and anti-patterns
|
||||
• Highlight potential issues or opportunities
|
||||
• Generate discussion points for user clarification
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/* | Topic: ${topic_or_question}
|
||||
|
||||
EXPECTED:
|
||||
- Structured analysis with clear sections
|
||||
- Specific insights tied to evidence
|
||||
- Questions to deepen understanding
|
||||
- Recommendations with rationale
|
||||
|
||||
CONSTRAINTS: Focus on ${dimensions.join(', ')}
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
**Step 2.2: Aggregate Findings**
|
||||
|
||||
```javascript
|
||||
// After explorations complete, aggregate into explorations.json
|
||||
const explorations = {
|
||||
session_id: sessionId,
|
||||
timestamp: getUtc8ISOString(),
|
||||
topic: topic_or_question,
|
||||
dimensions: dimensions,
|
||||
sources: [
|
||||
{ type: "codebase", file: "exploration-codebase.json" },
|
||||
{ type: "gemini", summary: geminiOutput }
|
||||
],
|
||||
key_findings: [...],
|
||||
discussion_points: [...],
|
||||
open_questions: [...]
|
||||
}
|
||||
|
||||
Write(explorationsPath, JSON.stringify(explorations, null, 2))
|
||||
```
|
||||
|
||||
**Step 2.3: Update discussion.md**
|
||||
|
||||
```markdown
|
||||
#### Exploration Results (${timestamp})
|
||||
|
||||
**Sources Analyzed**:
|
||||
${sources.map(s => `- ${s.type}: ${s.summary}`).join('\n')}
|
||||
|
||||
**Key Findings**:
|
||||
${keyFindings.map((f, i) => `${i+1}. ${f}`).join('\n')}
|
||||
|
||||
**Points for Discussion**:
|
||||
${discussionPoints.map((p, i) => `${i+1}. ${p}`).join('\n')}
|
||||
|
||||
**Open Questions**:
|
||||
${openQuestions.map((q, i) => `- ${q}`).join('\n')}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Interactive Discussion (Multi-Round)
|
||||
|
||||
**Step 3.1: Present Findings & Gather Feedback**
|
||||
|
||||
```javascript
|
||||
// Maximum discussion rounds
|
||||
const MAX_ROUNDS = 5
|
||||
let roundNumber = 1
|
||||
let discussionComplete = false
|
||||
|
||||
while (!discussionComplete && roundNumber <= MAX_ROUNDS) {
|
||||
// Display current findings
|
||||
console.log(`
|
||||
## Discussion Round ${roundNumber}
|
||||
|
||||
${currentFindings}
|
||||
|
||||
### Key Points for Your Input
|
||||
${discussionPoints.map((p, i) => `${i+1}. ${p}`).join('\n')}
|
||||
`)
|
||||
|
||||
// Gather user input
|
||||
const userResponse = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "对以上分析有什么看法或补充?",
|
||||
header: "Feedback",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "同意,继续深入", description: "分析方向正确,继续探索" },
|
||||
{ label: "需要调整方向", description: "我有不同的理解或重点" },
|
||||
{ label: "分析完成", description: "已获得足够信息" },
|
||||
{ label: "有具体问题", description: "我想问一些具体问题" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// Process user response
|
||||
switch (userResponse.feedback) {
|
||||
case "同意,继续深入":
|
||||
// Deepen analysis in current direction
|
||||
await deepenAnalysis()
|
||||
break
|
||||
case "需要调整方向":
|
||||
// Get user's adjusted focus
|
||||
const adjustment = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "请说明您希望调整的方向或重点:",
|
||||
header: "Direction",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "更多代码细节", description: "深入代码实现" },
|
||||
{ label: "更多架构视角", description: "关注整体设计" },
|
||||
{ label: "更多实践对比", description: "对比最佳实践" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
await adjustAnalysisDirection(adjustment)
|
||||
break
|
||||
case "分析完成":
|
||||
discussionComplete = true
|
||||
break
|
||||
case "有具体问题":
|
||||
// Let user ask specific questions, then answer
|
||||
await handleUserQuestions()
|
||||
break
|
||||
}
|
||||
|
||||
// Update discussion.md with this round
|
||||
updateDiscussionDocument(roundNumber, userResponse, findings)
|
||||
roundNumber++
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3.2: Document Each Round**
|
||||
|
||||
Append to discussion.md:
|
||||
```markdown
|
||||
### Round ${n} - Discussion (${timestamp})
|
||||
|
||||
#### User Input
|
||||
|
||||
${userInputSummary}
|
||||
|
||||
${userResponse === 'adjustment' ? `
|
||||
**Direction Adjustment**: ${adjustmentDetails}
|
||||
` : ''}
|
||||
|
||||
${userResponse === 'questions' ? `
|
||||
**User Questions**:
|
||||
${userQuestions.map((q, i) => `${i+1}. ${q}`).join('\n')}
|
||||
|
||||
**Answers**:
|
||||
${answers.map((a, i) => `${i+1}. ${a}`).join('\n')}
|
||||
` : ''}
|
||||
|
||||
#### Updated Understanding
|
||||
|
||||
Based on user feedback:
|
||||
- ${insight1}
|
||||
- ${insight2}
|
||||
|
||||
#### Corrected Assumptions
|
||||
|
||||
${corrections.length > 0 ? corrections.map(c => `
|
||||
- ~~${c.wrong}~~ → ${c.corrected}
|
||||
- Reason: ${c.reason}
|
||||
`).join('\n') : 'None'}
|
||||
|
||||
#### New Insights
|
||||
|
||||
${newInsights.map(i => `- ${i}`).join('\n')}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Synthesis & Conclusion
|
||||
|
||||
**Step 4.1: Consolidate Insights**
|
||||
|
||||
```javascript
|
||||
const conclusions = {
|
||||
session_id: sessionId,
|
||||
topic: topic_or_question,
|
||||
completed: getUtc8ISOString(),
|
||||
total_rounds: roundNumber,
|
||||
|
||||
summary: "...",
|
||||
|
||||
key_conclusions: [
|
||||
{ point: "...", evidence: "...", confidence: "high|medium|low" }
|
||||
],
|
||||
|
||||
recommendations: [
|
||||
{ action: "...", rationale: "...", priority: "high|medium|low" }
|
||||
],
|
||||
|
||||
open_questions: [...],
|
||||
|
||||
follow_up_suggestions: [
|
||||
{ type: "issue", summary: "..." },
|
||||
{ type: "task", summary: "..." }
|
||||
]
|
||||
}
|
||||
|
||||
Write(conclusionsPath, JSON.stringify(conclusions, null, 2))
|
||||
```
|
||||
|
||||
**Step 4.2: Final discussion.md Update**
|
||||
|
||||
```markdown
|
||||
---
|
||||
|
||||
## Conclusions (${timestamp})
|
||||
|
||||
### Summary
|
||||
|
||||
${summaryParagraph}
|
||||
|
||||
### Key Conclusions
|
||||
|
||||
${conclusions.key_conclusions.map((c, i) => `
|
||||
${i+1}. **${c.point}** (Confidence: ${c.confidence})
|
||||
- Evidence: ${c.evidence}
|
||||
`).join('\n')}
|
||||
|
||||
### Recommendations
|
||||
|
||||
${conclusions.recommendations.map((r, i) => `
|
||||
${i+1}. **${r.action}** (Priority: ${r.priority})
|
||||
- Rationale: ${r.rationale}
|
||||
`).join('\n')}
|
||||
|
||||
### Remaining Questions
|
||||
|
||||
${conclusions.open_questions.map(q => `- ${q}`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Current Understanding (Final)
|
||||
|
||||
### What We Established
|
||||
|
||||
${establishedPoints.map(p => `- ${p}`).join('\n')}
|
||||
|
||||
### What Was Clarified/Corrected
|
||||
|
||||
${corrections.map(c => `- ~~${c.original}~~ → ${c.corrected}`).join('\n')}
|
||||
|
||||
### Key Insights
|
||||
|
||||
${keyInsights.map(i => `- ${i}`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Session Statistics
|
||||
|
||||
- **Total Rounds**: ${totalRounds}
|
||||
- **Duration**: ${duration}
|
||||
- **Sources Used**: ${sources.join(', ')}
|
||||
- **Artifacts Generated**: discussion.md, explorations.json, conclusions.json
|
||||
```
|
||||
|
||||
**Step 4.3: Post-Completion Options**
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "分析完成。是否需要后续操作?",
|
||||
header: "Next Steps",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "创建Issue", description: "将结论转为可执行的Issue" },
|
||||
{ label: "生成任务", description: "创建实施任务" },
|
||||
{ label: "导出报告", description: "生成独立的分析报告" },
|
||||
{ label: "完成", description: "不需要后续操作" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
|
||||
// Handle selections
|
||||
if (selection.includes("创建Issue")) {
|
||||
SlashCommand("/issue:new", `${topic_or_question} - 分析结论实施`)
|
||||
}
|
||||
if (selection.includes("生成任务")) {
|
||||
SlashCommand("/workflow:lite-plan", `实施分析结论: ${summary}`)
|
||||
}
|
||||
if (selection.includes("导出报告")) {
|
||||
exportAnalysisReport(sessionFolder)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.analysis/ANL-{slug}-{date}/
|
||||
├── discussion.md # Evolution of understanding & discussions
|
||||
├── explorations.json # CLI exploration findings
|
||||
├── conclusions.json # Final synthesis
|
||||
└── exploration-*.json # Individual exploration results (optional)
|
||||
```
|
||||
|
||||
## Discussion Document Template
|
||||
|
||||
```markdown
|
||||
# Analysis Discussion
|
||||
|
||||
**Session ID**: ANL-xxx-2025-01-25
|
||||
**Topic**: [topic or question]
|
||||
**Started**: 2025-01-25T10:00:00+08:00
|
||||
**Dimensions**: [architecture, implementation, ...]
|
||||
|
||||
---
|
||||
|
||||
## User Context
|
||||
|
||||
**Focus Areas**: [user-selected focus]
|
||||
**Analysis Depth**: [quick|standard|deep]
|
||||
|
||||
---
|
||||
|
||||
## Discussion Timeline
|
||||
|
||||
### Round 1 - Initial Understanding (2025-01-25 10:00)
|
||||
|
||||
#### Topic Analysis
|
||||
...
|
||||
|
||||
#### Exploration Results
|
||||
...
|
||||
|
||||
### Round 2 - Discussion (2025-01-25 10:15)
|
||||
|
||||
#### User Input
|
||||
...
|
||||
|
||||
#### Updated Understanding
|
||||
...
|
||||
|
||||
#### Corrected Assumptions
|
||||
- ~~[wrong]~~ → [corrected]
|
||||
|
||||
### Round 3 - Deep Dive (2025-01-25 10:30)
|
||||
...
|
||||
|
||||
---
|
||||
|
||||
## Conclusions (2025-01-25 11:00)
|
||||
|
||||
### Summary
|
||||
...
|
||||
|
||||
### Key Conclusions
|
||||
...
|
||||
|
||||
### Recommendations
|
||||
...
|
||||
|
||||
---
|
||||
|
||||
## Current Understanding (Final)
|
||||
|
||||
### What We Established
|
||||
- [confirmed points]
|
||||
|
||||
### What Was Clarified/Corrected
|
||||
- ~~[original assumption]~~ → [corrected understanding]
|
||||
|
||||
### Key Insights
|
||||
- [insights gained]
|
||||
|
||||
---
|
||||
|
||||
## Session Statistics
|
||||
|
||||
- **Total Rounds**: 3
|
||||
- **Duration**: 1 hour
|
||||
- **Sources Used**: codebase exploration, Gemini analysis
|
||||
- **Artifacts Generated**: discussion.md, explorations.json, conclusions.json
|
||||
```
|
||||
|
||||
## Iteration Flow
|
||||
|
||||
```
|
||||
First Call (/workflow:analyze-with-file "topic"):
|
||||
├─ No session exists → New mode
|
||||
├─ Identify analysis dimensions
|
||||
├─ Scope with user (unless --yes)
|
||||
├─ Create discussion.md with initial understanding
|
||||
├─ Launch CLI explorations
|
||||
└─ Enter discussion loop
|
||||
|
||||
Continue Call (/workflow:analyze-with-file --continue "topic"):
|
||||
├─ Session exists → Continue mode
|
||||
├─ Load discussion.md
|
||||
├─ Resume from last round
|
||||
└─ Continue discussion loop
|
||||
|
||||
Discussion Loop:
|
||||
├─ Present current findings
|
||||
├─ Gather user feedback (AskUserQuestion)
|
||||
├─ Process response:
|
||||
│ ├─ Agree → Deepen analysis
|
||||
│ ├─ Adjust → Change direction
|
||||
│ ├─ Question → Answer then continue
|
||||
│ └─ Complete → Exit loop
|
||||
├─ Update discussion.md
|
||||
└─ Repeat until complete or max rounds
|
||||
|
||||
Completion:
|
||||
├─ Generate conclusions.json
|
||||
├─ Update discussion.md with final synthesis
|
||||
└─ Offer follow-up options (issue, task, report)
|
||||
```
|
||||
|
||||
## CLI Integration Points
|
||||
|
||||
### 1. Codebase Exploration (cli-explore-agent)
|
||||
|
||||
**Purpose**: Gather relevant code context
|
||||
|
||||
**When**: Topic involves implementation or architecture analysis
|
||||
|
||||
### 2. Gemini Deep Analysis
|
||||
|
||||
**Purpose**: Conceptual analysis, pattern identification, best practices
|
||||
|
||||
**Prompt Pattern**:
|
||||
```
|
||||
PURPOSE: Analyze topic + identify insights
|
||||
TASK: Explore dimensions + generate discussion points
|
||||
CONTEXT: Codebase + topic
|
||||
EXPECTED: Structured analysis + questions
|
||||
```
|
||||
|
||||
### 3. Follow-up CLI Calls
|
||||
|
||||
**Purpose**: Deepen specific areas based on user feedback
|
||||
|
||||
**Dynamic invocation** based on discussion direction
|
||||
|
||||
## Consolidation Rules
|
||||
|
||||
When updating "Current Understanding":
|
||||
|
||||
1. **Promote confirmed insights**: Move validated findings to "What We Established"
|
||||
2. **Track corrections**: Keep important wrong→right transformations
|
||||
3. **Focus on current state**: What do we know NOW
|
||||
4. **Avoid timeline repetition**: Don't copy discussion details
|
||||
5. **Preserve key learnings**: Keep insights valuable for future reference
|
||||
|
||||
**Bad (cluttered)**:
|
||||
```markdown
|
||||
## Current Understanding
|
||||
|
||||
In round 1 we discussed X, then in round 2 user said Y, and we explored Z...
|
||||
```
|
||||
|
||||
**Good (consolidated)**:
|
||||
```markdown
|
||||
## Current Understanding
|
||||
|
||||
### What We Established
|
||||
- The authentication flow uses JWT with refresh tokens
|
||||
- Rate limiting is implemented at API gateway level
|
||||
|
||||
### What Was Clarified
|
||||
- ~~Assumed Redis for sessions~~ → Actually uses database-backed sessions
|
||||
|
||||
### Key Insights
|
||||
- Current architecture supports horizontal scaling
|
||||
- Security audit recommended before production
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| CLI exploration fails | Continue with available context, note limitation |
|
||||
| User timeout in discussion | Save state, show resume command |
|
||||
| Max rounds reached | Force synthesis, offer continuation option |
|
||||
| No relevant findings | Broaden search, ask user for clarification |
|
||||
| Session folder conflict | Append timestamp suffix |
|
||||
| Gemini unavailable | Fallback to Codex or manual analysis |
|
||||
|
||||
|
||||
## Usage Recommendations
|
||||
|
||||
Use `/workflow:analyze-with-file` when:
|
||||
- Exploring a complex topic collaboratively
|
||||
- Need documented discussion trail
|
||||
- Decision-making requires multiple perspectives
|
||||
- Want to iterate on understanding with user input
|
||||
- Building shared understanding before implementation
|
||||
|
||||
Use `/workflow:debug-with-file` when:
|
||||
- Diagnosing specific bugs
|
||||
- Need hypothesis-driven investigation
|
||||
- Focus on evidence and verification
|
||||
|
||||
Use `/workflow:lite-plan` when:
|
||||
- Ready to implement (past analysis phase)
|
||||
- Need structured task breakdown
|
||||
- Focus on execution planning
|
||||
1153
.claude/commands/workflow/brainstorm-with-file.md
Normal file
1153
.claude/commands/workflow/brainstorm-with-file.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,587 +0,0 @@
|
||||
---
|
||||
name: api-designer
|
||||
description: Generate or update api-designer/analysis.md addressing guidance-specification discussion points for API design perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🔌 **API Designer Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating api-designer/analysis.md** that addresses guidance-specification.md discussion points from backend API design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **API Design Focus**: RESTful/GraphQL API design, endpoint structure, and contract definition
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **API Architecture**: RESTful/GraphQL design patterns and best practices
|
||||
- **Endpoint Design**: Resource modeling, URL structure, and HTTP method selection
|
||||
- **Data Contracts**: Request/response schemas, validation rules, and data transformation
|
||||
- **API Documentation**: OpenAPI/Swagger specifications and developer experience
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (API Contract Within Architectural Framework)**
|
||||
- **API Contract Definition**: Specific endpoint paths, HTTP methods, and status codes
|
||||
- **Resource Modeling**: Mapping domain entities to RESTful resources or GraphQL types
|
||||
- **Request/Response Schemas**: Detailed data contracts, validation rules, and error formats
|
||||
- **API Versioning Strategy**: Version management, deprecation policies, and migration paths
|
||||
- **Developer Experience**: API documentation (OpenAPI/Swagger), code examples, and SDKs
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **System Architecture Decisions**: Microservices vs monolithic, overall communication patterns → Defers to **System Architect**
|
||||
- **Canonical Data Model**: Underlying data schemas and entity relationships → Defers to **Data Architect**
|
||||
- **UI/Frontend Integration**: How clients consume the API → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **FROM System Architect**: Receives architectural constraints (REST vs GraphQL, sync vs async) that define the design space
|
||||
- **FROM Data Architect**: Receives canonical data model and translates it into public API data contracts (as projection/view)
|
||||
- **TO Frontend Teams**: Provides complete API specifications, documentation, and integration guides
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Check existing analysis
|
||||
CHECK: brainstorm_dir/api-designer/analysis.md
|
||||
IF EXISTS:
|
||||
SHOW existing analysis summary
|
||||
ASK: "Analysis exists. Do you want to:"
|
||||
OPTIONS:
|
||||
1. "Update with new insights" → Update existing
|
||||
2. "Replace completely" → Generate new
|
||||
3. "Cancel" → Exit without changes
|
||||
ELSE:
|
||||
CREATE new analysis
|
||||
```
|
||||
|
||||
### Phase 3: Agent Task Generation
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```bash
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Generate API designer analysis addressing topic framework
|
||||
|
||||
## Framework Integration Required
|
||||
**MANDATORY**: Load and address guidance-specification.md discussion points
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
**Output Location**: {session.brainstorm_dir}/api-designer/analysis.md
|
||||
|
||||
## Analysis Requirements
|
||||
1. **Load Topic Framework**: Read guidance-specification.md completely
|
||||
2. **Address Each Discussion Point**: Respond to all 5 framework sections from API design perspective
|
||||
3. **Include Framework Reference**: Start analysis.md with @../guidance-specification.md
|
||||
4. **API Design Focus**: Emphasize endpoint structure, data contracts, versioning strategies
|
||||
5. **Structured Response**: Use framework structure for analysis organization
|
||||
|
||||
## Framework Sections to Address
|
||||
- Core Requirements (from API design perspective)
|
||||
- Technical Considerations (detailed API architecture analysis)
|
||||
- User Experience Factors (developer experience and API usability)
|
||||
- Implementation Challenges (API design risks and solutions)
|
||||
- Success Metrics (API performance metrics and adoption tracking)
|
||||
|
||||
## Output Structure Required
|
||||
```markdown
|
||||
# API Designer Analysis: [Topic]
|
||||
|
||||
**Framework Reference**: @../guidance-specification.md
|
||||
**Role Focus**: Backend API Design and Contract Definition
|
||||
|
||||
## Core Requirements Analysis
|
||||
[Address framework requirements from API design perspective]
|
||||
|
||||
## Technical Considerations
|
||||
[Detailed API architecture and endpoint design analysis]
|
||||
|
||||
## Developer Experience Factors
|
||||
[API usability, documentation, and integration ease]
|
||||
|
||||
## Implementation Challenges
|
||||
[API design risks and mitigation strategies]
|
||||
|
||||
## Success Metrics
|
||||
[API performance metrics, adoption rates, and developer satisfaction]
|
||||
|
||||
## API Design-Specific Recommendations
|
||||
[Detailed API design recommendations and best practices]
|
||||
```",
|
||||
description="Generate API designer framework-based analysis")
|
||||
```
|
||||
|
||||
### Phase 4: Update Mechanism
|
||||
**Analysis Update Process**:
|
||||
```bash
|
||||
# For existing analysis updates
|
||||
IF update_mode = "incremental":
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Update existing API designer analysis
|
||||
|
||||
## Current Analysis Context
|
||||
**Existing Analysis**: @{session.brainstorm_dir}/api-designer/analysis.md
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
|
||||
## Update Requirements
|
||||
1. **Preserve Structure**: Maintain existing analysis structure
|
||||
2. **Add New Insights**: Integrate new API design insights and recommendations
|
||||
3. **Framework Alignment**: Ensure continued alignment with topic framework
|
||||
4. **API Updates**: Add new endpoint patterns, versioning strategies, documentation improvements
|
||||
5. **Maintain References**: Keep @../guidance-specification.md reference
|
||||
|
||||
## Update Instructions
|
||||
- Read existing analysis completely
|
||||
- Identify areas for enhancement or new insights
|
||||
- Add API design depth while preserving original structure
|
||||
- Update recommendations with new API design patterns and approaches
|
||||
- Maintain framework discussion point addressing",
|
||||
description="Update API designer analysis incrementally")
|
||||
```
|
||||
|
||||
## Document Structure
|
||||
|
||||
### Output Files
|
||||
```
|
||||
.workflow/active/WFS-[topic]/.brainstorming/
|
||||
├── guidance-specification.md # Input: Framework (if exists)
|
||||
└── api-designer/
|
||||
└── analysis.md # ★ OUTPUT: Framework-based analysis
|
||||
```
|
||||
|
||||
### Analysis Structure
|
||||
**Required Elements**:
|
||||
- **Framework Reference**: @../guidance-specification.md (if framework exists)
|
||||
- **Role Focus**: Backend API Design and Contract Definition perspective
|
||||
- **5 Framework Sections**: Address each framework discussion point
|
||||
- **API Design Recommendations**: Endpoint-specific insights and solutions
|
||||
|
||||
## ⚡ **Two-Step Execution Flow**
|
||||
|
||||
### ⚠️ Session Management - FIRST STEP
|
||||
Session detection and selection:
|
||||
```bash
|
||||
# Check for active sessions
|
||||
active_sessions=$(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
if [ multiple_sessions ]; then
|
||||
prompt_user_to_select_session()
|
||||
else
|
||||
use_existing_or_create_new()
|
||||
fi
|
||||
```
|
||||
|
||||
### Step 1: Context Gathering Phase
|
||||
**API Designer Perspective Questioning**
|
||||
|
||||
Before agent assignment, gather comprehensive API design context:
|
||||
|
||||
#### 📋 Role-Specific Questions
|
||||
1. **API Type & Architecture**
|
||||
- RESTful, GraphQL, or hybrid API approach?
|
||||
- Synchronous vs asynchronous communication patterns?
|
||||
- Real-time requirements (WebSocket, Server-Sent Events)?
|
||||
|
||||
2. **Resource Modeling & Endpoints**
|
||||
- What are the core domain resources/entities?
|
||||
- Expected CRUD operations for each resource?
|
||||
- Complex query requirements (filtering, sorting, pagination)?
|
||||
|
||||
3. **Data Contracts & Validation**
|
||||
- Request/response data format requirements (JSON, XML, Protocol Buffers)?
|
||||
- Input validation and sanitization requirements?
|
||||
- Data transformation and mapping needs?
|
||||
|
||||
4. **API Management & Governance**
|
||||
- API versioning strategy requirements?
|
||||
- Authentication and authorization mechanisms?
|
||||
- Rate limiting and throttling requirements?
|
||||
- API documentation and developer portal needs?
|
||||
|
||||
5. **Integration & Compatibility**
|
||||
- Client platforms consuming the API (web, mobile, third-party)?
|
||||
- Backward compatibility requirements?
|
||||
- External API integrations needed?
|
||||
|
||||
#### Context Validation
|
||||
- **Minimum Response**: Each answer must be ≥50 characters
|
||||
- **Re-prompting**: Insufficient detail triggers follow-up questions
|
||||
- **Context Storage**: Save responses to `.brainstorming/api-designer-context.md`
|
||||
|
||||
### Step 2: Agent Assignment with Flow Control
|
||||
**Dedicated Agent Execution**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute dedicated api-designer conceptual analysis for: {topic}
|
||||
|
||||
ASSIGNED_ROLE: api-designer
|
||||
OUTPUT_LOCATION: .brainstorming/api-designer/
|
||||
USER_CONTEXT: {validated_responses_from_context_gathering}
|
||||
|
||||
Flow Control Steps:
|
||||
[
|
||||
{
|
||||
\"step\": \"load_role_template\",
|
||||
\"action\": \"Load api-designer planning template\",
|
||||
\"command\": \"bash($(cat ~/.claude/workflows/cli-templates/planning-roles/api-designer.md))\",
|
||||
\"output_to\": \"role_template\"
|
||||
}
|
||||
]
|
||||
|
||||
Conceptual Analysis Requirements:
|
||||
- Apply api-designer perspective to topic analysis
|
||||
- Focus on endpoint design, data contracts, and API governance
|
||||
- Use loaded role template framework for analysis structure
|
||||
- Generate role-specific deliverables in designated output location
|
||||
- Address all user context from questioning phase
|
||||
|
||||
Deliverables:
|
||||
- analysis.md: Main API design analysis
|
||||
- api-specification.md: Detailed endpoint specifications
|
||||
- data-contracts.md: Request/response schemas and validation rules
|
||||
- api-documentation.md: API documentation strategy and templates
|
||||
|
||||
Embody api-designer role expertise for comprehensive conceptual planning."
|
||||
```
|
||||
|
||||
### Progress Tracking
|
||||
TodoWrite tracking for two-step process:
|
||||
```json
|
||||
[
|
||||
{"content": "Gather API designer context through role-specific questioning", "status": "in_progress", "activeForm": "Gathering context"},
|
||||
{"content": "Validate context responses and save to api-designer-context.md", "status": "pending", "activeForm": "Validating context"},
|
||||
{"content": "Load api-designer planning template via flow control", "status": "pending", "activeForm": "Loading template"},
|
||||
{"content": "Execute dedicated conceptual-planning-agent for api-designer role", "status": "pending", "activeForm": "Executing agent"}
|
||||
]
|
||||
```
|
||||
|
||||
## 📊 **Output Specification**
|
||||
|
||||
### Output Location
|
||||
```
|
||||
.workflow/active/WFS-{topic-slug}/.brainstorming/api-designer/
|
||||
├── analysis.md # Primary API design analysis
|
||||
├── api-specification.md # Detailed endpoint specifications (OpenAPI/Swagger)
|
||||
├── data-contracts.md # Request/response schemas and validation rules
|
||||
├── versioning-strategy.md # API versioning and backward compatibility plan
|
||||
└── developer-guide.md # API usage documentation and integration examples
|
||||
```
|
||||
|
||||
### Document Templates
|
||||
|
||||
#### analysis.md Structure
|
||||
```markdown
|
||||
# API Design Analysis: {Topic}
|
||||
*Generated: {timestamp}*
|
||||
|
||||
## Executive Summary
|
||||
[Key API design findings and recommendations overview]
|
||||
|
||||
## API Architecture Overview
|
||||
### API Type Selection (REST/GraphQL/Hybrid)
|
||||
### Communication Patterns
|
||||
### Authentication & Authorization Strategy
|
||||
|
||||
## Resource Modeling
|
||||
### Core Domain Resources
|
||||
### Resource Relationships
|
||||
### URL Structure and Naming Conventions
|
||||
|
||||
## Endpoint Design
|
||||
### Resource Endpoints
|
||||
- GET /api/v1/resources
|
||||
- POST /api/v1/resources
|
||||
- GET /api/v1/resources/{id}
|
||||
- PUT /api/v1/resources/{id}
|
||||
- DELETE /api/v1/resources/{id}
|
||||
|
||||
### Query Parameters
|
||||
- Filtering: ?filter[field]=value
|
||||
- Sorting: ?sort=field,-field2
|
||||
- Pagination: ?page=1&limit=20
|
||||
|
||||
### HTTP Methods and Status Codes
|
||||
- Success responses (2xx)
|
||||
- Client errors (4xx)
|
||||
- Server errors (5xx)
|
||||
|
||||
## Data Contracts
|
||||
### Request Schemas
|
||||
[JSON Schema or OpenAPI definitions]
|
||||
|
||||
### Response Schemas
|
||||
[JSON Schema or OpenAPI definitions]
|
||||
|
||||
### Validation Rules
|
||||
- Required fields
|
||||
- Data types and formats
|
||||
- Business logic constraints
|
||||
|
||||
## API Versioning Strategy
|
||||
### Versioning Approach (URL/Header/Accept)
|
||||
### Version Lifecycle Management
|
||||
### Deprecation Policy
|
||||
### Migration Paths
|
||||
|
||||
## Security & Governance
|
||||
### Authentication Mechanisms
|
||||
- OAuth 2.0 / JWT / API Keys
|
||||
### Authorization Patterns
|
||||
- RBAC / ABAC / Resource-based
|
||||
### Rate Limiting & Throttling
|
||||
### CORS and Security Headers
|
||||
|
||||
## Error Handling
|
||||
### Standard Error Response Format
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "ERROR_CODE",
|
||||
"message": "Human-readable error message",
|
||||
"details": [],
|
||||
"trace_id": "uuid"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Error Code Taxonomy
|
||||
### Validation Error Responses
|
||||
|
||||
## API Documentation
|
||||
### OpenAPI/Swagger Specification
|
||||
### Developer Portal Requirements
|
||||
### Code Examples and SDKs
|
||||
### Changelog and Migration Guides
|
||||
|
||||
## Performance Optimization
|
||||
### Response Caching Strategies
|
||||
### Compression (gzip, brotli)
|
||||
### Field Selection (sparse fieldsets)
|
||||
### Bulk Operations and Batch Endpoints
|
||||
|
||||
## Monitoring & Observability
|
||||
### API Metrics
|
||||
- Request count, latency, error rates
|
||||
- Endpoint usage analytics
|
||||
### Logging Strategy
|
||||
### Distributed Tracing
|
||||
|
||||
## Developer Experience
|
||||
### API Usability Assessment
|
||||
### Integration Complexity
|
||||
### SDK and Client Library Needs
|
||||
### Sandbox and Testing Environments
|
||||
```
|
||||
|
||||
#### api-specification.md Structure
|
||||
```markdown
|
||||
# API Specification: {Topic}
|
||||
*OpenAPI 3.0 Specification*
|
||||
|
||||
## API Information
|
||||
- **Title**: {API Name}
|
||||
- **Version**: 1.0.0
|
||||
- **Base URL**: https://api.example.com/v1
|
||||
- **Contact**: api-team@example.com
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Users API
|
||||
|
||||
#### GET /users
|
||||
**Description**: Retrieve a list of users
|
||||
|
||||
**Parameters**:
|
||||
- `page` (query, integer): Page number (default: 1)
|
||||
- `limit` (query, integer): Items per page (default: 20, max: 100)
|
||||
- `sort` (query, string): Sort field (e.g., "created_at", "-updated_at")
|
||||
- `filter[status]` (query, string): Filter by user status
|
||||
|
||||
**Response 200**:
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "uuid",
|
||||
"username": "string",
|
||||
"email": "string",
|
||||
"created_at": "2025-10-15T00:00:00Z"
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"page": 1,
|
||||
"limit": 20,
|
||||
"total": 100
|
||||
},
|
||||
"links": {
|
||||
"self": "/users?page=1",
|
||||
"next": "/users?page=2",
|
||||
"prev": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### POST /users
|
||||
**Description**: Create a new user
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"username": "string (required, 3-50 chars)",
|
||||
"email": "string (required, valid email)",
|
||||
"password": "string (required, min 8 chars)",
|
||||
"profile": {
|
||||
"first_name": "string (optional)",
|
||||
"last_name": "string (optional)"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response 201**:
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"id": "uuid",
|
||||
"username": "string",
|
||||
"email": "string",
|
||||
"created_at": "2025-10-15T00:00:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response 400** (Validation Error):
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "Request validation failed",
|
||||
"details": [
|
||||
{
|
||||
"field": "email",
|
||||
"message": "Invalid email format"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[Continue for all endpoints...]
|
||||
|
||||
## Authentication
|
||||
|
||||
### OAuth 2.0 Flow
|
||||
1. Client requests authorization
|
||||
2. User grants permission
|
||||
3. Client receives access token
|
||||
4. Client uses token in requests
|
||||
|
||||
**Header Format**:
|
||||
```
|
||||
Authorization: Bearer {access_token}
|
||||
```
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
**Headers**:
|
||||
- `X-RateLimit-Limit`: 1000
|
||||
- `X-RateLimit-Remaining`: 999
|
||||
- `X-RateLimit-Reset`: 1634270400
|
||||
|
||||
**Response 429** (Too Many Requests):
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "RATE_LIMIT_EXCEEDED",
|
||||
"message": "API rate limit exceeded",
|
||||
"retry_after": 3600
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Status Synchronization
|
||||
Upon completion, update `workflow-session.json`:
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"api_designer": {
|
||||
"status": "completed",
|
||||
"completed_at": "timestamp",
|
||||
"output_directory": ".workflow/active/WFS-{topic}/.brainstorming/api-designer/",
|
||||
"key_insights": ["endpoint_design", "versioning_strategy", "data_contracts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cross-Role Collaboration
|
||||
API designer perspective provides:
|
||||
- **API Contract Specifications** → Frontend Developer
|
||||
- **Data Schema Requirements** → Data Architect
|
||||
- **Security Requirements** → Security Expert
|
||||
- **Integration Endpoints** → System Architect
|
||||
- **Performance Constraints** → DevOps Engineer
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Complete endpoint inventory with HTTP methods and paths
|
||||
- [ ] Detailed request/response schemas with validation rules
|
||||
- [ ] Clear versioning strategy and backward compatibility plan
|
||||
- [ ] Comprehensive error handling and status code usage
|
||||
- [ ] API documentation strategy (OpenAPI/Swagger)
|
||||
|
||||
### API Design Principles
|
||||
- [ ] **Consistency**: Uniform naming conventions and patterns across all endpoints
|
||||
- [ ] **Simplicity**: Intuitive resource modeling and URL structures
|
||||
- [ ] **Flexibility**: Support for filtering, sorting, pagination, and field selection
|
||||
- [ ] **Security**: Proper authentication, authorization, and input validation
|
||||
- [ ] **Performance**: Caching strategies, compression, and efficient data structures
|
||||
|
||||
### Developer Experience Validation
|
||||
- [ ] API is self-documenting with clear endpoint descriptions
|
||||
- [ ] Error messages are actionable and helpful for debugging
|
||||
- [ ] Response formats are consistent and predictable
|
||||
- [ ] Code examples and integration guides are provided
|
||||
- [ ] Sandbox environment available for testing
|
||||
|
||||
### Technical Completeness
|
||||
- [ ] **Resource Modeling**: All domain entities mapped to API resources
|
||||
- [ ] **CRUD Coverage**: Complete create, read, update, delete operations
|
||||
- [ ] **Query Capabilities**: Advanced filtering, sorting, and search functionality
|
||||
- [ ] **Versioning**: Clear version management and migration paths
|
||||
- [ ] **Monitoring**: API metrics, logging, and tracing strategies defined
|
||||
|
||||
### Integration Readiness
|
||||
- [ ] **Client Compatibility**: API works with all target client platforms
|
||||
- [ ] **External Integration**: Third-party API dependencies identified
|
||||
- [ ] **Backward Compatibility**: Changes don't break existing clients
|
||||
- [ ] **Migration Path**: Clear upgrade paths for API consumers
|
||||
- [ ] **SDK Support**: Client libraries and code generation considered
|
||||
@@ -132,55 +132,30 @@ SlashCommand(command="/workflow:brainstorm:artifacts \"{topic}\" --count {N}")
|
||||
|
||||
### Phase 2: Parallel Role Analysis Execution
|
||||
|
||||
**For Each Selected Role**:
|
||||
**For Each Selected Role** (unified role-analysis command):
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute {role-name} analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: {role-name}
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/{role}/
|
||||
TOPIC: {user-provided-topic}
|
||||
|
||||
## Flow Control Steps
|
||||
1. load_topic_framework → .workflow/active/WFS-{session}/.brainstorming/guidance-specification.md
|
||||
2. load_role_template → ~/.claude/workflows/cli-templates/planning-roles/{role}.md
|
||||
3. load_session_metadata → .workflow/active/WFS-{session}/workflow-session.json
|
||||
4. load_style_skill (ui-designer only, if style_skill_package) → .claude/skills/style-{style_skill_package}/
|
||||
|
||||
## Analysis Requirements
|
||||
**Primary Reference**: Original user prompt from workflow-session.json is authoritative
|
||||
**Framework Source**: Address all discussion points in guidance-specification.md from {role-name} perspective
|
||||
**Role Focus**: {role-name} domain expertise aligned with user intent
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md** (optionally with analysis-{slug}.md sub-documents)
|
||||
2. **Framework Reference**: @../guidance-specification.md
|
||||
3. **User Intent Alignment**: Validate against session_context
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with {role-name} expertise
|
||||
- Provide actionable recommendations from {role-name} perspective within analysis files
|
||||
- All output files MUST start with `analysis` prefix (no recommendations.md or other naming)
|
||||
- Reference framework document using @ notation for integration
|
||||
- Update workflow-session.json with completion status
|
||||
"
|
||||
SlashCommand(command="/workflow:brainstorm:role-analysis {role-name} --session {session-id} --skip-questions")
|
||||
```
|
||||
|
||||
**Parallel Execute**:
|
||||
- Launch N agents simultaneously (one message with multiple Task calls)
|
||||
- Each agent task **attached** to orchestrator's TodoWrite
|
||||
- All agents execute concurrently, each attaching their own analysis sub-tasks
|
||||
- Each agent operates independently reading same guidance-specification.md
|
||||
**What It Does**:
|
||||
- Unified command execution for each role
|
||||
- Loads topic framework from guidance-specification.md
|
||||
- Applies role-specific template and context
|
||||
- Generates analysis.md addressing framework discussion points
|
||||
- Supports optional interactive context gathering (via --include-questions flag)
|
||||
|
||||
**Parallel Execution**:
|
||||
- Launch N SlashCommand calls simultaneously (one message with multiple SlashCommand invokes)
|
||||
- Each role command **attached** to orchestrator's TodoWrite
|
||||
- All roles execute concurrently, each reading same guidance-specification.md
|
||||
- Each role operates independently
|
||||
- For ui-designer only: append `--style-skill {style_skill_package}` if provided
|
||||
|
||||
**Input**:
|
||||
- `selected_roles[]` from Phase 1
|
||||
- `session_id` from Phase 1
|
||||
- guidance-specification.md path
|
||||
- `guidance-specification.md` (framework reference)
|
||||
- `style_skill_package` (for ui-designer only)
|
||||
|
||||
**Validation**:
|
||||
- Each role creates `.workflow/active/WFS-{topic}/.brainstorming/{role}/analysis.md`
|
||||
@@ -189,6 +164,7 @@ TOPIC: {user-provided-topic}
|
||||
- **FORBIDDEN**: `recommendations.md` or any non-`analysis` prefixed files
|
||||
- All N role analyses completed
|
||||
|
||||
|
||||
**TodoWrite Update (Phase 2 agents executed - tasks attached in parallel)**:
|
||||
```json
|
||||
[
|
||||
@@ -455,4 +431,3 @@ CONTEXT_VARS:
|
||||
```
|
||||
|
||||
**Template Source**: `~/.claude/workflows/cli-templates/planning-roles/`
|
||||
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
---
|
||||
name: data-architect
|
||||
description: Generate or update data-architect/analysis.md addressing guidance-specification discussion points for data architecture perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 📊 **Data Architect Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating data-architect/analysis.md** that addresses guidance-specification.md discussion points from data architecture perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Data Architecture Focus**: Data models, pipelines, governance, and analytics perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Data Model Design**: Efficient and scalable data models and schemas
|
||||
- **Data Flow Design**: Data collection, processing, and storage workflows
|
||||
- **Data Quality Management**: Data accuracy, completeness, and consistency
|
||||
- **Analytics and Insights**: Data analysis and business intelligence solutions
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Canonical Data Model - Source of Truth)**
|
||||
- **Canonical Data Model**: The authoritative, system-wide data schema representing domain entities and relationships
|
||||
- **Entity-Relationship Design**: Defining entities, attributes, relationships, and constraints
|
||||
- **Data Normalization & Optimization**: Ensuring data integrity, reducing redundancy, and optimizing storage
|
||||
- **Database Schema Design**: Physical database structures, indexes, partitioning strategies
|
||||
- **Data Pipeline Architecture**: ETL/ELT processes, data warehousing, and analytics pipelines
|
||||
- **Data Governance**: Data quality standards, retention policies, and compliance requirements
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **API Data Contracts**: Public-facing request/response schemas exposed by APIs → Defers to **API Designer**
|
||||
- **System Integration Patterns**: How services communicate at the macro level → Defers to **System Architect**
|
||||
- **UI Data Presentation**: How data is displayed to users → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO API Designer**: Provides canonical data model that API Designer translates into public API data contracts (as projection/view)
|
||||
- **TO System Architect**: Provides data flow requirements and storage constraints to inform system design
|
||||
- **FROM System Architect**: Receives system-level integration requirements and scalability constraints
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute data-architect analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: data-architect
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/data-architect/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load data-architect planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/data-architect.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from data architecture perspective
|
||||
**Role Focus**: Data models, pipelines, governance, analytics platforms
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive data architecture analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with data architecture expertise
|
||||
- Provide data model designs, pipeline architectures, and governance strategies
|
||||
- Include scalability, performance, and quality considerations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute data-architect analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing data-architect framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured data-architect analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with data-architect completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/data-architect/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Data Architect Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Data Architecture perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with data architecture expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Data architecture perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Data model, pipeline, and storage considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Data access patterns and analytics user experience]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Data migration, quality, and governance challenges]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Data quality metrics and analytics success criteria]
|
||||
|
||||
## Data Architecture Specific Recommendations
|
||||
[Role-specific data architecture recommendations and solutions]
|
||||
|
||||
---
|
||||
*Generated by data-architect analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"data_architect": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/data-architect/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Data architecture insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: product-manager
|
||||
description: Generate or update product-manager/analysis.md addressing guidance-specification discussion points for product management perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Product Manager Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating product-manager/analysis.md** that addresses guidance-specification.md discussion points from product strategy perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Product Strategy Focus**: User needs, business value, and market positioning
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **User Needs Analysis**: Target users, problems, and value propositions
|
||||
- **Business Impact Assessment**: ROI, metrics, and commercial outcomes
|
||||
- **Market Positioning**: Competitive analysis and differentiation
|
||||
- **Product Strategy**: Roadmaps, priorities, and go-to-market approaches
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute product-manager analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: product-manager
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/product-manager/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load product-manager planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/product-manager.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from product strategy perspective
|
||||
**Role Focus**: User value, business impact, market positioning, product strategy
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive product strategy analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with product management expertise
|
||||
- Provide actionable business strategies and user value propositions
|
||||
- Include market analysis and competitive positioning insights
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute product-manager analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing product-manager framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured product-manager analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with product-manager completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/product-manager/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Product Manager Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Product Strategy perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with product management expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Product strategy perspective on user needs and requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Business and technical feasibility considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User value proposition and market positioning analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Business execution and go-to-market considerations]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Product success metrics and business KPIs]
|
||||
|
||||
## Product Strategy Specific Recommendations
|
||||
[Role-specific product management strategies and business solutions]
|
||||
|
||||
---
|
||||
*Generated by product-manager analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"product_manager": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/product-manager/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Product strategy insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: product-owner
|
||||
description: Generate or update product-owner/analysis.md addressing guidance-specification discussion points for product ownership perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Product Owner Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating product-owner/analysis.md** that addresses guidance-specification.md discussion points from product backlog and feature prioritization perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Product Backlog Focus**: Feature prioritization, user stories, and acceptance criteria
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Backlog Management**: User story creation, refinement, and prioritization
|
||||
- **Stakeholder Alignment**: Requirements gathering, value definition, and expectation management
|
||||
- **Feature Prioritization**: ROI analysis, MoSCoW method, and value-driven delivery
|
||||
- **Acceptance Criteria**: Definition of Done, acceptance testing, and quality standards
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute product-owner analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: product-owner
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/product-owner/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load product-owner planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/product-owner.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from product backlog and feature prioritization perspective
|
||||
**Role Focus**: Backlog management, stakeholder alignment, feature prioritization, acceptance criteria
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive product ownership analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with product ownership expertise
|
||||
- Provide actionable user stories and acceptance criteria definitions
|
||||
- Include feature prioritization and stakeholder alignment strategies
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute product-owner analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing product-owner framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured product-owner analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with product-owner completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/product-owner/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Product Owner Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Product Backlog & Feature Prioritization perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with product ownership expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[User story formulation and backlog refinement perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Technical feasibility and implementation sequencing considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User value definition and acceptance criteria analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Sprint planning, dependency management, and delivery strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Feature adoption, value delivery metrics, and stakeholder satisfaction indicators]
|
||||
|
||||
## Product Owner Specific Recommendations
|
||||
[Role-specific backlog management and feature prioritization strategies]
|
||||
|
||||
---
|
||||
*Generated by product-owner analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"product_owner": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/product-owner/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Product ownership insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
705
.claude/commands/workflow/brainstorm/role-analysis.md
Normal file
705
.claude/commands/workflow/brainstorm/role-analysis.md
Normal file
@@ -0,0 +1,705 @@
|
||||
---
|
||||
name: role-analysis
|
||||
description: Unified role-specific analysis generation with interactive context gathering and incremental updates
|
||||
argument-hint: "[role-name] [--session session-id] [--update] [--include-questions] [--skip-questions]"
|
||||
allowed-tools: Task(conceptual-planning-agent), AskUserQuestion(*), TodoWrite(*), Read(*), Write(*), Edit(*), Glob(*)
|
||||
---
|
||||
|
||||
## 🎯 **Unified Role Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Unified command for generating and updating role-specific analysis** with interactive context gathering, framework alignment, and incremental update support. Replaces 9 individual role commands with single parameterized workflow.
|
||||
|
||||
### Core Function
|
||||
- **Multi-Role Support**: Single command supports all 9 brainstorming roles
|
||||
- **Interactive Context**: Dynamic question generation based on role and framework
|
||||
- **Incremental Updates**: Merge new insights into existing analyses
|
||||
- **Framework Alignment**: Address guidance-specification.md discussion points
|
||||
- **Agent Delegation**: Use conceptual-planning-agent with role-specific templates
|
||||
|
||||
### Supported Roles
|
||||
|
||||
| Role ID | Title | Focus Area | Context Questions |
|
||||
|---------|-------|------------|-------------------|
|
||||
| `ux-expert` | UX专家 | User research, information architecture, user journey | 4 |
|
||||
| `ui-designer` | UI设计师 | Visual design, high-fidelity mockups, design systems | 4 |
|
||||
| `system-architect` | 系统架构师 | Technical architecture, scalability, integration patterns | 5 |
|
||||
| `product-manager` | 产品经理 | Product strategy, roadmap, prioritization | 4 |
|
||||
| `product-owner` | 产品负责人 | Backlog management, user stories, acceptance criteria | 4 |
|
||||
| `scrum-master` | 敏捷教练 | Process facilitation, impediment removal, team dynamics | 3 |
|
||||
| `subject-matter-expert` | 领域专家 | Domain knowledge, business rules, compliance | 4 |
|
||||
| `data-architect` | 数据架构师 | Data models, storage strategies, data flow | 5 |
|
||||
| `api-designer` | API设计师 | API contracts, versioning, integration patterns | 4 |
|
||||
|
||||
---
|
||||
|
||||
## 📋 **Usage**
|
||||
|
||||
```bash
|
||||
# Generate new analysis with interactive context
|
||||
/workflow:brainstorm:role-analysis ux-expert
|
||||
|
||||
# Generate with existing framework + context questions
|
||||
/workflow:brainstorm:role-analysis system-architect --session WFS-xxx --include-questions
|
||||
|
||||
# Update existing analysis (incremental merge)
|
||||
/workflow:brainstorm:role-analysis ui-designer --session WFS-xxx --update
|
||||
|
||||
# Quick generation (skip interactive context)
|
||||
/workflow:brainstorm:role-analysis product-manager --session WFS-xxx --skip-questions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Detection & Validation
|
||||
|
||||
**Step 1.1: Role Validation**
|
||||
```bash
|
||||
VALIDATE role_name IN [
|
||||
ux-expert, ui-designer, system-architect, product-manager,
|
||||
product-owner, scrum-master, subject-matter-expert,
|
||||
data-architect, api-designer
|
||||
]
|
||||
IF invalid:
|
||||
ERROR: "Unknown role: {role_name}. Use one of: ux-expert, ui-designer, ..."
|
||||
EXIT
|
||||
```
|
||||
|
||||
**Step 1.2: Session Detection**
|
||||
```bash
|
||||
IF --session PROVIDED:
|
||||
session_id = --session
|
||||
brainstorm_dir = .workflow/active/{session_id}/.brainstorming/
|
||||
ELSE:
|
||||
FIND .workflow/active/WFS-*/
|
||||
IF multiple:
|
||||
PROMPT user to select
|
||||
ELSE IF single:
|
||||
USE existing
|
||||
ELSE:
|
||||
ERROR: "No active session. Run /workflow:brainstorm:artifacts first"
|
||||
EXIT
|
||||
|
||||
VALIDATE brainstorm_dir EXISTS
|
||||
```
|
||||
|
||||
**Step 1.3: Framework Detection**
|
||||
```bash
|
||||
framework_file = {brainstorm_dir}/guidance-specification.md
|
||||
IF framework_file EXISTS:
|
||||
framework_mode = true
|
||||
LOAD framework_content
|
||||
ELSE:
|
||||
WARN: "No framework found - will create standalone analysis"
|
||||
framework_mode = false
|
||||
```
|
||||
|
||||
**Step 1.4: Update Mode Detection**
|
||||
```bash
|
||||
existing_analysis = {brainstorm_dir}/{role_name}/analysis*.md
|
||||
IF --update FLAG OR existing_analysis EXISTS:
|
||||
update_mode = true
|
||||
IF --update NOT PROVIDED:
|
||||
ASK: "Analysis exists. Update or regenerate?"
|
||||
OPTIONS: ["Incremental update", "Full regenerate", "Cancel"]
|
||||
ELSE:
|
||||
update_mode = false
|
||||
```
|
||||
|
||||
### Phase 2: Interactive Context Gathering
|
||||
|
||||
**Trigger Conditions**:
|
||||
- Default: Always ask unless `--skip-questions` provided
|
||||
- `--include-questions`: Force context gathering even if analysis exists
|
||||
- `--skip-questions`: Skip all interactive questions
|
||||
|
||||
**Step 2.1: Load Role Configuration**
|
||||
```javascript
|
||||
const roleConfig = {
|
||||
'ux-expert': {
|
||||
title: 'UX专家',
|
||||
focus_area: 'User research, information architecture, user journey',
|
||||
question_categories: ['User Intent', 'Requirements', 'UX'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/ux-expert.md'
|
||||
},
|
||||
'ui-designer': {
|
||||
title: 'UI设计师',
|
||||
focus_area: 'Visual design, high-fidelity mockups, design systems',
|
||||
question_categories: ['Requirements', 'UX', 'Feasibility'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/ui-designer.md'
|
||||
},
|
||||
'system-architect': {
|
||||
title: '系统架构师',
|
||||
focus_area: 'Technical architecture, scalability, integration patterns',
|
||||
question_categories: ['Scale & Performance', 'Technical Constraints', 'Architecture Complexity', 'Non-Functional Requirements'],
|
||||
question_count: 5,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/system-architect.md'
|
||||
},
|
||||
'product-manager': {
|
||||
title: '产品经理',
|
||||
focus_area: 'Product strategy, roadmap, prioritization',
|
||||
question_categories: ['User Intent', 'Requirements', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/product-manager.md'
|
||||
},
|
||||
'product-owner': {
|
||||
title: '产品负责人',
|
||||
focus_area: 'Backlog management, user stories, acceptance criteria',
|
||||
question_categories: ['Requirements', 'Decisions', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/product-owner.md'
|
||||
},
|
||||
'scrum-master': {
|
||||
title: '敏捷教练',
|
||||
focus_area: 'Process facilitation, impediment removal, team dynamics',
|
||||
question_categories: ['Process', 'Risk', 'Decisions'],
|
||||
question_count: 3,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/scrum-master.md'
|
||||
},
|
||||
'subject-matter-expert': {
|
||||
title: '领域专家',
|
||||
focus_area: 'Domain knowledge, business rules, compliance',
|
||||
question_categories: ['Requirements', 'Feasibility', 'Terminology'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/subject-matter-expert.md'
|
||||
},
|
||||
'data-architect': {
|
||||
title: '数据架构师',
|
||||
focus_area: 'Data models, storage strategies, data flow',
|
||||
question_categories: ['Architecture', 'Scale & Performance', 'Technical Constraints', 'Feasibility'],
|
||||
question_count: 5,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/data-architect.md'
|
||||
},
|
||||
'api-designer': {
|
||||
title: 'API设计师',
|
||||
focus_area: 'API contracts, versioning, integration patterns',
|
||||
question_categories: ['Architecture', 'Requirements', 'Feasibility', 'Decisions'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/api-designer.md'
|
||||
}
|
||||
};
|
||||
|
||||
config = roleConfig[role_name];
|
||||
```
|
||||
|
||||
**Step 2.2: Generate Role-Specific Questions**
|
||||
|
||||
**9-Category Taxonomy** (from synthesis.md):
|
||||
|
||||
| Category | Focus | Example Question Pattern |
|
||||
|----------|-------|--------------------------|
|
||||
| User Intent | 用户目标 | "该分析的核心目标是什么?" |
|
||||
| Requirements | 需求细化 | "需求的优先级如何排序?" |
|
||||
| Architecture | 架构决策 | "技术栈的选择考量?" |
|
||||
| UX | 用户体验 | "交互复杂度的取舍?" |
|
||||
| Feasibility | 可行性 | "资源约束下的实现范围?" |
|
||||
| Risk | 风险管理 | "风险容忍度是多少?" |
|
||||
| Process | 流程规范 | "开发迭代的节奏?" |
|
||||
| Decisions | 决策确认 | "冲突的解决方案?" |
|
||||
| Terminology | 术语统一 | "统一使用哪个术语?" |
|
||||
| Scale & Performance | 性能扩展 | "预期的负载和性能要求?" |
|
||||
| Technical Constraints | 技术约束 | "现有技术栈的限制?" |
|
||||
| Architecture Complexity | 架构复杂度 | "架构的复杂度权衡?" |
|
||||
| Non-Functional Requirements | 非功能需求 | "可用性和可维护性要求?" |
|
||||
|
||||
**Question Generation Algorithm**:
|
||||
```javascript
|
||||
async function generateQuestions(role_name, framework_content) {
|
||||
const config = roleConfig[role_name];
|
||||
const questions = [];
|
||||
|
||||
// Parse framework for keywords
|
||||
const keywords = extractKeywords(framework_content);
|
||||
|
||||
// Generate category-specific questions
|
||||
for (const category of config.question_categories) {
|
||||
const question = generateCategoryQuestion(category, keywords, role_name);
|
||||
questions.push(question);
|
||||
}
|
||||
|
||||
return questions.slice(0, config.question_count);
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2.3: Multi-Round Question Execution**
|
||||
|
||||
```javascript
|
||||
const BATCH_SIZE = 4;
|
||||
const user_context = {};
|
||||
|
||||
for (let i = 0; i < questions.length; i += BATCH_SIZE) {
|
||||
const batch = questions.slice(i, i + BATCH_SIZE);
|
||||
const currentRound = Math.floor(i / BATCH_SIZE) + 1;
|
||||
const totalRounds = Math.ceil(questions.length / BATCH_SIZE);
|
||||
|
||||
console.log(`\n[Round ${currentRound}/${totalRounds}] ${config.title} 上下文询问\n`);
|
||||
|
||||
AskUserQuestion({
|
||||
questions: batch.map(q => ({
|
||||
question: q.question,
|
||||
header: q.category.substring(0, 12),
|
||||
multiSelect: false,
|
||||
options: q.options.map(opt => ({
|
||||
label: opt.label,
|
||||
description: opt.description
|
||||
}))
|
||||
}))
|
||||
});
|
||||
|
||||
// Store responses before next round
|
||||
for (const answer of responses) {
|
||||
user_context[answer.question] = {
|
||||
answer: answer.selected,
|
||||
category: answer.category,
|
||||
timestamp: new Date().toISOString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Save context to file
|
||||
Write(
|
||||
`${brainstorm_dir}/${role_name}/${role_name}-context.md`,
|
||||
formatUserContext(user_context)
|
||||
);
|
||||
```
|
||||
|
||||
**Question Quality Rules** (from artifacts.md):
|
||||
|
||||
**MUST Include**:
|
||||
- ✅ All questions in Chinese (用中文提问)
|
||||
- ✅ 业务场景作为问题前提
|
||||
- ✅ 技术选项的业务影响说明
|
||||
- ✅ 量化指标和约束条件
|
||||
|
||||
**MUST Avoid**:
|
||||
- ❌ 纯技术选型无业务上下文
|
||||
- ❌ 过度抽象的通用问题
|
||||
- ❌ 脱离框架的重复询问
|
||||
|
||||
### Phase 3: Agent Execution
|
||||
|
||||
**Step 3.1: Load Session Metadata**
|
||||
```bash
|
||||
session_metadata = Read(.workflow/active/{session_id}/workflow-session.json)
|
||||
original_topic = session_metadata.topic
|
||||
selected_roles = session_metadata.selected_roles
|
||||
```
|
||||
|
||||
**Step 3.2: Prepare Agent Context**
|
||||
```javascript
|
||||
const agentContext = {
|
||||
role_name: role_name,
|
||||
role_config: roleConfig[role_name],
|
||||
output_location: `${brainstorm_dir}/${role_name}/`,
|
||||
framework_mode: framework_mode,
|
||||
framework_path: framework_mode ? `${brainstorm_dir}/guidance-specification.md` : null,
|
||||
update_mode: update_mode,
|
||||
user_context: user_context,
|
||||
original_topic: original_topic,
|
||||
session_id: session_id
|
||||
};
|
||||
```
|
||||
|
||||
**Step 3.3: Execute Conceptual Planning Agent**
|
||||
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
description=`Generate ${role_name} analysis`,
|
||||
prompt=`
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ${role_name} analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ${role_name}
|
||||
OUTPUT_LOCATION: ${agentContext.output_location}
|
||||
ANALYSIS_MODE: ${framework_mode ? "framework_based" : "standalone"}
|
||||
UPDATE_MODE: ${update_mode}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(${agentContext.framework_path})
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ${role_name} planning template
|
||||
- Command: Read(${roleConfig[role_name].template})
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and user intent
|
||||
- Command: Read(.workflow/active/${session_id}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
4. **load_user_context** (if exists)
|
||||
- Action: Load interactive context responses
|
||||
- Command: Read(${brainstorm_dir}/${role_name}/${role_name}-context.md)
|
||||
- Output: user_context_answers
|
||||
|
||||
5. **${update_mode ? 'load_existing_analysis' : 'skip'}**
|
||||
${update_mode ? `
|
||||
- Action: Load existing analysis for incremental update
|
||||
- Command: Read(${brainstorm_dir}/${role_name}/analysis.md)
|
||||
- Output: existing_analysis_content
|
||||
` : ''}
|
||||
|
||||
## Analysis Requirements
|
||||
**Primary Reference**: Original user prompt from workflow-session.json is authoritative
|
||||
**Framework Source**: Address all discussion points in guidance-specification.md from ${role_name} perspective
|
||||
**User Context Integration**: Incorporate interactive Q&A responses into analysis
|
||||
**Role Focus**: ${roleConfig[role_name].focus_area}
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md** (main document, optionally with analysis-{slug}.md sub-documents)
|
||||
2. **Framework Reference**: @../guidance-specification.md (if framework_mode)
|
||||
3. **User Context Reference**: @./${role_name}-context.md (if user context exists)
|
||||
4. **User Intent Alignment**: Validate against session_context
|
||||
|
||||
## Update Requirements (if UPDATE_MODE)
|
||||
- **Preserve Structure**: Maintain existing analysis structure
|
||||
- **Add "Clarifications" Section**: Document new user context with timestamp
|
||||
- **Merge Insights**: Integrate new perspectives without removing existing content
|
||||
- **Resolve Conflicts**: If new context contradicts existing analysis, document both and recommend resolution
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with ${role_name} expertise
|
||||
- Provide actionable recommendations from ${role_name} perspective within analysis files
|
||||
- All output files MUST start with "analysis" prefix (no recommendations.md or other naming)
|
||||
- Reference framework document using @ notation for integration
|
||||
- Update workflow-session.json with completion status
|
||||
`
|
||||
);
|
||||
```
|
||||
|
||||
### Phase 4: Validation & Finalization
|
||||
|
||||
**Step 4.1: Validate Output**
|
||||
```bash
|
||||
VERIFY EXISTS: ${brainstorm_dir}/${role_name}/analysis.md
|
||||
VERIFY CONTAINS: "@../guidance-specification.md" (if framework_mode)
|
||||
IF user_context EXISTS:
|
||||
VERIFY CONTAINS: "@./${role_name}-context.md" OR "## Clarifications" section
|
||||
```
|
||||
|
||||
**Step 4.2: Update Session Metadata**
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"${role_name}": {
|
||||
"status": "${update_mode ? 'updated' : 'completed'}",
|
||||
"completed_at": "timestamp",
|
||||
"framework_addressed": true,
|
||||
"context_gathered": user_context ? true : false,
|
||||
"output_location": "${brainstorm_dir}/${role_name}/analysis.md",
|
||||
"update_history": [
|
||||
{
|
||||
"timestamp": "ISO8601",
|
||||
"mode": "${update_mode ? 'incremental' : 'initial'}",
|
||||
"context_questions": question_count
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.3: Completion Report**
|
||||
```markdown
|
||||
✅ ${roleConfig[role_name].title} Analysis Complete
|
||||
|
||||
**Output**: ${brainstorm_dir}/${role_name}/analysis.md
|
||||
**Mode**: ${update_mode ? 'Incremental Update' : 'New Generation'}
|
||||
**Framework**: ${framework_mode ? '✓ Aligned' : '✗ Standalone'}
|
||||
**Context Questions**: ${question_count} answered
|
||||
|
||||
${update_mode ? '
|
||||
**Changes**:
|
||||
- Added "Clarifications" section with new user context
|
||||
- Merged new insights into existing sections
|
||||
- Resolved conflicts with framework alignment
|
||||
' : ''}
|
||||
|
||||
**Next Steps**:
|
||||
${selected_roles.length > 1 ? `
|
||||
- Continue with other roles: ${selected_roles.filter(r => r !== role_name).join(', ')}
|
||||
- Run synthesis: /workflow:brainstorm:synthesis --session ${session_id}
|
||||
` : `
|
||||
- Clarify insights: /workflow:brainstorm:synthesis --session ${session_id}
|
||||
- Generate plan: /workflow:plan --session ${session_id}
|
||||
`}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Phase 1: Detect session and validate role configuration",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and role"
|
||||
},
|
||||
{
|
||||
content: "Phase 2: Interactive context gathering with AskUserQuestion",
|
||||
status: "pending",
|
||||
activeForm: "Gathering user context"
|
||||
},
|
||||
{
|
||||
content: "Phase 3: Execute conceptual-planning-agent for role analysis",
|
||||
status: "pending",
|
||||
activeForm: "Executing agent analysis"
|
||||
},
|
||||
{
|
||||
content: "Phase 4: Validate output and update session metadata",
|
||||
status: "pending",
|
||||
activeForm: "Finalizing and validating"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Directory Layout
|
||||
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/
|
||||
├── guidance-specification.md # Framework (if exists)
|
||||
└── {role-name}/
|
||||
├── {role-name}-context.md # Interactive Q&A responses
|
||||
├── analysis.md # Main analysis (REQUIRED)
|
||||
└── analysis-{slug}.md # Section documents (optional, max 5)
|
||||
```
|
||||
|
||||
### Analysis Document Structure (New Generation)
|
||||
|
||||
```markdown
|
||||
# ${roleConfig[role_name].title} Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: ${roleConfig[role_name].focus_area}
|
||||
**User Context**: @./${role_name}-context.md
|
||||
|
||||
## User Context Summary
|
||||
**Context Gathered**: ${question_count} questions answered
|
||||
**Categories**: ${question_categories.join(', ')}
|
||||
|
||||
${user_context ? formatContextSummary(user_context) : ''}
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with ${role_name} expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Role-specific perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Role-specific technical analysis]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Role-specific UX considerations]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Role-specific challenges and solutions]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Role-specific metrics and KPIs]
|
||||
|
||||
## ${roleConfig[role_name].title} Specific Recommendations
|
||||
[Role-specific actionable strategies]
|
||||
|
||||
---
|
||||
*Generated by ${role_name} analysis addressing structured framework*
|
||||
*Context gathered: ${new Date().toISOString()}*
|
||||
```
|
||||
|
||||
### Analysis Document Structure (Incremental Update)
|
||||
|
||||
```markdown
|
||||
# ${roleConfig[role_name].title} Analysis: [Topic]
|
||||
|
||||
## Framework Reference
|
||||
[Existing content preserved]
|
||||
|
||||
## Clarifications
|
||||
### Session ${new Date().toISOString().split('T')[0]}
|
||||
${Object.entries(user_context).map(([q, a]) => `
|
||||
- **Q**: ${q} (Category: ${a.category})
|
||||
**A**: ${a.answer}
|
||||
`).join('\n')}
|
||||
|
||||
## User Context Summary
|
||||
[Updated with new context]
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Existing content enhanced with new insights]
|
||||
|
||||
[Rest of sections updated based on clarifications]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 **Integration with Other Commands**
|
||||
|
||||
### Called By
|
||||
- `/workflow:brainstorm:auto-parallel` (Phase 2 - parallel role execution)
|
||||
- Manual invocation for single-role analysis
|
||||
|
||||
### Calls To
|
||||
- `conceptual-planning-agent` (agent execution)
|
||||
- `AskUserQuestion` (interactive context gathering)
|
||||
|
||||
### Coordinates With
|
||||
- `/workflow:brainstorm:artifacts` (creates framework for role analysis)
|
||||
- `/workflow:brainstorm:synthesis` (reads role analyses for integration)
|
||||
|
||||
---
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Framework discussion points addressed (if framework_mode)
|
||||
- [ ] User context integrated (if context gathered)
|
||||
- [ ] Role template guidelines applied
|
||||
- [ ] Output files follow naming convention (analysis*.md only)
|
||||
- [ ] Framework reference using @ notation
|
||||
- [ ] Session metadata updated
|
||||
|
||||
### Context Quality
|
||||
- [ ] Questions in Chinese with business context
|
||||
- [ ] Options include technical trade-offs
|
||||
- [ ] Categories aligned with role focus
|
||||
- [ ] No generic questions unrelated to framework
|
||||
|
||||
### Update Quality (if update_mode)
|
||||
- [ ] "Clarifications" section added with timestamp
|
||||
- [ ] New insights merged without content loss
|
||||
- [ ] Conflicts documented and resolved
|
||||
- [ ] Framework alignment maintained
|
||||
|
||||
---
|
||||
|
||||
## 🎛️ **Command Parameters**
|
||||
|
||||
### Required Parameters
|
||||
- `[role-name]`: Role identifier (ux-expert, ui-designer, system-architect, etc.)
|
||||
|
||||
### Optional Parameters
|
||||
- `--session [session-id]`: Specify brainstorming session (auto-detect if omitted)
|
||||
- `--update`: Force incremental update mode (auto-detect if analysis exists)
|
||||
- `--include-questions`: Force context gathering even if analysis exists
|
||||
- `--skip-questions`: Skip all interactive context gathering
|
||||
- `--style-skill [package]`: For ui-designer only, load style SKILL package
|
||||
|
||||
### Parameter Combinations
|
||||
|
||||
| Scenario | Command | Behavior |
|
||||
|----------|---------|----------|
|
||||
| New analysis | `role-analysis ux-expert` | Generate + ask context questions |
|
||||
| Quick generation | `role-analysis ux-expert --skip-questions` | Generate without context |
|
||||
| Update existing | `role-analysis ux-expert --update` | Ask clarifications + merge |
|
||||
| Force questions | `role-analysis ux-expert --include-questions` | Ask even if exists |
|
||||
| Specific session | `role-analysis ux-expert --session WFS-xxx` | Target specific session |
|
||||
|
||||
---
|
||||
|
||||
## 🚫 **Error Handling**
|
||||
|
||||
### Invalid Role Name
|
||||
```
|
||||
ERROR: Unknown role: "ui-expert"
|
||||
Valid roles: ux-expert, ui-designer, system-architect, product-manager,
|
||||
product-owner, scrum-master, subject-matter-expert,
|
||||
data-architect, api-designer
|
||||
```
|
||||
|
||||
### No Active Session
|
||||
```
|
||||
ERROR: No active brainstorming session found
|
||||
Run: /workflow:brainstorm:artifacts "[topic]" to create session
|
||||
```
|
||||
|
||||
### Missing Framework (with warning)
|
||||
```
|
||||
WARN: No guidance-specification.md found
|
||||
Generating standalone analysis without framework alignment
|
||||
Recommend: Run /workflow:brainstorm:artifacts first for better results
|
||||
```
|
||||
|
||||
### Agent Execution Failure
|
||||
```
|
||||
ERROR: Conceptual planning agent failed
|
||||
Check: ${brainstorm_dir}/${role_name}/error.log
|
||||
Action: Retry with --skip-questions or check framework validity
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 **Advanced Usage**
|
||||
|
||||
### Batch Role Generation (via auto-parallel)
|
||||
```bash
|
||||
# This command handles multiple roles in parallel
|
||||
/workflow:brainstorm:auto-parallel "topic" --count 3
|
||||
# → Internally calls role-analysis for each selected role
|
||||
```
|
||||
|
||||
### Manual Multi-Role Workflow
|
||||
```bash
|
||||
# 1. Create framework
|
||||
/workflow:brainstorm:artifacts "Build real-time collaboration platform" --count 3
|
||||
|
||||
# 2. Generate each role with context
|
||||
/workflow:brainstorm:role-analysis system-architect --include-questions
|
||||
/workflow:brainstorm:role-analysis ui-designer --include-questions
|
||||
/workflow:brainstorm:role-analysis product-manager --include-questions
|
||||
|
||||
# 3. Synthesize insights
|
||||
/workflow:brainstorm:synthesis --session WFS-xxx
|
||||
```
|
||||
|
||||
### Iterative Refinement
|
||||
```bash
|
||||
# Initial generation
|
||||
/workflow:brainstorm:role-analysis ux-expert
|
||||
|
||||
# User reviews and wants more depth
|
||||
/workflow:brainstorm:role-analysis ux-expert --update --include-questions
|
||||
# → Asks clarification questions, merges new insights
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 **Reference Information**
|
||||
|
||||
### Role Template Locations
|
||||
- Templates: `~/.claude/workflows/cli-templates/planning-roles/`
|
||||
- Format: `{role-name}.md` (e.g., `ux-expert.md`, `system-architect.md`)
|
||||
|
||||
### Related Commands
|
||||
- `/workflow:brainstorm:artifacts` - Create framework and select roles
|
||||
- `/workflow:brainstorm:auto-parallel` - Parallel multi-role execution
|
||||
- `/workflow:brainstorm:synthesis` - Integrate role analyses
|
||||
- `/workflow:plan` - Generate implementation plan from synthesis
|
||||
|
||||
### Context Package
|
||||
- Location: `.workflow/active/WFS-{session}/.process/context-package.json`
|
||||
- Used by: `context-search-agent` (Phase 0 of artifacts)
|
||||
- Contains: Project context, tech stack, conflict risks
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: scrum-master
|
||||
description: Generate or update scrum-master/analysis.md addressing guidance-specification discussion points for Agile process perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Scrum Master Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating scrum-master/analysis.md** that addresses guidance-specification.md discussion points from agile process and team collaboration perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Agile Process Focus**: Sprint planning, team dynamics, and delivery optimization
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Sprint Planning**: Task breakdown, estimation, and iteration planning
|
||||
- **Team Collaboration**: Communication patterns, impediment removal, and facilitation
|
||||
- **Process Optimization**: Agile ceremonies, retrospectives, and continuous improvement
|
||||
- **Delivery Management**: Velocity tracking, burndown analysis, and release planning
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute scrum-master analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: scrum-master
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/scrum-master/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load scrum-master planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/scrum-master.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from agile process and team collaboration perspective
|
||||
**Role Focus**: Sprint planning, team dynamics, process optimization, delivery management
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive agile process analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with scrum mastery expertise
|
||||
- Provide actionable sprint planning and team facilitation strategies
|
||||
- Include process optimization and impediment removal insights
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute scrum-master analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing scrum-master framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured scrum-master analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with scrum-master completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/scrum-master/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Scrum Master Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Agile Process & Team Collaboration perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with scrum mastery expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Sprint planning and iteration breakdown perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Technical debt management and process considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User story refinement and acceptance criteria analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Impediment identification and removal strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Velocity tracking, burndown metrics, and team performance indicators]
|
||||
|
||||
## Scrum Master Specific Recommendations
|
||||
[Role-specific agile process optimization and team facilitation strategies]
|
||||
|
||||
---
|
||||
*Generated by scrum-master analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"scrum_master": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/scrum-master/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Agile process insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: subject-matter-expert
|
||||
description: Generate or update subject-matter-expert/analysis.md addressing guidance-specification discussion points for domain expertise perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Subject Matter Expert Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating subject-matter-expert/analysis.md** that addresses guidance-specification.md discussion points from domain knowledge and technical expertise perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Domain Expertise Focus**: Deep technical knowledge, industry standards, and best practices
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Domain Knowledge**: Industry-specific expertise, regulatory requirements, and compliance
|
||||
- **Technical Standards**: Best practices, design patterns, and architectural guidelines
|
||||
- **Risk Assessment**: Technical debt, scalability concerns, and maintenance implications
|
||||
- **Knowledge Transfer**: Documentation strategies, training requirements, and expertise sharing
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute subject-matter-expert analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: subject-matter-expert
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load subject-matter-expert planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/subject-matter-expert.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from domain expertise and technical standards perspective
|
||||
**Role Focus**: Domain knowledge, technical standards, risk assessment, knowledge transfer
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive domain expertise analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with subject matter expertise
|
||||
- Provide actionable technical standards and best practices recommendations
|
||||
- Include risk assessment and compliance considerations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute subject-matter-expert analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing subject-matter-expert framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured subject-matter-expert analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with subject-matter-expert completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Subject Matter Expert Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Domain Expertise & Technical Standards perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with subject matter expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Domain-specific requirements and industry standards perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Deep technical analysis, architectural patterns, and best practices]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Domain-specific usability standards and industry conventions]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Technical risks, scalability concerns, and maintenance implications]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Domain-specific KPIs, compliance metrics, and quality standards]
|
||||
|
||||
## Subject Matter Expert Specific Recommendations
|
||||
[Role-specific technical expertise and industry best practices]
|
||||
|
||||
---
|
||||
*Generated by subject-matter-expert analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"subject_matter_expert": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Domain expertise insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,389 +0,0 @@
|
||||
---
|
||||
name: system-architect
|
||||
description: Generate or update system-architect/analysis.md addressing guidance-specification discussion points for system architecture perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🏗️ **System Architect Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating system-architect/analysis.md** that addresses guidance-specification.md discussion points from system architecture perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Architecture Focus**: Technical architecture, scalability, and system design perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Technical Architecture**: Scalable and maintainable system design
|
||||
- **Technology Selection**: Stack evaluation and architectural decisions
|
||||
- **Performance & Scalability**: Capacity planning and optimization strategies
|
||||
- **Integration Patterns**: System communication and data flow design
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Macro-Architecture)**
|
||||
- **System-Level Architecture**: Service boundaries, deployment topology, and system composition
|
||||
- **Cross-Service Communication Patterns**: Choosing between microservices/monolithic, event-driven/request-response, sync/async patterns
|
||||
- **Technology Stack Decisions**: Language, framework, database, and infrastructure choices
|
||||
- **Non-Functional Requirements**: Scalability, performance, availability, disaster recovery, and monitoring strategies
|
||||
- **Integration Planning**: How systems and services connect at the macro level (not specific API contracts)
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **API Contract Details**: Specific endpoint definitions, URL structures, HTTP methods → Defers to **API Designer**
|
||||
- **Data Schemas**: Detailed data model design and entity relationships → Defers to **Data Architect**
|
||||
- **UI/UX Design**: Interface design and user experience → Defers to **UX Expert** and **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO API Designer**: Provides architectural constraints (REST vs GraphQL, sync vs async) that define the API design space
|
||||
- **TO Data Architect**: Provides system-level data flow requirements and integration patterns
|
||||
- **FROM Data Architect**: Receives canonical data model to inform system integration design
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Check existing analysis
|
||||
CHECK: brainstorm_dir/system-architect/analysis.md
|
||||
IF EXISTS:
|
||||
SHOW existing analysis summary
|
||||
ASK: "Analysis exists. Do you want to:"
|
||||
OPTIONS:
|
||||
1. "Update with new insights" → Update existing
|
||||
2. "Replace completely" → Generate new
|
||||
3. "Cancel" → Exit without changes
|
||||
ELSE:
|
||||
CREATE new analysis
|
||||
```
|
||||
|
||||
### Phase 3: Agent Task Generation
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```bash
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Generate system architect analysis addressing topic framework
|
||||
|
||||
## Framework Integration Required
|
||||
**MANDATORY**: Load and address guidance-specification.md discussion points
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
**Output Location**: {session.brainstorm_dir}/system-architect/analysis.md
|
||||
|
||||
## Analysis Requirements
|
||||
1. **Load Topic Framework**: Read guidance-specification.md completely
|
||||
2. **Address Each Discussion Point**: Respond to all 5 framework sections from system architecture perspective
|
||||
3. **Include Framework Reference**: Start analysis.md with @../guidance-specification.md
|
||||
4. **Technical Focus**: Emphasize scalability, architecture patterns, technology decisions
|
||||
5. **Structured Response**: Use framework structure for analysis organization
|
||||
|
||||
## Framework Sections to Address
|
||||
- Core Requirements (from architecture perspective)
|
||||
- Technical Considerations (detailed architectural analysis)
|
||||
- User Experience Factors (technical UX considerations)
|
||||
- Implementation Challenges (architecture risks and solutions)
|
||||
- Success Metrics (technical metrics and monitoring)
|
||||
|
||||
## Output Structure Required
|
||||
```markdown
|
||||
# System Architect Analysis: [Topic]
|
||||
|
||||
**Framework Reference**: @../guidance-specification.md
|
||||
**Role Focus**: System Architecture and Technical Design
|
||||
|
||||
## Core Requirements Analysis
|
||||
[Address framework requirements from architecture perspective]
|
||||
|
||||
## Technical Considerations
|
||||
[Detailed architectural analysis]
|
||||
|
||||
## User Experience Factors
|
||||
[Technical aspects of UX implementation]
|
||||
|
||||
## Implementation Challenges
|
||||
[Architecture risks and mitigation strategies]
|
||||
|
||||
## Success Metrics
|
||||
[Technical metrics and system monitoring]
|
||||
|
||||
## Architecture-Specific Recommendations
|
||||
[Detailed technical recommendations]
|
||||
```",
|
||||
description="Generate system architect framework-based analysis")
|
||||
```
|
||||
|
||||
### Phase 4: Update Mechanism
|
||||
**Analysis Update Process**:
|
||||
```bash
|
||||
# For existing analysis updates
|
||||
IF update_mode = "incremental":
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Update existing system architect analysis
|
||||
|
||||
## Current Analysis Context
|
||||
**Existing Analysis**: @{session.brainstorm_dir}/system-architect/analysis.md
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
|
||||
## Update Requirements
|
||||
1. **Preserve Structure**: Maintain existing analysis structure
|
||||
2. **Add New Insights**: Integrate new technical insights and recommendations
|
||||
3. **Framework Alignment**: Ensure continued alignment with topic framework
|
||||
4. **Technical Updates**: Add new architecture patterns, technology considerations
|
||||
5. **Maintain References**: Keep @../guidance-specification.md reference
|
||||
|
||||
## Update Instructions
|
||||
- Read existing analysis completely
|
||||
- Identify areas for enhancement or new insights
|
||||
- Add technical depth while preserving original structure
|
||||
- Update recommendations with new architectural approaches
|
||||
- Maintain framework discussion point addressing",
|
||||
description="Update system architect analysis incrementally")
|
||||
```
|
||||
|
||||
## Document Structure
|
||||
|
||||
### Output Files
|
||||
```
|
||||
.workflow/active/WFS-[topic]/.brainstorming/
|
||||
├── guidance-specification.md # Input: Framework (if exists)
|
||||
└── system-architect/
|
||||
└── analysis.md # ★ OUTPUT: Framework-based analysis
|
||||
```
|
||||
|
||||
### Analysis Structure
|
||||
**Required Elements**:
|
||||
- **Framework Reference**: @../guidance-specification.md (if framework exists)
|
||||
- **Role Focus**: System Architecture and Technical Design perspective
|
||||
- **5 Framework Sections**: Address each framework discussion point
|
||||
- **Technical Recommendations**: Architecture-specific insights and solutions
|
||||
- How should we design APIs and manage versioning?
|
||||
|
||||
**4. Performance and Scalability**
|
||||
- Where are the current system performance bottlenecks?
|
||||
- How should we handle traffic growth and scaling demands?
|
||||
- What database scaling and optimization strategies are needed?
|
||||
|
||||
## ⚡ **Two-Step Execution Flow**
|
||||
|
||||
### ⚠️ Session Management - FIRST STEP
|
||||
Session detection and selection:
|
||||
```bash
|
||||
# Check for existing sessions
|
||||
existing_sessions=$(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
if [ multiple_sessions ]; then
|
||||
prompt_user_to_select_session()
|
||||
else
|
||||
use_existing_or_create_new()
|
||||
fi
|
||||
```
|
||||
|
||||
### Step 1: Context Gathering Phase
|
||||
**System Architect Perspective Questioning**
|
||||
|
||||
Before agent assignment, gather comprehensive system architecture context:
|
||||
|
||||
#### 📋 Role-Specific Questions
|
||||
1. **Scale & Performance Requirements**
|
||||
- Expected user load and traffic patterns?
|
||||
- Performance requirements (latency, throughput)?
|
||||
- Data volume and growth projections?
|
||||
|
||||
2. **Technical Constraints & Environment**
|
||||
- Existing technology stack and constraints?
|
||||
- Integration requirements with external systems?
|
||||
- Infrastructure and deployment environment?
|
||||
|
||||
3. **Architecture Complexity & Patterns**
|
||||
- Microservices vs monolithic considerations?
|
||||
- Data consistency and transaction requirements?
|
||||
- Event-driven vs request-response patterns?
|
||||
|
||||
4. **Non-Functional Requirements**
|
||||
- High availability and disaster recovery needs?
|
||||
- Security and compliance requirements?
|
||||
- Monitoring and observability expectations?
|
||||
|
||||
#### Context Validation
|
||||
- **Minimum Response**: Each answer must be ≥50 characters
|
||||
- **Re-prompting**: Insufficient detail triggers follow-up questions
|
||||
- **Context Storage**: Save responses to `.brainstorming/system-architect-context.md`
|
||||
|
||||
### Step 2: Agent Assignment with Flow Control
|
||||
**Dedicated Agent Execution**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute dedicated system-architect conceptual analysis for: {topic}
|
||||
|
||||
ASSIGNED_ROLE: system-architect
|
||||
OUTPUT_LOCATION: .brainstorming/system-architect/
|
||||
USER_CONTEXT: {validated_responses_from_context_gathering}
|
||||
|
||||
Flow Control Steps:
|
||||
[
|
||||
{
|
||||
\"step\": \"load_role_template\",
|
||||
\"action\": \"Load system-architect planning template\",
|
||||
\"command\": \"bash($(cat ~/.claude/workflows/cli-templates/planning-roles/system-architect.md))\",
|
||||
\"output_to\": \"role_template\"
|
||||
}
|
||||
]
|
||||
|
||||
Conceptual Analysis Requirements:
|
||||
- Apply system-architect perspective to topic analysis
|
||||
- Focus on architectural patterns, scalability, and integration points
|
||||
- Use loaded role template framework for analysis structure
|
||||
- Generate role-specific deliverables in designated output location
|
||||
- Address all user context from questioning phase
|
||||
|
||||
Deliverables:
|
||||
- analysis.md: Main system architecture analysis
|
||||
- recommendations.md: Architecture recommendations
|
||||
- deliverables/: Architecture-specific outputs as defined in role template
|
||||
|
||||
Embody system-architect role expertise for comprehensive conceptual planning."
|
||||
```
|
||||
|
||||
### Progress Tracking
|
||||
TodoWrite tracking for two-step process:
|
||||
```json
|
||||
[
|
||||
{"content": "Gather system architect context through role-specific questioning", "status": "in_progress", "activeForm": "Gathering context"},
|
||||
{"content": "Validate context responses and save to system-architect-context.md", "status": "pending", "activeForm": "Validating context"},
|
||||
{"content": "Load system-architect planning template via flow control", "status": "pending", "activeForm": "Loading template"},
|
||||
{"content": "Execute dedicated conceptual-planning-agent for system-architect role", "status": "pending", "activeForm": "Executing agent"}
|
||||
]
|
||||
```
|
||||
|
||||
## 📊 **Output Specification**
|
||||
|
||||
### Output Location
|
||||
```
|
||||
.workflow/active/WFS-{topic-slug}/.brainstorming/system-architect/
|
||||
├── analysis.md # Primary architecture analysis
|
||||
├── architecture-design.md # Detailed system design and diagrams
|
||||
├── technology-stack.md # Technology stack recommendations and justifications
|
||||
└── integration-plan.md # System integration and API strategies
|
||||
```
|
||||
|
||||
### Document Templates
|
||||
|
||||
#### analysis.md Structure
|
||||
```markdown
|
||||
# System Architecture Analysis: {Topic}
|
||||
*Generated: {timestamp}*
|
||||
|
||||
## Executive Summary
|
||||
[Key architectural findings and recommendations overview]
|
||||
|
||||
## Current State Assessment
|
||||
### Existing Architecture Overview
|
||||
### Technical Stack Analysis
|
||||
### Performance Bottlenecks
|
||||
### Technical Debt Assessment
|
||||
|
||||
## Requirements Analysis
|
||||
### Functional Requirements
|
||||
### Non-Functional Requirements
|
||||
- Performance: [Response time, throughput requirements]
|
||||
- Scalability: [User growth, data volume expectations]
|
||||
- Availability: [Uptime requirements]
|
||||
- Security: [Security requirements]
|
||||
|
||||
## Proposed Architecture
|
||||
### High-Level Architecture Design
|
||||
### Component Breakdown
|
||||
### Data Flow Diagrams
|
||||
### Technology Stack Recommendations
|
||||
|
||||
## Implementation Strategy
|
||||
### Migration Planning
|
||||
### Risk Mitigation
|
||||
### Performance Optimization
|
||||
### Security Considerations
|
||||
|
||||
## Scalability and Maintenance
|
||||
### Horizontal Scaling Strategy
|
||||
### Monitoring and Observability
|
||||
### Deployment Strategy
|
||||
### Long-term Maintenance Plan
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Status Synchronization
|
||||
Upon completion, update `workflow-session.json`:
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"system_architect": {
|
||||
"status": "completed",
|
||||
"completed_at": "timestamp",
|
||||
"output_directory": ".workflow/active/WFS-{topic}/.brainstorming/system-architect/",
|
||||
"key_insights": ["scalability_bottleneck", "architecture_pattern", "technology_recommendation"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cross-Role Collaboration
|
||||
System architect perspective provides:
|
||||
- **Technical Constraints and Possibilities** → Product Manager
|
||||
- **Architecture Requirements and Limitations** → UI Designer
|
||||
- **Data Architecture Requirements** → Data Architect
|
||||
- **Security Architecture Framework** → Security Expert
|
||||
- **Technical Implementation Framework** → Feature Planner
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Clear architecture diagrams and component designs
|
||||
- [ ] Detailed technology stack evaluation and recommendations
|
||||
- [ ] Scalability and performance analysis with metrics
|
||||
- [ ] System integration and API design specifications
|
||||
- [ ] Comprehensive risk assessment and mitigation strategies
|
||||
|
||||
### Architecture Design Principles
|
||||
- [ ] **Scalability**: System can handle growth in users and data
|
||||
- [ ] **Maintainability**: Clear code structure, easy to modify and extend
|
||||
- [ ] **Reliability**: Built-in fault tolerance and recovery mechanisms
|
||||
- [ ] **Security**: Integrated security controls and protection measures
|
||||
- [ ] **Performance**: Meets response time and throughput requirements
|
||||
|
||||
### Technical Decision Validation
|
||||
- [ ] Technology choices have thorough justification and comparison analysis
|
||||
- [ ] Architectural patterns align with business requirements and constraints
|
||||
- [ ] Integration solutions consider compatibility and maintenance costs
|
||||
- [ ] Deployment strategies are feasible with acceptable risk levels
|
||||
- [ ] Monitoring and operations strategies are comprehensive and actionable
|
||||
|
||||
### Implementation Readiness
|
||||
- [ ] **Technical Feasibility**: All proposed solutions are technically achievable
|
||||
- [ ] **Resource Planning**: Resource requirements clearly defined and realistic
|
||||
- [ ] **Risk Management**: Technical risks identified with mitigation plans
|
||||
- [ ] **Performance Validation**: Architecture can meet performance requirements
|
||||
- [ ] **Evolution Strategy**: Design allows for future growth and changes
|
||||
@@ -1,221 +0,0 @@
|
||||
---
|
||||
name: ui-designer
|
||||
description: Generate or update ui-designer/analysis.md addressing guidance-specification discussion points for UI design perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎨 **UI Designer Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating ui-designer/analysis.md** that addresses guidance-specification.md discussion points from UI/UX design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **UI/UX Focus**: User experience, interface design, and accessibility perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Visual Design**: Color palettes, typography, spacing, and visual hierarchy implementation
|
||||
- **High-Fidelity Mockups**: Polished, pixel-perfect interface designs
|
||||
- **Design System Implementation**: Component libraries, design tokens, and style guides
|
||||
- **Micro-Interactions & Animations**: Transition effects, loading states, and interactive feedback
|
||||
- **Responsive Design**: Layout adaptations for different screen sizes and devices
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Concrete Visual Interface Implementation)**
|
||||
- **Visual Design Language**: Colors, typography, iconography, spacing, and overall aesthetic
|
||||
- **High-Fidelity Mockups**: Polished designs showing exactly how the interface will look
|
||||
- **Design System Components**: Building and documenting reusable UI components (buttons, inputs, cards, etc.)
|
||||
- **Design Tokens**: Defining variables for colors, spacing, typography that can be used in code
|
||||
- **Micro-Interactions**: Hover states, transitions, animations, and interactive feedback details
|
||||
- **Responsive Layouts**: Adapting designs for mobile, tablet, and desktop breakpoints
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **User Research & Personas**: User behavior analysis and needs assessment → Defers to **UX Expert**
|
||||
- **Information Architecture**: Content structure and navigation strategy → Defers to **UX Expert**
|
||||
- **Low-Fidelity Wireframes**: Structural layouts without visual design → Defers to **UX Expert**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **FROM UX Expert**: Receives wireframes, user flows, and information architecture as the foundation for visual design
|
||||
- **TO Frontend Developers**: Provides design specifications, component libraries, and design tokens for implementation
|
||||
- **WITH API Designer**: Coordinates on data presentation and form validation feedback (visual aspects only)
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ui-designer analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ui-designer
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/ui-designer/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ui-designer planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/ui-designer.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from UI/UX perspective
|
||||
**Role Focus**: User experience design, interface optimization, accessibility compliance
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive UI/UX analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with UI/UX design expertise
|
||||
- Provide actionable design recommendations and interface solutions
|
||||
- Include accessibility considerations and WCAG compliance planning
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute ui-designer analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing ui-designer framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured ui-designer analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with ui-designer completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/ui-designer/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# UI Designer Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: UI/UX Design perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with UI/UX expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[UI/UX perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Interface and design system considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Detailed UX analysis and recommendations]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Design implementation and accessibility considerations]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[UX metrics and usability success criteria]
|
||||
|
||||
## UI/UX Specific Recommendations
|
||||
[Role-specific design recommendations and solutions]
|
||||
|
||||
---
|
||||
*Generated by ui-designer analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"ui_designer": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/ui-designer/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: UI/UX insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,221 +0,0 @@
|
||||
---
|
||||
name: ux-expert
|
||||
description: Generate or update ux-expert/analysis.md addressing guidance-specification discussion points for UX perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **UX Expert Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating ux-expert/analysis.md** that addresses guidance-specification.md discussion points from user experience and interface design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **UX Design Focus**: User interface, interaction patterns, and usability optimization
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **User Research**: User personas, behavioral analysis, and needs assessment
|
||||
- **Information Architecture**: Content structure, navigation hierarchy, and mental models
|
||||
- **User Journey Mapping**: User flows, task analysis, and interaction models
|
||||
- **Usability Strategy**: Accessibility planning, cognitive load reduction, and user testing frameworks
|
||||
- **Wireframing**: Low-fidelity layouts and structural prototypes (not visual design)
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Abstract User Experience & Research)**
|
||||
- **User Research & Personas**: Understanding target users, their goals, pain points, and behaviors
|
||||
- **Information Architecture**: Organizing content and defining navigation structures at a conceptual level
|
||||
- **User Journey Mapping**: Defining user flows, task sequences, and interaction models
|
||||
- **Wireframes & Low-Fidelity Prototypes**: Structural layouts showing information hierarchy (boxes and arrows, not colors/fonts)
|
||||
- **Usability Testing Strategy**: Planning user testing, A/B tests, and validation methods
|
||||
- **Accessibility Planning**: WCAG compliance strategy and inclusive design principles
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **Visual Design**: Colors, typography, spacing, visual style → Defers to **UI Designer**
|
||||
- **High-Fidelity Mockups**: Polished, pixel-perfect designs → Defers to **UI Designer**
|
||||
- **Component Implementation**: Design system components, CSS, animations → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO UI Designer**: Provides wireframes, user flows, and information architecture that UI Designer will transform into high-fidelity visual designs
|
||||
- **FROM User Research**: May receive external research data to inform UX decisions
|
||||
- **TO Product Owner**: Provides user insights and validation results to inform feature prioritization
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ux-expert analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ux-expert
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/ux-expert/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ux-expert planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/ux-expert.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from user experience and interface design perspective
|
||||
**Role Focus**: UI design, interaction patterns, usability optimization, design systems
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive UX design analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with UX design expertise
|
||||
- Provide actionable interface design and usability optimization strategies
|
||||
- Include accessibility considerations and interaction pattern recommendations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute ux-expert analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing ux-expert framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured ux-expert analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with ux-expert completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/ux-expert/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# UX Expert Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: User Experience & Interface Design perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with UX design expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[User interface and interaction design requirements perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Design system implementation and technical feasibility considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Usability optimization, accessibility, and user-centered design analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Design implementation challenges and progressive enhancement strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[UX metrics including usability testing, user satisfaction, and design KPIs]
|
||||
|
||||
## UX Expert Specific Recommendations
|
||||
[Role-specific interface design patterns and usability optimization strategies]
|
||||
|
||||
---
|
||||
*Generated by ux-expert analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"ux_expert": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/ux-expert/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: UX design insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -17,6 +17,8 @@ Enhanced evidence-based debugging with **documented exploration process**. Recor
|
||||
|
||||
**Core workflow**: Explore → Document → Log → Analyze → Correct Understanding → Fix → Verify
|
||||
|
||||
**Scope**: Adds temporary debug logging to observe program state; cleans up all instrumentation after resolution. Does NOT execute code injection, security testing, or modify program behavior.
|
||||
|
||||
**Key enhancements over /workflow:debug**:
|
||||
- **understanding.md**: Timeline of exploration and learning
|
||||
- **Gemini-assisted correction**: Validates and corrects hypotheses
|
||||
@@ -44,7 +46,7 @@ Explore Mode:
|
||||
├─ Locate error source in codebase
|
||||
├─ Document initial understanding in understanding.md
|
||||
├─ Generate testable hypotheses with Gemini validation
|
||||
├─ Add NDJSON logging instrumentation
|
||||
├─ Add NDJSON debug logging statements
|
||||
└─ Output: Hypothesis list + await user reproduction
|
||||
|
||||
Analyze Mode:
|
||||
@@ -216,9 +218,9 @@ Save Gemini output to `hypotheses.json`:
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.4: Add NDJSON Instrumentation**
|
||||
**Step 1.4: Add NDJSON Debug Logging**
|
||||
|
||||
For each hypothesis, add logging (same as original debug command).
|
||||
For each hypothesis, add temporary logging statements to observe program state at key execution points. Use NDJSON format for structured log parsing. These are read-only observations that do not modify program behavior.
|
||||
|
||||
**Step 1.5: Update understanding.md**
|
||||
|
||||
@@ -441,7 +443,7 @@ What we learned from this debugging session:
|
||||
|
||||
**Step 3.3: Cleanup**
|
||||
|
||||
Remove debug instrumentation (same as original command).
|
||||
Remove all temporary debug logging statements added during investigation. Verify no instrumentation code remains in production code.
|
||||
|
||||
---
|
||||
|
||||
@@ -647,7 +649,7 @@ Why is config value None during update?
|
||||
|
||||
| Feature | /workflow:debug | /workflow:debug-with-file |
|
||||
|---------|-----------------|---------------------------|
|
||||
| NDJSON logging | ✅ | ✅ |
|
||||
| NDJSON debug logging | ✅ | ✅ |
|
||||
| Hypothesis generation | Manual | Gemini-assisted |
|
||||
| Exploration documentation | ❌ | ✅ understanding.md |
|
||||
| Understanding evolution | ❌ | ✅ Timeline + corrections |
|
||||
|
||||
@@ -1,331 +0,0 @@
|
||||
---
|
||||
name: debug
|
||||
description: Interactive hypothesis-driven debugging with NDJSON logging, iterative until resolved
|
||||
argument-hint: "[-y|--yes] \"bug description or error message\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm all decisions (hypotheses, fixes, iteration), use recommended settings.
|
||||
|
||||
# Workflow Debug Command (/workflow:debug)
|
||||
|
||||
## Overview
|
||||
|
||||
Evidence-based interactive debugging command. Systematically identifies root causes through hypothesis-driven logging and iterative verification.
|
||||
|
||||
**Core workflow**: Explore → Add Logging → Reproduce → Analyze Log → Fix → Verify
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:debug <BUG_DESCRIPTION>
|
||||
|
||||
# Arguments
|
||||
<bug-description> Bug description, error message, or stack trace (required)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Session Detection:
|
||||
├─ Check if debug session exists for this bug
|
||||
├─ EXISTS + debug.log has content → Analyze mode
|
||||
└─ NOT_FOUND or empty log → Explore mode
|
||||
|
||||
Explore Mode:
|
||||
├─ Locate error source in codebase
|
||||
├─ Generate testable hypotheses (dynamic count)
|
||||
├─ Add NDJSON logging instrumentation
|
||||
└─ Output: Hypothesis list + await user reproduction
|
||||
|
||||
Analyze Mode:
|
||||
├─ Parse debug.log, validate each hypothesis
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix root cause
|
||||
├─ Inconclusive → Add more logging, iterate
|
||||
└─ All rejected → Generate new hypotheses
|
||||
|
||||
Fix & Cleanup:
|
||||
├─ Apply fix based on confirmed hypothesis
|
||||
├─ User verifies
|
||||
├─ Remove debug instrumentation
|
||||
└─ If not fixed → Return to Analyze mode
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Mode Detection
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
|
||||
const sessionId = `DBG-${bugSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.debug/${sessionId}`
|
||||
const debugLogPath = `${sessionFolder}/debug.log`
|
||||
|
||||
// Auto-detect mode
|
||||
const sessionExists = fs.existsSync(sessionFolder)
|
||||
const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
|
||||
|
||||
const mode = logHasContent ? 'analyze' : 'explore'
|
||||
|
||||
if (!sessionExists) {
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Explore Mode
|
||||
|
||||
**Step 1.1: Locate Error Source**
|
||||
|
||||
```javascript
|
||||
// Extract keywords from bug description
|
||||
const keywords = extractErrorKeywords(bug_description)
|
||||
// e.g., ['Stack Length', '未找到', 'registered 0']
|
||||
|
||||
// Search codebase for error locations
|
||||
for (const keyword of keywords) {
|
||||
Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
|
||||
}
|
||||
|
||||
// Identify affected files and functions
|
||||
const affectedLocations = [...] // from search results
|
||||
```
|
||||
|
||||
**Step 1.2: Generate Hypotheses (Dynamic)**
|
||||
|
||||
```javascript
|
||||
// Hypothesis categories based on error pattern
|
||||
const HYPOTHESIS_PATTERNS = {
|
||||
"not found|missing|undefined|未找到": "data_mismatch",
|
||||
"0|empty|zero|registered 0": "logic_error",
|
||||
"timeout|connection|sync": "integration_issue",
|
||||
"type|format|parse": "type_mismatch"
|
||||
}
|
||||
|
||||
// Generate hypotheses based on actual issue (NOT fixed count)
|
||||
function generateHypotheses(bugDescription, affectedLocations) {
|
||||
const hypotheses = []
|
||||
|
||||
// Analyze bug and create targeted hypotheses
|
||||
// Each hypothesis has:
|
||||
// - id: H1, H2, ... (dynamic count)
|
||||
// - description: What might be wrong
|
||||
// - testable_condition: What to log
|
||||
// - logging_point: Where to add instrumentation
|
||||
|
||||
return hypotheses // Could be 1, 3, 5, or more
|
||||
}
|
||||
|
||||
const hypotheses = generateHypotheses(bug_description, affectedLocations)
|
||||
```
|
||||
|
||||
**Step 1.3: Add NDJSON Instrumentation**
|
||||
|
||||
For each hypothesis, add logging at the relevant location:
|
||||
|
||||
**Python template**:
|
||||
```python
|
||||
# region debug [H{n}]
|
||||
try:
|
||||
import json, time
|
||||
_dbg = {
|
||||
"sid": "{sessionId}",
|
||||
"hid": "H{n}",
|
||||
"loc": "{file}:{line}",
|
||||
"msg": "{testable_condition}",
|
||||
"data": {
|
||||
# Capture relevant values here
|
||||
},
|
||||
"ts": int(time.time() * 1000)
|
||||
}
|
||||
with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
|
||||
_f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
|
||||
except: pass
|
||||
# endregion
|
||||
```
|
||||
|
||||
**JavaScript/TypeScript template**:
|
||||
```javascript
|
||||
// region debug [H{n}]
|
||||
try {
|
||||
require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
|
||||
sid: "{sessionId}",
|
||||
hid: "H{n}",
|
||||
loc: "{file}:{line}",
|
||||
msg: "{testable_condition}",
|
||||
data: { /* Capture relevant values */ },
|
||||
ts: Date.now()
|
||||
}) + "\n");
|
||||
} catch(_) {}
|
||||
// endregion
|
||||
```
|
||||
|
||||
**Output to user**:
|
||||
```
|
||||
## Hypotheses Generated
|
||||
|
||||
Based on error "{bug_description}", generated {n} hypotheses:
|
||||
|
||||
{hypotheses.map(h => `
|
||||
### ${h.id}: ${h.description}
|
||||
- Logging at: ${h.logging_point}
|
||||
- Testing: ${h.testable_condition}
|
||||
`).join('')}
|
||||
|
||||
**Debug log**: ${debugLogPath}
|
||||
|
||||
**Next**: Run reproduction steps, then come back for analysis.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Analyze Mode
|
||||
|
||||
```javascript
|
||||
// Parse NDJSON log
|
||||
const entries = Read(debugLogPath).split('\n')
|
||||
.filter(l => l.trim())
|
||||
.map(l => JSON.parse(l))
|
||||
|
||||
// Group by hypothesis
|
||||
const byHypothesis = groupBy(entries, 'hid')
|
||||
|
||||
// Validate each hypothesis
|
||||
for (const [hid, logs] of Object.entries(byHypothesis)) {
|
||||
const hypothesis = hypotheses.find(h => h.id === hid)
|
||||
const latestLog = logs[logs.length - 1]
|
||||
|
||||
// Check if evidence confirms or rejects hypothesis
|
||||
const verdict = evaluateEvidence(hypothesis, latestLog.data)
|
||||
// Returns: 'confirmed' | 'rejected' | 'inconclusive'
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
## Evidence Analysis
|
||||
|
||||
Analyzed ${entries.length} log entries.
|
||||
|
||||
${results.map(r => `
|
||||
### ${r.id}: ${r.description}
|
||||
- **Status**: ${r.verdict}
|
||||
- **Evidence**: ${JSON.stringify(r.evidence)}
|
||||
- **Reason**: ${r.reason}
|
||||
`).join('')}
|
||||
|
||||
${confirmedHypothesis ? `
|
||||
## Root Cause Identified
|
||||
|
||||
**${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
|
||||
|
||||
Ready to fix.
|
||||
` : `
|
||||
## Need More Evidence
|
||||
|
||||
Add more logging or refine hypotheses.
|
||||
`}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Fix & Cleanup
|
||||
|
||||
```javascript
|
||||
// Apply fix based on confirmed hypothesis
|
||||
// ... Edit affected files
|
||||
|
||||
// After user verifies fix works:
|
||||
|
||||
// Remove debug instrumentation (search for region markers)
|
||||
const instrumentedFiles = Grep({
|
||||
pattern: "# region debug|// region debug",
|
||||
output_mode: "files_with_matches"
|
||||
})
|
||||
|
||||
for (const file of instrumentedFiles) {
|
||||
// Remove content between region markers
|
||||
removeDebugRegions(file)
|
||||
}
|
||||
|
||||
console.log(`
|
||||
## Debug Complete
|
||||
|
||||
- Root cause: ${confirmedHypothesis.description}
|
||||
- Fix applied to: ${modifiedFiles.join(', ')}
|
||||
- Debug instrumentation removed
|
||||
`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Debug Log Format (NDJSON)
|
||||
|
||||
Each line is a JSON object:
|
||||
|
||||
```json
|
||||
{"sid":"DBG-xxx-2025-12-18","hid":"H1","loc":"file.py:func:42","msg":"Check dict keys","data":{"keys":["a","b"],"target":"c","found":false},"ts":1734567890123}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `sid` | Session ID |
|
||||
| `hid` | Hypothesis ID (H1, H2, ...) |
|
||||
| `loc` | Code location |
|
||||
| `msg` | What's being tested |
|
||||
| `data` | Captured values |
|
||||
| `ts` | Timestamp (ms) |
|
||||
|
||||
## Session Folder
|
||||
|
||||
```
|
||||
.workflow/.debug/DBG-{slug}-{date}/
|
||||
├── debug.log # NDJSON log (main artifact)
|
||||
└── resolution.md # Summary after fix (optional)
|
||||
```
|
||||
|
||||
## Iteration Flow
|
||||
|
||||
```
|
||||
First Call (/workflow:debug "error"):
|
||||
├─ No session exists → Explore mode
|
||||
├─ Extract error keywords, search codebase
|
||||
├─ Generate hypotheses, add logging
|
||||
└─ Await user reproduction
|
||||
|
||||
After Reproduction (/workflow:debug "error"):
|
||||
├─ Session exists + debug.log has content → Analyze mode
|
||||
├─ Parse log, evaluate hypotheses
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix → User verify
|
||||
│ ├─ Fixed → Cleanup → Done
|
||||
│ └─ Not fixed → Add logging → Iterate
|
||||
├─ Inconclusive → Add logging → Iterate
|
||||
└─ All rejected → New hypotheses → Iterate
|
||||
|
||||
Output:
|
||||
└─ .workflow/.debug/DBG-{slug}-{date}/debug.log
|
||||
```
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Empty debug.log | Verify reproduction triggered the code path |
|
||||
| All hypotheses rejected | Generate new hypotheses with broader scope |
|
||||
| Fix doesn't work | Iterate with more granular logging |
|
||||
| >5 iterations | Escalate to `/workflow:lite-fix` with evidence |
|
||||
File diff suppressed because it is too large
Load Diff
@@ -477,7 +477,7 @@ Task(subagent_type="{meta.agent}",
|
||||
- TODO List: {session.todo_list_path}
|
||||
- Summaries: {session.summaries_dir}
|
||||
|
||||
**Execution**: Read task JSON → Parse flow_control → Execute implementation_approach → Update TODO_LIST.md → Generate summary",
|
||||
**Execution**: Read task JSON → Execute pre_analysis → Check execution_config.method → (CLI: handoff to CLI tool | Agent: direct implementation) → Update TODO_LIST.md → Generate summary",
|
||||
description="Implement: {task.id}")
|
||||
```
|
||||
|
||||
@@ -486,9 +486,11 @@ Task(subagent_type="{meta.agent}",
|
||||
- `[FLOW_CONTROL]`: Triggers flow_control.pre_analysis execution
|
||||
|
||||
**Why Path-Based**: Agent (code-developer.md) autonomously:
|
||||
- Reads and parses task JSON (requirements, acceptance, flow_control)
|
||||
- Loads tech stack guidelines based on detected language
|
||||
- Executes pre_analysis steps and implementation_approach
|
||||
- Reads and parses task JSON (requirements, acceptance, flow_control, execution_config)
|
||||
- Executes pre_analysis steps (Phase 1: context gathering)
|
||||
- Checks execution_config.method (Phase 2: determine mode)
|
||||
- CLI mode: Builds handoff prompt and executes via ccw cli with resume strategy
|
||||
- Agent mode: Directly implements using modification_points and logic_flow
|
||||
- Generates structured summary with integration points
|
||||
|
||||
Embedding task content in prompt creates duplication and conflicts with agent's parsing logic.
|
||||
|
||||
@@ -72,8 +72,8 @@ Phase 2: Clarification (optional, multi-round)
|
||||
|
||||
Phase 3: Planning (NO CODE EXECUTION - planning only)
|
||||
└─ Decision (based on Phase 1 complexity):
|
||||
├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json → MUST proceed to Phase 4
|
||||
└─ Medium/High → cli-lite-planning-agent → plan.json → MUST proceed to Phase 4
|
||||
├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json
|
||||
└─ Medium/High → cli-lite-planning-agent → plan.json (agent internally executes quality check)
|
||||
|
||||
Phase 4: Confirmation & Selection
|
||||
├─ Display plan summary (tasks, complexity, estimated time)
|
||||
|
||||
807
.claude/commands/workflow/merge-plans-with-file.md
Normal file
807
.claude/commands/workflow/merge-plans-with-file.md
Normal file
@@ -0,0 +1,807 @@
|
||||
---
|
||||
name: merge-plans-with-file
|
||||
description: Merge multiple planning/brainstorm/analysis outputs, resolve conflicts, and synthesize unified plan. Designed for multi-team input aggregation and final plan crystallization
|
||||
argument-hint: "[-y|--yes] [-r|--rule consensus|priority|hierarchy] \"plan or topic name\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-resolve conflicts using specified rule (consensus/priority/hierarchy), minimal user prompts.
|
||||
|
||||
# Workflow Merge-Plans-With-File Command (/workflow:merge-plans-with-file)
|
||||
|
||||
## Overview
|
||||
|
||||
Plan aggregation and conflict resolution workflow. Takes multiple planning artifacts (brainstorm conclusions, analysis recommendations, quick-plans, implementation plans) and synthesizes them into a unified, conflict-resolved execution plan.
|
||||
|
||||
**Core workflow**: Load Sources → Parse Plans → Conflict Analysis → Arbitration → Unified Plan
|
||||
|
||||
**Key features**:
|
||||
- **Multi-Source Support**: Brainstorm, analysis, quick-plan, IMPL_PLAN, task JSONs
|
||||
- **Parallel Conflict Detection**: Identify all contradictions across input plans
|
||||
- **Conflict Resolution**: Consensus, priority-based, or hierarchical resolution modes
|
||||
- **Unified Synthesis**: Single authoritative plan from multiple perspectives
|
||||
- **Decision Tracking**: Full audit trail of conflicts and resolutions
|
||||
- **Resumable**: Save intermediate states, refine resolutions
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:merge-plans-with-file [FLAGS] <PLAN_NAME_OR_PATTERN>
|
||||
|
||||
# Flags
|
||||
-y, --yes Auto-resolve conflicts using rule, skip confirmations
|
||||
-r, --rule <rule> Conflict resolution rule: consensus (default) | priority | hierarchy
|
||||
-o, --output <path> Output directory (default: .workflow/.merged/{name})
|
||||
|
||||
# Arguments
|
||||
<plan-name-or-pattern> Plan name or glob pattern to identify input files/sessions
|
||||
Examples: "auth-module", "*.analysis-*.json", "PLAN-*"
|
||||
|
||||
# Examples
|
||||
/workflow:merge-plans-with-file "authentication" # Auto-detect all auth-related plans
|
||||
/workflow:merge-plans-with-file -y -r priority "payment-system" # Auto-resolve with priority rule
|
||||
/workflow:merge-plans-with-file -r hierarchy "feature-complete" # Use hierarchy rule (requires user ranking)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Discovery & Loading:
|
||||
├─ Search for planning artifacts matching pattern
|
||||
├─ Load all synthesis.json, conclusions.json, IMPL_PLAN.md
|
||||
├─ Parse each into normalized task/plan structure
|
||||
└─ Validate data completeness
|
||||
|
||||
Session Initialization:
|
||||
├─ Create .workflow/.merged/{sessionId}/
|
||||
├─ Initialize merge.md with plan summary
|
||||
├─ Index all source plans
|
||||
└─ Extract planning metadata and constraints
|
||||
|
||||
Phase 1: Plan Normalization
|
||||
├─ Convert all formats to common task representation
|
||||
├─ Extract tasks, dependencies, effort, risks
|
||||
├─ Identify plan scope and boundaries
|
||||
├─ Validate no duplicate tasks
|
||||
└─ Aggregate recommendations from each plan
|
||||
|
||||
Phase 2: Conflict Detection (Parallel)
|
||||
├─ Architecture conflicts: different design approaches
|
||||
├─ Task conflicts: overlapping responsibilities or different priorities
|
||||
├─ Effort conflicts: vastly different estimates
|
||||
├─ Risk assessment conflicts: different risk levels
|
||||
├─ Scope conflicts: different feature inclusions
|
||||
└─ Generate conflict matrix with severity levels
|
||||
|
||||
Phase 3: Consensus Building / Arbitration
|
||||
├─ For each conflict, analyze source rationale
|
||||
├─ Apply resolution rule (consensus/priority/hierarchy)
|
||||
├─ Escalate unresolvable conflicts to user (unless --yes)
|
||||
├─ Document decision rationale
|
||||
└─ Generate resolutions.json
|
||||
|
||||
Phase 4: Plan Synthesis
|
||||
├─ Merge task lists (remove duplicates, combine insights)
|
||||
├─ Integrate dependencies from all sources
|
||||
├─ Consolidate effort and risk estimates
|
||||
├─ Generate unified execution sequence
|
||||
├─ Create final unified plan
|
||||
└─ Output ready for execution
|
||||
|
||||
Output:
|
||||
├─ .workflow/.merged/{sessionId}/merge.md (merge process & decisions)
|
||||
├─ .workflow/.merged/{sessionId}/source-index.json (input sources)
|
||||
├─ .workflow/.merged/{sessionId}/conflicts.json (conflict matrix)
|
||||
├─ .workflow/.merged/{sessionId}/resolutions.json (how conflicts were resolved)
|
||||
├─ .workflow/.merged/{sessionId}/unified-plan.json (final merged plan)
|
||||
└─ .workflow/.merged/{sessionId}/unified-plan.md (execution-ready markdown)
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Plan Discovery & Loading
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
// Parse arguments
|
||||
const planPattern = "$PLAN_NAME_OR_PATTERN"
|
||||
const resolutionRule = $ARGUMENTS.match(/--rule\s+(\w+)/)?.[1] || 'consensus'
|
||||
const isAutoMode = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
// Generate session ID
|
||||
const mergeSlug = planPattern.toLowerCase()
|
||||
.replace(/[*?]/g, '-')
|
||||
.replace(/[^a-z0-9\u4e00-\u9fa5-]+/g, '-')
|
||||
.substring(0, 30)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
const sessionId = `MERGE-${mergeSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.merged/${sessionId}`
|
||||
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
|
||||
// Discover all relevant planning artifacts
|
||||
const discoveryPaths = [
|
||||
`.workflow/.brainstorm/*/${planPattern}*/synthesis.json`,
|
||||
`.workflow/.analysis/*/${planPattern}*/conclusions.json`,
|
||||
`.workflow/.planning/*/${planPattern}*/synthesis.json`,
|
||||
`.workflow/.plan/${planPattern}*IMPL_PLAN.md`,
|
||||
`.workflow/*/${planPattern}*.json`
|
||||
]
|
||||
|
||||
const sourcePlans = []
|
||||
|
||||
for (const pattern of discoveryPaths) {
|
||||
const matches = glob(pattern)
|
||||
for (const path of matches) {
|
||||
try {
|
||||
const content = Read(path)
|
||||
const plan = parsePlanFile(path, content)
|
||||
if (plan && plan.tasks?.length > 0) {
|
||||
sourcePlans.push({
|
||||
source_path: path,
|
||||
source_type: identifySourceType(path),
|
||||
plan: plan,
|
||||
loaded_at: getUtc8ISOString()
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`Failed to load plan from ${path}: ${e.message}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sourcePlans.length === 0) {
|
||||
console.error(`
|
||||
## Error: No Plans Found
|
||||
|
||||
Pattern: ${planPattern}
|
||||
Searched locations:
|
||||
${discoveryPaths.join('\n')}
|
||||
|
||||
Available plans in .workflow/:
|
||||
`)
|
||||
bash(`find .workflow -name "*.json" -o -name "*PLAN.md" | head -20`)
|
||||
return { status: 'error', message: 'No plans found' }
|
||||
}
|
||||
|
||||
console.log(`
|
||||
## Plans Discovered
|
||||
|
||||
Total: ${sourcePlans.length}
|
||||
${sourcePlans.map(sp => `- ${sp.source_type}: ${sp.source_path}`).join('\n')}
|
||||
`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Plan Normalization
|
||||
|
||||
```javascript
|
||||
// Normalize all plans to common format
|
||||
const normalizedPlans = sourcePlans.map((sourcePlan, idx) => {
|
||||
const plan = sourcePlan.plan
|
||||
const tasks = plan.tasks || []
|
||||
|
||||
return {
|
||||
index: idx,
|
||||
source: sourcePlan.source_path,
|
||||
source_type: sourcePlan.source_type,
|
||||
|
||||
metadata: {
|
||||
title: plan.title || `Plan ${idx + 1}`,
|
||||
topic: plan.topic || plan.planning_topic || 'unknown',
|
||||
timestamp: plan.completed || plan.timestamp || sourcePlan.loaded_at,
|
||||
source_ideas: plan.top_ideas?.length || 0,
|
||||
complexity: plan.complexity_level || 'unknown'
|
||||
},
|
||||
|
||||
// Normalized tasks
|
||||
tasks: tasks.map(task => ({
|
||||
id: task.id || `T${idx}-${task.title?.substring(0, 20)}`,
|
||||
title: task.title || task.content,
|
||||
description: task.description || '',
|
||||
type: task.type || inferType(task),
|
||||
priority: task.priority || 'normal',
|
||||
|
||||
// Effort estimation
|
||||
effort: {
|
||||
estimated: task.estimated_duration || task.effort_estimate || 'unknown',
|
||||
from_plan: idx
|
||||
},
|
||||
|
||||
// Risk assessment
|
||||
risk: {
|
||||
level: task.risk_level || 'medium',
|
||||
from_plan: idx
|
||||
},
|
||||
|
||||
// Dependencies
|
||||
dependencies: task.dependencies || [],
|
||||
|
||||
// Source tracking
|
||||
source_plan_index: idx,
|
||||
original_id: task.id,
|
||||
|
||||
// Quality tracking
|
||||
success_criteria: task.success_criteria || [],
|
||||
challenges: task.challenges || []
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
// Save source index
|
||||
const sourceIndex = {
|
||||
session_id: sessionId,
|
||||
merge_timestamp: getUtc8ISOString(),
|
||||
pattern: planPattern,
|
||||
total_source_plans: sourcePlans.length,
|
||||
|
||||
sources: normalizedPlans.map(p => ({
|
||||
index: p.index,
|
||||
source_path: p.source,
|
||||
source_type: p.source_type,
|
||||
topic: p.metadata.topic,
|
||||
task_count: p.tasks.length
|
||||
}))
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/source-index.json`, JSON.stringify(sourceIndex, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Conflict Detection
|
||||
|
||||
```javascript
|
||||
// Detect conflicts across plans
|
||||
const conflictDetector = {
|
||||
// Architecture conflicts
|
||||
architectureConflicts: [],
|
||||
|
||||
// Task conflicts (duplicates, different scope)
|
||||
taskConflicts: [],
|
||||
|
||||
// Effort conflicts
|
||||
effortConflicts: [],
|
||||
|
||||
// Risk assessment conflicts
|
||||
riskConflicts: [],
|
||||
|
||||
// Scope conflicts
|
||||
scopeConflicts: [],
|
||||
|
||||
// Priority conflicts
|
||||
priorityConflicts: []
|
||||
}
|
||||
|
||||
// Algorithm 1: Detect similar tasks across plans
|
||||
const allTasks = normalizedPlans.flatMap(p => p.tasks)
|
||||
const taskGroups = groupSimilarTasks(allTasks)
|
||||
|
||||
for (const group of taskGroups) {
|
||||
if (group.tasks.length > 1) {
|
||||
// Same task appears in multiple plans
|
||||
const efforts = group.tasks.map(t => t.effort.estimated)
|
||||
const effortVariance = calculateVariance(efforts)
|
||||
|
||||
if (effortVariance > 0.5) {
|
||||
// Significant difference in effort estimates
|
||||
conflictDetector.effortConflicts.push({
|
||||
task_group: group.title,
|
||||
conflicting_tasks: group.tasks.map((t, i) => ({
|
||||
id: t.id,
|
||||
from_plan: t.source_plan_index,
|
||||
effort: t.effort.estimated
|
||||
})),
|
||||
variance: effortVariance,
|
||||
severity: 'high'
|
||||
})
|
||||
}
|
||||
|
||||
// Check for scope differences
|
||||
const scopeDifferences = analyzeScopeDifferences(group.tasks)
|
||||
if (scopeDifferences.length > 0) {
|
||||
conflictDetector.taskConflicts.push({
|
||||
task_group: group.title,
|
||||
scope_differences: scopeDifferences,
|
||||
severity: 'medium'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Algorithm 2: Architecture conflicts
|
||||
const architectures = normalizedPlans.map(p => p.metadata.complexity)
|
||||
if (new Set(architectures).size > 1) {
|
||||
conflictDetector.architectureConflicts.push({
|
||||
different_approaches: true,
|
||||
complexity_levels: architectures.map((a, i) => ({
|
||||
plan: i,
|
||||
complexity: a
|
||||
})),
|
||||
severity: 'high'
|
||||
})
|
||||
}
|
||||
|
||||
// Algorithm 3: Risk assessment conflicts
|
||||
const riskLevels = allTasks.map(t => ({ task: t.id, risk: t.risk.level }))
|
||||
const taskRisks = {}
|
||||
for (const tr of riskLevels) {
|
||||
if (!taskRisks[tr.task]) taskRisks[tr.task] = []
|
||||
taskRisks[tr.task].push(tr.risk)
|
||||
}
|
||||
|
||||
for (const [task, risks] of Object.entries(taskRisks)) {
|
||||
if (new Set(risks).size > 1) {
|
||||
conflictDetector.riskConflicts.push({
|
||||
task: task,
|
||||
conflicting_risk_levels: risks,
|
||||
severity: 'medium'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Save conflicts
|
||||
Write(`${sessionFolder}/conflicts.json`, JSON.stringify(conflictDetector, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Conflict Resolution
|
||||
|
||||
```javascript
|
||||
// Resolve conflicts based on selected rule
|
||||
const resolutions = {
|
||||
resolution_rule: resolutionRule,
|
||||
timestamp: getUtc8ISOString(),
|
||||
|
||||
effort_resolutions: [],
|
||||
architecture_resolutions: [],
|
||||
risk_resolutions: [],
|
||||
scope_resolutions: [],
|
||||
priority_resolutions: []
|
||||
}
|
||||
|
||||
// Resolution Strategy 1: Consensus
|
||||
if (resolutionRule === 'consensus') {
|
||||
for (const conflict of conflictDetector.effortConflicts) {
|
||||
// Use median or average
|
||||
const efforts = conflict.conflicting_tasks.map(t => parseEffort(t.effort))
|
||||
const resolved_effort = calculateMedian(efforts)
|
||||
|
||||
resolutions.effort_resolutions.push({
|
||||
conflict: conflict.task_group,
|
||||
original_estimates: efforts,
|
||||
resolved_estimate: resolved_effort,
|
||||
method: 'consensus-median',
|
||||
rationale: 'Used median of all estimates'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Resolution Strategy 2: Priority-Based
|
||||
else if (resolutionRule === 'priority') {
|
||||
// Use the plan from highest priority source (first or most recent)
|
||||
for (const conflict of conflictDetector.effortConflicts) {
|
||||
const highestPriority = conflict.conflicting_tasks[0] // First plan has priority
|
||||
|
||||
resolutions.effort_resolutions.push({
|
||||
conflict: conflict.task_group,
|
||||
conflicting_estimates: conflict.conflicting_tasks.map(t => t.effort),
|
||||
resolved_estimate: highestPriority.effort,
|
||||
selected_from_plan: highestPriority.from_plan,
|
||||
method: 'priority-based',
|
||||
rationale: `Selected estimate from plan ${highestPriority.from_plan} (highest priority)`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Resolution Strategy 3: Hierarchy (requires user ranking)
|
||||
else if (resolutionRule === 'hierarchy') {
|
||||
if (!isAutoMode) {
|
||||
// Ask user to rank plan importance
|
||||
const planRanking = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "请按重要性排序这些规划(从最重要到最不重要):",
|
||||
header: "Plan Ranking",
|
||||
multiSelect: false,
|
||||
options: normalizedPlans.slice(0, 5).map(p => ({
|
||||
label: `Plan ${p.index}: ${p.metadata.title.substring(0, 40)}`,
|
||||
description: `${p.tasks.length} tasks, complexity: ${p.metadata.complexity}`
|
||||
}))
|
||||
}]
|
||||
})
|
||||
|
||||
// Apply hierarchy
|
||||
const hierarchy = extractHierarchy(planRanking)
|
||||
for (const conflict of conflictDetector.effortConflicts) {
|
||||
const topPriorityTask = conflict.conflicting_tasks
|
||||
.sort((a, b) => hierarchy[a.from_plan] - hierarchy[b.from_plan])[0]
|
||||
|
||||
resolutions.effort_resolutions.push({
|
||||
conflict: conflict.task_group,
|
||||
resolved_estimate: topPriorityTask.effort,
|
||||
selected_from_plan: topPriorityTask.from_plan,
|
||||
method: 'hierarchy-based',
|
||||
rationale: `Selected from highest-ranked plan`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/resolutions.json`, JSON.stringify(resolutions, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Plan Synthesis
|
||||
|
||||
```javascript
|
||||
// Merge all tasks into unified plan
|
||||
const unifiedTasks = []
|
||||
const processedTaskIds = new Set()
|
||||
|
||||
for (const task of allTasks) {
|
||||
const taskKey = generateTaskKey(task)
|
||||
|
||||
if (processedTaskIds.has(taskKey)) {
|
||||
// Task already added, skip
|
||||
continue
|
||||
}
|
||||
|
||||
processedTaskIds.add(taskKey)
|
||||
|
||||
// Apply resolution if this task has conflicts
|
||||
let resolvedTask = { ...task }
|
||||
|
||||
const effortResolution = resolutions.effort_resolutions
|
||||
.find(r => r.conflict === taskKey)
|
||||
if (effortResolution) {
|
||||
resolvedTask.effort.estimated = effortResolution.resolved_estimate
|
||||
resolvedTask.effort.resolution_method = effortResolution.method
|
||||
}
|
||||
|
||||
unifiedTasks.push({
|
||||
id: taskKey,
|
||||
title: task.title,
|
||||
description: task.description,
|
||||
type: task.type,
|
||||
priority: task.priority,
|
||||
|
||||
effort: resolvedTask.effort,
|
||||
risk: task.risk,
|
||||
dependencies: task.dependencies,
|
||||
|
||||
success_criteria: [...new Set([
|
||||
...task.success_criteria,
|
||||
...findRelatedTasks(task, allTasks)
|
||||
.flatMap(t => t.success_criteria)
|
||||
])],
|
||||
|
||||
challenges: [...new Set([
|
||||
...task.challenges,
|
||||
...findRelatedTasks(task, allTasks)
|
||||
.flatMap(t => t.challenges)
|
||||
])],
|
||||
|
||||
source_plans: [
|
||||
...new Set(allTasks
|
||||
.filter(t => generateTaskKey(t) === taskKey)
|
||||
.map(t => t.source_plan_index))
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Generate execution sequence
|
||||
const executionSequence = topologicalSort(unifiedTasks)
|
||||
const criticalPath = identifyCriticalPath(unifiedTasks, executionSequence)
|
||||
|
||||
// Final unified plan
|
||||
const unifiedPlan = {
|
||||
session_id: sessionId,
|
||||
merge_timestamp: getUtc8ISOString(),
|
||||
|
||||
summary: {
|
||||
total_source_plans: normalizedPlans.length,
|
||||
original_tasks_total: allTasks.length,
|
||||
merged_tasks: unifiedTasks.length,
|
||||
conflicts_resolved: Object.values(conflictDetector).flat().length,
|
||||
resolution_rule: resolutionRule
|
||||
},
|
||||
|
||||
merged_metadata: {
|
||||
topics: [...new Set(normalizedPlans.map(p => p.metadata.topic))],
|
||||
average_complexity: calculateAverage(normalizedPlans.map(p => parseComplexity(p.metadata.complexity))),
|
||||
combined_scope: estimateScope(unifiedTasks)
|
||||
},
|
||||
|
||||
tasks: unifiedTasks,
|
||||
|
||||
execution_sequence: executionSequence,
|
||||
critical_path: criticalPath,
|
||||
|
||||
risks: aggregateRisks(unifiedTasks),
|
||||
success_criteria: aggregateSuccessCriteria(unifiedTasks),
|
||||
|
||||
audit_trail: {
|
||||
source_plans: normalizedPlans.length,
|
||||
conflicts_detected: Object.values(conflictDetector).flat().length,
|
||||
conflicts_resolved: Object.values(resolutions).flat().length,
|
||||
resolution_method: resolutionRule
|
||||
}
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/unified-plan.json`, JSON.stringify(unifiedPlan, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 6: Generate Execution Plan
|
||||
|
||||
```markdown
|
||||
# Merged Planning Session
|
||||
|
||||
**Session ID**: ${sessionId}
|
||||
**Pattern**: ${planPattern}
|
||||
**Created**: ${getUtc8ISOString()}
|
||||
|
||||
---
|
||||
|
||||
## Merge Summary
|
||||
|
||||
**Source Plans**: ${unifiedPlan.summary.total_source_plans}
|
||||
**Original Tasks**: ${unifiedPlan.summary.original_tasks_total}
|
||||
**Merged Tasks**: ${unifiedPlan.summary.merged_tasks}
|
||||
**Tasks Deduplicated**: ${unifiedPlan.summary.original_tasks_total - unifiedPlan.summary.merged_tasks}
|
||||
**Conflicts Resolved**: ${unifiedPlan.summary.conflicts_resolved}
|
||||
|
||||
**Resolution Method**: ${unifiedPlan.summary.resolution_rule}
|
||||
|
||||
---
|
||||
|
||||
## Merged Plan Overview
|
||||
|
||||
**Topics**: ${unifiedPlan.merged_metadata.topics.join(', ')}
|
||||
**Combined Complexity**: ${unifiedPlan.merged_metadata.average_complexity}
|
||||
**Total Scope**: ${unifiedPlan.merged_metadata.combined_scope}
|
||||
|
||||
---
|
||||
|
||||
## Unified Task List
|
||||
|
||||
${unifiedPlan.tasks.map((task, i) => `
|
||||
${i+1}. **${task.id}: ${task.title}**
|
||||
- Type: ${task.type}
|
||||
- Effort: ${task.effort.estimated}
|
||||
- Risk: ${task.risk.level}
|
||||
- Source Plans: ${task.source_plans.join(', ')}
|
||||
- ${task.description}
|
||||
`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Execution Sequence
|
||||
|
||||
**Critical Path**: ${unifiedPlan.critical_path.join(' → ')}
|
||||
|
||||
**Execution Order**:
|
||||
${unifiedPlan.execution_sequence.map((id, i) => `${i+1}. ${id}`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Conflict Resolution Report
|
||||
|
||||
**Total Conflicts**: ${unifiedPlan.summary.conflicts_resolved}
|
||||
|
||||
**Resolved Conflicts**:
|
||||
${Object.entries(resolutions).flatMap(([key, items]) =>
|
||||
items.slice(0, 3).map((item, i) => `
|
||||
- ${key.replace('_', ' ')}: ${item.rationale || item.method}
|
||||
`)
|
||||
).join('\n')}
|
||||
|
||||
**Full Report**: See \`conflicts.json\` and \`resolutions.json\`
|
||||
|
||||
---
|
||||
|
||||
## Risks & Considerations
|
||||
|
||||
**Aggregated Risks**:
|
||||
${unifiedPlan.risks.slice(0, 5).map(r => `- **${r.title}**: ${r.mitigation}`).join('\n')}
|
||||
|
||||
**Combined Success Criteria**:
|
||||
${unifiedPlan.success_criteria.slice(0, 5).map(c => `- ${c}`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
### Option 1: Direct Execution
|
||||
Execute merged plan with unified-execute-with-file:
|
||||
\`\`\`
|
||||
/workflow:unified-execute-with-file -p ${sessionFolder}/unified-plan.json
|
||||
\`\`\`
|
||||
|
||||
### Option 2: Detailed Planning
|
||||
Create detailed IMPL_PLAN from merged plan:
|
||||
\`\`\`
|
||||
/workflow:plan "Based on merged plan from $(echo ${planPattern})"
|
||||
\`\`\`
|
||||
|
||||
### Option 3: Review Conflicts
|
||||
Review detailed conflict analysis:
|
||||
\`\`\`
|
||||
cat ${sessionFolder}/resolutions.json
|
||||
\`\`\`
|
||||
|
||||
---
|
||||
|
||||
## Artifacts
|
||||
|
||||
- **source-index.json** - All input plans and sources
|
||||
- **conflicts.json** - Conflict detection results
|
||||
- **resolutions.json** - How each conflict was resolved
|
||||
- **unified-plan.json** - Merged plan data structure (for execution)
|
||||
- **unified-plan.md** - This document (human-readable)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.merged/{sessionId}/
|
||||
├── merge.md # Merge process and decisions
|
||||
├── source-index.json # All input plan sources
|
||||
├── conflicts.json # Detected conflicts
|
||||
├── resolutions.json # Conflict resolutions applied
|
||||
├── unified-plan.json # Merged plan (machine-parseable, for execution)
|
||||
└── unified-plan.md # Execution-ready plan (human-readable)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Resolution Rules
|
||||
|
||||
### Rule 1: Consensus (default)
|
||||
- Use median or average of conflicting estimates
|
||||
- Good for: Multiple similar perspectives
|
||||
- Tradeoff: May miss important minority viewpoints
|
||||
|
||||
### Rule 2: Priority-Based
|
||||
- First plan has highest priority, subsequent plans are fallback
|
||||
- Good for: Clear ranking of plan sources
|
||||
- Tradeoff: Discards valuable alternative perspectives
|
||||
|
||||
### Rule 3: Hierarchy
|
||||
- User explicitly ranks importance of each plan
|
||||
- Good for: Mixed-source plans (engineering + product + leadership)
|
||||
- Tradeoff: Requires user input
|
||||
|
||||
---
|
||||
|
||||
## Input Format Support
|
||||
|
||||
| Source Type | Detection | Parsing | Notes |
|
||||
|-------------|-----------|---------|-------|
|
||||
| **Brainstorm** | `.brainstorm/*/synthesis.json` | Top ideas → tasks | Ideas converted to work items |
|
||||
| **Analysis** | `.analysis/*/conclusions.json` | Recommendations → tasks | Recommendations prioritized |
|
||||
| **Quick-Plan** | `.planning/*/synthesis.json` | Direct task list | Already normalized |
|
||||
| **IMPL_PLAN** | `*IMPL_PLAN.md` | Markdown → tasks | Parsed from markdown structure |
|
||||
| **Task JSON** | `.json` with `tasks` key | Direct mapping | Requires standard schema |
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| No plans found | Suggest search terms, list available plans |
|
||||
| Incompatible formats | Skip unsupported format, continue with others |
|
||||
| Circular dependencies | Alert user, suggest manual review |
|
||||
| Unresolvable conflicts | Require user decision (unless --yes + conflict rule) |
|
||||
| Contradictory recommendations | Document both options for user consideration |
|
||||
|
||||
---
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Pattern 1: Merge Multiple Brainstorms
|
||||
|
||||
```bash
|
||||
/workflow:merge-plans-with-file "authentication" -y -r consensus
|
||||
# → Finds all brainstorm sessions with "auth"
|
||||
# → Merges top ideas into unified task list
|
||||
# → Uses consensus method for conflicts
|
||||
```
|
||||
|
||||
### Pattern 2: Synthesize Team Input
|
||||
|
||||
```bash
|
||||
/workflow:merge-plans-with-file "payment-integration" -r hierarchy
|
||||
# → Loads plans from different team members
|
||||
# → Asks for ranking by importance
|
||||
# → Applies hierarchy-based conflict resolution
|
||||
```
|
||||
|
||||
### Pattern 3: Bridge Planning Phases
|
||||
|
||||
```bash
|
||||
/workflow:merge-plans-with-file "user-auth" -f analysis
|
||||
# → Takes analysis conclusions
|
||||
# → Merges with existing quick-plans
|
||||
# → Produces execution-ready plan
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Advanced: Custom Conflict Resolution
|
||||
|
||||
For complex conflict scenarios, create custom resolution script:
|
||||
|
||||
```
|
||||
.workflow/.merged/{sessionId}/
|
||||
└── custom-resolutions.js (optional)
|
||||
- Define custom conflict resolution logic
|
||||
- Applied after automatic resolution
|
||||
- Override specific decisions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Before merging**:
|
||||
- Ensure all source plans have same quality level
|
||||
- Verify plans address same scope/topic
|
||||
- Document any special considerations
|
||||
|
||||
2. **During merging**:
|
||||
- Review conflict matrix (conflicts.json)
|
||||
- Understand resolution rationale (resolutions.json)
|
||||
- Challenge assumptions if results seem odd
|
||||
|
||||
3. **After merging**:
|
||||
- Validate unified plan makes sense
|
||||
- Review critical path
|
||||
- Ensure no important details lost
|
||||
- Execute or iterate if needed
|
||||
|
||||
---
|
||||
|
||||
## Integration with Other Workflows
|
||||
|
||||
```
|
||||
Multiple Brainstorms / Analyses
|
||||
│
|
||||
├─ brainstorm-with-file (session 1)
|
||||
├─ brainstorm-with-file (session 2)
|
||||
├─ analyze-with-file (session 3)
|
||||
│
|
||||
▼
|
||||
merge-plans-with-file ◄──── This workflow
|
||||
│
|
||||
▼
|
||||
unified-plan.json
|
||||
│
|
||||
├─ /workflow:unified-execute-with-file (direct execution)
|
||||
├─ /workflow:plan (detailed planning)
|
||||
└─ /workflow:quick-plan-with-file (refinement)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Comparison: When to Use Which Merge Rule
|
||||
|
||||
| Rule | Use When | Pros | Cons |
|
||||
|------|----------|------|------|
|
||||
| **Consensus** | Similar-quality inputs | Fair, balanced | May miss extremes |
|
||||
| **Priority** | Clear hierarchy | Simple, predictable | May bias to first input |
|
||||
| **Hierarchy** | Mixed stakeholders | Respects importance | Requires user ranking |
|
||||
|
||||
---
|
||||
|
||||
**Ready to execute**: Run `/workflow:merge-plans-with-file` to start merging plans!
|
||||
@@ -150,378 +150,213 @@ Create internal representations (do not include raw artifacts in output):
|
||||
- Task-to-task dependencies (depends_on, blocks)
|
||||
- Requirement-level dependencies (from synthesis)
|
||||
|
||||
### 4. Detection Passes (Token-Efficient Analysis)
|
||||
### 4. Detection Passes (Agent-Driven Multi-Dimensional Analysis)
|
||||
|
||||
**Token Budget Strategy**:
|
||||
- **Total Limit**: 50 findings maximum (aggregate remainder in overflow summary)
|
||||
- **Priority Allocation**: CRITICAL (unlimited) → HIGH (15) → MEDIUM (20) → LOW (15)
|
||||
- **Early Exit**: If CRITICAL findings > 0 in User Intent/Requirements Coverage, skip LOW/MEDIUM priority checks
|
||||
**Execution Strategy**:
|
||||
- Single `cli-explore-agent` invocation
|
||||
- Agent executes multiple CLI analyses internally (different dimensions: A-H)
|
||||
- Token Budget: 50 findings maximum (aggregate remainder in overflow summary)
|
||||
- Priority Allocation: CRITICAL (unlimited) → HIGH (15) → MEDIUM (20) → LOW (15)
|
||||
- Early Exit: If CRITICAL findings > 0 in User Intent/Requirements Coverage, skip LOW/MEDIUM checks
|
||||
|
||||
**Execution Order** (Process in sequence; skip if token budget exhausted):
|
||||
**Execution Order** (Agent orchestrates internally):
|
||||
|
||||
1. **Tier 1 (CRITICAL Path)**: A, B, C - User intent, coverage, consistency (process fully)
|
||||
2. **Tier 2 (HIGH Priority)**: D, E - Dependencies, synthesis alignment (limit 15 findings total)
|
||||
1. **Tier 1 (CRITICAL Path)**: A, B, C - User intent, coverage, consistency (full analysis)
|
||||
2. **Tier 2 (HIGH Priority)**: D, E - Dependencies, synthesis alignment (limit 15 findings)
|
||||
3. **Tier 3 (MEDIUM Priority)**: F - Specification quality (limit 20 findings)
|
||||
4. **Tier 4 (LOW Priority)**: G, H - Duplication, feasibility (limit 15 findings total)
|
||||
4. **Tier 4 (LOW Priority)**: G, H - Duplication, feasibility (limit 15 findings)
|
||||
|
||||
---
|
||||
|
||||
#### A. User Intent Alignment (CRITICAL - Tier 1)
|
||||
#### Phase 4.1: Launch Unified Verification Agent
|
||||
|
||||
- **Goal Alignment**: IMPL_PLAN objectives match user's original intent
|
||||
- **Scope Drift**: Plan covers user's stated scope without unauthorized expansion
|
||||
- **Success Criteria Match**: Plan's success criteria reflect user's expectations
|
||||
- **Intent Conflicts**: Tasks contradicting user's original objectives
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-explore-agent",
|
||||
run_in_background=false,
|
||||
description="Multi-dimensional plan verification",
|
||||
prompt=`
|
||||
## Plan Verification Task
|
||||
|
||||
#### B. Requirements Coverage Analysis
|
||||
### MANDATORY FIRST STEPS
|
||||
1. Read: ~/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json (dimensions & rules)
|
||||
2. Read: ~/.claude/workflows/cli-templates/schemas/verify-json-schema.json (output schema)
|
||||
3. Read: ${session_file} (user intent)
|
||||
4. Read: ${IMPL_PLAN} (implementation plan)
|
||||
5. Glob: ${task_dir}/*.json (task files)
|
||||
6. Glob: ${SYNTHESIS_DIR}/*/analysis.md (role analyses)
|
||||
|
||||
- **Orphaned Requirements**: Requirements in synthesis with zero associated tasks
|
||||
- **Unmapped Tasks**: Tasks with no clear requirement linkage
|
||||
- **NFR Coverage Gaps**: Non-functional requirements (performance, security, scalability) not reflected in tasks
|
||||
### Execution Flow
|
||||
|
||||
#### C. Consistency Validation
|
||||
**Load schema → Execute tiered CLI analysis → Aggregate findings → Write JSON**
|
||||
|
||||
- **Requirement Conflicts**: Tasks contradicting synthesis requirements
|
||||
- **Architecture Drift**: IMPL_PLAN architecture not matching synthesis ADRs
|
||||
- **Terminology Drift**: Same concept named differently across IMPL_PLAN and tasks
|
||||
- **Data Model Inconsistency**: Tasks referencing entities/fields not in synthesis data model
|
||||
FOR each tier in [1, 2, 3, 4]:
|
||||
- Load tier config from plan-verify-agent-schema.json
|
||||
- Execute: ccw cli -p "PURPOSE: Verify dimensions {tier.dimensions}
|
||||
TASK: {tier.checks from schema}
|
||||
CONTEXT: @${session_dir}/**/*
|
||||
EXPECTED: Findings JSON with dimension, severity, location, summary, recommendation
|
||||
CONSTRAINTS: Limit {tier.limit} findings
|
||||
" --tool gemini --mode analysis --rule {tier.rule}
|
||||
- Parse findings, check early exit condition
|
||||
- IF tier == 1 AND critical_count > 0: skip tier 3-4
|
||||
|
||||
#### D. Dependency Integrity
|
||||
### Output
|
||||
Write: ${process_dir}/verification-findings.json (follow verify-json-schema.json)
|
||||
Return: Quality gate decision + 2-3 sentence summary
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
- **Circular Dependencies**: Task A depends on B, B depends on C, C depends on A
|
||||
- **Missing Dependencies**: Task requires outputs from another task but no explicit dependency
|
||||
- **Broken Dependencies**: Task depends on non-existent task ID
|
||||
- **Logical Ordering Issues**: Implementation tasks before foundational setup without dependency note
|
||||
---
|
||||
|
||||
#### E. Synthesis Alignment
|
||||
#### Phase 4.2: Load and Organize Findings
|
||||
|
||||
- **Priority Conflicts**: High-priority synthesis requirements mapped to low-priority tasks
|
||||
- **Success Criteria Mismatch**: IMPL_PLAN success criteria not covering synthesis acceptance criteria
|
||||
- **Risk Mitigation Gaps**: Critical risks in synthesis without corresponding mitigation tasks
|
||||
```javascript
|
||||
// Load findings (single parse for all subsequent use)
|
||||
const data = JSON.parse(Read(`${process_dir}/verification-findings.json`))
|
||||
const { session_id, timestamp, verification_tiers_completed, findings, summary } = data
|
||||
const { critical_count, high_count, medium_count, low_count, total_findings, coverage_percentage, recommendation } = summary
|
||||
|
||||
#### F. Task Specification Quality
|
||||
// Group by severity and dimension
|
||||
const bySeverity = Object.groupBy(findings, f => f.severity)
|
||||
const byDimension = Object.groupBy(findings, f => f.dimension)
|
||||
|
||||
- **Ambiguous Focus Paths**: Tasks with vague or missing focus_paths
|
||||
- **Underspecified Acceptance**: Tasks without clear acceptance criteria
|
||||
- **Missing Artifacts References**: Tasks not referencing relevant brainstorming artifacts in context.artifacts
|
||||
- **Weak Flow Control**: Tasks without clear implementation_approach or pre_analysis steps
|
||||
- **Missing Target Files**: Tasks without flow_control.target_files specification
|
||||
// Dimension metadata (from schema)
|
||||
const DIMS = {
|
||||
A: "User Intent Alignment", B: "Requirements Coverage", C: "Consistency Validation",
|
||||
D: "Dependency Integrity", E: "Synthesis Alignment", F: "Task Specification Quality",
|
||||
G: "Duplication Detection", H: "Feasibility Assessment"
|
||||
}
|
||||
```
|
||||
|
||||
#### G. Duplication Detection
|
||||
### 5. Generate Report
|
||||
|
||||
- **Overlapping Task Scope**: Multiple tasks with nearly identical descriptions
|
||||
- **Redundant Requirements Coverage**: Same requirement covered by multiple tasks without clear partitioning
|
||||
```javascript
|
||||
// Helper: render dimension section
|
||||
const renderDimension = (dim) => {
|
||||
const items = byDimension[dim] || []
|
||||
return items.length > 0
|
||||
? items.map(f => `### ${f.id}: ${f.summary}\n- **Severity**: ${f.severity}\n- **Location**: ${f.location.join(', ')}\n- **Recommendation**: ${f.recommendation}`).join('\n\n')
|
||||
: `> ✅ No ${DIMS[dim]} issues detected.`
|
||||
}
|
||||
|
||||
#### H. Feasibility Assessment
|
||||
// Helper: render severity section
|
||||
const renderSeverity = (severity, impact) => {
|
||||
const items = bySeverity[severity] || []
|
||||
return items.length > 0
|
||||
? items.map(f => `#### ${f.id}: ${f.summary}\n- **Dimension**: ${f.dimension_name}\n- **Location**: ${f.location.join(', ')}\n- **Impact**: ${impact}\n- **Recommendation**: ${f.recommendation}`).join('\n\n')
|
||||
: `> ✅ No ${severity.toLowerCase()}-severity issues detected.`
|
||||
}
|
||||
|
||||
- **Complexity Misalignment**: Task marked "simple" but requires multiple file modifications
|
||||
- **Resource Conflicts**: Parallel tasks requiring same resources/files
|
||||
- **Skill Gap Risks**: Tasks requiring skills not in team capability assessment (from synthesis)
|
||||
|
||||
### 5. Severity Assignment
|
||||
|
||||
Use this heuristic to prioritize findings:
|
||||
|
||||
- **CRITICAL**:
|
||||
- Violates user's original intent (goal misalignment, scope drift)
|
||||
- Violates synthesis authority (requirement conflict)
|
||||
- Core requirement with zero coverage
|
||||
- Circular dependencies
|
||||
- Broken dependencies
|
||||
|
||||
- **HIGH**:
|
||||
- NFR coverage gaps
|
||||
- Priority conflicts
|
||||
- Missing risk mitigation tasks
|
||||
- Ambiguous acceptance criteria
|
||||
|
||||
- **MEDIUM**:
|
||||
- Terminology drift
|
||||
- Missing artifacts references
|
||||
- Weak flow control
|
||||
- Logical ordering issues
|
||||
|
||||
- **LOW**:
|
||||
- Style/wording improvements
|
||||
- Minor redundancy not affecting execution
|
||||
|
||||
### 6. Produce Compact Analysis Report
|
||||
|
||||
**Report Generation**: Generate report content and save to file.
|
||||
|
||||
Output a Markdown report with the following structure:
|
||||
|
||||
```markdown
|
||||
// Build Markdown report
|
||||
const fullReport = `
|
||||
# Plan Verification Report
|
||||
|
||||
**Session**: WFS-{session-id}
|
||||
**Generated**: {timestamp}
|
||||
**Artifacts Analyzed**: role analysis documents, IMPL_PLAN.md, {N} task files
|
||||
**User Intent Analysis**: {user_intent_analysis or "SKIPPED: workflow-session.json not found"}
|
||||
**Session**: WFS-${session_id} | **Generated**: ${timestamp}
|
||||
**Tiers Completed**: ${verification_tiers_completed.join(', ')}
|
||||
|
||||
---
|
||||
|
||||
## Executive Summary
|
||||
|
||||
### Quality Gate Decision
|
||||
|
||||
| Metric | Value | Status |
|
||||
|--------|-------|--------|
|
||||
| Overall Risk Level | CRITICAL \| HIGH \| MEDIUM \| LOW | {status_emoji} |
|
||||
| Critical Issues | {count} | 🔴 |
|
||||
| High Issues | {count} | 🟠 |
|
||||
| Medium Issues | {count} | 🟡 |
|
||||
| Low Issues | {count} | 🟢 |
|
||||
| Risk Level | ${critical_count > 0 ? 'CRITICAL' : high_count > 0 ? 'HIGH' : medium_count > 0 ? 'MEDIUM' : 'LOW'} | ${critical_count > 0 ? '🔴' : high_count > 0 ? '🟠' : medium_count > 0 ? '🟡' : '🟢'} |
|
||||
| Critical/High/Medium/Low | ${critical_count}/${high_count}/${medium_count}/${low_count} | |
|
||||
| Coverage | ${coverage_percentage}% | ${coverage_percentage >= 90 ? '🟢' : coverage_percentage >= 75 ? '🟡' : '🔴'} |
|
||||
|
||||
### Recommendation
|
||||
|
||||
**{RECOMMENDATION}**
|
||||
|
||||
**Decision Rationale**:
|
||||
{brief explanation based on severity criteria}
|
||||
|
||||
**Quality Gate Criteria**:
|
||||
- **BLOCK_EXECUTION**: Critical issues > 0 (must fix before proceeding)
|
||||
- **PROCEED_WITH_FIXES**: Critical = 0, High > 0 (fix recommended before execution)
|
||||
- **PROCEED_WITH_CAUTION**: Critical = 0, High = 0, Medium > 0 (proceed with awareness)
|
||||
- **PROCEED**: Only Low issues or None (safe to execute)
|
||||
**Recommendation**: **${recommendation}**
|
||||
|
||||
---
|
||||
|
||||
## Findings Summary
|
||||
|
||||
| ID | Category | Severity | Location(s) | Summary | Recommendation |
|
||||
|----|----------|----------|-------------|---------|----------------|
|
||||
| C1 | Coverage | CRITICAL | synthesis:FR-03 | Requirement "User auth" has zero task coverage | Add authentication implementation task |
|
||||
| H1 | Consistency | HIGH | IMPL-1.2 vs synthesis:ADR-02 | Task uses REST while synthesis specifies GraphQL | Align task with ADR-02 decision |
|
||||
| M1 | Specification | MEDIUM | IMPL-2.1 | Missing context.artifacts reference | Add @synthesis reference |
|
||||
| L1 | Duplication | LOW | IMPL-3.1, IMPL-3.2 | Similar scope | Consider merging |
|
||||
|
||||
(Generate stable IDs prefixed by severity initial: C/H/M/L + number)
|
||||
| ID | Dimension | Severity | Location | Summary |
|
||||
|----|-----------|----------|----------|---------|
|
||||
${findings.map(f => `| ${f.id} | ${f.dimension_name} | ${f.severity} | ${f.location.join(', ')} | ${f.summary} |`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## User Intent Alignment Analysis
|
||||
## Analysis by Dimension
|
||||
|
||||
{IF user_intent_analysis != "SKIPPED"}
|
||||
|
||||
### Goal Alignment
|
||||
- **User Intent**: {user_original_intent}
|
||||
- **IMPL_PLAN Objectives**: {plan_objectives}
|
||||
- **Alignment Status**: {ALIGNED/MISALIGNED/PARTIAL}
|
||||
- **Findings**: {specific alignment issues}
|
||||
|
||||
### Scope Verification
|
||||
- **User Scope**: {user_defined_scope}
|
||||
- **Plan Scope**: {plan_actual_scope}
|
||||
- **Drift Detection**: {NONE/MINOR/MAJOR}
|
||||
- **Findings**: {specific scope issues}
|
||||
|
||||
{ELSE}
|
||||
> ⚠️ User intent alignment analysis was skipped because workflow-session.json was not found.
|
||||
|
||||
{END IF}
|
||||
${['A','B','C','D','E','F','G','H'].map(d => `### ${d}. ${DIMS[d]}\n\n${renderDimension(d)}`).join('\n\n---\n\n')}
|
||||
|
||||
---
|
||||
|
||||
## Requirements Coverage Analysis
|
||||
## Findings by Severity
|
||||
|
||||
### Functional Requirements
|
||||
### CRITICAL (${critical_count})
|
||||
${renderSeverity('CRITICAL', 'Blocks execution')}
|
||||
|
||||
| Requirement ID | Requirement Summary | Has Task? | Task IDs | Priority Match | Notes |
|
||||
|----------------|---------------------|-----------|----------|----------------|-------|
|
||||
| FR-01 | User authentication | Yes | IMPL-1.1, IMPL-1.2 | Match | Complete |
|
||||
| FR-02 | Data export | Yes | IMPL-2.3 | Mismatch | High req → Med priority task |
|
||||
| FR-03 | Profile management | No | - | - | **CRITICAL: Zero coverage** |
|
||||
### HIGH (${high_count})
|
||||
${renderSeverity('HIGH', 'Fix before execution recommended')}
|
||||
|
||||
### Non-Functional Requirements
|
||||
### MEDIUM (${medium_count})
|
||||
${renderSeverity('MEDIUM', 'Address during/after implementation')}
|
||||
|
||||
| Requirement ID | Requirement Summary | Has Task? | Task IDs | Notes |
|
||||
|----------------|---------------------|-----------|----------|-------|
|
||||
| NFR-01 | Response time <200ms | No | - | **HIGH: No performance tasks** |
|
||||
| NFR-02 | Security compliance | Yes | IMPL-4.1 | Complete |
|
||||
|
||||
### Business Requirements
|
||||
|
||||
| Requirement ID | Requirement Summary | Has Task? | Task IDs | Notes |
|
||||
|----------------|---------------------|-----------|----------|-------|
|
||||
| BR-01 | Launch by Q2 | Yes | IMPL-1.* through IMPL-5.* | Timeline realistic |
|
||||
|
||||
### Coverage Metrics
|
||||
|
||||
| Requirement Type | Total | Covered | Coverage % |
|
||||
|------------------|-------|---------|------------|
|
||||
| Functional | {count} | {count} | {percent}% |
|
||||
| Non-Functional | {count} | {count} | {percent}% |
|
||||
| Business | {count} | {count} | {percent}% |
|
||||
| **Overall** | **{total}** | **{covered}** | **{percent}%** |
|
||||
### LOW (${low_count})
|
||||
${renderSeverity('LOW', 'Optional improvement')}
|
||||
|
||||
---
|
||||
|
||||
## Dependency Integrity
|
||||
## Next Steps
|
||||
|
||||
### Dependency Graph Analysis
|
||||
${recommendation === 'BLOCK_EXECUTION' ? '🛑 **BLOCK**: Fix critical issues → Re-verify' :
|
||||
recommendation === 'PROCEED_WITH_FIXES' ? '⚠️ **FIX RECOMMENDED**: Address high issues → Re-verify or Execute' :
|
||||
'✅ **READY**: Proceed to /workflow:execute'}
|
||||
|
||||
**Circular Dependencies**: {None or List}
|
||||
Re-verify: \`/workflow:plan-verify --session ${session_id}\`
|
||||
Execute: \`/workflow:execute --resume-session="${session_id}"\`
|
||||
`
|
||||
|
||||
**Broken Dependencies**:
|
||||
- IMPL-2.3 depends on "IMPL-2.4" (non-existent)
|
||||
|
||||
**Missing Dependencies**:
|
||||
- IMPL-5.1 (integration test) has no dependency on IMPL-1.* (implementation tasks)
|
||||
|
||||
**Logical Ordering Issues**:
|
||||
{List or "None detected"}
|
||||
|
||||
---
|
||||
|
||||
## Synthesis Alignment Issues
|
||||
|
||||
| Issue Type | Synthesis Reference | IMPL_PLAN/Task | Impact | Recommendation |
|
||||
|------------|---------------------|----------------|--------|----------------|
|
||||
| Architecture Conflict | synthesis:ADR-01 (JWT auth) | IMPL_PLAN uses session cookies | HIGH | Update IMPL_PLAN to use JWT |
|
||||
| Priority Mismatch | synthesis:FR-02 (High) | IMPL-2.3 (Medium) | MEDIUM | Elevate task priority |
|
||||
| Missing Risk Mitigation | synthesis:Risk-03 (API rate limits) | No mitigation tasks | HIGH | Add rate limiting implementation task |
|
||||
|
||||
---
|
||||
|
||||
## Task Specification Quality
|
||||
|
||||
### Aggregate Statistics
|
||||
|
||||
| Quality Dimension | Tasks Affected | Percentage |
|
||||
|-------------------|----------------|------------|
|
||||
| Missing Artifacts References | {count} | {percent}% |
|
||||
| Weak Flow Control | {count} | {percent}% |
|
||||
| Missing Target Files | {count} | {percent}% |
|
||||
| Ambiguous Focus Paths | {count} | {percent}% |
|
||||
|
||||
### Sample Issues
|
||||
|
||||
- **IMPL-1.2**: No context.artifacts reference to synthesis
|
||||
- **IMPL-3.1**: Missing flow_control.target_files specification
|
||||
- **IMPL-4.2**: Vague focus_paths ["src/"] - needs refinement
|
||||
|
||||
---
|
||||
|
||||
## Feasibility Concerns
|
||||
|
||||
| Concern | Tasks Affected | Issue | Recommendation |
|
||||
|---------|----------------|-------|----------------|
|
||||
| Skill Gap | IMPL-6.1, IMPL-6.2 | Requires Kubernetes expertise not in team | Add training task or external consultant |
|
||||
| Resource Conflict | IMPL-3.1, IMPL-3.2 | Both modify src/auth/service.ts in parallel | Add dependency or serialize |
|
||||
|
||||
---
|
||||
|
||||
## Detailed Findings by Severity
|
||||
|
||||
### CRITICAL Issues ({count})
|
||||
|
||||
{Detailed breakdown of each critical issue with location, impact, and recommendation}
|
||||
|
||||
### HIGH Issues ({count})
|
||||
|
||||
{Detailed breakdown of each high issue with location, impact, and recommendation}
|
||||
|
||||
### MEDIUM Issues ({count})
|
||||
|
||||
{Detailed breakdown of each medium issue with location, impact, and recommendation}
|
||||
|
||||
### LOW Issues ({count})
|
||||
|
||||
{Detailed breakdown of each low issue with location, impact, and recommendation}
|
||||
|
||||
---
|
||||
|
||||
## Metrics Summary
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Total Requirements | {count} ({functional} functional, {nonfunctional} non-functional, {business} business) |
|
||||
| Total Tasks | {count} |
|
||||
| Overall Coverage | {percent}% ({covered}/{total} requirements with ≥1 task) |
|
||||
| Critical Issues | {count} |
|
||||
| High Issues | {count} |
|
||||
| Medium Issues | {count} |
|
||||
| Low Issues | {count} |
|
||||
| Total Findings | {total_findings} |
|
||||
|
||||
---
|
||||
|
||||
## Remediation Recommendations
|
||||
|
||||
### Priority Order
|
||||
|
||||
1. **CRITICAL** - Must fix before proceeding
|
||||
2. **HIGH** - Fix before execution
|
||||
3. **MEDIUM** - Fix during or after implementation
|
||||
4. **LOW** - Optional improvements
|
||||
|
||||
### Next Steps
|
||||
|
||||
Based on the quality gate recommendation ({RECOMMENDATION}):
|
||||
|
||||
{IF BLOCK_EXECUTION}
|
||||
**🛑 BLOCK EXECUTION**
|
||||
|
||||
You must resolve all CRITICAL issues before proceeding with implementation:
|
||||
|
||||
1. Review each critical issue in detail
|
||||
2. Determine remediation approach (modify IMPL_PLAN.md, update task.json, or add new tasks)
|
||||
3. Apply fixes systematically
|
||||
4. Re-run verification to confirm resolution
|
||||
|
||||
{ELSE IF PROCEED_WITH_FIXES}
|
||||
**⚠️ PROCEED WITH FIXES RECOMMENDED**
|
||||
|
||||
No critical issues detected, but HIGH issues exist. Recommended workflow:
|
||||
|
||||
1. Review high-priority issues
|
||||
2. Apply fixes before execution for optimal results
|
||||
3. Re-run verification (optional)
|
||||
|
||||
{ELSE IF PROCEED_WITH_CAUTION}
|
||||
**✅ PROCEED WITH CAUTION**
|
||||
|
||||
Only MEDIUM issues detected. You may proceed with implementation:
|
||||
|
||||
- Address medium issues during or after implementation
|
||||
- Maintain awareness of identified concerns
|
||||
|
||||
{ELSE}
|
||||
**✅ PROCEED**
|
||||
|
||||
No significant issues detected. Safe to execute implementation workflow.
|
||||
|
||||
{END IF}
|
||||
|
||||
---
|
||||
|
||||
**Report End**
|
||||
// Write report
|
||||
Write(`${process_dir}/PLAN_VERIFICATION.md`, fullReport)
|
||||
console.log(`✅ Report: ${process_dir}/PLAN_VERIFICATION.md\n📊 ${recommendation} | C:${critical_count} H:${high_count} M:${medium_count} L:${low_count} | Coverage:${coverage_percentage}%`)
|
||||
```
|
||||
|
||||
### 7. Save and Display Report
|
||||
### 6. Next Step Selection
|
||||
|
||||
**Step 7.1: Save Report**:
|
||||
```bash
|
||||
report_path = ".workflow/active/WFS-{session}/.process/PLAN_VERIFICATION.md"
|
||||
Write(report_path, full_report_content)
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const canExecute = recommendation !== 'BLOCK_EXECUTION'
|
||||
|
||||
// Auto mode
|
||||
if (autoYes) {
|
||||
if (canExecute) {
|
||||
SlashCommand("/workflow:execute --yes --resume-session=\"${session_id}\"")
|
||||
} else {
|
||||
console.log(`[--yes] BLOCK_EXECUTION - Fix ${critical_count} critical issues first.`)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Interactive mode - build options based on quality gate
|
||||
const options = canExecute
|
||||
? [
|
||||
{ label: canExecute && recommendation === 'PROCEED_WITH_FIXES' ? "Execute Anyway" : "Execute (Recommended)",
|
||||
description: "Proceed to /workflow:execute" },
|
||||
{ label: "Review Report", description: "Review findings before deciding" },
|
||||
{ label: "Re-verify", description: "Re-run after manual fixes" }
|
||||
]
|
||||
: [
|
||||
{ label: "Review Report", description: "Review critical issues" },
|
||||
{ label: "Re-verify", description: "Re-run after fixing issues" }
|
||||
]
|
||||
|
||||
const selection = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Quality gate: ${recommendation}. Next step?`,
|
||||
header: "Action",
|
||||
multiSelect: false,
|
||||
options
|
||||
}]
|
||||
})
|
||||
|
||||
// Handle selection
|
||||
if (selection.includes("Execute")) {
|
||||
SlashCommand("/workflow:execute --resume-session=\"${session_id}\"")
|
||||
} else if (selection === "Re-verify") {
|
||||
SlashCommand("/workflow:plan-verify --session ${session_id}")
|
||||
}
|
||||
```
|
||||
|
||||
**Step 7.2: Display Summary to User**:
|
||||
```bash
|
||||
# Display executive summary in terminal
|
||||
echo "=== Plan Verification Complete ==="
|
||||
echo "Report saved to: {report_path}"
|
||||
echo ""
|
||||
echo "Quality Gate: {RECOMMENDATION}"
|
||||
echo "Critical: {count} | High: {count} | Medium: {count} | Low: {count}"
|
||||
echo ""
|
||||
echo "Next: Review full report for detailed findings and recommendations"
|
||||
```
|
||||
|
||||
**Step 7.3: Completion**:
|
||||
- Report is saved to `.process/PLAN_VERIFICATION.md`
|
||||
- User can review findings and decide on remediation approach
|
||||
- No automatic modifications are made to source artifacts
|
||||
- User can manually apply fixes or use separate remediation command (if available)
|
||||
|
||||
@@ -3,6 +3,7 @@ name: plan
|
||||
description: 5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs
|
||||
argument-hint: "[-y|--yes] \"text description\"|file.md"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
group: workflow
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
@@ -115,7 +116,38 @@ CONTEXT: Existing user database schema, REST API endpoints
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
**After Phase 1**: Initialize planning-notes.md with user intent
|
||||
|
||||
```javascript
|
||||
// Create minimal planning notes document
|
||||
const planningNotesPath = `.workflow/active/${sessionId}/planning-notes.md`
|
||||
const userGoal = structuredDescription.goal
|
||||
const userConstraints = structuredDescription.context || "None specified"
|
||||
|
||||
Write(planningNotesPath, `# Planning Notes
|
||||
|
||||
**Session**: ${sessionId}
|
||||
**Created**: ${new Date().toISOString()}
|
||||
|
||||
## User Intent (Phase 1)
|
||||
|
||||
- **GOAL**: ${userGoal}
|
||||
- **KEY_CONSTRAINTS**: ${userConstraints}
|
||||
|
||||
---
|
||||
|
||||
## Context Findings (Phase 2)
|
||||
(To be filled by context-gather)
|
||||
|
||||
## Conflict Decisions (Phase 3)
|
||||
(To be filled if conflicts detected)
|
||||
|
||||
## Consolidated Constraints (Phase 4 Input)
|
||||
1. ${userConstraints}
|
||||
`)
|
||||
```
|
||||
|
||||
Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
|
||||
---
|
||||
|
||||
@@ -138,6 +170,7 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
**Validation**:
|
||||
- Context package path extracted
|
||||
- File exists and is valid JSON
|
||||
- `prioritized_context` field exists
|
||||
|
||||
<!-- TodoWrite: When context-gather executed, INSERT 3 context-gather tasks, mark first as in_progress -->
|
||||
|
||||
@@ -168,7 +201,37 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
|
||||
**Note**: Phase 2 tasks completed and collapsed to summary.
|
||||
|
||||
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
|
||||
**After Phase 2**: Update planning-notes.md with context findings, then auto-continue
|
||||
|
||||
```javascript
|
||||
// Read context-package to extract key findings
|
||||
const contextPackage = JSON.parse(Read(contextPath))
|
||||
const conflictRisk = contextPackage.conflict_detection?.risk_level || 'low'
|
||||
const criticalFiles = (contextPackage.exploration_results?.aggregated_insights?.critical_files || [])
|
||||
.slice(0, 5).map(f => f.path)
|
||||
const archPatterns = contextPackage.project_context?.architecture_patterns || []
|
||||
const constraints = contextPackage.exploration_results?.aggregated_insights?.constraints || []
|
||||
|
||||
// Append Phase 2 findings to planning-notes.md
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Context Findings (Phase 2)\n(To be filled by context-gather)',
|
||||
new: `## Context Findings (Phase 2)
|
||||
|
||||
- **CRITICAL_FILES**: ${criticalFiles.join(', ') || 'None identified'}
|
||||
- **ARCHITECTURE**: ${archPatterns.join(', ') || 'Not detected'}
|
||||
- **CONFLICT_RISK**: ${conflictRisk}
|
||||
- **CONSTRAINTS**: ${constraints.length > 0 ? constraints.join('; ') : 'None'}`
|
||||
})
|
||||
|
||||
// Append Phase 2 constraints to consolidated list
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Consolidated Constraints (Phase 4 Input)',
|
||||
new: `## Consolidated Constraints (Phase 4 Input)
|
||||
${constraints.map((c, i) => `${i + 2}. [Context] ${c}`).join('\n')}`
|
||||
})
|
||||
```
|
||||
|
||||
Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
|
||||
|
||||
---
|
||||
|
||||
@@ -229,7 +292,45 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
|
||||
**Note**: Phase 3 tasks completed and collapsed to summary.
|
||||
|
||||
**After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
|
||||
**After Phase 3**: Update planning-notes.md with conflict decisions (if executed), then auto-continue
|
||||
|
||||
```javascript
|
||||
// If Phase 3 was executed, update planning-notes.md
|
||||
if (conflictRisk >= 'medium') {
|
||||
const conflictResPath = `.workflow/active/${sessionId}/.process/conflict-resolution.json`
|
||||
|
||||
if (fs.existsSync(conflictResPath)) {
|
||||
const conflictRes = JSON.parse(Read(conflictResPath))
|
||||
const resolved = conflictRes.resolved_conflicts || []
|
||||
const modifiedArtifacts = conflictRes.modified_artifacts || []
|
||||
const planningConstraints = conflictRes.planning_constraints || []
|
||||
|
||||
// Update Phase 3 section
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Conflict Decisions (Phase 3)\n(To be filled if conflicts detected)',
|
||||
new: `## Conflict Decisions (Phase 3)
|
||||
|
||||
- **RESOLVED**: ${resolved.map(r => `${r.type} → ${r.strategy}`).join('; ') || 'None'}
|
||||
- **MODIFIED_ARTIFACTS**: ${modifiedArtifacts.join(', ') || 'None'}
|
||||
- **CONSTRAINTS**: ${planningConstraints.join('; ') || 'None'}`
|
||||
})
|
||||
|
||||
// Append Phase 3 constraints to consolidated list
|
||||
if (planningConstraints.length > 0) {
|
||||
const currentNotes = Read(planningNotesPath)
|
||||
const constraintCount = (currentNotes.match(/^\d+\./gm) || []).length
|
||||
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Consolidated Constraints (Phase 4 Input)',
|
||||
new: `## Consolidated Constraints (Phase 4 Input)
|
||||
${planningConstraints.map((c, i) => `${constraintCount + i + 1}. [Conflict] ${c}`).join('\n')}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
|
||||
|
||||
**Memory State Check**:
|
||||
- Evaluate current context window usage and memory state
|
||||
@@ -282,7 +383,12 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]"
|
||||
|
||||
**CLI Execution Note**: CLI tool usage is now determined semantically by action-planning-agent based on user's task description. If user specifies "use Codex/Gemini/Qwen for X", the agent embeds `command` fields in relevant `implementation_approach` steps.
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
**Input**:
|
||||
- `sessionId` from Phase 1
|
||||
- **planning-notes.md**: Consolidated constraints from all phases (Phase 1-3)
|
||||
- Path: `.workflow/active/[sessionId]/planning-notes.md`
|
||||
- Contains: User intent, context findings, conflict decisions, consolidated constraints
|
||||
- **Purpose**: Provides structured, minimal context summary to action-planning-agent
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/[sessionId]/IMPL_PLAN.md` exists
|
||||
@@ -315,20 +421,55 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]"
|
||||
|
||||
**Note**: Agent task completed. No collapse needed (single task).
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
Planning complete for session: [sessionId]
|
||||
Tasks generated: [count]
|
||||
Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
|
||||
**Step 4.2: User Decision** - Choose next action
|
||||
|
||||
Recommended Next Steps:
|
||||
1. /workflow:plan-verify --session [sessionId] # Verify plan quality before execution
|
||||
2. /workflow:status # Review task breakdown
|
||||
3. /workflow:execute # Start implementation (after verification)
|
||||
After Phase 4 completes, present user with action choices:
|
||||
|
||||
Quality Gate: Consider running /workflow:plan-verify to catch issues early
|
||||
```javascript
|
||||
console.log(`
|
||||
✅ Planning complete for session: ${sessionId}
|
||||
📊 Tasks generated: ${taskCount}
|
||||
📋 Plan: .workflow/active/${sessionId}/IMPL_PLAN.md
|
||||
`);
|
||||
|
||||
// Ask user for next action
|
||||
const userChoice = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Planning complete. What would you like to do next?",
|
||||
header: "Next Action",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Verify Plan Quality (Recommended)",
|
||||
description: "Run quality verification to catch issues before execution. Checks plan structure, task dependencies, and completeness."
|
||||
},
|
||||
{
|
||||
label: "Start Execution",
|
||||
description: "Begin implementing tasks immediately. Use this if you've already reviewed the plan or want to start quickly."
|
||||
},
|
||||
{
|
||||
label: "Review Status Only",
|
||||
description: "View task breakdown and session status without taking further action. You can decide what to do next manually."
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Execute based on user choice
|
||||
if (userChoice.answers["Next Action"] === "Verify Plan Quality (Recommended)") {
|
||||
console.log("\n🔍 Starting plan verification...\n");
|
||||
SlashCommand(command="/workflow:plan-verify --session " + sessionId);
|
||||
} else if (userChoice.answers["Next Action"] === "Start Execution") {
|
||||
console.log("\n🚀 Starting task execution...\n");
|
||||
SlashCommand(command="/workflow:execute --session " + sessionId);
|
||||
} else if (userChoice.answers["Next Action"] === "Review Status Only") {
|
||||
console.log("\n📊 Displaying session status...\n");
|
||||
SlashCommand(command="/workflow:status --session " + sessionId);
|
||||
}
|
||||
```
|
||||
|
||||
**Return to User**: Based on user's choice, execute the corresponding workflow command.
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
**Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
|
||||
@@ -404,26 +545,21 @@ User Input (task description)
|
||||
↓
|
||||
Phase 1: session:start --auto "structured-description"
|
||||
↓ Output: sessionId
|
||||
↓ Session Memory: Previous tasks, context, artifacts
|
||||
↓ Write: planning-notes.md (User Intent section)
|
||||
↓
|
||||
Phase 2: context-gather --session sessionId "structured-description"
|
||||
↓ Input: sessionId + session memory + structured description
|
||||
↓ Output: contextPath (context-package.json) + conflict_risk
|
||||
↓ Input: sessionId + structured description
|
||||
↓ Output: contextPath (context-package.json with prioritized_context) + conflict_risk
|
||||
↓ Update: planning-notes.md (Context Findings + Consolidated Constraints)
|
||||
↓
|
||||
Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
|
||||
↓ Input: sessionId + contextPath + conflict_risk
|
||||
↓ CLI-powered conflict detection (JSON output)
|
||||
↓ AskUserQuestion: Present conflicts + resolution strategies
|
||||
↓ User selects strategies (or skip)
|
||||
↓ Apply modifications via Edit tool:
|
||||
↓ - Update guidance-specification.md
|
||||
↓ - Update role analyses (*.md)
|
||||
↓ - Mark context-package.json as "resolved"
|
||||
↓ Output: Modified brainstorm artifacts (NO report file)
|
||||
↓ Output: Modified brainstorm artifacts
|
||||
↓ Update: planning-notes.md (Conflict Decisions + Consolidated Constraints)
|
||||
↓ Skip if conflict_risk is none/low → proceed directly to Phase 4
|
||||
↓
|
||||
Phase 4: task-generate-agent --session sessionId
|
||||
↓ Input: sessionId + resolved brainstorm artifacts + session memory
|
||||
↓ Input: sessionId + planning-notes.md + context-package.json + brainstorm artifacts
|
||||
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
|
||||
↓
|
||||
Return summary to user
|
||||
|
||||
808
.claude/commands/workflow/quick-plan-with-file.md
Normal file
808
.claude/commands/workflow/quick-plan-with-file.md
Normal file
@@ -0,0 +1,808 @@
|
||||
---
|
||||
name: quick-plan-with-file
|
||||
description: Multi-agent rapid planning with minimal documentation, conflict resolution, and actionable synthesis. Designed as a lightweight planning supplement between brainstorm and full implementation planning
|
||||
argument-hint: "[-y|--yes] [-c|--continue] [-f|--from <type>] \"planning topic or task description\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm planning decisions, use aggressive parallelization, minimal user interaction.
|
||||
|
||||
# Workflow Quick-Plan-With-File Command (/workflow:quick-plan-with-file)
|
||||
|
||||
## Overview
|
||||
|
||||
Multi-agent rapid planning workflow with **minimal documentation overhead**. Coordinates parallel agent analysis, synthesizes conflicting perspectives into actionable decisions, and generates a lightweight implementation-ready plan.
|
||||
|
||||
**Core workflow**: Parse Input → Parallel Analysis → Conflict Resolution → Plan Synthesis → Output
|
||||
|
||||
**Key features**:
|
||||
- **Plan Format Agnostic**: Consumes brainstorm conclusions, analysis recommendations, or raw task descriptions
|
||||
- **Minimal Docs**: Single `plan.md` (no lengthy brainstorm.md or discussion.md)
|
||||
- **Parallel Multi-Agent**: 3-4 concurrent agent perspectives (architecture, implementation, validation, risk)
|
||||
- **Conflict Resolution**: Automatic conflict detection and resolution via synthesis agent
|
||||
- **Actionable Output**: Direct task breakdown ready for execution
|
||||
- **Session Resumable**: Continue if interrupted, checkpoint at each phase
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:quick-plan-with-file [FLAGS] <PLANNING_TOPIC>
|
||||
|
||||
# Flags
|
||||
-y, --yes Auto-confirm decisions, use defaults
|
||||
-c, --continue Continue existing session (auto-detected)
|
||||
-f, --from <type> Input source type: brainstorm|analysis|task|raw
|
||||
|
||||
# Arguments
|
||||
<planning-topic> Planning topic, task, or reference to planning artifact
|
||||
|
||||
# Examples
|
||||
/workflow:quick-plan-with-file "实现分布式缓存层,支持Redis和内存后端"
|
||||
/workflow:quick-plan-with-file --continue "缓存层规划" # Continue
|
||||
/workflow:quick-plan-with-file -y -f analysis "从分析结论生成实施规划" # Auto mode
|
||||
/workflow:quick-plan-with-file --from brainstorm BS-rate-limiting-2025-01-28 # From artifact
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Validation & Loading:
|
||||
├─ Parse input (topic | artifact reference)
|
||||
├─ Load artifact if referenced (synthesis.json | conclusions.json | etc.)
|
||||
├─ Extract key constraints and requirements
|
||||
└─ Initialize session folder and plan.md
|
||||
|
||||
Session Initialization:
|
||||
├─ Create .workflow/.planning/{sessionId}/
|
||||
├─ Initialize plan.md with input summary
|
||||
├─ Parse existing output (if --from artifact)
|
||||
└─ Define planning dimensions & focus areas
|
||||
|
||||
Phase 1: Parallel Multi-Agent Analysis (concurrent)
|
||||
├─ Agent 1 (Architecture): High-level design & decomposition
|
||||
├─ Agent 2 (Implementation): Technical approach & feasibility
|
||||
├─ Agent 3 (Validation): Risk analysis & edge cases
|
||||
├─ Agent 4 (Decision): Recommendations & tradeoffs
|
||||
└─ Aggregate findings into perspectives.json
|
||||
|
||||
Phase 2: Conflict Detection & Resolution
|
||||
├─ Analyze agent perspectives for contradictions
|
||||
├─ Identify critical decision points
|
||||
├─ Generate synthesis via arbitration agent
|
||||
├─ Document conflicts and resolutions
|
||||
└─ Update plan.md with decisive recommendations
|
||||
|
||||
Phase 3: Plan Synthesis
|
||||
├─ Consolidate all insights
|
||||
├─ Generate actionable task breakdown
|
||||
├─ Create execution strategy
|
||||
├─ Document assumptions & risks
|
||||
└─ Generate synthesis.md with ready-to-execute tasks
|
||||
|
||||
Output:
|
||||
├─ .workflow/.planning/{sessionId}/plan.md (minimal, actionable)
|
||||
├─ .workflow/.planning/{sessionId}/perspectives.json (agent findings)
|
||||
├─ .workflow/.planning/{sessionId}/conflicts.json (decision points)
|
||||
├─ .workflow/.planning/{sessionId}/synthesis.md (task breakdown)
|
||||
└─ Optional: Feed to /workflow:unified-execute-with-file
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Input Loading
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
// Parse arguments
|
||||
const planningTopic = "$PLANNING_TOPIC"
|
||||
const inputType = $ARGUMENTS.match(/--from\s+(\w+)/)?.[1] || 'raw'
|
||||
const isAutoMode = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const isContinue = $ARGUMENTS.includes('--continue') || $ARGUMENTS.includes('-c')
|
||||
|
||||
// Auto-detect artifact if referenced
|
||||
let artifact = null
|
||||
let artifactContent = null
|
||||
|
||||
if (inputType === 'brainstorm' || planningTopic.startsWith('BS-')) {
|
||||
const sessionId = planningTopic
|
||||
const synthesisPath = `.workflow/.brainstorm/${sessionId}/synthesis.json`
|
||||
if (fs.existsSync(synthesisPath)) {
|
||||
artifact = { type: 'brainstorm', path: synthesisPath }
|
||||
artifactContent = JSON.parse(Read(synthesisPath))
|
||||
}
|
||||
} else if (inputType === 'analysis' || planningTopic.startsWith('ANL-')) {
|
||||
const sessionId = planningTopic
|
||||
const conclusionsPath = `.workflow/.analysis/${sessionId}/conclusions.json`
|
||||
if (fs.existsSync(conclusionsPath)) {
|
||||
artifact = { type: 'analysis', path: conclusionsPath }
|
||||
artifactContent = JSON.parse(Read(conclusionsPath))
|
||||
}
|
||||
}
|
||||
|
||||
// Generate session ID
|
||||
const planSlug = planningTopic.toLowerCase()
|
||||
.replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
|
||||
.substring(0, 30)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
const sessionId = `PLAN-${planSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.planning/${sessionId}`
|
||||
|
||||
// Session mode detection
|
||||
const sessionExists = fs.existsSync(sessionFolder)
|
||||
const hasPlan = sessionExists && fs.existsSync(`${sessionFolder}/plan.md`)
|
||||
const mode = (hasPlan || isContinue) ? 'continue' : 'new'
|
||||
|
||||
if (!sessionExists) {
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 1: Initialize plan.md (Minimal)
|
||||
|
||||
```markdown
|
||||
# Quick Planning Session
|
||||
|
||||
**Session ID**: ${sessionId}
|
||||
**Topic**: ${planningTopic}
|
||||
**Started**: ${getUtc8ISOString()}
|
||||
**Mode**: ${mode}
|
||||
|
||||
---
|
||||
|
||||
## Input Context
|
||||
|
||||
${artifact ? `
|
||||
**Source**: ${artifact.type} artifact
|
||||
**Path**: ${artifact.path}
|
||||
|
||||
**Artifact Summary**:
|
||||
${artifact.type === 'brainstorm' ? `
|
||||
- Topic: ${artifactContent.topic}
|
||||
- Top Ideas: ${artifactContent.top_ideas?.length || 0}
|
||||
- Key Insights: ${artifactContent.key_insights?.slice(0, 2).join(', ') || 'N/A'}
|
||||
` : artifact.type === 'analysis' ? `
|
||||
- Topic: ${artifactContent.topic}
|
||||
- Key Conclusions: ${artifactContent.key_conclusions?.length || 0}
|
||||
- Recommendations: ${artifactContent.recommendations?.length || 0}
|
||||
` : ''}
|
||||
` : `
|
||||
**User Input**: ${planningTopic}
|
||||
`}
|
||||
|
||||
---
|
||||
|
||||
## Planning Dimensions
|
||||
|
||||
*To be populated after agent analysis*
|
||||
|
||||
---
|
||||
|
||||
## Key Decisions
|
||||
|
||||
*Conflict resolution and recommendations - to be populated*
|
||||
|
||||
---
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
*Task breakdown - to be populated after synthesis*
|
||||
|
||||
---
|
||||
|
||||
## Progress
|
||||
|
||||
- [ ] Multi-agent analysis
|
||||
- [ ] Conflict detection
|
||||
- [ ] Plan synthesis
|
||||
- [ ] Ready for execution
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Parallel Multi-Agent Analysis
|
||||
|
||||
```javascript
|
||||
const analysisPrompt = artifact
|
||||
? `Convert ${artifact.type} artifact to planning requirements and execute parallel analysis`
|
||||
: `Create planning breakdown for: ${planningTopic}`
|
||||
|
||||
// Prepare context for agents
|
||||
const agentContext = {
|
||||
topic: planningTopic,
|
||||
artifact: artifact ? {
|
||||
type: artifact.type,
|
||||
summary: extractArtifactSummary(artifactContent)
|
||||
} : null,
|
||||
planning_focus: determineFocusAreas(planningTopic),
|
||||
constraints: extractConstraints(planningTopic, artifactContent)
|
||||
}
|
||||
|
||||
// Agent 1: Architecture & Design
|
||||
const archPromise = Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Architecture & high-level design planning for '${planningTopic}'
|
||||
Success: Clear component decomposition, interface design, and data flow
|
||||
|
||||
TASK:
|
||||
• Decompose problem into major components/modules
|
||||
• Identify architectural patterns and integration points
|
||||
• Design interfaces and data models
|
||||
• Assess scalability and maintainability implications
|
||||
• Propose architectural approach with rationale
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/*
|
||||
${artifact ? `| Source artifact: ${artifact.type}` : ''}
|
||||
|
||||
EXPECTED:
|
||||
- Component decomposition (box diagram in text)
|
||||
- Module interfaces and responsibilities
|
||||
- Data flow between components
|
||||
- Architectural patterns applied
|
||||
- Scalability assessment (1-5 rating)
|
||||
- Risks from architectural perspective
|
||||
|
||||
CONSTRAINTS: Focus on long-term maintainability
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
// Agent 2: Implementation & Feasibility
|
||||
const implPromise = Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Implementation approach & technical feasibility for '${planningTopic}'
|
||||
Success: Concrete implementation strategy with realistic resource estimates
|
||||
|
||||
TASK:
|
||||
• Evaluate technical feasibility of approach
|
||||
• Identify required technologies and dependencies
|
||||
• Estimate effort: high/medium/low + rationale
|
||||
• Suggest implementation phases and milestones
|
||||
• Highlight technical blockers or challenges
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/*
|
||||
${artifact ? `| Source artifact: ${artifact.type}` : ''}
|
||||
|
||||
EXPECTED:
|
||||
- Technology stack recommendation
|
||||
- Implementation complexity: high|medium|low with justification
|
||||
- Estimated effort breakdown (analysis/design/coding/testing/deployment)
|
||||
- Key technical decisions with tradeoffs
|
||||
- Potential blockers and mitigations
|
||||
- Suggested implementation phases
|
||||
- Reusable components or libraries
|
||||
|
||||
CONSTRAINTS: Realistic with current tech stack
|
||||
" --tool codex --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
// Agent 3: Risk & Validation
|
||||
const riskPromise = Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Risk analysis and validation strategy for '${planningTopic}'
|
||||
Success: Comprehensive risk matrix with testing strategy
|
||||
|
||||
TASK:
|
||||
• Identify technical risks and failure scenarios
|
||||
• Assess business/timeline risks
|
||||
• Define validation/testing strategy
|
||||
• Suggest monitoring and observability requirements
|
||||
• Rate overall risk level (low/medium/high)
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/*
|
||||
${artifact ? `| Source artifact: ${artifact.type}` : ''}
|
||||
|
||||
EXPECTED:
|
||||
- Risk matrix (likelihood × impact, 1-5 each)
|
||||
- Top 3 technical risks with mitigations
|
||||
- Top 3 timeline/resource risks with mitigations
|
||||
- Testing strategy (unit/integration/e2e/performance)
|
||||
- Deployment strategy and rollback plan
|
||||
- Monitoring/observability requirements
|
||||
- Overall risk rating with confidence (low/medium/high)
|
||||
|
||||
CONSTRAINTS: Be realistic, not pessimistic
|
||||
" --tool claude --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
// Agent 4: Decisions & Recommendations
|
||||
const decisionPromise = Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Strategic decisions and execution recommendations for '${planningTopic}'
|
||||
Success: Clear recommended approach with tradeoff analysis
|
||||
|
||||
TASK:
|
||||
• Synthesize all considerations into recommendations
|
||||
• Clearly identify critical decision points
|
||||
• Outline key tradeoffs (speed vs quality, scope vs timeline, etc.)
|
||||
• Propose go/no-go decision criteria
|
||||
• Suggest execution strategy and sequencing
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/*
|
||||
${artifact ? `| Source artifact: ${artifact.type}` : ''}
|
||||
|
||||
EXPECTED:
|
||||
- Primary recommendation with strong rationale
|
||||
- Alternative approaches with pros/cons
|
||||
- 2-3 critical decision points with recommended choices
|
||||
- Key tradeoffs and what we're optimizing for
|
||||
- Success metrics and go/no-go criteria
|
||||
- Suggested execution sequencing
|
||||
- Resource requirements and dependencies
|
||||
|
||||
CONSTRAINTS: Focus on actionable decisions, not analysis
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
// Wait for all parallel analyses
|
||||
const [archResult, implResult, riskResult, decisionResult] = await Promise.all([
|
||||
archPromise, implPromise, riskPromise, decisionPromise
|
||||
])
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Aggregate Perspectives
|
||||
|
||||
```javascript
|
||||
// Parse and structure agent findings
|
||||
const perspectives = {
|
||||
session_id: sessionId,
|
||||
timestamp: getUtc8ISOString(),
|
||||
topic: planningTopic,
|
||||
source_artifact: artifact?.type || 'raw',
|
||||
|
||||
architecture: {
|
||||
source: 'gemini (design)',
|
||||
components: extractComponents(archResult),
|
||||
interfaces: extractInterfaces(archResult),
|
||||
patterns: extractPatterns(archResult),
|
||||
scalability_rating: extractRating(archResult, 'scalability'),
|
||||
risks_from_design: extractRisks(archResult)
|
||||
},
|
||||
|
||||
implementation: {
|
||||
source: 'codex (pragmatic)',
|
||||
technology_stack: extractStack(implResult),
|
||||
complexity: extractComplexity(implResult),
|
||||
effort_breakdown: extractEffort(implResult),
|
||||
blockers: extractBlockers(implResult),
|
||||
phases: extractPhases(implResult)
|
||||
},
|
||||
|
||||
validation: {
|
||||
source: 'claude (systematic)',
|
||||
risk_matrix: extractRiskMatrix(riskResult),
|
||||
top_risks: extractTopRisks(riskResult),
|
||||
testing_strategy: extractTestingStrategy(riskResult),
|
||||
deployment_strategy: extractDeploymentStrategy(riskResult),
|
||||
monitoring_requirements: extractMonitoring(riskResult),
|
||||
overall_risk_rating: extractRiskRating(riskResult)
|
||||
},
|
||||
|
||||
recommendation: {
|
||||
source: 'gemini (synthesis)',
|
||||
primary_approach: extractPrimaryApproach(decisionResult),
|
||||
alternatives: extractAlternatives(decisionResult),
|
||||
critical_decisions: extractDecisions(decisionResult),
|
||||
tradeoffs: extractTradeoffs(decisionResult),
|
||||
success_criteria: extractCriteria(decisionResult),
|
||||
execution_sequence: extractSequence(decisionResult)
|
||||
},
|
||||
|
||||
analysis_timestamp: getUtc8ISOString()
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/perspectives.json`, JSON.stringify(perspectives, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Conflict Detection & Resolution
|
||||
|
||||
```javascript
|
||||
// Analyze for conflicts and contradictions
|
||||
const conflicts = detectConflicts({
|
||||
arch_vs_impl: compareArchitectureAndImplementation(perspectives),
|
||||
design_vs_risk: compareDesignAndRisk(perspectives),
|
||||
effort_vs_scope: compareEffortAndScope(perspectives),
|
||||
timeline_implications: extractTimingConflicts(perspectives)
|
||||
})
|
||||
|
||||
// If conflicts exist, invoke arbitration agent
|
||||
if (conflicts.critical.length > 0) {
|
||||
const arbitrationResult = await Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Resolve planning conflicts and generate unified recommendation
|
||||
Input: ${JSON.stringify(conflicts, null, 2)}
|
||||
|
||||
TASK:
|
||||
• Review all conflicts presented
|
||||
• Recommend resolution for each critical conflict
|
||||
• Explain tradeoff choices
|
||||
• Identify what we're optimizing for (speed/quality/risk/resource)
|
||||
• Generate unified execution strategy
|
||||
|
||||
MODE: analysis
|
||||
|
||||
EXPECTED:
|
||||
- For each conflict: recommended resolution + rationale
|
||||
- Unified optimization criteria (what matters most?)
|
||||
- Final recommendation with confidence level
|
||||
- Any unresolved tensions that need user input
|
||||
|
||||
CONSTRAINTS: Be decisive, not fence-sitting
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
|
||||
const conflictResolution = {
|
||||
detected_conflicts: conflicts,
|
||||
arbitration_result: arbitrationResult,
|
||||
timestamp: getUtc8ISOString()
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/conflicts.json`, JSON.stringify(conflictResolution, null, 2))
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Plan Synthesis & Task Breakdown
|
||||
|
||||
```javascript
|
||||
const synthesisPrompt = `
|
||||
Given the planning context:
|
||||
- Topic: ${planningTopic}
|
||||
- Architecture: ${perspectives.architecture.components.map(c => c.name).join(', ')}
|
||||
- Implementation Complexity: ${perspectives.implementation.complexity}
|
||||
- Timeline Risk: ${perspectives.validation.overall_risk_rating}
|
||||
- Primary Recommendation: ${perspectives.recommendation.primary_approach.summary}
|
||||
|
||||
Generate a minimal but complete implementation plan with:
|
||||
1. Task breakdown (5-8 major tasks)
|
||||
2. Dependencies between tasks
|
||||
3. For each task: what needs to be done, why, and key considerations
|
||||
4. Success criteria for the entire effort
|
||||
5. Known risks and mitigation strategies
|
||||
|
||||
Output as structured task list ready for execution.
|
||||
`
|
||||
|
||||
const synthesisResult = await Bash({
|
||||
command: `ccw cli -p "${synthesisPrompt}" --tool gemini --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
|
||||
// Parse synthesis and generate task breakdown
|
||||
const tasks = parseTaskBreakdown(synthesisResult)
|
||||
|
||||
const synthesis = {
|
||||
session_id: sessionId,
|
||||
planning_topic: planningTopic,
|
||||
completed: getUtc8ISOString(),
|
||||
|
||||
// Summary
|
||||
executive_summary: perspectives.recommendation.primary_approach.summary,
|
||||
optimization_focus: extractOptimizationFocus(perspectives),
|
||||
|
||||
// Architecture
|
||||
architecture_approach: perspectives.architecture.patterns[0] || 'TBD',
|
||||
key_components: perspectives.architecture.components.slice(0, 5),
|
||||
|
||||
// Implementation
|
||||
technology_stack: perspectives.implementation.technology_stack,
|
||||
complexity_level: perspectives.implementation.complexity,
|
||||
estimated_effort: perspectives.implementation.effort_breakdown,
|
||||
|
||||
// Risks & Validation
|
||||
top_risks: perspectives.validation.top_risks.slice(0, 3),
|
||||
testing_approach: perspectives.validation.testing_strategy,
|
||||
|
||||
// Execution
|
||||
phases: perspectives.implementation.phases,
|
||||
critical_path_tasks: extractCriticalPath(tasks),
|
||||
total_tasks: tasks.length,
|
||||
|
||||
// Task breakdown (ready for unified-execute-with-file)
|
||||
tasks: tasks.map(task => ({
|
||||
id: task.id,
|
||||
title: task.title,
|
||||
description: task.description,
|
||||
type: task.type,
|
||||
dependencies: task.dependencies,
|
||||
effort_estimate: task.effort,
|
||||
success_criteria: task.criteria
|
||||
}))
|
||||
}
|
||||
|
||||
Write(`${sessionFolder}/synthesis.md`, formatSynthesisMarkdown(synthesis))
|
||||
Write(`${sessionFolder}/synthesis.json`, JSON.stringify(synthesis, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 6: Update plan.md with Results
|
||||
|
||||
```markdown
|
||||
# Quick Planning Session
|
||||
|
||||
**Session ID**: ${sessionId}
|
||||
**Topic**: ${planningTopic}
|
||||
**Started**: ${startTime}
|
||||
**Completed**: ${completionTime}
|
||||
|
||||
---
|
||||
|
||||
## Executive Summary
|
||||
|
||||
${synthesis.executive_summary}
|
||||
|
||||
**Optimization Focus**: ${synthesis.optimization_focus}
|
||||
**Complexity**: ${synthesis.complexity_level}
|
||||
**Estimated Effort**: ${formatEffort(synthesis.estimated_effort)}
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
**Primary Pattern**: ${synthesis.architecture_approach}
|
||||
|
||||
**Key Components**:
|
||||
${synthesis.key_components.map((c, i) => `${i+1}. ${c.name}: ${c.responsibility}`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Implementation Strategy
|
||||
|
||||
**Technology Stack**:
|
||||
${synthesis.technology_stack.map(t => `- ${t}`).join('\n')}
|
||||
|
||||
**Phases**:
|
||||
${synthesis.phases.map((p, i) => `${i+1}. ${p.name} (${p.effort})`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
**Overall Risk Level**: ${synthesis.top_risks[0].risk_level}
|
||||
|
||||
**Top 3 Risks**:
|
||||
${synthesis.top_risks.map((r, i) => `
|
||||
${i+1}. **${r.title}** (Impact: ${r.impact})
|
||||
- Mitigation: ${r.mitigation}
|
||||
`).join('\n')}
|
||||
|
||||
**Testing Approach**: ${synthesis.testing_approach}
|
||||
|
||||
---
|
||||
|
||||
## Execution Plan
|
||||
|
||||
**Total Tasks**: ${synthesis.total_tasks}
|
||||
**Critical Path**: ${synthesis.critical_path_tasks.map(t => t.id).join(' → ')}
|
||||
|
||||
### Task Breakdown
|
||||
|
||||
${synthesis.tasks.map((task, i) => `
|
||||
${i+1}. **${task.id}: ${task.title}** (Effort: ${task.effort_estimate})
|
||||
- ${task.description}
|
||||
- Depends on: ${task.dependencies.join(', ') || 'none'}
|
||||
- Success: ${task.success_criteria}
|
||||
`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
**Recommended**: Execute with \`/workflow:unified-execute-with-file\` using:
|
||||
\`\`\`
|
||||
/workflow:unified-execute-with-file -p ${sessionFolder}/synthesis.json
|
||||
\`\`\`
|
||||
|
||||
---
|
||||
|
||||
## Artifacts
|
||||
|
||||
- **Perspectives**: ${sessionFolder}/perspectives.json (all agent findings)
|
||||
- **Conflicts**: ${sessionFolder}/conflicts.json (decision points and resolutions)
|
||||
- **Synthesis**: ${sessionFolder}/synthesis.json (task breakdown for execution)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.planning/{sessionId}/
|
||||
├── plan.md # Minimal, actionable planning doc
|
||||
├── perspectives.json # Multi-agent findings (architecture, impl, risk, decision)
|
||||
├── conflicts.json # Detected conflicts and resolutions (if any)
|
||||
├── synthesis.json # Task breakdown ready for execution
|
||||
└── synthesis.md # Human-readable execution plan
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Multi-Agent Roles
|
||||
|
||||
| Agent | Focus | Input | Output |
|
||||
|-------|-------|-------|--------|
|
||||
| **Gemini (Design)** | Architecture & design patterns | Topic + constraints | Components, interfaces, patterns, scalability |
|
||||
| **Codex (Pragmatic)** | Implementation reality | Topic + architecture | Tech stack, effort, phases, blockers |
|
||||
| **Claude (Validation)** | Risk & testing | Architecture + impl | Risk matrix, test strategy, monitoring |
|
||||
| **Gemini (Decision)** | Synthesis & strategy | All findings | Recommendations, tradeoffs, execution plan |
|
||||
|
||||
---
|
||||
|
||||
## Conflict Resolution Strategy
|
||||
|
||||
**Auto-Resolution for conflicts**:
|
||||
1. **Architecture vs Implementation**: Recommend design-for-feasibility approach
|
||||
2. **Scope vs Timeline**: Prioritize critical path, defer nice-to-haves
|
||||
3. **Quality vs Speed**: Suggest iterative approach (MVP + iterations)
|
||||
4. **Resource vs Effort**: Identify parallelizable tasks
|
||||
|
||||
**Require User Input for**:
|
||||
- Strategic choices (which feature to prioritize?)
|
||||
- Tool/technology decisions with strong team preferences
|
||||
- Budget/resource constraints not stated in planning topic
|
||||
|
||||
---
|
||||
|
||||
## Continue & Resume
|
||||
|
||||
```bash
|
||||
/workflow:quick-plan-with-file --continue "planning-topic"
|
||||
```
|
||||
|
||||
When continuing:
|
||||
1. Load existing plan.md and perspectives.json
|
||||
2. Identify what's incomplete
|
||||
3. Re-run affected agents (if planning has changed)
|
||||
4. Update plan.md with new findings
|
||||
5. Generate updated synthesis.json
|
||||
|
||||
---
|
||||
|
||||
## Integration Flow
|
||||
|
||||
```
|
||||
Input Source:
|
||||
├─ Raw task description
|
||||
├─ Brainstorm synthesis.json
|
||||
└─ Analysis conclusions.json
|
||||
↓
|
||||
/workflow:quick-plan-with-file
|
||||
↓
|
||||
plan.md + synthesis.json
|
||||
↓
|
||||
/workflow:unified-execute-with-file
|
||||
↓
|
||||
Implementation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Pattern 1: Quick Planning from Task
|
||||
|
||||
```bash
|
||||
# User has a task, needs rapid multi-perspective plan
|
||||
/workflow:quick-plan-with-file -y "实现实时通知系统,支持推送和WebSocket"
|
||||
# → Creates plan in ~5 minutes
|
||||
# → Ready for execution
|
||||
```
|
||||
|
||||
### Pattern 2: Convert Brainstorm to Executable Plan
|
||||
|
||||
```bash
|
||||
# User completed brainstorm, wants to convert top idea to executable plan
|
||||
/workflow:quick-plan-with-file --from brainstorm BS-notifications-2025-01-28
|
||||
# → Reads synthesis.json from brainstorm
|
||||
# → Generates implementation plan
|
||||
# → Ready for unified-execute-with-file
|
||||
```
|
||||
|
||||
### Pattern 3: From Analysis to Implementation
|
||||
|
||||
```bash
|
||||
# Analysis completed, now need execution plan
|
||||
/workflow:quick-plan-with-file --from analysis ANL-auth-architecture-2025-01-28
|
||||
# → Reads conclusions.json from analysis
|
||||
# → Generates planning with recommendations
|
||||
# → Output task breakdown
|
||||
```
|
||||
|
||||
### Pattern 4: Planning with Interactive Conflict Resolution
|
||||
|
||||
```bash
|
||||
# Full planning with user involvement in decision-making
|
||||
/workflow:quick-plan-with-file "新的支付流程集成"
|
||||
# → Without -y flag
|
||||
# → After conflict detection, asks user about tradeoffs
|
||||
# → Generates plan based on user preferences
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Comparison with Other Workflows
|
||||
|
||||
| Feature | brainstorm | analyze | quick-plan | plan |
|
||||
|---------|-----------|---------|-----------|------|
|
||||
| **Purpose** | Ideation | Investigation | Lightweight planning | Detailed planning |
|
||||
| **Multi-agent** | 3 perspectives | 2 CLI + explore | 4 concurrent agents | N/A (single) |
|
||||
| **Documentation** | Extensive | Extensive | Minimal | Standard |
|
||||
| **Output** | Ideas + synthesis | Conclusions | Executable tasks | IMPL_PLAN |
|
||||
| **Typical Duration** | 30-60 min | 20-30 min | 5-10 min | 15-20 min |
|
||||
| **User Interaction** | High (multi-round) | High (Q&A) | Low (decisions) | Medium |
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Agents conflict on approach | Arbitration agent decides, document in conflicts.json |
|
||||
| Missing critical files | Continue with available context, note limitations |
|
||||
| Insufficient task breakdown | Ask user for planning focus areas |
|
||||
| Effort estimate too high | Suggest MVP approach or phasing |
|
||||
| Unclear requirements | Ask clarifying questions via AskUserQuestion |
|
||||
| Agent timeout | Use last successful result, note partial analysis |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use when**:
|
||||
- You have clarity on WHAT but not HOW
|
||||
- Need rapid multi-perspective planning
|
||||
- Converting brainstorm/analysis into execution
|
||||
- Want minimal planning overhead
|
||||
|
||||
2. **Avoid when**:
|
||||
- Requirements are highly ambiguous (use brainstorm instead)
|
||||
- Need deep investigation (use analyze instead)
|
||||
- Want extensive planning document (use plan instead)
|
||||
- No tech stack clarity (use analyze first)
|
||||
|
||||
3. **For best results**:
|
||||
- Provide complete task/requirement description
|
||||
- Include constraints and success criteria
|
||||
- Specify preferences (speed vs quality vs risk)
|
||||
- Review conflicts.json and make conscious tradeoff decisions
|
||||
|
||||
---
|
||||
|
||||
## Next Steps After Planning
|
||||
|
||||
### Feed to Execution
|
||||
```bash
|
||||
/workflow:unified-execute-with-file -p .workflow/.planning/{sessionId}/synthesis.json
|
||||
```
|
||||
|
||||
### Detailed Planning if Needed
|
||||
```bash
|
||||
/workflow:plan "Based on quick-plan recommendations..."
|
||||
```
|
||||
|
||||
### Continuous Refinement
|
||||
```bash
|
||||
/workflow:quick-plan-with-file --continue "{topic}" # Update plan with new constraints
|
||||
```
|
||||
@@ -113,7 +113,40 @@ const taskId = taskIdMatch?.[1]
|
||||
- List existing tasks
|
||||
- Read `IMPL_PLAN.md` and `TODO_LIST.md`
|
||||
|
||||
**Output**: Session validated, context loaded, mode determined
|
||||
4. **Parse Execution Intent** (from requirements text):
|
||||
```javascript
|
||||
// Dynamic tool detection from cli-tools.json
|
||||
// Read enabled tools: ["gemini", "qwen", "codex", ...]
|
||||
const enabledTools = loadEnabledToolsFromConfig(); // See ~/.claude/cli-tools.json
|
||||
|
||||
// Build dynamic patterns from enabled tools
|
||||
function buildExecPatterns(tools) {
|
||||
const patterns = {
|
||||
agent: /改为\s*Agent\s*执行|使用\s*Agent\s*执行/i
|
||||
};
|
||||
tools.forEach(tool => {
|
||||
// Pattern: "使用 {tool} 执行" or "改用 {tool}"
|
||||
patterns[`cli_${tool}`] = new RegExp(
|
||||
`使用\\s*(${tool})\\s*执行|改用\\s*(${tool})`, 'i'
|
||||
);
|
||||
});
|
||||
return patterns;
|
||||
}
|
||||
|
||||
const execPatterns = buildExecPatterns(enabledTools);
|
||||
|
||||
let executionIntent = null
|
||||
for (const [key, pattern] of Object.entries(execPatterns)) {
|
||||
if (pattern.test(requirements)) {
|
||||
executionIntent = key.startsWith('cli_')
|
||||
? { method: 'cli', cli_tool: key.replace('cli_', '') }
|
||||
: { method: 'agent', cli_tool: null }
|
||||
break
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: Session validated, context loaded, mode determined, **executionIntent parsed**
|
||||
|
||||
---
|
||||
|
||||
@@ -356,7 +389,18 @@ const updated_task = {
|
||||
flow_control: {
|
||||
...task.flow_control,
|
||||
implementation_approach: [...updated_steps]
|
||||
}
|
||||
},
|
||||
// Update execution config if intent detected
|
||||
...(executionIntent && {
|
||||
meta: {
|
||||
...task.meta,
|
||||
execution_config: {
|
||||
method: executionIntent.method,
|
||||
cli_tool: executionIntent.cli_tool,
|
||||
enable_resume: executionIntent.method !== 'agent'
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Write({
|
||||
@@ -365,6 +409,8 @@ Write({
|
||||
});
|
||||
```
|
||||
|
||||
**Note**: Implementation approach steps are NO LONGER modified. CLI execution is controlled by task-level `meta.execution_config` only.
|
||||
|
||||
**Step 5.4: Create New Tasks** (if needed)
|
||||
|
||||
Generate complete task JSON with all required fields:
|
||||
@@ -570,3 +616,33 @@ A: 是,需要同步更新依赖任务
|
||||
|
||||
任务重规划完成! 更新 2 个任务
|
||||
```
|
||||
|
||||
### Task Replan - Change Execution Method
|
||||
|
||||
```bash
|
||||
/workflow:replan IMPL-001 "改用 Codex 执行"
|
||||
|
||||
# Semantic parsing detects executionIntent:
|
||||
# { method: 'cli', cli_tool: 'codex' }
|
||||
|
||||
# Execution (no interactive questions needed)
|
||||
✓ 创建备份
|
||||
✓ 更新 IMPL-001.json
|
||||
- meta.execution_config = { method: 'cli', cli_tool: 'codex', enable_resume: true }
|
||||
|
||||
任务执行方式已更新: Agent → CLI (codex)
|
||||
```
|
||||
|
||||
```bash
|
||||
/workflow:replan IMPL-002 "改为 Agent 执行"
|
||||
|
||||
# Semantic parsing detects executionIntent:
|
||||
# { method: 'agent', cli_tool: null }
|
||||
|
||||
# Execution
|
||||
✓ 创建备份
|
||||
✓ 更新 IMPL-002.json
|
||||
- meta.execution_config = { method: 'agent', cli_tool: null }
|
||||
|
||||
任务执行方式已更新: CLI → Agent
|
||||
```
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
---
|
||||
name: review-fix
|
||||
name: review-cycle-fix
|
||||
description: Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.
|
||||
argument-hint: "<export-file|review-dir> [--resume] [--max-iterations=N]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow Review-Fix Command
|
||||
# Workflow Review-Cycle-Fix Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Fix from exported findings file (session-based path)
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/fix-export-1706184622000.json
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/fix-export-1706184622000.json
|
||||
|
||||
# Fix from review directory (auto-discovers latest export)
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/
|
||||
|
||||
# Resume interrupted fix session
|
||||
/workflow:review-fix --resume
|
||||
/workflow:review-cycle-fix --resume
|
||||
|
||||
# Custom max retry attempts per finding
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/ --max-iterations=5
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/ --max-iterations=5
|
||||
```
|
||||
|
||||
**Fix Source**: Exported findings from review cycle dashboard
|
||||
@@ -764,8 +764,8 @@ After completing a module review, use the generated findings JSON for automated
|
||||
/workflow:review-module-cycle src/auth/**
|
||||
|
||||
# Step 2: Run automated fixes using dimension findings
|
||||
/workflow:review-fix .workflow/active/WFS-{session-id}/.review/
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
|
||||
```
|
||||
|
||||
See `/workflow:review-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
See `/workflow:review-cycle-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
|
||||
|
||||
@@ -775,8 +775,8 @@ After completing a review, use the generated findings JSON for automated fixing:
|
||||
/workflow:review-session-cycle
|
||||
|
||||
# Step 2: Run automated fixes using dimension findings
|
||||
/workflow:review-fix .workflow/active/WFS-{session-id}/.review/
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
|
||||
```
|
||||
|
||||
See `/workflow:review-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
See `/workflow:review-cycle-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
| Responsibility | Description |
|
||||
|---------------|-------------|
|
||||
| **Detect Conflicts** | Analyze plan vs existing code inconsistencies |
|
||||
| **Scenario Uniqueness** | **NEW**: Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Scenario Uniqueness** | Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Generate Strategies** | Provide 2-4 resolution options per conflict |
|
||||
| **Iterative Clarification** | **NEW**: Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | **NEW**: Dynamically update strategies based on user clarifications |
|
||||
| **Iterative Clarification** | Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | Dynamically update strategies based on user clarifications |
|
||||
| **CLI Analysis** | Use Gemini/Qwen (Claude fallback) |
|
||||
| **User Decision** | Present options ONE BY ONE, never auto-apply |
|
||||
| **Direct Text Output** | Output questions via text directly, NEVER use bash echo/printf |
|
||||
@@ -57,7 +57,7 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
- Breaking updates
|
||||
|
||||
### 5. Module Scenario Overlap
|
||||
- **NEW**: Functional overlap between new and existing modules
|
||||
- Functional overlap between new and existing modules
|
||||
- Scenario boundary ambiguity
|
||||
- Duplicate responsibility detection
|
||||
- Module merge/split decisions
|
||||
@@ -134,7 +134,7 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
### 1. Load Context
|
||||
- Read existing files from conflict_detection.existing_files
|
||||
- Load plan from .workflow/active/{session_id}/.process/context-package.json
|
||||
- **NEW**: Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Extract role analyses and requirements
|
||||
|
||||
### 2. Execute CLI Analysis (Enhanced with Exploration + Scenario Uniqueness)
|
||||
@@ -186,28 +186,18 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
- modifications.old_content: 20-100 chars for unique Edit tool matching
|
||||
- modifications.new_content: preserves markdown formatting
|
||||
- modification_suggestions: 2-5 actionable suggestions for custom handling
|
||||
`)
|
||||
```
|
||||
|
||||
**Agent Internal Flow** (Enhanced):
|
||||
```
|
||||
1. Load context package
|
||||
2. Check conflict_risk (exit if none/low)
|
||||
3. Read existing files + plan artifacts
|
||||
4. Run CLI analysis (Gemini→Qwen→Claude) with enhanced tasks:
|
||||
- Standard conflict detection (Architecture/API/Data/Dependency)
|
||||
- **NEW: Module scenario uniqueness detection**
|
||||
* Extract new module functionality from plan
|
||||
* Search all existing modules with similar keywords/functionality
|
||||
* Compare scenario coverage and responsibilities
|
||||
* Identify functional overlaps and boundary ambiguities
|
||||
* Generate ModuleOverlap conflicts with overlap_analysis
|
||||
5. Parse conflict findings (including ModuleOverlap category)
|
||||
6. Generate 2-4 strategies per conflict:
|
||||
- Include modifications for each strategy
|
||||
- **For ModuleOverlap**: Add clarification_needed questions for boundary definition
|
||||
7. Return JSON to stdout (NOT file write)
|
||||
8. Return execution log path
|
||||
### 5. Planning Notes Record (REQUIRED)
|
||||
After analysis complete, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/{session_id}/planning-notes.md
|
||||
**Location**: Under "## Conflict Decisions (Phase 3)" section
|
||||
**Format**:
|
||||
\`\`\`
|
||||
### [Conflict-Resolution Agent] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结冲突类型、解决策略、关键决策等]
|
||||
\`\`\`
|
||||
`)
|
||||
```
|
||||
|
||||
### Phase 3: User Interaction Loop
|
||||
|
||||
@@ -35,7 +35,7 @@ Step 1: Context-Package Detection
|
||||
├─ Valid package exists → Return existing (skip execution)
|
||||
└─ No valid package → Continue to Step 2
|
||||
|
||||
Step 2: Complexity Assessment & Parallel Explore (NEW)
|
||||
Step 2: Complexity Assessment & Parallel Explore
|
||||
├─ Analyze task_description → classify Low/Medium/High
|
||||
├─ Select exploration angles (1-4 based on complexity)
|
||||
├─ Launch N cli-explore-agents in parallel
|
||||
@@ -213,19 +213,37 @@ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationM
|
||||
**Only execute after Step 2 completes**
|
||||
|
||||
```javascript
|
||||
// Load user intent from planning-notes.md (from Phase 1)
|
||||
const planningNotesPath = `.workflow/active/${session_id}/planning-notes.md`;
|
||||
let userIntent = { goal: task_description, key_constraints: "None specified" };
|
||||
|
||||
if (file_exists(planningNotesPath)) {
|
||||
const notesContent = Read(planningNotesPath);
|
||||
const goalMatch = notesContent.match(/\*\*GOAL\*\*:\s*(.+)/);
|
||||
const constraintsMatch = notesContent.match(/\*\*KEY_CONSTRAINTS\*\*:\s*(.+)/);
|
||||
if (goalMatch) userIntent.goal = goalMatch[1].trim();
|
||||
if (constraintsMatch) userIntent.key_constraints = constraintsMatch[1].trim();
|
||||
}
|
||||
|
||||
Task(
|
||||
subagent_type="context-search-agent",
|
||||
run_in_background=false,
|
||||
description="Gather comprehensive context for plan",
|
||||
prompt=`
|
||||
## Execution Mode
|
||||
**PLAN MODE** (Comprehensive) - Full Phase 1-3 execution
|
||||
**PLAN MODE** (Comprehensive) - Full Phase 1-3 execution with priority sorting
|
||||
|
||||
## Session Information
|
||||
- **Session ID**: ${session_id}
|
||||
- **Task Description**: ${task_description}
|
||||
- **Output Path**: .workflow/${session_id}/.process/context-package.json
|
||||
|
||||
## User Intent (from Phase 1 - Planning Notes)
|
||||
**GOAL**: ${userIntent.goal}
|
||||
**KEY_CONSTRAINTS**: ${userIntent.key_constraints}
|
||||
|
||||
This is the PRIMARY context source - all subsequent analysis must align with user intent.
|
||||
|
||||
## Exploration Input (from Step 2)
|
||||
- **Manifest**: ${sessionFolder}/explorations-manifest.json
|
||||
- **Exploration Count**: ${explorationManifest.exploration_count}
|
||||
@@ -245,7 +263,13 @@ Execute complete context-search-agent workflow for implementation planning:
|
||||
4. **Analysis**: Extract keywords, determine scope, classify complexity based on task description and project state
|
||||
|
||||
### Phase 2: Multi-Source Context Discovery
|
||||
Execute all discovery tracks:
|
||||
Execute all discovery tracks (WITH USER INTENT INTEGRATION):
|
||||
- **Track -1**: User Intent & Priority Foundation (EXECUTE FIRST)
|
||||
- Load user intent (GOAL, KEY_CONSTRAINTS) from session input
|
||||
- Map user requirements to codebase entities (files, modules, patterns)
|
||||
- Establish baseline priority scores based on user goal alignment
|
||||
- Output: user_intent_mapping.json with preliminary priority scores
|
||||
|
||||
- **Track 0**: Exploration Synthesis (load ${sessionFolder}/explorations-manifest.json, prioritize critical_files, deduplicate patterns/integration_points)
|
||||
- **Track 1**: Historical archive analysis (query manifest.json for lessons learned)
|
||||
- **Track 2**: Reference documentation (CLAUDE.md, architecture docs)
|
||||
@@ -254,13 +278,45 @@ Execute all discovery tracks:
|
||||
|
||||
### Phase 3: Synthesis, Assessment & Packaging
|
||||
1. Apply relevance scoring and build dependency graph
|
||||
2. **Synthesize 4-source data**: Merge findings from all sources (archive > docs > code > web). **Prioritize the context from `project-tech.json`** for architecture and tech stack unless code analysis reveals it's outdated.
|
||||
3. **Populate `project_context`**: Directly use the `overview` from `project-tech.json` to fill the `project_context` section. Include description, technology_stack, architecture, and key_components.
|
||||
4. **Populate `project_guidelines`**: Load conventions, constraints, and learnings from `project-guidelines.json` into a dedicated section.
|
||||
5. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
|
||||
6. Perform conflict detection with risk assessment
|
||||
7. **Inject historical conflicts** from archive analysis into conflict_detection
|
||||
8. Generate and validate context-package.json
|
||||
2. **Synthesize 5-source data** (including Track -1): Merge findings from all sources
|
||||
- Priority order: User Intent > Archive > Docs > Exploration > Code > Web
|
||||
- **Prioritize the context from `project-tech.json`** for architecture and tech stack unless code analysis reveals it's outdated
|
||||
3. **Context Priority Sorting**:
|
||||
a. Combine scores from Track -1 (user intent alignment) + relevance scores + exploration critical_files
|
||||
b. Classify files into priority tiers:
|
||||
- **Critical** (score ≥ 0.85): Directly mentioned in user goal OR exploration critical_files
|
||||
- **High** (0.70-0.84): Key dependencies, patterns required for goal
|
||||
- **Medium** (0.50-0.69): Supporting files, indirect dependencies
|
||||
- **Low** (< 0.50): Contextual awareness only
|
||||
c. Generate dependency_order: Based on dependency graph + user goal sequence
|
||||
d. Document sorting_rationale: Explain prioritization logic
|
||||
|
||||
4. **Populate `project_context`**: Directly use the `overview` from `project-tech.json` to fill the `project_context` section. Include description, technology_stack, architecture, and key_components.
|
||||
5. **Populate `project_guidelines`**: Load conventions, constraints, and learnings from `project-guidelines.json` into a dedicated section.
|
||||
6. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
|
||||
7. Perform conflict detection with risk assessment
|
||||
8. **Inject historical conflicts** from archive analysis into conflict_detection
|
||||
9. **Generate prioritized_context section**:
|
||||
```json
|
||||
{
|
||||
"prioritized_context": {
|
||||
"user_intent": {
|
||||
"goal": "...",
|
||||
"scope": "...",
|
||||
"key_constraints": ["..."]
|
||||
},
|
||||
"priority_tiers": {
|
||||
"critical": [{ "path": "...", "relevance": 0.95, "rationale": "..." }],
|
||||
"high": [...],
|
||||
"medium": [...],
|
||||
"low": [...]
|
||||
},
|
||||
"dependency_order": ["module1", "module2", "module3"],
|
||||
"sorting_rationale": "Based on user goal alignment (Track -1), exploration critical files, and dependency graph analysis"
|
||||
}
|
||||
}
|
||||
```
|
||||
10. Generate and validate context-package.json with prioritized_context field
|
||||
|
||||
## Output Requirements
|
||||
Complete context-package.json with:
|
||||
@@ -272,6 +328,7 @@ Complete context-package.json with:
|
||||
- **brainstorm_artifacts**: {guidance_specification, role_analyses[], synthesis_output} with content
|
||||
- **conflict_detection**: {risk_level, risk_factors, affected_modules[], mitigation_strategy, historical_conflicts[]}
|
||||
- **exploration_results**: {manifest_path, exploration_count, angles, explorations[], aggregated_insights} (from Track 0)
|
||||
- **prioritized_context**: {user_intent, priority_tiers{critical, high, medium, low}, dependency_order[], sorting_rationale}
|
||||
|
||||
## Quality Validation
|
||||
Before completion verify:
|
||||
@@ -282,6 +339,17 @@ Before completion verify:
|
||||
- [ ] No sensitive data exposed
|
||||
- [ ] Total files ≤50 (prioritize high-relevance)
|
||||
|
||||
## Planning Notes Record (REQUIRED)
|
||||
After completing context-package.json, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/${session_id}/planning-notes.md
|
||||
**Location**: Under "## Context Findings (Phase 2)" section
|
||||
**Format**:
|
||||
\`\`\`
|
||||
### [Context-Search Agent] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结关键发现,如探索角度、关键文件、冲突风险等]
|
||||
\`\`\`
|
||||
|
||||
Execute autonomously following agent documentation.
|
||||
Report completion with statistics.
|
||||
`
|
||||
@@ -326,116 +394,11 @@ Refer to `context-search-agent.md` Phase 3.7 for complete `context-package.json`
|
||||
- **brainstorm_artifacts**: Brainstorm documents with full content (if exists)
|
||||
- **conflict_detection**: Risk assessment with mitigation strategies and historical conflicts
|
||||
- **exploration_results**: Aggregated exploration insights (from parallel explore phase)
|
||||
|
||||
## Historical Archive Analysis
|
||||
|
||||
### Track 1: Query Archive Manifest
|
||||
|
||||
The context-search-agent MUST perform historical archive analysis as Track 1 in Phase 2:
|
||||
|
||||
**Step 1: Check for Archive Manifest**
|
||||
```bash
|
||||
# Check if archive manifest exists
|
||||
if [[ -f .workflow/archives/manifest.json ]]; then
|
||||
# Manifest available for querying
|
||||
fi
|
||||
```
|
||||
|
||||
**Step 2: Extract Task Keywords**
|
||||
```javascript
|
||||
// From current task description, extract key entities and operations
|
||||
const keywords = extractKeywords(task_description);
|
||||
// Examples: ["User", "model", "authentication", "JWT", "reporting"]
|
||||
```
|
||||
|
||||
**Step 3: Search Archive for Relevant Sessions**
|
||||
```javascript
|
||||
// Query manifest for sessions with matching tags or descriptions
|
||||
const relevantArchives = archives.filter(archive => {
|
||||
return archive.tags.some(tag => keywords.includes(tag)) ||
|
||||
keywords.some(kw => archive.description.toLowerCase().includes(kw.toLowerCase()));
|
||||
});
|
||||
```
|
||||
|
||||
**Step 4: Extract Watch Patterns**
|
||||
```javascript
|
||||
// For each relevant archive, check watch_patterns for applicability
|
||||
const historicalConflicts = [];
|
||||
|
||||
relevantArchives.forEach(archive => {
|
||||
archive.lessons.watch_patterns?.forEach(pattern => {
|
||||
// Check if pattern trigger matches current task
|
||||
if (isPatternRelevant(pattern.pattern, task_description)) {
|
||||
historicalConflicts.push({
|
||||
source_session: archive.session_id,
|
||||
pattern: pattern.pattern,
|
||||
action: pattern.action,
|
||||
files_to_check: pattern.related_files,
|
||||
archived_at: archive.archived_at
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**Step 5: Inject into Context Package**
|
||||
```json
|
||||
{
|
||||
"conflict_detection": {
|
||||
"risk_level": "medium",
|
||||
"risk_factors": ["..."],
|
||||
"affected_modules": ["..."],
|
||||
"mitigation_strategy": "...",
|
||||
"historical_conflicts": [
|
||||
{
|
||||
"source_session": "WFS-auth-feature",
|
||||
"pattern": "When modifying User model",
|
||||
"action": "Check reporting-service and auditing-service dependencies",
|
||||
"files_to_check": ["src/models/User.ts", "src/services/reporting.ts"],
|
||||
"archived_at": "2025-09-16T09:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Risk Level Escalation
|
||||
|
||||
If `historical_conflicts` array is not empty, minimum risk level should be "medium":
|
||||
|
||||
```javascript
|
||||
if (historicalConflicts.length > 0 && currentRisk === "low") {
|
||||
conflict_detection.risk_level = "medium";
|
||||
conflict_detection.risk_factors.push(
|
||||
`${historicalConflicts.length} historical conflict pattern(s) detected from past sessions`
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Archive Query Algorithm
|
||||
|
||||
```markdown
|
||||
1. IF .workflow/archives/manifest.json does NOT exist → Skip Track 1, continue to Track 2
|
||||
2. IF manifest exists:
|
||||
a. Load manifest.json
|
||||
b. Extract keywords from task_description (nouns, verbs, technical terms)
|
||||
c. Filter archives where:
|
||||
- ANY tag matches keywords (case-insensitive) OR
|
||||
- description contains keywords (case-insensitive substring match)
|
||||
d. For each relevant archive:
|
||||
- Read lessons.watch_patterns array
|
||||
- Check if pattern.pattern keywords overlap with task_description
|
||||
- If relevant: Add to historical_conflicts array
|
||||
e. IF historical_conflicts.length > 0:
|
||||
- Set risk_level = max(current_risk, "medium")
|
||||
- Add to risk_factors
|
||||
3. Continue to Track 2 (reference documentation)
|
||||
```
|
||||
- **prioritized_context**: Pre-sorted context with user intent and priority tiers (critical/high/medium/low)
|
||||
|
||||
## Notes
|
||||
|
||||
- **Detection-first**: Always check for existing package before invoking agent
|
||||
- **Dual project file integration**: Agent reads both `.workflow/project-tech.json` (tech analysis) and `.workflow/project-guidelines.json` (user constraints) as primary sources
|
||||
- **Guidelines injection**: Project guidelines are included in context-package to ensure task generation respects user-defined constraints
|
||||
- **No redundancy**: This command is a thin orchestrator, all logic in agent
|
||||
- **User intent integration**: Load user intent from planning-notes.md (Phase 1 output)
|
||||
- **Output**: Generates `context-package.json` with `prioritized_context` field
|
||||
- **Plan-specific**: Use this for implementation planning; brainstorm mode uses direct agent call
|
||||
|
||||
@@ -19,6 +19,10 @@ Generate implementation planning documents (IMPL_PLAN.md, task JSONs, TODO_LIST.
|
||||
## Core Philosophy
|
||||
- **Planning Only**: Generate planning documents (IMPL_PLAN.md, task JSONs, TODO_LIST.md) - does NOT implement code
|
||||
- **Agent-Driven Document Generation**: Delegate plan generation to action-planning-agent
|
||||
- **NO Redundant Context Sorting**: Context priority sorting is ALREADY completed in context-gather Phase 2/3
|
||||
- Use `context-package.json.prioritized_context` directly
|
||||
- DO NOT re-sort files or re-compute priorities
|
||||
- `priority_tiers` and `dependency_order` are pre-computed and ready-to-use
|
||||
- **N+1 Parallel Planning**: Auto-detect multi-module projects, enable parallel planning (2+1 or 3+1 mode)
|
||||
- **Progressive Loading**: Load context incrementally (Core → Selective → On-Demand) due to analysis.md file size
|
||||
- **Memory-First**: Reuse loaded documents from conversation memory
|
||||
@@ -161,12 +165,13 @@ const userConfig = {
|
||||
|
||||
### Phase 1: Context Preparation & Module Detection (Command Responsibility)
|
||||
|
||||
**Command prepares session paths, metadata, and detects module structure.**
|
||||
**Command prepares session paths, metadata, detects module structure. Context priority sorting is NOT performed here - it's already completed in context-gather Phase 2/3.**
|
||||
|
||||
**Session Path Structure**:
|
||||
```
|
||||
.workflow/active/WFS-{session-id}/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── planning-notes.md # Consolidated planning notes
|
||||
├── .process/
|
||||
│ └── context-package.json # Context package with artifact catalog
|
||||
├── .task/ # Output: Task JSON files
|
||||
@@ -248,9 +253,21 @@ IMPORTANT: This is PLANNING ONLY - you are generating planning documents, NOT im
|
||||
|
||||
CRITICAL: Follow the progressive loading strategy defined in agent specification (load analysis.md files incrementally due to file size)
|
||||
|
||||
## PLANNING NOTES (PHASE 1-3 CONTEXT)
|
||||
Load: .workflow/active/{session-id}/planning-notes.md
|
||||
|
||||
This document contains:
|
||||
- User Intent: Original GOAL and KEY_CONSTRAINTS from Phase 1
|
||||
- Context Findings: Critical files, architecture, and constraints from Phase 2
|
||||
- Conflict Decisions: Resolved conflicts and planning constraints from Phase 3
|
||||
- Consolidated Constraints: All constraints from all phases
|
||||
|
||||
**USAGE**: Read planning-notes.md FIRST. Use Consolidated Constraints list to guide task sequencing and dependencies.
|
||||
|
||||
## SESSION PATHS
|
||||
Input:
|
||||
- Session Metadata: .workflow/active/{session-id}/workflow-session.json
|
||||
- Planning Notes: .workflow/active/{session-id}/planning-notes.md
|
||||
- Context Package: .workflow/active/{session-id}/.process/context-package.json
|
||||
|
||||
Output:
|
||||
@@ -278,7 +295,17 @@ CLI Resume Support (MANDATORY for all CLI commands):
|
||||
- Read previous task's cliExecutionId from session state
|
||||
- Format: ccw cli -p "[prompt]" --resume ${previousCliId} --tool ${tool} --mode write
|
||||
|
||||
## EXPLORATION CONTEXT (from context-package.exploration_results)
|
||||
## PRIORITIZED CONTEXT (from context-package.prioritized_context) - ALREADY SORTED
|
||||
Context sorting is ALREADY COMPLETED in context-gather Phase 2/3. DO NOT re-sort.
|
||||
Direct usage:
|
||||
- **user_intent**: Use goal/scope/key_constraints for task alignment
|
||||
- **priority_tiers.critical**: These files are PRIMARY focus for task generation
|
||||
- **priority_tiers.high**: These files are SECONDARY focus
|
||||
- **dependency_order**: Use this for task sequencing - already computed
|
||||
- **sorting_rationale**: Reference for understanding priority decisions
|
||||
|
||||
## EXPLORATION CONTEXT (from context-package.exploration_results) - SUPPLEMENT ONLY
|
||||
If prioritized_context is incomplete, fall back to exploration_results:
|
||||
- Load exploration_results from context-package.json
|
||||
- Use aggregated_insights.critical_files for focus_paths generation
|
||||
- Apply aggregated_insights.constraints to acceptance criteria
|
||||
@@ -298,8 +325,10 @@ CLI Resume Support (MANDATORY for all CLI commands):
|
||||
- 6-field schema (id, title, status, context_package_path, meta, context, flow_control)
|
||||
- Quantified requirements with explicit counts
|
||||
- Artifacts integration from context package
|
||||
- **focus_paths enhanced with exploration critical_files**
|
||||
- Flow control with pre_analysis steps (include exploration integration_points analysis)
|
||||
- **focus_paths generated directly from prioritized_context.priority_tiers (critical + high)**
|
||||
- NO re-sorting or re-prioritization - use pre-computed tiers as-is
|
||||
- Critical files are PRIMARY focus, High files are SECONDARY
|
||||
- Flow control with pre_analysis steps (use prioritized_context.dependency_order for task sequencing)
|
||||
- **CLI Execution IDs and strategies (MANDATORY)**
|
||||
|
||||
2. Implementation Plan (IMPL_PLAN.md)
|
||||
@@ -347,6 +376,19 @@ Hard Constraints:
|
||||
- IMPL_PLAN.md created with complete structure
|
||||
- TODO_LIST.md generated matching task JSONs
|
||||
- Return completion status with document count and task breakdown summary
|
||||
|
||||
## PLANNING NOTES RECORD (REQUIRED)
|
||||
After completing all documents, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/{session_id}/planning-notes.md
|
||||
**Location**: Create new section after "## Consolidated Constraints"
|
||||
**Format**:
|
||||
\`\`\`
|
||||
## Task Generation (Phase 4)
|
||||
|
||||
### [Action-Planning Agent] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结任务数量、关键任务、依赖关系等]
|
||||
\`\`\`
|
||||
`
|
||||
)
|
||||
```
|
||||
@@ -376,16 +418,22 @@ IMPORTANT: Generate Task JSONs ONLY. IMPL_PLAN.md and TODO_LIST.md by Phase 3 Co
|
||||
|
||||
CRITICAL: Follow the progressive loading strategy defined in agent specification (load analysis.md files incrementally due to file size)
|
||||
|
||||
## PLANNING NOTES (PHASE 1-3 CONTEXT)
|
||||
Load: .workflow/active/{session-id}/planning-notes.md
|
||||
|
||||
This document contains consolidated constraints and user intent to guide module-scoped task generation.
|
||||
|
||||
## MODULE SCOPE
|
||||
- Module: ${module.name} (${module.type})
|
||||
- Focus Paths: ${module.paths.join(', ')}
|
||||
- Task ID Prefix: IMPL-${module.prefix}
|
||||
- Task Limit: ≤9 tasks (hard limit for this module)
|
||||
- Task Limit: ≤6 tasks (hard limit for this module)
|
||||
- Other Modules: ${otherModules.join(', ')} (reference only, do NOT generate tasks for them)
|
||||
|
||||
## SESSION PATHS
|
||||
Input:
|
||||
- Session Metadata: .workflow/active/{session-id}/workflow-session.json
|
||||
- Planning Notes: .workflow/active/{session-id}/planning-notes.md
|
||||
- Context Package: .workflow/active/{session-id}/.process/context-package.json
|
||||
|
||||
Output:
|
||||
@@ -411,7 +459,16 @@ CLI Resume Support (MANDATORY for all CLI commands):
|
||||
- Read previous task's cliExecutionId from session state
|
||||
- Format: ccw cli -p "[prompt]" --resume ${previousCliId} --tool ${tool} --mode write
|
||||
|
||||
## EXPLORATION CONTEXT (from context-package.exploration_results)
|
||||
## PRIORITIZED CONTEXT (from context-package.prioritized_context) - ALREADY SORTED
|
||||
Context sorting is ALREADY COMPLETED in context-gather Phase 2/3. DO NOT re-sort.
|
||||
Filter by module scope (${module.paths.join(', ')}):
|
||||
- **user_intent**: Use for task alignment within module
|
||||
- **priority_tiers.critical**: Filter for files in ${module.paths.join(', ')} → PRIMARY focus
|
||||
- **priority_tiers.high**: Filter for files in ${module.paths.join(', ')} → SECONDARY focus
|
||||
- **dependency_order**: Use module-relevant entries for task sequencing
|
||||
|
||||
## EXPLORATION CONTEXT (from context-package.exploration_results) - SUPPLEMENT ONLY
|
||||
If prioritized_context is incomplete for this module, fall back to exploration_results:
|
||||
- Load exploration_results from context-package.json
|
||||
- Filter for ${module.name} module: Use aggregated_insights.critical_files matching ${module.paths.join(', ')}
|
||||
- Apply module-relevant constraints from aggregated_insights.constraints
|
||||
@@ -438,8 +495,10 @@ Task JSON Files (.task/IMPL-${module.prefix}*.json):
|
||||
- Task ID format: IMPL-${module.prefix}1, IMPL-${module.prefix}2, ...
|
||||
- Quantified requirements with explicit counts
|
||||
- Artifacts integration from context package (filtered for ${module.name})
|
||||
- **focus_paths enhanced with exploration critical_files (module-scoped)**
|
||||
- Flow control with pre_analysis steps (include exploration integration_points analysis)
|
||||
- **focus_paths generated directly from prioritized_context.priority_tiers filtered by ${module.paths.join(', ')}**
|
||||
- NO re-sorting - use pre-computed tiers filtered for this module
|
||||
- Critical files are PRIMARY focus, High files are SECONDARY
|
||||
- Flow control with pre_analysis steps (use prioritized_context.dependency_order for module task sequencing)
|
||||
- **CLI Execution IDs and strategies (MANDATORY)**
|
||||
- Focus ONLY on ${module.name} module scope
|
||||
|
||||
@@ -482,6 +541,21 @@ Hard Constraints:
|
||||
- Cross-module dependencies use CROSS:: placeholder format consistently
|
||||
- Focus paths scoped to ${module.paths.join(', ')} only
|
||||
- Return: task count, task IDs, dependency summary (internal + cross-module)
|
||||
|
||||
## PLANNING NOTES RECORD (REQUIRED)
|
||||
After completing module task JSONs, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/{session_id}/planning-notes.md
|
||||
**Location**: Create new section after "## Consolidated Constraints" (if not exists)
|
||||
**Format**:
|
||||
\`\`\`
|
||||
## Task Generation (Phase 4)
|
||||
|
||||
### [Action-Planning Agent - ${module.name}] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结本模块任务数量、关键任务等]
|
||||
\`\`\`
|
||||
|
||||
**Note**: Multiple module agents will append their records. Phase 3 Integration Coordinator will add final summary.
|
||||
`
|
||||
)
|
||||
);
|
||||
@@ -562,6 +636,17 @@ Module Count: ${modules.length}
|
||||
- No CROSS:: placeholders remaining in task JSONs
|
||||
- IMPL_PLAN.md and TODO_LIST.md generated with multi-module structure
|
||||
- Return: task count, per-module breakdown, resolved dependency count
|
||||
|
||||
## PLANNING NOTES RECORD (REQUIRED)
|
||||
After completing integration, append final summary to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/{session_id}/planning-notes.md
|
||||
**Location**: Under "## Task Generation (Phase 4)" section (after module agent records)
|
||||
**Format**:
|
||||
\`\`\`
|
||||
### [Integration Coordinator] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结总任务数、跨模块依赖解决情况等]
|
||||
\`\`\`
|
||||
`
|
||||
)
|
||||
```
|
||||
@@ -579,5 +664,4 @@ function resolveCrossModuleDependency(placeholder, allTasks) {
|
||||
? candidates.sort((a, b) => a.id.localeCompare(b.id))[0].id
|
||||
: placeholder; // Keep for manual resolution
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
807
.claude/commands/workflow/unified-execute-with-file.md
Normal file
807
.claude/commands/workflow/unified-execute-with-file.md
Normal file
@@ -0,0 +1,807 @@
|
||||
---
|
||||
name: unified-execute-with-file
|
||||
description: Universal execution engine for consuming any planning/brainstorm/analysis output with minimal progress tracking, multi-agent coordination, and incremental execution
|
||||
argument-hint: "[-y|--yes] [-p|--plan <path>] [-m|--mode sequential|parallel] [\"execution context or task name\"]"
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm execution decisions, use default parallel strategy where possible.
|
||||
|
||||
# Workflow Unified-Execute-With-File Command (/workflow:unified-execute-with-file)
|
||||
|
||||
## Overview
|
||||
|
||||
Universal execution engine that consumes **any** planning/brainstorm/analysis output and executes it with minimal progress tracking. Coordinates multiple agents (subagents or CLI tools), handles dependencies, and maintains execution timeline in a single minimal document.
|
||||
|
||||
**Core workflow**: Load Plan → Parse Tasks → Coordinate Agents → Execute → Track Progress → Verify
|
||||
|
||||
**Key features**:
|
||||
- **Plan Format Agnostic**: Consumes IMPL_PLAN.md, brainstorm.md, analysis conclusions, debug resolutions
|
||||
- **execution.md**: Single source of truth for progress, execution timeline, and results
|
||||
- **Multi-Agent Orchestration**: Parallel execution where possible, sequential where needed
|
||||
- **Incremental Execution**: Resume from failure point, no re-execution of completed tasks
|
||||
- **Dependency Management**: Automatic topological sort and wait strategy
|
||||
- **Real-Time Progress**: TodoWrite integration for live task status
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:unified-execute-with-file [FLAGS] [EXECUTION_CONTEXT]
|
||||
|
||||
# Flags
|
||||
-y, --yes Auto-confirm execution decisions, use defaults
|
||||
-p, --plan <path> Explicitly specify plan file (auto-detected if omitted)
|
||||
-m, --mode <mode> Execution strategy: sequential (strict order) | parallel (smart dependencies)
|
||||
|
||||
# Arguments
|
||||
[execution-context] Optional: Task category, module name, or execution focus (for filtering/priority)
|
||||
|
||||
# Examples
|
||||
/workflow:unified-execute-with-file # Auto-detect and execute latest plan
|
||||
/workflow:unified-execute-with-file -p .workflow/plans/auth-plan.md # Execute specific plan
|
||||
/workflow:unified-execute-with-file -y "auth module" # Auto-execute with context focus
|
||||
/workflow:unified-execute-with-file -m sequential "payment feature" # Sequential execution
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Plan Detection:
|
||||
├─ Check for IMPL_PLAN.md or task JSON files in .workflow/
|
||||
├─ Or use explicit --plan path
|
||||
├─ Or auto-detect from git branch/issue context
|
||||
└─ Load plan metadata and task definitions
|
||||
|
||||
Session Initialization:
|
||||
├─ Create .workflow/.execution/{sessionId}/
|
||||
├─ Initialize execution.md with plan summary
|
||||
├─ Parse all tasks, identify dependencies
|
||||
├─ Determine execution strategy (parallel/sequential)
|
||||
└─ Initialize progress tracking
|
||||
|
||||
Pre-Execution Validation:
|
||||
├─ Check task feasibility (required files exist, tools available)
|
||||
├─ Validate dependency graph (detect cycles)
|
||||
├─ Ask user to confirm execution (unless --yes)
|
||||
└─ Display execution plan and timeline estimate
|
||||
|
||||
Task Execution Loop (Parallel/Sequential):
|
||||
├─ Select next executable tasks (dependencies satisfied)
|
||||
├─ Launch agents in parallel (if strategy=parallel)
|
||||
├─ Monitor execution, wait for completion
|
||||
├─ Capture outputs, log results
|
||||
├─ Update execution.md with progress
|
||||
├─ Mark tasks complete/failed
|
||||
└─ Repeat until all done or max failures reached
|
||||
|
||||
Error Handling:
|
||||
├─ Task failure → Ask user: retry|skip|abort
|
||||
├─ Dependency failure → Auto-skip dependent tasks
|
||||
├─ Output conflict → Ask for resolution
|
||||
└─ Timeout → Mark as timeout, continue or escalate
|
||||
|
||||
Completion:
|
||||
├─ Mark session complete
|
||||
├─ Summarize execution results in execution.md
|
||||
├─ Generate completion report (statistics, failures, recommendations)
|
||||
└─ Offer follow-up: review|debug|enhance
|
||||
|
||||
Output:
|
||||
├─ .workflow/.execution/{sessionId}/execution.md (plan and overall status)
|
||||
├─ .workflow/.execution/{sessionId}/execution-events.md (SINGLE SOURCE OF TRUTH - all task executions)
|
||||
└─ Generated files in project directories (src/*, tests/*, docs/*, etc.)
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Plan Detection
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
// Plan detection strategy
|
||||
let planPath = $ARGUMENTS.match(/--plan\s+(\S+)/)?.[1]
|
||||
|
||||
if (!planPath) {
|
||||
// Auto-detect: check recent workflow artifacts
|
||||
const candidates = [
|
||||
'.workflow/.plan/IMPL_PLAN.md',
|
||||
'.workflow/plans/IMPL_PLAN.md',
|
||||
'.workflow/IMPL_PLAN.md',
|
||||
]
|
||||
|
||||
// Find most recent plan
|
||||
planPath = findMostRecentPlan(candidates)
|
||||
|
||||
if (!planPath) {
|
||||
// Check for task JSONs
|
||||
const taskJsons = glob('.workflow/**/*.json').filter(f => f.includes('IMPL-') || f.includes('task'))
|
||||
if (taskJsons.length > 0) {
|
||||
planPath = taskJsons[0] // Primary task
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!planPath) {
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "未找到执行规划。请选择方式:",
|
||||
header: "Plan Source",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "浏览文件", description: "从 .workflow 目录选择" },
|
||||
{ label: "使用最近规划", description: "从git提交消息推断" },
|
||||
{ label: "手动输入路径", description: "直接指定规划文件路径" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
// Parse plan and extract tasks
|
||||
const planContent = Read(planPath)
|
||||
const plan = parsePlan(planContent, planPath) // Format-agnostic parser
|
||||
|
||||
const executionId = `EXEC-${plan.slug}-${getUtc8ISOString().substring(0, 10)}-${randomId(4)}`
|
||||
const executionFolder = `.workflow/.execution/${executionId}`
|
||||
const executionPath = `${executionFolder}/execution.md`
|
||||
const eventLogPath = `${executionFolder}/execution-events.md`
|
||||
|
||||
bash(`mkdir -p ${executionFolder}`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Plan Format Parsers
|
||||
|
||||
Support multiple plan sources:
|
||||
|
||||
```javascript
|
||||
function parsePlan(content, filePath) {
|
||||
const ext = filePath.split('.').pop()
|
||||
|
||||
if (filePath.includes('IMPL_PLAN')) {
|
||||
return parseImplPlan(content) // From /workflow:plan
|
||||
} else if (filePath.includes('brainstorm')) {
|
||||
return parseBrainstormPlan(content) // From /workflow:brainstorm-with-file
|
||||
} else if (filePath.includes('synthesis')) {
|
||||
return parseSynthesisPlan(content) // From /workflow:brainstorm-with-file synthesis.json
|
||||
} else if (filePath.includes('conclusions')) {
|
||||
return parseConclusionsPlan(content) // From /workflow:analyze-with-file conclusions.json
|
||||
} else if (filePath.endsWith('.json') && content.includes('tasks')) {
|
||||
return parseTaskJson(content) // Direct task JSON
|
||||
}
|
||||
|
||||
throw new Error(`Unsupported plan format: ${filePath}`)
|
||||
}
|
||||
|
||||
// IMPL_PLAN.md parser
|
||||
function parseImplPlan(content) {
|
||||
// Extract:
|
||||
// - Overview/summary
|
||||
// - Phase sections
|
||||
// - Task list with dependencies
|
||||
// - Critical files
|
||||
// - Execution order
|
||||
|
||||
return {
|
||||
type: 'impl-plan',
|
||||
title: extractSection(content, 'Overview'),
|
||||
phases: extractPhases(content),
|
||||
tasks: extractTasks(content),
|
||||
criticalFiles: extractCriticalFiles(content),
|
||||
estimatedDuration: extractEstimate(content)
|
||||
}
|
||||
}
|
||||
|
||||
// Brainstorm synthesis.json parser
|
||||
function parseSynthesisPlan(content) {
|
||||
const synthesis = JSON.parse(content)
|
||||
|
||||
return {
|
||||
type: 'brainstorm-synthesis',
|
||||
title: synthesis.topic,
|
||||
ideas: synthesis.top_ideas,
|
||||
tasks: synthesis.top_ideas.map(idea => ({
|
||||
id: `IDEA-${slugify(idea.title)}`,
|
||||
type: 'investigation',
|
||||
title: idea.title,
|
||||
description: idea.description,
|
||||
dependencies: [],
|
||||
agent_type: 'cli-execution-agent',
|
||||
prompt: `Implement: ${idea.title}\n${idea.description}`,
|
||||
expected_output: idea.next_steps
|
||||
})),
|
||||
recommendations: synthesis.recommendations
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 1: Plan Loading & Validation
|
||||
|
||||
**Step 1.1: Parse Plan and Extract Tasks**
|
||||
|
||||
```javascript
|
||||
const tasks = plan.tasks || parseTasksFromContent(plan)
|
||||
|
||||
// Normalize task structure
|
||||
const normalizedTasks = tasks.map(task => ({
|
||||
id: task.id || `TASK-${generateId()}`,
|
||||
title: task.title || task.content,
|
||||
description: task.description || task.activeForm,
|
||||
type: task.type || inferTaskType(task), // 'code', 'test', 'doc', 'analysis', 'integration'
|
||||
agent_type: task.agent_type || selectBestAgent(task),
|
||||
dependencies: task.dependencies || [],
|
||||
|
||||
// Execution parameters
|
||||
prompt: task.prompt || task.description,
|
||||
files_to_modify: task.files_to_modify || [],
|
||||
expected_output: task.expected_output || [],
|
||||
|
||||
// Metadata
|
||||
priority: task.priority || 'normal',
|
||||
parallel_safe: task.parallel_safe !== false,
|
||||
estimated_duration: task.estimated_duration || null,
|
||||
|
||||
// Status tracking
|
||||
status: 'pending',
|
||||
attempts: 0,
|
||||
max_retries: 2
|
||||
}))
|
||||
|
||||
// Validate and detect issues
|
||||
const validation = {
|
||||
cycles: detectDependencyCycles(normalizedTasks),
|
||||
missing_dependencies: findMissingDependencies(normalizedTasks),
|
||||
file_conflicts: detectOutputConflicts(normalizedTasks),
|
||||
warnings: []
|
||||
}
|
||||
|
||||
if (validation.cycles.length > 0) {
|
||||
throw new Error(`Circular dependencies detected: ${validation.cycles.join(', ')}`)
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.2: Create execution.md**
|
||||
|
||||
```markdown
|
||||
# Execution Progress
|
||||
|
||||
**Execution ID**: ${executionId}
|
||||
**Plan Source**: ${planPath}
|
||||
**Started**: ${getUtc8ISOString()}
|
||||
**Mode**: ${executionMode}
|
||||
|
||||
**Plan Summary**:
|
||||
- Title: ${plan.title}
|
||||
- Total Tasks: ${tasks.length}
|
||||
- Phases: ${plan.phases?.length || 'N/A'}
|
||||
|
||||
---
|
||||
|
||||
## Execution Plan
|
||||
|
||||
### Task Overview
|
||||
|
||||
| Task ID | Title | Type | Agent | Dependencies | Status |
|
||||
|---------|-------|------|-------|--------------|--------|
|
||||
${normalizedTasks.map(t => `| ${t.id} | ${t.title} | ${t.type} | ${t.agent_type} | ${t.dependencies.join(',')} | ${t.status} |`).join('\n')}
|
||||
|
||||
### Dependency Graph
|
||||
|
||||
\`\`\`
|
||||
${generateDependencyGraph(normalizedTasks)}
|
||||
\`\`\`
|
||||
|
||||
### Execution Strategy
|
||||
|
||||
- **Mode**: ${executionMode}
|
||||
- **Parallelization**: ${calculateParallel(normalizedTasks)}
|
||||
- **Estimated Duration**: ${estimateTotalDuration(normalizedTasks)}
|
||||
|
||||
---
|
||||
|
||||
## Execution Timeline
|
||||
|
||||
*Updates as execution progresses*
|
||||
|
||||
---
|
||||
|
||||
## Current Status
|
||||
|
||||
${executionStatus()}
|
||||
```
|
||||
|
||||
**Step 1.3: Pre-Execution Confirmation**
|
||||
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (!autoYes) {
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: `准备执行 ${normalizedTasks.length} 个任务,模式: ${executionMode}\n\n关键任务:\n${normalizedTasks.slice(0, 3).map(t => `• ${t.id}: ${t.title}`).join('\n')}\n\n继续?`,
|
||||
header: "Confirmation",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "开始执行", description: "按计划执行" },
|
||||
{ label: "调整参数", description: "修改执行参数" },
|
||||
{ label: "查看详情", description: "查看完整任务列表" },
|
||||
{ label: "取消", description: "退出不执行" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Execution Orchestration
|
||||
|
||||
**Step 2.1: Determine Execution Order**
|
||||
|
||||
```javascript
|
||||
// Topological sort
|
||||
const executionOrder = topologicalSort(normalizedTasks)
|
||||
|
||||
// For parallel mode, group tasks into waves
|
||||
let executionWaves = []
|
||||
if (executionMode === 'parallel') {
|
||||
executionWaves = groupIntoWaves(executionOrder, parallelLimit = 3)
|
||||
} else {
|
||||
executionWaves = executionOrder.map(task => [task])
|
||||
}
|
||||
|
||||
// Log execution plan to execution.md
|
||||
// execution-events.md will track actual progress as tasks execute
|
||||
```
|
||||
|
||||
**Step 2.2: Execute Task Waves**
|
||||
|
||||
```javascript
|
||||
let completedCount = 0
|
||||
let failedCount = 0
|
||||
const results = {}
|
||||
|
||||
for (let waveIndex = 0; waveIndex < executionWaves.length; waveIndex++) {
|
||||
const wave = executionWaves[waveIndex]
|
||||
|
||||
console.log(`\n=== Wave ${waveIndex + 1}/${executionWaves.length} ===`)
|
||||
console.log(`Tasks: ${wave.map(t => t.id).join(', ')}`)
|
||||
|
||||
// Launch tasks in parallel
|
||||
const taskPromises = wave.map(task => executeTask(task, executionFolder))
|
||||
|
||||
// Wait for wave completion
|
||||
const waveResults = await Promise.allSettled(taskPromises)
|
||||
|
||||
// Process results
|
||||
for (let i = 0; i < waveResults.length; i++) {
|
||||
const result = waveResults[i]
|
||||
const task = wave[i]
|
||||
|
||||
if (result.status === 'fulfilled') {
|
||||
results[task.id] = result.value
|
||||
if (result.value.success) {
|
||||
completedCount++
|
||||
task.status = 'completed'
|
||||
console.log(`✅ ${task.id}: Completed`)
|
||||
} else if (result.value.retry) {
|
||||
console.log(`⚠️ ${task.id}: Will retry`)
|
||||
task.status = 'pending'
|
||||
} else {
|
||||
console.log(`❌ ${task.id}: Failed`)
|
||||
}
|
||||
} else {
|
||||
console.log(`❌ ${task.id}: Execution error`)
|
||||
}
|
||||
|
||||
// Progress is tracked in execution-events.md (appended by executeTask)
|
||||
}
|
||||
|
||||
// Update execution.md summary
|
||||
appendExecutionTimeline(executionPath, waveIndex + 1, wave, waveResults)
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2.3: Execute Individual Task with Unified Event Logging**
|
||||
|
||||
```javascript
|
||||
async function executeTask(task, executionFolder) {
|
||||
const eventLogPath = `${executionFolder}/execution-events.md`
|
||||
const startTime = Date.now()
|
||||
|
||||
try {
|
||||
// Read previous execution events for context
|
||||
let previousEvents = ''
|
||||
if (fs.existsSync(eventLogPath)) {
|
||||
previousEvents = Read(eventLogPath)
|
||||
}
|
||||
|
||||
// Select agent based on task type
|
||||
const agent = selectAgent(task.agent_type)
|
||||
|
||||
// Build execution context including previous agent outputs
|
||||
const executionContext = `
|
||||
## Previous Agent Executions (for reference)
|
||||
|
||||
${previousEvents}
|
||||
|
||||
---
|
||||
|
||||
## Current Task: ${task.id}
|
||||
|
||||
**Title**: ${task.title}
|
||||
**Agent**: ${agent}
|
||||
**Time**: ${getUtc8ISOString()}
|
||||
|
||||
### Description
|
||||
${task.description}
|
||||
|
||||
### Context
|
||||
- Modified Files: ${task.files_to_modify.join(', ')}
|
||||
- Expected Output: ${task.expected_output.join(', ')}
|
||||
- Previous Artifacts: [list any artifacts from previous tasks]
|
||||
|
||||
### Requirements
|
||||
${task.requirements || 'Follow the plan'}
|
||||
|
||||
### Constraints
|
||||
${task.constraints || 'No breaking changes'}
|
||||
`
|
||||
|
||||
// Execute based on agent type
|
||||
let result
|
||||
|
||||
if (agent === 'code-developer' || agent === 'tdd-developer') {
|
||||
// Code implementation
|
||||
result = await Task({
|
||||
subagent_type: agent,
|
||||
description: `Execute: ${task.title}`,
|
||||
prompt: executionContext,
|
||||
run_in_background: false
|
||||
})
|
||||
} else if (agent === 'cli-execution-agent' || agent === 'universal-executor') {
|
||||
// CLI-based execution
|
||||
result = await Bash({
|
||||
command: `ccw cli -p "${escapeQuotes(executionContext)}" --tool gemini --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
} else if (agent === 'test-fix-agent') {
|
||||
// Test execution and fixing
|
||||
result = await Task({
|
||||
subagent_type: 'test-fix-agent',
|
||||
description: `Execute Tests: ${task.title}`,
|
||||
prompt: executionContext,
|
||||
run_in_background: false
|
||||
})
|
||||
} else {
|
||||
// Generic task execution
|
||||
result = await Task({
|
||||
subagent_type: 'universal-executor',
|
||||
description: task.title,
|
||||
prompt: executionContext,
|
||||
run_in_background: false
|
||||
})
|
||||
}
|
||||
|
||||
// Capture artifacts (code, tests, docs generated by this task)
|
||||
const artifacts = captureArtifacts(task, executionFolder)
|
||||
|
||||
// Append to unified execution events log
|
||||
const eventEntry = `
|
||||
## Task ${task.id} - COMPLETED ✅
|
||||
|
||||
**Timestamp**: ${getUtc8ISOString()}
|
||||
**Duration**: ${calculateDuration(startTime)}ms
|
||||
**Agent**: ${agent}
|
||||
|
||||
### Execution Summary
|
||||
|
||||
${generateSummary(result)}
|
||||
|
||||
### Key Outputs
|
||||
|
||||
${formatOutputs(result)}
|
||||
|
||||
### Generated Artifacts
|
||||
|
||||
${artifacts.map(a => `- **${a.type}**: \`${a.path}\` (${a.size})`).join('\n')}
|
||||
|
||||
### Notes for Next Agent
|
||||
|
||||
${generateNotesForNextAgent(result, task)}
|
||||
|
||||
---
|
||||
`
|
||||
|
||||
appendToEventLog(eventLogPath, eventEntry)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
task_id: task.id,
|
||||
output: result,
|
||||
artifacts: artifacts,
|
||||
duration: calculateDuration(startTime)
|
||||
}
|
||||
} catch (error) {
|
||||
// Append failure event to unified log
|
||||
const failureEntry = `
|
||||
## Task ${task.id} - FAILED ❌
|
||||
|
||||
**Timestamp**: ${getUtc8ISOString()}
|
||||
**Duration**: ${calculateDuration(startTime)}ms
|
||||
**Agent**: ${agent}
|
||||
**Error**: ${error.message}
|
||||
|
||||
### Error Details
|
||||
|
||||
\`\`\`
|
||||
${error.stack}
|
||||
\`\`\`
|
||||
|
||||
### Recovery Notes for Next Attempt
|
||||
|
||||
${generateRecoveryNotes(error, task)}
|
||||
|
||||
---
|
||||
`
|
||||
|
||||
appendToEventLog(eventLogPath, failureEntry)
|
||||
|
||||
// Handle failure: retry, skip, or abort
|
||||
task.attempts++
|
||||
if (task.attempts < task.max_retries && autoYes) {
|
||||
console.log(`⚠️ ${task.id}: Failed, retrying (${task.attempts}/${task.max_retries})`)
|
||||
return { success: false, task_id: task.id, error: error.message, retry: true, duration: calculateDuration(startTime) }
|
||||
} else if (task.attempts >= task.max_retries && !autoYes) {
|
||||
const decision = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `任务失败: ${task.id}\n错误: ${error.message}`,
|
||||
header: "Decision",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "重试", description: "重新执行该任务" },
|
||||
{ label: "跳过", description: "跳过此任务,继续下一个" },
|
||||
{ label: "终止", description: "停止整个执行" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
if (decision === 'retry') {
|
||||
task.attempts = 0
|
||||
return { success: false, task_id: task.id, error: error.message, retry: true, duration: calculateDuration(startTime) }
|
||||
} else if (decision === 'skip') {
|
||||
task.status = 'skipped'
|
||||
skipDependentTasks(task.id, normalizedTasks)
|
||||
} else {
|
||||
throw new Error('Execution aborted by user')
|
||||
}
|
||||
} else {
|
||||
task.status = 'failed'
|
||||
skipDependentTasks(task.id, normalizedTasks)
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
task_id: task.id,
|
||||
error: error.message,
|
||||
duration: calculateDuration(startTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to append to unified event log
|
||||
function appendToEventLog(logPath, eventEntry) {
|
||||
if (fs.existsSync(logPath)) {
|
||||
const currentContent = Read(logPath)
|
||||
Write(logPath, currentContent + eventEntry)
|
||||
} else {
|
||||
Write(logPath, eventEntry)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Progress Tracking & Event Logging
|
||||
|
||||
The `execution-events.md` file is the **single source of truth** for all agent executions:
|
||||
- Each agent **reads** previous execution events for context
|
||||
- **Executes** its task (with full knowledge of what was done before)
|
||||
- **Writes** its execution event (success or failure) in markdown format
|
||||
- Next agent **reads** all previous events, creating a "knowledge chain"
|
||||
|
||||
**Event log format** (appended entry):
|
||||
```markdown
|
||||
## Task {id} - {STATUS} {emoji}
|
||||
|
||||
**Timestamp**: {time}
|
||||
**Duration**: {ms}
|
||||
**Agent**: {type}
|
||||
|
||||
### Execution Summary
|
||||
{What was done}
|
||||
|
||||
### Generated Artifacts
|
||||
- `src/types/auth.ts` (2.3KB)
|
||||
|
||||
### Notes for Next Agent
|
||||
- Key decisions made
|
||||
- Potential issues
|
||||
- Ready for: TASK-003
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Completion & Summary
|
||||
|
||||
After all tasks complete or max failures reached:
|
||||
|
||||
1. **Collect results**: Count completed/failed/skipped tasks
|
||||
2. **Update execution.md**: Add "Execution Completed" section with statistics
|
||||
3. **execution-events.md**: Already contains all detailed execution records
|
||||
|
||||
```javascript
|
||||
const statistics = {
|
||||
total_tasks: normalizedTasks.length,
|
||||
completed: normalizedTasks.filter(t => t.status === 'completed').length,
|
||||
failed: normalizedTasks.filter(t => t.status === 'failed').length,
|
||||
skipped: normalizedTasks.filter(t => t.status === 'skipped').length,
|
||||
success_rate: (completedCount / normalizedTasks.length * 100).toFixed(1)
|
||||
}
|
||||
|
||||
// Update execution.md with final status
|
||||
appendExecutionSummary(executionPath, statistics)
|
||||
```
|
||||
|
||||
**Post-Completion Options** (unless --yes):
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "执行完成。是否需要后续操作?",
|
||||
header: "Next Steps",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "查看详情", description: "查看完整执行日志" },
|
||||
{ label: "调试失败项", description: "对失败任务进行调试" },
|
||||
{ label: "优化执行", description: "分析执行改进建议" },
|
||||
{ label: "完成", description: "不需要后续操作" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.execution/{sessionId}/
|
||||
├── execution.md # Execution plan and overall status
|
||||
└── execution-events.md # 📋 Unified execution log (all agents) - SINGLE SOURCE OF TRUTH
|
||||
# This is both human-readable AND machine-parseable
|
||||
|
||||
# Generated files go directly to project directories (not into execution folder)
|
||||
# E.g. TASK-001 generates: src/types/auth.ts (not artifacts/src/types/auth.ts)
|
||||
# execution-events.md records the actual project paths
|
||||
```
|
||||
|
||||
**Key Concept**:
|
||||
- **execution-events.md** is the **single source of truth** for execution state
|
||||
- Human-readable: Clear markdown format with task summaries
|
||||
- Machine-parseable: Status indicators (✅/❌/⏳) and structured sections
|
||||
- Progress tracking: Read task count by parsing status indicators
|
||||
- No redundancy: One unified log for all purposes
|
||||
|
||||
---
|
||||
|
||||
## Agent Selection Strategy
|
||||
|
||||
```javascript
|
||||
function selectBestAgent(task) {
|
||||
if (task.type === 'code' || task.type === 'implementation') {
|
||||
return task.includes_tests ? 'tdd-developer' : 'code-developer'
|
||||
} else if (task.type === 'test' || task.type === 'test-fix') {
|
||||
return 'test-fix-agent'
|
||||
} else if (task.type === 'doc' || task.type === 'documentation') {
|
||||
return 'doc-generator'
|
||||
} else if (task.type === 'analysis' || task.type === 'investigation') {
|
||||
return 'cli-execution-agent'
|
||||
} else if (task.type === 'debug') {
|
||||
return 'debug-explore-agent'
|
||||
} else {
|
||||
return 'universal-executor'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Parallelization Rules
|
||||
|
||||
```javascript
|
||||
function calculateParallel(tasks) {
|
||||
// Group tasks into execution waves
|
||||
// Constraints:
|
||||
// - Tasks with same file modifications must be sequential
|
||||
// - Tasks with dependencies must wait
|
||||
// - Max 3 parallel tasks per wave (resource constraint)
|
||||
|
||||
const waves = []
|
||||
const completed = new Set()
|
||||
|
||||
while (completed.size < tasks.length) {
|
||||
const available = tasks.filter(t =>
|
||||
!completed.has(t.id) &&
|
||||
t.dependencies.every(d => completed.has(d))
|
||||
)
|
||||
|
||||
if (available.length === 0) break
|
||||
|
||||
// Check for file conflicts
|
||||
const noConflict = []
|
||||
const modifiedFiles = new Set()
|
||||
|
||||
for (const task of available) {
|
||||
const conflicts = task.files_to_modify.some(f => modifiedFiles.has(f))
|
||||
if (!conflicts && noConflict.length < 3) {
|
||||
noConflict.push(task)
|
||||
task.files_to_modify.forEach(f => modifiedFiles.add(f))
|
||||
} else if (!conflicts && noConflict.length < 3) {
|
||||
waves.push([task])
|
||||
completed.add(task.id)
|
||||
}
|
||||
}
|
||||
|
||||
if (noConflict.length > 0) {
|
||||
waves.push(noConflict)
|
||||
noConflict.forEach(t => completed.add(t.id))
|
||||
}
|
||||
}
|
||||
|
||||
return waves
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling & Recovery
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Task timeout | Mark as timeout, ask user: retry/skip/abort |
|
||||
| Missing dependency | Auto-skip dependent tasks, log warning |
|
||||
| File conflict | Detect before execution, ask for resolution |
|
||||
| Output mismatch | Validate against expected_output, flag for review |
|
||||
| Agent unavailable | Fallback to universal-executor |
|
||||
| Execution interrupted | Support resume with `/workflow:unified-execute-with-file --continue` |
|
||||
|
||||
## Usage Recommendations
|
||||
|
||||
Use `/workflow:unified-execute-with-file` when:
|
||||
- Executing any planning document (IMPL_PLAN.md, brainstorm conclusions, analysis recommendations)
|
||||
- Multiple tasks with dependencies need orchestration
|
||||
- Want minimal progress tracking without clutter
|
||||
- Need to handle failures gracefully and resume
|
||||
- Want to parallelize where possible but ensure correctness
|
||||
|
||||
Use for consuming output from:
|
||||
- `/workflow:plan` → IMPL_PLAN.md
|
||||
- `/workflow:brainstorm-with-file` → synthesis.json → execution
|
||||
- `/workflow:analyze-with-file` → conclusions.json → execution
|
||||
- `/workflow:debug-with-file` → recommendations → execution
|
||||
- `/workflow:lite-plan` → task JSONs → execution
|
||||
|
||||
## Session Resume
|
||||
|
||||
```bash
|
||||
/workflow:unified-execute-with-file --continue # Resume last execution
|
||||
/workflow:unified-execute-with-file --continue EXEC-xxx-2025-01-27-abcd # Resume specific
|
||||
```
|
||||
|
||||
When resuming:
|
||||
1. Load execution.md and execution-events.md
|
||||
2. Parse execution-events.md to identify completed/failed/skipped tasks
|
||||
3. Recalculate remaining dependencies
|
||||
4. Resume from first incomplete task
|
||||
5. Append to execution-events.md with "Resumed from [sessionId]" note
|
||||
@@ -1,45 +0,0 @@
|
||||
# CCW Coordinator
|
||||
|
||||
交互式命令编排工具
|
||||
|
||||
## 使用
|
||||
|
||||
```
|
||||
/ccw-coordinator
|
||||
或
|
||||
/coordinator
|
||||
```
|
||||
|
||||
## 流程
|
||||
|
||||
1. 用户描述任务
|
||||
2. Claude推荐命令链
|
||||
3. 用户确认或调整
|
||||
4. 执行命令链
|
||||
5. 生成报告
|
||||
|
||||
## 示例
|
||||
|
||||
**Bug修复**
|
||||
```
|
||||
任务: 修复登录bug
|
||||
推荐: lite-fix → test-cycle-execute
|
||||
```
|
||||
|
||||
**新功能**
|
||||
```
|
||||
任务: 实现注册功能
|
||||
推荐: plan → execute → test-cycle-execute
|
||||
```
|
||||
|
||||
## 文件说明
|
||||
|
||||
| 文件 | 用途 |
|
||||
|------|------|
|
||||
| SKILL.md | Skill入口 |
|
||||
| phases/orchestrator.md | 编排逻辑 |
|
||||
| phases/state-schema.md | 状态定义 |
|
||||
| phases/actions/*.md | 动作实现 |
|
||||
| specs/specs.md | 命令库、验证规则、注册表 |
|
||||
| tools/chain-validate.cjs | 验证工具 |
|
||||
| tools/command-registry.cjs | 命令注册表工具 |
|
||||
@@ -1,320 +0,0 @@
|
||||
---
|
||||
name: ccw-coordinator
|
||||
description: Interactive command orchestration tool for building and executing Claude CLI command chains. Triggers on "coordinator", "ccw-coordinator", "命令编排", "command chain", "orchestrate commands", "编排CLI命令".
|
||||
allowed-tools: Task, AskUserQuestion, Read, Write, Bash, Glob, Grep
|
||||
---
|
||||
|
||||
# CCW Coordinator
|
||||
|
||||
交互式命令编排工具:允许用户依次选择命令,形成命令串,然后依次调用claude cli执行整个命令串。
|
||||
|
||||
支持灵活的工作流组合,提供交互式界面用于命令选择、编排和执行管理。
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Orchestrator (状态驱动决策) │
|
||||
│ 根据用户选择编排命令和执行流程 │
|
||||
└───────────────┬─────────────────────────────────────────────────┘
|
||||
│
|
||||
┌───────────┼───────────┬───────────────┐
|
||||
↓ ↓ ↓ ↓
|
||||
┌─────────┐ ┌──────────────┐ ┌────────────┐ ┌──────────┐
|
||||
│ Init │ │ Command │ │ Command │ │ Execute │
|
||||
│ │ │ Selection │ │ Build │ │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ 初始化 │ │ 选择命令 │ │ 编排调整 │ │ 执行链 │
|
||||
└─────────┘ └──────────────┘ └────────────┘ └──────────┘
|
||||
│ │ │ │
|
||||
└───────────────┼──────────────┴────────────┘
|
||||
│
|
||||
↓
|
||||
┌──────────────┐
|
||||
│ Complete │
|
||||
│ 生成报告 │
|
||||
└──────────────┘
|
||||
```
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **智能推荐**: Claude 根据用户任务描述,自动推荐最优命令链
|
||||
2. **交互式编排**: 用户通过交互式界面选择和编排命令,实时反馈
|
||||
3. **无状态动作**: 每个动作独立执行,通过共享状态进行通信
|
||||
4. **灵活的命令库**: 支持ccw workflow命令和标准claude cli命令
|
||||
5. **执行透明性**: 展示执行进度、结果和可能的错误
|
||||
6. **会话持久化**: 保存编排会话,支持中途暂停和恢复
|
||||
7. **智能提示词生成**: 根据任务上下文和前序产物自动生成 ccw cli 提示词
|
||||
8. **自动确认**: 所有命令自动添加 `-y` 参数,跳过交互式确认,实现无人值守执行
|
||||
|
||||
## Intelligent Prompt Generation
|
||||
|
||||
执行命令时,系统根据以下信息智能生成 `ccw cli -p` 提示词:
|
||||
|
||||
### 提示词构成
|
||||
|
||||
```javascript
|
||||
// 集成命令注册表 (~/.claude/tools/command-registry.js)
|
||||
const registry = new CommandRegistry();
|
||||
registry.buildRegistry();
|
||||
|
||||
function generatePrompt(cmd, state) {
|
||||
const cmdMeta = registry.getCommand(cmd.command);
|
||||
|
||||
let prompt = `任务: ${state.task_description}\n`;
|
||||
|
||||
if (state.execution_results.length > 0) {
|
||||
const previousOutputs = state.execution_results
|
||||
.filter(r => r.status === 'success')
|
||||
.map(r => {
|
||||
if (r.summary?.session) {
|
||||
return `- ${r.command}: ${r.summary.session} (${r.summary.files?.join(', ')})`;
|
||||
}
|
||||
return `- ${r.command}: 已完成`;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
prompt += `\n前序完成:\n${previousOutputs}\n`;
|
||||
}
|
||||
|
||||
// 从 YAML 头提取命令元数据
|
||||
if (cmdMeta) {
|
||||
prompt += `\n命令: ${cmd.command}`;
|
||||
if (cmdMeta.argumentHint) {
|
||||
prompt += ` ${cmdMeta.argumentHint}`;
|
||||
}
|
||||
}
|
||||
|
||||
return prompt;
|
||||
}
|
||||
```
|
||||
|
||||
### 产物追踪
|
||||
|
||||
每个命令执行后自动提取关键产物:
|
||||
|
||||
```javascript
|
||||
{
|
||||
command: "/workflow:lite-plan",
|
||||
status: "success",
|
||||
output: "...",
|
||||
summary: {
|
||||
session: "WFS-plan-20250123", // 会话ID
|
||||
files: [".workflow/IMPL_PLAN.md"], // 产物文件
|
||||
timestamp: "2025-01-23T10:30:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 命令调用示例
|
||||
|
||||
```bash
|
||||
# 自动生成的智能提示词
|
||||
ccw cli -p "任务: 实现用户认证功能
|
||||
|
||||
前序完成:
|
||||
- /workflow:lite-plan: WFS-plan-20250123 (.workflow/IMPL_PLAN.md)
|
||||
|
||||
命令: /workflow:lite-execute [--resume-session=\"session-id\"]" /workflow:lite-execute
|
||||
```
|
||||
|
||||
### 命令注册表集成
|
||||
|
||||
- **位置**: `tools/command-registry.js` (skill 内置)
|
||||
- **工作模式**: 按需提取(只提取用户任务链中的命令)
|
||||
- **功能**: 自动查找全局 `.claude/commands/workflow` 目录,解析命令 YAML 头元数据
|
||||
- **作用**: 确保提示词包含准确的命令参数和上下文
|
||||
|
||||
详见 `tools/README.md`
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Orchestrator Execution Loop
|
||||
|
||||
```javascript
|
||||
1. 初始化会话
|
||||
↓
|
||||
2. 循环执行直到完成
|
||||
├─ 读取当前状态
|
||||
├─ 选择下一个动作(根据状态和用户意图)
|
||||
├─ 执行动作,更新状态
|
||||
└─ 检查终止条件
|
||||
↓
|
||||
3. 生成最终报告
|
||||
```
|
||||
|
||||
### Action Sequence (Typical)
|
||||
|
||||
```
|
||||
action-init
|
||||
↓ (status: pending → running)
|
||||
action-command-selection (可重复)
|
||||
↓ (添加命令到链)
|
||||
action-command-build (可选)
|
||||
↓ (调整命令顺序)
|
||||
action-command-execute
|
||||
↓ (依次执行所有命令)
|
||||
action-complete
|
||||
↓ (status: running → completed)
|
||||
```
|
||||
|
||||
## State Management
|
||||
|
||||
### Initial State
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "pending",
|
||||
"task_description": "",
|
||||
"command_chain": [],
|
||||
"confirmed": false,
|
||||
"error_count": 0,
|
||||
"execution_results": [],
|
||||
"current_command_index": 0,
|
||||
"started_at": null
|
||||
}
|
||||
```
|
||||
|
||||
### State Transitions
|
||||
|
||||
```
|
||||
pending → running (init) → running → completed (execute)
|
||||
↓
|
||||
aborted (error or user exit)
|
||||
```
|
||||
|
||||
## Directory Setup
|
||||
|
||||
```javascript
|
||||
const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, '');
|
||||
const workDir = `.workflow/.ccw-coordinator/${timestamp}`;
|
||||
|
||||
Bash(`mkdir -p "${workDir}"`);
|
||||
Bash(`mkdir -p "${workDir}/commands"`);
|
||||
Bash(`mkdir -p "${workDir}/logs"`);
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```
|
||||
.workflow/.ccw-coordinator/{timestamp}/
|
||||
├── state.json # 当前会话状态
|
||||
├── command-chain.json # 编排的完整命令链
|
||||
├── execution-log.md # 执行日志
|
||||
├── final-summary.md # 最终报告
|
||||
├── commands/ # 各命令执行详情
|
||||
│ ├── 01-command.log
|
||||
│ ├── 02-command.log
|
||||
│ └── ...
|
||||
└── logs/ # 错误和警告日志
|
||||
├── errors.log
|
||||
└── warnings.log
|
||||
```
|
||||
|
||||
## Reference Documents
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [phases/orchestrator.md](phases/orchestrator.md) | 编排器实现 |
|
||||
| [phases/state-schema.md](phases/state-schema.md) | 状态结构定义 |
|
||||
| [phases/actions/action-init.md](phases/actions/action-init.md) | 初始化动作 |
|
||||
| [phases/actions/action-command-selection.md](phases/actions/action-command-selection.md) | 命令选择动作 |
|
||||
| [phases/actions/action-command-build.md](phases/actions/action-command-build.md) | 命令编排动作 |
|
||||
| [phases/actions/action-command-execute.md](phases/actions/action-command-execute.md) | 命令执行动作 |
|
||||
| [phases/actions/action-complete.md](phases/actions/action-complete.md) | 完成动作 |
|
||||
| [phases/actions/action-abort.md](phases/actions/action-abort.md) | 中止动作 |
|
||||
| [specs/specs.md](specs/specs.md) | 命令库、验证规则、注册表 |
|
||||
| [tools/chain-validate.cjs](tools/chain-validate.cjs) | 验证工具 |
|
||||
| [tools/command-registry.cjs](tools/command-registry.cjs) | 命令注册表工具 |
|
||||
|
||||
---
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### 快速命令链
|
||||
|
||||
用户想要执行:规划 → 执行 → 测试
|
||||
|
||||
```
|
||||
1. 触发 /ccw-coordinator
|
||||
2. 描述任务:"实现用户注册功能"
|
||||
3. Claude推荐: plan → execute → test-cycle-execute
|
||||
4. 用户确认
|
||||
5. 执行命令链
|
||||
```
|
||||
|
||||
### 复杂工作流
|
||||
|
||||
用户想要执行:规划 → 执行 → 审查 → 修复
|
||||
|
||||
```
|
||||
1. 触发 /ccw-coordinator
|
||||
2. 描述任务:"重构认证模块"
|
||||
3. Claude推荐: plan → execute → review-session-cycle → review-fix
|
||||
4. 用户可调整命令顺序
|
||||
5. 确认执行
|
||||
6. 实时查看执行进度
|
||||
```
|
||||
|
||||
### 紧急修复
|
||||
|
||||
用户想要快速修复bug
|
||||
|
||||
```
|
||||
1. 触发 /ccw-coordinator
|
||||
2. 描述任务:"修复生产环境登录bug"
|
||||
3. Claude推荐: lite-fix --hotfix → test-cycle-execute
|
||||
4. 用户确认
|
||||
5. 快速执行修复
|
||||
```
|
||||
|
||||
## Constraints and Rules
|
||||
|
||||
### 1. 命令推荐约束
|
||||
|
||||
- **智能推荐优先**: 必须先基于用户任务描述进行智能推荐,而非直接展示命令库
|
||||
- **不使用静态映射**: 禁止使用查表或硬编码的推荐逻辑(如 `if task=bug则推荐lite-fix`)
|
||||
- **推荐必须说明理由**: Claude 推荐命令链时必须解释为什么这样推荐
|
||||
- **用户保留选择权**: 推荐后,用户可选择:使用推荐/调整/手动选择
|
||||
|
||||
### 2. 验证约束
|
||||
|
||||
- **执行前必须验证**: 使用 `chain-validate.js` 验证命令链合法性
|
||||
- **不合法必须提示**: 如果验证失败,必须明确告知用户错误原因和修复方法
|
||||
- **允许用户覆盖**: 验证失败时,询问用户是否仍要执行(警告模式)
|
||||
|
||||
### 3. 执行约束
|
||||
|
||||
- **顺序执行**: 命令必须严格按照 command_chain 中的 order 顺序执行
|
||||
- **错误处理**: 单个命令失败时,询问用户:重试/跳过/中止
|
||||
- **错误上限**: 连续 3 次错误自动中止会话
|
||||
- **实时反馈**: 每个命令执行时显示进度(如 `[2/5] 执行: lite-execute`)
|
||||
|
||||
### 4. 状态管理约束
|
||||
|
||||
- **状态持久化**: 每次状态更新必须立即写入磁盘
|
||||
- **单一数据源**: 状态只保存在 `state.json`,禁止多个状态文件
|
||||
- **原子操作**: 状态更新必须使用 read-modify-write 模式,避免并发冲突
|
||||
|
||||
### 5. 用户体验约束
|
||||
|
||||
- **最小交互**: 默认使用智能推荐 + 一次确认,避免多次询问
|
||||
- **清晰输出**: 每个步骤输出必须包含:当前状态、可用选项、建议操作
|
||||
- **可恢复性**: 会话中断后,用户可从上次状态恢复
|
||||
|
||||
### 6. 禁止行为
|
||||
|
||||
- ❌ **禁止跳过推荐步骤**: 不能直接进入手动选择,必须先尝试推荐
|
||||
- ❌ **禁止静态推荐**: 不能使用 recommended-chains.json 查表
|
||||
- ❌ **禁止无验证执行**: 不能跳过链条验证直接执行
|
||||
- ❌ **禁止静默失败**: 错误必须明确报告,不能静默跳过
|
||||
|
||||
## Notes
|
||||
|
||||
- 编排器使用状态机模式,确保执行流程的可靠性
|
||||
- 所有命令链和执行结果都被持久化保存,支持后续查询和调试
|
||||
- 支持用户中途修改命令链(在执行前)
|
||||
- 执行错误会自动记录,支持重试机制
|
||||
- Claude 智能推荐基于任务分析,非查表静态推荐
|
||||
@@ -1,9 +0,0 @@
|
||||
# action-abort
|
||||
|
||||
中止会话,保存状态
|
||||
|
||||
```javascript
|
||||
updateState({ status: 'aborted' });
|
||||
|
||||
console.log(`会话已中止: ${workDir}`);
|
||||
```
|
||||
@@ -1,40 +0,0 @@
|
||||
# action-command-build
|
||||
|
||||
调整命令链顺序或删除命令
|
||||
|
||||
## 流程
|
||||
|
||||
1. 显示当前命令链
|
||||
2. 让用户调整(重新排序、删除)
|
||||
3. 确认执行
|
||||
|
||||
## 伪代码
|
||||
|
||||
```javascript
|
||||
// 显示链
|
||||
console.log('命令链:');
|
||||
state.command_chain.forEach((cmd, i) => {
|
||||
console.log(`${i+1}. ${cmd.command}`);
|
||||
});
|
||||
|
||||
// 询问用户
|
||||
const action = await AskUserQuestion({
|
||||
options: [
|
||||
'继续执行',
|
||||
'删除命令',
|
||||
'重新排序',
|
||||
'返回选择'
|
||||
]
|
||||
});
|
||||
|
||||
// 处理用户操作
|
||||
if (action === '继续执行') {
|
||||
updateState({confirmed: true, status: 'executing'});
|
||||
}
|
||||
// ... 其他操作
|
||||
```
|
||||
|
||||
## 状态更新
|
||||
|
||||
- command_chain (可能修改)
|
||||
- confirmed = true 时状态转为 executing
|
||||
@@ -1,124 +0,0 @@
|
||||
# action-command-execute
|
||||
|
||||
依次执行命令链,智能生成 ccw cli 提示词
|
||||
|
||||
## 命令注册表集成
|
||||
|
||||
```javascript
|
||||
// 从 ./tools/command-registry.cjs 按需提取命令元数据
|
||||
const CommandRegistry = require('./tools/command-registry.cjs');
|
||||
const registry = new CommandRegistry();
|
||||
|
||||
// 只提取当前任务链中的命令
|
||||
const commandNames = command_chain.map(cmd => cmd.command);
|
||||
const commandMeta = registry.getCommands(commandNames);
|
||||
```
|
||||
|
||||
## 提示词生成策略
|
||||
|
||||
```javascript
|
||||
function generatePrompt(cmd, state, commandMeta) {
|
||||
const { task_description, execution_results } = state;
|
||||
|
||||
// 获取命令元数据(从已提取的 commandMeta)
|
||||
const cmdInfo = commandMeta[cmd.command];
|
||||
|
||||
// 提取前序产物信息
|
||||
const previousOutputs = execution_results
|
||||
.filter(r => r.status === 'success')
|
||||
.map(r => {
|
||||
const summary = r.summary;
|
||||
if (summary?.session) {
|
||||
return `- ${r.command}: ${summary.session} (${summary.files?.join(', ') || '完成'})`;
|
||||
}
|
||||
return `- ${r.command}: 已完成`;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
// 根据命令类型构建提示词
|
||||
let prompt = `任务: ${task_description}\n`;
|
||||
|
||||
if (previousOutputs) {
|
||||
prompt += `\n前序完成:\n${previousOutputs}\n`;
|
||||
}
|
||||
|
||||
// 添加命令元数据上下文
|
||||
if (cmdInfo) {
|
||||
prompt += `\n命令: ${cmd.command}`;
|
||||
if (cmdInfo.argumentHint) {
|
||||
prompt += ` ${cmdInfo.argumentHint}`;
|
||||
}
|
||||
}
|
||||
|
||||
return prompt;
|
||||
}
|
||||
```
|
||||
|
||||
## 执行逻辑
|
||||
|
||||
```javascript
|
||||
for (let i = current_command_index; i < command_chain.length; i++) {
|
||||
const cmd = command_chain[i];
|
||||
|
||||
console.log(`[${i+1}/${command_chain.length}] 执行: ${cmd.command}`);
|
||||
|
||||
// 生成智能提示词
|
||||
const prompt = generatePrompt(cmd, state, commandMeta);
|
||||
|
||||
try {
|
||||
// 使用 ccw cli 执行(添加 -y 参数跳过确认)
|
||||
const result = Bash(`ccw cli -p "${prompt.replace(/"/g, '\\"')}" ${cmd.command} -y`, {
|
||||
run_in_background: true
|
||||
});
|
||||
|
||||
execution_results.push({
|
||||
command: cmd.command,
|
||||
status: result.exit_code === 0 ? 'success' : 'failed',
|
||||
exit_code: result.exit_code,
|
||||
output: result.stdout,
|
||||
summary: extractSummary(result.stdout) // 提取关键产物
|
||||
});
|
||||
|
||||
command_chain[i].status = 'completed';
|
||||
current_command_index = i + 1;
|
||||
|
||||
} catch (error) {
|
||||
error_count++;
|
||||
command_chain[i].status = 'failed';
|
||||
|
||||
if (error_count >= 3) break;
|
||||
|
||||
const action = await AskUserQuestion({
|
||||
options: ['重试', '跳过', '中止']
|
||||
});
|
||||
|
||||
if (action === '重试') i--;
|
||||
if (action === '中止') break;
|
||||
}
|
||||
|
||||
updateState({ command_chain, execution_results, current_command_index, error_count });
|
||||
}
|
||||
```
|
||||
|
||||
## 产物提取
|
||||
|
||||
```javascript
|
||||
function extractSummary(output) {
|
||||
// 从输出提取关键产物信息
|
||||
// 例如: 会话ID, 文件路径, 任务完成状态等
|
||||
const sessionMatch = output.match(/WFS-\w+-\d+/);
|
||||
const fileMatch = output.match(/\.workflow\/[^\s]+/g);
|
||||
|
||||
return {
|
||||
session: sessionMatch?.[0],
|
||||
files: fileMatch || [],
|
||||
timestamp: new Date().toISOString()
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## 状态更新
|
||||
|
||||
- execution_results (包含 summary 产物信息)
|
||||
- command_chain[].status
|
||||
- current_command_index
|
||||
@@ -1,48 +0,0 @@
|
||||
# action-command-selection
|
||||
|
||||
## 流程
|
||||
|
||||
1. 问用户任务
|
||||
2. Claude推荐命令链
|
||||
3. 用户确认/手动选择
|
||||
4. 添加到command_chain
|
||||
|
||||
## 伪代码
|
||||
|
||||
```javascript
|
||||
// 1. 获取用户任务描述
|
||||
const taskInput = await AskUserQuestion({
|
||||
question: '请描述您的任务',
|
||||
options: [
|
||||
{ label: '手动选择命令', value: 'manual' }
|
||||
]
|
||||
});
|
||||
|
||||
// 保存任务描述到状态
|
||||
updateState({ task_description: taskInput.text || taskInput.value });
|
||||
|
||||
// 2. 若用户描述任务,Claude推荐
|
||||
if (taskInput.text) {
|
||||
console.log('推荐: ', recommendChain(taskInput.text));
|
||||
const confirm = await AskUserQuestion({
|
||||
question: '是否使用推荐链?',
|
||||
options: ['使用推荐', '调整', '手动选择']
|
||||
});
|
||||
if (confirm === '使用推荐') {
|
||||
addCommandsToChain(recommendedChain);
|
||||
updateState({ confirmed: true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 手动选择
|
||||
const commands = loadCommandLibrary();
|
||||
const selected = await AskUserQuestion(commands);
|
||||
addToChain(selected);
|
||||
```
|
||||
|
||||
## 状态更新
|
||||
|
||||
- task_description = 用户任务描述
|
||||
- command_chain.push(newCommand)
|
||||
- 如果用户确认: confirmed = true
|
||||
@@ -1,25 +0,0 @@
|
||||
# action-complete
|
||||
|
||||
生成执行报告
|
||||
|
||||
```javascript
|
||||
const success = execution_results.filter(r => r.status === 'success').length;
|
||||
const failed = execution_results.filter(r => r.status === 'failed').length;
|
||||
const duration = Date.now() - new Date(started_at).getTime();
|
||||
|
||||
const report = `
|
||||
# 执行报告
|
||||
|
||||
- 会话: ${session_id}
|
||||
- 耗时: ${Math.round(duration/1000)}s
|
||||
- 成功: ${success}
|
||||
- 失败: ${failed}
|
||||
|
||||
## 命令详情
|
||||
|
||||
${command_chain.map((c, i) => `${i+1}. ${c.command} - ${c.status}`).join('\n')}
|
||||
`;
|
||||
|
||||
Write(`${workDir}/final-report.md`, report);
|
||||
updateState({ status: 'completed' });
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
# action-init
|
||||
|
||||
初始化编排会话
|
||||
|
||||
```javascript
|
||||
const timestamp = Date.now();
|
||||
const workDir = `.workflow/.ccw-coordinator/${timestamp}`;
|
||||
|
||||
Bash(`mkdir -p "${workDir}"`);
|
||||
|
||||
const state = {
|
||||
session_id: `coord-${timestamp}`,
|
||||
status: 'running',
|
||||
started_at: new Date().toISOString(),
|
||||
task_description: '',
|
||||
command_chain: [],
|
||||
current_command_index: 0,
|
||||
execution_results: [],
|
||||
confirmed: false,
|
||||
error_count: 0
|
||||
};
|
||||
|
||||
Write(`${workDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
console.log(`会话已初始化: ${workDir}`);
|
||||
```
|
||||
@@ -1,59 +0,0 @@
|
||||
# Orchestrator
|
||||
|
||||
状态驱动编排:读状态 → 选动作 → 执行 → 更新状态
|
||||
|
||||
## 决策逻辑
|
||||
|
||||
```javascript
|
||||
function selectNextAction(state) {
|
||||
if (['completed', 'aborted'].includes(state.status)) return null;
|
||||
if (state.error_count >= 3) return 'action-abort';
|
||||
|
||||
switch (state.status) {
|
||||
case 'pending':
|
||||
return 'action-init';
|
||||
case 'running':
|
||||
return state.confirmed && state.command_chain.length > 0
|
||||
? 'action-command-execute'
|
||||
: 'action-command-selection';
|
||||
case 'executing':
|
||||
const pending = state.command_chain.filter(c => c.status === 'pending');
|
||||
return pending.length === 0 ? 'action-complete' : 'action-command-execute';
|
||||
default:
|
||||
return 'action-abort';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 执行循环
|
||||
|
||||
```javascript
|
||||
const timestamp = Date.now();
|
||||
const workDir = `.workflow/.ccw-coordinator/${timestamp}`;
|
||||
Bash(`mkdir -p "${workDir}"`);
|
||||
|
||||
const state = {
|
||||
session_id: `coord-${timestamp}`,
|
||||
status: 'pending',
|
||||
started_at: new Date().toISOString(),
|
||||
task_description: '', // 从 action-command-selection 获取
|
||||
command_chain: [],
|
||||
current_command_index: 0,
|
||||
execution_results: [],
|
||||
confirmed: false,
|
||||
error_count: 0
|
||||
};
|
||||
Write(`${workDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
let iterations = 0;
|
||||
while (iterations < 50) {
|
||||
const state = JSON.parse(Read(`${workDir}/state.json`));
|
||||
const nextAction = selectNextAction(state);
|
||||
if (!nextAction) break;
|
||||
|
||||
console.log(`[${nextAction}]`);
|
||||
// 执行 phases/actions/{nextAction}.md
|
||||
|
||||
iterations++;
|
||||
}
|
||||
```
|
||||
@@ -1,66 +0,0 @@
|
||||
# State Schema
|
||||
|
||||
```typescript
|
||||
interface State {
|
||||
session_id: string;
|
||||
status: 'pending' | 'running' | 'executing' | 'completed' | 'aborted';
|
||||
started_at: string;
|
||||
task_description: string; // 用户任务描述
|
||||
command_chain: Command[];
|
||||
current_command_index: number;
|
||||
execution_results: ExecutionResult[];
|
||||
confirmed: boolean;
|
||||
error_count: number;
|
||||
}
|
||||
|
||||
interface Command {
|
||||
id: string;
|
||||
order: number;
|
||||
command: string;
|
||||
status: 'pending' | 'running' | 'completed' | 'failed';
|
||||
result?: ExecutionResult;
|
||||
}
|
||||
|
||||
interface ExecutionResult {
|
||||
command: string;
|
||||
status: 'success' | 'failed';
|
||||
exit_code: number;
|
||||
output?: string;
|
||||
summary?: { // 提取的关键产物
|
||||
session?: string;
|
||||
files?: string[];
|
||||
timestamp: string;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## 状态转移
|
||||
|
||||
```
|
||||
pending → running → executing → completed
|
||||
↓ ↓
|
||||
(abort) (error → abort)
|
||||
```
|
||||
|
||||
## 初始化
|
||||
|
||||
```javascript
|
||||
{
|
||||
session_id: generateId(),
|
||||
status: 'pending',
|
||||
started_at: new Date().toISOString(),
|
||||
task_description: '', // 从用户输入获取
|
||||
command_chain: [],
|
||||
current_command_index: 0,
|
||||
execution_results: [],
|
||||
confirmed: false,
|
||||
error_count: 0
|
||||
}
|
||||
```
|
||||
|
||||
## 更新
|
||||
|
||||
- 添加命令: `command_chain.push(cmd)`
|
||||
- 确认执行: `confirmed = true, status = 'executing'`
|
||||
- 记录执行: `execution_results.push(...), current_command_index++`
|
||||
- 错误计数: `error_count++`
|
||||
@@ -1,66 +0,0 @@
|
||||
{
|
||||
"skill_name": "ccw-coordinator",
|
||||
"display_name": "CCW Coordinator",
|
||||
"description": "Interactive command orchestration - select, build, and execute workflow command chains",
|
||||
"execution_mode": "autonomous",
|
||||
"version": "1.0.0",
|
||||
"triggers": [
|
||||
"coordinator",
|
||||
"ccw-coordinator",
|
||||
"命令编排",
|
||||
"command chain"
|
||||
],
|
||||
"allowed_tools": [
|
||||
"Task",
|
||||
"AskUserQuestion",
|
||||
"Read",
|
||||
"Write",
|
||||
"Bash"
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"id": "action-init",
|
||||
"name": "Init",
|
||||
"description": "Initialize orchestration session"
|
||||
},
|
||||
{
|
||||
"id": "action-command-selection",
|
||||
"name": "Select Commands",
|
||||
"description": "Interactive command selection from library"
|
||||
},
|
||||
{
|
||||
"id": "action-command-build",
|
||||
"name": "Build Chain",
|
||||
"description": "Adjust and confirm command chain"
|
||||
},
|
||||
{
|
||||
"id": "action-command-execute",
|
||||
"name": "Execute",
|
||||
"description": "Execute command chain sequentially"
|
||||
},
|
||||
{
|
||||
"id": "action-complete",
|
||||
"name": "Complete",
|
||||
"description": "Generate final report"
|
||||
},
|
||||
{
|
||||
"id": "action-abort",
|
||||
"name": "Abort",
|
||||
"description": "Abort session and save state"
|
||||
}
|
||||
],
|
||||
"termination_conditions": [
|
||||
"user_exit",
|
||||
"task_completed",
|
||||
"error"
|
||||
],
|
||||
"output": {
|
||||
"location": ".workflow/.ccw-coordinator/{timestamp}",
|
||||
"artifacts": [
|
||||
"state.json",
|
||||
"command-chain.json",
|
||||
"execution-log.md",
|
||||
"final-report.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
# Command Library
|
||||
|
||||
CCW Coordinator 支持的命令库。基于 CCW workflow 命令系统。
|
||||
|
||||
## Command Categories
|
||||
|
||||
### Planning Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-plan` | 轻量级规划 | L2 |
|
||||
| `/workflow:plan` | 标准规划 | L3 |
|
||||
| `/workflow:multi-cli-plan` | 多CLI协作规划 | L2 |
|
||||
| `/workflow:brainstorm:auto-parallel` | 头脑风暴规划 | L4 |
|
||||
| `/workflow:tdd-plan` | TDD规划 | L3 |
|
||||
|
||||
### Execution Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-execute` | 轻量级执行 | L2 |
|
||||
| `/workflow:execute` | 标准执行 | L3 |
|
||||
| `/workflow:test-cycle-execute` | 测试循环执行 | L3 |
|
||||
|
||||
### BugFix Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-fix` | 轻量级修复 | L2 |
|
||||
| `/workflow:lite-fix --hotfix` | 紧急修复 | L2 |
|
||||
|
||||
### Testing Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:test-gen` | 测试生成 | L3 |
|
||||
| `/workflow:test-fix-gen` | 测试修复生成 | L3 |
|
||||
| `/workflow:tdd-verify` | TDD验证 | L3 |
|
||||
|
||||
### Review Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:review-session-cycle` | 会话审查 | L3 |
|
||||
| `/workflow:review-module-cycle` | 模块审查 | L3 |
|
||||
| `/workflow:review-fix` | 审查修复 | L3 |
|
||||
| `/workflow:plan-verify` | 计划验证 | L3 |
|
||||
|
||||
### Documentation Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/memory:docs` | 生成文档 | L2 |
|
||||
| `/memory:update-related` | 更新相关文档 | L2 |
|
||||
| `/memory:update-full` | 全面更新文档 | L2 |
|
||||
|
||||
### Issue Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/issue:discover` | 发现Issue | Supplementary |
|
||||
| `/issue:discover-by-prompt` | 基于提示发现Issue | Supplementary |
|
||||
| `/issue:plan --all-pending` | 规划所有待处理Issue | Supplementary |
|
||||
| `/issue:queue` | 排队Issue | Supplementary |
|
||||
| `/issue:execute` | 执行Issue | Supplementary |
|
||||
|
||||
## Command Chains (Recommended)
|
||||
|
||||
### 标准开发流程
|
||||
|
||||
```
|
||||
1. /workflow:lite-plan
|
||||
2. /workflow:lite-execute
|
||||
3. /workflow:test-cycle-execute
|
||||
```
|
||||
|
||||
### 完整规划流程
|
||||
|
||||
```
|
||||
1. /workflow:plan
|
||||
2. /workflow:plan-verify
|
||||
3. /workflow:execute
|
||||
4. /workflow:review-session-cycle
|
||||
```
|
||||
|
||||
### TDD 流程
|
||||
|
||||
```
|
||||
1. /workflow:tdd-plan
|
||||
2. /workflow:execute
|
||||
3. /workflow:tdd-verify
|
||||
```
|
||||
|
||||
### Issue 批处理流程
|
||||
|
||||
```
|
||||
1. /issue:plan --all-pending
|
||||
2. /issue:queue
|
||||
3. /issue:execute
|
||||
```
|
||||
|
||||
## JSON Format
|
||||
|
||||
```json
|
||||
{
|
||||
"workflow_commands": [
|
||||
{
|
||||
"category": "Planning",
|
||||
"commands": [
|
||||
{ "name": "/workflow:lite-plan", "description": "轻量级规划" },
|
||||
{ "name": "/workflow:plan", "description": "标准规划" },
|
||||
{ "name": "/workflow:multi-cli-plan", "description": "多CLI协作规划" },
|
||||
{ "name": "/workflow:brainstorm:auto-parallel", "description": "头脑风暴" },
|
||||
{ "name": "/workflow:tdd-plan", "description": "TDD规划" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "Execution",
|
||||
"commands": [
|
||||
{ "name": "/workflow:lite-execute", "description": "轻量级执行" },
|
||||
{ "name": "/workflow:execute", "description": "标准执行" },
|
||||
{ "name": "/workflow:test-cycle-execute", "description": "测试循环执行" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "BugFix",
|
||||
"commands": [
|
||||
{ "name": "/workflow:lite-fix", "description": "轻量级修复" },
|
||||
{ "name": "/workflow:lite-fix --hotfix", "description": "紧急修复" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "Testing",
|
||||
"commands": [
|
||||
{ "name": "/workflow:test-gen", "description": "测试生成" },
|
||||
{ "name": "/workflow:test-fix-gen", "description": "测试修复" },
|
||||
{ "name": "/workflow:tdd-verify", "description": "TDD验证" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "Review",
|
||||
"commands": [
|
||||
{ "name": "/workflow:review-session-cycle", "description": "会话审查" },
|
||||
{ "name": "/workflow:review-module-cycle", "description": "模块审查" },
|
||||
{ "name": "/workflow:review-fix", "description": "审查修复" },
|
||||
{ "name": "/workflow:plan-verify", "description": "计划验证" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "Documentation",
|
||||
"commands": [
|
||||
{ "name": "/memory:docs", "description": "生成文档" },
|
||||
{ "name": "/memory:update-related", "description": "更新相关文档" },
|
||||
{ "name": "/memory:update-full", "description": "全面更新文档" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "Issues",
|
||||
"commands": [
|
||||
{ "name": "/issue:discover", "description": "发现Issue" },
|
||||
{ "name": "/issue:discover-by-prompt", "description": "基于提示发现Issue" },
|
||||
{ "name": "/issue:plan --all-pending", "description": "规划所有待处理Issue" },
|
||||
{ "name": "/issue:queue", "description": "排队Issue" },
|
||||
{ "name": "/issue:execute", "description": "执行Issue" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -1,362 +0,0 @@
|
||||
# CCW Coordinator Specifications
|
||||
|
||||
命令库、验证规则和注册表一体化规范。
|
||||
|
||||
---
|
||||
|
||||
## 命令库
|
||||
|
||||
### Planning Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-plan` | 轻量级规划 | L2 |
|
||||
| `/workflow:plan` | 标准规划 | L3 |
|
||||
| `/workflow:multi-cli-plan` | 多CLI协作规划 | L2 |
|
||||
| `/workflow:brainstorm:auto-parallel` | 头脑风暴规划 | L4 |
|
||||
| `/workflow:tdd-plan` | TDD规划 | L3 |
|
||||
|
||||
### Execution Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-execute` | 轻量级执行 | L2 |
|
||||
| `/workflow:execute` | 标准执行 | L3 |
|
||||
| `/workflow:test-cycle-execute` | 测试循环执行 | L3 |
|
||||
|
||||
### BugFix Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:lite-fix` | 轻量级修复 | L2 |
|
||||
| `/workflow:lite-fix --hotfix` | 紧急修复 | L2 |
|
||||
|
||||
### Testing Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:test-gen` | 测试生成 | L3 |
|
||||
| `/workflow:test-fix-gen` | 测试修复生成 | L3 |
|
||||
| `/workflow:tdd-verify` | TDD验证 | L3 |
|
||||
|
||||
### Review Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/workflow:review-session-cycle` | 会话审查 | L3 |
|
||||
| `/workflow:review-module-cycle` | 模块审查 | L3 |
|
||||
| `/workflow:review-fix` | 审查修复 | L3 |
|
||||
| `/workflow:plan-verify` | 计划验证 | L3 |
|
||||
|
||||
### Documentation Commands
|
||||
|
||||
| Command | Description | Level |
|
||||
|---------|-------------|-------|
|
||||
| `/memory:docs` | 生成文档 | L2 |
|
||||
| `/memory:update-related` | 更新相关文档 | L2 |
|
||||
| `/memory:update-full` | 全面更新文档 | L2 |
|
||||
|
||||
### Issue Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/issue:discover` | 发现Issue |
|
||||
| `/issue:discover-by-prompt` | 基于提示发现Issue |
|
||||
| `/issue:plan --all-pending` | 规划所有待处理Issue |
|
||||
| `/issue:queue` | 排队Issue |
|
||||
| `/issue:execute` | 执行Issue |
|
||||
|
||||
---
|
||||
|
||||
## 命令链推荐
|
||||
|
||||
### 标准开发流程
|
||||
|
||||
```
|
||||
1. /workflow:lite-plan
|
||||
2. /workflow:lite-execute
|
||||
3. /workflow:test-cycle-execute
|
||||
```
|
||||
|
||||
### 完整规划流程
|
||||
|
||||
```
|
||||
1. /workflow:plan
|
||||
2. /workflow:plan-verify
|
||||
3. /workflow:execute
|
||||
4. /workflow:review-session-cycle
|
||||
```
|
||||
|
||||
### TDD 流程
|
||||
|
||||
```
|
||||
1. /workflow:tdd-plan
|
||||
2. /workflow:execute
|
||||
3. /workflow:tdd-verify
|
||||
```
|
||||
|
||||
### Issue 批处理流程
|
||||
|
||||
```
|
||||
1. /issue:plan --all-pending
|
||||
2. /issue:queue
|
||||
3. /issue:execute
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 验证规则
|
||||
|
||||
### Rule 1: Single Planning Command
|
||||
|
||||
每条链最多包含一个规划命令。
|
||||
|
||||
| 有效 | 无效 |
|
||||
|------|------|
|
||||
| `plan → execute` | `plan → lite-plan → execute` |
|
||||
|
||||
### Rule 2: Compatible Pairs
|
||||
|
||||
规划和执行命令必须兼容。
|
||||
|
||||
| Planning | Execution | 兼容 |
|
||||
|----------|-----------|------|
|
||||
| lite-plan | lite-execute | ✓ |
|
||||
| lite-plan | execute | ✗ |
|
||||
| multi-cli-plan | lite-execute | ✓ |
|
||||
| multi-cli-plan | execute | ✓ |
|
||||
| plan | execute | ✓ |
|
||||
| plan | lite-execute | ✗ |
|
||||
| tdd-plan | execute | ✓ |
|
||||
| tdd-plan | lite-execute | ✗ |
|
||||
|
||||
### Rule 3: Testing After Execution
|
||||
|
||||
测试命令必须在执行命令之后。
|
||||
|
||||
| 有效 | 无效 |
|
||||
|------|------|
|
||||
| `execute → test-cycle-execute` | `test-cycle-execute → execute` |
|
||||
|
||||
### Rule 4: Review After Execution
|
||||
|
||||
审查命令必须在执行命令之后。
|
||||
|
||||
| 有效 | 无效 |
|
||||
|------|------|
|
||||
| `execute → review-session-cycle` | `review-session-cycle → execute` |
|
||||
|
||||
### Rule 5: BugFix Standalone
|
||||
|
||||
`lite-fix` 必须单独执行,不能与其他命令组合。
|
||||
|
||||
| 有效 | 无效 |
|
||||
|------|------|
|
||||
| `lite-fix` | `plan → lite-fix → execute` |
|
||||
| `lite-fix --hotfix` | `lite-fix → test-cycle-execute` |
|
||||
|
||||
### Rule 6: Dependency Satisfaction
|
||||
|
||||
每个命令的依赖必须在前面执行。
|
||||
|
||||
```javascript
|
||||
test-fix-gen → test-cycle-execute ✓
|
||||
test-cycle-execute ✗
|
||||
```
|
||||
|
||||
### Rule 7: No Redundancy
|
||||
|
||||
链条中不能有重复的命令。
|
||||
|
||||
| 有效 | 无效 |
|
||||
|------|------|
|
||||
| `plan → execute → test` | `plan → plan → execute` |
|
||||
|
||||
### Rule 8: Command Exists
|
||||
|
||||
所有命令必须在此规范中定义。
|
||||
|
||||
---
|
||||
|
||||
## 反模式(避免)
|
||||
|
||||
### ❌ Pattern 1: Multiple Planning
|
||||
|
||||
```
|
||||
plan → lite-plan → execute
|
||||
```
|
||||
**问题**: 重复分析,浪费时间
|
||||
**修复**: 选一个规划命令
|
||||
|
||||
### ❌ Pattern 2: Test Without Context
|
||||
|
||||
```
|
||||
test-cycle-execute (独立执行)
|
||||
```
|
||||
**问题**: 没有执行上下文,无法工作
|
||||
**修复**: 先执行 `execute` 或 `test-fix-gen`
|
||||
|
||||
### ❌ Pattern 3: BugFix with Planning
|
||||
|
||||
```
|
||||
plan → execute → lite-fix
|
||||
```
|
||||
**问题**: lite-fix 是独立命令,不应与规划混合
|
||||
**修复**: 用 `lite-fix` 单独修复,或用 `plan → execute` 做大改
|
||||
|
||||
### ❌ Pattern 4: Review Without Changes
|
||||
|
||||
```
|
||||
review-session-cycle (独立执行)
|
||||
```
|
||||
**问题**: 没有 git 改动可审查
|
||||
**修复**: 先执行 `execute` 生成改动
|
||||
|
||||
### ❌ Pattern 5: TDD Misuse
|
||||
|
||||
```
|
||||
tdd-plan → lite-execute
|
||||
```
|
||||
**问题**: lite-execute 无法处理 TDD 任务结构
|
||||
**修复**: 用 `tdd-plan → execute → tdd-verify`
|
||||
|
||||
---
|
||||
|
||||
## 命令注册表
|
||||
|
||||
### 命令元数据结构
|
||||
|
||||
```json
|
||||
{
|
||||
"command_name": {
|
||||
"category": "Planning|Execution|Testing|Review|BugFix|Maintenance",
|
||||
"level": "L0|L1|L2|L3",
|
||||
"description": "命令描述",
|
||||
"inputs": ["input1", "input2"],
|
||||
"outputs": ["output1", "output2"],
|
||||
"dependencies": ["依赖命令"],
|
||||
"parameters": [
|
||||
{"name": "--flag", "type": "string|boolean|number", "default": "value"}
|
||||
],
|
||||
"chain_position": "start|middle|middle_or_end|end|standalone",
|
||||
"next_recommended": ["推荐的下一个命令"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 命令分组
|
||||
|
||||
| Group | Commands |
|
||||
|-------|----------|
|
||||
| planning | lite-plan, multi-cli-plan, plan, tdd-plan |
|
||||
| execution | lite-execute, execute, develop-with-file |
|
||||
| testing | test-gen, test-fix-gen, test-cycle-execute, tdd-verify |
|
||||
| review | review-session-cycle, review-module-cycle, review-fix |
|
||||
| bugfix | lite-fix, debug, debug-with-file |
|
||||
| maintenance | clean, replan |
|
||||
| verification | plan-verify, tdd-verify |
|
||||
|
||||
### 兼容性矩阵
|
||||
|
||||
| 组合 | 状态 |
|
||||
|------|------|
|
||||
| lite-plan + lite-execute | ✓ compatible |
|
||||
| lite-plan + execute | ✗ incompatible - use plan |
|
||||
| multi-cli-plan + lite-execute | ✓ compatible |
|
||||
| plan + execute | ✓ compatible |
|
||||
| plan + lite-execute | ✗ incompatible - use lite-plan |
|
||||
| tdd-plan + execute | ✓ compatible |
|
||||
| execute + test-cycle-execute | ✓ compatible |
|
||||
| lite-execute + test-cycle-execute | ✓ compatible |
|
||||
| test-fix-gen + test-cycle-execute | ✓ required |
|
||||
| review-session-cycle + review-fix | ✓ compatible |
|
||||
| lite-fix + test-cycle-execute | ✗ incompatible - lite-fix standalone |
|
||||
|
||||
---
|
||||
|
||||
## 验证工具
|
||||
|
||||
### chain-validate.cjs
|
||||
|
||||
位置: `tools/chain-validate.cjs`
|
||||
|
||||
验证命令链合法性:
|
||||
|
||||
```bash
|
||||
node tools/chain-validate.cjs plan execute test-cycle-execute
|
||||
```
|
||||
|
||||
输出:
|
||||
```
|
||||
{
|
||||
"valid": true,
|
||||
"errors": [],
|
||||
"warnings": []
|
||||
}
|
||||
```
|
||||
|
||||
## 命令注册表
|
||||
|
||||
### 工具位置
|
||||
|
||||
位置: `tools/command-registry.cjs` (skill 内置)
|
||||
|
||||
### 工作模式
|
||||
|
||||
**按需提取**: 只提取用户确定的任务链中的命令,不是全量扫描。
|
||||
|
||||
```javascript
|
||||
// 用户任务链: [lite-plan, lite-execute]
|
||||
const commandNames = command_chain.map(cmd => cmd.command);
|
||||
const commandMeta = registry.getCommands(commandNames);
|
||||
// 只提取这 2 个命令的元数据
|
||||
```
|
||||
|
||||
### 功能
|
||||
|
||||
- 自动查找全局 `.claude/commands/workflow` 目录(相对路径 > 用户 home)
|
||||
- 按需提取指定命令的 YAML 头元数据
|
||||
- 缓存机制避免重复读取
|
||||
- 提供批量查询接口
|
||||
|
||||
### 集成方式
|
||||
|
||||
在 action-command-execute 中自动集成:
|
||||
|
||||
```javascript
|
||||
const CommandRegistry = require('./tools/command-registry.cjs');
|
||||
const registry = new CommandRegistry();
|
||||
|
||||
// 只提取任务链中的命令
|
||||
const commandNames = command_chain.map(cmd => cmd.command);
|
||||
const commandMeta = registry.getCommands(commandNames);
|
||||
|
||||
// 使用元数据生成提示词
|
||||
const cmdInfo = commandMeta[cmd.command];
|
||||
// {
|
||||
// name: 'lite-plan',
|
||||
// description: '轻量级规划...',
|
||||
// argumentHint: '[-e|--explore] "task description"',
|
||||
// allowedTools: [...],
|
||||
// filePath: '...'
|
||||
// }
|
||||
```
|
||||
|
||||
### 提示词生成
|
||||
|
||||
智能提示词自动包含:
|
||||
|
||||
1. **任务上下文**: 用户任务描述
|
||||
2. **前序产物**: 已完成命令的产物信息
|
||||
3. **命令元数据**: 命令的参数提示和描述
|
||||
|
||||
```
|
||||
任务: 实现用户注册功能
|
||||
|
||||
前序完成:
|
||||
- /workflow:lite-plan: WFS-plan-001 (IMPL_PLAN.md)
|
||||
|
||||
命令: /workflow:lite-execute [--resume-session="session-id"]
|
||||
```
|
||||
|
||||
详见 `tools/README.md`。
|
||||
@@ -1,95 +0,0 @@
|
||||
# CCW Coordinator Tools
|
||||
|
||||
## command-registry.cjs
|
||||
|
||||
命令注册表工具:获取和提取命令元数据。
|
||||
|
||||
### 功能
|
||||
|
||||
- **按需提取**: 只提取指定命令的完整信息(name, description, argumentHint, allowedTools 等)
|
||||
- **全量获取**: 获取所有命令的名称和描述(快速查询)
|
||||
- **自动查找**: 从全局 `.claude/commands/workflow` 目录读取(项目相对路径 > 用户 home)
|
||||
- **缓存机制**: 避免重复读取文件
|
||||
|
||||
### 编程接口
|
||||
|
||||
```javascript
|
||||
const CommandRegistry = require('./tools/command-registry.cjs');
|
||||
const registry = new CommandRegistry();
|
||||
|
||||
// 1. 获取所有命令的名称和描述(快速)
|
||||
const allCommands = registry.getAllCommandsSummary();
|
||||
// {
|
||||
// "/workflow:lite-plan": {
|
||||
// name: 'lite-plan',
|
||||
// description: '轻量级规划...'
|
||||
// },
|
||||
// "/workflow:lite-execute": { ... }
|
||||
// }
|
||||
|
||||
// 2. 按需提取指定命令的完整信息
|
||||
const commands = registry.getCommands([
|
||||
'/workflow:lite-plan',
|
||||
'/workflow:lite-execute'
|
||||
]);
|
||||
// {
|
||||
// "/workflow:lite-plan": {
|
||||
// name: 'lite-plan',
|
||||
// description: '...',
|
||||
// argumentHint: '[-e|--explore] "task description"',
|
||||
// allowedTools: [...],
|
||||
// filePath: '...'
|
||||
// },
|
||||
// ...
|
||||
// }
|
||||
```
|
||||
|
||||
### 命令行接口
|
||||
|
||||
```bash
|
||||
# 获取所有命令的名称和描述
|
||||
node .claude/skills/ccw-coordinator/tools/command-registry.cjs
|
||||
node .claude/skills/ccw-coordinator/tools/command-registry.cjs --all
|
||||
|
||||
# 输出: 23 个命令的简明列表 (name + description)
|
||||
```
|
||||
|
||||
```bash
|
||||
# 按需提取指定命令的完整信息
|
||||
node .claude/skills/ccw-coordinator/tools/command-registry.cjs lite-plan lite-execute
|
||||
|
||||
# 输出: 完整信息 (name, description, argumentHint, allowedTools, filePath)
|
||||
```
|
||||
|
||||
### 集成用途
|
||||
|
||||
在 `action-command-execute` 中使用:
|
||||
|
||||
```javascript
|
||||
// 1. 初始化时只提取任务链中的命令(完整信息)
|
||||
const commandNames = command_chain.map(cmd => cmd.command);
|
||||
const commandMeta = registry.getCommands(commandNames);
|
||||
|
||||
// 2. 生成提示词时使用
|
||||
function generatePrompt(cmd, state, commandMeta) {
|
||||
const cmdInfo = commandMeta[cmd.command];
|
||||
let prompt = `任务: ${state.task_description}\n`;
|
||||
|
||||
if (cmdInfo?.argumentHint) {
|
||||
prompt += `命令: ${cmd.command} ${cmdInfo.argumentHint}`;
|
||||
}
|
||||
|
||||
return prompt;
|
||||
}
|
||||
```
|
||||
|
||||
确保 `ccw cli -p "..."` 提示词包含准确的命令参数提示。
|
||||
|
||||
### 目录查找逻辑
|
||||
|
||||
自动查找顺序:
|
||||
1. `.claude/commands/workflow` (相对于当前工作目录)
|
||||
2. `~/.claude/commands/workflow` (用户 home 目录)
|
||||
|
||||
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Chain Validation Tool
|
||||
*
|
||||
* Validates workflow command chains against defined rules.
|
||||
*
|
||||
* Usage:
|
||||
* node chain-validate.js plan execute test-cycle-execute
|
||||
* node chain-validate.js --json "plan,execute,test-cycle-execute"
|
||||
* node chain-validate.js --file custom-chain.json
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Optional registry loading - gracefully degrade if not found
|
||||
let registry = null;
|
||||
try {
|
||||
const registryPath = path.join(__dirname, '..', 'specs', 'chain-registry.json');
|
||||
if (fs.existsSync(registryPath)) {
|
||||
registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
||||
}
|
||||
} catch (error) {
|
||||
// Registry not available - dependency validation will be skipped
|
||||
}
|
||||
|
||||
class ChainValidator {
|
||||
constructor(registry) {
|
||||
this.registry = registry;
|
||||
this.errors = [];
|
||||
this.warnings = [];
|
||||
}
|
||||
|
||||
validate(chain) {
|
||||
this.errors = [];
|
||||
this.warnings = [];
|
||||
|
||||
this.validateSinglePlanning(chain);
|
||||
this.validateCompatiblePairs(chain);
|
||||
this.validateTestingPosition(chain);
|
||||
this.validateReviewPosition(chain);
|
||||
this.validateBugfixStandalone(chain);
|
||||
this.validateDependencies(chain);
|
||||
this.validateNoRedundancy(chain);
|
||||
this.validateCommandExistence(chain);
|
||||
|
||||
return {
|
||||
valid: this.errors.length === 0,
|
||||
errors: this.errors,
|
||||
warnings: this.warnings
|
||||
};
|
||||
}
|
||||
|
||||
validateSinglePlanning(chain) {
|
||||
const planningCommands = chain.filter(cmd =>
|
||||
['plan', 'lite-plan', 'multi-cli-plan', 'tdd-plan'].includes(cmd)
|
||||
);
|
||||
|
||||
if (planningCommands.length > 1) {
|
||||
this.errors.push({
|
||||
rule: 'Single Planning Command',
|
||||
message: `Too many planning commands: ${planningCommands.join(', ')}`,
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
validateCompatiblePairs(chain) {
|
||||
const compatibility = {
|
||||
'lite-plan': ['lite-execute'],
|
||||
'multi-cli-plan': ['lite-execute', 'execute'],
|
||||
'plan': ['execute'],
|
||||
'tdd-plan': ['execute']
|
||||
};
|
||||
|
||||
const planningCmd = chain.find(cmd =>
|
||||
['plan', 'lite-plan', 'multi-cli-plan', 'tdd-plan'].includes(cmd)
|
||||
);
|
||||
|
||||
const executionCmd = chain.find(cmd =>
|
||||
['execute', 'lite-execute'].includes(cmd)
|
||||
);
|
||||
|
||||
if (planningCmd && executionCmd) {
|
||||
const compatible = compatibility[planningCmd] || [];
|
||||
if (!compatible.includes(executionCmd)) {
|
||||
this.errors.push({
|
||||
rule: 'Compatible Pairs',
|
||||
message: `${planningCmd} incompatible with ${executionCmd}`,
|
||||
fix: `Use ${planningCmd} with ${compatible.join(' or ')}`,
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateTestingPosition(chain) {
|
||||
const executionIdx = chain.findIndex(cmd =>
|
||||
['execute', 'lite-execute', 'develop-with-file'].includes(cmd)
|
||||
);
|
||||
|
||||
const testingIdx = chain.findIndex(cmd =>
|
||||
['test-cycle-execute', 'tdd-verify', 'test-gen', 'test-fix-gen'].includes(cmd)
|
||||
);
|
||||
|
||||
if (testingIdx !== -1 && executionIdx !== -1 && executionIdx > testingIdx) {
|
||||
this.errors.push({
|
||||
rule: 'Testing After Execution',
|
||||
message: 'Testing commands must come after execution',
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
if (testingIdx !== -1 && executionIdx === -1) {
|
||||
const hasTestGen = chain.some(cmd => ['test-gen', 'test-fix-gen'].includes(cmd));
|
||||
if (!hasTestGen) {
|
||||
this.warnings.push({
|
||||
rule: 'Testing After Execution',
|
||||
message: 'test-cycle-execute without execution context - needs test-gen or execute first',
|
||||
severity: 'warning'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateReviewPosition(chain) {
|
||||
const executionIdx = chain.findIndex(cmd =>
|
||||
['execute', 'lite-execute'].includes(cmd)
|
||||
);
|
||||
|
||||
const reviewIdx = chain.findIndex(cmd =>
|
||||
cmd.includes('review')
|
||||
);
|
||||
|
||||
if (reviewIdx !== -1 && executionIdx !== -1 && executionIdx > reviewIdx) {
|
||||
this.errors.push({
|
||||
rule: 'Review After Changes',
|
||||
message: 'Review commands must come after execution',
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
if (reviewIdx !== -1 && executionIdx === -1) {
|
||||
const isModuleReview = chain[reviewIdx] === 'review-module-cycle';
|
||||
if (!isModuleReview) {
|
||||
this.warnings.push({
|
||||
rule: 'Review After Changes',
|
||||
message: 'Review without execution - needs git changes to review',
|
||||
severity: 'warning'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateBugfixStandalone(chain) {
|
||||
if (chain.includes('lite-fix')) {
|
||||
const others = chain.filter(cmd => cmd !== 'lite-fix');
|
||||
if (others.length > 0) {
|
||||
this.errors.push({
|
||||
rule: 'BugFix Standalone',
|
||||
message: 'lite-fix must be standalone, cannot combine with other commands',
|
||||
fix: 'Use lite-fix alone OR use plan + execute for larger changes',
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateDependencies(chain) {
|
||||
// Skip if registry not available
|
||||
if (!this.registry || !this.registry.commands) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
const cmd = chain[i];
|
||||
const cmdMeta = this.registry.commands[cmd];
|
||||
|
||||
if (!cmdMeta) continue;
|
||||
|
||||
const deps = cmdMeta.dependencies || [];
|
||||
const depsOptional = cmdMeta.dependencies_optional || false;
|
||||
|
||||
if (deps.length > 0 && !depsOptional) {
|
||||
const hasDependency = deps.some(dep => {
|
||||
const depIdx = chain.indexOf(dep);
|
||||
return depIdx !== -1 && depIdx < i;
|
||||
});
|
||||
|
||||
if (!hasDependency) {
|
||||
this.errors.push({
|
||||
rule: 'Dependency Satisfaction',
|
||||
message: `${cmd} requires ${deps.join(' or ')} before it`,
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateNoRedundancy(chain) {
|
||||
const seen = new Set();
|
||||
const duplicates = [];
|
||||
|
||||
for (const cmd of chain) {
|
||||
if (seen.has(cmd)) {
|
||||
duplicates.push(cmd);
|
||||
}
|
||||
seen.add(cmd);
|
||||
}
|
||||
|
||||
if (duplicates.length > 0) {
|
||||
this.errors.push({
|
||||
rule: 'No Redundant Commands',
|
||||
message: `Duplicate commands: ${duplicates.join(', ')}`,
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
validateCommandExistence(chain) {
|
||||
// Skip if registry not available
|
||||
if (!this.registry || !this.registry.commands) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const cmd of chain) {
|
||||
if (!this.registry.commands[cmd]) {
|
||||
this.errors.push({
|
||||
rule: 'Command Existence',
|
||||
message: `Unknown command: ${cmd}`,
|
||||
severity: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0) {
|
||||
console.log('Usage:');
|
||||
console.log(' chain-validate.js <command1> <command2> ...');
|
||||
console.log(' chain-validate.js --json "cmd1,cmd2,cmd3"');
|
||||
console.log(' chain-validate.js --file chain.json');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let chain;
|
||||
|
||||
if (args[0] === '--json') {
|
||||
chain = args[1].split(',').map(s => s.trim());
|
||||
} else if (args[0] === '--file') {
|
||||
const filePath = args[1];
|
||||
|
||||
// SEC-001: 路径遍历验证 - 只允许访问工作目录下的文件
|
||||
const resolvedPath = path.resolve(filePath);
|
||||
const workDir = path.resolve('.');
|
||||
if (!resolvedPath.startsWith(workDir)) {
|
||||
console.error('Error: File path must be within current working directory');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// CORR-001: JSON 解析错误处理
|
||||
let fileContent;
|
||||
try {
|
||||
fileContent = JSON.parse(fs.readFileSync(resolvedPath, 'utf8'));
|
||||
} catch (error) {
|
||||
console.error(`Error: Failed to parse JSON file ${filePath}: ${error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// CORR-002: 嵌套属性 null 检查
|
||||
chain = fileContent.chain || fileContent.steps?.map(s => s.command) || [];
|
||||
if (chain.length === 0) {
|
||||
console.error('Error: No valid chain found in file (expected "chain" array or "steps" with "command" fields)');
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
chain = args;
|
||||
}
|
||||
|
||||
const validator = new ChainValidator(registry);
|
||||
const result = validator.validate(chain);
|
||||
|
||||
console.log('\n=== Chain Validation Report ===\n');
|
||||
console.log('Chain:', chain.join(' → '));
|
||||
console.log('');
|
||||
|
||||
if (result.valid) {
|
||||
console.log('✓ Chain is valid!\n');
|
||||
} else {
|
||||
console.log('✗ Chain has errors:\n');
|
||||
result.errors.forEach(err => {
|
||||
console.log(` [${err.rule}] ${err.message}`);
|
||||
if (err.fix) {
|
||||
console.log(` Fix: ${err.fix}`);
|
||||
}
|
||||
});
|
||||
console.log('');
|
||||
}
|
||||
|
||||
if (result.warnings.length > 0) {
|
||||
console.log('⚠ Warnings:\n');
|
||||
result.warnings.forEach(warn => {
|
||||
console.log(` [${warn.rule}] ${warn.message}`);
|
||||
});
|
||||
console.log('');
|
||||
}
|
||||
|
||||
process.exit(result.valid ? 0 : 1);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = { ChainValidator };
|
||||
@@ -1,255 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Command Registry Tool
|
||||
*
|
||||
* 功能:
|
||||
* 1. 根据命令名称查找并提取 YAML 头
|
||||
* 2. 从全局 .claude/commands/workflow 目录读取
|
||||
* 3. 支持按需提取(不是全量扫描)
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
class CommandRegistry {
|
||||
constructor(commandDir = null) {
|
||||
// 优先使用传入的目录
|
||||
if (commandDir) {
|
||||
this.commandDir = commandDir;
|
||||
} else {
|
||||
// 自动查找 .claude/commands/workflow
|
||||
this.commandDir = this.findCommandDir();
|
||||
}
|
||||
this.cache = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动查找 .claude/commands/workflow 目录
|
||||
* 支持: 项目相对路径、用户 home 目录
|
||||
*/
|
||||
findCommandDir() {
|
||||
// 1. 尝试相对于当前工作目录
|
||||
const relativePath = path.join('.claude', 'commands', 'workflow');
|
||||
if (fs.existsSync(relativePath)) {
|
||||
return path.resolve(relativePath);
|
||||
}
|
||||
|
||||
// 2. 尝试用户 home 目录
|
||||
const homeDir = os.homedir();
|
||||
const homeCommandDir = path.join(homeDir, '.claude', 'commands', 'workflow');
|
||||
if (fs.existsSync(homeCommandDir)) {
|
||||
return homeCommandDir;
|
||||
}
|
||||
|
||||
// 未找到时返回 null,后续操作会失败并提示
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 YAML 头 (简化版本)
|
||||
*
|
||||
* 限制:
|
||||
* - 只支持简单的 key: value 对 (单行值)
|
||||
* - 不支持多行值、嵌套对象、复杂列表
|
||||
* - allowed-tools 字段支持逗号分隔的字符串,自动转为数组
|
||||
*
|
||||
* 示例:
|
||||
* ---
|
||||
* name: lite-plan
|
||||
* description: "Lightweight planning workflow"
|
||||
* allowed-tools: Read, Write, Bash
|
||||
* ---
|
||||
*/
|
||||
parseYamlHeader(content) {
|
||||
// 处理 Windows 行结尾 (\r\n)
|
||||
const match = content.match(/^---[\r\n]+([\s\S]*?)[\r\n]+---/);
|
||||
if (!match) return null;
|
||||
|
||||
const yamlContent = match[1];
|
||||
const result = {};
|
||||
|
||||
try {
|
||||
const lines = yamlContent.split(/[\r\n]+/);
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith('#')) continue; // 跳过空行和注释
|
||||
|
||||
const colonIndex = trimmed.indexOf(':');
|
||||
if (colonIndex === -1) continue;
|
||||
|
||||
const key = trimmed.substring(0, colonIndex).trim();
|
||||
const value = trimmed.substring(colonIndex + 1).trim();
|
||||
|
||||
if (!key) continue; // 跳过无效行
|
||||
|
||||
// 去除引号 (单引号或双引号)
|
||||
let cleanValue = value.replace(/^["']|["']$/g, '');
|
||||
|
||||
// allowed-tools 字段特殊处理:转为数组
|
||||
// 支持格式: "Read, Write, Bash" 或 "Read,Write,Bash"
|
||||
if (key === 'allowed-tools') {
|
||||
cleanValue = Array.isArray(cleanValue)
|
||||
? cleanValue
|
||||
: cleanValue.split(',').map(t => t.trim()).filter(t => t);
|
||||
}
|
||||
|
||||
result[key] = cleanValue;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('YAML parsing error:', error.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个命令的元数据
|
||||
* @param {string} commandName 命令名称 (e.g., "lite-plan" 或 "/workflow:lite-plan")
|
||||
* @returns {object|null} 命令信息或 null
|
||||
*/
|
||||
getCommand(commandName) {
|
||||
if (!this.commandDir) {
|
||||
console.error('ERROR: .claude/commands/workflow 目录未找到');
|
||||
return null;
|
||||
}
|
||||
|
||||
// 标准化命令名称
|
||||
const normalized = commandName.startsWith('/workflow:')
|
||||
? commandName.substring('/workflow:'.length)
|
||||
: commandName;
|
||||
|
||||
// 检查缓存
|
||||
if (this.cache[normalized]) {
|
||||
return this.cache[normalized];
|
||||
}
|
||||
|
||||
// 读取命令文件
|
||||
const filePath = path.join(this.commandDir, `${normalized}.md`);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const header = this.parseYamlHeader(content);
|
||||
|
||||
if (header && header.name) {
|
||||
const result = {
|
||||
name: header.name,
|
||||
command: `/workflow:${header.name}`,
|
||||
description: header.description || '',
|
||||
argumentHint: header['argument-hint'] || '',
|
||||
allowedTools: Array.isArray(header['allowed-tools'])
|
||||
? header['allowed-tools']
|
||||
: (header['allowed-tools'] ? [header['allowed-tools']] : []),
|
||||
filePath: filePath
|
||||
};
|
||||
|
||||
// 缓存结果
|
||||
this.cache[normalized] = result;
|
||||
return result;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`读取命令失败 ${filePath}:`, error.message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取多个命令的元数据
|
||||
* @param {array} commandNames 命令名称数组
|
||||
* @returns {object} 命令信息映射
|
||||
*/
|
||||
getCommands(commandNames) {
|
||||
const result = {};
|
||||
|
||||
for (const name of commandNames) {
|
||||
const cmd = this.getCommand(name);
|
||||
if (cmd) {
|
||||
result[cmd.command] = cmd;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有命令的名称和描述
|
||||
* @returns {object} 命令名称和描述的映射
|
||||
*/
|
||||
getAllCommandsSummary() {
|
||||
const result = {};
|
||||
const commandDir = this.commandDir;
|
||||
|
||||
if (!commandDir) {
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
const files = fs.readdirSync(commandDir);
|
||||
|
||||
for (const file of files) {
|
||||
if (!file.endsWith('.md')) continue;
|
||||
|
||||
const filePath = path.join(commandDir, file);
|
||||
const stat = fs.statSync(filePath);
|
||||
|
||||
if (stat.isDirectory()) continue;
|
||||
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const header = this.parseYamlHeader(content);
|
||||
|
||||
if (header && header.name) {
|
||||
const commandName = `/workflow:${header.name}`;
|
||||
result[commandName] = {
|
||||
name: header.name,
|
||||
description: header.description || ''
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
// 跳过读取失败的文件
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 目录读取失败
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成注册表 JSON
|
||||
*/
|
||||
toJSON(commands = null) {
|
||||
const data = commands || this.cache;
|
||||
return JSON.stringify(data, null, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// CLI 模式
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0 || args[0] === '--all') {
|
||||
// 获取所有命令的名称和描述
|
||||
const registry = new CommandRegistry();
|
||||
const commands = registry.getAllCommandsSummary();
|
||||
console.log(JSON.stringify(commands, null, 2));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const registry = new CommandRegistry();
|
||||
const commands = registry.getCommands(args);
|
||||
|
||||
console.log(JSON.stringify(commands, null, 2));
|
||||
}
|
||||
|
||||
module.exports = CommandRegistry;
|
||||
|
||||
@@ -11,8 +11,8 @@ CCW 命令帮助系统,提供命令搜索、推荐、文档查看功能。
|
||||
|
||||
## Trigger Conditions
|
||||
|
||||
- 关键词: "ccw-help", "ccw-issue", "帮助", "命令", "怎么用"
|
||||
- 场景: 询问命令用法、搜索命令、请求下一步建议
|
||||
- 关键词: "ccw-help", "ccw-issue", "帮助", "命令", "怎么用", "ccw 怎么用", "工作流"
|
||||
- 场景: 询问命令用法、搜索命令、请求下一步建议、询问任务应该用哪个工作流
|
||||
|
||||
## Operation Modes
|
||||
|
||||
@@ -50,7 +50,35 @@ CCW 命令帮助系统,提供命令搜索、推荐、文档查看功能。
|
||||
1. Query `essential_commands` array
|
||||
2. Guide appropriate workflow entry point
|
||||
|
||||
### Mode 5: Issue Reporting
|
||||
### Mode 5: CCW Command Orchestration
|
||||
|
||||
**Triggers**: "ccw ", "自动工作流", "自动选择工作流", "帮我规划"
|
||||
|
||||
**Process**:
|
||||
1. Analyze user intent (task type, complexity, clarity)
|
||||
2. Auto-select workflow level (1-4 or Issue)
|
||||
3. Build command chain based on workflow
|
||||
4. Get user confirmation
|
||||
5. Execute chain with TODO tracking
|
||||
|
||||
**Supported Workflows**:
|
||||
- **Level 1** (Lite-Lite-Lite): Ultra-simple quick tasks
|
||||
- **Level 2** (Rapid/Hotfix): Bug fixes, simple features, documentation
|
||||
- **Level 2.5** (Rapid-to-Issue): Bridge from quick planning to issue workflow
|
||||
- **Level 3** (Coupled): Complex features with planning, execution, review, tests
|
||||
- **Level 3 Variants**:
|
||||
- TDD workflows (test-first development)
|
||||
- Test-fix workflows (debug failing tests)
|
||||
- Review workflows (code review and fixes)
|
||||
- UI design workflows
|
||||
- **Level 4** (Full): Exploratory tasks with brainstorming
|
||||
- **With-File Workflows**: Documented exploration with multi-CLI collaboration
|
||||
- `brainstorm-with-file`: Multi-perspective ideation
|
||||
- `debug-with-file`: Hypothesis-driven debugging
|
||||
- `analyze-with-file`: Collaborative analysis
|
||||
- **Issue Workflow**: Batch issue discovery, planning, queueing, execution
|
||||
|
||||
### Mode 6: Issue Reporting
|
||||
|
||||
**Triggers**: "ccw-issue", "报告 bug"
|
||||
|
||||
@@ -84,28 +112,60 @@ Single source of truth: **[command.json](command.json)**
|
||||
## Slash Commands
|
||||
|
||||
```bash
|
||||
/ccw-help # 通用帮助入口
|
||||
/ccw-help search <keyword> # 搜索命令
|
||||
/ccw-help next <command> # 获取下一步建议
|
||||
/ccw-issue # 问题报告
|
||||
/ccw "task description" # Auto-select workflow and execute
|
||||
/ccw-help # General help entry
|
||||
/ccw-help search <keyword> # Search commands
|
||||
/ccw-help next <command> # Get next step suggestions
|
||||
/ccw-issue # Issue reporting
|
||||
```
|
||||
|
||||
### CCW Command Examples
|
||||
|
||||
```bash
|
||||
/ccw "Add user authentication" # → auto-select level 2-3
|
||||
/ccw "Fix memory leak in WebSocket" # → auto-select bugfix workflow
|
||||
/ccw "Implement with TDD" # → detect TDD, use tdd-plan → execute → tdd-verify
|
||||
/ccw "头脑风暴: 用户通知系统" # → detect brainstorm, use brainstorm-with-file
|
||||
/ccw "深度调试: 系统随机崩溃" # → detect debug-file, use debug-with-file
|
||||
/ccw "协作分析: 认证架构设计" # → detect analyze-file, use analyze-with-file
|
||||
```
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Update Index
|
||||
### Update Mechanism
|
||||
|
||||
CCW-Help skill supports manual updates through user confirmation dialog.
|
||||
|
||||
#### How to Update
|
||||
|
||||
**Option 1: When executing the skill, user will be prompted:**
|
||||
|
||||
```
|
||||
Would you like to update CCW-Help command index?
|
||||
- Yes: Run auto-update and regenerate command.json
|
||||
- No: Use current index
|
||||
```
|
||||
|
||||
**Option 2: Manual update**
|
||||
|
||||
```bash
|
||||
cd D:/Claude_dms3/.claude/skills/ccw-help
|
||||
python scripts/analyze_commands.py
|
||||
python scripts/auto-update.py
|
||||
```
|
||||
|
||||
脚本功能:扫描 commands/ 和 agents/ 目录,生成统一的 command.json
|
||||
This runs `analyze_commands.py` to scan commands/ and agents/ directories and regenerate `command.json`.
|
||||
|
||||
#### Update Scripts
|
||||
|
||||
- **`auto-update.py`**: Simple wrapper that runs analyze_commands.py
|
||||
- **`analyze_commands.py`**: Scans directories and generates command index
|
||||
|
||||
## Statistics
|
||||
|
||||
- **Commands**: 88+
|
||||
- **Commands**: 50+
|
||||
- **Agents**: 16
|
||||
- **Essential**: 10 核心命令
|
||||
- **Workflows**: 6 main levels + 3 with-file variants
|
||||
- **Essential**: 10 core commands
|
||||
|
||||
## Core Principle
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
97
.claude/skills/ccw-help/index/all-agents.json
Normal file
97
.claude/skills/ccw-help/index/all-agents.json
Normal file
@@ -0,0 +1,97 @@
|
||||
[
|
||||
{
|
||||
"name": "action-planning-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/action-planning-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-discuss-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/cli-discuss-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-execution-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/cli-execution-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-explore-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/cli-explore-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-lite-planning-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/cli-lite-planning-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-planning-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/cli-planning-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "code-developer",
|
||||
"description": "|",
|
||||
"source": "../../../agents/code-developer.md"
|
||||
},
|
||||
{
|
||||
"name": "conceptual-planning-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/conceptual-planning-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "context-search-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/context-search-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "debug-explore-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/debug-explore-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "doc-generator",
|
||||
"description": "|",
|
||||
"source": "../../../agents/doc-generator.md"
|
||||
},
|
||||
{
|
||||
"name": "issue-plan-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/issue-plan-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "issue-queue-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/issue-queue-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "memory-bridge",
|
||||
"description": "Execute complex project documentation updates using script coordination",
|
||||
"source": "../../../agents/memory-bridge.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-developer",
|
||||
"description": "|",
|
||||
"source": "../../../agents/tdd-developer.md"
|
||||
},
|
||||
{
|
||||
"name": "test-context-search-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/test-context-search-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "test-fix-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/test-fix-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "ui-design-agent",
|
||||
"description": "|",
|
||||
"source": "../../../agents/ui-design-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "universal-executor",
|
||||
"description": "|",
|
||||
"source": "../../../agents/universal-executor.md"
|
||||
}
|
||||
]
|
||||
805
.claude/skills/ccw-help/index/all-commands.json
Normal file
805
.claude/skills/ccw-help/index/all-commands.json
Normal file
@@ -0,0 +1,805 @@
|
||||
[
|
||||
{
|
||||
"name": "ccw-coordinator",
|
||||
"command": "/ccw-coordinator",
|
||||
"description": "Command orchestration tool - analyze requirements, recommend chain, execute sequentially with state persistence",
|
||||
"arguments": "[task description]",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-coordinator.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw-debug",
|
||||
"command": "/ccw-debug",
|
||||
"description": "Aggregated debug command - combines debugging diagnostics and test verification in a synergistic workflow supporting cli-quick / debug-first / test-first / bidirectional-verification modes",
|
||||
"arguments": "[--mode cli|debug|test|bidirectional] [--yes|-y] [--hotfix] \\\"bug description or error message\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-debug.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw",
|
||||
"command": "/ccw",
|
||||
"description": "Main workflow orchestrator - analyze intent, select workflow, execute command chain in main process",
|
||||
"arguments": "\\\"task description\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-init",
|
||||
"command": "/cli:cli-init",
|
||||
"description": "Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection",
|
||||
"arguments": "[--tool gemini|qwen|all] [--output path] [--preview]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/cli-init.md"
|
||||
},
|
||||
{
|
||||
"name": "codex-review",
|
||||
"command": "/cli:codex-review",
|
||||
"description": "Interactive code review using Codex CLI via ccw endpoint with configurable review target, model, and custom instructions",
|
||||
"arguments": "[--uncommitted|--base <branch>|--commit <sha>] [--model <model>] [--title <title>] [prompt]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/codex-review.md"
|
||||
},
|
||||
{
|
||||
"name": "convert-to-plan",
|
||||
"command": "/issue:convert-to-plan",
|
||||
"description": "Convert planning artifacts (lite-plan, workflow session, markdown) to issue solutions",
|
||||
"arguments": "[-y|--yes] [--issue <id>] [--supplement] <SOURCE>",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/convert-to-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover-by-prompt",
|
||||
"command": "/issue:discover-by-prompt",
|
||||
"description": "Discover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts).",
|
||||
"arguments": "[-y|--yes] <prompt> [--scope=src/**] [--depth=standard|deep] [--max-iterations=5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover-by-prompt.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover",
|
||||
"command": "/issue:discover",
|
||||
"description": "Discover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives.",
|
||||
"arguments": "[-y|--yes] <path-pattern> [--perspectives=bug,ux,...] [--external]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/issue:execute",
|
||||
"description": "Execute queue with DAG-based parallel orchestration (one commit per solution)",
|
||||
"arguments": "[-y|--yes] --queue <queue-id> [--worktree [<existing-path>]]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "from-brainstorm",
|
||||
"command": "/issue:from-brainstorm",
|
||||
"description": "Convert brainstorm session ideas into issue with executable solution for parallel-dev-cycle",
|
||||
"arguments": "SESSION=\\\"<session-id>\\\" [--idea=<index>] [--auto] [-y|--yes]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/from-brainstorm.md"
|
||||
},
|
||||
{
|
||||
"name": "new",
|
||||
"command": "/issue:new",
|
||||
"description": "Create structured issue from GitHub URL or text description",
|
||||
"arguments": "[-y|--yes] <github-url | text-description> [--priority 1-5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/new.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/issue:plan",
|
||||
"description": "Batch plan issue resolution using issue-plan-agent (explore + plan closed-loop)",
|
||||
"arguments": "[-y|--yes] --all-pending <issue-id>[,<issue-id>,...] [--batch-size 3]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "queue",
|
||||
"command": "/issue:queue",
|
||||
"description": "Form execution queue from bound solutions using issue-queue-agent (solution-level)",
|
||||
"arguments": "[-y|--yes] [--queues <n>] [--issue <id>]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/queue.md"
|
||||
},
|
||||
{
|
||||
"name": "compact",
|
||||
"command": "/memory:compact",
|
||||
"description": "Compact current session memory into structured text for session recovery, extracting objective/plan/files/decisions/constraints/state, and save via MCP core_memory tool",
|
||||
"arguments": "[optional: session description]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/compact.md"
|
||||
},
|
||||
{
|
||||
"name": "docs-full-cli",
|
||||
"command": "/memory:docs-full-cli",
|
||||
"description": "Generate full project documentation using CLI execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[path] [--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-full-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "docs-related-cli",
|
||||
"command": "/memory:docs-related-cli",
|
||||
"description": "Generate/update documentation for git-changed modules using CLI execution with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <15 modules uses direct parallel",
|
||||
"arguments": "[--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-related-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "load",
|
||||
"command": "/memory:load",
|
||||
"description": "Delegate to universal-executor agent to analyze project via Gemini/Qwen CLI and return JSON core content package for task context",
|
||||
"arguments": "[--tool gemini|qwen] \\\"task context description\\",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/load.md"
|
||||
},
|
||||
{
|
||||
"name": "style-skill-memory",
|
||||
"command": "/memory:style-skill-memory",
|
||||
"description": "Generate SKILL memory package from style reference for easy loading and consistent design system usage",
|
||||
"arguments": "[package-name] [--regenerate]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/style-skill-memory.md"
|
||||
},
|
||||
{
|
||||
"name": "tips",
|
||||
"command": "/memory:tips",
|
||||
"description": "Quick note-taking command to capture ideas, snippets, reminders, and insights for later reference",
|
||||
"arguments": "<note content> [--tag <tag1,tag2>] [--context <context>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/tips.md"
|
||||
},
|
||||
{
|
||||
"name": "update-full",
|
||||
"command": "/memory:update-full",
|
||||
"description": "Update all CLAUDE.md files using layer-based execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[--tool gemini|qwen|codex] [--path <directory>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-full.md"
|
||||
},
|
||||
{
|
||||
"name": "update-related",
|
||||
"command": "/memory:update-related",
|
||||
"description": "Update CLAUDE.md for git-changed modules using batched agent execution (4 modules/agent) with gemini→qwen→codex fallback, <15 modules uses direct execution",
|
||||
"arguments": "[--tool gemini|qwen|codex]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-related.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw view",
|
||||
"command": "/ccw view",
|
||||
"description": "Dashboard - Open CCW workflow dashboard for managing tasks and sessions",
|
||||
"arguments": "",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/view.md"
|
||||
},
|
||||
{
|
||||
"name": "analyze-with-file",
|
||||
"command": "/workflow:analyze-with-file",
|
||||
"description": "Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding",
|
||||
"arguments": "[-y|--yes] [-c|--continue] \\\"topic or question\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/analyze-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "artifacts",
|
||||
"command": "/workflow:brainstorm:artifacts",
|
||||
"description": "Interactive clarification generating confirmed guidance specification through role-based analysis and synthesis",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/artifacts.md"
|
||||
},
|
||||
{
|
||||
"name": "auto-parallel",
|
||||
"command": "/workflow:brainstorm:auto-parallel",
|
||||
"description": "Parallel brainstorming automation with dynamic role selection and concurrent execution across multiple perspectives",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/auto-parallel.md"
|
||||
},
|
||||
{
|
||||
"name": "role-analysis",
|
||||
"command": "/workflow:brainstorm:role-analysis",
|
||||
"description": "Unified role-specific analysis generation with interactive context gathering and incremental updates",
|
||||
"arguments": "[role-name] [--session session-id] [--update] [--include-questions] [--skip-questions]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/role-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "synthesis",
|
||||
"command": "/workflow:brainstorm:synthesis",
|
||||
"description": "Clarify and refine role analyses through intelligent Q&A and targeted updates with synthesis agent",
|
||||
"arguments": "[-y|--yes] [optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/synthesis.md"
|
||||
},
|
||||
{
|
||||
"name": "brainstorm-with-file",
|
||||
"command": "/workflow:brainstorm-with-file",
|
||||
"description": "Interactive brainstorming with multi-CLI collaboration, idea expansion, and documented thought evolution",
|
||||
"arguments": "[-y|--yes] [-c|--continue] [-m|--mode creative|structured] \\\"idea or topic\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "clean",
|
||||
"command": "/workflow:clean",
|
||||
"description": "Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution",
|
||||
"arguments": "[-y|--yes] [--dry-run] [\\\"focus area\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/clean.md"
|
||||
},
|
||||
{
|
||||
"name": "debug-with-file",
|
||||
"command": "/workflow:debug-with-file",
|
||||
"description": "Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction",
|
||||
"arguments": "[-y|--yes] \\\"bug description or error message\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/debug-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/workflow:execute",
|
||||
"description": "Coordinate agent execution for workflow tasks with automatic session discovery, parallel task processing, and status tracking",
|
||||
"arguments": "[-y|--yes] [--resume-session=\\\"session-id\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "init",
|
||||
"command": "/workflow:init",
|
||||
"description": "Initialize project-level state with intelligent project analysis using cli-explore-agent",
|
||||
"arguments": "[--regenerate]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/init.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-execute",
|
||||
"command": "/workflow:lite-execute",
|
||||
"description": "Execute tasks based on in-memory plan, prompt description, or file content",
|
||||
"arguments": "[-y|--yes] [--in-memory] [\\\"task description\\\"|file-path]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-fix",
|
||||
"command": "/workflow:lite-fix",
|
||||
"description": "Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents",
|
||||
"arguments": "[-y|--yes] [--hotfix] \\\"bug description or issue reference\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:lite-lite-lite",
|
||||
"command": "/workflow:lite-lite-lite",
|
||||
"description": "Ultra-lightweight multi-tool analysis and direct execution. No artifacts for simple tasks; auto-creates planning docs in .workflow/.scratchpad/ for complex tasks. Auto tool selection based on task analysis, user-driven iteration via AskUser.",
|
||||
"arguments": "[-y|--yes] <task description>",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-lite-lite.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-plan",
|
||||
"command": "/workflow:lite-plan",
|
||||
"description": "Lightweight interactive planning workflow with in-memory planning, code exploration, and execution execute to lite-execute after user confirmation",
|
||||
"arguments": "[-y|--yes] [-e|--explore] \\\"task description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:multi-cli-plan",
|
||||
"command": "/workflow:multi-cli-plan",
|
||||
"description": "Multi-CLI collaborative planning workflow with ACE context gathering and iterative cross-verification. Uses cli-discuss-agent for Gemini+Codex+Claude analysis to converge on optimal execution plan.",
|
||||
"arguments": "[-y|--yes] <task description> [--max-rounds=3] [--tools=gemini,codex] [--mode=parallel|serial]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/multi-cli-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "plan-verify",
|
||||
"command": "/workflow:plan-verify",
|
||||
"description": "Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.",
|
||||
"arguments": "[optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/workflow:plan",
|
||||
"description": "5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs",
|
||||
"arguments": "[-y|--yes] \\\"text description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "replan",
|
||||
"command": "/workflow:replan",
|
||||
"description": "Interactive workflow replanning with session-level artifact updates and boundary clarification through guided questioning",
|
||||
"arguments": "[-y|--yes] [--session session-id] [task-id] \\\"requirements\\\"|file.md [--interactive]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/replan.md"
|
||||
},
|
||||
{
|
||||
"name": "review-cycle-fix",
|
||||
"command": "/workflow:review-cycle-fix",
|
||||
"description": "Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.",
|
||||
"arguments": "<export-file|review-dir> [--resume] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-cycle-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "review-module-cycle",
|
||||
"command": "/workflow:review-module-cycle",
|
||||
"description": "Independent multi-dimensional code review for specified modules/files. Analyzes specific code paths across 7 dimensions with hybrid parallel-iterative execution, independent of workflow sessions.",
|
||||
"arguments": "<path-pattern> [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-module-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "review-session-cycle",
|
||||
"command": "/workflow:review-session-cycle",
|
||||
"description": "Session-based comprehensive multi-dimensional code review. Analyzes git changes from workflow session across 7 dimensions with hybrid parallel-iterative execution, aggregates findings, and performs focused deep-dives on critical issues until quality gates met.",
|
||||
"arguments": "[session-id] [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-session-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "review",
|
||||
"command": "/workflow:review",
|
||||
"description": "Post-implementation review with specialized types (security/architecture/action-items/quality) using analysis agents and Gemini",
|
||||
"arguments": "[--type=security|architecture|action-items|quality] [--archived] [optional: session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review.md"
|
||||
},
|
||||
{
|
||||
"name": "complete",
|
||||
"command": "/workflow:session:complete",
|
||||
"description": "Mark active workflow session as complete, archive with lessons learned, update manifest, remove active flag",
|
||||
"arguments": "[-y|--yes] [--detailed]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/complete.md"
|
||||
},
|
||||
{
|
||||
"name": "list",
|
||||
"command": "/workflow:session:list",
|
||||
"description": "List all workflow sessions with status filtering, shows session metadata and progress information",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/session/list.md"
|
||||
},
|
||||
{
|
||||
"name": "resume",
|
||||
"command": "/workflow:session:resume",
|
||||
"description": "Resume the most recently paused workflow session with automatic session discovery and status update",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/resume.md"
|
||||
},
|
||||
{
|
||||
"name": "solidify",
|
||||
"command": "/workflow:session:solidify",
|
||||
"description": "Crystallize session learnings and user-defined constraints into permanent project guidelines",
|
||||
"arguments": "[-y|--yes] [--type <convention|constraint|learning>] [--category <category>] \\\"rule or insight\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/solidify.md"
|
||||
},
|
||||
{
|
||||
"name": "start",
|
||||
"command": "/workflow:session:start",
|
||||
"description": "Discover existing sessions or start new workflow session with intelligent session management and conflict detection",
|
||||
"arguments": "[--type <workflow|review|tdd|test|docs>] [--auto|--new] [optional: task description for new session]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/start.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-plan",
|
||||
"command": "/workflow:tdd-plan",
|
||||
"description": "TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking",
|
||||
"arguments": "\\\"feature description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-verify",
|
||||
"command": "/workflow:tdd-verify",
|
||||
"description": "Verify TDD workflow compliance against Red-Green-Refactor cycles. Generates quality report with coverage analysis and quality gate recommendation. Orchestrates sub-commands for comprehensive validation.",
|
||||
"arguments": "[optional: --session WFS-session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "test-cycle-execute",
|
||||
"command": "/workflow:test-cycle-execute",
|
||||
"description": "Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.",
|
||||
"arguments": "[--resume-session=\\\"session-id\\\"] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-cycle-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "test-fix-gen",
|
||||
"command": "/workflow:test-fix-gen",
|
||||
"description": "Create test-fix workflow session from session ID, description, or file path with test strategy generation and task planning",
|
||||
"arguments": "(source-session-id | \\\"feature description\\\" | /path/to/file.md)",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-fix-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "test-gen",
|
||||
"command": "/workflow:test-gen",
|
||||
"description": "Create independent test-fix workflow session from completed implementation session, analyzes code to generate test tasks",
|
||||
"arguments": "source-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "conflict-resolution",
|
||||
"command": "/workflow:tools:conflict-resolution",
|
||||
"description": "Detect and resolve conflicts between plan and existing codebase using CLI-powered analysis with Gemini/Qwen",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id --context path/to/context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/conflict-resolution.md"
|
||||
},
|
||||
{
|
||||
"name": "gather",
|
||||
"command": "/workflow:tools:gather",
|
||||
"description": "Intelligently collect project context using context-search-agent based on task description, packages into standardized JSON",
|
||||
"arguments": "--session WFS-session-id \\\"task description\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/context-gather.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-agent",
|
||||
"command": "/workflow:tools:task-generate-agent",
|
||||
"description": "Generate implementation plan documents (IMPL_PLAN.md, task JSONs, TODO_LIST.md) using action-planning-agent - produces planning artifacts, does NOT execute code implementation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-tdd",
|
||||
"command": "/workflow:tools:task-generate-tdd",
|
||||
"description": "Autonomous TDD task generation using action-planning-agent with Red-Green-Refactor cycles, test-first structure, and cycle validation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-tdd.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-coverage-analysis",
|
||||
"command": "/workflow:tools:tdd-coverage-analysis",
|
||||
"description": "Analyze test coverage and TDD cycle execution with Red-Green-Refactor compliance verification",
|
||||
"arguments": "--session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/tdd-coverage-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "test-concept-enhanced",
|
||||
"command": "/workflow:tools:test-concept-enhanced",
|
||||
"description": "Coordinate test analysis workflow using cli-execution-agent to generate test strategy via Gemini",
|
||||
"arguments": "--session WFS-test-session-id --context path/to/test-context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-concept-enhanced.md"
|
||||
},
|
||||
{
|
||||
"name": "test-context-gather",
|
||||
"command": "/workflow:tools:test-context-gather",
|
||||
"description": "Collect test coverage context using test-context-search-agent and package into standardized test-context JSON",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-context-gather.md"
|
||||
},
|
||||
{
|
||||
"name": "test-task-generate",
|
||||
"command": "/workflow:tools:test-task-generate",
|
||||
"description": "Generate test planning documents (IMPL_PLAN.md, test task JSONs, TODO_LIST.md) using action-planning-agent - produces test planning artifacts, does NOT execute tests",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-task-generate.md"
|
||||
},
|
||||
{
|
||||
"name": "animation-extract",
|
||||
"command": "/workflow:ui-design:animation-extract",
|
||||
"description": "Extract animation and transition patterns from prompt inference and image references for design system documentation",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--focus \"<types>\"] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/animation-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:codify-style",
|
||||
"command": "/workflow:ui-design:codify-style",
|
||||
"description": "Orchestrator to extract styles from code and generate shareable reference package with preview (automatic file discovery)",
|
||||
"arguments": "<path> [--package-name <name>] [--output-dir <path>] [--overwrite]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/codify-style.md"
|
||||
},
|
||||
{
|
||||
"name": "design-sync",
|
||||
"command": "/workflow:ui-design:design-sync",
|
||||
"description": "Synchronize finalized design system references to brainstorming artifacts, preparing them for /workflow:plan consumption",
|
||||
"arguments": "--session <session_id> [--selected-prototypes \"<list>\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/design-sync.md"
|
||||
},
|
||||
{
|
||||
"name": "explore-auto",
|
||||
"command": "/workflow:ui-design:explore-auto",
|
||||
"description": "Interactive exploratory UI design workflow with style-centric batch generation, creates design variants from prompts/images with parallel execution and user selection",
|
||||
"arguments": "[--input \"<value>\"] [--targets \"<list>\"] [--target-type \"page|component\"] [--session <id>] [--style-variants <count>] [--layout-variants <count>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/explore-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "generate",
|
||||
"command": "/workflow:ui-design:generate",
|
||||
"description": "Assemble UI prototypes by combining layout templates with design tokens (default animation support), pure assembler without new content generation",
|
||||
"arguments": "[--design-id <id>] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/generate.md"
|
||||
},
|
||||
{
|
||||
"name": "imitate-auto",
|
||||
"command": "/workflow:ui-design:imitate-auto",
|
||||
"description": "UI design workflow with direct code/image input for design token extraction and prototype generation",
|
||||
"arguments": "[--input \"<value>\"] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/imitate-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:import-from-code",
|
||||
"command": "/workflow:ui-design:import-from-code",
|
||||
"description": "Import design system from code files (CSS/JS/HTML/SCSS) with automatic file discovery and parallel agent analysis",
|
||||
"arguments": "[--design-id <id>] [--session <id>] [--source <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/import-from-code.md"
|
||||
},
|
||||
{
|
||||
"name": "layout-extract",
|
||||
"command": "/workflow:ui-design:layout-extract",
|
||||
"description": "Extract structural layout information from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--targets \"<list>\"] [--variants <count>] [--device-type <desktop|mobile|tablet|responsive>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/layout-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:reference-page-generator",
|
||||
"command": "/workflow:ui-design:reference-page-generator",
|
||||
"description": "Generate multi-component reference pages and documentation from design run extraction",
|
||||
"arguments": "[--design-run <path>] [--package-name <name>] [--output-dir <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/reference-page-generator.md"
|
||||
},
|
||||
{
|
||||
"name": "style-extract",
|
||||
"command": "/workflow:ui-design:style-extract",
|
||||
"description": "Extract design style from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--variants <count>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/style-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "unified-execute-with-file",
|
||||
"command": "/workflow:unified-execute-with-file",
|
||||
"description": "Universal execution engine for consuming any planning/brainstorm/analysis output with minimal progress tracking, multi-agent coordination, and incremental execution",
|
||||
"arguments": "[-y|--yes] [-p|--plan <path>] [-m|--mode sequential|parallel] [\\\"execution context or task name\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/unified-execute-with-file.md"
|
||||
}
|
||||
]
|
||||
833
.claude/skills/ccw-help/index/by-category.json
Normal file
833
.claude/skills/ccw-help/index/by-category.json
Normal file
@@ -0,0 +1,833 @@
|
||||
{
|
||||
"general": {
|
||||
"_root": [
|
||||
{
|
||||
"name": "ccw-coordinator",
|
||||
"command": "/ccw-coordinator",
|
||||
"description": "Command orchestration tool - analyze requirements, recommend chain, execute sequentially with state persistence",
|
||||
"arguments": "[task description]",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-coordinator.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw-debug",
|
||||
"command": "/ccw-debug",
|
||||
"description": "Aggregated debug command - combines debugging diagnostics and test verification in a synergistic workflow supporting cli-quick / debug-first / test-first / bidirectional-verification modes",
|
||||
"arguments": "[--mode cli|debug|test|bidirectional] [--yes|-y] [--hotfix] \\\"bug description or error message\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-debug.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw",
|
||||
"command": "/ccw",
|
||||
"description": "Main workflow orchestrator - analyze intent, select workflow, execute command chain in main process",
|
||||
"arguments": "\\\"task description\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw view",
|
||||
"command": "/ccw view",
|
||||
"description": "Dashboard - Open CCW workflow dashboard for managing tasks and sessions",
|
||||
"arguments": "",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/view.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cli": {
|
||||
"_root": [
|
||||
{
|
||||
"name": "cli-init",
|
||||
"command": "/cli:cli-init",
|
||||
"description": "Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection",
|
||||
"arguments": "[--tool gemini|qwen|all] [--output path] [--preview]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/cli-init.md"
|
||||
},
|
||||
{
|
||||
"name": "codex-review",
|
||||
"command": "/cli:codex-review",
|
||||
"description": "Interactive code review using Codex CLI via ccw endpoint with configurable review target, model, and custom instructions",
|
||||
"arguments": "[--uncommitted|--base <branch>|--commit <sha>] [--model <model>] [--title <title>] [prompt]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/codex-review.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
"issue": {
|
||||
"_root": [
|
||||
{
|
||||
"name": "convert-to-plan",
|
||||
"command": "/issue:convert-to-plan",
|
||||
"description": "Convert planning artifacts (lite-plan, workflow session, markdown) to issue solutions",
|
||||
"arguments": "[-y|--yes] [--issue <id>] [--supplement] <SOURCE>",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/convert-to-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover-by-prompt",
|
||||
"command": "/issue:discover-by-prompt",
|
||||
"description": "Discover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts).",
|
||||
"arguments": "[-y|--yes] <prompt> [--scope=src/**] [--depth=standard|deep] [--max-iterations=5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover-by-prompt.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover",
|
||||
"command": "/issue:discover",
|
||||
"description": "Discover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives.",
|
||||
"arguments": "[-y|--yes] <path-pattern> [--perspectives=bug,ux,...] [--external]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/issue:execute",
|
||||
"description": "Execute queue with DAG-based parallel orchestration (one commit per solution)",
|
||||
"arguments": "[-y|--yes] --queue <queue-id> [--worktree [<existing-path>]]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "from-brainstorm",
|
||||
"command": "/issue:from-brainstorm",
|
||||
"description": "Convert brainstorm session ideas into issue with executable solution for parallel-dev-cycle",
|
||||
"arguments": "SESSION=\\\"<session-id>\\\" [--idea=<index>] [--auto] [-y|--yes]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/from-brainstorm.md"
|
||||
},
|
||||
{
|
||||
"name": "new",
|
||||
"command": "/issue:new",
|
||||
"description": "Create structured issue from GitHub URL or text description",
|
||||
"arguments": "[-y|--yes] <github-url | text-description> [--priority 1-5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/new.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/issue:plan",
|
||||
"description": "Batch plan issue resolution using issue-plan-agent (explore + plan closed-loop)",
|
||||
"arguments": "[-y|--yes] --all-pending <issue-id>[,<issue-id>,...] [--batch-size 3]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "queue",
|
||||
"command": "/issue:queue",
|
||||
"description": "Form execution queue from bound solutions using issue-queue-agent (solution-level)",
|
||||
"arguments": "[-y|--yes] [--queues <n>] [--issue <id>]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/queue.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
"memory": {
|
||||
"_root": [
|
||||
{
|
||||
"name": "compact",
|
||||
"command": "/memory:compact",
|
||||
"description": "Compact current session memory into structured text for session recovery, extracting objective/plan/files/decisions/constraints/state, and save via MCP core_memory tool",
|
||||
"arguments": "[optional: session description]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/compact.md"
|
||||
},
|
||||
{
|
||||
"name": "docs-full-cli",
|
||||
"command": "/memory:docs-full-cli",
|
||||
"description": "Generate full project documentation using CLI execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[path] [--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-full-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "docs-related-cli",
|
||||
"command": "/memory:docs-related-cli",
|
||||
"description": "Generate/update documentation for git-changed modules using CLI execution with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <15 modules uses direct parallel",
|
||||
"arguments": "[--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-related-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "load",
|
||||
"command": "/memory:load",
|
||||
"description": "Delegate to universal-executor agent to analyze project via Gemini/Qwen CLI and return JSON core content package for task context",
|
||||
"arguments": "[--tool gemini|qwen] \\\"task context description\\",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/load.md"
|
||||
},
|
||||
{
|
||||
"name": "style-skill-memory",
|
||||
"command": "/memory:style-skill-memory",
|
||||
"description": "Generate SKILL memory package from style reference for easy loading and consistent design system usage",
|
||||
"arguments": "[package-name] [--regenerate]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/style-skill-memory.md"
|
||||
},
|
||||
{
|
||||
"name": "tips",
|
||||
"command": "/memory:tips",
|
||||
"description": "Quick note-taking command to capture ideas, snippets, reminders, and insights for later reference",
|
||||
"arguments": "<note content> [--tag <tag1,tag2>] [--context <context>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/tips.md"
|
||||
},
|
||||
{
|
||||
"name": "update-full",
|
||||
"command": "/memory:update-full",
|
||||
"description": "Update all CLAUDE.md files using layer-based execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[--tool gemini|qwen|codex] [--path <directory>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-full.md"
|
||||
},
|
||||
{
|
||||
"name": "update-related",
|
||||
"command": "/memory:update-related",
|
||||
"description": "Update CLAUDE.md for git-changed modules using batched agent execution (4 modules/agent) with gemini→qwen→codex fallback, <15 modules uses direct execution",
|
||||
"arguments": "[--tool gemini|qwen|codex]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-related.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
"workflow": {
|
||||
"_root": [
|
||||
{
|
||||
"name": "analyze-with-file",
|
||||
"command": "/workflow:analyze-with-file",
|
||||
"description": "Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding",
|
||||
"arguments": "[-y|--yes] [-c|--continue] \\\"topic or question\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/analyze-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "brainstorm-with-file",
|
||||
"command": "/workflow:brainstorm-with-file",
|
||||
"description": "Interactive brainstorming with multi-CLI collaboration, idea expansion, and documented thought evolution",
|
||||
"arguments": "[-y|--yes] [-c|--continue] [-m|--mode creative|structured] \\\"idea or topic\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "clean",
|
||||
"command": "/workflow:clean",
|
||||
"description": "Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution",
|
||||
"arguments": "[-y|--yes] [--dry-run] [\\\"focus area\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/clean.md"
|
||||
},
|
||||
{
|
||||
"name": "debug-with-file",
|
||||
"command": "/workflow:debug-with-file",
|
||||
"description": "Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction",
|
||||
"arguments": "[-y|--yes] \\\"bug description or error message\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/debug-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/workflow:execute",
|
||||
"description": "Coordinate agent execution for workflow tasks with automatic session discovery, parallel task processing, and status tracking",
|
||||
"arguments": "[-y|--yes] [--resume-session=\\\"session-id\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "init",
|
||||
"command": "/workflow:init",
|
||||
"description": "Initialize project-level state with intelligent project analysis using cli-explore-agent",
|
||||
"arguments": "[--regenerate]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/init.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-execute",
|
||||
"command": "/workflow:lite-execute",
|
||||
"description": "Execute tasks based on in-memory plan, prompt description, or file content",
|
||||
"arguments": "[-y|--yes] [--in-memory] [\\\"task description\\\"|file-path]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-fix",
|
||||
"command": "/workflow:lite-fix",
|
||||
"description": "Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents",
|
||||
"arguments": "[-y|--yes] [--hotfix] \\\"bug description or issue reference\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:lite-lite-lite",
|
||||
"command": "/workflow:lite-lite-lite",
|
||||
"description": "Ultra-lightweight multi-tool analysis and direct execution. No artifacts for simple tasks; auto-creates planning docs in .workflow/.scratchpad/ for complex tasks. Auto tool selection based on task analysis, user-driven iteration via AskUser.",
|
||||
"arguments": "[-y|--yes] <task description>",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-lite-lite.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-plan",
|
||||
"command": "/workflow:lite-plan",
|
||||
"description": "Lightweight interactive planning workflow with in-memory planning, code exploration, and execution execute to lite-execute after user confirmation",
|
||||
"arguments": "[-y|--yes] [-e|--explore] \\\"task description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:multi-cli-plan",
|
||||
"command": "/workflow:multi-cli-plan",
|
||||
"description": "Multi-CLI collaborative planning workflow with ACE context gathering and iterative cross-verification. Uses cli-discuss-agent for Gemini+Codex+Claude analysis to converge on optimal execution plan.",
|
||||
"arguments": "[-y|--yes] <task description> [--max-rounds=3] [--tools=gemini,codex] [--mode=parallel|serial]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/multi-cli-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "plan-verify",
|
||||
"command": "/workflow:plan-verify",
|
||||
"description": "Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.",
|
||||
"arguments": "[optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/workflow:plan",
|
||||
"description": "5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs",
|
||||
"arguments": "[-y|--yes] \\\"text description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "replan",
|
||||
"command": "/workflow:replan",
|
||||
"description": "Interactive workflow replanning with session-level artifact updates and boundary clarification through guided questioning",
|
||||
"arguments": "[-y|--yes] [--session session-id] [task-id] \\\"requirements\\\"|file.md [--interactive]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/replan.md"
|
||||
},
|
||||
{
|
||||
"name": "review-cycle-fix",
|
||||
"command": "/workflow:review-cycle-fix",
|
||||
"description": "Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.",
|
||||
"arguments": "<export-file|review-dir> [--resume] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-cycle-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "review-module-cycle",
|
||||
"command": "/workflow:review-module-cycle",
|
||||
"description": "Independent multi-dimensional code review for specified modules/files. Analyzes specific code paths across 7 dimensions with hybrid parallel-iterative execution, independent of workflow sessions.",
|
||||
"arguments": "<path-pattern> [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-module-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "review-session-cycle",
|
||||
"command": "/workflow:review-session-cycle",
|
||||
"description": "Session-based comprehensive multi-dimensional code review. Analyzes git changes from workflow session across 7 dimensions with hybrid parallel-iterative execution, aggregates findings, and performs focused deep-dives on critical issues until quality gates met.",
|
||||
"arguments": "[session-id] [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-session-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "review",
|
||||
"command": "/workflow:review",
|
||||
"description": "Post-implementation review with specialized types (security/architecture/action-items/quality) using analysis agents and Gemini",
|
||||
"arguments": "[--type=security|architecture|action-items|quality] [--archived] [optional: session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-plan",
|
||||
"command": "/workflow:tdd-plan",
|
||||
"description": "TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking",
|
||||
"arguments": "\\\"feature description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-verify",
|
||||
"command": "/workflow:tdd-verify",
|
||||
"description": "Verify TDD workflow compliance against Red-Green-Refactor cycles. Generates quality report with coverage analysis and quality gate recommendation. Orchestrates sub-commands for comprehensive validation.",
|
||||
"arguments": "[optional: --session WFS-session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "test-cycle-execute",
|
||||
"command": "/workflow:test-cycle-execute",
|
||||
"description": "Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.",
|
||||
"arguments": "[--resume-session=\\\"session-id\\\"] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-cycle-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "test-fix-gen",
|
||||
"command": "/workflow:test-fix-gen",
|
||||
"description": "Create test-fix workflow session from session ID, description, or file path with test strategy generation and task planning",
|
||||
"arguments": "(source-session-id | \\\"feature description\\\" | /path/to/file.md)",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-fix-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "test-gen",
|
||||
"command": "/workflow:test-gen",
|
||||
"description": "Create independent test-fix workflow session from completed implementation session, analyzes code to generate test tasks",
|
||||
"arguments": "source-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "unified-execute-with-file",
|
||||
"command": "/workflow:unified-execute-with-file",
|
||||
"description": "Universal execution engine for consuming any planning/brainstorm/analysis output with minimal progress tracking, multi-agent coordination, and incremental execution",
|
||||
"arguments": "[-y|--yes] [-p|--plan <path>] [-m|--mode sequential|parallel] [\\\"execution context or task name\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/unified-execute-with-file.md"
|
||||
}
|
||||
],
|
||||
"brainstorm": [
|
||||
{
|
||||
"name": "artifacts",
|
||||
"command": "/workflow:brainstorm:artifacts",
|
||||
"description": "Interactive clarification generating confirmed guidance specification through role-based analysis and synthesis",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/artifacts.md"
|
||||
},
|
||||
{
|
||||
"name": "auto-parallel",
|
||||
"command": "/workflow:brainstorm:auto-parallel",
|
||||
"description": "Parallel brainstorming automation with dynamic role selection and concurrent execution across multiple perspectives",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/auto-parallel.md"
|
||||
},
|
||||
{
|
||||
"name": "role-analysis",
|
||||
"command": "/workflow:brainstorm:role-analysis",
|
||||
"description": "Unified role-specific analysis generation with interactive context gathering and incremental updates",
|
||||
"arguments": "[role-name] [--session session-id] [--update] [--include-questions] [--skip-questions]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/role-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "synthesis",
|
||||
"command": "/workflow:brainstorm:synthesis",
|
||||
"description": "Clarify and refine role analyses through intelligent Q&A and targeted updates with synthesis agent",
|
||||
"arguments": "[-y|--yes] [optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/synthesis.md"
|
||||
}
|
||||
],
|
||||
"session": [
|
||||
{
|
||||
"name": "complete",
|
||||
"command": "/workflow:session:complete",
|
||||
"description": "Mark active workflow session as complete, archive with lessons learned, update manifest, remove active flag",
|
||||
"arguments": "[-y|--yes] [--detailed]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/complete.md"
|
||||
},
|
||||
{
|
||||
"name": "list",
|
||||
"command": "/workflow:session:list",
|
||||
"description": "List all workflow sessions with status filtering, shows session metadata and progress information",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/session/list.md"
|
||||
},
|
||||
{
|
||||
"name": "resume",
|
||||
"command": "/workflow:session:resume",
|
||||
"description": "Resume the most recently paused workflow session with automatic session discovery and status update",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/resume.md"
|
||||
},
|
||||
{
|
||||
"name": "solidify",
|
||||
"command": "/workflow:session:solidify",
|
||||
"description": "Crystallize session learnings and user-defined constraints into permanent project guidelines",
|
||||
"arguments": "[-y|--yes] [--type <convention|constraint|learning>] [--category <category>] \\\"rule or insight\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/solidify.md"
|
||||
},
|
||||
{
|
||||
"name": "start",
|
||||
"command": "/workflow:session:start",
|
||||
"description": "Discover existing sessions or start new workflow session with intelligent session management and conflict detection",
|
||||
"arguments": "[--type <workflow|review|tdd|test|docs>] [--auto|--new] [optional: task description for new session]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/start.md"
|
||||
}
|
||||
],
|
||||
"tools": [
|
||||
{
|
||||
"name": "conflict-resolution",
|
||||
"command": "/workflow:tools:conflict-resolution",
|
||||
"description": "Detect and resolve conflicts between plan and existing codebase using CLI-powered analysis with Gemini/Qwen",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id --context path/to/context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/conflict-resolution.md"
|
||||
},
|
||||
{
|
||||
"name": "gather",
|
||||
"command": "/workflow:tools:gather",
|
||||
"description": "Intelligently collect project context using context-search-agent based on task description, packages into standardized JSON",
|
||||
"arguments": "--session WFS-session-id \\\"task description\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/context-gather.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-agent",
|
||||
"command": "/workflow:tools:task-generate-agent",
|
||||
"description": "Generate implementation plan documents (IMPL_PLAN.md, task JSONs, TODO_LIST.md) using action-planning-agent - produces planning artifacts, does NOT execute code implementation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-tdd",
|
||||
"command": "/workflow:tools:task-generate-tdd",
|
||||
"description": "Autonomous TDD task generation using action-planning-agent with Red-Green-Refactor cycles, test-first structure, and cycle validation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-tdd.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-coverage-analysis",
|
||||
"command": "/workflow:tools:tdd-coverage-analysis",
|
||||
"description": "Analyze test coverage and TDD cycle execution with Red-Green-Refactor compliance verification",
|
||||
"arguments": "--session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/tdd-coverage-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "test-concept-enhanced",
|
||||
"command": "/workflow:tools:test-concept-enhanced",
|
||||
"description": "Coordinate test analysis workflow using cli-execution-agent to generate test strategy via Gemini",
|
||||
"arguments": "--session WFS-test-session-id --context path/to/test-context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-concept-enhanced.md"
|
||||
},
|
||||
{
|
||||
"name": "test-context-gather",
|
||||
"command": "/workflow:tools:test-context-gather",
|
||||
"description": "Collect test coverage context using test-context-search-agent and package into standardized test-context JSON",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-context-gather.md"
|
||||
},
|
||||
{
|
||||
"name": "test-task-generate",
|
||||
"command": "/workflow:tools:test-task-generate",
|
||||
"description": "Generate test planning documents (IMPL_PLAN.md, test task JSONs, TODO_LIST.md) using action-planning-agent - produces test planning artifacts, does NOT execute tests",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-task-generate.md"
|
||||
}
|
||||
],
|
||||
"ui-design": [
|
||||
{
|
||||
"name": "animation-extract",
|
||||
"command": "/workflow:ui-design:animation-extract",
|
||||
"description": "Extract animation and transition patterns from prompt inference and image references for design system documentation",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--focus \"<types>\"] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/animation-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:codify-style",
|
||||
"command": "/workflow:ui-design:codify-style",
|
||||
"description": "Orchestrator to extract styles from code and generate shareable reference package with preview (automatic file discovery)",
|
||||
"arguments": "<path> [--package-name <name>] [--output-dir <path>] [--overwrite]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/codify-style.md"
|
||||
},
|
||||
{
|
||||
"name": "design-sync",
|
||||
"command": "/workflow:ui-design:design-sync",
|
||||
"description": "Synchronize finalized design system references to brainstorming artifacts, preparing them for /workflow:plan consumption",
|
||||
"arguments": "--session <session_id> [--selected-prototypes \"<list>\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/design-sync.md"
|
||||
},
|
||||
{
|
||||
"name": "explore-auto",
|
||||
"command": "/workflow:ui-design:explore-auto",
|
||||
"description": "Interactive exploratory UI design workflow with style-centric batch generation, creates design variants from prompts/images with parallel execution and user selection",
|
||||
"arguments": "[--input \"<value>\"] [--targets \"<list>\"] [--target-type \"page|component\"] [--session <id>] [--style-variants <count>] [--layout-variants <count>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/explore-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "generate",
|
||||
"command": "/workflow:ui-design:generate",
|
||||
"description": "Assemble UI prototypes by combining layout templates with design tokens (default animation support), pure assembler without new content generation",
|
||||
"arguments": "[--design-id <id>] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/generate.md"
|
||||
},
|
||||
{
|
||||
"name": "imitate-auto",
|
||||
"command": "/workflow:ui-design:imitate-auto",
|
||||
"description": "UI design workflow with direct code/image input for design token extraction and prototype generation",
|
||||
"arguments": "[--input \"<value>\"] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/imitate-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:import-from-code",
|
||||
"command": "/workflow:ui-design:import-from-code",
|
||||
"description": "Import design system from code files (CSS/JS/HTML/SCSS) with automatic file discovery and parallel agent analysis",
|
||||
"arguments": "[--design-id <id>] [--session <id>] [--source <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/import-from-code.md"
|
||||
},
|
||||
{
|
||||
"name": "layout-extract",
|
||||
"command": "/workflow:ui-design:layout-extract",
|
||||
"description": "Extract structural layout information from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--targets \"<list>\"] [--variants <count>] [--device-type <desktop|mobile|tablet|responsive>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/layout-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:reference-page-generator",
|
||||
"command": "/workflow:ui-design:reference-page-generator",
|
||||
"description": "Generate multi-component reference pages and documentation from design run extraction",
|
||||
"arguments": "[--design-run <path>] [--package-name <name>] [--output-dir <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/reference-page-generator.md"
|
||||
},
|
||||
{
|
||||
"name": "style-extract",
|
||||
"command": "/workflow:ui-design:style-extract",
|
||||
"description": "Extract design style from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--variants <count>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/style-extract.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
819
.claude/skills/ccw-help/index/by-use-case.json
Normal file
819
.claude/skills/ccw-help/index/by-use-case.json
Normal file
@@ -0,0 +1,819 @@
|
||||
{
|
||||
"general": [
|
||||
{
|
||||
"name": "ccw-coordinator",
|
||||
"command": "/ccw-coordinator",
|
||||
"description": "Command orchestration tool - analyze requirements, recommend chain, execute sequentially with state persistence",
|
||||
"arguments": "[task description]",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-coordinator.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw-debug",
|
||||
"command": "/ccw-debug",
|
||||
"description": "Aggregated debug command - combines debugging diagnostics and test verification in a synergistic workflow supporting cli-quick / debug-first / test-first / bidirectional-verification modes",
|
||||
"arguments": "[--mode cli|debug|test|bidirectional] [--yes|-y] [--hotfix] \\\"bug description or error message\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw-debug.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw",
|
||||
"command": "/ccw",
|
||||
"description": "Main workflow orchestrator - analyze intent, select workflow, execute command chain in main process",
|
||||
"arguments": "\\\"task description\\",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/ccw.md"
|
||||
},
|
||||
{
|
||||
"name": "cli-init",
|
||||
"command": "/cli:cli-init",
|
||||
"description": "Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection",
|
||||
"arguments": "[--tool gemini|qwen|all] [--output path] [--preview]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/cli-init.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover-by-prompt",
|
||||
"command": "/issue:discover-by-prompt",
|
||||
"description": "Discover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts).",
|
||||
"arguments": "[-y|--yes] <prompt> [--scope=src/**] [--depth=standard|deep] [--max-iterations=5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover-by-prompt.md"
|
||||
},
|
||||
{
|
||||
"name": "issue:discover",
|
||||
"command": "/issue:discover",
|
||||
"description": "Discover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives.",
|
||||
"arguments": "[-y|--yes] <path-pattern> [--perspectives=bug,ux,...] [--external]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/discover.md"
|
||||
},
|
||||
{
|
||||
"name": "new",
|
||||
"command": "/issue:new",
|
||||
"description": "Create structured issue from GitHub URL or text description",
|
||||
"arguments": "[-y|--yes] <github-url | text-description> [--priority 1-5]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/new.md"
|
||||
},
|
||||
{
|
||||
"name": "queue",
|
||||
"command": "/issue:queue",
|
||||
"description": "Form execution queue from bound solutions using issue-queue-agent (solution-level)",
|
||||
"arguments": "[-y|--yes] [--queues <n>] [--issue <id>]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/queue.md"
|
||||
},
|
||||
{
|
||||
"name": "compact",
|
||||
"command": "/memory:compact",
|
||||
"description": "Compact current session memory into structured text for session recovery, extracting objective/plan/files/decisions/constraints/state, and save via MCP core_memory tool",
|
||||
"arguments": "[optional: session description]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/compact.md"
|
||||
},
|
||||
{
|
||||
"name": "load",
|
||||
"command": "/memory:load",
|
||||
"description": "Delegate to universal-executor agent to analyze project via Gemini/Qwen CLI and return JSON core content package for task context",
|
||||
"arguments": "[--tool gemini|qwen] \\\"task context description\\",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/load.md"
|
||||
},
|
||||
{
|
||||
"name": "tips",
|
||||
"command": "/memory:tips",
|
||||
"description": "Quick note-taking command to capture ideas, snippets, reminders, and insights for later reference",
|
||||
"arguments": "<note content> [--tag <tag1,tag2>] [--context <context>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/tips.md"
|
||||
},
|
||||
{
|
||||
"name": "update-full",
|
||||
"command": "/memory:update-full",
|
||||
"description": "Update all CLAUDE.md files using layer-based execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[--tool gemini|qwen|codex] [--path <directory>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-full.md"
|
||||
},
|
||||
{
|
||||
"name": "update-related",
|
||||
"command": "/memory:update-related",
|
||||
"description": "Update CLAUDE.md for git-changed modules using batched agent execution (4 modules/agent) with gemini→qwen→codex fallback, <15 modules uses direct execution",
|
||||
"arguments": "[--tool gemini|qwen|codex]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/update-related.md"
|
||||
},
|
||||
{
|
||||
"name": "ccw view",
|
||||
"command": "/ccw view",
|
||||
"description": "Dashboard - Open CCW workflow dashboard for managing tasks and sessions",
|
||||
"arguments": "",
|
||||
"category": "general",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/view.md"
|
||||
},
|
||||
{
|
||||
"name": "artifacts",
|
||||
"command": "/workflow:brainstorm:artifacts",
|
||||
"description": "Interactive clarification generating confirmed guidance specification through role-based analysis and synthesis",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/artifacts.md"
|
||||
},
|
||||
{
|
||||
"name": "auto-parallel",
|
||||
"command": "/workflow:brainstorm:auto-parallel",
|
||||
"description": "Parallel brainstorming automation with dynamic role selection and concurrent execution across multiple perspectives",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/auto-parallel.md"
|
||||
},
|
||||
{
|
||||
"name": "role-analysis",
|
||||
"command": "/workflow:brainstorm:role-analysis",
|
||||
"description": "Unified role-specific analysis generation with interactive context gathering and incremental updates",
|
||||
"arguments": "[role-name] [--session session-id] [--update] [--include-questions] [--skip-questions]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/role-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "synthesis",
|
||||
"command": "/workflow:brainstorm:synthesis",
|
||||
"description": "Clarify and refine role analyses through intelligent Q&A and targeted updates with synthesis agent",
|
||||
"arguments": "[-y|--yes] [optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/brainstorm/synthesis.md"
|
||||
},
|
||||
{
|
||||
"name": "clean",
|
||||
"command": "/workflow:clean",
|
||||
"description": "Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution",
|
||||
"arguments": "[-y|--yes] [--dry-run] [\\\"focus area\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/clean.md"
|
||||
},
|
||||
{
|
||||
"name": "debug-with-file",
|
||||
"command": "/workflow:debug-with-file",
|
||||
"description": "Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction",
|
||||
"arguments": "[-y|--yes] \\\"bug description or error message\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/debug-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "init",
|
||||
"command": "/workflow:init",
|
||||
"description": "Initialize project-level state with intelligent project analysis using cli-explore-agent",
|
||||
"arguments": "[--regenerate]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/init.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-fix",
|
||||
"command": "/workflow:lite-fix",
|
||||
"description": "Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents",
|
||||
"arguments": "[-y|--yes] [--hotfix] \\\"bug description or issue reference\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:lite-lite-lite",
|
||||
"command": "/workflow:lite-lite-lite",
|
||||
"description": "Ultra-lightweight multi-tool analysis and direct execution. No artifacts for simple tasks; auto-creates planning docs in .workflow/.scratchpad/ for complex tasks. Auto tool selection based on task analysis, user-driven iteration via AskUser.",
|
||||
"arguments": "[-y|--yes] <task description>",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-lite-lite.md"
|
||||
},
|
||||
{
|
||||
"name": "list",
|
||||
"command": "/workflow:session:list",
|
||||
"description": "List all workflow sessions with status filtering, shows session metadata and progress information",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/session/list.md"
|
||||
},
|
||||
{
|
||||
"name": "solidify",
|
||||
"command": "/workflow:session:solidify",
|
||||
"description": "Crystallize session learnings and user-defined constraints into permanent project guidelines",
|
||||
"arguments": "[-y|--yes] [--type <convention|constraint|learning>] [--category <category>] \\\"rule or insight\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/solidify.md"
|
||||
},
|
||||
{
|
||||
"name": "start",
|
||||
"command": "/workflow:session:start",
|
||||
"description": "Discover existing sessions or start new workflow session with intelligent session management and conflict detection",
|
||||
"arguments": "[--type <workflow|review|tdd|test|docs>] [--auto|--new] [optional: task description for new session]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/start.md"
|
||||
},
|
||||
{
|
||||
"name": "conflict-resolution",
|
||||
"command": "/workflow:tools:conflict-resolution",
|
||||
"description": "Detect and resolve conflicts between plan and existing codebase using CLI-powered analysis with Gemini/Qwen",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id --context path/to/context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/conflict-resolution.md"
|
||||
},
|
||||
{
|
||||
"name": "gather",
|
||||
"command": "/workflow:tools:gather",
|
||||
"description": "Intelligently collect project context using context-search-agent based on task description, packages into standardized JSON",
|
||||
"arguments": "--session WFS-session-id \\\"task description\\",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/context-gather.md"
|
||||
},
|
||||
{
|
||||
"name": "animation-extract",
|
||||
"command": "/workflow:ui-design:animation-extract",
|
||||
"description": "Extract animation and transition patterns from prompt inference and image references for design system documentation",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--focus \"<types>\"] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/animation-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "explore-auto",
|
||||
"command": "/workflow:ui-design:explore-auto",
|
||||
"description": "Interactive exploratory UI design workflow with style-centric batch generation, creates design variants from prompts/images with parallel execution and user selection",
|
||||
"arguments": "[--input \"<value>\"] [--targets \"<list>\"] [--target-type \"page|component\"] [--session <id>] [--style-variants <count>] [--layout-variants <count>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/explore-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "imitate-auto",
|
||||
"command": "/workflow:ui-design:imitate-auto",
|
||||
"description": "UI design workflow with direct code/image input for design token extraction and prototype generation",
|
||||
"arguments": "[--input \"<value>\"] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/imitate-auto.md"
|
||||
},
|
||||
{
|
||||
"name": "layout-extract",
|
||||
"command": "/workflow:ui-design:layout-extract",
|
||||
"description": "Extract structural layout information from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--targets \"<list>\"] [--variants <count>] [--device-type <desktop|mobile|tablet|responsive>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/layout-extract.md"
|
||||
},
|
||||
{
|
||||
"name": "style-extract",
|
||||
"command": "/workflow:ui-design:style-extract",
|
||||
"description": "Extract design style from reference images or text prompts using Claude analysis with variant generation or refinement mode",
|
||||
"arguments": "[-y|--yes] [--design-id <id>] [--session <id>] [--images \"<glob>\"] [--prompt \"<desc>\"] [--variants <count>] [--interactive] [--refine]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/style-extract.md"
|
||||
}
|
||||
],
|
||||
"analysis": [
|
||||
{
|
||||
"name": "codex-review",
|
||||
"command": "/cli:codex-review",
|
||||
"description": "Interactive code review using Codex CLI via ccw endpoint with configurable review target, model, and custom instructions",
|
||||
"arguments": "[--uncommitted|--base <branch>|--commit <sha>] [--model <model>] [--title <title>] [prompt]",
|
||||
"category": "cli",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/cli/codex-review.md"
|
||||
},
|
||||
{
|
||||
"name": "analyze-with-file",
|
||||
"command": "/workflow:analyze-with-file",
|
||||
"description": "Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding",
|
||||
"arguments": "[-y|--yes] [-c|--continue] \\\"topic or question\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Beginner",
|
||||
"source": "../../../commands/workflow/analyze-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "review-cycle-fix",
|
||||
"command": "/workflow:review-cycle-fix",
|
||||
"description": "Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.",
|
||||
"arguments": "<export-file|review-dir> [--resume] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-cycle-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "review-module-cycle",
|
||||
"command": "/workflow:review-module-cycle",
|
||||
"description": "Independent multi-dimensional code review for specified modules/files. Analyzes specific code paths across 7 dimensions with hybrid parallel-iterative execution, independent of workflow sessions.",
|
||||
"arguments": "<path-pattern> [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-module-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "review",
|
||||
"command": "/workflow:review",
|
||||
"description": "Post-implementation review with specialized types (security/architecture/action-items/quality) using analysis agents and Gemini",
|
||||
"arguments": "[--type=security|architecture|action-items|quality] [--archived] [optional: session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "analysis",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review.md"
|
||||
}
|
||||
],
|
||||
"planning": [
|
||||
{
|
||||
"name": "convert-to-plan",
|
||||
"command": "/issue:convert-to-plan",
|
||||
"description": "Convert planning artifacts (lite-plan, workflow session, markdown) to issue solutions",
|
||||
"arguments": "[-y|--yes] [--issue <id>] [--supplement] <SOURCE>",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/convert-to-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "from-brainstorm",
|
||||
"command": "/issue:from-brainstorm",
|
||||
"description": "Convert brainstorm session ideas into issue with executable solution for parallel-dev-cycle",
|
||||
"arguments": "SESSION=\\\"<session-id>\\\" [--idea=<index>] [--auto] [-y|--yes]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/from-brainstorm.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/issue:plan",
|
||||
"description": "Batch plan issue resolution using issue-plan-agent (explore + plan closed-loop)",
|
||||
"arguments": "[-y|--yes] --all-pending <issue-id>[,<issue-id>,...] [--batch-size 3]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "brainstorm-with-file",
|
||||
"command": "/workflow:brainstorm-with-file",
|
||||
"description": "Interactive brainstorming with multi-CLI collaboration, idea expansion, and documented thought evolution",
|
||||
"arguments": "[-y|--yes] [-c|--continue] [-m|--mode creative|structured] \\\"idea or topic\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm-with-file.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-plan",
|
||||
"command": "/workflow:lite-plan",
|
||||
"description": "Lightweight interactive planning workflow with in-memory planning, code exploration, and execution execute to lite-execute after user confirmation",
|
||||
"arguments": "[-y|--yes] [-e|--explore] \\\"task description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:multi-cli-plan",
|
||||
"command": "/workflow:multi-cli-plan",
|
||||
"description": "Multi-CLI collaborative planning workflow with ACE context gathering and iterative cross-verification. Uses cli-discuss-agent for Gemini+Codex+Claude analysis to converge on optimal execution plan.",
|
||||
"arguments": "[-y|--yes] <task description> [--max-rounds=3] [--tools=gemini,codex] [--mode=parallel|serial]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/multi-cli-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "plan-verify",
|
||||
"command": "/workflow:plan-verify",
|
||||
"description": "Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.",
|
||||
"arguments": "[optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/workflow:plan",
|
||||
"description": "5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs",
|
||||
"arguments": "[-y|--yes] \\\"text description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "replan",
|
||||
"command": "/workflow:replan",
|
||||
"description": "Interactive workflow replanning with session-level artifact updates and boundary clarification through guided questioning",
|
||||
"arguments": "[-y|--yes] [--session session-id] [task-id] \\\"requirements\\\"|file.md [--interactive]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/replan.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-plan",
|
||||
"command": "/workflow:tdd-plan",
|
||||
"description": "TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking",
|
||||
"arguments": "\\\"feature description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:codify-style",
|
||||
"command": "/workflow:ui-design:codify-style",
|
||||
"description": "Orchestrator to extract styles from code and generate shareable reference package with preview (automatic file discovery)",
|
||||
"arguments": "<path> [--package-name <name>] [--output-dir <path>] [--overwrite]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/codify-style.md"
|
||||
},
|
||||
{
|
||||
"name": "design-sync",
|
||||
"command": "/workflow:ui-design:design-sync",
|
||||
"description": "Synchronize finalized design system references to brainstorming artifacts, preparing them for /workflow:plan consumption",
|
||||
"arguments": "--session <session_id> [--selected-prototypes \"<list>\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/design-sync.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:import-from-code",
|
||||
"command": "/workflow:ui-design:import-from-code",
|
||||
"description": "Import design system from code files (CSS/JS/HTML/SCSS) with automatic file discovery and parallel agent analysis",
|
||||
"arguments": "[--design-id <id>] [--session <id>] [--source <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/import-from-code.md"
|
||||
},
|
||||
{
|
||||
"name": "workflow:ui-design:reference-page-generator",
|
||||
"command": "/workflow:ui-design:reference-page-generator",
|
||||
"description": "Generate multi-component reference pages and documentation from design run extraction",
|
||||
"arguments": "[--design-run <path>] [--package-name <name>] [--output-dir <path>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/reference-page-generator.md"
|
||||
}
|
||||
],
|
||||
"implementation": [
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/issue:execute",
|
||||
"description": "Execute queue with DAG-based parallel orchestration (one commit per solution)",
|
||||
"arguments": "[-y|--yes] --queue <queue-id> [--worktree [<existing-path>]]",
|
||||
"category": "issue",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/issue/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/workflow:execute",
|
||||
"description": "Coordinate agent execution for workflow tasks with automatic session discovery, parallel task processing, and status tracking",
|
||||
"arguments": "[-y|--yes] [--resume-session=\\\"session-id\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-execute",
|
||||
"command": "/workflow:lite-execute",
|
||||
"description": "Execute tasks based on in-memory plan, prompt description, or file content",
|
||||
"arguments": "[-y|--yes] [--in-memory] [\\\"task description\\\"|file-path]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "test-cycle-execute",
|
||||
"command": "/workflow:test-cycle-execute",
|
||||
"description": "Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.",
|
||||
"arguments": "[--resume-session=\\\"session-id\\\"] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-cycle-execute.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-agent",
|
||||
"command": "/workflow:tools:task-generate-agent",
|
||||
"description": "Generate implementation plan documents (IMPL_PLAN.md, task JSONs, TODO_LIST.md) using action-planning-agent - produces planning artifacts, does NOT execute code implementation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-agent.md"
|
||||
},
|
||||
{
|
||||
"name": "task-generate-tdd",
|
||||
"command": "/workflow:tools:task-generate-tdd",
|
||||
"description": "Autonomous TDD task generation using action-planning-agent with Red-Green-Refactor cycles, test-first structure, and cycle validation",
|
||||
"arguments": "[-y|--yes] --session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/task-generate-tdd.md"
|
||||
},
|
||||
{
|
||||
"name": "test-task-generate",
|
||||
"command": "/workflow:tools:test-task-generate",
|
||||
"description": "Generate test planning documents (IMPL_PLAN.md, test task JSONs, TODO_LIST.md) using action-planning-agent - produces test planning artifacts, does NOT execute tests",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-task-generate.md"
|
||||
},
|
||||
{
|
||||
"name": "generate",
|
||||
"command": "/workflow:ui-design:generate",
|
||||
"description": "Assemble UI prototypes by combining layout templates with design tokens (default animation support), pure assembler without new content generation",
|
||||
"arguments": "[--design-id <id>] [--session <id>]",
|
||||
"category": "workflow",
|
||||
"subcategory": "ui-design",
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/ui-design/generate.md"
|
||||
},
|
||||
{
|
||||
"name": "unified-execute-with-file",
|
||||
"command": "/workflow:unified-execute-with-file",
|
||||
"description": "Universal execution engine for consuming any planning/brainstorm/analysis output with minimal progress tracking, multi-agent coordination, and incremental execution",
|
||||
"arguments": "[-y|--yes] [-p|--plan <path>] [-m|--mode sequential|parallel] [\\\"execution context or task name\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/unified-execute-with-file.md"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
{
|
||||
"name": "docs-full-cli",
|
||||
"command": "/memory:docs-full-cli",
|
||||
"description": "Generate full project documentation using CLI execution (Layer 3→1) with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <20 modules uses direct parallel",
|
||||
"arguments": "[path] [--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-full-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "docs-related-cli",
|
||||
"command": "/memory:docs-related-cli",
|
||||
"description": "Generate/update documentation for git-changed modules using CLI execution with batched agents (4 modules/agent) and gemini→qwen→codex fallback, <15 modules uses direct parallel",
|
||||
"arguments": "[--tool <gemini|qwen|codex>]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/docs-related-cli.md"
|
||||
},
|
||||
{
|
||||
"name": "style-skill-memory",
|
||||
"command": "/memory:style-skill-memory",
|
||||
"description": "Generate SKILL memory package from style reference for easy loading and consistent design system usage",
|
||||
"arguments": "[package-name] [--regenerate]",
|
||||
"category": "memory",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "documentation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/memory/style-skill-memory.md"
|
||||
}
|
||||
],
|
||||
"session-management": [
|
||||
{
|
||||
"name": "review-session-cycle",
|
||||
"command": "/workflow:review-session-cycle",
|
||||
"description": "Session-based comprehensive multi-dimensional code review. Analyzes git changes from workflow session across 7 dimensions with hybrid parallel-iterative execution, aggregates findings, and performs focused deep-dives on critical issues until quality gates met.",
|
||||
"arguments": "[session-id] [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-session-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "complete",
|
||||
"command": "/workflow:session:complete",
|
||||
"description": "Mark active workflow session as complete, archive with lessons learned, update manifest, remove active flag",
|
||||
"arguments": "[-y|--yes] [--detailed]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/complete.md"
|
||||
},
|
||||
{
|
||||
"name": "resume",
|
||||
"command": "/workflow:session:resume",
|
||||
"description": "Resume the most recently paused workflow session with automatic session discovery and status update",
|
||||
"arguments": "",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/resume.md"
|
||||
}
|
||||
],
|
||||
"testing": [
|
||||
{
|
||||
"name": "tdd-verify",
|
||||
"command": "/workflow:tdd-verify",
|
||||
"description": "Verify TDD workflow compliance against Red-Green-Refactor cycles. Generates quality report with coverage analysis and quality gate recommendation. Orchestrates sub-commands for comprehensive validation.",
|
||||
"arguments": "[optional: --session WFS-session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tdd-verify.md"
|
||||
},
|
||||
{
|
||||
"name": "test-fix-gen",
|
||||
"command": "/workflow:test-fix-gen",
|
||||
"description": "Create test-fix workflow session from session ID, description, or file path with test strategy generation and task planning",
|
||||
"arguments": "(source-session-id | \\\"feature description\\\" | /path/to/file.md)",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-fix-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "test-gen",
|
||||
"command": "/workflow:test-gen",
|
||||
"description": "Create independent test-fix workflow session from completed implementation session, analyzes code to generate test tasks",
|
||||
"arguments": "source-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/test-gen.md"
|
||||
},
|
||||
{
|
||||
"name": "tdd-coverage-analysis",
|
||||
"command": "/workflow:tools:tdd-coverage-analysis",
|
||||
"description": "Analyze test coverage and TDD cycle execution with Red-Green-Refactor compliance verification",
|
||||
"arguments": "--session WFS-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Advanced",
|
||||
"source": "../../../commands/workflow/tools/tdd-coverage-analysis.md"
|
||||
},
|
||||
{
|
||||
"name": "test-concept-enhanced",
|
||||
"command": "/workflow:tools:test-concept-enhanced",
|
||||
"description": "Coordinate test analysis workflow using cli-execution-agent to generate test strategy via Gemini",
|
||||
"arguments": "--session WFS-test-session-id --context path/to/test-context-package.json",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-concept-enhanced.md"
|
||||
},
|
||||
{
|
||||
"name": "test-context-gather",
|
||||
"command": "/workflow:tools:test-context-gather",
|
||||
"description": "Collect test coverage context using test-context-search-agent and package into standardized test-context JSON",
|
||||
"arguments": "--session WFS-test-session-id",
|
||||
"category": "workflow",
|
||||
"subcategory": "tools",
|
||||
"usage_scenario": "testing",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/tools/test-context-gather.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
160
.claude/skills/ccw-help/index/command-relationships.json
Normal file
160
.claude/skills/ccw-help/index/command-relationships.json
Normal file
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"workflow:plan": {
|
||||
"calls_internally": [
|
||||
"workflow:session:start",
|
||||
"workflow:tools:context-gather",
|
||||
"workflow:tools:conflict-resolution",
|
||||
"workflow:tools:task-generate-agent"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:plan-verify",
|
||||
"workflow:status",
|
||||
"workflow:execute"
|
||||
],
|
||||
"alternatives": [
|
||||
"workflow:tdd-plan"
|
||||
],
|
||||
"prerequisites": []
|
||||
},
|
||||
"workflow:tdd-plan": {
|
||||
"calls_internally": [
|
||||
"workflow:session:start",
|
||||
"workflow:tools:context-gather",
|
||||
"workflow:tools:task-generate-tdd"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:tdd-verify",
|
||||
"workflow:status",
|
||||
"workflow:execute"
|
||||
],
|
||||
"alternatives": [
|
||||
"workflow:plan"
|
||||
],
|
||||
"prerequisites": []
|
||||
},
|
||||
"workflow:execute": {
|
||||
"prerequisites": [
|
||||
"workflow:plan",
|
||||
"workflow:tdd-plan"
|
||||
],
|
||||
"related": [
|
||||
"workflow:status",
|
||||
"workflow:resume"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:review",
|
||||
"workflow:tdd-verify"
|
||||
]
|
||||
},
|
||||
"workflow:plan-verify": {
|
||||
"prerequisites": [
|
||||
"workflow:plan"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:execute"
|
||||
],
|
||||
"related": [
|
||||
"workflow:status"
|
||||
]
|
||||
},
|
||||
"workflow:tdd-verify": {
|
||||
"prerequisites": [
|
||||
"workflow:execute"
|
||||
],
|
||||
"related": [
|
||||
"workflow:tools:tdd-coverage-analysis"
|
||||
]
|
||||
},
|
||||
"workflow:session:start": {
|
||||
"next_steps": [
|
||||
"workflow:plan",
|
||||
"workflow:execute"
|
||||
],
|
||||
"related": [
|
||||
"workflow:session:list",
|
||||
"workflow:session:resume"
|
||||
]
|
||||
},
|
||||
"workflow:session:resume": {
|
||||
"alternatives": [
|
||||
"workflow:resume"
|
||||
],
|
||||
"related": [
|
||||
"workflow:session:list",
|
||||
"workflow:status"
|
||||
]
|
||||
},
|
||||
"workflow:lite-plan": {
|
||||
"calls_internally": [
|
||||
"workflow:lite-execute"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:lite-execute",
|
||||
"workflow:status"
|
||||
],
|
||||
"alternatives": [
|
||||
"workflow:plan"
|
||||
],
|
||||
"prerequisites": []
|
||||
},
|
||||
"workflow:lite-fix": {
|
||||
"next_steps": [
|
||||
"workflow:lite-execute",
|
||||
"workflow:status"
|
||||
],
|
||||
"alternatives": [
|
||||
"workflow:lite-plan"
|
||||
],
|
||||
"related": [
|
||||
"workflow:test-cycle-execute"
|
||||
]
|
||||
},
|
||||
"workflow:lite-execute": {
|
||||
"prerequisites": [
|
||||
"workflow:lite-plan",
|
||||
"workflow:lite-fix"
|
||||
],
|
||||
"related": [
|
||||
"workflow:execute",
|
||||
"workflow:status"
|
||||
]
|
||||
},
|
||||
"workflow:review-session-cycle": {
|
||||
"prerequisites": [
|
||||
"workflow:execute"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:review-fix"
|
||||
],
|
||||
"related": [
|
||||
"workflow:review-module-cycle"
|
||||
]
|
||||
},
|
||||
"workflow:review-fix": {
|
||||
"prerequisites": [
|
||||
"workflow:review-module-cycle",
|
||||
"workflow:review-session-cycle"
|
||||
],
|
||||
"related": [
|
||||
"workflow:test-cycle-execute"
|
||||
]
|
||||
},
|
||||
"memory:docs": {
|
||||
"calls_internally": [
|
||||
"workflow:session:start",
|
||||
"workflow:tools:context-gather"
|
||||
],
|
||||
"next_steps": [
|
||||
"workflow:execute"
|
||||
]
|
||||
},
|
||||
"memory:skill-memory": {
|
||||
"next_steps": [
|
||||
"workflow:plan",
|
||||
"cli:analyze"
|
||||
],
|
||||
"related": [
|
||||
"memory:load-skill-memory"
|
||||
]
|
||||
}
|
||||
}
|
||||
90
.claude/skills/ccw-help/index/essential-commands.json
Normal file
90
.claude/skills/ccw-help/index/essential-commands.json
Normal file
@@ -0,0 +1,90 @@
|
||||
[
|
||||
{
|
||||
"name": "lite-plan",
|
||||
"command": "/workflow:lite-plan",
|
||||
"description": "Lightweight interactive planning workflow with in-memory planning, code exploration, and execution execute to lite-execute after user confirmation",
|
||||
"arguments": "[-y|--yes] [-e|--explore] \\\"task description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-plan.md"
|
||||
},
|
||||
{
|
||||
"name": "lite-fix",
|
||||
"command": "/workflow:lite-fix",
|
||||
"description": "Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents",
|
||||
"arguments": "[-y|--yes] [--hotfix] \\\"bug description or issue reference\\",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/lite-fix.md"
|
||||
},
|
||||
{
|
||||
"name": "plan",
|
||||
"command": "/workflow:plan",
|
||||
"description": "5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs",
|
||||
"arguments": "[-y|--yes] \\\"text description\\\"|file.md",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan.md"
|
||||
},
|
||||
{
|
||||
"name": "execute",
|
||||
"command": "/workflow:execute",
|
||||
"description": "Coordinate agent execution for workflow tasks with automatic session discovery, parallel task processing, and status tracking",
|
||||
"arguments": "[-y|--yes] [--resume-session=\\\"session-id\\\"]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "implementation",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/execute.md"
|
||||
},
|
||||
{
|
||||
"name": "start",
|
||||
"command": "/workflow:session:start",
|
||||
"description": "Discover existing sessions or start new workflow session with intelligent session management and conflict detection",
|
||||
"arguments": "[--type <workflow|review|tdd|test|docs>] [--auto|--new] [optional: task description for new session]",
|
||||
"category": "workflow",
|
||||
"subcategory": "session",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/session/start.md"
|
||||
},
|
||||
{
|
||||
"name": "review-session-cycle",
|
||||
"command": "/workflow:review-session-cycle",
|
||||
"description": "Session-based comprehensive multi-dimensional code review. Analyzes git changes from workflow session across 7 dimensions with hybrid parallel-iterative execution, aggregates findings, and performs focused deep-dives on critical issues until quality gates met.",
|
||||
"arguments": "[session-id] [--dimensions=security,architecture,...] [--max-iterations=N]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "session-management",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/review-session-cycle.md"
|
||||
},
|
||||
{
|
||||
"name": "artifacts",
|
||||
"command": "/workflow:brainstorm:artifacts",
|
||||
"description": "Interactive clarification generating confirmed guidance specification through role-based analysis and synthesis",
|
||||
"arguments": "[-y|--yes] topic or challenge description [--count N]",
|
||||
"category": "workflow",
|
||||
"subcategory": "brainstorm",
|
||||
"usage_scenario": "general",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/brainstorm/artifacts.md"
|
||||
},
|
||||
{
|
||||
"name": "plan-verify",
|
||||
"command": "/workflow:plan-verify",
|
||||
"description": "Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.",
|
||||
"arguments": "[optional: --session session-id]",
|
||||
"category": "workflow",
|
||||
"subcategory": null,
|
||||
"usage_scenario": "planning",
|
||||
"difficulty": "Intermediate",
|
||||
"source": "../../../commands/workflow/plan-verify.md"
|
||||
}
|
||||
]
|
||||
34
.claude/skills/ccw-help/scripts/auto-update.py
Normal file
34
.claude/skills/ccw-help/scripts/auto-update.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple update script for ccw-help skill.
|
||||
Runs analyze_commands.py to regenerate command index.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
BASE_DIR = Path("D:/Claude_dms3/.claude")
|
||||
SKILL_DIR = BASE_DIR / "skills" / "ccw-help"
|
||||
ANALYZE_SCRIPT = SKILL_DIR / "scripts" / "analyze_commands.py"
|
||||
|
||||
def run_update():
|
||||
"""Run command analysis update."""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(ANALYZE_SCRIPT)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30
|
||||
)
|
||||
|
||||
print(result.stdout)
|
||||
return result.returncode == 0
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error running update: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
success = run_update()
|
||||
sys.exit(0 if success else 1)
|
||||
@@ -1,303 +0,0 @@
|
||||
# CCW Loop Skill
|
||||
|
||||
无状态迭代开发循环工作流,支持开发 (Develop)、调试 (Debug)、验证 (Validate) 三个阶段,每个阶段都有独立的文件记录进展。
|
||||
|
||||
## Overview
|
||||
|
||||
CCW Loop 是一个自主模式 (Autonomous) 的 Skill,通过文件驱动的无状态循环,帮助开发者系统化地完成开发任务。
|
||||
|
||||
### 核心特性
|
||||
|
||||
1. **无状态循环**: 每次执行从文件读取状态,不依赖内存
|
||||
2. **文件驱动**: 所有进度记录在 Markdown 文件中,可审计、可回顾
|
||||
3. **Gemini 辅助**: 关键决策点使用 CLI 工具进行深度分析
|
||||
4. **可恢复**: 任何时候中断后可继续
|
||||
5. **双模式**: 支持交互式和自动循环
|
||||
|
||||
### 三大阶段
|
||||
|
||||
- **Develop**: 任务分解 → 代码实现 → 进度记录
|
||||
- **Debug**: 假设生成 → 证据收集 → 根因分析 → 修复验证
|
||||
- **Validate**: 测试执行 → 覆盖率检查 → 质量评估
|
||||
|
||||
## Installation
|
||||
|
||||
已包含在 `.claude/skills/ccw-loop/`,无需额外安装。
|
||||
|
||||
## Usage
|
||||
|
||||
### 基本用法
|
||||
|
||||
```bash
|
||||
# 启动新循环
|
||||
/ccw-loop "实现用户认证功能"
|
||||
|
||||
# 继续现有循环
|
||||
/ccw-loop --resume LOOP-auth-2026-01-22
|
||||
|
||||
# 自动循环模式
|
||||
/ccw-loop --auto "修复登录bug并添加测试"
|
||||
```
|
||||
|
||||
### 交互式流程
|
||||
|
||||
```
|
||||
1. 启动: /ccw-loop "任务描述"
|
||||
2. 初始化: 自动分析任务并生成子任务列表
|
||||
3. 显示菜单:
|
||||
- 📝 继续开发 (Develop)
|
||||
- 🔍 开始调试 (Debug)
|
||||
- ✅ 运行验证 (Validate)
|
||||
- 📊 查看详情 (Status)
|
||||
- 🏁 完成循环 (Complete)
|
||||
- 🚪 退出 (Exit)
|
||||
4. 执行选择的动作
|
||||
5. 重复步骤 3-4 直到完成
|
||||
```
|
||||
|
||||
### 自动循环流程
|
||||
|
||||
```
|
||||
Develop (所有任务) → Debug (如有需要) → Validate → 完成
|
||||
```
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
.workflow/.loop/{session-id}/
|
||||
├── meta.json # 会话元数据 (不可修改)
|
||||
├── state.json # 当前状态 (每次更新)
|
||||
├── summary.md # 完成报告 (结束时生成)
|
||||
├── develop/
|
||||
│ ├── progress.md # 开发进度时间线
|
||||
│ ├── tasks.json # 任务列表
|
||||
│ └── changes.log # 代码变更日志 (NDJSON)
|
||||
├── debug/
|
||||
│ ├── understanding.md # 理解演变文档
|
||||
│ ├── hypotheses.json # 假设历史
|
||||
│ └── debug.log # 调试日志 (NDJSON)
|
||||
└── validate/
|
||||
├── validation.md # 验证报告
|
||||
├── test-results.json # 测试结果
|
||||
└── coverage.json # 覆盖率数据
|
||||
```
|
||||
|
||||
## Action Reference
|
||||
|
||||
| Action | 描述 | 触发条件 |
|
||||
|--------|------|----------|
|
||||
| action-init | 初始化会话 | 首次启动 |
|
||||
| action-menu | 显示操作菜单 | 交互模式下每次循环 |
|
||||
| action-develop-with-file | 执行开发任务 | 有待处理任务 |
|
||||
| action-debug-with-file | 假设驱动调试 | 需要调试 |
|
||||
| action-validate-with-file | 运行测试验证 | 需要验证 |
|
||||
| action-complete | 完成并生成报告 | 所有任务完成 |
|
||||
|
||||
详细说明见 [specs/action-catalog.md](specs/action-catalog.md)
|
||||
|
||||
## CLI Integration
|
||||
|
||||
CCW Loop 在关键决策点集成 CLI 工具:
|
||||
|
||||
### 任务分解 (action-init)
|
||||
```bash
|
||||
ccw cli -p "PURPOSE: 分解开发任务..."
|
||||
--tool gemini
|
||||
--mode analysis
|
||||
--rule planning-breakdown-task-steps
|
||||
```
|
||||
|
||||
### 代码实现 (action-develop)
|
||||
```bash
|
||||
ccw cli -p "PURPOSE: 实现功能代码..."
|
||||
--tool gemini
|
||||
--mode write
|
||||
--rule development-implement-feature
|
||||
```
|
||||
|
||||
### 假设生成 (action-debug - 探索)
|
||||
```bash
|
||||
ccw cli -p "PURPOSE: Generate debugging hypotheses..."
|
||||
--tool gemini
|
||||
--mode analysis
|
||||
--rule analysis-diagnose-bug-root-cause
|
||||
```
|
||||
|
||||
### 证据分析 (action-debug - 分析)
|
||||
```bash
|
||||
ccw cli -p "PURPOSE: Analyze debug log evidence..."
|
||||
--tool gemini
|
||||
--mode analysis
|
||||
--rule analysis-diagnose-bug-root-cause
|
||||
```
|
||||
|
||||
### 质量评估 (action-validate)
|
||||
```bash
|
||||
ccw cli -p "PURPOSE: Analyze test results and coverage..."
|
||||
--tool gemini
|
||||
--mode analysis
|
||||
--rule analysis-review-code-quality
|
||||
```
|
||||
|
||||
## State Management
|
||||
|
||||
### State Schema
|
||||
|
||||
参见 [phases/state-schema.md](phases/state-schema.md)
|
||||
|
||||
### State Transitions
|
||||
|
||||
```
|
||||
pending → running → completed
|
||||
↓
|
||||
user_exit
|
||||
↓
|
||||
failed
|
||||
```
|
||||
|
||||
### State Recovery
|
||||
|
||||
如果 `state.json` 损坏,可从其他文件重建:
|
||||
- develop/tasks.json → develop.*
|
||||
- debug/hypotheses.json → debug.*
|
||||
- validate/test-results.json → validate.*
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: 功能开发
|
||||
|
||||
```bash
|
||||
# 1. 启动循环
|
||||
/ccw-loop "Add user profile page"
|
||||
|
||||
# 2. 系统初始化,生成任务:
|
||||
# - task-001: Create profile component
|
||||
# - task-002: Add API endpoints
|
||||
# - task-003: Implement tests
|
||||
|
||||
# 3. 选择 "继续开发"
|
||||
# → 执行 task-001 (Gemini 辅助实现)
|
||||
# → 更新 progress.md
|
||||
|
||||
# 4. 重复开发直到所有任务完成
|
||||
|
||||
# 5. 选择 "运行验证"
|
||||
# → 运行测试
|
||||
# → 检查覆盖率
|
||||
# → 生成 validation.md
|
||||
|
||||
# 6. 选择 "完成循环"
|
||||
# → 生成 summary.md
|
||||
# → 询问是否扩展为 Issue
|
||||
```
|
||||
|
||||
### Example 2: Bug 修复
|
||||
|
||||
```bash
|
||||
# 1. 启动循环
|
||||
/ccw-loop "Fix login timeout issue"
|
||||
|
||||
# 2. 选择 "开始调试"
|
||||
# → 输入 bug 描述: "Login times out after 30s"
|
||||
# → Gemini 生成假设 (H1, H2, H3)
|
||||
# → 添加 NDJSON 日志
|
||||
# → 提示复现 bug
|
||||
|
||||
# 3. 复现 bug (在应用中操作)
|
||||
|
||||
# 4. 再次选择 "开始调试"
|
||||
# → 解析 debug.log
|
||||
# → Gemini 分析证据
|
||||
# → H2 确认为根因
|
||||
# → 生成修复代码
|
||||
# → 更新 understanding.md
|
||||
|
||||
# 5. 选择 "运行验证"
|
||||
# → 测试通过
|
||||
|
||||
# 6. 完成
|
||||
```
|
||||
|
||||
## Templates
|
||||
|
||||
- [progress-template.md](templates/progress-template.md): 开发进度文档模板
|
||||
- [understanding-template.md](templates/understanding-template.md): 调试理解文档模板
|
||||
- [validation-template.md](templates/validation-template.md): 验证报告模板
|
||||
|
||||
## Specifications
|
||||
|
||||
- [loop-requirements.md](specs/loop-requirements.md): 循环需求规范
|
||||
- [action-catalog.md](specs/action-catalog.md): 动作目录
|
||||
|
||||
## Integration
|
||||
|
||||
### Dashboard Integration
|
||||
|
||||
CCW Loop 与 Dashboard Loop Monitor 集成:
|
||||
- Dashboard 创建 Loop → 触发此 Skill
|
||||
- state.json → Dashboard 实时显示
|
||||
- 任务列表双向同步
|
||||
- 控制按钮映射到 actions
|
||||
|
||||
### Issue System Integration
|
||||
|
||||
完成后可扩展为 Issue:
|
||||
- 维度: test, enhance, refactor, doc
|
||||
- 自动调用 `/issue:new`
|
||||
- 上下文自动填充
|
||||
|
||||
## Error Handling
|
||||
|
||||
| 情况 | 处理 |
|
||||
|------|------|
|
||||
| Session 不存在 | 创建新会话 |
|
||||
| state.json 损坏 | 从文件重建 |
|
||||
| CLI 工具失败 | 回退到手动模式 |
|
||||
| 测试失败 | 循环回到 develop/debug |
|
||||
| >10 迭代 | 警告用户,建议拆分 |
|
||||
|
||||
## Limitations
|
||||
|
||||
1. **单会话限制**: 同一时间只能有一个活跃会话
|
||||
2. **迭代限制**: 建议不超过 10 次迭代
|
||||
3. **CLI 依赖**: 部分功能依赖 Gemini CLI 可用性
|
||||
4. **测试框架**: 需要 package.json 中定义测试脚本
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Q: 如何查看当前会话状态?
|
||||
|
||||
A: 在菜单中选择 "查看详情 (Status)"
|
||||
|
||||
### Q: 如何恢复中断的会话?
|
||||
|
||||
A: 使用 `--resume` 参数:
|
||||
```bash
|
||||
/ccw-loop --resume LOOP-xxx-2026-01-22
|
||||
```
|
||||
|
||||
### Q: 如果 CLI 工具失败怎么办?
|
||||
|
||||
A: Skill 会自动降级到手动模式,提示用户手动输入
|
||||
|
||||
### Q: 如何添加自定义 action?
|
||||
|
||||
A: 参见 [specs/action-catalog.md](specs/action-catalog.md) 的 "Action Extensions" 部分
|
||||
|
||||
## Contributing
|
||||
|
||||
添加新功能:
|
||||
1. 创建 action 文件在 `phases/actions/`
|
||||
2. 更新 orchestrator 决策逻辑
|
||||
3. 添加到 action-catalog.md
|
||||
4. 更新 action-menu.md
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
---
|
||||
|
||||
**Version**: 1.0.0
|
||||
**Last Updated**: 2026-01-22
|
||||
**Author**: CCW Team
|
||||
@@ -1,522 +0,0 @@
|
||||
---
|
||||
name: ccw
|
||||
description: Stateless workflow orchestrator. Auto-selects optimal workflow based on task intent. Triggers "ccw", "workflow".
|
||||
allowed-tools: Task(*), SlashCommand(*), AskUserQuestion(*), Read(*), Bash(*), Grep(*), TodoWrite(*)
|
||||
---
|
||||
|
||||
# CCW - Claude Code Workflow Orchestrator
|
||||
|
||||
无状态工作流协调器,根据任务意图自动选择最优工作流。
|
||||
|
||||
## Workflow System Overview
|
||||
|
||||
CCW 提供两个工作流系统:**Main Workflow** 和 **Issue Workflow**,协同覆盖完整的软件开发生命周期。
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Main Workflow │
|
||||
│ │
|
||||
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
||||
│ │ Level 1 │ → │ Level 2 │ → │ Level 3 │ → │ Level 4 │ │
|
||||
│ │ Rapid │ │ Lightweight │ │ Standard │ │ Brainstorm │ │
|
||||
│ │ │ │ │ │ │ │ │ │
|
||||
│ │ lite-lite- │ │ lite-plan │ │ plan │ │ brainstorm │ │
|
||||
│ │ lite │ │ lite-fix │ │ tdd-plan │ │ :auto- │ │
|
||||
│ │ │ │ multi-cli- │ │ test-fix- │ │ parallel │ │
|
||||
│ │ │ │ plan │ │ gen │ │ ↓ │ │
|
||||
│ │ │ │ │ │ │ │ plan │ │
|
||||
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
||||
│ │
|
||||
│ Complexity: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━▶ │
|
||||
│ Low High │
|
||||
└─────────────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
│ After development
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Issue Workflow │
|
||||
│ │
|
||||
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
||||
│ │ Accumulate │ → │ Plan │ → │ Execute │ │
|
||||
│ │ Discover & │ │ Batch │ │ Parallel │ │
|
||||
│ │ Collect │ │ Planning │ │ Execution │ │
|
||||
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
||||
│ │
|
||||
│ Supplementary role: Maintain main branch stability, worktree isolation │
|
||||
└─────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ CCW Orchestrator (CLI-Enhanced + Requirement Analysis) │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 1 │ Input Analysis (rule-based, fast path) │
|
||||
│ Phase 1.5 │ CLI Classification (semantic, smart path) │
|
||||
│ Phase 1.75 │ Requirement Clarification (clarity < 2) │
|
||||
│ Phase 2 │ Level Selection (intent → level → workflow) │
|
||||
│ Phase 2.5 │ CLI Action Planning (high complexity) │
|
||||
│ Phase 3 │ User Confirmation (optional) │
|
||||
│ Phase 4 │ TODO Tracking Setup │
|
||||
│ Phase 5 │ Execution Loop │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Level Quick Reference
|
||||
|
||||
| Level | Name | Workflows | Artifacts | Execution |
|
||||
|-------|------|-----------|-----------|-----------|
|
||||
| **1** | Rapid | `lite-lite-lite` | None | Direct execute |
|
||||
| **2** | Lightweight | `lite-plan`, `lite-fix`, `multi-cli-plan` | Memory/Lightweight files | → `lite-execute` |
|
||||
| **3** | Standard | `plan`, `tdd-plan`, `test-fix-gen` | Session persistence | → `execute` / `test-cycle-execute` |
|
||||
| **4** | Brainstorm | `brainstorm:auto-parallel` → `plan` | Multi-role analysis + Session | → `execute` |
|
||||
| **-** | Issue | `discover` → `plan` → `queue` → `execute` | Issue records | Worktree isolation (optional) |
|
||||
|
||||
## Workflow Selection Decision Tree
|
||||
|
||||
```
|
||||
Start
|
||||
│
|
||||
├─ Is it post-development maintenance?
|
||||
│ ├─ Yes → Issue Workflow
|
||||
│ └─ No ↓
|
||||
│
|
||||
├─ Are requirements clear?
|
||||
│ ├─ Uncertain → Level 4 (brainstorm:auto-parallel)
|
||||
│ └─ Clear ↓
|
||||
│
|
||||
├─ Need persistent Session?
|
||||
│ ├─ Yes → Level 3 (plan / tdd-plan / test-fix-gen)
|
||||
│ └─ No ↓
|
||||
│
|
||||
├─ Need multi-perspective / solution comparison?
|
||||
│ ├─ Yes → Level 2 (multi-cli-plan)
|
||||
│ └─ No ↓
|
||||
│
|
||||
├─ Is it a bug fix?
|
||||
│ ├─ Yes → Level 2 (lite-fix)
|
||||
│ └─ No ↓
|
||||
│
|
||||
├─ Need planning?
|
||||
│ ├─ Yes → Level 2 (lite-plan)
|
||||
│ └─ No → Level 1 (lite-lite-lite)
|
||||
```
|
||||
|
||||
## Intent Classification
|
||||
|
||||
### Priority Order (with Level Mapping)
|
||||
|
||||
| Priority | Intent | Patterns | Level | Flow |
|
||||
|----------|--------|----------|-------|------|
|
||||
| 1 | bugfix/hotfix | `urgent,production,critical` + bug | L2 | `bugfix.hotfix` |
|
||||
| 1 | bugfix | `fix,bug,error,crash,fail` | L2 | `bugfix.standard` |
|
||||
| 2 | issue batch | `issues,batch` + `fix,resolve` | Issue | `issue` |
|
||||
| 3 | exploration | `不确定,explore,研究,what if` | L4 | `full` |
|
||||
| 3 | multi-perspective | `多视角,权衡,比较方案,cross-verify` | L2 | `multi-cli-plan` |
|
||||
| 4 | quick-task | `快速,简单,small,quick` + feature | L1 | `lite-lite-lite` |
|
||||
| 5 | ui design | `ui,design,component,style` | L3/L4 | `ui` |
|
||||
| 6 | tdd | `tdd,test-driven,先写测试` | L3 | `tdd` |
|
||||
| 7 | test-fix | `测试失败,test fail,fix test` | L3 | `test-fix-gen` |
|
||||
| 8 | review | `review,审查,code review` | L3 | `review-fix` |
|
||||
| 9 | documentation | `文档,docs,readme` | L2 | `docs` |
|
||||
| 99 | feature | complexity-based | L2/L3 | `rapid`/`coupled` |
|
||||
|
||||
### Quick Selection Guide
|
||||
|
||||
| Scenario | Recommended Workflow | Level |
|
||||
|----------|---------------------|-------|
|
||||
| Quick fixes, config adjustments | `lite-lite-lite` | 1 |
|
||||
| Clear single-module features | `lite-plan → lite-execute` | 2 |
|
||||
| Bug diagnosis and fix | `lite-fix` | 2 |
|
||||
| Production emergencies | `lite-fix --hotfix` | 2 |
|
||||
| Technology selection, solution comparison | `multi-cli-plan → lite-execute` | 2 |
|
||||
| Multi-module changes, refactoring | `plan → verify → execute` | 3 |
|
||||
| Test-driven development | `tdd-plan → execute → tdd-verify` | 3 |
|
||||
| Test failure fixes | `test-fix-gen → test-cycle-execute` | 3 |
|
||||
| New features, architecture design | `brainstorm:auto-parallel → plan → execute` | 4 |
|
||||
| Post-development issue fixes | Issue Workflow | - |
|
||||
|
||||
### Complexity Assessment
|
||||
|
||||
```javascript
|
||||
function assessComplexity(text) {
|
||||
let score = 0
|
||||
if (/refactor|重构|migrate|迁移|architect|架构|system|系统/.test(text)) score += 2
|
||||
if (/multiple|多个|across|跨|all|所有|entire|整个/.test(text)) score += 2
|
||||
if (/integrate|集成|api|database|数据库/.test(text)) score += 1
|
||||
if (/security|安全|performance|性能|scale|扩展/.test(text)) score += 1
|
||||
return score >= 4 ? 'high' : score >= 2 ? 'medium' : 'low'
|
||||
}
|
||||
```
|
||||
|
||||
| Complexity | Flow |
|
||||
|------------|------|
|
||||
| high | `coupled` (plan → verify → execute) |
|
||||
| medium/low | `rapid` (lite-plan → lite-execute) |
|
||||
|
||||
### Dimension Extraction (WHAT/WHERE/WHY/HOW)
|
||||
|
||||
从用户输入提取四个维度,用于需求澄清和工作流选择:
|
||||
|
||||
| 维度 | 提取内容 | 示例模式 |
|
||||
|------|----------|----------|
|
||||
| **WHAT** | action + target | `创建/修复/重构/优化/分析` + 目标对象 |
|
||||
| **WHERE** | scope + paths | `file/module/system` + 文件路径 |
|
||||
| **WHY** | goal + motivation | `为了.../因为.../目的是...` |
|
||||
| **HOW** | constraints + preferences | `必须.../不要.../应该...` |
|
||||
|
||||
**Clarity Score** (0-3):
|
||||
- +0.5: 有明确 action
|
||||
- +0.5: 有具体 target
|
||||
- +0.5: 有文件路径
|
||||
- +0.5: scope 不是 unknown
|
||||
- +0.5: 有明确 goal
|
||||
- +0.5: 有约束条件
|
||||
- -0.5: 包含不确定词 (`不知道/maybe/怎么`)
|
||||
|
||||
### Requirement Clarification
|
||||
|
||||
当 `clarity_score < 2` 时触发需求澄清:
|
||||
|
||||
```javascript
|
||||
if (dimensions.clarity_score < 2) {
|
||||
const questions = generateClarificationQuestions(dimensions)
|
||||
// 生成问题:目标是什么? 范围是什么? 有什么约束?
|
||||
AskUserQuestion({ questions })
|
||||
}
|
||||
```
|
||||
|
||||
**澄清问题类型**:
|
||||
- 目标不明确 → "你想要对什么进行操作?"
|
||||
- 范围不明确 → "操作的范围是什么?"
|
||||
- 目的不明确 → "这个操作的主要目标是什么?"
|
||||
- 复杂操作 → "有什么特殊要求或限制?"
|
||||
|
||||
## TODO Tracking Protocol
|
||||
|
||||
### CRITICAL: Append-Only Rule
|
||||
|
||||
CCW 创建的 Todo **必须附加到现有列表**,不能覆盖用户的其他 Todo。
|
||||
|
||||
### Implementation
|
||||
|
||||
```javascript
|
||||
// 1. 使用 CCW 前缀隔离工作流 todo
|
||||
const prefix = `CCW:${flowName}`
|
||||
|
||||
// 2. 创建新 todo 时使用前缀格式
|
||||
TodoWrite({
|
||||
todos: [
|
||||
...existingNonCCWTodos, // 保留用户的 todo
|
||||
{ content: `${prefix}: [1/N] /command:step1`, status: "in_progress", activeForm: "..." },
|
||||
{ content: `${prefix}: [2/N] /command:step2`, status: "pending", activeForm: "..." }
|
||||
]
|
||||
})
|
||||
|
||||
// 3. 更新状态时只修改匹配前缀的 todo
|
||||
```
|
||||
|
||||
### Todo Format
|
||||
|
||||
```
|
||||
CCW:{flow}: [{N}/{Total}] /command:name
|
||||
```
|
||||
|
||||
### Visual Example
|
||||
|
||||
```
|
||||
✓ CCW:rapid: [1/2] /workflow:lite-plan
|
||||
→ CCW:rapid: [2/2] /workflow:lite-execute
|
||||
用户自己的 todo(保留不动)
|
||||
```
|
||||
|
||||
### Status Management
|
||||
|
||||
- 开始工作流:创建所有步骤 todo,第一步 `in_progress`
|
||||
- 完成步骤:当前步骤 `completed`,下一步 `in_progress`
|
||||
- 工作流结束:所有 CCW todo 标记 `completed`
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```javascript
|
||||
// 1. Check explicit command
|
||||
if (input.startsWith('/workflow:') || input.startsWith('/issue:')) {
|
||||
SlashCommand(input)
|
||||
return
|
||||
}
|
||||
|
||||
// 2. Classify intent
|
||||
const intent = classifyIntent(input) // See command.json intent_rules
|
||||
|
||||
// 3. Select flow
|
||||
const flow = selectFlow(intent) // See command.json flows
|
||||
|
||||
// 4. Create todos with CCW prefix
|
||||
createWorkflowTodos(flow)
|
||||
|
||||
// 5. Dispatch first command
|
||||
SlashCommand(flow.steps[0].command, args: input)
|
||||
```
|
||||
|
||||
## CLI Tool Integration
|
||||
|
||||
CCW 在特定条件下自动注入 CLI 调用:
|
||||
|
||||
| Condition | CLI Inject |
|
||||
|-----------|------------|
|
||||
| 大量代码上下文 (≥50k chars) | `gemini --mode analysis` |
|
||||
| 高复杂度任务 | `gemini --mode analysis` |
|
||||
| Bug 诊断 | `gemini --mode analysis` |
|
||||
| 多任务执行 (≥3 tasks) | `codex --mode write` |
|
||||
|
||||
### CLI Enhancement Phases
|
||||
|
||||
**Phase 1.5: CLI-Assisted Classification**
|
||||
|
||||
当规则匹配不明确时,使用 CLI 辅助分类:
|
||||
|
||||
| 触发条件 | 说明 |
|
||||
|----------|------|
|
||||
| matchCount < 2 | 多个意图模式匹配 |
|
||||
| complexity = high | 高复杂度任务 |
|
||||
| input > 100 chars | 长输入需要语义理解 |
|
||||
|
||||
**Phase 2.5: CLI-Assisted Action Planning**
|
||||
|
||||
高复杂度任务的工作流优化:
|
||||
|
||||
| 触发条件 | 说明 |
|
||||
|----------|------|
|
||||
| complexity = high | 高复杂度任务 |
|
||||
| steps >= 3 | 多步骤工作流 |
|
||||
| input > 200 chars | 复杂需求描述 |
|
||||
|
||||
CLI 可返回建议:`use_default` | `modify` (调整步骤) | `upgrade` (升级工作流)
|
||||
|
||||
## Continuation Commands
|
||||
|
||||
工作流执行中的用户控制命令:
|
||||
|
||||
| 命令 | 作用 |
|
||||
|------|------|
|
||||
| `continue` | 继续执行下一步 |
|
||||
| `skip` | 跳过当前步骤 |
|
||||
| `abort` | 终止工作流 |
|
||||
| `/workflow:*` | 切换到指定命令 |
|
||||
| 自然语言 | 重新分析意图 |
|
||||
|
||||
## Workflow Flow Details
|
||||
|
||||
### Issue Workflow (Main Workflow 补充机制)
|
||||
|
||||
Issue Workflow 是 Main Workflow 的**补充机制**,专注于开发后的持续维护。
|
||||
|
||||
#### 设计理念
|
||||
|
||||
| 方面 | Main Workflow | Issue Workflow |
|
||||
|------|---------------|----------------|
|
||||
| **用途** | 主要开发周期 | 开发后维护 |
|
||||
| **时机** | 功能开发阶段 | 主工作流完成后 |
|
||||
| **范围** | 完整功能实现 | 针对性修复/增强 |
|
||||
| **并行性** | 依赖分析 → Agent 并行 | Worktree 隔离 (可选) |
|
||||
| **分支模型** | 当前分支工作 | 可使用隔离的 worktree |
|
||||
|
||||
#### 为什么 Main Workflow 不自动使用 Worktree?
|
||||
|
||||
**依赖分析已解决并行性问题**:
|
||||
1. 规划阶段 (`/workflow:plan`) 执行依赖分析
|
||||
2. 自动识别任务依赖和关键路径
|
||||
3. 划分为**并行组**(独立任务)和**串行链**(依赖任务)
|
||||
4. Agent 并行执行独立任务,无需文件系统隔离
|
||||
|
||||
#### 两阶段生命周期
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ Phase 1: Accumulation (积累阶段) │
|
||||
│ │
|
||||
│ Triggers: 任务完成后的 review、代码审查发现、测试失败 │
|
||||
│ │
|
||||
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
|
||||
│ │ discover │ │ discover- │ │ new │ │
|
||||
│ │ Auto-find │ │ by-prompt │ │ Manual │ │
|
||||
│ └────────────┘ └────────────┘ └────────────┘ │
|
||||
│ │
|
||||
│ 持续积累 issues 到待处理队列 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
│ 积累足够后
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ Phase 2: Batch Resolution (批量解决阶段) │
|
||||
│ │
|
||||
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
|
||||
│ │ plan │ ──→ │ queue │ ──→ │ execute │ │
|
||||
│ │ --all- │ │ Optimize │ │ Parallel │ │
|
||||
│ │ pending │ │ order │ │ execution │ │
|
||||
│ └────────────┘ └────────────┘ └────────────┘ │
|
||||
│ │
|
||||
│ 支持 worktree 隔离,保持主分支稳定 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### 与 Main Workflow 的协作
|
||||
|
||||
```
|
||||
开发迭代循环
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ │
|
||||
│ ┌─────────┐ ┌─────────┐ │
|
||||
│ │ Feature │ ──→ Main Workflow ──→ Done ──→│ Review │ │
|
||||
│ │ Request │ (Level 1-4) └────┬────┘ │
|
||||
│ └─────────┘ │ │
|
||||
│ ▲ │ 发现 Issues │
|
||||
│ │ ▼ │
|
||||
│ │ ┌─────────┐ │
|
||||
│ 继续 │ │ Issue │ │
|
||||
│ 新功能│ │ Workflow│ │
|
||||
│ │ └────┬────┘ │
|
||||
│ │ ┌──────────────────────────────┘ │
|
||||
│ │ │ 修复完成 │
|
||||
│ │ ▼ │
|
||||
│ ┌────┴────┐◀────── │
|
||||
│ │ Main │ Merge │
|
||||
│ │ Branch │ back │
|
||||
│ └─────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### 命令列表
|
||||
|
||||
**积累阶段:**
|
||||
```bash
|
||||
/issue:discover # 多视角自动发现
|
||||
/issue:discover-by-prompt # 基于提示发现
|
||||
/issue:new # 手动创建
|
||||
```
|
||||
|
||||
**批量解决阶段:**
|
||||
```bash
|
||||
/issue:plan --all-pending # 批量规划所有待处理
|
||||
/issue:queue # 生成优化执行队列
|
||||
/issue:execute # 并行执行
|
||||
```
|
||||
|
||||
### lite-lite-lite vs multi-cli-plan
|
||||
|
||||
| 维度 | lite-lite-lite | multi-cli-plan |
|
||||
|------|---------------|----------------|
|
||||
| **产物** | 无文件 | IMPL_PLAN.md + plan.json + synthesis.json |
|
||||
| **状态** | 无状态 | 持久化 session |
|
||||
| **CLI选择** | 自动分析任务类型选择 | 配置驱动 |
|
||||
| **迭代** | 通过 AskUser | 多轮收敛 |
|
||||
| **执行** | 直接执行 | 通过 lite-execute |
|
||||
| **适用** | 快速修复、简单功能 | 复杂多步骤实现 |
|
||||
|
||||
**选择指南**:
|
||||
- 任务清晰、改动范围小 → `lite-lite-lite`
|
||||
- 需要多视角分析、复杂架构 → `multi-cli-plan`
|
||||
|
||||
### multi-cli-plan vs lite-plan
|
||||
|
||||
| 维度 | multi-cli-plan | lite-plan |
|
||||
|------|---------------|-----------|
|
||||
| **上下文** | ACE 语义搜索 | 手动文件模式 |
|
||||
| **分析** | 多 CLI 交叉验证 | 单次规划 |
|
||||
| **迭代** | 多轮直到收敛 | 单轮 |
|
||||
| **置信度** | 高 (共识驱动) | 中 (单一视角) |
|
||||
| **适用** | 需要多视角的复杂任务 | 直接明确的实现 |
|
||||
|
||||
**选择指南**:
|
||||
- 需求明确、路径清晰 → `lite-plan`
|
||||
- 需要权衡、多方案比较 → `multi-cli-plan`
|
||||
|
||||
## Artifact Flow Protocol
|
||||
|
||||
工作流产出的自动流转机制,支持不同格式产出间的意图提取和完成度判断。
|
||||
|
||||
### 产出格式
|
||||
|
||||
| 命令 | 产出位置 | 格式 | 关键字段 |
|
||||
|------|----------|------|----------|
|
||||
| `/workflow:lite-plan` | memory://plan | structured_plan | tasks, files, dependencies |
|
||||
| `/workflow:plan` | .workflow/{session}/IMPL_PLAN.md | markdown_plan | phases, tasks, risks |
|
||||
| `/workflow:execute` | execution_log.json | execution_report | completed_tasks, errors |
|
||||
| `/workflow:test-cycle-execute` | test_results.json | test_report | pass_rate, failures, coverage |
|
||||
| `/workflow:review-session-cycle` | review_report.md | review_report | findings, severity_counts |
|
||||
|
||||
### 意图提取 (Intent Extraction)
|
||||
|
||||
流转到下一步时,自动提取关键信息:
|
||||
|
||||
```
|
||||
plan → execute:
|
||||
提取: tasks (未完成), priority_order, files_to_modify, context_summary
|
||||
|
||||
execute → test:
|
||||
提取: modified_files, test_scope (推断), pending_verification
|
||||
|
||||
test → fix:
|
||||
条件: pass_rate < 0.95
|
||||
提取: failures, error_messages, affected_files, suggested_fixes
|
||||
|
||||
review → fix:
|
||||
条件: critical > 0 OR high > 3
|
||||
提取: findings (critical/high), fix_priority, affected_files
|
||||
```
|
||||
|
||||
### 完成度判断
|
||||
|
||||
**Test 完成度路由**:
|
||||
```
|
||||
pass_rate >= 0.95 AND coverage >= 0.80 → complete
|
||||
pass_rate >= 0.95 AND coverage < 0.80 → add_more_tests
|
||||
pass_rate >= 0.80 → fix_failures_then_continue
|
||||
pass_rate < 0.80 → major_fix_required
|
||||
```
|
||||
|
||||
**Review 完成度路由**:
|
||||
```
|
||||
critical == 0 AND high <= 3 → complete_or_optional_fix
|
||||
critical > 0 → mandatory_fix
|
||||
high > 3 → recommended_fix
|
||||
```
|
||||
|
||||
### 流转决策模式
|
||||
|
||||
**plan_execute_test**:
|
||||
```
|
||||
plan → execute → test
|
||||
↓ (if test fail)
|
||||
extract_failures → fix → test (max 3 iterations)
|
||||
↓ (if still fail)
|
||||
manual_intervention
|
||||
```
|
||||
|
||||
**iterative_improvement**:
|
||||
```
|
||||
execute → test → fix → test → ...
|
||||
loop until: pass_rate >= 0.95 OR iterations >= 3
|
||||
```
|
||||
|
||||
### 使用示例
|
||||
|
||||
```javascript
|
||||
// 执行完成后,根据产出决定下一步
|
||||
const result = await execute(plan)
|
||||
|
||||
// 提取意图流转到测试
|
||||
const testContext = extractIntent('execute_to_test', result)
|
||||
// testContext = { modified_files, test_scope, pending_verification }
|
||||
|
||||
// 测试完成后,根据完成度决定路由
|
||||
const testResult = await test(testContext)
|
||||
const nextStep = evaluateCompletion('test', testResult)
|
||||
// nextStep = 'fix_failures_then_continue' if pass_rate = 0.85
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
- [command.json](command.json) - 命令元数据、Flow 定义、意图规则、Artifact Flow
|
||||
@@ -1,641 +0,0 @@
|
||||
{
|
||||
"_metadata": {
|
||||
"version": "2.0.0",
|
||||
"description": "Unified CCW command index with capabilities, flows, and intent rules"
|
||||
},
|
||||
|
||||
"capabilities": {
|
||||
"explore": {
|
||||
"description": "Codebase exploration and context gathering",
|
||||
"commands": ["/workflow:init", "/workflow:tools:gather", "/memory:load"],
|
||||
"agents": ["cli-explore-agent", "context-search-agent"]
|
||||
},
|
||||
"brainstorm": {
|
||||
"description": "Multi-perspective analysis and ideation",
|
||||
"commands": ["/workflow:brainstorm:auto-parallel", "/workflow:brainstorm:artifacts", "/workflow:brainstorm:synthesis"],
|
||||
"roles": ["product-manager", "system-architect", "ux-expert", "data-architect", "api-designer"]
|
||||
},
|
||||
"plan": {
|
||||
"description": "Task planning and decomposition",
|
||||
"commands": ["/workflow:lite-plan", "/workflow:plan", "/workflow:tdd-plan", "/task:create", "/task:breakdown"],
|
||||
"agents": ["cli-lite-planning-agent", "action-planning-agent"]
|
||||
},
|
||||
"verify": {
|
||||
"description": "Plan and quality verification",
|
||||
"commands": ["/workflow:plan-verify", "/workflow:tdd-verify"]
|
||||
},
|
||||
"execute": {
|
||||
"description": "Task execution and implementation",
|
||||
"commands": ["/workflow:lite-execute", "/workflow:execute", "/task:execute"],
|
||||
"agents": ["code-developer", "cli-execution-agent", "universal-executor"]
|
||||
},
|
||||
"bugfix": {
|
||||
"description": "Bug diagnosis and fixing",
|
||||
"commands": ["/workflow:lite-fix"],
|
||||
"agents": ["code-developer"]
|
||||
},
|
||||
"test": {
|
||||
"description": "Test generation and execution",
|
||||
"commands": ["/workflow:test-gen", "/workflow:test-fix-gen", "/workflow:test-cycle-execute"],
|
||||
"agents": ["test-fix-agent"]
|
||||
},
|
||||
"review": {
|
||||
"description": "Code review and quality analysis",
|
||||
"commands": ["/workflow:review-session-cycle", "/workflow:review-module-cycle", "/workflow:review", "/workflow:review-fix"]
|
||||
},
|
||||
"issue": {
|
||||
"description": "Issue lifecycle management - discover, accumulate, batch resolve",
|
||||
"commands": ["/issue:new", "/issue:discover", "/issue:discover-by-prompt", "/issue:plan", "/issue:queue", "/issue:execute", "/issue:manage"],
|
||||
"agents": ["issue-plan-agent", "issue-queue-agent", "cli-explore-agent"],
|
||||
"lifecycle": {
|
||||
"accumulation": {
|
||||
"description": "任务完成后进行需求扩展、bug分析、测试发现",
|
||||
"triggers": ["post-task review", "code review findings", "test failures"],
|
||||
"commands": ["/issue:discover", "/issue:discover-by-prompt", "/issue:new"]
|
||||
},
|
||||
"batch_resolution": {
|
||||
"description": "积累的issue集中规划和并行执行",
|
||||
"flow": ["plan", "queue", "execute"],
|
||||
"commands": ["/issue:plan --all-pending", "/issue:queue", "/issue:execute"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ui-design": {
|
||||
"description": "UI design and prototyping",
|
||||
"commands": ["/workflow:ui-design:explore-auto", "/workflow:ui-design:imitate-auto", "/workflow:ui-design:design-sync"],
|
||||
"agents": ["ui-design-agent"]
|
||||
},
|
||||
"memory": {
|
||||
"description": "Documentation and knowledge management",
|
||||
"commands": ["/memory:docs", "/memory:update-related", "/memory:update-full", "/memory:skill-memory"],
|
||||
"agents": ["doc-generator", "memory-bridge"]
|
||||
}
|
||||
},
|
||||
|
||||
"flows": {
|
||||
"_level_guide": {
|
||||
"L1": "Rapid - No artifacts, direct execution",
|
||||
"L2": "Lightweight - Memory/lightweight files, → lite-execute",
|
||||
"L3": "Standard - Session persistence, → execute/test-cycle-execute",
|
||||
"L4": "Brainstorm - Multi-role analysis + Session, → execute"
|
||||
},
|
||||
"lite-lite-lite": {
|
||||
"name": "Ultra-Rapid Execution",
|
||||
"level": "L1",
|
||||
"description": "零文件 + 自动CLI选择 + 语义描述 + 直接执行",
|
||||
"complexity": ["low"],
|
||||
"artifacts": "none",
|
||||
"steps": [
|
||||
{ "phase": "clarify", "description": "需求澄清 (AskUser if needed)" },
|
||||
{ "phase": "auto-select", "description": "任务分析 → 自动选择CLI组合" },
|
||||
{ "phase": "multi-cli", "description": "并行多CLI分析" },
|
||||
{ "phase": "decision", "description": "展示结果 → AskUser决策" },
|
||||
{ "phase": "execute", "description": "直接执行 (无中间文件)" }
|
||||
],
|
||||
"cli_hints": {
|
||||
"analysis": { "tool": "auto", "mode": "analysis", "parallel": true },
|
||||
"execution": { "tool": "auto", "mode": "write" }
|
||||
},
|
||||
"estimated_time": "10-30 min"
|
||||
},
|
||||
"rapid": {
|
||||
"name": "Rapid Iteration",
|
||||
"level": "L2",
|
||||
"description": "内存规划 + 直接执行",
|
||||
"complexity": ["low", "medium"],
|
||||
"artifacts": "memory://plan",
|
||||
"steps": [
|
||||
{ "command": "/workflow:lite-plan", "optional": false, "auto_continue": true },
|
||||
{ "command": "/workflow:lite-execute", "optional": false }
|
||||
],
|
||||
"cli_hints": {
|
||||
"explore_phase": { "tool": "gemini", "mode": "analysis", "trigger": "needs_exploration" },
|
||||
"execution": { "tool": "codex", "mode": "write", "trigger": "complexity >= medium" }
|
||||
},
|
||||
"estimated_time": "15-45 min"
|
||||
},
|
||||
"multi-cli-plan": {
|
||||
"name": "Multi-CLI Collaborative Planning",
|
||||
"level": "L2",
|
||||
"description": "ACE上下文 + 多CLI协作分析 + 迭代收敛 + 计划生成",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/.multi-cli-plan/{session}/",
|
||||
"steps": [
|
||||
{ "command": "/workflow:multi-cli-plan", "optional": false, "phases": [
|
||||
"context_gathering: ACE语义搜索",
|
||||
"multi_cli_discussion: cli-discuss-agent多轮分析",
|
||||
"present_options: 展示解决方案",
|
||||
"user_decision: 用户选择",
|
||||
"plan_generation: cli-lite-planning-agent生成计划"
|
||||
]},
|
||||
{ "command": "/workflow:lite-execute", "optional": false }
|
||||
],
|
||||
"vs_lite_plan": {
|
||||
"context": "ACE semantic search vs Manual file patterns",
|
||||
"analysis": "Multi-CLI cross-verification vs Single-pass planning",
|
||||
"iteration": "Multiple rounds until convergence vs Single round",
|
||||
"confidence": "High (consensus-based) vs Medium (single perspective)",
|
||||
"best_for": "Complex tasks needing multiple perspectives vs Straightforward implementations"
|
||||
},
|
||||
"agents": ["cli-discuss-agent", "cli-lite-planning-agent"],
|
||||
"cli_hints": {
|
||||
"discussion": { "tools": ["gemini", "codex", "claude"], "mode": "analysis", "parallel": true },
|
||||
"planning": { "tool": "gemini", "mode": "analysis" }
|
||||
},
|
||||
"estimated_time": "30-90 min"
|
||||
},
|
||||
"coupled": {
|
||||
"name": "Standard Planning",
|
||||
"level": "L3",
|
||||
"description": "完整规划 + 验证 + 执行",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/active/{session}/",
|
||||
"steps": [
|
||||
{ "command": "/workflow:plan", "optional": false },
|
||||
{ "command": "/workflow:plan-verify", "optional": false, "auto_continue": true },
|
||||
{ "command": "/workflow:execute", "optional": false },
|
||||
{ "command": "/workflow:review", "optional": true }
|
||||
],
|
||||
"cli_hints": {
|
||||
"pre_analysis": { "tool": "gemini", "mode": "analysis", "trigger": "always" },
|
||||
"execution": { "tool": "codex", "mode": "write", "trigger": "always" }
|
||||
},
|
||||
"estimated_time": "2-4 hours"
|
||||
},
|
||||
"full": {
|
||||
"name": "Full Exploration (Brainstorm)",
|
||||
"level": "L4",
|
||||
"description": "头脑风暴 + 规划 + 执行",
|
||||
"complexity": ["high"],
|
||||
"artifacts": ".workflow/active/{session}/.brainstorming/",
|
||||
"steps": [
|
||||
{ "command": "/workflow:brainstorm:auto-parallel", "optional": false, "confirm_before": true },
|
||||
{ "command": "/workflow:plan", "optional": false },
|
||||
{ "command": "/workflow:plan-verify", "optional": true, "auto_continue": true },
|
||||
{ "command": "/workflow:execute", "optional": false }
|
||||
],
|
||||
"cli_hints": {
|
||||
"role_analysis": { "tool": "gemini", "mode": "analysis", "trigger": "always", "parallel": true },
|
||||
"execution": { "tool": "codex", "mode": "write", "trigger": "task_count >= 3" }
|
||||
},
|
||||
"estimated_time": "1-3 hours"
|
||||
},
|
||||
"bugfix": {
|
||||
"name": "Bug Fix",
|
||||
"level": "L2",
|
||||
"description": "智能诊断 + 修复 (5 phases)",
|
||||
"complexity": ["low", "medium"],
|
||||
"artifacts": ".workflow/.lite-fix/{bug-slug}-{date}/",
|
||||
"variants": {
|
||||
"standard": [{ "command": "/workflow:lite-fix", "optional": false }],
|
||||
"hotfix": [{ "command": "/workflow:lite-fix --hotfix", "optional": false }]
|
||||
},
|
||||
"phases": [
|
||||
"Phase 1: Bug Analysis & Diagnosis (severity pre-assessment)",
|
||||
"Phase 2: Clarification (optional, AskUserQuestion)",
|
||||
"Phase 3: Fix Planning (Low/Medium → Claude, High/Critical → cli-lite-planning-agent)",
|
||||
"Phase 4: Confirmation & Selection",
|
||||
"Phase 5: Execute (→ lite-execute --mode bugfix)"
|
||||
],
|
||||
"cli_hints": {
|
||||
"diagnosis": { "tool": "gemini", "mode": "analysis", "trigger": "always" },
|
||||
"fix": { "tool": "codex", "mode": "write", "trigger": "severity >= medium" }
|
||||
},
|
||||
"estimated_time": "10-30 min"
|
||||
},
|
||||
"issue": {
|
||||
"name": "Issue Lifecycle",
|
||||
"level": "Supplementary",
|
||||
"description": "发现积累 → 批量规划 → 队列优化 → 并行执行 (Main Workflow 补充机制)",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/.issues/",
|
||||
"purpose": "Post-development continuous maintenance, maintain main branch stability",
|
||||
"phases": {
|
||||
"accumulation": {
|
||||
"description": "项目迭代中持续发现和积累issue",
|
||||
"commands": ["/issue:discover", "/issue:discover-by-prompt", "/issue:new"],
|
||||
"trigger": "post-task, code-review, test-failure"
|
||||
},
|
||||
"resolution": {
|
||||
"description": "集中规划和执行积累的issue",
|
||||
"steps": [
|
||||
{ "command": "/issue:plan --all-pending", "optional": false },
|
||||
{ "command": "/issue:queue", "optional": false },
|
||||
{ "command": "/issue:execute", "optional": false }
|
||||
]
|
||||
}
|
||||
},
|
||||
"worktree_support": {
|
||||
"description": "可选的 worktree 隔离,保持主分支稳定",
|
||||
"use_case": "主开发完成后的 issue 修复"
|
||||
},
|
||||
"cli_hints": {
|
||||
"discovery": { "tool": "gemini", "mode": "analysis", "trigger": "perspective_analysis", "parallel": true },
|
||||
"solution_generation": { "tool": "gemini", "mode": "analysis", "trigger": "always", "parallel": true },
|
||||
"batch_execution": { "tool": "codex", "mode": "write", "trigger": "always" }
|
||||
},
|
||||
"estimated_time": "1-4 hours"
|
||||
},
|
||||
"tdd": {
|
||||
"name": "Test-Driven Development",
|
||||
"level": "L3",
|
||||
"description": "TDD规划 + 执行 + 验证 (6 phases)",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/active/{session}/",
|
||||
"steps": [
|
||||
{ "command": "/workflow:tdd-plan", "optional": false },
|
||||
{ "command": "/workflow:plan-verify", "optional": true, "auto_continue": true },
|
||||
{ "command": "/workflow:execute", "optional": false },
|
||||
{ "command": "/workflow:tdd-verify", "optional": false }
|
||||
],
|
||||
"tdd_structure": {
|
||||
"description": "Each IMPL task contains complete internal Red-Green-Refactor cycle",
|
||||
"meta": "tdd_workflow: true",
|
||||
"flow_control": "implementation_approach contains 3 steps (red/green/refactor)"
|
||||
},
|
||||
"cli_hints": {
|
||||
"test_strategy": { "tool": "gemini", "mode": "analysis", "trigger": "always" },
|
||||
"red_green_refactor": { "tool": "codex", "mode": "write", "trigger": "always" }
|
||||
},
|
||||
"estimated_time": "1-3 hours"
|
||||
},
|
||||
"test-fix": {
|
||||
"name": "Test Fix Generation",
|
||||
"level": "L3",
|
||||
"description": "测试修复生成 + 执行循环 (5 phases)",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/active/WFS-test-{session}/",
|
||||
"dual_mode": {
|
||||
"session_mode": { "input": "WFS-xxx", "context_source": "Source session summaries" },
|
||||
"prompt_mode": { "input": "Text/file path", "context_source": "Direct codebase analysis" }
|
||||
},
|
||||
"steps": [
|
||||
{ "command": "/workflow:test-fix-gen", "optional": false },
|
||||
{ "command": "/workflow:test-cycle-execute", "optional": false }
|
||||
],
|
||||
"task_structure": [
|
||||
"IMPL-001.json (test understanding & generation)",
|
||||
"IMPL-001.5-review.json (quality gate)",
|
||||
"IMPL-002.json (test execution & fix cycle)"
|
||||
],
|
||||
"cli_hints": {
|
||||
"analysis": { "tool": "gemini", "mode": "analysis", "trigger": "always" },
|
||||
"fix_cycle": { "tool": "codex", "mode": "write", "trigger": "pass_rate < 0.95" }
|
||||
},
|
||||
"estimated_time": "1-2 hours"
|
||||
},
|
||||
"ui": {
|
||||
"name": "UI-First Development",
|
||||
"level": "L3/L4",
|
||||
"description": "UI设计 + 规划 + 执行",
|
||||
"complexity": ["medium", "high"],
|
||||
"artifacts": ".workflow/active/{session}/",
|
||||
"variants": {
|
||||
"explore": [
|
||||
{ "command": "/workflow:ui-design:explore-auto", "optional": false },
|
||||
{ "command": "/workflow:ui-design:design-sync", "optional": false, "auto_continue": true },
|
||||
{ "command": "/workflow:plan", "optional": false },
|
||||
{ "command": "/workflow:execute", "optional": false }
|
||||
],
|
||||
"imitate": [
|
||||
{ "command": "/workflow:ui-design:imitate-auto", "optional": false },
|
||||
{ "command": "/workflow:ui-design:design-sync", "optional": false, "auto_continue": true },
|
||||
{ "command": "/workflow:plan", "optional": false },
|
||||
{ "command": "/workflow:execute", "optional": false }
|
||||
]
|
||||
},
|
||||
"estimated_time": "2-4 hours"
|
||||
},
|
||||
"review-fix": {
|
||||
"name": "Review and Fix",
|
||||
"level": "L3",
|
||||
"description": "多维审查 + 自动修复",
|
||||
"complexity": ["medium"],
|
||||
"artifacts": ".workflow/active/{session}/review_report.md",
|
||||
"steps": [
|
||||
{ "command": "/workflow:review-session-cycle", "optional": false },
|
||||
{ "command": "/workflow:review-fix", "optional": true }
|
||||
],
|
||||
"cli_hints": {
|
||||
"multi_dimension_review": { "tool": "gemini", "mode": "analysis", "trigger": "always", "parallel": true },
|
||||
"auto_fix": { "tool": "codex", "mode": "write", "trigger": "findings_count >= 3" }
|
||||
},
|
||||
"estimated_time": "30-90 min"
|
||||
},
|
||||
"docs": {
|
||||
"name": "Documentation",
|
||||
"level": "L2",
|
||||
"description": "批量文档生成",
|
||||
"complexity": ["low", "medium"],
|
||||
"variants": {
|
||||
"incremental": [{ "command": "/memory:update-related", "optional": false }],
|
||||
"full": [
|
||||
{ "command": "/memory:docs", "optional": false },
|
||||
{ "command": "/workflow:execute", "optional": false }
|
||||
]
|
||||
},
|
||||
"estimated_time": "15-60 min"
|
||||
}
|
||||
},
|
||||
|
||||
"intent_rules": {
|
||||
"_level_mapping": {
|
||||
"description": "Intent → Level → Flow mapping guide",
|
||||
"L1": ["lite-lite-lite"],
|
||||
"L2": ["rapid", "bugfix", "multi-cli-plan", "docs"],
|
||||
"L3": ["coupled", "tdd", "test-fix", "review-fix", "ui"],
|
||||
"L4": ["full"],
|
||||
"Supplementary": ["issue"]
|
||||
},
|
||||
"bugfix": {
|
||||
"priority": 1,
|
||||
"level": "L2",
|
||||
"variants": {
|
||||
"hotfix": {
|
||||
"patterns": ["hotfix", "urgent", "production", "critical", "emergency", "紧急", "生产环境", "线上"],
|
||||
"flow": "bugfix.hotfix"
|
||||
},
|
||||
"standard": {
|
||||
"patterns": ["fix", "bug", "error", "issue", "crash", "broken", "fail", "wrong", "修复", "错误", "崩溃"],
|
||||
"flow": "bugfix.standard"
|
||||
}
|
||||
}
|
||||
},
|
||||
"issue_batch": {
|
||||
"priority": 2,
|
||||
"level": "Supplementary",
|
||||
"patterns": {
|
||||
"batch": ["issues", "batch", "queue", "多个", "批量"],
|
||||
"action": ["fix", "resolve", "处理", "解决"]
|
||||
},
|
||||
"require_both": true,
|
||||
"flow": "issue"
|
||||
},
|
||||
"exploration": {
|
||||
"priority": 3,
|
||||
"level": "L4",
|
||||
"patterns": ["不确定", "不知道", "explore", "研究", "分析一下", "怎么做", "what if", "探索"],
|
||||
"flow": "full"
|
||||
},
|
||||
"multi_perspective": {
|
||||
"priority": 3,
|
||||
"level": "L2",
|
||||
"patterns": ["多视角", "权衡", "比较方案", "cross-verify", "多CLI", "协作分析"],
|
||||
"flow": "multi-cli-plan"
|
||||
},
|
||||
"quick_task": {
|
||||
"priority": 4,
|
||||
"level": "L1",
|
||||
"patterns": ["快速", "简单", "small", "quick", "simple", "trivial", "小改动"],
|
||||
"flow": "lite-lite-lite"
|
||||
},
|
||||
"ui_design": {
|
||||
"priority": 5,
|
||||
"level": "L3/L4",
|
||||
"patterns": ["ui", "界面", "design", "设计", "component", "组件", "style", "样式", "layout", "布局"],
|
||||
"variants": {
|
||||
"imitate": { "triggers": ["参考", "模仿", "像", "类似"], "flow": "ui.imitate" },
|
||||
"explore": { "triggers": [], "flow": "ui.explore" }
|
||||
}
|
||||
},
|
||||
"tdd": {
|
||||
"priority": 6,
|
||||
"level": "L3",
|
||||
"patterns": ["tdd", "test-driven", "测试驱动", "先写测试", "test first"],
|
||||
"flow": "tdd"
|
||||
},
|
||||
"test_fix": {
|
||||
"priority": 7,
|
||||
"level": "L3",
|
||||
"patterns": ["测试失败", "test fail", "fix test", "test error", "pass rate", "coverage gap"],
|
||||
"flow": "test-fix"
|
||||
},
|
||||
"review": {
|
||||
"priority": 8,
|
||||
"level": "L3",
|
||||
"patterns": ["review", "审查", "检查代码", "code review", "质量检查"],
|
||||
"flow": "review-fix"
|
||||
},
|
||||
"documentation": {
|
||||
"priority": 9,
|
||||
"level": "L2",
|
||||
"patterns": ["文档", "documentation", "docs", "readme"],
|
||||
"variants": {
|
||||
"incremental": { "triggers": ["更新", "增量"], "flow": "docs.incremental" },
|
||||
"full": { "triggers": ["全部", "完整"], "flow": "docs.full" }
|
||||
}
|
||||
},
|
||||
"feature": {
|
||||
"priority": 99,
|
||||
"complexity_map": {
|
||||
"high": { "level": "L3", "flow": "coupled" },
|
||||
"medium": { "level": "L2", "flow": "rapid" },
|
||||
"low": { "level": "L1", "flow": "lite-lite-lite" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"complexity_indicators": {
|
||||
"high": {
|
||||
"threshold": 4,
|
||||
"patterns": {
|
||||
"architecture": { "keywords": ["refactor", "重构", "migrate", "迁移", "architect", "架构", "system", "系统"], "weight": 2 },
|
||||
"multi_module": { "keywords": ["multiple", "多个", "across", "跨", "all", "所有", "entire", "整个"], "weight": 2 },
|
||||
"integration": { "keywords": ["integrate", "集成", "api", "database", "数据库"], "weight": 1 },
|
||||
"quality": { "keywords": ["security", "安全", "performance", "性能", "scale", "扩展"], "weight": 1 }
|
||||
}
|
||||
},
|
||||
"medium": { "threshold": 2 },
|
||||
"low": { "threshold": 0 }
|
||||
},
|
||||
|
||||
"cli_tools": {
|
||||
"gemini": {
|
||||
"strengths": ["超长上下文", "深度分析", "架构理解", "执行流追踪"],
|
||||
"triggers": ["分析", "理解", "设计", "架构", "诊断"],
|
||||
"mode": "analysis"
|
||||
},
|
||||
"qwen": {
|
||||
"strengths": ["代码模式识别", "多维度分析"],
|
||||
"triggers": ["评估", "对比", "验证"],
|
||||
"mode": "analysis"
|
||||
},
|
||||
"codex": {
|
||||
"strengths": ["精确代码生成", "自主执行"],
|
||||
"triggers": ["实现", "重构", "修复", "生成"],
|
||||
"mode": "write"
|
||||
}
|
||||
},
|
||||
|
||||
"cli_injection_rules": {
|
||||
"context_gathering": { "trigger": "file_read >= 50k OR module_count >= 5", "inject": "gemini --mode analysis" },
|
||||
"pre_planning_analysis": { "trigger": "complexity === high", "inject": "gemini --mode analysis" },
|
||||
"debug_diagnosis": { "trigger": "intent === bugfix AND root_cause_unclear", "inject": "gemini --mode analysis" },
|
||||
"code_review": { "trigger": "step === review", "inject": "gemini --mode analysis" },
|
||||
"implementation": { "trigger": "step === execute AND task_count >= 3", "inject": "codex --mode write" }
|
||||
},
|
||||
|
||||
"artifact_flow": {
|
||||
"_description": "定义工作流产出的格式、意图提取和流转规则",
|
||||
|
||||
"outputs": {
|
||||
"/workflow:lite-plan": {
|
||||
"artifact": "memory://plan",
|
||||
"format": "structured_plan",
|
||||
"fields": ["tasks", "files", "dependencies", "approach"]
|
||||
},
|
||||
"/workflow:plan": {
|
||||
"artifact": ".workflow/{session}/IMPL_PLAN.md",
|
||||
"format": "markdown_plan",
|
||||
"fields": ["phases", "tasks", "dependencies", "risks", "test_strategy"]
|
||||
},
|
||||
"/workflow:multi-cli-plan": {
|
||||
"artifact": ".workflow/.multi-cli-plan/{session}/",
|
||||
"format": "multi_file",
|
||||
"files": ["IMPL_PLAN.md", "plan.json", "synthesis.json"],
|
||||
"fields": ["consensus", "divergences", "recommended_approach", "tasks"]
|
||||
},
|
||||
"/workflow:lite-execute": {
|
||||
"artifact": "git_changes",
|
||||
"format": "code_diff",
|
||||
"fields": ["modified_files", "added_files", "deleted_files", "build_status"]
|
||||
},
|
||||
"/workflow:execute": {
|
||||
"artifact": ".workflow/{session}/execution_log.json",
|
||||
"format": "execution_report",
|
||||
"fields": ["completed_tasks", "pending_tasks", "errors", "warnings"]
|
||||
},
|
||||
"/workflow:test-cycle-execute": {
|
||||
"artifact": ".workflow/{session}/test_results.json",
|
||||
"format": "test_report",
|
||||
"fields": ["pass_rate", "failures", "coverage", "duration"]
|
||||
},
|
||||
"/workflow:review-session-cycle": {
|
||||
"artifact": ".workflow/{session}/review_report.md",
|
||||
"format": "review_report",
|
||||
"fields": ["findings", "severity_counts", "recommendations"]
|
||||
},
|
||||
"/workflow:lite-fix": {
|
||||
"artifact": "git_changes",
|
||||
"format": "fix_report",
|
||||
"fields": ["root_cause", "fix_applied", "files_modified", "verification_status"]
|
||||
}
|
||||
},
|
||||
|
||||
"intent_extraction": {
|
||||
"plan_to_execute": {
|
||||
"from": ["lite-plan", "plan", "multi-cli-plan"],
|
||||
"to": ["lite-execute", "execute"],
|
||||
"extract": {
|
||||
"tasks": "$.tasks[] | filter(status != 'completed')",
|
||||
"priority_order": "$.tasks | sort_by(priority)",
|
||||
"files_to_modify": "$.tasks[].files | flatten | unique",
|
||||
"dependencies": "$.dependencies",
|
||||
"context_summary": "$.approach OR $.recommended_approach"
|
||||
}
|
||||
},
|
||||
"execute_to_test": {
|
||||
"from": ["lite-execute", "execute"],
|
||||
"to": ["test-cycle-execute", "test-fix-gen"],
|
||||
"extract": {
|
||||
"modified_files": "$.modified_files",
|
||||
"test_scope": "infer_from($.modified_files)",
|
||||
"build_status": "$.build_status",
|
||||
"pending_verification": "$.completed_tasks | needs_test"
|
||||
}
|
||||
},
|
||||
"test_to_fix": {
|
||||
"from": ["test-cycle-execute"],
|
||||
"to": ["lite-fix", "review-fix"],
|
||||
"condition": "$.pass_rate < 0.95",
|
||||
"extract": {
|
||||
"failures": "$.failures",
|
||||
"error_messages": "$.failures[].message",
|
||||
"affected_files": "$.failures[].file",
|
||||
"suggested_fixes": "$.failures[].suggested_fix"
|
||||
}
|
||||
},
|
||||
"review_to_fix": {
|
||||
"from": ["review-session-cycle", "review-module-cycle"],
|
||||
"to": ["review-fix"],
|
||||
"condition": "$.severity_counts.critical > 0 OR $.severity_counts.high > 3",
|
||||
"extract": {
|
||||
"findings": "$.findings | filter(severity in ['critical', 'high'])",
|
||||
"fix_priority": "$.findings | group_by(category) | sort_by(severity)",
|
||||
"affected_files": "$.findings[].file | unique"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"completion_criteria": {
|
||||
"plan": {
|
||||
"required": ["has_tasks", "has_files"],
|
||||
"optional": ["has_tests", "no_blocking_risks"],
|
||||
"threshold": 0.8,
|
||||
"routing": {
|
||||
"complete": "proceed_to_execute",
|
||||
"incomplete": "clarify_requirements"
|
||||
}
|
||||
},
|
||||
"execute": {
|
||||
"required": ["all_tasks_attempted", "no_critical_errors"],
|
||||
"optional": ["build_passes", "lint_passes"],
|
||||
"threshold": 1.0,
|
||||
"routing": {
|
||||
"complete": "proceed_to_test_or_review",
|
||||
"partial": "continue_execution",
|
||||
"failed": "diagnose_and_retry"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"metrics": {
|
||||
"pass_rate": { "target": 0.95, "minimum": 0.80 },
|
||||
"coverage": { "target": 0.80, "minimum": 0.60 }
|
||||
},
|
||||
"routing": {
|
||||
"pass_rate >= 0.95 AND coverage >= 0.80": "complete",
|
||||
"pass_rate >= 0.95 AND coverage < 0.80": "add_more_tests",
|
||||
"pass_rate >= 0.80": "fix_failures_then_continue",
|
||||
"pass_rate < 0.80": "major_fix_required"
|
||||
}
|
||||
},
|
||||
"review": {
|
||||
"metrics": {
|
||||
"critical_findings": { "target": 0, "maximum": 0 },
|
||||
"high_findings": { "target": 0, "maximum": 3 }
|
||||
},
|
||||
"routing": {
|
||||
"critical == 0 AND high <= 3": "complete_or_optional_fix",
|
||||
"critical > 0": "mandatory_fix",
|
||||
"high > 3": "recommended_fix"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"flow_decisions": {
|
||||
"_description": "根据产出完成度决定下一步",
|
||||
"patterns": {
|
||||
"plan_execute_test": {
|
||||
"sequence": ["plan", "execute", "test"],
|
||||
"on_test_fail": {
|
||||
"action": "extract_failures_and_fix",
|
||||
"max_iterations": 3,
|
||||
"fallback": "manual_intervention"
|
||||
}
|
||||
},
|
||||
"plan_execute_review": {
|
||||
"sequence": ["plan", "execute", "review"],
|
||||
"on_review_issues": {
|
||||
"action": "prioritize_and_fix",
|
||||
"auto_fix_threshold": "severity < high"
|
||||
}
|
||||
},
|
||||
"iterative_improvement": {
|
||||
"sequence": ["execute", "test", "fix"],
|
||||
"loop_until": "pass_rate >= 0.95 OR iterations >= 3",
|
||||
"on_loop_exit": "report_status"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
650
.claude/skills/lite-skill-generator/SKILL.md
Normal file
650
.claude/skills/lite-skill-generator/SKILL.md
Normal file
@@ -0,0 +1,650 @@
|
||||
---
|
||||
name: lite-skill-generator
|
||||
description: Lightweight skill generator with style learning - creates simple skills using flow-based execution and style imitation. Use for quick skill scaffolding, simple workflow creation, or style-aware skill generation.
|
||||
allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion
|
||||
---
|
||||
|
||||
# Lite Skill Generator
|
||||
|
||||
Lightweight meta-skill for rapid skill creation with intelligent style learning and flow-based execution.
|
||||
|
||||
## Core Concept
|
||||
|
||||
**Simplicity First**: Generate simple, focused skills quickly with minimal overhead. Learn from existing skills to maintain consistent style and structure.
|
||||
|
||||
**Progressive Disclosure**: Follow anthropics' three-layer loading principle:
|
||||
1. **Metadata** - name, description, triggers (always loaded)
|
||||
2. **SKILL.md** - core instructions (loaded when triggered)
|
||||
3. **Bundled resources** - scripts, references, assets (loaded on demand)
|
||||
|
||||
## Execution Model
|
||||
|
||||
**3-Phase Flow**: Style Learning → Requirements Gathering → Generation
|
||||
|
||||
```
|
||||
User Input → Phase 1: Style Analysis → Phase 2: Requirements → Phase 3: Generate → Skill Package
|
||||
↓ ↓ ↓
|
||||
Learn from examples Interactive prompts Write files + validate
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Lite Skill Generator │
|
||||
│ │
|
||||
│ Input: Skill name, purpose, reference skills │
|
||||
│ ↓ │
|
||||
│ ┌─────────────────────────────────────────────────────────┐ │
|
||||
│ │ Phase 1-3: Lightweight Pipeline │ │
|
||||
│ │ ┌────┐ ┌────┐ ┌────┐ │ │
|
||||
│ │ │ P1 │→│ P2 │→│ P3 │ │ │
|
||||
│ │ │Styl│ │Req │ │Gen │ │ │
|
||||
│ │ └────┘ └────┘ └────┘ │ │
|
||||
│ └─────────────────────────────────────────────────────────┘ │
|
||||
│ ↓ │
|
||||
│ Output: .claude/skills/{skill-name}/ (minimal package) │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## 3-Phase Workflow
|
||||
|
||||
### Phase 1: Style Analysis & Learning
|
||||
|
||||
Analyze reference skills to extract language patterns, structural conventions, and writing style.
|
||||
|
||||
```javascript
|
||||
// Phase 1 Execution Flow
|
||||
async function analyzeStyle(referencePaths) {
|
||||
// Step 1: Load reference skills
|
||||
const references = [];
|
||||
for (const path of referencePaths) {
|
||||
const content = Read(path);
|
||||
references.push({
|
||||
path: path,
|
||||
content: content,
|
||||
metadata: extractYAMLFrontmatter(content)
|
||||
});
|
||||
}
|
||||
|
||||
// Step 2: Extract style patterns
|
||||
const styleProfile = {
|
||||
// Structural patterns
|
||||
structure: {
|
||||
hasFrontmatter: references.every(r => r.metadata !== null),
|
||||
sectionHeaders: extractCommonSections(references),
|
||||
codeBlockUsage: detectCodeBlockPatterns(references),
|
||||
flowDiagramUsage: detectFlowDiagrams(references)
|
||||
},
|
||||
|
||||
// Language patterns
|
||||
language: {
|
||||
instructionStyle: detectInstructionStyle(references), // 'imperative' | 'declarative' | 'procedural'
|
||||
pseudocodeUsage: detectPseudocodePatterns(references),
|
||||
verbosity: calculateVerbosityLevel(references), // 'concise' | 'detailed' | 'verbose'
|
||||
terminology: extractCommonTerms(references)
|
||||
},
|
||||
|
||||
// Organization patterns
|
||||
organization: {
|
||||
phaseStructure: detectPhasePattern(references), // 'sequential' | 'autonomous' | 'flat'
|
||||
exampleDensity: calculateExampleRatio(references),
|
||||
templateUsage: detectTemplateReferences(references)
|
||||
}
|
||||
};
|
||||
|
||||
// Step 3: Generate style guide
|
||||
return {
|
||||
profile: styleProfile,
|
||||
recommendations: generateStyleRecommendations(styleProfile),
|
||||
examples: extractStyleExamples(references, styleProfile)
|
||||
};
|
||||
}
|
||||
|
||||
// Structural pattern detection
|
||||
function extractCommonSections(references) {
|
||||
const allSections = references.map(r =>
|
||||
r.content.match(/^##? (.+)$/gm)?.map(s => s.replace(/^##? /, ''))
|
||||
).flat();
|
||||
return findMostCommon(allSections);
|
||||
}
|
||||
|
||||
// Language style detection
|
||||
function detectInstructionStyle(references) {
|
||||
const imperativePattern = /^(Use|Execute|Run|Call|Create|Generate)\s/gim;
|
||||
const declarativePattern = /^(The|This|Each|All)\s.*\s(is|are|will be)\s/gim;
|
||||
const proceduralPattern = /^(Step \d+|Phase \d+|First|Then|Finally)\s/gim;
|
||||
|
||||
const scores = references.map(r => ({
|
||||
imperative: (r.content.match(imperativePattern) || []).length,
|
||||
declarative: (r.content.match(declarativePattern) || []).length,
|
||||
procedural: (r.content.match(proceduralPattern) || []).length
|
||||
}));
|
||||
|
||||
return getMaxStyle(scores);
|
||||
}
|
||||
|
||||
// Pseudocode pattern detection
|
||||
function detectPseudocodePatterns(references) {
|
||||
const hasJavaScriptBlocks = references.some(r => r.content.includes('```javascript'));
|
||||
const hasFunctionDefs = references.some(r => /function\s+\w+\(/m.test(r.content));
|
||||
const hasFlowComments = references.some(r => /\/\/.*→/m.test(r.content));
|
||||
|
||||
return {
|
||||
usePseudocode: hasJavaScriptBlocks && hasFunctionDefs,
|
||||
flowAnnotations: hasFlowComments,
|
||||
style: hasFunctionDefs ? 'functional' : 'imperative'
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
Style Analysis Complete:
|
||||
Structure: Flow-based with pseudocode
|
||||
Language: Procedural, detailed
|
||||
Organization: Sequential phases
|
||||
Key Patterns: 3-5 phases, function definitions, ASCII diagrams
|
||||
|
||||
Recommendations:
|
||||
✓ Use phase-based structure (3-4 phases)
|
||||
✓ Include pseudocode for complex logic
|
||||
✓ Add ASCII flow diagrams
|
||||
✓ Maintain concise documentation style
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Requirements Gathering
|
||||
|
||||
Interactive discovery of skill requirements using learned style patterns.
|
||||
|
||||
```javascript
|
||||
async function gatherRequirements(styleProfile) {
|
||||
// Step 1: Basic information
|
||||
const basicInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "What is the skill name? (kebab-case, e.g., 'pdf-generator')",
|
||||
header: "Name",
|
||||
options: [
|
||||
{ label: "pdf-generator", description: "Example: PDF generation skill" },
|
||||
{ label: "code-analyzer", description: "Example: Code analysis skill" },
|
||||
{ label: "Custom", description: "Enter custom name" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "What is the primary purpose?",
|
||||
header: "Purpose",
|
||||
options: [
|
||||
{ label: "Generation", description: "Create/generate artifacts" },
|
||||
{ label: "Analysis", description: "Analyze/inspect code or data" },
|
||||
{ label: "Transformation", description: "Convert/transform content" },
|
||||
{ label: "Orchestration", description: "Coordinate multiple operations" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// Step 2: Execution complexity
|
||||
const complexity = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "How many main steps does this skill need?",
|
||||
header: "Steps",
|
||||
options: [
|
||||
{ label: "2-3 steps", description: "Simple workflow (recommended for lite-skill)" },
|
||||
{ label: "4-5 steps", description: "Moderate workflow" },
|
||||
{ label: "6+ steps", description: "Complex workflow (consider full skill-generator)" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Step 3: Tool requirements
|
||||
const tools = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Which tools will this skill use? (select multiple)",
|
||||
header: "Tools",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Read", description: "Read files" },
|
||||
{ label: "Write", description: "Write files" },
|
||||
{ label: "Bash", description: "Execute commands" },
|
||||
{ label: "Task", description: "Launch agents" },
|
||||
{ label: "AskUserQuestion", description: "Interactive prompts" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Step 4: Output format
|
||||
const output = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What does this skill produce?",
|
||||
header: "Output",
|
||||
options: [
|
||||
{ label: "Single file", description: "One main output file" },
|
||||
{ label: "Multiple files", description: "Several related files" },
|
||||
{ label: "Directory structure", description: "Complete directory tree" },
|
||||
{ label: "Modified files", description: "Edits to existing files" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Step 5: Build configuration
|
||||
return {
|
||||
name: basicInfo.Name,
|
||||
purpose: basicInfo.Purpose,
|
||||
description: generateDescription(basicInfo.Name, basicInfo.Purpose),
|
||||
steps: parseStepCount(complexity.Steps),
|
||||
allowedTools: tools.Tools,
|
||||
outputType: output.Output,
|
||||
styleProfile: styleProfile,
|
||||
triggerPhrases: generateTriggerPhrases(basicInfo.Name, basicInfo.Purpose)
|
||||
};
|
||||
}
|
||||
|
||||
// Generate skill description from name and purpose
|
||||
function generateDescription(name, purpose) {
|
||||
const templates = {
|
||||
Generation: `Generate ${humanize(name)} with intelligent scaffolding`,
|
||||
Analysis: `Analyze ${humanize(name)} with detailed reporting`,
|
||||
Transformation: `Transform ${humanize(name)} with format conversion`,
|
||||
Orchestration: `Orchestrate ${humanize(name)} workflow with multi-step coordination`
|
||||
};
|
||||
return templates[purpose] || `${humanize(name)} skill for ${purpose.toLowerCase()} tasks`;
|
||||
}
|
||||
|
||||
// Generate trigger phrases
|
||||
function generateTriggerPhrases(name, purpose) {
|
||||
const base = [name, name.replace(/-/g, ' ')];
|
||||
const purposeVariants = {
|
||||
Generation: ['generate', 'create', 'build'],
|
||||
Analysis: ['analyze', 'inspect', 'review'],
|
||||
Transformation: ['transform', 'convert', 'format'],
|
||||
Orchestration: ['orchestrate', 'coordinate', 'manage']
|
||||
};
|
||||
return [...base, ...purposeVariants[purpose].map(v => `${v} ${humanize(name)}`)];
|
||||
}
|
||||
```
|
||||
|
||||
**Display to User**:
|
||||
```
|
||||
Requirements Gathered:
|
||||
Name: pdf-generator
|
||||
Purpose: Generation
|
||||
Steps: 3 (Setup → Generate → Validate)
|
||||
Tools: Read, Write, Bash
|
||||
Output: Single file (PDF document)
|
||||
Triggers: "pdf-generator", "generate pdf", "create pdf"
|
||||
|
||||
Style Application:
|
||||
Using flow-based structure (from style analysis)
|
||||
Including pseudocode blocks
|
||||
Adding ASCII diagrams for clarity
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Generate Skill Package
|
||||
|
||||
Create minimal skill structure with style-aware content generation.
|
||||
|
||||
```javascript
|
||||
async function generateSkillPackage(requirements) {
|
||||
const skillDir = `.claude/skills/${requirements.name}`;
|
||||
const workDir = `.workflow/.scratchpad/lite-skill-gen-${Date.now()}`;
|
||||
|
||||
// Step 1: Create directory structure
|
||||
Bash(`mkdir -p "${skillDir}" "${workDir}"`);
|
||||
|
||||
// Step 2: Generate SKILL.md (using learned style)
|
||||
const skillContent = generateSkillMd(requirements);
|
||||
Write(`${skillDir}/SKILL.md`, skillContent);
|
||||
|
||||
// Step 3: Conditionally add bundled resources
|
||||
if (requirements.outputType === 'Directory structure') {
|
||||
Bash(`mkdir -p "${skillDir}/templates"`);
|
||||
const templateContent = generateTemplate(requirements);
|
||||
Write(`${skillDir}/templates/base-template.md`, templateContent);
|
||||
}
|
||||
|
||||
if (requirements.allowedTools.includes('Bash')) {
|
||||
Bash(`mkdir -p "${skillDir}/scripts"`);
|
||||
const scriptContent = generateScript(requirements);
|
||||
Write(`${skillDir}/scripts/helper.sh`, scriptContent);
|
||||
}
|
||||
|
||||
// Step 4: Generate README
|
||||
const readmeContent = generateReadme(requirements);
|
||||
Write(`${skillDir}/README.md`, readmeContent);
|
||||
|
||||
// Step 5: Validate structure
|
||||
const validation = validateSkillStructure(skillDir, requirements);
|
||||
Write(`${workDir}/validation-report.json`, JSON.stringify(validation, null, 2));
|
||||
|
||||
// Step 6: Return summary
|
||||
return {
|
||||
skillPath: skillDir,
|
||||
filesCreated: [
|
||||
`${skillDir}/SKILL.md`,
|
||||
...(validation.hasTemplates ? [`${skillDir}/templates/`] : []),
|
||||
...(validation.hasScripts ? [`${skillDir}/scripts/`] : []),
|
||||
`${skillDir}/README.md`
|
||||
],
|
||||
validation: validation,
|
||||
nextSteps: generateNextSteps(requirements)
|
||||
};
|
||||
}
|
||||
|
||||
// Generate SKILL.md with style awareness
|
||||
function generateSkillMd(req) {
|
||||
const { styleProfile } = req;
|
||||
|
||||
// YAML frontmatter
|
||||
const frontmatter = `---
|
||||
name: ${req.name}
|
||||
description: ${req.description}
|
||||
allowed-tools: ${req.allowedTools.join(', ')}
|
||||
---
|
||||
`;
|
||||
|
||||
// Main content structure (adapts to style)
|
||||
let content = frontmatter;
|
||||
|
||||
content += `\n# ${humanize(req.name)}\n\n`;
|
||||
content += `${req.description}\n\n`;
|
||||
|
||||
// Add architecture diagram if style uses them
|
||||
if (styleProfile.structure.flowDiagramUsage) {
|
||||
content += generateArchitectureDiagram(req);
|
||||
}
|
||||
|
||||
// Add execution flow
|
||||
content += `## Execution Flow\n\n`;
|
||||
if (styleProfile.language.pseudocodeUsage.usePseudocode) {
|
||||
content += generatePseudocodeFlow(req);
|
||||
} else {
|
||||
content += generateProceduralFlow(req);
|
||||
}
|
||||
|
||||
// Add phase sections
|
||||
for (let i = 0; i < req.steps; i++) {
|
||||
content += generatePhaseSection(i + 1, req, styleProfile);
|
||||
}
|
||||
|
||||
// Add examples if style is verbose
|
||||
if (styleProfile.language.verbosity !== 'concise') {
|
||||
content += generateExamplesSection(req);
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
// Generate architecture diagram
|
||||
function generateArchitectureDiagram(req) {
|
||||
return `## Architecture
|
||||
\`\`\`
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ ${humanize(req.name)} │
|
||||
│ │
|
||||
│ Input → Phase 1 → Phase 2 → Phase 3 → Output │
|
||||
│ ${getPhaseName(1, req)} │
|
||||
│ ${getPhaseName(2, req)} │
|
||||
│ ${getPhaseName(3, req)} │
|
||||
└─────────────────────────────────────────────────┘
|
||||
\`\`\`
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
// Generate pseudocode flow
|
||||
function generatePseudocodeFlow(req) {
|
||||
return `\`\`\`javascript
|
||||
async function ${toCamelCase(req.name)}(input) {
|
||||
// Phase 1: ${getPhaseName(1, req)}
|
||||
const prepared = await phase1Prepare(input);
|
||||
|
||||
// Phase 2: ${getPhaseName(2, req)}
|
||||
const processed = await phase2Process(prepared);
|
||||
|
||||
// Phase 3: ${getPhaseName(3, req)}
|
||||
const result = await phase3Finalize(processed);
|
||||
|
||||
return result;
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
// Generate phase section
|
||||
function generatePhaseSection(phaseNum, req, styleProfile) {
|
||||
const phaseName = getPhaseName(phaseNum, req);
|
||||
|
||||
let section = `### Phase ${phaseNum}: ${phaseName}\n\n`;
|
||||
|
||||
if (styleProfile.language.pseudocodeUsage.usePseudocode) {
|
||||
section += `\`\`\`javascript\n`;
|
||||
section += `async function phase${phaseNum}${toCamelCase(phaseName)}(input) {\n`;
|
||||
section += ` // TODO: Implement ${phaseName.toLowerCase()} logic\n`;
|
||||
section += ` return output;\n`;
|
||||
section += `}\n\`\`\`\n\n`;
|
||||
} else {
|
||||
section += `**Steps**:\n`;
|
||||
section += `1. Load input data\n`;
|
||||
section += `2. Process according to ${phaseName.toLowerCase()} logic\n`;
|
||||
section += `3. Return result to next phase\n\n`;
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
// Validation
|
||||
function validateSkillStructure(skillDir, req) {
|
||||
const requiredFiles = [`${skillDir}/SKILL.md`, `${skillDir}/README.md`];
|
||||
const exists = requiredFiles.map(f => Bash(`test -f "${f}"`).exitCode === 0);
|
||||
|
||||
return {
|
||||
valid: exists.every(e => e),
|
||||
hasTemplates: Bash(`test -d "${skillDir}/templates"`).exitCode === 0,
|
||||
hasScripts: Bash(`test -d "${skillDir}/scripts"`).exitCode === 0,
|
||||
filesPresent: requiredFiles.filter((f, i) => exists[i]),
|
||||
styleCompliance: checkStyleCompliance(skillDir, req.styleProfile)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
Skill Package Generated:
|
||||
Location: .claude/skills/pdf-generator/
|
||||
|
||||
Structure:
|
||||
✓ SKILL.md (entry point)
|
||||
✓ README.md (usage guide)
|
||||
✓ templates/ (directory templates)
|
||||
✓ scripts/ (helper scripts)
|
||||
|
||||
Validation:
|
||||
✓ All required files present
|
||||
✓ Style compliance: 95%
|
||||
✓ Frontmatter valid
|
||||
✓ Tool references correct
|
||||
|
||||
Next Steps:
|
||||
1. Review SKILL.md and customize phases
|
||||
2. Test skill: /skill:pdf-generator "test input"
|
||||
3. Iterate based on usage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Execution Flow
|
||||
|
||||
```
|
||||
User: "Create a PDF generator skill"
|
||||
↓
|
||||
Phase 1: Style Analysis
|
||||
|-- Read reference skills (ccw.md, ccw-coordinator.md)
|
||||
|-- Extract style patterns (flow diagrams, pseudocode, structure)
|
||||
|-- Generate style profile
|
||||
+-- Output: Style recommendations
|
||||
↓
|
||||
Phase 2: Requirements
|
||||
|-- Ask: Name, purpose, steps
|
||||
|-- Ask: Tools, output format
|
||||
|-- Generate: Description, triggers
|
||||
+-- Output: Requirements config
|
||||
↓
|
||||
Phase 3: Generation
|
||||
|-- Create: Directory structure
|
||||
|-- Write: SKILL.md (style-aware)
|
||||
|-- Write: README.md
|
||||
|-- Optionally: templates/, scripts/
|
||||
|-- Validate: Structure and style
|
||||
+-- Output: Skill package
|
||||
↓
|
||||
Return: Skill location + next steps
|
||||
```
|
||||
|
||||
## Phase Execution Protocol
|
||||
|
||||
```javascript
|
||||
// Main entry point
|
||||
async function liteSkillGenerator(input) {
|
||||
// Phase 1: Style Learning
|
||||
const references = [
|
||||
'.claude/commands/ccw.md',
|
||||
'.claude/commands/ccw-coordinator.md',
|
||||
...discoverReferenceSkills(input)
|
||||
];
|
||||
const styleProfile = await analyzeStyle(references);
|
||||
console.log(`Style Analysis: ${styleProfile.organization.phaseStructure}, ${styleProfile.language.verbosity}`);
|
||||
|
||||
// Phase 2: Requirements
|
||||
const requirements = await gatherRequirements(styleProfile);
|
||||
console.log(`Requirements: ${requirements.name} (${requirements.steps} phases)`);
|
||||
|
||||
// Phase 3: Generation
|
||||
const result = await generateSkillPackage(requirements);
|
||||
console.log(`✅ Generated: ${result.skillPath}`);
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
**Minimal Package** (default):
|
||||
```
|
||||
.claude/skills/{skill-name}/
|
||||
├── SKILL.md # Entry point with frontmatter
|
||||
└── README.md # Usage guide
|
||||
```
|
||||
|
||||
**With Templates** (if needed):
|
||||
```
|
||||
.claude/skills/{skill-name}/
|
||||
├── SKILL.md
|
||||
├── README.md
|
||||
└── templates/
|
||||
└── base-template.md
|
||||
```
|
||||
|
||||
**With Scripts** (if using Bash):
|
||||
```
|
||||
.claude/skills/{skill-name}/
|
||||
├── SKILL.md
|
||||
├── README.md
|
||||
└── scripts/
|
||||
└── helper.sh
|
||||
```
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Style Learning** - Analyze reference skills to maintain consistency
|
||||
2. **Minimal Overhead** - Generate only essential files (SKILL.md + README)
|
||||
3. **Progressive Disclosure** - Follow anthropics' three-layer loading
|
||||
4. **Flow-Based** - Use pseudocode and flow diagrams (when style appropriate)
|
||||
5. **Interactive** - Guided requirements gathering via AskUserQuestion
|
||||
6. **Fast Generation** - 3 phases instead of 6, focused on simplicity
|
||||
7. **Style Awareness** - Adapt output based on detected patterns
|
||||
|
||||
## Style Pattern Detection
|
||||
|
||||
**Structural Patterns**:
|
||||
- YAML frontmatter usage (100% in references)
|
||||
- Section headers (H2 for major, H3 for sub-sections)
|
||||
- Code blocks (JavaScript pseudocode, Bash examples)
|
||||
- ASCII diagrams (architecture, flow charts)
|
||||
|
||||
**Language Patterns**:
|
||||
- Instruction style: Procedural with function definitions
|
||||
- Pseudocode: JavaScript-based with flow annotations
|
||||
- Verbosity: Detailed but focused
|
||||
- Terminology: Phase, workflow, pipeline, orchestrator
|
||||
|
||||
**Organization Patterns**:
|
||||
- Phase structure: 3-5 sequential phases
|
||||
- Example density: Moderate (1-2 per major section)
|
||||
- Template usage: Minimal (only when necessary)
|
||||
|
||||
## Usage Examples
|
||||
|
||||
**Basic Generation**:
|
||||
```
|
||||
User: "Create a markdown formatter skill"
|
||||
Lite-Skill-Generator:
|
||||
→ Analyzes ccw.md style
|
||||
→ Asks: Name? "markdown-formatter"
|
||||
→ Asks: Purpose? "Transformation"
|
||||
→ Asks: Steps? "3 steps"
|
||||
→ Generates: .claude/skills/markdown-formatter/
|
||||
```
|
||||
|
||||
**With Custom References**:
|
||||
```
|
||||
User: "Create a skill like software-manual but simpler"
|
||||
Lite-Skill-Generator:
|
||||
→ Analyzes software-manual skill
|
||||
→ Learns: Multi-phase, agent-based, template-heavy
|
||||
→ Simplifies: 3 phases, direct execution, minimal templates
|
||||
→ Generates: Simplified version
|
||||
```
|
||||
|
||||
## Comparison: lite-skill-generator vs skill-generator
|
||||
|
||||
| Aspect | lite-skill-generator | skill-generator |
|
||||
|--------|---------------------|-----------------|
|
||||
| **Phases** | 3 (Style → Req → Gen) | 6 (Spec → Req → Dir → Gen → Specs → Val) |
|
||||
| **Style Learning** | Yes (analyze references) | No (fixed templates) |
|
||||
| **Complexity** | Simple skills only | Full-featured skills |
|
||||
| **Output** | Minimal (SKILL.md + README) | Complete (phases/, specs/, templates/) |
|
||||
| **Generation Time** | Fast (~2 min) | Thorough (~10 min) |
|
||||
| **Use Case** | Quick scaffolding | Production-ready skills |
|
||||
|
||||
## Workflow Integration
|
||||
|
||||
**Standalone**:
|
||||
```bash
|
||||
/skill:lite-skill-generator "Create a log analyzer skill"
|
||||
```
|
||||
|
||||
**With References**:
|
||||
```bash
|
||||
/skill:lite-skill-generator "Create a skill based on ccw-coordinator.md style"
|
||||
```
|
||||
|
||||
**Batch Generation** (for multiple simple skills):
|
||||
```bash
|
||||
/skill:lite-skill-generator "Create 3 skills: json-validator, yaml-parser, toml-converter"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Next Steps After Generation**:
|
||||
1. Review `.claude/skills/{name}/SKILL.md`
|
||||
2. Customize phase logic for your use case
|
||||
3. Add examples to README.md
|
||||
4. Test skill with sample input
|
||||
5. Iterate based on real usage
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
name: {{SKILL_NAME}}
|
||||
description: {{SKILL_DESCRIPTION}}
|
||||
allowed-tools: {{ALLOWED_TOOLS}}
|
||||
---
|
||||
|
||||
# {{SKILL_TITLE}}
|
||||
|
||||
{{SKILL_DESCRIPTION}}
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ {{SKILL_TITLE}} │
|
||||
│ │
|
||||
│ Input → {{PHASE_1}} → {{PHASE_2}} → Output │
|
||||
└─────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```javascript
|
||||
async function {{SKILL_FUNCTION}}(input) {
|
||||
// Phase 1: {{PHASE_1}}
|
||||
const prepared = await phase1(input);
|
||||
|
||||
// Phase 2: {{PHASE_2}}
|
||||
const result = await phase2(prepared);
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 1: {{PHASE_1}}
|
||||
|
||||
```javascript
|
||||
async function phase1(input) {
|
||||
// TODO: Implement {{PHASE_1_LOWER}} logic
|
||||
return output;
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 2: {{PHASE_2}}
|
||||
|
||||
```javascript
|
||||
async function phase2(input) {
|
||||
// TODO: Implement {{PHASE_2_LOWER}} logic
|
||||
return output;
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/skill:{{SKILL_NAME}} "input description"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
**Basic Usage**:
|
||||
```
|
||||
User: "{{EXAMPLE_INPUT}}"
|
||||
{{SKILL_NAME}}:
|
||||
→ Phase 1: {{PHASE_1_ACTION}}
|
||||
→ Phase 2: {{PHASE_2_ACTION}}
|
||||
→ Output: {{EXAMPLE_OUTPUT}}
|
||||
```
|
||||
64
.claude/skills/lite-skill-generator/templates/style-guide.md
Normal file
64
.claude/skills/lite-skill-generator/templates/style-guide.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Style Guide Template
|
||||
|
||||
Generated by lite-skill-generator style analysis phase.
|
||||
|
||||
## Detected Patterns
|
||||
|
||||
### Structural Patterns
|
||||
|
||||
| Pattern | Detected | Recommendation |
|
||||
|---------|----------|----------------|
|
||||
| YAML Frontmatter | {{HAS_FRONTMATTER}} | {{FRONTMATTER_REC}} |
|
||||
| ASCII Diagrams | {{HAS_DIAGRAMS}} | {{DIAGRAMS_REC}} |
|
||||
| Code Blocks | {{HAS_CODE_BLOCKS}} | {{CODE_BLOCKS_REC}} |
|
||||
| Phase Structure | {{PHASE_STRUCTURE}} | {{PHASE_REC}} |
|
||||
|
||||
### Language Patterns
|
||||
|
||||
| Pattern | Value | Notes |
|
||||
|---------|-------|-------|
|
||||
| Instruction Style | {{INSTRUCTION_STYLE}} | imperative/declarative/procedural |
|
||||
| Pseudocode Usage | {{PSEUDOCODE_USAGE}} | functional/imperative/none |
|
||||
| Verbosity Level | {{VERBOSITY}} | concise/detailed/verbose |
|
||||
| Common Terms | {{TERMINOLOGY}} | domain-specific vocabulary |
|
||||
|
||||
### Organization Patterns
|
||||
|
||||
| Pattern | Value |
|
||||
|---------|-------|
|
||||
| Phase Count | {{PHASE_COUNT}} |
|
||||
| Example Density | {{EXAMPLE_DENSITY}} |
|
||||
| Template Usage | {{TEMPLATE_USAGE}} |
|
||||
|
||||
## Style Compliance Checklist
|
||||
|
||||
- [ ] YAML frontmatter with name, description, allowed-tools
|
||||
- [ ] Architecture diagram (if pattern detected)
|
||||
- [ ] Execution flow section with pseudocode
|
||||
- [ ] Phase sections (sequential numbered)
|
||||
- [ ] Usage examples section
|
||||
- [ ] README.md for external documentation
|
||||
|
||||
## Reference Skills Analyzed
|
||||
|
||||
{{#REFERENCES}}
|
||||
- `{{REF_PATH}}`: {{REF_NOTES}}
|
||||
{{/REFERENCES}}
|
||||
|
||||
## Generated Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"style": {
|
||||
"structure": "{{STRUCTURE_TYPE}}",
|
||||
"language": "{{LANGUAGE_TYPE}}",
|
||||
"organization": "{{ORG_TYPE}}"
|
||||
},
|
||||
"recommendations": {
|
||||
"usePseudocode": {{USE_PSEUDOCODE}},
|
||||
"includeDiagrams": {{INCLUDE_DIAGRAMS}},
|
||||
"verbosityLevel": "{{VERBOSITY}}",
|
||||
"phaseCount": {{PHASE_COUNT}}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: skill-generator
|
||||
description: Meta-skill for creating new Claude Code skills with configurable execution modes. Supports sequential (fixed order) and autonomous (stateless) phase patterns. Use for skill scaffolding, skill creation, or building new workflows. Triggers on "create skill", "new skill", "skill generator", "生成技能", "创建技能".
|
||||
description: Meta-skill for creating new Claude Code skills with configurable execution modes. Supports sequential (fixed order) and autonomous (stateless) phase patterns. Use for skill scaffolding, skill creation, or building new workflows. Triggers on "create skill", "new skill", "skill generator".
|
||||
allowed-tools: Task, AskUserQuestion, Read, Bash, Glob, Grep, Write
|
||||
---
|
||||
|
||||
@@ -12,215 +12,454 @@ Meta-skill for creating new Claude Code skills with configurable execution modes
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Skill Generator Architecture │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Skill Generator │
|
||||
│ │
|
||||
│ ⚠️ Phase 0: Specification → 阅读并理解设计规范 (强制前置) │
|
||||
│ Study SKILL-DESIGN-SPEC.md + 模板 │
|
||||
│ ↓ │
|
||||
│ Phase 1: Requirements → skill-config.json │
|
||||
│ Discovery (name, type, mode, agents) │
|
||||
│ ↓ │
|
||||
│ Phase 2: Structure → 目录结构 + 核心文件骨架 │
|
||||
│ Generation │
|
||||
│ ↓ │
|
||||
│ Phase 3: Phase → phases/*.md (根据 mode 生成) │
|
||||
│ Generation Sequential | Autonomous │
|
||||
│ ↓ │
|
||||
│ Phase 4: Specs & → specs/*.md + templates/*.md │
|
||||
│ Templates │
|
||||
│ ↓ │
|
||||
│ Phase 5: Validation → 验证完整性 + 生成使用说明 │
|
||||
│ & Documentation │
|
||||
│ Input: User Request (skill name, purpose, mode) │
|
||||
│ ↓ │
|
||||
│ ┌─────────────────────────────────────────────────────────┐ │
|
||||
│ │ Phase 0-5: Sequential Pipeline │ │
|
||||
│ │ ┌────┐ ┌────┐ ┌────┐ ┌────┐ ┌────┐ ┌────┐ │ │
|
||||
│ │ │ P0 │→│ P1 │→│ P2 │→│ P3 │→│ P4 │→│ P5 │ │ │
|
||||
│ │ │Spec│ │Req │ │Dir │ │Gen │ │Spec│ │Val │ │ │
|
||||
│ │ └────┘ └────┘ └────┘ └─┬──┘ └────┘ └────┘ │ │
|
||||
│ │ │ │ │
|
||||
│ │ ┌────┴────┐ │ │
|
||||
│ │ ↓ ↓ │ │
|
||||
│ │ Sequential Autonomous │ │
|
||||
│ │ (phases/) (actions/) │ │
|
||||
│ └─────────────────────────────────────────────────────────┘ │
|
||||
│ ↓ │
|
||||
│ Output: .claude/skills/{skill-name}/ (complete package) │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Execution Modes
|
||||
|
||||
### Mode 1: Sequential (固定顺序)
|
||||
### Mode 1: Sequential (Fixed Order)
|
||||
|
||||
传统线性执行模式,阶段按数字前缀顺序执行。
|
||||
Traditional linear execution model, phases execute in numeric prefix order.
|
||||
|
||||
```
|
||||
Phase 01 → Phase 02 → Phase 03 → ... → Phase N
|
||||
Phase 01 -> Phase 02 -> Phase 03 -> ... -> Phase N
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 流水线式任务(收集 → 分析 → 生成)
|
||||
- 阶段间有强依赖关系
|
||||
- 输出结构固定
|
||||
**Use Cases**:
|
||||
- Pipeline tasks (collect -> analyze -> generate)
|
||||
- Strong dependencies between phases
|
||||
- Fixed output structure
|
||||
|
||||
**示例**: `software-manual`, `copyright-docs`
|
||||
**Examples**: `software-manual`, `copyright-docs`
|
||||
|
||||
### Mode 2: Autonomous (无状态自主选择)
|
||||
### Mode 2: Autonomous (Stateless Auto-Select)
|
||||
|
||||
智能路由模式,根据上下文动态选择执行路径。
|
||||
Intelligent routing model, dynamically selects execution path based on context.
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────┐
|
||||
│ Orchestrator Agent │
|
||||
│ (读取状态 → 选择 Phase → 执行 → 更新) │
|
||||
└───────────────┬─────────────────────────┘
|
||||
│
|
||||
┌───────────┼───────────┐
|
||||
↓ ↓ ↓
|
||||
┌───────┐ ┌───────┐ ┌───────┐
|
||||
│Phase A│ │Phase B│ │Phase C│
|
||||
│(独立) │ │(独立) │ │(独立) │
|
||||
└───────┘ └───────┘ └───────┘
|
||||
---------------------------------------------------
|
||||
Orchestrator Agent
|
||||
(Read state -> Select Phase -> Execute -> Update)
|
||||
---------------------------------------------------
|
||||
|
|
||||
---------+----------+----------
|
||||
| | |
|
||||
Phase A Phase B Phase C
|
||||
(standalone) (standalone) (standalone)
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 交互式任务(对话、问答)
|
||||
- 阶段间无强依赖
|
||||
- 需要动态响应用户意图
|
||||
**Use Cases**:
|
||||
- Interactive tasks (chat, Q&A)
|
||||
- No strong dependencies between phases
|
||||
- Dynamic user intent response required
|
||||
|
||||
**示例**: `issue-manage`, `workflow-debug`
|
||||
**Examples**: `issue-manage`, `workflow-debug`
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **模式感知**: 根据任务特性自动推荐执行模式
|
||||
2. **骨架生成**: 生成完整目录结构和文件骨架
|
||||
3. **规范遵循**: 严格遵循 `_shared/SKILL-DESIGN-SPEC.md`
|
||||
4. **可扩展性**: 生成的 Skill 易于扩展和修改
|
||||
1. **Mode Awareness**: Automatically recommend execution mode based on task characteristics
|
||||
2. **Skeleton Generation**: Generate complete directory structure and file skeletons
|
||||
3. **Standards Compliance**: Strictly follow `_shared/SKILL-DESIGN-SPEC.md`
|
||||
4. **Extensibility**: Generated Skills are easy to extend and modify
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Mandatory Prerequisites (强制前置条件)
|
||||
## Required Prerequisites
|
||||
|
||||
> **⛔ 禁止跳过**: 在执行任何生成操作之前,**必须**完整阅读以下文档。未阅读规范直接生成将导致输出不符合质量标准。
|
||||
IMPORTANT: Before any generation operation, read the following specification documents. Generating without understanding these standards will result in non-conforming output.
|
||||
|
||||
### 核心规范 (必读)
|
||||
### Core Specifications (Mandatory Read)
|
||||
|
||||
| Document | Purpose | Priority |
|
||||
|----------|---------|----------|
|
||||
| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | 通用设计规范 - 定义所有 Skill 的结构、命名、质量标准 | **P0 - 最高** |
|
||||
| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal design spec - defines structure, naming, quality standards for all Skills | **P0 - Critical** |
|
||||
| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation spec - ensures generated Skills have proper phase-based Reference Documents with usage timing guidance | **P0 - Critical** |
|
||||
|
||||
### 模板文件 (生成前必读)
|
||||
### Template Files (Read Before Generation)
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [templates/skill-md.md](templates/skill-md.md) | SKILL.md 入口文件模板 |
|
||||
| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase 模板 |
|
||||
| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Autonomous 编排器模板 |
|
||||
| [templates/autonomous-action.md](templates/autonomous-action.md) | Autonomous Action 模板 |
|
||||
| [templates/code-analysis-action.md](templates/code-analysis-action.md) | 代码分析 Action 模板 |
|
||||
| [templates/llm-action.md](templates/llm-action.md) | LLM Action 模板 |
|
||||
| [templates/script-bash.md](templates/script-bash.md) | Bash 脚本模板 |
|
||||
| [templates/script-python.md](templates/script-python.md) | Python 脚本模板 |
|
||||
| [templates/skill-md.md](templates/skill-md.md) | SKILL.md entry file template |
|
||||
| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template |
|
||||
| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Autonomous Orchestrator template |
|
||||
| [templates/autonomous-action.md](templates/autonomous-action.md) | Autonomous Action template |
|
||||
| [templates/code-analysis-action.md](templates/code-analysis-action.md) | Code Analysis Action template |
|
||||
| [templates/llm-action.md](templates/llm-action.md) | LLM Action template |
|
||||
| [templates/script-template.md](templates/script-template.md) | Unified Script Template (Bash + Python) |
|
||||
|
||||
### 规范文档 (按需阅读)
|
||||
### Specification Documents (Read as Needed)
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [specs/execution-modes.md](specs/execution-modes.md) | 执行模式规范 |
|
||||
| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill 需求规范 |
|
||||
| [specs/cli-integration.md](specs/cli-integration.md) | CLI 集成规范 |
|
||||
| [specs/scripting-integration.md](specs/scripting-integration.md) | 脚本集成规范 |
|
||||
| [specs/execution-modes.md](specs/execution-modes.md) | Execution Modes Specification |
|
||||
| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill Requirements Specification |
|
||||
| [specs/cli-integration.md](specs/cli-integration.md) | CLI Integration Specification |
|
||||
| [specs/scripting-integration.md](specs/scripting-integration.md) | Script Integration Specification |
|
||||
|
||||
### Phase 执行指南 (执行时参考)
|
||||
### Phase Execution Guides (Reference During Execution)
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | 收集 Skill 需求 |
|
||||
| [phases/02-structure-generation.md](phases/02-structure-generation.md) | 生成目录结构 |
|
||||
| [phases/03-phase-generation.md](phases/03-phase-generation.md) | 生成 Phase 文件 |
|
||||
| [phases/04-specs-templates.md](phases/04-specs-templates.md) | 生成规范和模板 |
|
||||
| [phases/05-validation.md](phases/05-validation.md) | 验证和文档 |
|
||||
| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Collect Skill Requirements |
|
||||
| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Generate Directory Structure |
|
||||
| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Generate Phase Files |
|
||||
| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Generate Specs and Templates |
|
||||
| [phases/05-validation.md](phases/05-validation.md) | Validation and Documentation |
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ ⚠️ Phase 0: Specification Study (强制前置 - 禁止跳过) │
|
||||
│ → Read: ../_shared/SKILL-DESIGN-SPEC.md (通用设计规范) │
|
||||
│ → Read: templates/*.md (所有相关模板文件) │
|
||||
│ → 理解: Skill 结构规范、命名约定、质量标准 │
|
||||
│ → Output: 内化规范要求,确保后续生成符合标准 │
|
||||
│ ⛔ 未完成 Phase 0 禁止进入 Phase 1 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 1: Requirements Discovery │
|
||||
│ → AskUserQuestion: Skill 名称、目标、执行模式 │
|
||||
│ → Output: skill-config.json │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 2: Structure Generation │
|
||||
│ → 创建目录结构: phases/, specs/, templates/, scripts/ │
|
||||
│ → 生成 SKILL.md 入口文件 │
|
||||
│ → Output: 完整目录结构 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 3: Phase Generation │
|
||||
│ → Sequential: 生成 01-xx.md, 02-xx.md, ... │
|
||||
│ → Autonomous: 生成 orchestrator.md + actions/*.md │
|
||||
│ → Output: phases/*.md │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 4: Specs & Templates │
|
||||
│ → 生成领域规范: specs/{domain}-requirements.md │
|
||||
│ → 生成质量标准: specs/quality-standards.md │
|
||||
│ → 生成模板: templates/agent-base.md │
|
||||
│ → Output: specs/*.md, templates/*.md │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Phase 5: Validation & Documentation │
|
||||
│ → 验证文件完整性 │
|
||||
│ → 生成 README.md 使用说明 │
|
||||
│ → Output: 验证报告 + README.md │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
Input Parsing:
|
||||
└─ Convert user request to structured format (skill-name/purpose/mode)
|
||||
|
||||
Phase 0: Specification Study (MANDATORY - Must complete before proceeding)
|
||||
- Read specification documents
|
||||
- Load: ../_shared/SKILL-DESIGN-SPEC.md
|
||||
- Load: All templates/*.md files
|
||||
- Understand: Structure rules, naming conventions, quality standards
|
||||
- Output: Internalized requirements (in-memory, no file output)
|
||||
- Validation: MUST complete before Phase 1
|
||||
|
||||
Phase 1: Requirements Discovery
|
||||
- Gather skill requirements via user interaction
|
||||
- Tool: AskUserQuestion
|
||||
- Collect: Skill name, purpose, execution mode
|
||||
- Collect: Phase/Action definition
|
||||
- Collect: Tool dependencies, output format
|
||||
- Process: Generate configuration object
|
||||
- Output: skill-config.json
|
||||
- Contains: skill_name, execution_mode, phases/actions, allowed_tools
|
||||
|
||||
Phase 2: Structure Generation
|
||||
- Create directory structure and entry file
|
||||
- Input: skill-config.json (from Phase 1)
|
||||
- Tool: Bash
|
||||
- Execute: mkdir -p .claude/skills/{skill-name}/{phases,specs,templates,scripts}
|
||||
- Tool: Write
|
||||
- Generate: SKILL.md (entry point with architecture diagram)
|
||||
- Output: Complete directory structure
|
||||
|
||||
Phase 3: Phase/Action Generation
|
||||
- Decision (execution_mode check):
|
||||
- IF execution_mode === "sequential": Generate Sequential Phases
|
||||
- Read template: templates/sequential-phase.md
|
||||
- Loop: For each phase in config.sequential_config.phases
|
||||
- Generate: phases/{phase-id}.md
|
||||
- Link: Previous phase output -> Current phase input
|
||||
- Write: phases/_orchestrator.md
|
||||
- Write: workflow.json
|
||||
- Output: phases/01-{name}.md, phases/02-{name}.md, ...
|
||||
|
||||
- ELSE IF execution_mode === "autonomous": Generate Orchestrator + Actions
|
||||
- Read template: templates/autonomous-orchestrator.md
|
||||
- Write: phases/state-schema.md
|
||||
- Write: phases/orchestrator.md
|
||||
- Write: specs/action-catalog.md
|
||||
- Loop: For each action in config.autonomous_config.actions
|
||||
- Read template: templates/autonomous-action.md
|
||||
- Generate: phases/actions/{action-id}.md
|
||||
- Output: phases/orchestrator.md, phases/actions/*.md
|
||||
|
||||
Phase 4: Specs & Templates
|
||||
- Generate domain specifications and templates
|
||||
- Input: skill-config.json (domain context)
|
||||
- Reference: [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for document organization
|
||||
- Tool: Write
|
||||
- Generate: specs/{domain}-requirements.md
|
||||
- Generate: specs/quality-standards.md
|
||||
- Generate: templates/agent-base.md (if needed)
|
||||
- Output: Domain-specific documentation
|
||||
|
||||
Phase 5: Validation & Documentation
|
||||
- Verify completeness and generate usage guide
|
||||
- Input: All generated files from previous phases
|
||||
- Tool: Glob + Read
|
||||
- Check: Required files exist and contain proper structure
|
||||
- Tool: Write
|
||||
- Generate: README.md (usage instructions)
|
||||
- Generate: validation-report.json (completeness check)
|
||||
- Output: Final documentation
|
||||
```
|
||||
|
||||
## Directory Setup
|
||||
**Execution Protocol**:
|
||||
|
||||
```javascript
|
||||
const skillName = config.skill_name;
|
||||
const skillDir = `.claude/skills/${skillName}`;
|
||||
// Phase 0: Read specifications (in-memory)
|
||||
Read('.claude/skills/_shared/SKILL-DESIGN-SPEC.md');
|
||||
Read('.claude/skills/skill-generator/templates/*.md'); // All templates
|
||||
|
||||
// 创建目录结构
|
||||
Bash(`mkdir -p "${skillDir}/phases"`);
|
||||
Bash(`mkdir -p "${skillDir}/specs"`);
|
||||
Bash(`mkdir -p "${skillDir}/templates"`);
|
||||
// Phase 1: Gather requirements
|
||||
const answers = AskUserQuestion({
|
||||
questions: [
|
||||
{ question: "Skill name?", header: "Name", options: [...] },
|
||||
{ question: "Execution mode?", header: "Mode", options: ["Sequential", "Autonomous"] }
|
||||
]
|
||||
});
|
||||
|
||||
// Autonomous 模式额外目录
|
||||
if (config.execution_mode === 'autonomous') {
|
||||
Bash(`mkdir -p "${skillDir}/phases/actions"`);
|
||||
const config = generateConfig(answers);
|
||||
const workDir = `.workflow/.scratchpad/skill-gen-${timestamp}`;
|
||||
Write(`${workDir}/skill-config.json`, JSON.stringify(config));
|
||||
|
||||
// Phase 2: Create structure
|
||||
const skillDir = `.claude/skills/${config.skill_name}`;
|
||||
Bash(`mkdir -p "${skillDir}/phases" "${skillDir}/specs" "${skillDir}/templates"`);
|
||||
Write(`${skillDir}/SKILL.md`, generateSkillEntry(config));
|
||||
|
||||
// Phase 3: Generate phases (mode-dependent)
|
||||
if (config.execution_mode === 'sequential') {
|
||||
Write(`${skillDir}/phases/_orchestrator.md`, generateOrchestrator(config));
|
||||
Write(`${skillDir}/workflow.json`, generateWorkflowDef(config));
|
||||
config.sequential_config.phases.forEach(phase => {
|
||||
Write(`${skillDir}/phases/${phase.id}.md`, generatePhase(phase, config));
|
||||
});
|
||||
} else {
|
||||
Write(`${skillDir}/phases/orchestrator.md`, generateAutonomousOrchestrator(config));
|
||||
Write(`${skillDir}/phases/state-schema.md`, generateStateSchema(config));
|
||||
config.autonomous_config.actions.forEach(action => {
|
||||
Write(`${skillDir}/phases/actions/${action.id}.md`, generateAction(action, config));
|
||||
});
|
||||
}
|
||||
|
||||
// Phase 4: Generate specs
|
||||
Write(`${skillDir}/specs/${config.skill_name}-requirements.md`, generateRequirements(config));
|
||||
Write(`${skillDir}/specs/quality-standards.md`, generateQualityStandards(config));
|
||||
|
||||
|
||||
// Phase 5: Validate & Document
|
||||
const validation = validateStructure(skillDir);
|
||||
Write(`${skillDir}/validation-report.json`, JSON.stringify(validation));
|
||||
Write(`${skillDir}/README.md`, generateReadme(config, validation));
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Reference Documents by Phase
|
||||
|
||||
IMPORTANT: This section demonstrates how skill-generator organizes its own reference documentation. This is the pattern that all generated Skills should emulate. See [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for details.
|
||||
|
||||
### Phase 0: Specification Study (Mandatory Prerequisites)
|
||||
|
||||
Specification documents that must be read before any generation operation
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal Skill design specification | Understand Skill structure and naming conventions - **REQUIRED** |
|
||||
| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation specification | Ensure Reference Documents have proper phase-based organization - **REQUIRED** |
|
||||
|
||||
### Phase 1: Requirements Discovery
|
||||
|
||||
Collect Skill requirements and configuration
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1 execution guide | Understand how to collect user requirements and generate configuration |
|
||||
| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill requirements specification | Understand what information a Skill should contain |
|
||||
|
||||
### Phase 2: Structure Generation
|
||||
|
||||
Generate directory structure and entry file
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2 execution guide | Understand how to generate directory structure |
|
||||
| [templates/skill-md.md](templates/skill-md.md) | SKILL.md template | Learn how to generate the entry file |
|
||||
|
||||
### Phase 3: Phase/Action Generation
|
||||
|
||||
Generate specific phase or action files based on execution mode
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3 execution guide | Understand Sequential vs Autonomous generation logic |
|
||||
| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template | Generate phase files for Sequential mode |
|
||||
| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator template | Generate orchestrator for Autonomous mode |
|
||||
| [templates/autonomous-action.md](templates/autonomous-action.md) | Action template | Generate action files for Autonomous mode |
|
||||
|
||||
### Phase 4: Specs & Templates
|
||||
|
||||
Generate domain-specific specifications and templates
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4 execution guide | Understand how to generate domain-specific documentation |
|
||||
| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document specification | IMPORTANT: Follow this spec when generating Specs |
|
||||
|
||||
### Phase 5: Validation & Documentation
|
||||
|
||||
Verify results and generate final documentation
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/05-validation.md](phases/05-validation.md) | Phase 5 execution guide | Understand how to verify generated Skill completeness |
|
||||
|
||||
### Debugging & Troubleshooting
|
||||
|
||||
Reference documents when encountering issues
|
||||
|
||||
| Issue | Solution Document |
|
||||
|-------|------------------|
|
||||
| Generated Skill missing Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - verify phase-based organization is followed |
|
||||
| Reference document organization unclear | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - Core Principles section |
|
||||
| Generated documentation does not meet quality standards | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) |
|
||||
|
||||
### Reference & Background
|
||||
|
||||
Documents for deep learning and design decisions
|
||||
|
||||
| Document | Purpose | Notes |
|
||||
|----------|---------|-------|
|
||||
| [specs/execution-modes.md](specs/execution-modes.md) | Detailed execution modes specification | Comparison and use cases for Sequential vs Autonomous |
|
||||
| [specs/cli-integration.md](specs/cli-integration.md) | CLI integration specification | How generated Skills integrate with CLI |
|
||||
| [specs/scripting-integration.md](specs/scripting-integration.md) | Script integration specification | How to use scripts in Phases |
|
||||
| [templates/script-template.md](templates/script-template.md) | Script template | Unified Bash + Python template |
|
||||
|
||||
---
|
||||
|
||||
## Output Structure
|
||||
|
||||
### Sequential Mode
|
||||
|
||||
```
|
||||
.claude/skills/{skill-name}/
|
||||
├── SKILL.md
|
||||
├── SKILL.md # Entry file
|
||||
├── phases/
|
||||
│ ├── 01-{step-one}.md
|
||||
│ ├── 02-{step-two}.md
|
||||
│ └── 03-{step-three}.md
|
||||
│ ├── _orchestrator.md # Declarative orchestrator
|
||||
│ ├── workflow.json # Workflow definition
|
||||
│ ├── 01-{step-one}.md # Phase 1
|
||||
│ ├── 02-{step-two}.md # Phase 2
|
||||
│ └── 03-{step-three}.md # Phase 3
|
||||
├── specs/
|
||||
│ ├── {domain}-requirements.md
|
||||
│ ├── {skill-name}-requirements.md
|
||||
│ └── quality-standards.md
|
||||
└── templates/
|
||||
└── agent-base.md
|
||||
├── templates/
|
||||
│ └── agent-base.md
|
||||
├── scripts/
|
||||
└── README.md
|
||||
```
|
||||
|
||||
### Autonomous Mode
|
||||
|
||||
```
|
||||
.claude/skills/{skill-name}/
|
||||
├── SKILL.md
|
||||
├── SKILL.md # Entry file
|
||||
├── phases/
|
||||
│ ├── orchestrator.md # 编排器:读取状态 → 选择动作
|
||||
│ ├── state-schema.md # 状态结构定义
|
||||
│ └── actions/ # 独立动作(无顺序)
|
||||
│ ├── action-{a}.md
|
||||
│ ├── action-{b}.md
|
||||
│ └── action-{c}.md
|
||||
│ ├── orchestrator.md # Orchestrator (state-driven)
|
||||
│ ├── state-schema.md # State schema definition
|
||||
│ └── actions/
|
||||
│ ├── action-init.md
|
||||
│ ├── action-create.md
|
||||
│ └── action-list.md
|
||||
├── specs/
|
||||
│ ├── {domain}-requirements.md
|
||||
│ ├── action-catalog.md # 动作目录(描述、前置条件、效果)
|
||||
│ ├── {skill-name}-requirements.md
|
||||
│ ├── action-catalog.md
|
||||
│ └── quality-standards.md
|
||||
└── templates/
|
||||
├── orchestrator-base.md # 编排器模板
|
||||
└── action-base.md # 动作模板
|
||||
├── templates/
|
||||
│ ├── orchestrator-base.md
|
||||
│ └── action-base.md
|
||||
├── scripts/
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Documents by Phase
|
||||
|
||||
IMPORTANT: This section demonstrates how skill-generator organizes its own reference documentation. This is the pattern that all generated Skills should emulate. See [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for details.
|
||||
|
||||
### Phase 0: Specification Study (Mandatory Prerequisites)
|
||||
|
||||
Specification documents that must be read before any generation operation
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal Skill design specification | Understand Skill structure and naming conventions - **REQUIRED** |
|
||||
| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation specification | Ensure Reference Documents have proper phase-based organization - **REQUIRED** |
|
||||
|
||||
### Phase 1: Requirements Discovery
|
||||
|
||||
Collect Skill requirements and configuration
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1 execution guide | Understand how to collect user requirements and generate configuration |
|
||||
| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill requirements specification | Understand what information a Skill should contain |
|
||||
|
||||
### Phase 2: Structure Generation
|
||||
|
||||
Generate directory structure and entry file
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2 execution guide | Understand how to generate directory structure |
|
||||
| [templates/skill-md.md](templates/skill-md.md) | SKILL.md template | Learn how to generate the entry file |
|
||||
|
||||
### Phase 3: Phase/Action Generation
|
||||
|
||||
Generate specific phase or action files based on execution mode
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3 execution guide | Understand Sequential vs Autonomous generation logic |
|
||||
| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template | Generate phase files for Sequential mode |
|
||||
| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator template | Generate orchestrator for Autonomous mode |
|
||||
| [templates/autonomous-action.md](templates/autonomous-action.md) | Action template | Generate action files for Autonomous mode |
|
||||
|
||||
### Phase 4: Specs & Templates
|
||||
|
||||
Generate domain-specific specifications and templates
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4 execution guide | Understand how to generate domain-specific documentation |
|
||||
| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document specification | IMPORTANT: Follow this spec when generating Specs |
|
||||
|
||||
### Phase 5: Validation & Documentation
|
||||
|
||||
Verify results and generate final documentation
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/05-validation.md](phases/05-validation.md) | Phase 5 execution guide | Understand how to verify generated Skill completeness |
|
||||
|
||||
### Debugging & Troubleshooting
|
||||
|
||||
Reference documents when encountering issues
|
||||
|
||||
| Issue | Solution Document |
|
||||
|-------|------------------|
|
||||
| Generated Skill missing Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - verify phase-based organization is followed |
|
||||
| Reference document organization unclear | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - Core Principles section |
|
||||
| Generated documentation does not meet quality standards | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) |
|
||||
|
||||
### Reference & Background
|
||||
|
||||
Documents for deep learning and design decisions
|
||||
|
||||
| Document | Purpose | Notes |
|
||||
|----------|---------|-------|
|
||||
| [specs/execution-modes.md](specs/execution-modes.md) | Detailed execution modes specification | Comparison and use cases for Sequential vs Autonomous |
|
||||
| [specs/cli-integration.md](specs/cli-integration.md) | CLI integration specification | How generated Skills integrate with CLI |
|
||||
| [specs/scripting-integration.md](specs/scripting-integration.md) | Script integration specification | How to use scripts in Phases |
|
||||
| [templates/script-template.md](templates/script-template.md) | Script template | Unified Bash + Python template |
|
||||
@@ -1,125 +1,125 @@
|
||||
# Phase 1: Requirements Discovery
|
||||
|
||||
收集新 Skill 的需求信息,生成配置文件。
|
||||
Collect basic skill information, configuration, and execution mode based on user input.
|
||||
|
||||
## Objective
|
||||
|
||||
- 收集 Skill 基本信息(名称、描述、触发词)
|
||||
- 确定执行模式(Sequential / Autonomous)
|
||||
- 定义阶段/动作
|
||||
- 配置工具依赖和输出格式
|
||||
- Collect skill basic information (name, description, trigger words)
|
||||
- Determine execution mode (Sequential/Autonomous/Hybrid)
|
||||
- Define phases or actions
|
||||
- Generate initial configuration file
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: 基本信息收集
|
||||
### Step 1: Basic Information Collection
|
||||
|
||||
```javascript
|
||||
const basicInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "新 Skill 的名称是什么?(英文,小写-连字符格式,如 'api-docs')",
|
||||
header: "Skill 名称",
|
||||
question: "What is the name of the new Skill? (English, lowercase with hyphens, e.g., 'api-docs')",
|
||||
header: "Skill Name",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "自动生成", description: "根据后续描述自动生成名称" },
|
||||
{ label: "手动输入", description: "现在输入自定义名称" }
|
||||
{ label: "Auto-generate", description: "Generate name automatically based on description" },
|
||||
{ label: "Manual Input", description: "Enter custom name now" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Skill 的主要用途是什么?",
|
||||
header: "用途类型",
|
||||
question: "What is the primary purpose of the Skill?",
|
||||
header: "Purpose Type",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "文档生成", description: "生成 Markdown/HTML 文档(如手册、报告)" },
|
||||
{ label: "代码分析", description: "分析代码结构、质量、安全性" },
|
||||
{ label: "交互管理", description: "管理 Issue、任务、工作流(CRUD 操作)" },
|
||||
{ label: "数据处理", description: "ETL、格式转换、报告生成" }
|
||||
{ label: "Document Generation", description: "Generate Markdown/HTML documents (manuals, reports)" },
|
||||
{ label: "Code Analysis", description: "Analyze code structure, quality, security" },
|
||||
{ label: "Interactive Management", description: "Manage Issues, tasks, workflows (CRUD operations)" },
|
||||
{ label: "Data Processing", description: "ETL, format conversion, report generation" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 如果选择手动输入,进一步询问
|
||||
if (basicInfo["Skill 名称"] === "手动输入") {
|
||||
// 用户会在 "Other" 中输入
|
||||
// If manual input is selected, prompt further
|
||||
if (basicInfo["Skill Name"] === "Manual Input") {
|
||||
// User will input in "Other"
|
||||
}
|
||||
|
||||
// 根据用途类型推断描述模板
|
||||
// Infer description template based on purpose type
|
||||
const purposeTemplates = {
|
||||
"文档生成": "Generate {type} documents from {source}",
|
||||
"代码分析": "Analyze {target} for {purpose}",
|
||||
"交互管理": "Manage {entity} with interactive operations",
|
||||
"数据处理": "Process {data} and generate {output}"
|
||||
"Document Generation": "Generate {type} documents from {source}",
|
||||
"Code Analysis": "Analyze {target} for {purpose}",
|
||||
"Interactive Management": "Manage {entity} with interactive operations",
|
||||
"Data Processing": "Process {data} and generate {output}"
|
||||
};
|
||||
```
|
||||
|
||||
### Step 2: 执行模式选择
|
||||
### Step 2: Execution Mode Selection
|
||||
|
||||
```javascript
|
||||
const modeInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "选择执行模式:",
|
||||
header: "执行模式",
|
||||
question: "Select execution mode:",
|
||||
header: "Execution Mode",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Sequential (顺序模式)",
|
||||
description: "阶段按固定顺序执行(收集→分析→生成),适合流水线任务(推荐)"
|
||||
{
|
||||
label: "Sequential (Sequential Mode)",
|
||||
description: "Phases execute in fixed order (collect→analyze→generate), suitable for pipeline tasks (recommended)"
|
||||
},
|
||||
{
|
||||
label: "Autonomous (自主模式)",
|
||||
description: "动态选择执行路径,适合交互式任务(如 Issue 管理)"
|
||||
{
|
||||
label: "Autonomous (Autonomous Mode)",
|
||||
description: "Dynamically select execution path, suitable for interactive tasks (e.g., Issue management)"
|
||||
},
|
||||
{
|
||||
label: "Hybrid (混合模式)",
|
||||
description: "初始化和收尾固定,中间交互灵活"
|
||||
{
|
||||
label: "Hybrid (Hybrid Mode)",
|
||||
description: "Fixed initialization and finalization, flexible interaction in the middle"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const executionMode = modeInfo["执行模式"].includes("Sequential") ? "sequential" :
|
||||
modeInfo["执行模式"].includes("Autonomous") ? "autonomous" : "hybrid";
|
||||
const executionMode = modeInfo["Execution Mode"].includes("Sequential") ? "sequential" :
|
||||
modeInfo["Execution Mode"].includes("Autonomous") ? "autonomous" : "hybrid";
|
||||
```
|
||||
|
||||
### Step 3: 阶段/动作定义
|
||||
### Step 3: Phase/Action Definition
|
||||
|
||||
#### Sequential 模式
|
||||
#### Sequential Mode
|
||||
|
||||
```javascript
|
||||
if (executionMode === "sequential") {
|
||||
const phaseInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "需要多少个执行阶段?",
|
||||
header: "阶段数量",
|
||||
question: "How many execution phases are needed?",
|
||||
header: "Phase Count",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "3 阶段(简单)", description: "收集 → 处理 → 输出" },
|
||||
{ label: "5 阶段(标准)", description: "收集 → 探索 → 分析 → 组装 → 验证" },
|
||||
{ label: "7 阶段(完整)", description: "含并行处理、汇总、迭代优化" }
|
||||
{ label: "3 Phases (Simple)", description: "Collection → Processing → Output" },
|
||||
{ label: "5 Phases (Standard)", description: "Collection → Exploration → Analysis → Assembly → Validation" },
|
||||
{ label: "7 Phases (Complete)", description: "Includes parallel processing, consolidation, iterative optimization" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 根据选择生成阶段定义
|
||||
|
||||
// Generate phase definitions based on selection
|
||||
const phaseTemplates = {
|
||||
"3 阶段": [
|
||||
"3 Phases": [
|
||||
{ id: "01-collection", name: "Data Collection" },
|
||||
{ id: "02-processing", name: "Processing" },
|
||||
{ id: "03-output", name: "Output Generation" }
|
||||
],
|
||||
"5 阶段": [
|
||||
"5 Phases": [
|
||||
{ id: "01-collection", name: "Requirements Collection" },
|
||||
{ id: "02-exploration", name: "Project Exploration" },
|
||||
{ id: "03-analysis", name: "Deep Analysis" },
|
||||
{ id: "04-assembly", name: "Document Assembly" },
|
||||
{ id: "05-validation", name: "Validation" }
|
||||
],
|
||||
"7 阶段": [
|
||||
"7 Phases": [
|
||||
{ id: "01-collection", name: "Requirements Collection" },
|
||||
{ id: "02-exploration", name: "Project Exploration" },
|
||||
{ id: "03-parallel", name: "Parallel Analysis" },
|
||||
@@ -132,23 +132,23 @@ if (executionMode === "sequential") {
|
||||
}
|
||||
```
|
||||
|
||||
#### Autonomous 模式
|
||||
#### Autonomous Mode
|
||||
|
||||
```javascript
|
||||
if (executionMode === "autonomous") {
|
||||
const actionInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "核心动作有哪些?(可多选)",
|
||||
header: "动作定义",
|
||||
question: "What are the core actions? (Multiple selection allowed)",
|
||||
header: "Action Definition",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "初始化 (init)", description: "设置初始状态" },
|
||||
{ label: "列表 (list)", description: "显示当前项目列表" },
|
||||
{ label: "创建 (create)", description: "创建新项目" },
|
||||
{ label: "编辑 (edit)", description: "修改现有项目" },
|
||||
{ label: "删除 (delete)", description: "删除项目" },
|
||||
{ label: "搜索 (search)", description: "搜索/过滤项目" }
|
||||
{ label: "Initialize (init)", description: "Set initial state" },
|
||||
{ label: "List (list)", description: "Display current item list" },
|
||||
{ label: "Create (create)", description: "Create new item" },
|
||||
{ label: "Edit (edit)", description: "Modify existing item" },
|
||||
{ label: "Delete (delete)", description: "Delete item" },
|
||||
{ label: "Search (search)", description: "Search/filter items" }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -156,37 +156,37 @@ if (executionMode === "autonomous") {
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: 工具和输出配置
|
||||
### Step 4: Tool and Output Configuration
|
||||
|
||||
```javascript
|
||||
const toolsInfo = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "需要哪些特殊工具?(基础工具已默认包含)",
|
||||
header: "工具选择",
|
||||
question: "Which special tools are needed? (Basic tools are included by default)",
|
||||
header: "Tool Selection",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "用户交互 (AskUserQuestion)", description: "需要与用户对话" },
|
||||
{ label: "Chrome 截图 (mcp__chrome__*)", description: "需要网页截图" },
|
||||
{ label: "外部搜索 (mcp__exa__search)", description: "需要搜索外部信息" },
|
||||
{ label: "无特殊需求", description: "仅使用基础工具" }
|
||||
{ label: "User Interaction (AskUserQuestion)", description: "Need to dialog with user" },
|
||||
{ label: "Chrome Screenshot (mcp__chrome__*)", description: "Need web page screenshots" },
|
||||
{ label: "External Search (mcp__exa__search)", description: "Need to search external information" },
|
||||
{ label: "No Special Requirements", description: "Use basic tools only" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "输出格式是什么?",
|
||||
header: "输出格式",
|
||||
question: "What is the output format?",
|
||||
header: "Output Format",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Markdown", description: "适合文档和报告" },
|
||||
{ label: "HTML", description: "适合交互式文档" },
|
||||
{ label: "JSON", description: "适合数据和配置" }
|
||||
{ label: "Markdown", description: "Suitable for documents and reports" },
|
||||
{ label: "HTML", description: "Suitable for interactive documents" },
|
||||
{ label: "JSON", description: "Suitable for data and configuration" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### Step 5: 生成配置文件
|
||||
### Step 5: Generate Configuration File
|
||||
|
||||
```javascript
|
||||
const config = {
|
||||
@@ -195,45 +195,44 @@ const config = {
|
||||
description: description,
|
||||
triggers: triggers,
|
||||
execution_mode: executionMode,
|
||||
|
||||
// 模式特定配置
|
||||
|
||||
// Mode-specific configuration
|
||||
...(executionMode === "sequential" ? {
|
||||
sequential_config: { phases: phases }
|
||||
} : {
|
||||
autonomous_config: {
|
||||
autonomous_config: {
|
||||
state_schema: stateSchema,
|
||||
actions: actions,
|
||||
termination_conditions: ["user_exit", "error_limit", "task_completed"]
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
allowed_tools: [
|
||||
"Task", "Read", "Write", "Glob", "Grep", "Bash",
|
||||
...selectedTools
|
||||
],
|
||||
|
||||
|
||||
output: {
|
||||
format: outputFormat.toLowerCase(),
|
||||
location: `.workflow/.scratchpad/${skillName}-{timestamp}`,
|
||||
filename_pattern: `{name}-output.${outputFormat === "HTML" ? "html" : outputFormat === "JSON" ? "json" : "md"}`
|
||||
},
|
||||
|
||||
|
||||
created_at: new Date().toISOString(),
|
||||
version: "1.0.0"
|
||||
};
|
||||
|
||||
// 写入配置文件
|
||||
// Write configuration file
|
||||
const workDir = `.workflow/.scratchpad/skill-gen-${timestamp}`;
|
||||
Bash(`mkdir -p "${workDir}"`);
|
||||
Write(`${workDir}/skill-config.json`, JSON.stringify(config, null, 2));
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `skill-config.json`
|
||||
- **Location**: `.workflow/.scratchpad/skill-gen-{timestamp}/`
|
||||
- **Format**: JSON
|
||||
|
||||
## Next Phase
|
||||
|
||||
→ [Phase 2: Structure Generation](02-structure-generation.md)
|
||||
|
||||
**Data Flow to Phase 2**:
|
||||
- skill-config.json with all configuration parameters
|
||||
- Execution mode decision drives directory structure creation
|
||||
|
||||
@@ -1,44 +1,101 @@
|
||||
# Phase 2: Structure Generation
|
||||
|
||||
根据配置创建 Skill 目录结构和入口文件。
|
||||
Create Skill directory structure and entry file based on configuration.
|
||||
|
||||
## Objective
|
||||
|
||||
- 创建标准目录结构
|
||||
- 生成 SKILL.md 入口文件
|
||||
- 根据执行模式创建对应的子目录
|
||||
- Create standard directory structure
|
||||
- Generate SKILL.md entry file
|
||||
- Create corresponding subdirectories based on execution mode
|
||||
|
||||
## Input
|
||||
|
||||
- 依赖: `skill-config.json` (Phase 1 产出)
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: 读取配置
|
||||
### Step 1: Read Configuration
|
||||
|
||||
```javascript
|
||||
const config = JSON.parse(Read(`${workDir}/skill-config.json`));
|
||||
const skillDir = `.claude/skills/${config.skill_name}`;
|
||||
```
|
||||
|
||||
### Step 2: 创建目录结构
|
||||
### Step 2: Create Directory Structure
|
||||
|
||||
#### Base Directories (All Modes)
|
||||
|
||||
```javascript
|
||||
// 基础目录
|
||||
Bash(`mkdir -p "${skillDir}/phases"`);
|
||||
Bash(`mkdir -p "${skillDir}/specs"`);
|
||||
Bash(`mkdir -p "${skillDir}/templates"`);
|
||||
// Base infrastructure
|
||||
Bash(`mkdir -p "${skillDir}/{phases,specs,templates,scripts}"`);
|
||||
```
|
||||
|
||||
// Autonomous 模式额外目录
|
||||
#### Execution Mode-Specific Directories
|
||||
|
||||
```
|
||||
config.execution_mode
|
||||
↓
|
||||
├─ "sequential"
|
||||
│ ↓ Creates:
|
||||
│ └─ phases/ (base directory already included)
|
||||
│ ├─ _orchestrator.md
|
||||
│ └─ workflow.json
|
||||
│
|
||||
└─ "autonomous" | "hybrid"
|
||||
↓ Creates:
|
||||
└─ phases/actions/
|
||||
├─ state-schema.md
|
||||
└─ *.md (action files)
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Additional directories for Autonomous/Hybrid mode
|
||||
if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') {
|
||||
Bash(`mkdir -p "${skillDir}/phases/actions"`);
|
||||
}
|
||||
|
||||
// scripts 目录(默认创建,用于存放确定性脚本)
|
||||
Bash(`mkdir -p "${skillDir}/scripts"`);
|
||||
```
|
||||
|
||||
### Step 3: 生成 SKILL.md
|
||||
#### Context Strategy-Specific Directories (P0 Enhancement)
|
||||
|
||||
```javascript
|
||||
// ========== P0: Create directories based on context strategy ==========
|
||||
const contextStrategy = config.context_strategy || 'file';
|
||||
|
||||
if (contextStrategy === 'file') {
|
||||
// File strategy: Create persistent context directory
|
||||
Bash(`mkdir -p "${skillDir}/.scratchpad-template/context"`);
|
||||
|
||||
// Create context template file
|
||||
Write(
|
||||
`${skillDir}/.scratchpad-template/context/.gitkeep`,
|
||||
"# Runtime context storage for file-based strategy"
|
||||
);
|
||||
}
|
||||
// Memory strategy does not require directory creation (in-memory only)
|
||||
```
|
||||
|
||||
**Directory Tree View**:
|
||||
|
||||
```
|
||||
Sequential + File Strategy:
|
||||
.claude/skills/{skill-name}/
|
||||
├── phases/
|
||||
│ ├── _orchestrator.md
|
||||
│ ├── workflow.json
|
||||
│ ├── 01-*.md
|
||||
│ └── 02-*.md
|
||||
├── .scratchpad-template/
|
||||
│ └── context/ <- File strategy persistent storage
|
||||
└── specs/
|
||||
|
||||
Autonomous + Memory Strategy:
|
||||
.claude/skills/{skill-name}/
|
||||
├── phases/
|
||||
│ ├── orchestrator.md
|
||||
│ ├── state-schema.md
|
||||
│ └── actions/
|
||||
│ └── *.md
|
||||
└── specs/
|
||||
```
|
||||
|
||||
### Step 3: Generate SKILL.md
|
||||
|
||||
```javascript
|
||||
const skillMdTemplate = `---
|
||||
@@ -72,8 +129,8 @@ const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, '');
|
||||
const workDir = \`${config.output.location.replace('{timestamp}', '${timestamp}')}\`;
|
||||
|
||||
Bash(\`mkdir -p "\${workDir}"\`);
|
||||
${config.execution_mode === 'sequential' ?
|
||||
`Bash(\`mkdir -p "\${workDir}/sections"\`);` :
|
||||
${config.execution_mode === 'sequential' ?
|
||||
`Bash(\`mkdir -p "\${workDir}/sections"\`);` :
|
||||
`Bash(\`mkdir -p "\${workDir}/state"\`);`}
|
||||
\`\`\`
|
||||
|
||||
@@ -91,53 +148,53 @@ ${generateReferenceTable(config)}
|
||||
Write(`${skillDir}/SKILL.md`, skillMdTemplate);
|
||||
```
|
||||
|
||||
### Step 4: 架构图生成函数
|
||||
### Step 4: Architecture Diagram Generation Functions
|
||||
|
||||
```javascript
|
||||
function generateArchitectureDiagram(config) {
|
||||
if (config.execution_mode === 'sequential') {
|
||||
return config.sequential_config.phases.map((p, i) =>
|
||||
return config.sequential_config.phases.map((p, i) =>
|
||||
`│ Phase ${i+1}: ${p.name.padEnd(15)} → ${p.output || 'output-' + (i+1) + '.json'}${' '.repeat(10)}│`
|
||||
).join('\n│ ↓' + ' '.repeat(45) + '│\n');
|
||||
} else {
|
||||
return `
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Orchestrator (状态驱动决策) │
|
||||
│ Orchestrator (State-driven decision-making) │
|
||||
└───────────────┬─────────────────────────────────────────────────┘
|
||||
│
|
||||
┌───────────┼───────────┐
|
||||
↓ ↓ ↓
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
`┌─────────┐ `).join('')}
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
`│${a.name.slice(0, 7).padEnd(7)}│ `).join('')}
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
${config.autonomous_config.actions.slice(0, 3).map(a =>
|
||||
`└─────────┘ `).join('')}`;
|
||||
}
|
||||
}
|
||||
|
||||
function generateDesignPrinciples(config) {
|
||||
const common = [
|
||||
"1. **规范遵循**: 严格遵循 `_shared/SKILL-DESIGN-SPEC.md`",
|
||||
"2. **简要返回**: Agent 返回路径+摘要,避免上下文溢出"
|
||||
"1. **Specification Compliance**: Strictly follow `_shared/SKILL-DESIGN-SPEC.md`",
|
||||
"2. **Brief Return**: Agent returns path+summary, avoiding context overflow"
|
||||
];
|
||||
|
||||
|
||||
if (config.execution_mode === 'sequential') {
|
||||
return [...common,
|
||||
"3. **阶段隔离**: 每个阶段独立可测",
|
||||
"4. **链式输出**: 阶段产出作为下阶段输入"
|
||||
"3. **Phase Isolation**: Each phase is independently testable",
|
||||
"4. **Chained Output**: Phase output becomes next phase input"
|
||||
].join('\n');
|
||||
} else {
|
||||
return [...common,
|
||||
"3. **状态驱动**: 显式状态管理,动态决策",
|
||||
"4. **动作独立**: 每个动作无副作用依赖"
|
||||
"3. **State-driven**: Explicit state management, dynamic decision-making",
|
||||
"4. **Action Independence**: Each action has no side-effect dependencies"
|
||||
].join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
function generateExecutionFlow(config) {
|
||||
if (config.execution_mode === 'sequential') {
|
||||
return '```\n' + config.sequential_config.phases.map((p, i) =>
|
||||
return '```\n' + config.sequential_config.phases.map((p, i) =>
|
||||
`├─ Phase ${i+1}: ${p.name}\n│ → Output: ${p.output || 'output.json'}`
|
||||
).join('\n') + '\n```';
|
||||
} else {
|
||||
@@ -158,9 +215,9 @@ function generateExecutionFlow(config) {
|
||||
function generateOutputStructure(config) {
|
||||
const base = `${config.output.location}/
|
||||
├── ${config.execution_mode === 'sequential' ? 'sections/' : 'state.json'}`;
|
||||
|
||||
|
||||
if (config.execution_mode === 'sequential') {
|
||||
return base + '\n' + config.sequential_config.phases.map(p =>
|
||||
return base + '\n' + config.sequential_config.phases.map(p =>
|
||||
`│ └── ${p.output || 'section-' + p.id + '.md'}`
|
||||
).join('\n') + `\n└── ${config.output.filename_pattern}`;
|
||||
} else {
|
||||
@@ -172,36 +229,33 @@ function generateOutputStructure(config) {
|
||||
|
||||
function generateReferenceTable(config) {
|
||||
const rows = [];
|
||||
|
||||
|
||||
if (config.execution_mode === 'sequential') {
|
||||
config.sequential_config.phases.forEach(p => {
|
||||
rows.push(`| [phases/${p.id}.md](phases/${p.id}.md) | ${p.name} |`);
|
||||
});
|
||||
} else {
|
||||
rows.push(`| [phases/orchestrator.md](phases/orchestrator.md) | 编排器 |`);
|
||||
rows.push(`| [phases/state-schema.md](phases/state-schema.md) | 状态定义 |`);
|
||||
rows.push(`| [phases/orchestrator.md](phases/orchestrator.md) | Orchestrator |`);
|
||||
rows.push(`| [phases/state-schema.md](phases/state-schema.md) | State Definition |`);
|
||||
config.autonomous_config.actions.forEach(a => {
|
||||
rows.push(`| [phases/actions/${a.id}.md](phases/actions/${a.id}.md) | ${a.name} |`);
|
||||
});
|
||||
}
|
||||
|
||||
rows.push(`| [specs/${config.skill_name}-requirements.md](specs/${config.skill_name}-requirements.md) | 领域规范 |`);
|
||||
rows.push(`| [specs/quality-standards.md](specs/quality-standards.md) | 质量标准 |`);
|
||||
|
||||
|
||||
rows.push(`| [specs/${config.skill_name}-requirements.md](specs/${config.skill_name}-requirements.md) | Domain Requirements |`);
|
||||
rows.push(`| [specs/quality-standards.md](specs/quality-standards.md) | Quality Standards |`);
|
||||
|
||||
return `| Document | Purpose |\n|----------|---------||\n` + rows.join('\n');
|
||||
}
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
- **Directory**: `.claude/skills/{skill-name}/`
|
||||
- **Files**:
|
||||
- `SKILL.md` (入口文件)
|
||||
- `phases/` (执行阶段目录)
|
||||
- `specs/` (规范文档目录)
|
||||
- `templates/` (模板目录)
|
||||
- `scripts/` (脚本目录,存放 Python/Bash 确定性脚本)
|
||||
|
||||
## Next Phase
|
||||
|
||||
→ [Phase 3: Phase Generation](03-phase-generation.md)
|
||||
|
||||
**Data Flow to Phase 3**:
|
||||
- Complete directory structure in .claude/skills/{skill-name}/
|
||||
- SKILL.md entry file ready for phase/action generation
|
||||
- skill-config.json for template population
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,107 @@
|
||||
# Phase 4: Specs & Templates Generation
|
||||
# Phase 4: Specifications & Templates Generation
|
||||
|
||||
生成规范文件和模板文件。
|
||||
Generate domain requirements, quality standards, agent templates, and action catalogs.
|
||||
|
||||
## Objective
|
||||
|
||||
- 生成领域规范 (`specs/{domain}-requirements.md`)
|
||||
- 生成质量标准 (`specs/quality-standards.md`)
|
||||
- 生成 Agent 模板 (`templates/agent-base.md`)
|
||||
- Autonomous 模式额外生成动作目录 (`specs/action-catalog.md`)
|
||||
Generate comprehensive specifications and templates:
|
||||
- Domain requirements document with validation function
|
||||
- Quality standards with automated check system
|
||||
- Agent base template with prompt structure
|
||||
- Action catalog for autonomous mode (conditional)
|
||||
|
||||
## Input
|
||||
|
||||
- 依赖: `skill-config.json`, SKILL.md, phases/*.md
|
||||
**File Dependencies**:
|
||||
- `skill-config.json` (from Phase 1)
|
||||
- `.claude/skills/{skill-name}/` directory (from Phase 2)
|
||||
- Generated phase/action files (from Phase 3)
|
||||
|
||||
## Execution Steps
|
||||
**Required Information**:
|
||||
- Skill name, display name, description
|
||||
- Execution mode (determines if action-catalog.md is generated)
|
||||
- Output format and location
|
||||
- Phase/action definitions
|
||||
|
||||
### Step 1: 生成领域规范
|
||||
## Output
|
||||
|
||||
**Generated Files**:
|
||||
|
||||
| File | Purpose | Generation Condition |
|
||||
|------|---------|---------------------|
|
||||
| `specs/{skill-name}-requirements.md` | Domain requirements with validation | Always |
|
||||
| `specs/quality-standards.md` | Quality evaluation criteria | Always |
|
||||
| `templates/agent-base.md` | Agent prompt template | Always |
|
||||
| `specs/action-catalog.md` | Action dependency graph and selection priority | Autonomous/Hybrid mode only |
|
||||
|
||||
**File Structure**:
|
||||
|
||||
**Domain Requirements** (`specs/{skill-name}-requirements.md`):
|
||||
```markdown
|
||||
# {display_name} Requirements
|
||||
- When to Use (phase/action reference table)
|
||||
- Domain Requirements (Functional requirements, Output requirements, Quality requirements)
|
||||
- Validation Function (JavaScript code)
|
||||
- Error Handling (recovery strategies)
|
||||
```
|
||||
|
||||
**Quality Standards** (`specs/quality-standards.md`):
|
||||
```markdown
|
||||
# Quality Standards
|
||||
- Quality Dimensions (Completeness 25%, Consistency 25%, Accuracy 25%, Usability 25%)
|
||||
- Quality Gates (Pass ≥80%, Review 60-79%, Fail <60%)
|
||||
- Issue Classification (Errors, Warnings, Info)
|
||||
- Automated Checks (runQualityChecks function)
|
||||
```
|
||||
|
||||
**Agent Base** (`templates/agent-base.md`):
|
||||
```markdown
|
||||
# Agent Base Template
|
||||
- Universal Prompt Structure (ROLE, PROJECT CONTEXT, TASK, CONSTRAINTS, OUTPUT_FORMAT, QUALITY_CHECKLIST)
|
||||
- Variable Description (workDir, output_path)
|
||||
- Return Format (AgentReturn interface)
|
||||
- Role Definition Reference (phase/action specific agents)
|
||||
```
|
||||
|
||||
**Action Catalog** (`specs/action-catalog.md`, Autonomous/Hybrid only):
|
||||
```markdown
|
||||
# Action Catalog
|
||||
- Available Actions (table with Purpose, Preconditions, Effects)
|
||||
- Action Dependencies (Mermaid diagram)
|
||||
- State Transitions (state machine table)
|
||||
- Selection Priority (ordered action list)
|
||||
```
|
||||
|
||||
## Decision Logic
|
||||
|
||||
```
|
||||
Decision (execution_mode check):
|
||||
├─ mode === 'sequential' → Generate 3 files only
|
||||
│ └─ Files: requirements.md, quality-standards.md, agent-base.md
|
||||
│
|
||||
├─ mode === 'autonomous' → Generate 4 files
|
||||
│ ├─ Files: requirements.md, quality-standards.md, agent-base.md
|
||||
│ └─ Additional: action-catalog.md (with action dependencies)
|
||||
│
|
||||
└─ mode === 'hybrid' → Generate 4 files
|
||||
├─ Files: requirements.md, quality-standards.md, agent-base.md
|
||||
└─ Additional: action-catalog.md (with hybrid logic)
|
||||
```
|
||||
|
||||
## Execution Protocol
|
||||
|
||||
```javascript
|
||||
// Phase 4: Generate Specifications & Templates
|
||||
// Reference: phases/04-specs-templates.md
|
||||
|
||||
// Load config and setup
|
||||
const config = JSON.parse(Read(`${workDir}/skill-config.json`));
|
||||
const skillDir = `.claude/skills/${config.skill_name}`;
|
||||
|
||||
// Ensure specs and templates directories exist (created in Phase 2)
|
||||
// skillDir structure: phases/, specs/, templates/
|
||||
|
||||
// Step 1: Generate domain requirements
|
||||
const domainRequirements = `# ${config.display_name} Requirements
|
||||
|
||||
${config.description}
|
||||
@@ -29,45 +110,45 @@ ${config.description}
|
||||
|
||||
| Phase | Usage | Reference |
|
||||
|-------|-------|-----------|
|
||||
${config.execution_mode === 'sequential' ?
|
||||
config.sequential_config.phases.map((p, i) =>
|
||||
${config.execution_mode === 'sequential' ?
|
||||
config.sequential_config.phases.map((p, i) =>
|
||||
`| Phase ${i+1} | ${p.name} | ${p.id}.md |`
|
||||
).join('\n') :
|
||||
`| Orchestrator | 动作选择 | orchestrator.md |
|
||||
| Actions | 动作执行 | actions/*.md |`}
|
||||
`| Orchestrator | Action selection | orchestrator.md |
|
||||
| Actions | Action execution | actions/*.md |`}
|
||||
|
||||
---
|
||||
|
||||
## Domain Requirements
|
||||
|
||||
### 功能要求
|
||||
### Functional Requirements
|
||||
|
||||
- [ ] 要求1: TODO
|
||||
- [ ] 要求2: TODO
|
||||
- [ ] 要求3: TODO
|
||||
- [ ] Requirement 1: TODO
|
||||
- [ ] Requirement 2: TODO
|
||||
- [ ] Requirement 3: TODO
|
||||
|
||||
### 输出要求
|
||||
### Output Requirements
|
||||
|
||||
- [ ] 格式: ${config.output.format}
|
||||
- [ ] 位置: ${config.output.location}
|
||||
- [ ] 命名: ${config.output.filename_pattern}
|
||||
- [ ] Format: ${config.output.format}
|
||||
- [ ] Location: ${config.output.location}
|
||||
- [ ] Naming: ${config.output.filename_pattern}
|
||||
|
||||
### 质量要求
|
||||
### Quality Requirements
|
||||
|
||||
- [ ] 完整性: 所有必需内容存在
|
||||
- [ ] 一致性: 术语和格式统一
|
||||
- [ ] 准确性: 内容基于实际分析
|
||||
- [ ] Completeness: All necessary content exists
|
||||
- [ ] Consistency: Terminology and format unified
|
||||
- [ ] Accuracy: Content based on actual analysis
|
||||
|
||||
## Validation Function
|
||||
|
||||
\`\`\`javascript
|
||||
function validate${toPascalCase(config.skill_name)}(output) {
|
||||
const checks = [
|
||||
// TODO: 添加验证规则
|
||||
{ name: "格式正确", pass: output.format === "${config.output.format}" },
|
||||
{ name: "内容完整", pass: output.content?.length > 0 }
|
||||
// TODO: Add validation rules
|
||||
{ name: "Format correct", pass: output.format === "${config.output.format}" },
|
||||
{ name: "Content complete", pass: output.content?.length > 0 }
|
||||
];
|
||||
|
||||
|
||||
return {
|
||||
passed: checks.filter(c => c.pass).length,
|
||||
total: checks.length,
|
||||
@@ -80,81 +161,78 @@ function validate${toPascalCase(config.skill_name)}(output) {
|
||||
|
||||
| Error | Recovery |
|
||||
|-------|----------|
|
||||
| 输入数据缺失 | 返回明确错误信息 |
|
||||
| 处理超时 | 缩小范围,重试 |
|
||||
| 输出验证失败 | 记录问题,人工审核 |
|
||||
| Missing input data | Return clear error message |
|
||||
| Processing timeout | Reduce scope, retry |
|
||||
| Output validation failure | Log issue, manual review |
|
||||
`;
|
||||
|
||||
Write(`${skillDir}/specs/${config.skill_name}-requirements.md`, domainRequirements);
|
||||
```
|
||||
|
||||
### Step 2: 生成质量标准
|
||||
|
||||
```javascript
|
||||
// Step 2: Generate quality standards
|
||||
const qualityStandards = `# Quality Standards
|
||||
|
||||
${config.display_name} 的质量评估标准。
|
||||
Quality assessment standards for ${config.display_name}.
|
||||
|
||||
## Quality Dimensions
|
||||
|
||||
### 1. Completeness (完整性) - 25%
|
||||
### 1. Completeness (Completeness) - 25%
|
||||
|
||||
| 要求 | 权重 | 检查方式 |
|
||||
|------|------|----------|
|
||||
| 所有必需输出存在 | 10 | 文件检查 |
|
||||
| 内容覆盖完整 | 10 | 内容分析 |
|
||||
| 无占位符残留 | 5 | 文本搜索 |
|
||||
| Requirement | Weight | Validation Method |
|
||||
|------------|--------|-----------------|
|
||||
| All necessary outputs exist | 10 | File check |
|
||||
| Content coverage complete | 10 | Content analysis |
|
||||
| No placeholder remnants | 5 | Text search |
|
||||
|
||||
### 2. Consistency (一致性) - 25%
|
||||
### 2. Consistency (Consistency) - 25%
|
||||
|
||||
| 方面 | 检查 |
|
||||
|------|------|
|
||||
| 术语 | 同一概念使用相同术语 |
|
||||
| 格式 | 标题层级、代码块格式一致 |
|
||||
| 风格 | 语气和表达方式统一 |
|
||||
| Aspect | Check |
|
||||
|--------|-------|
|
||||
| Terminology | Use same term for same concept |
|
||||
| Format | Title levels, code block format consistent |
|
||||
| Style | Tone and expression unified |
|
||||
|
||||
### 3. Accuracy (准确性) - 25%
|
||||
### 3. Accuracy (Accuracy) - 25%
|
||||
|
||||
| 要求 | 说明 |
|
||||
|------|------|
|
||||
| 数据正确 | 引用和数据无错误 |
|
||||
| 逻辑正确 | 流程和关系描述准确 |
|
||||
| 代码正确 | 代码示例可运行 |
|
||||
| Requirement | Description |
|
||||
|-------------|------------|
|
||||
| Data correct | References and data error-free |
|
||||
| Logic correct | Process and relationship descriptions accurate |
|
||||
| Code correct | Code examples runnable |
|
||||
|
||||
### 4. Usability (可用性) - 25%
|
||||
### 4. Usability (Usability) - 25%
|
||||
|
||||
| 指标 | 目标 |
|
||||
|------|------|
|
||||
| 可读性 | 结构清晰,易于理解 |
|
||||
| 可导航 | 目录和链接正确 |
|
||||
| 可操作 | 步骤明确,可执行 |
|
||||
| Metric | Goal |
|
||||
|--------|------|
|
||||
| Readability | Clear structure, easy to understand |
|
||||
| Navigability | Table of contents and links correct |
|
||||
| Operability | Steps clear, executable |
|
||||
|
||||
## Quality Gates
|
||||
|
||||
| Gate | Threshold | Action |
|
||||
|------|-----------|--------|
|
||||
| Pass | ≥ 80% | 输出最终产物 |
|
||||
| Review | 60-79% | 处理警告后继续 |
|
||||
| Fail | < 60% | 必须修复 |
|
||||
| Pass | >= 80% | Output final deliverables |
|
||||
| Review | 60-79% | Process warnings then continue |
|
||||
| Fail | < 60% | Must fix |
|
||||
|
||||
## Issue Classification
|
||||
|
||||
### Errors (Must Fix)
|
||||
|
||||
- 必需输出缺失
|
||||
- 数据错误
|
||||
- 代码不可运行
|
||||
- Necessary output missing
|
||||
- Data error
|
||||
- Code not runnable
|
||||
|
||||
### Warnings (Should Fix)
|
||||
|
||||
- 格式不一致
|
||||
- 内容深度不足
|
||||
- 缺少示例
|
||||
- Format inconsistency
|
||||
- Content depth insufficient
|
||||
- Missing examples
|
||||
|
||||
### Info (Nice to Have)
|
||||
|
||||
- 优化建议
|
||||
- 增强机会
|
||||
- Optimization suggestions
|
||||
- Enhancement opportunities
|
||||
|
||||
## Automated Checks
|
||||
|
||||
@@ -176,7 +254,7 @@ function runQualityChecks(workDir) {
|
||||
|
||||
return {
|
||||
score: results.overall,
|
||||
gate: results.overall >= 80 ? 'pass' :
|
||||
gate: results.overall >= 80 ? 'pass' :
|
||||
results.overall >= 60 ? 'review' : 'fail',
|
||||
details: results
|
||||
};
|
||||
@@ -185,51 +263,48 @@ function runQualityChecks(workDir) {
|
||||
`;
|
||||
|
||||
Write(`${skillDir}/specs/quality-standards.md`, qualityStandards);
|
||||
```
|
||||
|
||||
### Step 3: 生成 Agent 模板
|
||||
|
||||
```javascript
|
||||
// Step 3: Generate agent base template
|
||||
const agentBase = `# Agent Base Template
|
||||
|
||||
${config.display_name} 的 Agent 基础模板。
|
||||
Agent base template for ${config.display_name}.
|
||||
|
||||
## 通用 Prompt 结构
|
||||
## Universal Prompt Structure
|
||||
|
||||
\`\`\`
|
||||
[ROLE] 你是{角色},专注于{职责}。
|
||||
[ROLE] You are {role}, focused on {responsibility}.
|
||||
|
||||
[PROJECT CONTEXT]
|
||||
Skill: ${config.skill_name}
|
||||
目标: ${config.description}
|
||||
Objective: ${config.description}
|
||||
|
||||
[TASK]
|
||||
{任务描述}
|
||||
- 输出: {output_path}
|
||||
- 格式: ${config.output.format}
|
||||
{task description}
|
||||
- Output: {output_path}
|
||||
- Format: ${config.output.format}
|
||||
|
||||
[CONSTRAINTS]
|
||||
- 约束1
|
||||
- 约束2
|
||||
- Constraint 1
|
||||
- Constraint 2
|
||||
|
||||
[OUTPUT_FORMAT]
|
||||
1. 执行任务
|
||||
2. 返回 JSON 简要信息
|
||||
1. Execute task
|
||||
2. Return JSON summary information
|
||||
|
||||
[QUALITY_CHECKLIST]
|
||||
- [ ] 输出格式正确
|
||||
- [ ] 内容完整无遗漏
|
||||
- [ ] 无占位符残留
|
||||
- [ ] Output format correct
|
||||
- [ ] Content complete without omission
|
||||
- [ ] No placeholder remnants
|
||||
\`\`\`
|
||||
|
||||
## 变量说明
|
||||
## Variable Description
|
||||
|
||||
| 变量 | 来源 | 示例 |
|
||||
|------|------|------|
|
||||
| {workDir} | 运行时 | .workflow/.scratchpad/${config.skill_name}-xxx |
|
||||
| {output_path} | 配置 | ${config.output.location}/${config.output.filename_pattern} |
|
||||
| Variable | Source | Example |
|
||||
|----------|--------|---------|
|
||||
| {workDir} | Runtime | .workflow/.scratchpad/${config.skill_name}-xxx |
|
||||
| {output_path} | Configuration | ${config.output.location}/${config.output.filename_pattern} |
|
||||
|
||||
## 返回格式
|
||||
## Return Format
|
||||
|
||||
\`\`\`typescript
|
||||
interface AgentReturn {
|
||||
@@ -243,33 +318,30 @@ interface AgentReturn {
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## 角色定义参考
|
||||
## Role Definition Reference
|
||||
|
||||
${config.execution_mode === 'sequential' ?
|
||||
config.sequential_config.phases.map((p, i) =>
|
||||
`- **Phase ${i+1} Agent**: ${p.name} 专家`
|
||||
config.sequential_config.phases.map((p, i) =>
|
||||
`- **Phase ${i+1} Agent**: ${p.name} Expert`
|
||||
).join('\n') :
|
||||
config.autonomous_config.actions.map(a =>
|
||||
`- **${a.name} Agent**: ${a.description || a.name + ' 执行者'}`
|
||||
config.autonomous_config.actions.map(a =>
|
||||
`- **${a.name} Agent**: ${a.description || a.name + ' Executor'}`
|
||||
).join('\n')}
|
||||
`;
|
||||
|
||||
Write(`${skillDir}/templates/agent-base.md`, agentBase);
|
||||
```
|
||||
|
||||
### Step 4: Autonomous 模式 - 动作目录
|
||||
|
||||
```javascript
|
||||
// Step 4: Conditional - Generate action catalog for autonomous/hybrid mode
|
||||
if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') {
|
||||
const actionCatalog = `# Action Catalog
|
||||
|
||||
${config.display_name} 的可用动作目录。
|
||||
Available action catalog for ${config.display_name}.
|
||||
|
||||
## Available Actions
|
||||
|
||||
| Action | Purpose | Preconditions | Effects |
|
||||
|--------|---------|---------------|---------|
|
||||
${config.autonomous_config.actions.map(a =>
|
||||
${config.autonomous_config.actions.map(a =>
|
||||
`| [${a.id}](../phases/actions/${a.id}.md) | ${a.description || a.name} | ${a.preconditions?.join(', ') || '-'} | ${a.effects?.join(', ') || '-'} |`
|
||||
).join('\n')}
|
||||
|
||||
@@ -278,9 +350,9 @@ ${config.autonomous_config.actions.map(a =>
|
||||
\`\`\`mermaid
|
||||
graph TD
|
||||
${config.autonomous_config.actions.map((a, i, arr) => {
|
||||
if (i === 0) return ` ${a.id.replace(/-/g, '_')}[${a.name}]`;
|
||||
if (i === 0) return \` ${a.id.replace(/-/g, '_')}[${a.name}]\`;
|
||||
const prev = arr[i-1];
|
||||
return ` ${prev.id.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]`;
|
||||
return \` ${prev.id.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]\`;
|
||||
}).join('\n')}
|
||||
\`\`\`
|
||||
|
||||
@@ -289,7 +361,7 @@ ${config.autonomous_config.actions.map((a, i, arr) => {
|
||||
| From State | Action | To State |
|
||||
|------------|--------|----------|
|
||||
| pending | action-init | running |
|
||||
${config.autonomous_config.actions.slice(1).map(a =>
|
||||
${config.autonomous_config.actions.slice(1).map(a =>
|
||||
`| running | ${a.id} | running |`
|
||||
).join('\n')}
|
||||
| running | action-complete | completed |
|
||||
@@ -297,32 +369,30 @@ ${config.autonomous_config.actions.slice(1).map(a =>
|
||||
|
||||
## Selection Priority
|
||||
|
||||
当多个动作的前置条件都满足时,按以下优先级选择:
|
||||
When multiple actions' preconditions are met, select based on the following priority:
|
||||
|
||||
${config.autonomous_config.actions.map((a, i) =>
|
||||
`${i + 1}. \`${a.id}\` - ${a.name}`
|
||||
${config.autonomous_config.actions.map((a, i) =>
|
||||
\`${i + 1}. \\\`${a.id}\\\` - ${a.name}\`
|
||||
).join('\n')}
|
||||
`;
|
||||
|
||||
Write(`${skillDir}/specs/action-catalog.md`, actionCatalog);
|
||||
}
|
||||
```
|
||||
|
||||
### Step 5: 辅助函数
|
||||
|
||||
```javascript
|
||||
// Helper function
|
||||
function toPascalCase(str) {
|
||||
return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('');
|
||||
}
|
||||
|
||||
// Phase output summary
|
||||
console.log('Phase 4 complete: Generated specs and templates');
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
- `specs/{skill-name}-requirements.md` - 领域规范
|
||||
- `specs/quality-standards.md` - 质量标准
|
||||
- `specs/action-catalog.md` - 动作目录 (Autonomous 模式)
|
||||
- `templates/agent-base.md` - Agent 模板
|
||||
|
||||
## Next Phase
|
||||
|
||||
→ [Phase 5: Validation](05-validation.md)
|
||||
|
||||
**Data Flow to Phase 5**:
|
||||
- All generated files in `specs/` and `templates/`
|
||||
- skill-config.json for validation reference
|
||||
- Complete skill directory structure ready for final validation
|
||||
|
||||
@@ -1,27 +1,119 @@
|
||||
# Phase 5: Validation & Documentation
|
||||
|
||||
验证生成的 Skill 完整性并生成使用说明。
|
||||
Verify generated skill completeness and generate user documentation.
|
||||
|
||||
## Objective
|
||||
|
||||
- 验证所有必需文件存在
|
||||
- 检查文件内容完整性
|
||||
- 生成 README.md 使用说明
|
||||
- 输出验证报告
|
||||
Comprehensive validation and documentation:
|
||||
- Verify all required files exist
|
||||
- Check file content quality and completeness
|
||||
- Generate validation report with issues and recommendations
|
||||
- Generate README.md usage documentation
|
||||
- Output final status and next steps
|
||||
|
||||
## Input
|
||||
|
||||
- 依赖: 所有前序阶段产出
|
||||
- 生成的 Skill 目录
|
||||
**File Dependencies**:
|
||||
- `skill-config.json` (from Phase 1)
|
||||
- `.claude/skills/{skill-name}/` directory (from Phase 2)
|
||||
- All generated phase/action files (from Phase 3)
|
||||
- All generated specs/templates files (from Phase 4)
|
||||
|
||||
## Execution Steps
|
||||
**Required Information**:
|
||||
- Skill name, display name, description
|
||||
- Execution mode
|
||||
- Trigger words
|
||||
- Output configuration
|
||||
- Complete skill directory structure
|
||||
|
||||
### Step 1: 文件完整性检查
|
||||
## Output
|
||||
|
||||
**Generated Files**:
|
||||
|
||||
| File | Purpose | Content |
|
||||
|------|---------|---------|
|
||||
| `validation-report.json` (workDir) | Validation report with detailed checks | File completeness, content quality, issues, recommendations |
|
||||
| `README.md` (skillDir) | User documentation | Quick Start, Usage, Output, Directory Structure, Customization |
|
||||
|
||||
**Validation Report Structure** (`validation-report.json`):
|
||||
```json
|
||||
{
|
||||
"skill_name": "...",
|
||||
"execution_mode": "sequential|autonomous",
|
||||
"generated_at": "ISO timestamp",
|
||||
"file_checks": {
|
||||
"total": N,
|
||||
"existing": N,
|
||||
"with_content": N,
|
||||
"with_todos": N,
|
||||
"details": [...]
|
||||
},
|
||||
"content_checks": {
|
||||
"files_checked": N,
|
||||
"all_passed": true|false,
|
||||
"details": [...]
|
||||
},
|
||||
"summary": {
|
||||
"status": "PASS|REVIEW|FAIL",
|
||||
"issues": [...],
|
||||
"recommendations": [...]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**README Structure** (`README.md`):
|
||||
```markdown
|
||||
# {display_name}
|
||||
- Quick Start (Triggers, Execution Mode)
|
||||
- Usage (Examples)
|
||||
- Output (Format, Location, Filename)
|
||||
- Directory Structure (Tree view)
|
||||
- Customization (How to modify)
|
||||
- Related Documents (Links)
|
||||
```
|
||||
|
||||
**Validation Status Gates**:
|
||||
|
||||
| Status | Condition | Meaning |
|
||||
|--------|-----------|---------|
|
||||
| PASS | All files exist + All content checks passed | Ready for use |
|
||||
| REVIEW | All files exist + Some content checks failed | Needs refinement |
|
||||
| FAIL | Missing files | Incomplete generation |
|
||||
|
||||
## Decision Logic
|
||||
|
||||
```
|
||||
Decision (Validation Flow):
|
||||
├─ File Completeness Check
|
||||
│ ├─ All files exist → Continue to content checks
|
||||
│ └─ Missing files → Status = FAIL, collect missing file errors
|
||||
│
|
||||
├─ Content Quality Check
|
||||
│ ├─ Sequential mode → Check phase files for structure
|
||||
│ ├─ Autonomous mode → Check orchestrator + action files
|
||||
│ └─ Common → Check SKILL.md, specs/, templates/
|
||||
│
|
||||
├─ Status Calculation
|
||||
│ ├─ All files exist + All checks pass → Status = PASS
|
||||
│ ├─ All files exist + Some checks fail → Status = REVIEW
|
||||
│ └─ Missing files → Status = FAIL
|
||||
│
|
||||
└─ Generate Report & README
|
||||
├─ validation-report.json (with issues and recommendations)
|
||||
└─ README.md (with usage documentation)
|
||||
```
|
||||
|
||||
## Execution Protocol
|
||||
|
||||
```javascript
|
||||
// Phase 5: Validation & Documentation
|
||||
// Reference: phases/05-validation.md
|
||||
|
||||
// Load config and setup
|
||||
const config = JSON.parse(Read(`${workDir}/skill-config.json`));
|
||||
const skillDir = `.claude/skills/${config.skill_name}`;
|
||||
|
||||
// Step 1: File completeness check
|
||||
const requiredFiles = {
|
||||
common: [
|
||||
'SKILL.md',
|
||||
@@ -64,14 +156,11 @@ const fileCheckResults = filesToCheck.map(file => {
|
||||
};
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Step 2: 内容质量检查
|
||||
|
||||
```javascript
|
||||
// Step 2: Content quality check
|
||||
const contentChecks = [];
|
||||
|
||||
// 检查 SKILL.md
|
||||
// Check SKILL.md structure
|
||||
const skillMd = Read(`${skillDir}/SKILL.md`);
|
||||
contentChecks.push({
|
||||
file: 'SKILL.md',
|
||||
@@ -83,11 +172,11 @@ contentChecks.push({
|
||||
]
|
||||
});
|
||||
|
||||
// 检查 Phase 文件
|
||||
// Check phase files
|
||||
const phaseFiles = Glob(`${skillDir}/phases/*.md`);
|
||||
for (const phaseFile of phaseFiles) {
|
||||
if (phaseFile.includes('/actions/')) continue; // 单独检查
|
||||
|
||||
if (phaseFile.includes('/actions/')) continue; // Check separately
|
||||
|
||||
const content = Read(phaseFile);
|
||||
contentChecks.push({
|
||||
file: phaseFile.replace(skillDir + '/', ''),
|
||||
@@ -100,7 +189,7 @@ for (const phaseFile of phaseFiles) {
|
||||
});
|
||||
}
|
||||
|
||||
// 检查 Specs 文件
|
||||
// Check specs files
|
||||
const specFiles = Glob(`${skillDir}/specs/*.md`);
|
||||
for (const specFile of specFiles) {
|
||||
const content = Read(specFile);
|
||||
@@ -113,16 +202,13 @@ for (const specFile of specFiles) {
|
||||
]
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: 生成验证报告
|
||||
|
||||
```javascript
|
||||
// Step 3: Generate validation report
|
||||
const report = {
|
||||
skill_name: config.skill_name,
|
||||
execution_mode: config.execution_mode,
|
||||
generated_at: new Date().toISOString(),
|
||||
|
||||
|
||||
file_checks: {
|
||||
total: fileCheckResults.length,
|
||||
existing: fileCheckResults.filter(f => f.exists).length,
|
||||
@@ -130,13 +216,13 @@ const report = {
|
||||
with_todos: fileCheckResults.filter(f => f.hasTodo).length,
|
||||
details: fileCheckResults
|
||||
},
|
||||
|
||||
|
||||
content_checks: {
|
||||
files_checked: contentChecks.length,
|
||||
all_passed: contentChecks.every(c => c.checks.every(ch => ch.pass)),
|
||||
details: contentChecks
|
||||
},
|
||||
|
||||
|
||||
summary: {
|
||||
status: calculateOverallStatus(fileCheckResults, contentChecks),
|
||||
issues: collectIssues(fileCheckResults, contentChecks),
|
||||
@@ -146,10 +232,11 @@ const report = {
|
||||
|
||||
Write(`${workDir}/validation-report.json`, JSON.stringify(report, null, 2));
|
||||
|
||||
// Helper functions
|
||||
function calculateOverallStatus(fileResults, contentResults) {
|
||||
const allFilesExist = fileResults.every(f => f.exists);
|
||||
const allContentPassed = contentResults.every(c => c.checks.every(ch => ch.pass));
|
||||
|
||||
|
||||
if (allFilesExist && allContentPassed) return 'PASS';
|
||||
if (allFilesExist) return 'REVIEW';
|
||||
return 'FAIL';
|
||||
@@ -157,125 +244,122 @@ function calculateOverallStatus(fileResults, contentResults) {
|
||||
|
||||
function collectIssues(fileResults, contentResults) {
|
||||
const issues = [];
|
||||
|
||||
|
||||
fileResults.filter(f => !f.exists).forEach(f => {
|
||||
issues.push({ type: 'ERROR', message: `文件缺失: ${f.file}` });
|
||||
issues.push({ type: 'ERROR', message: `Missing file: ${f.file}` });
|
||||
});
|
||||
|
||||
|
||||
fileResults.filter(f => f.hasTodo).forEach(f => {
|
||||
issues.push({ type: 'WARNING', message: `包含 TODO: ${f.file}` });
|
||||
issues.push({ type: 'WARNING', message: `Contains TODO: ${f.file}` });
|
||||
});
|
||||
|
||||
|
||||
contentResults.forEach(c => {
|
||||
c.checks.filter(ch => !ch.pass).forEach(ch => {
|
||||
issues.push({ type: 'WARNING', message: `${c.file}: 缺少 ${ch.name}` });
|
||||
issues.push({ type: 'WARNING', message: `${c.file}: Missing ${ch.name}` });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
return issues;
|
||||
}
|
||||
|
||||
function generateRecommendations(fileResults, contentResults) {
|
||||
const recommendations = [];
|
||||
|
||||
|
||||
if (fileResults.some(f => f.hasTodo)) {
|
||||
recommendations.push('替换所有 TODO 占位符为实际内容');
|
||||
recommendations.push('Replace all TODO placeholders with actual content');
|
||||
}
|
||||
|
||||
|
||||
contentResults.forEach(c => {
|
||||
if (c.checks.some(ch => !ch.pass)) {
|
||||
recommendations.push(`完善 ${c.file} 的结构`);
|
||||
recommendations.push(`Improve structure of ${c.file}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return recommendations;
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: 生成 README.md
|
||||
|
||||
```javascript
|
||||
// Step 4: Generate README.md
|
||||
const readme = `# ${config.display_name}
|
||||
|
||||
${config.description}
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 触发词
|
||||
### Trigger Words
|
||||
|
||||
${config.triggers.map(t => `- "${t}"`).join('\n')}
|
||||
|
||||
### 执行模式
|
||||
### Execution Mode
|
||||
|
||||
**${config.execution_mode === 'sequential' ? 'Sequential (顺序)' : 'Autonomous (自主)'}**
|
||||
**${config.execution_mode === 'sequential' ? 'Sequential (Sequential)' : 'Autonomous (Autonomous)'}**
|
||||
|
||||
${config.execution_mode === 'sequential' ?
|
||||
`阶段按固定顺序执行:\n${config.sequential_config.phases.map((p, i) =>
|
||||
`${i + 1}. ${p.name}`
|
||||
).join('\n')}` :
|
||||
`动作由编排器动态选择:\n${config.autonomous_config.actions.map(a =>
|
||||
`- ${a.name}: ${a.description || ''}`
|
||||
).join('\n')}`}
|
||||
\`Phases execute in fixed order:\n\${config.sequential_config.phases.map((p, i) =>
|
||||
\`\${i + 1}. \${p.name}\`
|
||||
).join('\n')}\` :
|
||||
\`Actions selected dynamically by orchestrator:\n\${config.autonomous_config.actions.map(a =>
|
||||
\`- \${a.name}: \${a.description || ''}\`
|
||||
).join('\n')}\`}
|
||||
|
||||
## Usage
|
||||
|
||||
\`\`\`
|
||||
# 直接触发
|
||||
用户: ${config.triggers[0]}
|
||||
# Direct trigger
|
||||
User: ${config.triggers[0]}
|
||||
|
||||
# 或使用 Skill 名称
|
||||
用户: /skill ${config.skill_name}
|
||||
# Or use Skill name
|
||||
User: /skill ${config.skill_name}
|
||||
\`\`\`
|
||||
|
||||
## Output
|
||||
|
||||
- **格式**: ${config.output.format}
|
||||
- **位置**: \`${config.output.location}\`
|
||||
- **文件名**: \`${config.output.filename_pattern}\`
|
||||
- **Format**: ${config.output.format}
|
||||
- **Location**: \`${config.output.location}\`
|
||||
- **Filename**: \`${config.output.filename_pattern}\`
|
||||
|
||||
## Directory Structure
|
||||
|
||||
\`\`\`
|
||||
.claude/skills/${config.skill_name}/
|
||||
├── SKILL.md # 入口文件
|
||||
├── phases/ # 执行阶段
|
||||
├── SKILL.md # Entry file
|
||||
├── phases/ # Execution phases
|
||||
${config.execution_mode === 'sequential' ?
|
||||
config.sequential_config.phases.map(p => `│ ├── ${p.id}.md`).join('\n') :
|
||||
`│ ├── orchestrator.md
|
||||
config.sequential_config.phases.map(p => \`│ ├── \${p.id}.md\`).join('\n') :
|
||||
\`│ ├── orchestrator.md
|
||||
│ ├── state-schema.md
|
||||
│ └── actions/
|
||||
${config.autonomous_config.actions.map(a => `│ ├── ${a.id}.md`).join('\n')}`}
|
||||
├── specs/ # 规范文件
|
||||
\${config.autonomous_config.actions.map(a => \`│ ├── \${a.id}.md\`).join('\n')}\`}
|
||||
├── specs/ # Specification files
|
||||
│ ├── ${config.skill_name}-requirements.md
|
||||
│ ├── quality-standards.md
|
||||
${config.execution_mode === 'autonomous' ? '│ └── action-catalog.md' : ''}
|
||||
└── templates/ # 模板文件
|
||||
└── templates/ # Template files
|
||||
└── agent-base.md
|
||||
\`\`\`
|
||||
|
||||
## Customization
|
||||
|
||||
### 修改执行逻辑
|
||||
### Modify Execution Logic
|
||||
|
||||
编辑 \`phases/\` 目录下的阶段文件。
|
||||
Edit phase files in the \`phases/\` directory.
|
||||
|
||||
### 调整质量标准
|
||||
### Adjust Quality Standards
|
||||
|
||||
编辑 \`specs/quality-standards.md\`。
|
||||
Edit \`specs/quality-standards.md\`.
|
||||
|
||||
### 添加新${config.execution_mode === 'sequential' ? '阶段' : '动作'}
|
||||
### Add New ${config.execution_mode === 'sequential' ? 'Phase' : 'Action'}
|
||||
|
||||
${config.execution_mode === 'sequential' ?
|
||||
`1. 在 \`phases/\` 创建新的阶段文件 (如 \`03.5-new-step.md\`)
|
||||
2. 更新 SKILL.md 的执行流程` :
|
||||
`1. 在 \`phases/actions/\` 创建新的动作文件
|
||||
2. 更新 \`specs/action-catalog.md\`
|
||||
3. 在 \`phases/orchestrator.md\` 添加选择逻辑`}
|
||||
\`1. Create new phase file in \`phases/\` (e.g., \`03.5-new-step.md\`)
|
||||
2. Update execution flow in SKILL.md\` :
|
||||
\`1. Create new action file in \`phases/actions/\`
|
||||
2. Update \`specs/action-catalog.md\`
|
||||
3. Add selection logic in \`phases/orchestrator.md\`\`}
|
||||
|
||||
## Related Documents
|
||||
|
||||
- [设计规范](../_shared/SKILL-DESIGN-SPEC.md)
|
||||
- [执行模式规范](specs/../../../skill-generator/specs/execution-modes.md)
|
||||
- [Design Specification](../_shared/SKILL-DESIGN-SPEC.md)
|
||||
- [Execution Modes Specification](specs/../../../skill-generator/specs/execution-modes.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -283,52 +367,51 @@ ${config.execution_mode === 'sequential' ?
|
||||
`;
|
||||
|
||||
Write(`${skillDir}/README.md`, readme);
|
||||
```
|
||||
|
||||
### Step 5: 输出最终结果
|
||||
|
||||
```javascript
|
||||
// Step 5: Output final result
|
||||
const finalResult = {
|
||||
skill_name: config.skill_name,
|
||||
skill_path: skillDir,
|
||||
execution_mode: config.execution_mode,
|
||||
|
||||
|
||||
generated_files: [
|
||||
'SKILL.md',
|
||||
'README.md',
|
||||
...filesToCheck
|
||||
],
|
||||
|
||||
|
||||
validation: report.summary,
|
||||
|
||||
|
||||
next_steps: [
|
||||
'1. 审阅生成的文件结构',
|
||||
'2. 替换 TODO 占位符',
|
||||
'3. 根据实际需求调整阶段逻辑',
|
||||
'4. 测试 Skill 执行流程',
|
||||
'5. 更新触发词和描述'
|
||||
'1. Review generated file structure',
|
||||
'2. Replace TODO placeholders',
|
||||
'3. Adjust phase logic based on actual requirements',
|
||||
'4. Test Skill execution flow',
|
||||
'5. Update trigger words and descriptions'
|
||||
]
|
||||
};
|
||||
|
||||
console.log('=== Skill 生成完成 ===');
|
||||
console.log(`路径: ${skillDir}`);
|
||||
console.log(`模式: ${config.execution_mode}`);
|
||||
console.log(`状态: ${report.summary.status}`);
|
||||
console.log('=== Skill Generation Complete ===');
|
||||
console.log(\`Path: \${skillDir}\`);
|
||||
console.log(\`Mode: \${config.execution_mode}\`);
|
||||
console.log(\`Status: \${report.summary.status}\`);
|
||||
console.log('');
|
||||
console.log('下一步:');
|
||||
console.log('Next Steps:');
|
||||
finalResult.next_steps.forEach(s => console.log(s));
|
||||
```
|
||||
|
||||
## Output
|
||||
## Workflow Completion
|
||||
|
||||
- `{workDir}/validation-report.json` - 验证报告
|
||||
- `{skillDir}/README.md` - 使用说明
|
||||
**Final Status**: Skill generation pipeline complete
|
||||
|
||||
## Completion
|
||||
**Generated Artifacts**:
|
||||
- Complete skill directory structure in `.claude/skills/{skill-name}/`
|
||||
- Validation report in `{workDir}/validation-report.json`
|
||||
- User documentation in `{skillDir}/README.md`
|
||||
|
||||
Skill 生成流程完成。用户可以:
|
||||
|
||||
1. 查看生成的 Skill 目录
|
||||
2. 根据验证报告修复问题
|
||||
3. 自定义执行逻辑
|
||||
4. 测试 Skill 功能
|
||||
**Next Steps**:
|
||||
1. Review validation report for any issues or recommendations
|
||||
2. Replace TODO placeholders with actual implementation
|
||||
3. Test skill execution with trigger words
|
||||
4. Customize phase logic based on specific requirements
|
||||
5. Update triggers and descriptions as needed
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
# CLI Integration Specification
|
||||
|
||||
CCW CLI 集成规范,定义 Skill 中如何正确调用外部 CLI 工具。
|
||||
CCW CLI integration specification that defines how to properly call external CLI tools within Skills.
|
||||
|
||||
---
|
||||
|
||||
## 执行模式
|
||||
## Execution Modes
|
||||
|
||||
### 1. 同步执行 (Blocking)
|
||||
### 1. Synchronous Execution (Blocking)
|
||||
|
||||
适用于需要立即获取结果的场景。
|
||||
Suitable for scenarios that need immediate results.
|
||||
|
||||
```javascript
|
||||
// Agent 调用 - 同步
|
||||
// Agent call - synchronous
|
||||
const result = Task({
|
||||
subagent_type: 'universal-executor',
|
||||
prompt: '执行任务...',
|
||||
run_in_background: false // 关键: 同步执行
|
||||
prompt: 'Execute task...',
|
||||
run_in_background: false // Key: synchronous execution
|
||||
});
|
||||
|
||||
// 结果立即可用
|
||||
// Result immediately available
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
### 2. 异步执行 (Background)
|
||||
### 2. Asynchronous Execution (Background)
|
||||
|
||||
适用于长时间运行的 CLI 命令。
|
||||
Suitable for long-running CLI commands.
|
||||
|
||||
```javascript
|
||||
// CLI 调用 - 异步
|
||||
// CLI call - asynchronous
|
||||
const task = Bash({
|
||||
command: 'ccw cli -p "..." --tool gemini --mode analysis',
|
||||
run_in_background: true // 关键: 后台执行
|
||||
run_in_background: true // Key: background execution
|
||||
});
|
||||
|
||||
// 立即返回,不等待结果
|
||||
// task.task_id 可用于后续查询
|
||||
// Returns immediately without waiting for result
|
||||
// task.task_id available for later queries
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CCW CLI 调用规范
|
||||
## CCW CLI Call Specification
|
||||
|
||||
### 基础命令结构
|
||||
### Basic Command Structure
|
||||
|
||||
```bash
|
||||
ccw cli -p "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write>
|
||||
```
|
||||
|
||||
### 参数说明
|
||||
### Parameter Description
|
||||
|
||||
| 参数 | 必需 | 说明 |
|
||||
|------|------|------|
|
||||
| `-p "<prompt>"` | ✓ | 提示词(使用双引号) |
|
||||
| `--tool <tool>` | ✓ | 工具选择: gemini, qwen, codex |
|
||||
| `--mode <mode>` | ✓ | 执行模式: analysis, write |
|
||||
| `--cd <path>` | - | 工作目录 |
|
||||
| `--includeDirs <dirs>` | - | 包含额外目录(逗号分隔) |
|
||||
| `--resume [id]` | - | 恢复会话 |
|
||||
| Parameter | Required | Description |
|
||||
|-----------|----------|-------------|
|
||||
| `-p "<prompt>"` | Yes | Prompt text (use double quotes) |
|
||||
| `--tool <tool>` | Yes | Tool selection: gemini, qwen, codex |
|
||||
| `--mode <mode>` | Yes | Execution mode: analysis, write |
|
||||
| `--cd <path>` | - | Working directory |
|
||||
| `--includeDirs <dirs>` | - | Additional directories (comma-separated) |
|
||||
| `--resume [id]` | - | Resume session |
|
||||
|
||||
### 模式选择
|
||||
### Mode Selection
|
||||
|
||||
```
|
||||
┌─ 分析/文档任务?
|
||||
│ └─→ --mode analysis (只读)
|
||||
│
|
||||
└─ 实现/修改任务?
|
||||
└─→ --mode write (读写)
|
||||
- Analysis/Documentation tasks?
|
||||
→ --mode analysis (read-only)
|
||||
|
||||
- Implementation/Modification tasks?
|
||||
→ --mode write (read-write)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Agent 类型与选择
|
||||
## Agent Types and Selection
|
||||
|
||||
### universal-executor
|
||||
|
||||
通用执行器,最常用的 Agent 类型。
|
||||
General-purpose executor, the most commonly used agent type.
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: 'universal-executor',
|
||||
prompt: `
|
||||
执行任务:
|
||||
1. 读取配置文件
|
||||
2. 分析依赖关系
|
||||
3. 生成报告到 ${outputPath}
|
||||
Execute task:
|
||||
1. Read configuration file
|
||||
2. Analyze dependencies
|
||||
3. Generate report to ${outputPath}
|
||||
`,
|
||||
run_in_background: false
|
||||
});
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 多步骤任务执行
|
||||
- 文件操作(读/写/编辑)
|
||||
- 需要工具调用的任务
|
||||
**Applicable Scenarios**:
|
||||
- Multi-step task execution
|
||||
- File operations (read/write/edit)
|
||||
- Tasks that require tool invocation
|
||||
|
||||
### Explore
|
||||
|
||||
代码探索 Agent,快速理解代码库。
|
||||
Code exploration agent for quick codebase understanding.
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: 'Explore',
|
||||
prompt: `
|
||||
探索 src/ 目录:
|
||||
- 识别主要模块
|
||||
- 理解目录结构
|
||||
- 找到入口点
|
||||
Explore src/ directory:
|
||||
- Identify main modules
|
||||
- Understand directory structure
|
||||
- Find entry points
|
||||
|
||||
Thoroughness: medium
|
||||
`,
|
||||
@@ -113,104 +113,104 @@ Thoroughness: medium
|
||||
});
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 代码库探索
|
||||
- 文件发现
|
||||
- 结构理解
|
||||
**Applicable Scenarios**:
|
||||
- Codebase exploration
|
||||
- File discovery
|
||||
- Structure understanding
|
||||
|
||||
### cli-explore-agent
|
||||
|
||||
深度代码分析 Agent。
|
||||
Deep code analysis agent.
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: 'cli-explore-agent',
|
||||
prompt: `
|
||||
深度分析 src/auth/ 模块:
|
||||
- 认证流程
|
||||
- 会话管理
|
||||
- 安全机制
|
||||
Deep analysis of src/auth/ module:
|
||||
- Authentication flow
|
||||
- Session management
|
||||
- Security mechanisms
|
||||
`,
|
||||
run_in_background: false
|
||||
});
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 深度代码理解
|
||||
- 设计模式识别
|
||||
- 复杂逻辑分析
|
||||
**Applicable Scenarios**:
|
||||
- Deep code understanding
|
||||
- Design pattern identification
|
||||
- Complex logic analysis
|
||||
|
||||
---
|
||||
|
||||
## 会话管理
|
||||
## Session Management
|
||||
|
||||
### 会话恢复
|
||||
### Session Recovery
|
||||
|
||||
```javascript
|
||||
// 保存会话 ID
|
||||
// Save session ID
|
||||
const session = Bash({
|
||||
command: 'ccw cli -p "初始分析..." --tool gemini --mode analysis',
|
||||
command: 'ccw cli -p "Initial analysis..." --tool gemini --mode analysis',
|
||||
run_in_background: true
|
||||
});
|
||||
|
||||
// 后续恢复
|
||||
// Resume later
|
||||
const continuation = Bash({
|
||||
command: `ccw cli -p "继续分析..." --tool gemini --mode analysis --resume ${session.id}`,
|
||||
command: `ccw cli -p "Continue analysis..." --tool gemini --mode analysis --resume ${session.id}`,
|
||||
run_in_background: true
|
||||
});
|
||||
```
|
||||
|
||||
### 多会话合并
|
||||
### Multi-Session Merge
|
||||
|
||||
```javascript
|
||||
// 合并多个会话的上下文
|
||||
// Merge context from multiple sessions
|
||||
const merged = Bash({
|
||||
command: `ccw cli -p "汇总分析..." --tool gemini --mode analysis --resume ${id1},${id2}`,
|
||||
command: `ccw cli -p "Aggregate analysis..." --tool gemini --mode analysis --resume ${id1},${id2}`,
|
||||
run_in_background: true
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Skill 中的 CLI 集成模式
|
||||
## CLI Integration Patterns in Skills
|
||||
|
||||
### 模式 1: 单次调用
|
||||
### Pattern 1: Single Call
|
||||
|
||||
简单任务,一次调用完成。
|
||||
Simple tasks completed in one call.
|
||||
|
||||
```javascript
|
||||
// Phase 执行
|
||||
// Phase execution
|
||||
async function executePhase(context) {
|
||||
const result = Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: 分析项目结构
|
||||
TASK: 识别模块、依赖、入口点
|
||||
PURPOSE: Analyze project structure
|
||||
TASK: Identify modules, dependencies, entry points
|
||||
MODE: analysis
|
||||
CONTEXT: @src/**/*
|
||||
EXPECTED: JSON 格式的结构报告
|
||||
EXPECTED: JSON format structure report
|
||||
" --tool gemini --mode analysis --cd ${context.projectRoot}`,
|
||||
run_in_background: true,
|
||||
timeout: 600000
|
||||
});
|
||||
|
||||
// 等待完成
|
||||
// Wait for completion
|
||||
return await waitForCompletion(result.task_id);
|
||||
}
|
||||
```
|
||||
|
||||
### 模式 2: 链式调用
|
||||
### Pattern 2: Chained Calls
|
||||
|
||||
多步骤任务,每步依赖前一步结果。
|
||||
Multi-step tasks where each step depends on previous results.
|
||||
|
||||
```javascript
|
||||
async function executeChain(context) {
|
||||
// Step 1: 收集
|
||||
// Step 1: Collect
|
||||
const collectId = await runCLI('collect', context);
|
||||
|
||||
// Step 2: 分析 (依赖 Step 1)
|
||||
// Step 2: Analyze (depends on Step 1)
|
||||
const analyzeId = await runCLI('analyze', context, `--resume ${collectId}`);
|
||||
|
||||
// Step 3: 生成 (依赖 Step 2)
|
||||
// Step 3: Generate (depends on Step 2)
|
||||
const generateId = await runCLI('generate', context, `--resume ${analyzeId}`);
|
||||
|
||||
return generateId;
|
||||
@@ -218,9 +218,9 @@ async function executeChain(context) {
|
||||
|
||||
async function runCLI(step, context, resumeFlag = '') {
|
||||
const prompts = {
|
||||
collect: 'PURPOSE: 收集代码文件...',
|
||||
analyze: 'PURPOSE: 分析代码模式...',
|
||||
generate: 'PURPOSE: 生成文档...'
|
||||
collect: 'PURPOSE: Collect code files...',
|
||||
analyze: 'PURPOSE: Analyze code patterns...',
|
||||
generate: 'PURPOSE: Generate documentation...'
|
||||
};
|
||||
|
||||
const result = Bash({
|
||||
@@ -232,9 +232,9 @@ async function runCLI(step, context, resumeFlag = '') {
|
||||
}
|
||||
```
|
||||
|
||||
### 模式 3: 并行调用
|
||||
### Pattern 3: Parallel Calls
|
||||
|
||||
独立任务并行执行。
|
||||
Independent tasks executed in parallel.
|
||||
|
||||
```javascript
|
||||
async function executeParallel(context) {
|
||||
@@ -244,15 +244,15 @@ async function executeParallel(context) {
|
||||
{ type: 'patterns', tool: 'qwen' }
|
||||
];
|
||||
|
||||
// 并行启动
|
||||
// Start tasks in parallel
|
||||
const taskIds = tasks.map(task =>
|
||||
Bash({
|
||||
command: `ccw cli -p "分析 ${task.type}..." --tool ${task.tool} --mode analysis`,
|
||||
command: `ccw cli -p "Analyze ${task.type}..." --tool ${task.tool} --mode analysis`,
|
||||
run_in_background: true
|
||||
}).task_id
|
||||
);
|
||||
|
||||
// 等待全部完成
|
||||
// Wait for all to complete
|
||||
const results = await Promise.all(
|
||||
taskIds.map(id => waitForCompletion(id))
|
||||
);
|
||||
@@ -261,9 +261,9 @@ async function executeParallel(context) {
|
||||
}
|
||||
```
|
||||
|
||||
### 模式 4: Fallback 链
|
||||
### Pattern 4: Fallback Chain
|
||||
|
||||
工具失败时自动切换。
|
||||
Automatically switch tools on failure.
|
||||
|
||||
```javascript
|
||||
async function executeWithFallback(context) {
|
||||
@@ -299,9 +299,9 @@ async function runWithTool(tool, context) {
|
||||
|
||||
---
|
||||
|
||||
## 提示词模板集成
|
||||
## Prompt Template Integration
|
||||
|
||||
### 引用协议模板
|
||||
### Reference Protocol Templates
|
||||
|
||||
```bash
|
||||
# Analysis mode - use --rule to auto-load protocol and template (appended to prompt)
|
||||
@@ -315,7 +315,7 @@ CONSTRAINTS: ...
|
||||
..." --tool codex --mode write --rule development-feature
|
||||
```
|
||||
|
||||
### 动态模板构建
|
||||
### Dynamic Template Building
|
||||
|
||||
```javascript
|
||||
function buildPrompt(config) {
|
||||
@@ -334,21 +334,21 @@ CONSTRAINTS: ${constraints || ''}
|
||||
|
||||
---
|
||||
|
||||
## 超时配置
|
||||
## Timeout Configuration
|
||||
|
||||
### 推荐超时值
|
||||
### Recommended Timeout Values
|
||||
|
||||
| 任务类型 | 超时 (ms) | 说明 |
|
||||
|---------|----------|------|
|
||||
| 快速分析 | 300000 | 5 分钟 |
|
||||
| 标准分析 | 600000 | 10 分钟 |
|
||||
| 深度分析 | 1200000 | 20 分钟 |
|
||||
| 代码生成 | 1800000 | 30 分钟 |
|
||||
| 复杂任务 | 3600000 | 60 分钟 |
|
||||
| Task Type | Timeout (ms) | Description |
|
||||
|-----------|--------------|-------------|
|
||||
| Quick analysis | 300000 | 5 minutes |
|
||||
| Standard analysis | 600000 | 10 minutes |
|
||||
| Deep analysis | 1200000 | 20 minutes |
|
||||
| Code generation | 1800000 | 30 minutes |
|
||||
| Complex tasks | 3600000 | 60 minutes |
|
||||
|
||||
### Codex 特殊处理
|
||||
### Special Codex Handling
|
||||
|
||||
Codex 需要更长的超时时间(建议 3x)。
|
||||
Codex requires longer timeout (recommend 3x).
|
||||
|
||||
```javascript
|
||||
const timeout = tool === 'codex' ? baseTimeout * 3 : baseTimeout;
|
||||
@@ -362,17 +362,17 @@ Bash({
|
||||
|
||||
---
|
||||
|
||||
## 错误处理
|
||||
## Error Handling
|
||||
|
||||
### 常见错误
|
||||
### Common Errors
|
||||
|
||||
| 错误 | 原因 | 处理 |
|
||||
|------|------|------|
|
||||
| ETIMEDOUT | 网络超时 | 重试或切换工具 |
|
||||
| Exit code 1 | 命令执行失败 | 检查参数,切换工具 |
|
||||
| Context overflow | 上下文过大 | 减少输入范围 |
|
||||
| Error | Cause | Handler |
|
||||
|-------|-------|---------|
|
||||
| ETIMEDOUT | Network timeout | Retry or switch tool |
|
||||
| Exit code 1 | Command execution failed | Check parameters, switch tool |
|
||||
| Context overflow | Input context too large | Reduce input scope |
|
||||
|
||||
### 重试策略
|
||||
### Retry Strategy
|
||||
|
||||
```javascript
|
||||
async function executeWithRetry(command, maxRetries = 3) {
|
||||
@@ -391,7 +391,7 @@ async function executeWithRetry(command, maxRetries = 3) {
|
||||
lastError = error;
|
||||
console.log(`Attempt ${attempt} failed: ${error.message}`);
|
||||
|
||||
// 指数退避
|
||||
// Exponential backoff
|
||||
if (attempt < maxRetries) {
|
||||
await sleep(Math.pow(2, attempt) * 1000);
|
||||
}
|
||||
@@ -404,30 +404,30 @@ async function executeWithRetry(command, maxRetries = 3) {
|
||||
|
||||
---
|
||||
|
||||
## 最佳实践
|
||||
## Best Practices
|
||||
|
||||
### 1. run_in_background 规则
|
||||
### 1. run_in_background Rule
|
||||
|
||||
```
|
||||
Agent 调用 (Task):
|
||||
run_in_background: false → 同步,立即获取结果
|
||||
Agent calls (Task):
|
||||
run_in_background: false → Synchronous, get result immediately
|
||||
|
||||
CLI 调用 (Bash + ccw cli):
|
||||
run_in_background: true → 异步,后台执行
|
||||
CLI calls (Bash + ccw cli):
|
||||
run_in_background: true → Asynchronous, run in background
|
||||
```
|
||||
|
||||
### 2. 工具选择
|
||||
### 2. Tool Selection
|
||||
|
||||
```
|
||||
分析任务: gemini > qwen
|
||||
生成任务: codex > gemini > qwen
|
||||
代码修改: codex > gemini
|
||||
Analysis tasks: gemini > qwen
|
||||
Generation tasks: codex > gemini > qwen
|
||||
Code modification: codex > gemini
|
||||
```
|
||||
|
||||
### 3. 会话管理
|
||||
### 3. Session Management
|
||||
|
||||
- 相关任务使用 `--resume` 保持上下文
|
||||
- 独立任务不使用 `--resume`
|
||||
- Use `--resume` for related tasks to maintain context
|
||||
- Do not use `--resume` for independent tasks
|
||||
|
||||
### 4. Prompt Specification
|
||||
|
||||
@@ -435,8 +435,8 @@ CLI 调用 (Bash + ccw cli):
|
||||
- Use `--rule <template>` to auto-append protocol + template to prompt
|
||||
- Template name format: `category-function` (e.g., `analysis-code-patterns`)
|
||||
|
||||
### 5. 结果处理
|
||||
### 5. Result Processing
|
||||
|
||||
- 持久化重要结果到 workDir
|
||||
- Brief returns: 路径 + 摘要,避免上下文溢出
|
||||
- JSON 格式便于后续处理
|
||||
- Persist important results to workDir
|
||||
- Brief returns: path + summary, avoid context overflow
|
||||
- JSON format convenient for downstream processing
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
# Execution Modes Specification
|
||||
|
||||
两种 Skill 执行模式的详细规范定义。
|
||||
Detailed specification definitions for two Skill execution modes.
|
||||
|
||||
---
|
||||
|
||||
## 模式概览
|
||||
## Mode Overview
|
||||
|
||||
| 特性 | Sequential (顺序) | Autonomous (自主) |
|
||||
|------|-------------------|-------------------|
|
||||
| 执行顺序 | 固定(数字前缀) | 动态(编排器决策) |
|
||||
| 阶段依赖 | 强依赖 | 弱依赖/无依赖 |
|
||||
| 状态管理 | 隐式(阶段产出) | 显式(状态文件) |
|
||||
| 适用场景 | 流水线任务 | 交互式任务 |
|
||||
| 复杂度 | 低 | 中-高 |
|
||||
| 可扩展性 | 插入子阶段 | 添加新动作 |
|
||||
| Feature | Sequential (Fixed Order) | Autonomous (Dynamic) |
|
||||
|---------|--------------------------|----------------------|
|
||||
| Execution Order | Fixed (numeric prefix) | Dynamic (orchestrator decision) |
|
||||
| Phase Dependencies | Strong dependencies | Weak/no dependencies |
|
||||
| State Management | Implicit (phase output) | Explicit (state file) |
|
||||
| Use Cases | Pipeline tasks | Interactive tasks |
|
||||
| Complexity | Low | Medium-High |
|
||||
| Extensibility | Insert sub-phases | Add new actions |
|
||||
|
||||
---
|
||||
|
||||
## Mode 1: Sequential (顺序模式)
|
||||
## Mode 1: Sequential (Fixed Order Mode)
|
||||
|
||||
### 定义
|
||||
### Definition
|
||||
|
||||
阶段按固定顺序线性执行,每个阶段的输出作为下一阶段的输入。
|
||||
Phases execute linearly in fixed order, with each phase's output serving as input to the next phase.
|
||||
|
||||
### 目录结构
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
phases/
|
||||
├── 01-{first-step}.md
|
||||
├── 02-{second-step}.md
|
||||
├── 02.5-{sub-step}.md # 可选:子阶段
|
||||
├── 02.5-{sub-step}.md # Optional: sub-phase
|
||||
├── 03-{third-step}.md
|
||||
└── ...
|
||||
```
|
||||
|
||||
### 执行流程
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
┌─────────┐ ┌─────────┐ ┌─────────┐
|
||||
@@ -45,33 +45,33 @@ phases/
|
||||
output1.json output2.md output3.md
|
||||
```
|
||||
|
||||
### Phase 文件规范
|
||||
### Phase File Specification
|
||||
|
||||
```markdown
|
||||
# Phase N: {阶段名称}
|
||||
# Phase N: {Phase Name}
|
||||
|
||||
{一句话描述}
|
||||
{One-sentence description}
|
||||
|
||||
## Objective
|
||||
|
||||
{详细目标}
|
||||
{Detailed objective}
|
||||
|
||||
## Input
|
||||
|
||||
- 依赖: {上一阶段产出}
|
||||
- 配置: {配置文件}
|
||||
- Dependencies: {Previous phase output}
|
||||
- Configuration: {Configuration file}
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: {步骤}
|
||||
{执行代码或说明}
|
||||
### Step 1: {Step}
|
||||
{Execution code or description}
|
||||
|
||||
### Step 2: {步骤}
|
||||
{执行代码或说明}
|
||||
### Step 2: {Step}
|
||||
{Execution code or description}
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `{输出文件}`
|
||||
- **File**: `{Output file}`
|
||||
- **Format**: {JSON/Markdown}
|
||||
|
||||
## Next Phase
|
||||
@@ -79,74 +79,74 @@ phases/
|
||||
→ [Phase N+1: xxx](0N+1-xxx.md)
|
||||
```
|
||||
|
||||
### 适用场景
|
||||
### Applicable Scenarios
|
||||
|
||||
- **文档生成**: 收集 → 分析 → 组装 → 优化
|
||||
- **代码分析**: 扫描 → 解析 → 报告
|
||||
- **数据处理**: 提取 → 转换 → 加载
|
||||
- **Document Generation**: Collect → Analyze → Assemble → Optimize
|
||||
- **Code Analysis**: Scan → Parse → Report
|
||||
- **Data Processing**: Extract → Transform → Load
|
||||
|
||||
### 优点
|
||||
### Advantages
|
||||
|
||||
- 逻辑清晰,易于理解
|
||||
- 调试简单,可逐阶段验证
|
||||
- 输出可预测
|
||||
- Clear logic, easy to understand
|
||||
- Simple debugging, can validate phase by phase
|
||||
- Predictable output
|
||||
|
||||
### 缺点
|
||||
### Disadvantages
|
||||
|
||||
- 灵活性低
|
||||
- 难以处理分支逻辑
|
||||
- 用户交互受限
|
||||
- Low flexibility
|
||||
- Difficult to handle branching logic
|
||||
- Limited user interaction
|
||||
|
||||
---
|
||||
|
||||
## Mode 2: Autonomous (自主模式)
|
||||
## Mode 2: Autonomous (Dynamic Mode)
|
||||
|
||||
### 定义
|
||||
### Definition
|
||||
|
||||
无固定执行顺序,由编排器 (Orchestrator) 根据当前状态动态选择下一个动作。
|
||||
No fixed execution order. The orchestrator dynamically selects the next action based on current state.
|
||||
|
||||
### 目录结构
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
phases/
|
||||
├── orchestrator.md # 编排器:核心决策逻辑
|
||||
├── state-schema.md # 状态结构定义
|
||||
└── actions/ # 独立动作(无顺序)
|
||||
├── orchestrator.md # Orchestrator: core decision logic
|
||||
├── state-schema.md # State structure definition
|
||||
└── actions/ # Independent actions (no order)
|
||||
├── action-{a}.md
|
||||
├── action-{b}.md
|
||||
├── action-{c}.md
|
||||
└── ...
|
||||
```
|
||||
|
||||
### 核心组件
|
||||
### Core Components
|
||||
|
||||
#### 1. Orchestrator (编排器)
|
||||
#### 1. Orchestrator
|
||||
|
||||
```markdown
|
||||
# Orchestrator
|
||||
|
||||
## Role
|
||||
|
||||
根据当前状态选择并执行下一个动作。
|
||||
Select and execute the next action based on current state.
|
||||
|
||||
## State Reading
|
||||
|
||||
读取状态文件: `{workDir}/state.json`
|
||||
Read state file: `{workDir}/state.json`
|
||||
|
||||
## Decision Logic
|
||||
|
||||
```javascript
|
||||
function selectNextAction(state) {
|
||||
// 1. 检查终止条件
|
||||
// 1. Check termination conditions
|
||||
if (state.status === 'completed') return null;
|
||||
if (state.error_count > MAX_RETRIES) return 'action-abort';
|
||||
|
||||
// 2. 根据状态选择动作
|
||||
|
||||
// 2. Select action based on state
|
||||
if (!state.initialized) return 'action-init';
|
||||
if (state.pending_items.length > 0) return 'action-process';
|
||||
if (state.needs_review) return 'action-review';
|
||||
|
||||
// 3. 默认动作
|
||||
|
||||
// 3. Default action
|
||||
return 'action-complete';
|
||||
}
|
||||
```
|
||||
@@ -158,42 +158,42 @@ while (true) {
|
||||
state = readState();
|
||||
action = selectNextAction(state);
|
||||
if (!action) break;
|
||||
|
||||
|
||||
result = executeAction(action, state);
|
||||
updateState(result);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
#### 2. State Schema (状态结构)
|
||||
#### 2. State Schema
|
||||
|
||||
```markdown
|
||||
# State Schema
|
||||
|
||||
## 状态文件
|
||||
## State File
|
||||
|
||||
位置: `{workDir}/state.json`
|
||||
Location: `{workDir}/state.json`
|
||||
|
||||
## 结构定义
|
||||
## Structure Definition
|
||||
|
||||
```typescript
|
||||
interface SkillState {
|
||||
// 元信息
|
||||
// Metadata
|
||||
skill_name: string;
|
||||
started_at: string;
|
||||
updated_at: string;
|
||||
|
||||
// 执行状态
|
||||
|
||||
// Execution state
|
||||
status: 'pending' | 'running' | 'completed' | 'failed';
|
||||
current_action: string | null;
|
||||
completed_actions: string[];
|
||||
|
||||
// 业务数据
|
||||
|
||||
// Business data
|
||||
context: Record<string, any>;
|
||||
pending_items: any[];
|
||||
results: Record<string, any>;
|
||||
|
||||
// 错误追踪
|
||||
|
||||
// Error tracking
|
||||
errors: Array<{
|
||||
action: string;
|
||||
message: string;
|
||||
@@ -203,7 +203,7 @@ interface SkillState {
|
||||
}
|
||||
```
|
||||
|
||||
## 初始状态
|
||||
## Initial State
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -222,23 +222,23 @@ interface SkillState {
|
||||
```
|
||||
```
|
||||
|
||||
#### 3. Action (动作)
|
||||
#### 3. Action
|
||||
|
||||
```markdown
|
||||
# Action: {action-name}
|
||||
|
||||
## Purpose
|
||||
|
||||
{动作目的}
|
||||
{Action purpose}
|
||||
|
||||
## Preconditions
|
||||
|
||||
- [ ] 条件1
|
||||
- [ ] 条件2
|
||||
- [ ] Condition 1
|
||||
- [ ] Condition 2
|
||||
|
||||
## Execution
|
||||
|
||||
{执行逻辑}
|
||||
{Execution logic}
|
||||
|
||||
## State Updates
|
||||
|
||||
@@ -247,19 +247,19 @@ return {
|
||||
completed_actions: [...state.completed_actions, 'action-name'],
|
||||
results: {
|
||||
...state.results,
|
||||
action_name: { /* 结果 */ }
|
||||
action_name: { /* result */ }
|
||||
},
|
||||
// 其他状态更新
|
||||
// Other state updates
|
||||
};
|
||||
```
|
||||
|
||||
## Next Actions (Hints)
|
||||
|
||||
- 成功时: `action-{next}`
|
||||
- 失败时: `action-retry` 或 `action-abort`
|
||||
- On success: `action-{next}`
|
||||
- On failure: `action-retry` or `action-abort`
|
||||
```
|
||||
|
||||
### 执行流程
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
@@ -289,9 +289,9 @@ return {
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 动作目录 (Action Catalog)
|
||||
### Action Catalog
|
||||
|
||||
在 `specs/action-catalog.md` 中定义:
|
||||
Defined in `specs/action-catalog.md`:
|
||||
|
||||
```markdown
|
||||
# Action Catalog
|
||||
@@ -300,11 +300,11 @@ return {
|
||||
|
||||
| Action | Purpose | Preconditions | Effects |
|
||||
|--------|---------|---------------|---------|
|
||||
| action-init | 初始化状态 | status=pending | status=running |
|
||||
| action-process | 处理待办项 | pending_items.length>0 | pending_items-- |
|
||||
| action-review | 用户审核 | needs_review=true | needs_review=false |
|
||||
| action-complete | 完成任务 | pending_items.length=0 | status=completed |
|
||||
| action-abort | 中止任务 | error_count>MAX | status=failed |
|
||||
| action-init | Initialize state | status=pending | status=running |
|
||||
| action-process | Process pending items | pending_items.length>0 | pending_items-- |
|
||||
| action-review | User review | needs_review=true | needs_review=false |
|
||||
| action-complete | Complete task | pending_items.length=0 | status=completed |
|
||||
| action-abort | Abort task | error_count>MAX | status=failed |
|
||||
|
||||
## Action Dependencies Graph
|
||||
|
||||
@@ -319,78 +319,81 @@ graph TD
|
||||
```
|
||||
```
|
||||
|
||||
### 适用场景
|
||||
### Applicable Scenarios
|
||||
|
||||
- **交互式任务**: 问答、对话、表单填写
|
||||
- **状态机任务**: Issue 管理、工作流审批
|
||||
- **探索式任务**: 调试、诊断、搜索
|
||||
- **Interactive Tasks**: Q&A, dialog, form filling
|
||||
- **State Machine Tasks**: Issue management, workflow approval
|
||||
- **Exploratory Tasks**: Debugging, diagnosis, search
|
||||
|
||||
### 优点
|
||||
### Advantages
|
||||
|
||||
- 高度灵活,适应动态需求
|
||||
- 支持复杂分支逻辑
|
||||
- 易于扩展新动作
|
||||
- Highly flexible, adapts to dynamic requirements
|
||||
- Supports complex branching logic
|
||||
- Easy to extend with new actions
|
||||
|
||||
### 缺点
|
||||
### Disadvantages
|
||||
|
||||
- 复杂度高
|
||||
- 状态管理开销
|
||||
- 调试难度大
|
||||
- High complexity
|
||||
- State management overhead
|
||||
- Large debugging difficulty
|
||||
|
||||
---
|
||||
|
||||
## 模式选择指南
|
||||
## Mode Selection Guide
|
||||
|
||||
### 决策流程
|
||||
### Decision Flow
|
||||
|
||||
```
|
||||
用户需求分析
|
||||
Analyze user requirements
|
||||
│
|
||||
▼
|
||||
┌────────────────────────────┐
|
||||
│ 阶段间是否有强依赖关系? │
|
||||
│ Are there strong │
|
||||
│ dependencies between │
|
||||
│ phases? │
|
||||
└────────────────────────────┘
|
||||
│
|
||||
├── 是 → Sequential
|
||||
├── Yes → Sequential
|
||||
│
|
||||
└── 否 → 继续判断
|
||||
└── No → Continue decision
|
||||
│
|
||||
▼
|
||||
┌────────────────────────────┐
|
||||
│ 是否需要动态响应用户意图? │
|
||||
│ Do you need dynamic │
|
||||
│ response to user intent? │
|
||||
└────────────────────────────┘
|
||||
│
|
||||
├── 是 → Autonomous
|
||||
├── Yes → Autonomous
|
||||
│
|
||||
└── 否 → Sequential
|
||||
└── No → Sequential
|
||||
```
|
||||
|
||||
### 快速判断表
|
||||
### Quick Decision Table
|
||||
|
||||
| 问题 | Sequential | Autonomous |
|
||||
|------|------------|------------|
|
||||
| 输出结构是否固定? | ✓ | ✗ |
|
||||
| 是否需要用户多轮交互? | ✗ | ✓ |
|
||||
| 阶段是否可以跳过/重复? | ✗ | ✓ |
|
||||
| 是否有复杂分支逻辑? | ✗ | ✓ |
|
||||
| 调试是否需要简单? | ✓ | ✗ |
|
||||
| Question | Sequential | Autonomous |
|
||||
|----------|------------|------------|
|
||||
| Is output structure fixed? | Yes | No |
|
||||
| Do you need multi-turn user interaction? | No | Yes |
|
||||
| Can phases be skipped/repeated? | No | Yes |
|
||||
| Is there complex branching logic? | No | Yes |
|
||||
| Should debugging be simple? | Yes | No |
|
||||
|
||||
---
|
||||
|
||||
## 混合模式
|
||||
## Hybrid Mode
|
||||
|
||||
某些复杂 Skill 可能需要混合使用两种模式:
|
||||
Some complex Skills may need to use both modes in combination:
|
||||
|
||||
```
|
||||
phases/
|
||||
├── 01-init.md # Sequential: 初始化
|
||||
├── 02-orchestrator.md # Autonomous: 核心交互循环
|
||||
├── 01-init.md # Sequential: initialization
|
||||
├── 02-orchestrator.md # Autonomous: core interaction loop
|
||||
│ └── actions/
|
||||
│ ├── action-a.md
|
||||
│ └── action-b.md
|
||||
└── 03-finalize.md # Sequential: 收尾
|
||||
└── 03-finalize.md # Sequential: finalization
|
||||
```
|
||||
|
||||
**适用场景**:
|
||||
- 初始化和收尾固定,中间交互灵活
|
||||
- 多阶段任务,某阶段需要动态决策
|
||||
**Applicable Scenarios**:
|
||||
- Initialization and finalization are fixed, middle interaction is flexible
|
||||
- Multi-phase tasks where certain phases need dynamic decisions
|
||||
|
||||
271
.claude/skills/skill-generator/specs/reference-docs-spec.md
Normal file
271
.claude/skills/skill-generator/specs/reference-docs-spec.md
Normal file
@@ -0,0 +1,271 @@
|
||||
# Reference Documents Generation Specification
|
||||
|
||||
> **IMPORTANT**: This specification defines how to organize and present reference documents in generated skills to avoid duplication issues.
|
||||
|
||||
## Core Principles
|
||||
|
||||
### 1. Phase-Based Organization
|
||||
|
||||
Reference documents must be organized by skill execution phases, not as a flat list.
|
||||
|
||||
**Wrong Approach** (Flat List):
|
||||
```markdown
|
||||
## Reference Documents
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| doc1.md | ... |
|
||||
| doc2.md | ... |
|
||||
| doc3.md | ... |
|
||||
```
|
||||
|
||||
**Correct Approach** (Phase-Based Navigation):
|
||||
```markdown
|
||||
## Reference Documents by Phase
|
||||
|
||||
### Phase 1: Analysis
|
||||
Documents to refer to when executing Phase 1
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| doc1.md | ... | Understand concept x |
|
||||
|
||||
### Phase 2: Implementation
|
||||
Documents to refer to when executing Phase 2
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| doc2.md | ... | Implement feature y |
|
||||
```
|
||||
|
||||
### 2. Four Standard Groupings
|
||||
|
||||
Reference documents must be divided into the following four groupings:
|
||||
|
||||
| Grouping | When to Use | Content |
|
||||
|----------|------------|---------|
|
||||
| **Phase N: [Name]** | When executing this phase | All documents related to this phase |
|
||||
| **Debugging** | When encountering problems | Issue to documentation mapping table |
|
||||
| **Reference** | When learning in depth | Templates, original implementations, best practices |
|
||||
| (Optional) **Quick Links** | Quick navigation | Most frequently consulted 5-7 documents |
|
||||
|
||||
### 3. Each Document Entry Must Include
|
||||
|
||||
```
|
||||
| [path](path) | Purpose | When to Use |
|
||||
```
|
||||
|
||||
**When to Use Column Requirements**:
|
||||
- Clear explanation of usage scenarios
|
||||
- Describe what problem is solved
|
||||
- Do not simply say "refer to" or "learn about"
|
||||
|
||||
**Good Examples**:
|
||||
- "Understand issue data structure"
|
||||
- "Learn about the Planning Agent role"
|
||||
- "Check if implementation meets quality standards"
|
||||
- "Quickly locate the reason for status anomalies"
|
||||
|
||||
**Poor Examples**:
|
||||
- "Reference document"
|
||||
- "More information"
|
||||
- "Background knowledge"
|
||||
|
||||
### 4. Embedding Document Guidance in Execution Flow
|
||||
|
||||
In the "Execution Flow" section, each Phase description should include "Refer to" hints:
|
||||
|
||||
```markdown
|
||||
### Phase 2: Planning Pipeline
|
||||
→ **Refer to**: action-plan.md, subagent-roles.md
|
||||
→ Detailed flow description...
|
||||
```
|
||||
|
||||
### 5. Quick Troubleshooting Reference Table
|
||||
|
||||
Should contain common issue to documentation mapping:
|
||||
|
||||
```markdown
|
||||
### Debugging & Troubleshooting
|
||||
|
||||
| Issue | Solution Document |
|
||||
|-------|------------------|
|
||||
| Phase execution failed | Refer to corresponding phase documentation |
|
||||
| Output format incorrect | specs/quality-standards.md |
|
||||
| Data validation failed | specs/schema-validation.md |
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Generation Rules
|
||||
|
||||
### Rule 1: Document Classification Recognition
|
||||
|
||||
Automatically generate groupings based on skill phases:
|
||||
|
||||
```javascript
|
||||
const phaseEmojis = {
|
||||
'discovery': '📋', // Collection, exploration
|
||||
'generation': '🔧', // Generation, creation
|
||||
'analysis': '🔍', // Analysis, review
|
||||
'implementation': '⚙️', // Implementation, execution
|
||||
'validation': '✅', // Validation, testing
|
||||
'completion': '🏁', // Completion, wrap-up
|
||||
};
|
||||
|
||||
// Generate a section for each phase
|
||||
phases.forEach((phase, index) => {
|
||||
const emoji = phaseEmojis[phase.type] || '📌';
|
||||
const title = `### ${emoji} Phase ${index + 1}: ${phase.name}`;
|
||||
// List all documents related to this phase
|
||||
});
|
||||
```
|
||||
|
||||
### Rule 2: Document to Phase Mapping
|
||||
|
||||
In config, specs and templates should be annotated with their belonging phases:
|
||||
|
||||
```json
|
||||
{
|
||||
"specs": [
|
||||
{
|
||||
"path": "specs/issue-handling.md",
|
||||
"purpose": "Issue data specification",
|
||||
"phases": ["phase-2", "phase-3"], // Which phases this spec is related to
|
||||
"context": "Understand issue structure and validation rules"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Rule 3: Priority and Mandatory Reading
|
||||
|
||||
Use visual symbols to distinguish document importance:
|
||||
|
||||
```markdown
|
||||
| Document | When | Notes |
|
||||
|----------|------|-------|
|
||||
| spec.md | **Must Read Before Execution** | Mandatory prerequisite |
|
||||
| action.md | Refer to during execution | Operation guide |
|
||||
| template.md | Reference for learning | Optional in-depth |
|
||||
```
|
||||
|
||||
### Rule 4: Avoid Duplication
|
||||
|
||||
- **Mandatory Prerequisites** section: List mandatory P0 specifications
|
||||
- **Reference Documents by Phase** section: List all documents (including mandatory prerequisites)
|
||||
- Documents in both sections can overlap, but their purposes differ:
|
||||
- Prerequisites: Emphasize "must read first"
|
||||
- Reference: Provide "complete navigation"
|
||||
|
||||
---
|
||||
|
||||
## Implementation Example
|
||||
|
||||
### Sequential Skill Example
|
||||
|
||||
```markdown
|
||||
## Mandatory Prerequisites
|
||||
|
||||
| Document | Purpose | When |
|
||||
|----------|---------|------|
|
||||
| [specs/issue-handling.md](specs/issue-handling.md) | Issue data specification | **Must Read Before Execution** |
|
||||
| [specs/solution-schema.md](specs/solution-schema.md) | Solution structure | **Must Read Before Execution** |
|
||||
|
||||
---
|
||||
|
||||
## Reference Documents by Phase
|
||||
|
||||
### Phase 1: Issue Collection
|
||||
Documents to refer to when executing Phase 1
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/actions/action-list.md](phases/actions/action-list.md) | Issue loading logic | Understand how to collect issues |
|
||||
| [specs/issue-handling.md](specs/issue-handling.md) | Issue data specification | Verify issue format **Required Reading** |
|
||||
|
||||
### Phase 2: Planning
|
||||
Documents to refer to when executing Phase 2
|
||||
|
||||
| Document | Purpose | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| [phases/actions/action-plan.md](phases/actions/action-plan.md) | Planning process | Understand issue to solution transformation |
|
||||
| [specs/solution-schema.md](specs/solution-schema.md) | Solution structure | Verify solution JSON format **Required Reading** |
|
||||
|
||||
### Debugging & Troubleshooting
|
||||
|
||||
| Issue | Solution Document |
|
||||
|-------|------------------|
|
||||
| Phase 1 failed | [phases/actions/action-list.md](phases/actions/action-list.md) |
|
||||
| Planning output incorrect | [phases/actions/action-plan.md](phases/actions/action-plan.md) + [specs/solution-schema.md](specs/solution-schema.md) |
|
||||
| Data validation failed | [specs/issue-handling.md](specs/issue-handling.md) |
|
||||
|
||||
### Reference & Background
|
||||
|
||||
| Document | Purpose | Notes |
|
||||
|----------|---------|-------|
|
||||
| [../issue-plan.md](../../.codex/prompts/issue-plan.md) | Original implementation | Planning Agent system prompt |
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Generation Algorithm
|
||||
|
||||
```javascript
|
||||
function generateReferenceDocuments(config) {
|
||||
let result = '## Reference Documents by Phase\n\n';
|
||||
|
||||
// Generate a section for each phase
|
||||
const phases = config.phases || config.actions || [];
|
||||
|
||||
phases.forEach((phase, index) => {
|
||||
const phaseNum = index + 1;
|
||||
const emoji = getPhaseEmoji(phase.type);
|
||||
const title = phase.display_name || phase.name;
|
||||
|
||||
result += `### ${emoji} Phase ${phaseNum}: ${title}\n`;
|
||||
result += `Documents to refer to when executing Phase ${phaseNum}\n\n`;
|
||||
|
||||
// Find all documents related to this phase
|
||||
const docs = config.specs.filter(spec =>
|
||||
(spec.phases || []).includes(`phase-${phaseNum}`) ||
|
||||
matchesByName(spec.path, phase.name)
|
||||
);
|
||||
|
||||
if (docs.length > 0) {
|
||||
result += '| Document | Purpose | When to Use |\n';
|
||||
result += '|----------|---------|-------------|\n';
|
||||
docs.forEach(doc => {
|
||||
const required = doc.phases && doc.phases[0] === `phase-${phaseNum}` ? ' **Required Reading**' : '';
|
||||
result += `| [${doc.path}](${doc.path}) | ${doc.purpose} | ${doc.context}${required} |\n`;
|
||||
});
|
||||
result += '\n';
|
||||
}
|
||||
});
|
||||
|
||||
// Troubleshooting section
|
||||
result += '### Debugging & Troubleshooting\n\n';
|
||||
result += generateDebuggingTable(config);
|
||||
|
||||
// In-depth reference learning
|
||||
result += '### Reference & Background\n\n';
|
||||
result += generateReferenceTable(config);
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Checklist
|
||||
|
||||
When generating skill's SKILL.md, the reference documents section should satisfy:
|
||||
|
||||
- [ ] Has clear "## Reference Documents by Phase" heading
|
||||
- [ ] Each phase has a corresponding section (identified with symbols)
|
||||
- [ ] Each document entry includes "When to Use" column
|
||||
- [ ] Includes "Debugging & Troubleshooting" section
|
||||
- [ ] Includes "Reference & Background" section
|
||||
- [ ] Mandatory reading documents are marked with **bold** text
|
||||
- [ ] Execution Flow section includes "→ **Refer to**: ..." guidance
|
||||
- [ ] Avoid overly long document lists (maximum 5-8 documents per phase)
|
||||
@@ -1,18 +1,18 @@
|
||||
# Scripting Integration Spec
|
||||
# Scripting Integration Specification
|
||||
|
||||
技能脚本集成规范,定义如何在技能中使用外部脚本执行确定性任务。
|
||||
Skill scripting integration specification that defines how to use external scripts for deterministic task execution.
|
||||
|
||||
## 核心原则
|
||||
## Core Principles
|
||||
|
||||
1. **约定优于配置**:命名即 ID,扩展名即运行时
|
||||
2. **极简调用**:一行完成脚本调用
|
||||
3. **标准输入输出**:命令行参数输入,JSON 标准输出
|
||||
1. **Convention over configuration**: Naming is ID, file extension is runtime
|
||||
2. **Minimal invocation**: Complete script call in one line
|
||||
3. **Standard input/output**: Command-line parameters as input, JSON as standard output
|
||||
|
||||
## 目录结构
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
.claude/skills/<skill-name>/
|
||||
├── scripts/ # 脚本专用目录
|
||||
├── scripts/ # Scripts directory
|
||||
│ ├── process-data.py # id: process-data
|
||||
│ ├── validate-output.sh # id: validate-output
|
||||
│ └── transform-json.js # id: transform-json
|
||||
@@ -20,17 +20,17 @@
|
||||
└── specs/
|
||||
```
|
||||
|
||||
## 命名约定
|
||||
## Naming Conventions
|
||||
|
||||
| 扩展名 | 运行时 | 执行命令 |
|
||||
|--------|--------|----------|
|
||||
| Extension | Runtime | Execution Command |
|
||||
|-----------|---------|-------------------|
|
||||
| `.py` | python | `python scripts/{id}.py` |
|
||||
| `.sh` | bash | `bash scripts/{id}.sh` |
|
||||
| `.js` | node | `node scripts/{id}.js` |
|
||||
|
||||
## 声明格式
|
||||
## Declaration Format
|
||||
|
||||
在 Phase 或 Action 文件的 `## Scripts` 部分声明:
|
||||
Declare in the `## Scripts` section of Phase or Action files:
|
||||
|
||||
```yaml
|
||||
## Scripts
|
||||
@@ -39,27 +39,27 @@
|
||||
- validate-output
|
||||
```
|
||||
|
||||
## 调用语法
|
||||
## Invocation Syntax
|
||||
|
||||
### 基础调用
|
||||
### Basic Call
|
||||
|
||||
```javascript
|
||||
const result = await ExecuteScript('script-id', { key: value });
|
||||
```
|
||||
|
||||
### 参数命名转换
|
||||
### Parameter Name Conversion
|
||||
|
||||
调用时 JS 对象中的键会**自动转换**为 `kebab-case` 命令行参数:
|
||||
Keys in the JS object are **automatically converted** to `kebab-case` command-line parameters:
|
||||
|
||||
| JS 键名 | 转换后参数 |
|
||||
|---------|-----------|
|
||||
| JS Key Name | Converted Parameter |
|
||||
|-------------|-------------------|
|
||||
| `input_path` | `--input-path` |
|
||||
| `output_dir` | `--output-dir` |
|
||||
| `max_count` | `--max-count` |
|
||||
|
||||
脚本中使用 `--input-path` 接收,调用时使用 `input_path` 传入。
|
||||
Use `--input-path` in scripts, pass `input_path` when calling.
|
||||
|
||||
### 完整调用(含错误处理)
|
||||
### Complete Call (with Error Handling)
|
||||
|
||||
```javascript
|
||||
const result = await ExecuteScript('process-data', {
|
||||
@@ -68,46 +68,46 @@ const result = await ExecuteScript('process-data', {
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(`脚本执行失败: ${result.stderr}`);
|
||||
throw new Error(`Script execution failed: ${result.stderr}`);
|
||||
}
|
||||
|
||||
const { output_file, count } = result.outputs;
|
||||
```
|
||||
|
||||
## 返回格式
|
||||
## Return Format
|
||||
|
||||
```typescript
|
||||
interface ScriptResult {
|
||||
success: boolean; // exit code === 0
|
||||
stdout: string; // 完整标准输出
|
||||
stderr: string; // 完整标准错误
|
||||
outputs: { // 从 stdout 最后一行解析的 JSON
|
||||
stdout: string; // Complete standard output
|
||||
stderr: string; // Complete standard error
|
||||
outputs: { // JSON parsed from last line of stdout
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## 脚本编写规范
|
||||
## Script Writing Specification
|
||||
|
||||
### 输入:命令行参数
|
||||
### Input: Command-line Parameters
|
||||
|
||||
```bash
|
||||
# Python: argparse
|
||||
--input-path /path/to/file --threshold 0.9
|
||||
|
||||
# Bash: 手动解析
|
||||
# Bash: manual parsing
|
||||
--input-path /path/to/file
|
||||
```
|
||||
|
||||
### 输出:标准输出 JSON
|
||||
### Output: Standard Output JSON
|
||||
|
||||
脚本最后一行必须打印单行 JSON:
|
||||
Script must print single-line JSON on last line:
|
||||
|
||||
```json
|
||||
{"output_file": "/tmp/result.json", "count": 42}
|
||||
```
|
||||
|
||||
### Python 模板
|
||||
### Python Template
|
||||
|
||||
```python
|
||||
import argparse
|
||||
@@ -119,10 +119,10 @@ def main():
|
||||
parser.add_argument('--threshold', type=float, default=0.9)
|
||||
args = parser.parse_args()
|
||||
|
||||
# 执行逻辑...
|
||||
# Execution logic...
|
||||
result_path = "/tmp/result.json"
|
||||
|
||||
# 输出 JSON
|
||||
# Output JSON
|
||||
print(json.dumps({
|
||||
"output_file": result_path,
|
||||
"items_processed": 100
|
||||
@@ -132,12 +132,12 @@ if __name__ == '__main__':
|
||||
main()
|
||||
```
|
||||
|
||||
### Bash 模板
|
||||
### Bash Template
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# 解析参数
|
||||
# Parse parameters
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--input-path) INPUT_PATH="$2"; shift ;;
|
||||
@@ -146,21 +146,21 @@ while [[ "$#" -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
# 执行逻辑...
|
||||
# Execution logic...
|
||||
LOG_FILE="/tmp/process.log"
|
||||
echo "Processing $INPUT_PATH" > "$LOG_FILE"
|
||||
|
||||
# 输出 JSON
|
||||
# Output JSON
|
||||
echo "{\"log_file\": \"$LOG_FILE\", \"status\": \"done\"}"
|
||||
```
|
||||
|
||||
## ExecuteScript 实现
|
||||
## ExecuteScript Implementation
|
||||
|
||||
```javascript
|
||||
async function ExecuteScript(scriptId, inputs = {}) {
|
||||
const skillDir = GetSkillDir();
|
||||
|
||||
// 查找脚本文件
|
||||
// Find script file
|
||||
const extensions = ['.py', '.sh', '.js'];
|
||||
let scriptPath, runtime;
|
||||
|
||||
@@ -177,22 +177,22 @@ async function ExecuteScript(scriptId, inputs = {}) {
|
||||
throw new Error(`Script not found: ${scriptId}`);
|
||||
}
|
||||
|
||||
// 构建命令行参数
|
||||
// Build command-line parameters
|
||||
const args = Object.entries(inputs)
|
||||
.map(([k, v]) => `--${k.replace(/_/g, '-')} "${v}"`)
|
||||
.join(' ');
|
||||
|
||||
// 执行脚本
|
||||
// Execute script
|
||||
const cmd = `${runtime} "${scriptPath}" ${args}`;
|
||||
const { stdout, stderr, exitCode } = await Bash(cmd);
|
||||
|
||||
// 解析输出
|
||||
// Parse output
|
||||
let outputs = {};
|
||||
try {
|
||||
const lastLine = stdout.trim().split('\n').pop();
|
||||
outputs = JSON.parse(lastLine);
|
||||
} catch (e) {
|
||||
// 无法解析 JSON,保持空对象
|
||||
// Unable to parse JSON, keep empty object
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -204,62 +204,62 @@ async function ExecuteScript(scriptId, inputs = {}) {
|
||||
}
|
||||
```
|
||||
|
||||
## 使用场景
|
||||
## Use Cases
|
||||
|
||||
### 适合脚本化的任务
|
||||
### Suitable for Scripting
|
||||
|
||||
- 数据处理和转换
|
||||
- 文件格式转换
|
||||
- 批量文件操作
|
||||
- 复杂计算逻辑
|
||||
- 调用外部工具/库
|
||||
- Data processing and transformation
|
||||
- File format conversion
|
||||
- Batch file operations
|
||||
- Complex calculation logic
|
||||
- Call external tools/libraries
|
||||
|
||||
### 不适合脚本化的任务
|
||||
### Not Suitable for Scripting
|
||||
|
||||
- 需要用户交互的任务
|
||||
- 需要访问 Claude 工具的任务
|
||||
- 简单的文件读写
|
||||
- 需要动态决策的任务
|
||||
- Tasks requiring user interaction
|
||||
- Tasks needing access to Claude tools
|
||||
- Simple file read/write
|
||||
- Tasks requiring dynamic decision-making
|
||||
|
||||
## 路径约定
|
||||
## Path Conventions
|
||||
|
||||
### 脚本路径
|
||||
### Script Path
|
||||
|
||||
脚本路径相对于 `SKILL.md` 所在目录(技能根目录):
|
||||
Script paths are relative to the directory containing `SKILL.md` (skill root directory):
|
||||
|
||||
```
|
||||
.claude/skills/<skill-name>/ # 技能根目录(SKILL.md 所在位置)
|
||||
.claude/skills/<skill-name>/ # Skill root directory (SKILL.md location)
|
||||
├── SKILL.md
|
||||
├── scripts/ # 脚本目录
|
||||
│ └── process-data.py # 相对路径: scripts/process-data.py
|
||||
├── scripts/ # Scripts directory
|
||||
│ └── process-data.py # Relative path: scripts/process-data.py
|
||||
└── phases/
|
||||
```
|
||||
|
||||
`ExecuteScript` 自动从技能根目录查找脚本:
|
||||
`ExecuteScript` automatically finds scripts from skill root directory:
|
||||
```javascript
|
||||
// 实际执行: python .claude/skills/<skill-name>/scripts/process-data.py
|
||||
// Actually executes: python .claude/skills/<skill-name>/scripts/process-data.py
|
||||
await ExecuteScript('process-data', { ... });
|
||||
```
|
||||
|
||||
### 输出目录
|
||||
### Output Directory
|
||||
|
||||
**推荐**:由调用方传递输出目录,而非脚本默认 `/tmp`:
|
||||
**Recommended**: Pass output directory from caller, not hardcode in script to `/tmp`:
|
||||
|
||||
```javascript
|
||||
// 调用时指定输出目录(在工作流工作目录内)
|
||||
// Specify output directory when calling (in workflow working directory)
|
||||
const result = await ExecuteScript('process-data', {
|
||||
input_path: `${workDir}/data.json`,
|
||||
output_dir: `${workDir}/output` // 明确指定输出位置
|
||||
output_dir: `${workDir}/output` // Explicitly specify output location
|
||||
});
|
||||
```
|
||||
|
||||
脚本应接受 `--output-dir` 参数,而非硬编码输出路径。
|
||||
Scripts should accept `--output-dir` parameter instead of hardcoding output paths.
|
||||
|
||||
## 最佳实践
|
||||
## Best Practices
|
||||
|
||||
1. **单一职责**:每个脚本只做一件事
|
||||
2. **无副作用**:脚本不应修改全局状态
|
||||
3. **幂等性**:相同输入产生相同输出
|
||||
4. **错误明确**:错误信息写入 stderr,正常输出写入 stdout
|
||||
5. **快速失败**:参数验证失败立即退出
|
||||
6. **路径参数化**:输出路径由调用方指定,不硬编码
|
||||
1. **Single Responsibility**: Each script does one thing
|
||||
2. **No Side Effects**: Scripts should not modify global state
|
||||
3. **Idempotence**: Same input produces same output
|
||||
4. **Clear Errors**: Error messages to stderr, normal output to stdout
|
||||
5. **Fail Fast**: Exit immediately on parameter validation failure
|
||||
6. **Parameterized Paths**: Output paths specified by caller, not hardcoded
|
||||
|
||||
@@ -1,102 +1,102 @@
|
||||
# Skill Requirements Specification
|
||||
|
||||
新 Skill 创建的需求收集规范。
|
||||
Requirements collection specification for new Skill creation.
|
||||
|
||||
---
|
||||
|
||||
## 必需信息
|
||||
## Required Information
|
||||
|
||||
### 1. 基本信息
|
||||
### 1. Basic Information
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `skill_name` | string | ✓ | Skill 标识符(小写-连字符) |
|
||||
| `display_name` | string | ✓ | 显示名称 |
|
||||
| `description` | string | ✓ | 一句话描述 |
|
||||
| `triggers` | string[] | ✓ | 触发关键词列表 |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `skill_name` | string | Yes | Skill identifier (lowercase with hyphens) |
|
||||
| `display_name` | string | Yes | Display name |
|
||||
| `description` | string | Yes | One-sentence description |
|
||||
| `triggers` | string[] | Yes | List of trigger keywords |
|
||||
|
||||
### 2. 执行模式
|
||||
### 2. Execution Mode
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `execution_mode` | enum | ✓ | `sequential` \| `autonomous` \| `hybrid` |
|
||||
| `phase_count` | number | 条件 | Sequential 模式下的阶段数 |
|
||||
| `action_count` | number | 条件 | Autonomous 模式下的动作数 |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `execution_mode` | enum | Yes | `sequential` \| `autonomous` \| `hybrid` |
|
||||
| `phase_count` | number | Conditional | Number of phases in Sequential mode |
|
||||
| `action_count` | number | Conditional | Number of actions in Autonomous mode |
|
||||
|
||||
### 2.5 上下文策略 (P0 增强)
|
||||
### 2.5 Context Strategy (P0 Enhancement)
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `context_strategy` | enum | ✓ | `file` \| `memory` |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `context_strategy` | enum | Yes | `file` \| `memory` |
|
||||
|
||||
**策略对比**:
|
||||
**Strategy Comparison**:
|
||||
|
||||
| 策略 | 持久化 | 可调试 | 可恢复 | 适用场景 |
|
||||
|------|--------|--------|--------|----------|
|
||||
| `file` | ✓ | ✓ | ✓ | 复杂多阶段任务(推荐) |
|
||||
| `memory` | ✗ | ✗ | ✗ | 简单线性任务 |
|
||||
| Strategy | Persistence | Debuggable | Recoverable | Applicable Scenarios |
|
||||
|----------|-------------|-----------|------------|----------------------|
|
||||
| `file` | Yes | Yes | Yes | Complex multi-phase tasks (recommended) |
|
||||
| `memory` | No | No | No | Simple linear tasks |
|
||||
|
||||
### 2.6 LLM 集成配置 (P1 增强)
|
||||
### 2.6 LLM Integration Configuration (P1 Enhancement)
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `llm_integration` | object | 可选 | LLM 调用配置 |
|
||||
| `llm_integration.enabled` | boolean | - | 是否启用 LLM 调用 |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `llm_integration` | object | Optional | LLM invocation configuration |
|
||||
| `llm_integration.enabled` | boolean | - | Enable LLM invocation |
|
||||
| `llm_integration.default_tool` | enum | - | `gemini` \| `qwen` \| `codex` |
|
||||
| `llm_integration.fallback_chain` | string[] | - | 失败时的备选工具链 |
|
||||
| `llm_integration.fallback_chain` | string[] | - | Fallback tool chain on failure |
|
||||
|
||||
### 3. 工具依赖
|
||||
### 3. Tool Dependencies
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `allowed_tools` | string[] | ✓ | 允许使用的工具列表 |
|
||||
| `mcp_tools` | string[] | 可选 | 需要的 MCP 工具 |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `allowed_tools` | string[] | Yes | List of allowed tools |
|
||||
| `mcp_tools` | string[] | Optional | Required MCP tools |
|
||||
|
||||
### 4. 输出配置
|
||||
### 4. Output Configuration
|
||||
|
||||
| 字段 | 类型 | 必需 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `output_format` | enum | ✓ | `markdown` \| `html` \| `json` |
|
||||
| `output_location` | string | ✓ | 输出目录模式 |
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `output_format` | enum | Yes | `markdown` \| `html` \| `json` |
|
||||
| `output_location` | string | Yes | Output directory pattern |
|
||||
|
||||
---
|
||||
|
||||
## 配置文件结构
|
||||
## Configuration File Structure
|
||||
|
||||
```typescript
|
||||
interface SkillConfig {
|
||||
// 基本信息
|
||||
// Basic information
|
||||
skill_name: string; // "my-skill"
|
||||
display_name: string; // "My Skill"
|
||||
description: string; // "一句话描述"
|
||||
description: string; // "One-sentence description"
|
||||
triggers: string[]; // ["keyword1", "keyword2"]
|
||||
|
||||
// 执行模式
|
||||
|
||||
// Execution mode
|
||||
execution_mode: 'sequential' | 'autonomous' | 'hybrid';
|
||||
|
||||
// 上下文策略 (P0 增强)
|
||||
context_strategy: 'file' | 'memory'; // 默认: 'file'
|
||||
// Context strategy (P0 Enhancement)
|
||||
context_strategy: 'file' | 'memory'; // Default: 'file'
|
||||
|
||||
// LLM 集成配置 (P1 增强)
|
||||
// LLM Integration Configuration (P1 Enhancement)
|
||||
llm_integration?: {
|
||||
enabled: boolean; // 是否启用 LLM 调用
|
||||
enabled: boolean; // Enable LLM invocation
|
||||
default_tool: 'gemini' | 'qwen' | 'codex';
|
||||
fallback_chain: string[]; // ['gemini', 'qwen', 'codex']
|
||||
mode: 'analysis' | 'write'; // 默认 mode
|
||||
mode: 'analysis' | 'write'; // Default mode
|
||||
};
|
||||
|
||||
// Sequential 模式配置
|
||||
// Sequential mode configuration
|
||||
sequential_config?: {
|
||||
phases: Array<{
|
||||
id: string; // "01-init"
|
||||
name: string; // "Initialization"
|
||||
description: string; // "收集初始配置"
|
||||
input: string[]; // 输入依赖
|
||||
output: string; // 输出文件
|
||||
description: string; // "Collect initial configuration"
|
||||
input: string[]; // Input dependencies
|
||||
output: string; // Output file
|
||||
}>;
|
||||
};
|
||||
|
||||
// Autonomous 模式配置
|
||||
|
||||
// Autonomous mode configuration
|
||||
autonomous_config?: {
|
||||
state_schema: {
|
||||
fields: Array<{
|
||||
@@ -108,31 +108,31 @@ interface SkillConfig {
|
||||
actions: Array<{
|
||||
id: string; // "action-init"
|
||||
name: string; // "Initialize"
|
||||
description: string; // "初始化状态"
|
||||
preconditions: string[]; // 前置条件
|
||||
effects: string[]; // 执行效果
|
||||
description: string; // "Initialize state"
|
||||
preconditions: string[]; // Preconditions
|
||||
effects: string[]; // Execution effects
|
||||
}>;
|
||||
termination_conditions: string[];
|
||||
};
|
||||
|
||||
// 工具依赖
|
||||
|
||||
// Tool dependencies
|
||||
allowed_tools: string[]; // ["Task", "Read", "Write", ...]
|
||||
mcp_tools?: string[]; // ["mcp__chrome__*"]
|
||||
|
||||
// 输出配置
|
||||
|
||||
// Output configuration
|
||||
output: {
|
||||
format: 'markdown' | 'html' | 'json';
|
||||
location: string; // ".workflow/.scratchpad/{skill}-{timestamp}"
|
||||
filename_pattern: string; // "{name}-output.{ext}"
|
||||
};
|
||||
|
||||
// 质量配置
|
||||
|
||||
// Quality configuration
|
||||
quality?: {
|
||||
dimensions: string[]; // ["completeness", "consistency", ...]
|
||||
pass_threshold: number; // 80
|
||||
};
|
||||
|
||||
// 元数据
|
||||
|
||||
// Metadata
|
||||
created_at: string;
|
||||
version: string;
|
||||
}
|
||||
@@ -140,59 +140,59 @@ interface SkillConfig {
|
||||
|
||||
---
|
||||
|
||||
## 需求收集问题
|
||||
## Requirements Collection Questions
|
||||
|
||||
### Phase 1: 基本信息
|
||||
### Phase 1: Basic Information
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Skill 的名称是什么?(英文,小写-连字符格式)",
|
||||
header: "Skill 名称",
|
||||
question: "What is the Skill name? (English, lowercase with hyphens)",
|
||||
header: "Skill Name",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "自动生成", description: "根据描述自动生成名称" },
|
||||
{ label: "手动输入", description: "输入自定义名称" }
|
||||
{ label: "Auto-generate", description: "Auto-generate name from description" },
|
||||
{ label: "Manual input", description: "Enter custom name" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Skill 的主要用途是什么?",
|
||||
header: "用途类型",
|
||||
question: "What is the primary purpose of this Skill?",
|
||||
header: "Purpose Type",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "文档生成", description: "生成 Markdown/HTML 文档" },
|
||||
{ label: "代码分析", description: "分析代码结构、质量、安全" },
|
||||
{ label: "交互管理", description: "管理 Issue、任务、工作流" },
|
||||
{ label: "数据处理", description: "ETL、转换、报告生成" },
|
||||
{ label: "自定义", description: "其他用途" }
|
||||
{ label: "Document Generation", description: "Generate Markdown/HTML documents" },
|
||||
{ label: "Code Analysis", description: "Analyze code structure, quality, security" },
|
||||
{ label: "Interactive Management", description: "Manage Issues, tasks, workflows" },
|
||||
{ label: "Data Processing", description: "ETL, transformation, report generation" },
|
||||
{ label: "Custom", description: "Other purposes" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 2: 执行模式
|
||||
### Phase 2: Execution Mode
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "选择执行模式:",
|
||||
header: "执行模式",
|
||||
question: "Select execution mode:",
|
||||
header: "Execution Mode",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Sequential (顺序)",
|
||||
description: "阶段按固定顺序执行,适合流水线任务(推荐)"
|
||||
{
|
||||
label: "Sequential (Fixed Order)",
|
||||
description: "Phases execute in fixed order, suitable for pipeline tasks (recommended)"
|
||||
},
|
||||
{
|
||||
label: "Autonomous (自主)",
|
||||
description: "动态选择执行路径,适合交互式任务"
|
||||
{
|
||||
label: "Autonomous (Dynamic)",
|
||||
description: "Dynamically select execution path, suitable for interactive tasks"
|
||||
},
|
||||
{
|
||||
label: "Hybrid (混合)",
|
||||
description: "初始化和收尾固定,中间交互灵活"
|
||||
{
|
||||
label: "Hybrid (Mixed)",
|
||||
description: "Fixed initialization and finalization, flexible middle interaction"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -200,67 +200,67 @@ AskUserQuestion({
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 3: 阶段/动作定义
|
||||
### Phase 3: Phase/Action Definition
|
||||
|
||||
#### Sequential 模式
|
||||
#### Sequential Mode
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "需要多少个执行阶段?",
|
||||
header: "阶段数量",
|
||||
question: "How many execution phases do you need?",
|
||||
header: "Phase Count",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "3 阶段", description: "简单: 收集 → 处理 → 输出" },
|
||||
{ label: "5 阶段", description: "标准: 收集 → 探索 → 分析 → 组装 → 验证" },
|
||||
{ label: "7 阶段", description: "完整: 包含并行处理和迭代优化" },
|
||||
{ label: "自定义", description: "手动指定阶段" }
|
||||
{ label: "3 phases", description: "Simple: Collect → Process → Output" },
|
||||
{ label: "5 phases", description: "Standard: Collect → Explore → Analyze → Assemble → Validate" },
|
||||
{ label: "7 phases", description: "Complete: Include parallel processing and iterative optimization" },
|
||||
{ label: "Custom", description: "Manually specify phases" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
#### Autonomous 模式
|
||||
#### Autonomous Mode
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "核心动作有哪些?",
|
||||
header: "动作定义",
|
||||
question: "What are the core actions?",
|
||||
header: "Action Definition",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "初始化 (init)", description: "设置初始状态" },
|
||||
{ label: "列表 (list)", description: "显示当前项目" },
|
||||
{ label: "创建 (create)", description: "创建新项目" },
|
||||
{ label: "编辑 (edit)", description: "修改现有项目" },
|
||||
{ label: "删除 (delete)", description: "删除项目" },
|
||||
{ label: "完成 (complete)", description: "完成任务" }
|
||||
{ label: "Initialize (init)", description: "Set initial state" },
|
||||
{ label: "List (list)", description: "Display current items" },
|
||||
{ label: "Create (create)", description: "Create new item" },
|
||||
{ label: "Edit (edit)", description: "Modify existing item" },
|
||||
{ label: "Delete (delete)", description: "Delete item" },
|
||||
{ label: "Complete (complete)", description: "Complete task" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 4: 上下文策略 (P0 增强)
|
||||
### Phase 4: Context Strategy (P0 Enhancement)
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "选择上下文管理策略:",
|
||||
header: "上下文策略",
|
||||
question: "Select context management strategy:",
|
||||
header: "Context Strategy",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "文件策略 (file)",
|
||||
description: "持久化到 .scratchpad,支持调试和恢复(推荐)"
|
||||
label: "File Strategy (file)",
|
||||
description: "Persist to .scratchpad, supports debugging and recovery (recommended)"
|
||||
},
|
||||
{
|
||||
label: "内存策略 (memory)",
|
||||
description: "仅在运行时保持,速度快但无法恢复"
|
||||
label: "Memory Strategy (memory)",
|
||||
description: "Keep only at runtime, fast but no recovery"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -268,41 +268,41 @@ AskUserQuestion({
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 5: LLM 集成 (P1 增强)
|
||||
### Phase 5: LLM Integration (P1 Enhancement)
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "是否需要 LLM 调用能力?",
|
||||
header: "LLM 集成",
|
||||
question: "Do you need LLM invocation capability?",
|
||||
header: "LLM Integration",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "启用 LLM 调用",
|
||||
description: "使用 gemini/qwen/codex 进行分析或生成"
|
||||
label: "Enable LLM Invocation",
|
||||
description: "Use gemini/qwen/codex for analysis or generation"
|
||||
},
|
||||
{
|
||||
label: "不需要",
|
||||
description: "仅使用本地工具"
|
||||
label: "Not needed",
|
||||
description: "Only use local tools"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 如果启用 LLM
|
||||
// If LLM enabled
|
||||
if (llmEnabled) {
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "选择默认 LLM 工具:",
|
||||
header: "LLM 工具",
|
||||
question: "Select default LLM tool:",
|
||||
header: "LLM Tool",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Gemini", description: "大上下文,适合分析任务(推荐)" },
|
||||
{ label: "Qwen", description: "代码生成能力强" },
|
||||
{ label: "Codex", description: "自主执行能力强,适合实现任务" }
|
||||
{ label: "Gemini", description: "Large context, suitable for analysis tasks (recommended)" },
|
||||
{ label: "Qwen", description: "Strong code generation capability" },
|
||||
{ label: "Codex", description: "Strong autonomous execution, suitable for implementation tasks" }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -310,21 +310,21 @@ if (llmEnabled) {
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 6: 工具依赖
|
||||
### Phase 6: Tool Dependencies
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "需要哪些工具?",
|
||||
header: "工具选择",
|
||||
question: "What tools do you need?",
|
||||
header: "Tool Selection",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "基础工具", description: "Task, Read, Write, Glob, Grep, Bash" },
|
||||
{ label: "用户交互", description: "AskUserQuestion" },
|
||||
{ label: "Chrome 截图", description: "mcp__chrome__*" },
|
||||
{ label: "外部搜索", description: "mcp__exa__search" },
|
||||
{ label: "CCW CLI 调用", description: "ccw cli (gemini/qwen/codex)" }
|
||||
{ label: "Basic tools", description: "Task, Read, Write, Glob, Grep, Bash" },
|
||||
{ label: "User interaction", description: "AskUserQuestion" },
|
||||
{ label: "Chrome screenshot", description: "mcp__chrome__*" },
|
||||
{ label: "External search", description: "mcp__exa__search" },
|
||||
{ label: "CCW CLI invocation", description: "ccw cli (gemini/qwen/codex)" }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -333,19 +333,19 @@ AskUserQuestion({
|
||||
|
||||
---
|
||||
|
||||
## 验证规则
|
||||
## Validation Rules
|
||||
|
||||
### 名称验证
|
||||
### Name Validation
|
||||
|
||||
```javascript
|
||||
function validateSkillName(name) {
|
||||
const rules = [
|
||||
{ test: /^[a-z][a-z0-9-]*$/, msg: "必须以小写字母开头,只包含小写字母、数字、连字符" },
|
||||
{ test: /^.{3,30}$/, msg: "长度 3-30 字符" },
|
||||
{ test: /^(?!.*--)/, msg: "不能有连续连字符" },
|
||||
{ test: /[^-]$/, msg: "不能以连字符结尾" }
|
||||
{ test: /^[a-z][a-z0-9-]*$/, msg: "Must start with lowercase letter, only contain lowercase letters, digits, hyphens" },
|
||||
{ test: /^.{3,30}$/, msg: "Length 3-30 characters" },
|
||||
{ test: /^(?!.*--)/, msg: "Cannot have consecutive hyphens" },
|
||||
{ test: /[^-]$/, msg: "Cannot end with hyphen" }
|
||||
];
|
||||
|
||||
|
||||
for (const rule of rules) {
|
||||
if (!rule.test.test(name)) {
|
||||
return { valid: false, error: rule.msg };
|
||||
@@ -355,37 +355,37 @@ function validateSkillName(name) {
|
||||
}
|
||||
```
|
||||
|
||||
### 配置验证
|
||||
### Configuration Validation
|
||||
|
||||
```javascript
|
||||
function validateSkillConfig(config) {
|
||||
const errors = [];
|
||||
|
||||
// 必需字段
|
||||
if (!config.skill_name) errors.push("缺少 skill_name");
|
||||
if (!config.description) errors.push("缺少 description");
|
||||
if (!config.execution_mode) errors.push("缺少 execution_mode");
|
||||
|
||||
// 模式特定验证
|
||||
|
||||
// Required fields
|
||||
if (!config.skill_name) errors.push("Missing skill_name");
|
||||
if (!config.description) errors.push("Missing description");
|
||||
if (!config.execution_mode) errors.push("Missing execution_mode");
|
||||
|
||||
// Mode-specific validation
|
||||
if (config.execution_mode === 'sequential') {
|
||||
if (!config.sequential_config?.phases?.length) {
|
||||
errors.push("Sequential 模式需要定义 phases");
|
||||
errors.push("Sequential mode requires phases definition");
|
||||
}
|
||||
} else if (config.execution_mode === 'autonomous') {
|
||||
if (!config.autonomous_config?.actions?.length) {
|
||||
errors.push("Autonomous 模式需要定义 actions");
|
||||
errors.push("Autonomous mode requires actions definition");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return { valid: errors.length === 0, errors };
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 示例配置
|
||||
## Example Configurations
|
||||
|
||||
### Sequential 模式示例 (增强版)
|
||||
### Sequential Mode Example (Enhanced)
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -432,7 +432,7 @@ function validateSkillConfig(config) {
|
||||
}
|
||||
```
|
||||
|
||||
### Autonomous 模式示例
|
||||
### Autonomous Mode Example
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -444,15 +444,15 @@ function validateSkillConfig(config) {
|
||||
"autonomous_config": {
|
||||
"state_schema": {
|
||||
"fields": [
|
||||
{ "name": "tasks", "type": "Task[]", "description": "任务列表" },
|
||||
{ "name": "current_view", "type": "string", "description": "当前视图" }
|
||||
{ "name": "tasks", "type": "Task[]", "description": "Task list" },
|
||||
{ "name": "current_view", "type": "string", "description": "Current view" }
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{ "id": "action-list", "name": "List Tasks", "preconditions": [], "effects": ["显示任务列表"] },
|
||||
{ "id": "action-create", "name": "Create Task", "preconditions": [], "effects": ["添加新任务"] },
|
||||
{ "id": "action-edit", "name": "Edit Task", "preconditions": ["task_selected"], "effects": ["更新任务"] },
|
||||
{ "id": "action-delete", "name": "Delete Task", "preconditions": ["task_selected"], "effects": ["删除任务"] }
|
||||
{ "id": "action-list", "name": "List Tasks", "preconditions": [], "effects": ["Display task list"] },
|
||||
{ "id": "action-create", "name": "Create Task", "preconditions": [], "effects": ["Add new task"] },
|
||||
{ "id": "action-edit", "name": "Edit Task", "preconditions": ["task_selected"], "effects": ["Update task"] },
|
||||
{ "id": "action-delete", "name": "Delete Task", "preconditions": ["task_selected"], "effects": ["Delete task"] }
|
||||
],
|
||||
"termination_conditions": ["user_exit", "error_limit"]
|
||||
},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user