claude-code-workflow 6.0.4 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/action-planning-agent.md +1 -1
- package/.claude/agents/cli-execution-agent.md +269 -269
- package/.claude/agents/cli-explore-agent.md +182 -182
- package/.claude/agents/context-search-agent.md +582 -582
- package/.claude/agents/memory-bridge.md +93 -93
- package/.claude/commands/cli/cli-init.md +1 -1
- package/.claude/commands/memory/docs-full-cli.md +471 -471
- package/.claude/commands/memory/docs-related-cli.md +386 -386
- package/.claude/commands/memory/docs.md +615 -615
- package/.claude/commands/memory/load.md +1 -1
- package/.claude/commands/memory/update-full.md +332 -332
- package/.claude/commands/memory/update-related.md +5 -5
- package/.claude/commands/workflow/init.md +1 -1
- package/.claude/commands/workflow/lite-fix.md +621 -621
- package/.claude/commands/workflow/lite-plan.md +592 -592
- package/.claude/commands/workflow/tools/context-gather.md +434 -434
- package/.claude/commands/workflow/ui-design/generate.md +504 -504
- package/.claude/commands/workflow/ui-design/import-from-code.md +537 -537
- package/.claude/scripts/classify-folders.sh +4 -0
- package/.claude/scripts/convert_tokens_to_css.sh +4 -0
- package/.claude/scripts/detect_changed_modules.sh +5 -1
- package/.claude/scripts/discover-design-files.sh +87 -83
- package/.claude/scripts/generate_module_docs.sh +717 -713
- package/.claude/scripts/get_modules_by_depth.sh +5 -1
- package/.claude/scripts/ui-generate-preview.sh +4 -0
- package/.claude/scripts/ui-instantiate-prototypes.sh +4 -0
- package/.claude/scripts/update_module_claude.sh +4 -0
- package/.claude/skills/command-guide/index/all-commands.json +1 -12
- package/.claude/skills/command-guide/index/by-category.json +1 -12
- package/.claude/skills/command-guide/index/by-use-case.json +1 -12
- package/.claude/skills/command-guide/index/essential-commands.json +1 -12
- package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +127 -71
- package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +269 -269
- package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -182
- package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +18 -38
- package/.claude/skills/command-guide/reference/agents/context-search-agent.md +582 -577
- package/.claude/skills/command-guide/reference/agents/memory-bridge.md +93 -93
- package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +1 -1
- package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -471
- package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -386
- package/.claude/skills/command-guide/reference/commands/memory/docs.md +615 -610
- package/.claude/skills/command-guide/reference/commands/memory/load.md +1 -1
- package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -332
- package/.claude/skills/command-guide/reference/commands/memory/update-related.md +5 -5
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +299 -451
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +14 -37
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +252 -350
- package/.claude/skills/command-guide/reference/commands/workflow/init.md +2 -2
- package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +52 -0
- package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +621 -602
- package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +46 -36
- package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +18 -58
- package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +22 -52
- package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +19 -48
- package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +25 -5
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +7 -7
- package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -434
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +151 -11
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +4 -4
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -504
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -537
- package/.claude/workflows/context-search-strategy.md +77 -77
- package/.claude/workflows/tool-strategy.md +90 -71
- package/.claude/workflows/workflow-architecture.md +1 -1
- package/ccw/package.json +6 -6
- package/ccw/src/cli.js +16 -0
- package/ccw/src/commands/stop.js +101 -0
- package/ccw/src/commands/tool.js +181 -0
- package/ccw/src/core/dashboard-generator.js +18 -3
- package/ccw/src/core/lite-scanner.js +35 -11
- package/ccw/src/core/server.js +583 -17
- package/ccw/src/templates/dashboard-css/01-base.css +161 -0
- package/ccw/src/templates/dashboard-css/02-session.css +726 -0
- package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
- package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
- package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
- package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
- package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
- package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
- package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
- package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
- package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
- package/ccw/src/templates/dashboard-js/components/mcp-manager.js +24 -2
- package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
- package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
- package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
- package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
- package/ccw/src/templates/dashboard-js/main.js +4 -0
- package/ccw/src/templates/dashboard-js/state.js +5 -0
- package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
- package/ccw/src/templates/dashboard-js/views/home.js +13 -9
- package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
- package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
- package/ccw/src/templates/dashboard-js/views/mcp-manager.js +148 -8
- package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
- package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
- package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
- package/ccw/src/templates/dashboard.html +129 -28
- package/ccw/src/tools/classify-folders.js +204 -0
- package/ccw/src/tools/convert-tokens-to-css.js +250 -0
- package/ccw/src/tools/detect-changed-modules.js +288 -0
- package/ccw/src/tools/discover-design-files.js +134 -0
- package/ccw/src/tools/edit-file.js +266 -0
- package/ccw/src/tools/generate-module-docs.js +416 -0
- package/ccw/src/tools/get-modules-by-depth.js +308 -0
- package/ccw/src/tools/index.js +176 -0
- package/ccw/src/tools/ui-generate-preview.js +327 -0
- package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
- package/ccw/src/tools/update-module-claude.js +380 -0
- package/ccw/src/utils/browser-launcher.js +15 -4
- package/package.json +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
- package/ccw/src/core/server.js.bak +0 -385
- package/ccw/src/core/server_original.bak +0 -385
- package/ccw/src/templates/dashboard.css +0 -8114
- package/ccw/src/templates/dashboard_tailwind.html +0 -42
- package/ccw/src/templates/dashboard_test.html +0 -37
- package/ccw/src/templates/tailwind-base.css +0 -212
|
@@ -1,471 +1,471 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: docs-full-cli
|
|
3
|
-
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
|
|
4
|
-
argument-hint: "[path] [--tool <gemini|qwen|codex>]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Full Documentation Generation - CLI Mode (/memory:docs-full-cli)
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
Orchestrates project-wide documentation generation using CLI-based execution with batched agents and automatic tool fallback.
|
|
12
|
-
|
|
13
|
-
**Parameters**:
|
|
14
|
-
- `path`: Target directory (default: current directory)
|
|
15
|
-
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
|
16
|
-
|
|
17
|
-
**Execution Flow**: Discovery → Plan Presentation → Execution → Verification
|
|
18
|
-
|
|
19
|
-
## 3-Layer Architecture & Auto-Strategy Selection
|
|
20
|
-
|
|
21
|
-
### Layer Definition & Strategy Assignment
|
|
22
|
-
|
|
23
|
-
| Layer | Depth | Strategy | Purpose | Context Pattern |
|
|
24
|
-
|-------|-------|----------|---------|----------------|
|
|
25
|
-
| **Layer 3** (Deepest) | ≥3 | `full` | Generate docs for all subdirectories with code | `@**/*` (all files) |
|
|
26
|
-
| **Layer 2** (Middle) | 1-2 | `single` | Current dir + child docs | `@*/API.md @*/README.md @*.{ts,tsx,js,...}` |
|
|
27
|
-
| **Layer 1** (Top) | 0 | `single` | Current dir + child docs | `@*/API.md @*/README.md @*.{ts,tsx,js,...}` |
|
|
28
|
-
|
|
29
|
-
**Generation Direction**: Layer 3 → Layer 2 → Layer 1 (bottom-up dependency flow)
|
|
30
|
-
|
|
31
|
-
**Strategy Auto-Selection**: Strategies are automatically determined by directory depth - no user configuration needed.
|
|
32
|
-
|
|
33
|
-
### Strategy Details
|
|
34
|
-
|
|
35
|
-
#### Full Strategy (Layer 3 Only)
|
|
36
|
-
- **Use Case**: Deepest directories with comprehensive file coverage
|
|
37
|
-
- **Behavior**: Generates API.md + README.md for current directory AND subdirectories containing code
|
|
38
|
-
- **Context**: All files in current directory tree (`@**/*`)
|
|
39
|
-
- **Output**: `.workflow/docs/{project_name}/{path}/API.md` + `README.md`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
#### Single Strategy (Layers 1-2)
|
|
43
|
-
- **Use Case**: Upper layers that aggregate from existing documentation
|
|
44
|
-
- **Behavior**: Generates API.md + README.md only in current directory
|
|
45
|
-
- **Context**: Direct children docs + current directory code files
|
|
46
|
-
- **Output**: `.workflow/docs/{project_name}/{path}/API.md` + `README.md`
|
|
47
|
-
|
|
48
|
-
### Example Flow
|
|
49
|
-
```
|
|
50
|
-
src/auth/handlers/ (depth 3) → FULL STRATEGY
|
|
51
|
-
CONTEXT: @**/* (all files in handlers/ and subdirs)
|
|
52
|
-
GENERATES: .workflow/docs/project/src/auth/handlers/{API.md,README.md} + subdirs
|
|
53
|
-
↓
|
|
54
|
-
src/auth/ (depth 2) → SINGLE STRATEGY
|
|
55
|
-
CONTEXT: @*/API.md @*/README.md @*.ts (handlers docs + current code)
|
|
56
|
-
GENERATES: .workflow/docs/project/src/auth/{API.md,README.md} only
|
|
57
|
-
↓
|
|
58
|
-
src/ (depth 1) → SINGLE STRATEGY
|
|
59
|
-
CONTEXT: @*/API.md @*/README.md (auth docs, utils docs)
|
|
60
|
-
GENERATES: .workflow/docs/project/src/{API.md,README.md} only
|
|
61
|
-
↓
|
|
62
|
-
./ (depth 0) → SINGLE STRATEGY
|
|
63
|
-
CONTEXT: @*/API.md @*/README.md (src docs, tests docs)
|
|
64
|
-
GENERATES: .workflow/docs/project/{API.md,README.md} only
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Core Execution Rules
|
|
68
|
-
|
|
69
|
-
1. **Analyze First**: Module discovery + folder classification before generation
|
|
70
|
-
2. **Wait for Approval**: Present plan, no execution without user confirmation
|
|
71
|
-
3. **Execution Strategy**:
|
|
72
|
-
- **<20 modules**: Direct parallel execution (max 4 concurrent per layer)
|
|
73
|
-
- **≥20 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
|
|
74
|
-
4. **Tool Fallback**: Auto-retry with fallback tools on failure
|
|
75
|
-
5. **Layer Sequential**: Process layers 3→2→1 (bottom-up), parallel batches within layer
|
|
76
|
-
6. **Safety Check**: Verify only docs files modified in .workflow/docs/
|
|
77
|
-
7. **Layer-based Grouping**: Group modules by LAYER (not depth) for execution
|
|
78
|
-
|
|
79
|
-
## Tool Fallback Hierarchy
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
--tool gemini → [gemini, qwen, codex] // default
|
|
83
|
-
--tool qwen → [qwen, gemini, codex]
|
|
84
|
-
--tool codex → [codex, gemini, qwen]
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**Trigger**: Non-zero exit code from generation script
|
|
88
|
-
|
|
89
|
-
| Tool | Best For | Fallback To |
|
|
90
|
-
|--------|--------------------------------|----------------|
|
|
91
|
-
| gemini | Documentation, patterns | qwen → codex |
|
|
92
|
-
| qwen | Architecture, system design | gemini → codex |
|
|
93
|
-
| codex | Implementation, code quality | gemini → qwen |
|
|
94
|
-
|
|
95
|
-
## Execution Phases
|
|
96
|
-
|
|
97
|
-
### Phase 1: Discovery & Analysis
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
// Get project metadata
|
|
101
|
-
Bash({command: "pwd && basename \"$(pwd)\" && git rev-parse --show-toplevel 2>/dev/null || pwd", run_in_background: false});
|
|
102
|
-
|
|
103
|
-
// Get module structure with classification
|
|
104
|
-
Bash({command: "
|
|
105
|
-
|
|
106
|
-
// OR with path parameter
|
|
107
|
-
Bash({command: "cd <target-path> &&
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
**Parse output** `depth:N|path:<PATH>|type:<code|navigation>|...` to extract module paths, types, and count.
|
|
111
|
-
|
|
112
|
-
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
|
113
|
-
|
|
114
|
-
### Phase 2: Plan Presentation
|
|
115
|
-
|
|
116
|
-
**For <20 modules**:
|
|
117
|
-
```
|
|
118
|
-
Documentation Generation Plan:
|
|
119
|
-
Tool: gemini (fallback: qwen → codex)
|
|
120
|
-
Total: 7 modules
|
|
121
|
-
Execution: Direct parallel (< 20 modules threshold)
|
|
122
|
-
Project: myproject
|
|
123
|
-
Output: .workflow/docs/myproject/
|
|
124
|
-
|
|
125
|
-
Will generate docs for:
|
|
126
|
-
- ./core/interfaces (12 files, type: code) - depth 2 [Layer 2] - single strategy
|
|
127
|
-
- ./core (22 files, type: code) - depth 1 [Layer 2] - single strategy
|
|
128
|
-
- ./models (9 files, type: code) - depth 1 [Layer 2] - single strategy
|
|
129
|
-
- ./utils (12 files, type: navigation) - depth 1 [Layer 2] - single strategy
|
|
130
|
-
- . (5 files, type: code) - depth 0 [Layer 1] - single strategy
|
|
131
|
-
|
|
132
|
-
Documentation Strategy (Auto-Selected):
|
|
133
|
-
- Layer 2 (depth 1-2): API.md + README.md (current dir only, reference child docs)
|
|
134
|
-
- Layer 1 (depth 0): API.md + README.md (current dir only, reference child docs)
|
|
135
|
-
|
|
136
|
-
Output Structure:
|
|
137
|
-
- Code folders: API.md + README.md
|
|
138
|
-
- Navigation folders: README.md only
|
|
139
|
-
|
|
140
|
-
Auto-skipped: ./tests, __pycache__, node_modules (15 paths)
|
|
141
|
-
Execution order: Layer 2 → Layer 1
|
|
142
|
-
Estimated time: ~5-10 minutes
|
|
143
|
-
|
|
144
|
-
Confirm execution? (y/n)
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**For ≥20 modules**:
|
|
148
|
-
```
|
|
149
|
-
Documentation Generation Plan:
|
|
150
|
-
Tool: gemini (fallback: qwen → codex)
|
|
151
|
-
Total: 31 modules
|
|
152
|
-
Execution: Agent batch processing (4 modules/agent)
|
|
153
|
-
Project: myproject
|
|
154
|
-
Output: .workflow/docs/myproject/
|
|
155
|
-
|
|
156
|
-
Will generate docs for:
|
|
157
|
-
- ./src/features/auth (12 files, type: code) - depth 3 [Layer 3] - full strategy
|
|
158
|
-
- ./.claude/commands/cli (6 files, type: code) - depth 3 [Layer 3] - full strategy
|
|
159
|
-
- ./src/utils (8 files, type: code) - depth 2 [Layer 2] - single strategy
|
|
160
|
-
...
|
|
161
|
-
|
|
162
|
-
Documentation Strategy (Auto-Selected):
|
|
163
|
-
- Layer 3 (depth ≥3): API.md + README.md (all subdirs with code)
|
|
164
|
-
- Layer 2 (depth 1-2): API.md + README.md (current dir only)
|
|
165
|
-
- Layer 1 (depth 0): API.md + README.md (current dir only)
|
|
166
|
-
|
|
167
|
-
Output Structure:
|
|
168
|
-
- Code folders: API.md + README.md
|
|
169
|
-
- Navigation folders: README.md only
|
|
170
|
-
|
|
171
|
-
Auto-skipped: ./tests, __pycache__, node_modules (15 paths)
|
|
172
|
-
Execution order: Layer 3 → Layer 2 → Layer 1
|
|
173
|
-
|
|
174
|
-
Agent allocation (by LAYER):
|
|
175
|
-
- Layer 3 (14 modules, depth ≥3): 4 agents [4, 4, 4, 2]
|
|
176
|
-
- Layer 2 (15 modules, depth 1-2): 4 agents [4, 4, 4, 3]
|
|
177
|
-
- Layer 1 (2 modules, depth 0): 1 agent [2]
|
|
178
|
-
|
|
179
|
-
Estimated time: ~15-25 minutes
|
|
180
|
-
|
|
181
|
-
Confirm execution? (y/n)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Phase 3A: Direct Execution (<20 modules)
|
|
185
|
-
|
|
186
|
-
**Strategy**: Parallel execution within layer (max 4 concurrent), no agent overhead.
|
|
187
|
-
|
|
188
|
-
**CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
|
|
189
|
-
|
|
190
|
-
```javascript
|
|
191
|
-
let project_name = detect_project_name();
|
|
192
|
-
|
|
193
|
-
for (let layer of [3, 2, 1]) {
|
|
194
|
-
if (modules_by_layer[layer].length === 0) continue;
|
|
195
|
-
let batches = batch_modules(modules_by_layer[layer], 4);
|
|
196
|
-
|
|
197
|
-
for (let batch of batches) {
|
|
198
|
-
let parallel_tasks = batch.map(module => {
|
|
199
|
-
return async () => {
|
|
200
|
-
let strategy = module.depth >= 3 ? "full" : "single";
|
|
201
|
-
for (let tool of tool_order) {
|
|
202
|
-
Bash({
|
|
203
|
-
command: `cd ${module.path} &&
|
|
204
|
-
run_in_background: false
|
|
205
|
-
});
|
|
206
|
-
if (bash_result.exit_code === 0) {
|
|
207
|
-
report(`✅ ${module.path} (Layer ${layer}) docs generated with ${tool}`);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
|
|
212
|
-
return false;
|
|
213
|
-
};
|
|
214
|
-
});
|
|
215
|
-
await Promise.all(parallel_tasks.map(task => task()));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Phase 3B: Agent Batch Execution (≥20 modules)
|
|
221
|
-
|
|
222
|
-
**Strategy**: Batch modules into groups of 4, spawn memory-bridge agents per batch.
|
|
223
|
-
|
|
224
|
-
```javascript
|
|
225
|
-
// Group modules by LAYER and batch within each layer
|
|
226
|
-
let modules_by_layer = group_by_layer(module_list);
|
|
227
|
-
let tool_order = construct_tool_order(primary_tool);
|
|
228
|
-
let project_name = detect_project_name();
|
|
229
|
-
|
|
230
|
-
for (let layer of [3, 2, 1]) {
|
|
231
|
-
if (modules_by_layer[layer].length === 0) continue;
|
|
232
|
-
|
|
233
|
-
let batches = batch_modules(modules_by_layer[layer], 4);
|
|
234
|
-
let worker_tasks = [];
|
|
235
|
-
|
|
236
|
-
for (let batch of batches) {
|
|
237
|
-
worker_tasks.push(
|
|
238
|
-
Task(
|
|
239
|
-
subagent_type="memory-bridge",
|
|
240
|
-
description=`Generate docs for ${batch.length} modules in Layer ${layer}`,
|
|
241
|
-
prompt=generate_batch_worker_prompt(batch, tool_order, layer, project_name)
|
|
242
|
-
)
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
await parallel_execute(worker_tasks);
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
**Batch Worker Prompt Template**:
|
|
251
|
-
```
|
|
252
|
-
PURPOSE: Generate documentation for assigned modules with tool fallback
|
|
253
|
-
|
|
254
|
-
TASK: Generate API.md + README.md for assigned modules using specified strategies.
|
|
255
|
-
|
|
256
|
-
PROJECT: {{project_name}}
|
|
257
|
-
OUTPUT: .workflow/docs/{{project_name}}/
|
|
258
|
-
|
|
259
|
-
MODULES:
|
|
260
|
-
{{module_path_1}} (strategy: {{strategy_1}}, type: {{folder_type_1}})
|
|
261
|
-
{{module_path_2}} (strategy: {{strategy_2}}, type: {{folder_type_2}})
|
|
262
|
-
...
|
|
263
|
-
|
|
264
|
-
TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
|
|
265
|
-
|
|
266
|
-
EXECUTION SCRIPT:
|
|
267
|
-
- Accepts strategy parameter: full | single
|
|
268
|
-
- Accepts folder type detection: code | navigation
|
|
269
|
-
- Tool execution via direct CLI commands (gemini/qwen/codex)
|
|
270
|
-
- Output path: .workflow/docs/{{project_name}}/{module_path}/
|
|
271
|
-
|
|
272
|
-
EXECUTION FLOW (for each module):
|
|
273
|
-
1. Tool fallback loop (exit on first success):
|
|
274
|
-
for tool in {{tool_1}} {{tool_2}} {{tool_3}}; do
|
|
275
|
-
Bash({
|
|
276
|
-
command: `cd "{{module_path}}" &&
|
|
277
|
-
run_in_background: false
|
|
278
|
-
})
|
|
279
|
-
exit_code=$?
|
|
280
|
-
|
|
281
|
-
if [ $exit_code -eq 0 ]; then
|
|
282
|
-
report "✅ {{module_path}} docs generated with $tool"
|
|
283
|
-
break
|
|
284
|
-
else
|
|
285
|
-
report "⚠️ {{module_path}} failed with $tool, trying next..."
|
|
286
|
-
continue
|
|
287
|
-
fi
|
|
288
|
-
done
|
|
289
|
-
|
|
290
|
-
2. Handle complete failure (all tools failed):
|
|
291
|
-
if [ $exit_code -ne 0 ]; then
|
|
292
|
-
report "❌ FAILED: {{module_path}} - all tools exhausted"
|
|
293
|
-
# Continue to next module (do not abort batch)
|
|
294
|
-
fi
|
|
295
|
-
|
|
296
|
-
FOLDER TYPE HANDLING:
|
|
297
|
-
- code: Generate API.md + README.md
|
|
298
|
-
- navigation: Generate README.md only
|
|
299
|
-
|
|
300
|
-
FAILURE HANDLING:
|
|
301
|
-
- Module-level isolation: One module's failure does not affect others
|
|
302
|
-
- Exit code detection: Non-zero exit code triggers next tool
|
|
303
|
-
- Exhaustion reporting: Log modules where all tools failed
|
|
304
|
-
- Batch continuation: Always process remaining modules
|
|
305
|
-
|
|
306
|
-
REPORTING FORMAT:
|
|
307
|
-
Per-module status:
|
|
308
|
-
✅ path/to/module docs generated with {tool}
|
|
309
|
-
⚠️ path/to/module failed with {tool}, trying next...
|
|
310
|
-
❌ FAILED: path/to/module - all tools exhausted
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Phase 4: Project-Level Documentation
|
|
314
|
-
|
|
315
|
-
**After all module documentation is generated, create project-level documentation files.**
|
|
316
|
-
|
|
317
|
-
```javascript
|
|
318
|
-
let project_name = detect_project_name();
|
|
319
|
-
let project_root = get_project_root();
|
|
320
|
-
|
|
321
|
-
// Step 1: Generate Project README
|
|
322
|
-
report("Generating project README.md...");
|
|
323
|
-
for (let tool of tool_order) {
|
|
324
|
-
Bash({
|
|
325
|
-
command: `cd ${project_root} &&
|
|
326
|
-
run_in_background: false
|
|
327
|
-
});
|
|
328
|
-
if (bash_result.exit_code === 0) {
|
|
329
|
-
report(`✅ Project README generated with ${tool}`);
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Step 2: Generate Architecture & Examples
|
|
335
|
-
report("Generating ARCHITECTURE.md and EXAMPLES.md...");
|
|
336
|
-
for (let tool of tool_order) {
|
|
337
|
-
Bash({
|
|
338
|
-
command: `cd ${project_root} &&
|
|
339
|
-
run_in_background: false
|
|
340
|
-
});
|
|
341
|
-
if (bash_result.exit_code === 0) {
|
|
342
|
-
report(`✅ Architecture docs generated with ${tool}`);
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Step 3: Generate HTTP API documentation (if API routes detected)
|
|
348
|
-
Bash({command: 'rg "router\\.|@Get|@Post" -g "*.{ts,js,py}" 2>/dev/null && echo "API_FOUND" || echo "NO_API"', run_in_background: false});
|
|
349
|
-
if (bash_result.stdout.includes("API_FOUND")) {
|
|
350
|
-
report("Generating HTTP API documentation...");
|
|
351
|
-
for (let tool of tool_order) {
|
|
352
|
-
Bash({
|
|
353
|
-
command: `cd ${project_root} &&
|
|
354
|
-
run_in_background: false
|
|
355
|
-
});
|
|
356
|
-
if (bash_result.exit_code === 0) {
|
|
357
|
-
report(`✅ HTTP API docs generated with ${tool}`);
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
**Expected Output**:
|
|
365
|
-
```
|
|
366
|
-
Project-Level Documentation:
|
|
367
|
-
✅ README.md (project root overview)
|
|
368
|
-
✅ ARCHITECTURE.md (system design)
|
|
369
|
-
✅ EXAMPLES.md (usage examples)
|
|
370
|
-
✅ api/README.md (HTTP API reference) [optional]
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
### Phase 5: Verification
|
|
374
|
-
|
|
375
|
-
```javascript
|
|
376
|
-
// Check documentation files created
|
|
377
|
-
Bash({command: 'find .workflow/docs -type f -name "*.md" 2>/dev/null | wc -l', run_in_background: false});
|
|
378
|
-
|
|
379
|
-
// Display structure
|
|
380
|
-
Bash({command: 'tree -L 3 .workflow/docs/', run_in_background: false});
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**Result Summary**:
|
|
384
|
-
```
|
|
385
|
-
Documentation Generation Summary:
|
|
386
|
-
Total: 31 | Success: 29 | Failed: 2
|
|
387
|
-
Tool usage: gemini: 25, qwen: 4, codex: 0
|
|
388
|
-
Failed: path1, path2
|
|
389
|
-
|
|
390
|
-
Generated documentation:
|
|
391
|
-
.workflow/docs/myproject/
|
|
392
|
-
├── src/
|
|
393
|
-
│ ├── auth/
|
|
394
|
-
│ │ ├── API.md
|
|
395
|
-
│ │ └── README.md
|
|
396
|
-
│ └── utils/
|
|
397
|
-
│ └── README.md
|
|
398
|
-
└── README.md
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
## Error Handling
|
|
402
|
-
|
|
403
|
-
**Batch Worker**: Tool fallback per module, batch isolation, clear status reporting
|
|
404
|
-
**Coordinator**: Invalid path abort, user decline handling, verification with cleanup
|
|
405
|
-
**Fallback Triggers**: Non-zero exit code, script timeout, unexpected output
|
|
406
|
-
|
|
407
|
-
## Output Structure
|
|
408
|
-
|
|
409
|
-
```
|
|
410
|
-
.workflow/docs/{project_name}/
|
|
411
|
-
├── src/ # Mirrors source structure
|
|
412
|
-
│ ├── modules/
|
|
413
|
-
│ │ ├── README.md # Navigation
|
|
414
|
-
│ │ ├── auth/
|
|
415
|
-
│ │ │ ├── API.md # API signatures
|
|
416
|
-
│ │ │ ├── README.md # Module docs
|
|
417
|
-
│ │ │ └── middleware/
|
|
418
|
-
│ │ │ ├── API.md
|
|
419
|
-
│ │ │ └── README.md
|
|
420
|
-
│ │ └── api/
|
|
421
|
-
│ │ ├── API.md
|
|
422
|
-
│ │ └── README.md
|
|
423
|
-
│ └── utils/
|
|
424
|
-
│ └── README.md
|
|
425
|
-
├── lib/
|
|
426
|
-
│ └── core/
|
|
427
|
-
│ ├── API.md
|
|
428
|
-
│ └── README.md
|
|
429
|
-
├── README.md # ✨ Project root overview (auto-generated)
|
|
430
|
-
├── ARCHITECTURE.md # ✨ System design (auto-generated)
|
|
431
|
-
├── EXAMPLES.md # ✨ Usage examples (auto-generated)
|
|
432
|
-
└── api/ # ✨ Optional (auto-generated if HTTP API detected)
|
|
433
|
-
└── README.md # HTTP API reference
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
## Usage Examples
|
|
437
|
-
|
|
438
|
-
```bash
|
|
439
|
-
# Full project documentation generation
|
|
440
|
-
/memory:docs-full-cli
|
|
441
|
-
|
|
442
|
-
# Target specific directory
|
|
443
|
-
/memory:docs-full-cli src/features/auth
|
|
444
|
-
/memory:docs-full-cli .claude
|
|
445
|
-
|
|
446
|
-
# Use specific tool
|
|
447
|
-
/memory:docs-full-cli --tool qwen
|
|
448
|
-
/memory:docs-full-cli src --tool qwen
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
## Key Advantages
|
|
452
|
-
|
|
453
|
-
- **Efficiency**: 30 modules → 8 agents (73% reduction from sequential)
|
|
454
|
-
- **Resilience**: 3-tier tool fallback per module
|
|
455
|
-
- **Performance**: Parallel batches, no concurrency limits
|
|
456
|
-
- **Observability**: Per-module tool usage, batch-level metrics
|
|
457
|
-
- **Automation**: Zero configuration - strategy auto-selected by directory depth
|
|
458
|
-
- **Path Mirroring**: Clear 1:1 mapping between source and documentation structure
|
|
459
|
-
|
|
460
|
-
## Template Reference
|
|
461
|
-
|
|
462
|
-
Templates used from `~/.claude/workflows/cli-templates/prompts/documentation/`:
|
|
463
|
-
- `api.txt`: Code API documentation (Part A: Code API, Part B: HTTP API)
|
|
464
|
-
- `module-readme.txt`: Module purpose, usage, dependencies
|
|
465
|
-
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
|
466
|
-
|
|
467
|
-
## Related Commands
|
|
468
|
-
|
|
469
|
-
- `/memory:docs` - Agent-based documentation planning workflow
|
|
470
|
-
- `/memory:docs-related-cli` - Update docs for changed modules only
|
|
471
|
-
- `/workflow:execute` - Execute documentation tasks (when using agent mode)
|
|
1
|
+
---
|
|
2
|
+
name: docs-full-cli
|
|
3
|
+
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
|
|
4
|
+
argument-hint: "[path] [--tool <gemini|qwen|codex>]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Full Documentation Generation - CLI Mode (/memory:docs-full-cli)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Orchestrates project-wide documentation generation using CLI-based execution with batched agents and automatic tool fallback.
|
|
12
|
+
|
|
13
|
+
**Parameters**:
|
|
14
|
+
- `path`: Target directory (default: current directory)
|
|
15
|
+
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
|
16
|
+
|
|
17
|
+
**Execution Flow**: Discovery → Plan Presentation → Execution → Verification
|
|
18
|
+
|
|
19
|
+
## 3-Layer Architecture & Auto-Strategy Selection
|
|
20
|
+
|
|
21
|
+
### Layer Definition & Strategy Assignment
|
|
22
|
+
|
|
23
|
+
| Layer | Depth | Strategy | Purpose | Context Pattern |
|
|
24
|
+
|-------|-------|----------|---------|----------------|
|
|
25
|
+
| **Layer 3** (Deepest) | ≥3 | `full` | Generate docs for all subdirectories with code | `@**/*` (all files) |
|
|
26
|
+
| **Layer 2** (Middle) | 1-2 | `single` | Current dir + child docs | `@*/API.md @*/README.md @*.{ts,tsx,js,...}` |
|
|
27
|
+
| **Layer 1** (Top) | 0 | `single` | Current dir + child docs | `@*/API.md @*/README.md @*.{ts,tsx,js,...}` |
|
|
28
|
+
|
|
29
|
+
**Generation Direction**: Layer 3 → Layer 2 → Layer 1 (bottom-up dependency flow)
|
|
30
|
+
|
|
31
|
+
**Strategy Auto-Selection**: Strategies are automatically determined by directory depth - no user configuration needed.
|
|
32
|
+
|
|
33
|
+
### Strategy Details
|
|
34
|
+
|
|
35
|
+
#### Full Strategy (Layer 3 Only)
|
|
36
|
+
- **Use Case**: Deepest directories with comprehensive file coverage
|
|
37
|
+
- **Behavior**: Generates API.md + README.md for current directory AND subdirectories containing code
|
|
38
|
+
- **Context**: All files in current directory tree (`@**/*`)
|
|
39
|
+
- **Output**: `.workflow/docs/{project_name}/{path}/API.md` + `README.md`
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
#### Single Strategy (Layers 1-2)
|
|
43
|
+
- **Use Case**: Upper layers that aggregate from existing documentation
|
|
44
|
+
- **Behavior**: Generates API.md + README.md only in current directory
|
|
45
|
+
- **Context**: Direct children docs + current directory code files
|
|
46
|
+
- **Output**: `.workflow/docs/{project_name}/{path}/API.md` + `README.md`
|
|
47
|
+
|
|
48
|
+
### Example Flow
|
|
49
|
+
```
|
|
50
|
+
src/auth/handlers/ (depth 3) → FULL STRATEGY
|
|
51
|
+
CONTEXT: @**/* (all files in handlers/ and subdirs)
|
|
52
|
+
GENERATES: .workflow/docs/project/src/auth/handlers/{API.md,README.md} + subdirs
|
|
53
|
+
↓
|
|
54
|
+
src/auth/ (depth 2) → SINGLE STRATEGY
|
|
55
|
+
CONTEXT: @*/API.md @*/README.md @*.ts (handlers docs + current code)
|
|
56
|
+
GENERATES: .workflow/docs/project/src/auth/{API.md,README.md} only
|
|
57
|
+
↓
|
|
58
|
+
src/ (depth 1) → SINGLE STRATEGY
|
|
59
|
+
CONTEXT: @*/API.md @*/README.md (auth docs, utils docs)
|
|
60
|
+
GENERATES: .workflow/docs/project/src/{API.md,README.md} only
|
|
61
|
+
↓
|
|
62
|
+
./ (depth 0) → SINGLE STRATEGY
|
|
63
|
+
CONTEXT: @*/API.md @*/README.md (src docs, tests docs)
|
|
64
|
+
GENERATES: .workflow/docs/project/{API.md,README.md} only
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Core Execution Rules
|
|
68
|
+
|
|
69
|
+
1. **Analyze First**: Module discovery + folder classification before generation
|
|
70
|
+
2. **Wait for Approval**: Present plan, no execution without user confirmation
|
|
71
|
+
3. **Execution Strategy**:
|
|
72
|
+
- **<20 modules**: Direct parallel execution (max 4 concurrent per layer)
|
|
73
|
+
- **≥20 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
|
|
74
|
+
4. **Tool Fallback**: Auto-retry with fallback tools on failure
|
|
75
|
+
5. **Layer Sequential**: Process layers 3→2→1 (bottom-up), parallel batches within layer
|
|
76
|
+
6. **Safety Check**: Verify only docs files modified in .workflow/docs/
|
|
77
|
+
7. **Layer-based Grouping**: Group modules by LAYER (not depth) for execution
|
|
78
|
+
|
|
79
|
+
## Tool Fallback Hierarchy
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
--tool gemini → [gemini, qwen, codex] // default
|
|
83
|
+
--tool qwen → [qwen, gemini, codex]
|
|
84
|
+
--tool codex → [codex, gemini, qwen]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Trigger**: Non-zero exit code from generation script
|
|
88
|
+
|
|
89
|
+
| Tool | Best For | Fallback To |
|
|
90
|
+
|--------|--------------------------------|----------------|
|
|
91
|
+
| gemini | Documentation, patterns | qwen → codex |
|
|
92
|
+
| qwen | Architecture, system design | gemini → codex |
|
|
93
|
+
| codex | Implementation, code quality | gemini → qwen |
|
|
94
|
+
|
|
95
|
+
## Execution Phases
|
|
96
|
+
|
|
97
|
+
### Phase 1: Discovery & Analysis
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
// Get project metadata
|
|
101
|
+
Bash({command: "pwd && basename \"$(pwd)\" && git rev-parse --show-toplevel 2>/dev/null || pwd", run_in_background: false});
|
|
102
|
+
|
|
103
|
+
// Get module structure with classification
|
|
104
|
+
Bash({command: "ccw tool exec get_modules_by_depth '{\"format\":\"list\"}' | ccw tool exec classify_folders '{}'", run_in_background: false});
|
|
105
|
+
|
|
106
|
+
// OR with path parameter
|
|
107
|
+
Bash({command: "cd <target-path> && ccw tool exec get_modules_by_depth '{\"format\":\"list\"}' | ccw tool exec classify_folders '{}'", run_in_background: false});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Parse output** `depth:N|path:<PATH>|type:<code|navigation>|...` to extract module paths, types, and count.
|
|
111
|
+
|
|
112
|
+
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
|
113
|
+
|
|
114
|
+
### Phase 2: Plan Presentation
|
|
115
|
+
|
|
116
|
+
**For <20 modules**:
|
|
117
|
+
```
|
|
118
|
+
Documentation Generation Plan:
|
|
119
|
+
Tool: gemini (fallback: qwen → codex)
|
|
120
|
+
Total: 7 modules
|
|
121
|
+
Execution: Direct parallel (< 20 modules threshold)
|
|
122
|
+
Project: myproject
|
|
123
|
+
Output: .workflow/docs/myproject/
|
|
124
|
+
|
|
125
|
+
Will generate docs for:
|
|
126
|
+
- ./core/interfaces (12 files, type: code) - depth 2 [Layer 2] - single strategy
|
|
127
|
+
- ./core (22 files, type: code) - depth 1 [Layer 2] - single strategy
|
|
128
|
+
- ./models (9 files, type: code) - depth 1 [Layer 2] - single strategy
|
|
129
|
+
- ./utils (12 files, type: navigation) - depth 1 [Layer 2] - single strategy
|
|
130
|
+
- . (5 files, type: code) - depth 0 [Layer 1] - single strategy
|
|
131
|
+
|
|
132
|
+
Documentation Strategy (Auto-Selected):
|
|
133
|
+
- Layer 2 (depth 1-2): API.md + README.md (current dir only, reference child docs)
|
|
134
|
+
- Layer 1 (depth 0): API.md + README.md (current dir only, reference child docs)
|
|
135
|
+
|
|
136
|
+
Output Structure:
|
|
137
|
+
- Code folders: API.md + README.md
|
|
138
|
+
- Navigation folders: README.md only
|
|
139
|
+
|
|
140
|
+
Auto-skipped: ./tests, __pycache__, node_modules (15 paths)
|
|
141
|
+
Execution order: Layer 2 → Layer 1
|
|
142
|
+
Estimated time: ~5-10 minutes
|
|
143
|
+
|
|
144
|
+
Confirm execution? (y/n)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**For ≥20 modules**:
|
|
148
|
+
```
|
|
149
|
+
Documentation Generation Plan:
|
|
150
|
+
Tool: gemini (fallback: qwen → codex)
|
|
151
|
+
Total: 31 modules
|
|
152
|
+
Execution: Agent batch processing (4 modules/agent)
|
|
153
|
+
Project: myproject
|
|
154
|
+
Output: .workflow/docs/myproject/
|
|
155
|
+
|
|
156
|
+
Will generate docs for:
|
|
157
|
+
- ./src/features/auth (12 files, type: code) - depth 3 [Layer 3] - full strategy
|
|
158
|
+
- ./.claude/commands/cli (6 files, type: code) - depth 3 [Layer 3] - full strategy
|
|
159
|
+
- ./src/utils (8 files, type: code) - depth 2 [Layer 2] - single strategy
|
|
160
|
+
...
|
|
161
|
+
|
|
162
|
+
Documentation Strategy (Auto-Selected):
|
|
163
|
+
- Layer 3 (depth ≥3): API.md + README.md (all subdirs with code)
|
|
164
|
+
- Layer 2 (depth 1-2): API.md + README.md (current dir only)
|
|
165
|
+
- Layer 1 (depth 0): API.md + README.md (current dir only)
|
|
166
|
+
|
|
167
|
+
Output Structure:
|
|
168
|
+
- Code folders: API.md + README.md
|
|
169
|
+
- Navigation folders: README.md only
|
|
170
|
+
|
|
171
|
+
Auto-skipped: ./tests, __pycache__, node_modules (15 paths)
|
|
172
|
+
Execution order: Layer 3 → Layer 2 → Layer 1
|
|
173
|
+
|
|
174
|
+
Agent allocation (by LAYER):
|
|
175
|
+
- Layer 3 (14 modules, depth ≥3): 4 agents [4, 4, 4, 2]
|
|
176
|
+
- Layer 2 (15 modules, depth 1-2): 4 agents [4, 4, 4, 3]
|
|
177
|
+
- Layer 1 (2 modules, depth 0): 1 agent [2]
|
|
178
|
+
|
|
179
|
+
Estimated time: ~15-25 minutes
|
|
180
|
+
|
|
181
|
+
Confirm execution? (y/n)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Phase 3A: Direct Execution (<20 modules)
|
|
185
|
+
|
|
186
|
+
**Strategy**: Parallel execution within layer (max 4 concurrent), no agent overhead.
|
|
187
|
+
|
|
188
|
+
**CRITICAL**: All Bash commands use `run_in_background: false` for synchronous execution.
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
let project_name = detect_project_name();
|
|
192
|
+
|
|
193
|
+
for (let layer of [3, 2, 1]) {
|
|
194
|
+
if (modules_by_layer[layer].length === 0) continue;
|
|
195
|
+
let batches = batch_modules(modules_by_layer[layer], 4);
|
|
196
|
+
|
|
197
|
+
for (let batch of batches) {
|
|
198
|
+
let parallel_tasks = batch.map(module => {
|
|
199
|
+
return async () => {
|
|
200
|
+
let strategy = module.depth >= 3 ? "full" : "single";
|
|
201
|
+
for (let tool of tool_order) {
|
|
202
|
+
Bash({
|
|
203
|
+
command: `cd ${module.path} && ccw tool exec generate_module_docs '{"strategy":"${strategy}","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
|
204
|
+
run_in_background: false
|
|
205
|
+
});
|
|
206
|
+
if (bash_result.exit_code === 0) {
|
|
207
|
+
report(`✅ ${module.path} (Layer ${layer}) docs generated with ${tool}`);
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
|
|
212
|
+
return false;
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
await Promise.all(parallel_tasks.map(task => task()));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Phase 3B: Agent Batch Execution (≥20 modules)
|
|
221
|
+
|
|
222
|
+
**Strategy**: Batch modules into groups of 4, spawn memory-bridge agents per batch.
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
// Group modules by LAYER and batch within each layer
|
|
226
|
+
let modules_by_layer = group_by_layer(module_list);
|
|
227
|
+
let tool_order = construct_tool_order(primary_tool);
|
|
228
|
+
let project_name = detect_project_name();
|
|
229
|
+
|
|
230
|
+
for (let layer of [3, 2, 1]) {
|
|
231
|
+
if (modules_by_layer[layer].length === 0) continue;
|
|
232
|
+
|
|
233
|
+
let batches = batch_modules(modules_by_layer[layer], 4);
|
|
234
|
+
let worker_tasks = [];
|
|
235
|
+
|
|
236
|
+
for (let batch of batches) {
|
|
237
|
+
worker_tasks.push(
|
|
238
|
+
Task(
|
|
239
|
+
subagent_type="memory-bridge",
|
|
240
|
+
description=`Generate docs for ${batch.length} modules in Layer ${layer}`,
|
|
241
|
+
prompt=generate_batch_worker_prompt(batch, tool_order, layer, project_name)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
await parallel_execute(worker_tasks);
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Batch Worker Prompt Template**:
|
|
251
|
+
```
|
|
252
|
+
PURPOSE: Generate documentation for assigned modules with tool fallback
|
|
253
|
+
|
|
254
|
+
TASK: Generate API.md + README.md for assigned modules using specified strategies.
|
|
255
|
+
|
|
256
|
+
PROJECT: {{project_name}}
|
|
257
|
+
OUTPUT: .workflow/docs/{{project_name}}/
|
|
258
|
+
|
|
259
|
+
MODULES:
|
|
260
|
+
{{module_path_1}} (strategy: {{strategy_1}}, type: {{folder_type_1}})
|
|
261
|
+
{{module_path_2}} (strategy: {{strategy_2}}, type: {{folder_type_2}})
|
|
262
|
+
...
|
|
263
|
+
|
|
264
|
+
TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
|
|
265
|
+
|
|
266
|
+
EXECUTION SCRIPT: ccw tool exec generate_module_docs
|
|
267
|
+
- Accepts strategy parameter: full | single
|
|
268
|
+
- Accepts folder type detection: code | navigation
|
|
269
|
+
- Tool execution via direct CLI commands (gemini/qwen/codex)
|
|
270
|
+
- Output path: .workflow/docs/{{project_name}}/{module_path}/
|
|
271
|
+
|
|
272
|
+
EXECUTION FLOW (for each module):
|
|
273
|
+
1. Tool fallback loop (exit on first success):
|
|
274
|
+
for tool in {{tool_1}} {{tool_2}} {{tool_3}}; do
|
|
275
|
+
Bash({
|
|
276
|
+
command: `cd "{{module_path}}" && ccw tool exec generate_module_docs '{"strategy":"{{strategy}}","sourcePath":".","projectName":"{{project_name}}","tool":"${tool}"}'`,
|
|
277
|
+
run_in_background: false
|
|
278
|
+
})
|
|
279
|
+
exit_code=$?
|
|
280
|
+
|
|
281
|
+
if [ $exit_code -eq 0 ]; then
|
|
282
|
+
report "✅ {{module_path}} docs generated with $tool"
|
|
283
|
+
break
|
|
284
|
+
else
|
|
285
|
+
report "⚠️ {{module_path}} failed with $tool, trying next..."
|
|
286
|
+
continue
|
|
287
|
+
fi
|
|
288
|
+
done
|
|
289
|
+
|
|
290
|
+
2. Handle complete failure (all tools failed):
|
|
291
|
+
if [ $exit_code -ne 0 ]; then
|
|
292
|
+
report "❌ FAILED: {{module_path}} - all tools exhausted"
|
|
293
|
+
# Continue to next module (do not abort batch)
|
|
294
|
+
fi
|
|
295
|
+
|
|
296
|
+
FOLDER TYPE HANDLING:
|
|
297
|
+
- code: Generate API.md + README.md
|
|
298
|
+
- navigation: Generate README.md only
|
|
299
|
+
|
|
300
|
+
FAILURE HANDLING:
|
|
301
|
+
- Module-level isolation: One module's failure does not affect others
|
|
302
|
+
- Exit code detection: Non-zero exit code triggers next tool
|
|
303
|
+
- Exhaustion reporting: Log modules where all tools failed
|
|
304
|
+
- Batch continuation: Always process remaining modules
|
|
305
|
+
|
|
306
|
+
REPORTING FORMAT:
|
|
307
|
+
Per-module status:
|
|
308
|
+
✅ path/to/module docs generated with {tool}
|
|
309
|
+
⚠️ path/to/module failed with {tool}, trying next...
|
|
310
|
+
❌ FAILED: path/to/module - all tools exhausted
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Phase 4: Project-Level Documentation
|
|
314
|
+
|
|
315
|
+
**After all module documentation is generated, create project-level documentation files.**
|
|
316
|
+
|
|
317
|
+
```javascript
|
|
318
|
+
let project_name = detect_project_name();
|
|
319
|
+
let project_root = get_project_root();
|
|
320
|
+
|
|
321
|
+
// Step 1: Generate Project README
|
|
322
|
+
report("Generating project README.md...");
|
|
323
|
+
for (let tool of tool_order) {
|
|
324
|
+
Bash({
|
|
325
|
+
command: `cd ${project_root} && ccw tool exec generate_module_docs '{"strategy":"project-readme","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
|
326
|
+
run_in_background: false
|
|
327
|
+
});
|
|
328
|
+
if (bash_result.exit_code === 0) {
|
|
329
|
+
report(`✅ Project README generated with ${tool}`);
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Step 2: Generate Architecture & Examples
|
|
335
|
+
report("Generating ARCHITECTURE.md and EXAMPLES.md...");
|
|
336
|
+
for (let tool of tool_order) {
|
|
337
|
+
Bash({
|
|
338
|
+
command: `cd ${project_root} && ccw tool exec generate_module_docs '{"strategy":"project-architecture","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
|
339
|
+
run_in_background: false
|
|
340
|
+
});
|
|
341
|
+
if (bash_result.exit_code === 0) {
|
|
342
|
+
report(`✅ Architecture docs generated with ${tool}`);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Step 3: Generate HTTP API documentation (if API routes detected)
|
|
348
|
+
Bash({command: 'rg "router\\.|@Get|@Post" -g "*.{ts,js,py}" 2>/dev/null && echo "API_FOUND" || echo "NO_API"', run_in_background: false});
|
|
349
|
+
if (bash_result.stdout.includes("API_FOUND")) {
|
|
350
|
+
report("Generating HTTP API documentation...");
|
|
351
|
+
for (let tool of tool_order) {
|
|
352
|
+
Bash({
|
|
353
|
+
command: `cd ${project_root} && ccw tool exec generate_module_docs '{"strategy":"http-api","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
|
354
|
+
run_in_background: false
|
|
355
|
+
});
|
|
356
|
+
if (bash_result.exit_code === 0) {
|
|
357
|
+
report(`✅ HTTP API docs generated with ${tool}`);
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Expected Output**:
|
|
365
|
+
```
|
|
366
|
+
Project-Level Documentation:
|
|
367
|
+
✅ README.md (project root overview)
|
|
368
|
+
✅ ARCHITECTURE.md (system design)
|
|
369
|
+
✅ EXAMPLES.md (usage examples)
|
|
370
|
+
✅ api/README.md (HTTP API reference) [optional]
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Phase 5: Verification
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
// Check documentation files created
|
|
377
|
+
Bash({command: 'find .workflow/docs -type f -name "*.md" 2>/dev/null | wc -l', run_in_background: false});
|
|
378
|
+
|
|
379
|
+
// Display structure
|
|
380
|
+
Bash({command: 'tree -L 3 .workflow/docs/', run_in_background: false});
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Result Summary**:
|
|
384
|
+
```
|
|
385
|
+
Documentation Generation Summary:
|
|
386
|
+
Total: 31 | Success: 29 | Failed: 2
|
|
387
|
+
Tool usage: gemini: 25, qwen: 4, codex: 0
|
|
388
|
+
Failed: path1, path2
|
|
389
|
+
|
|
390
|
+
Generated documentation:
|
|
391
|
+
.workflow/docs/myproject/
|
|
392
|
+
├── src/
|
|
393
|
+
│ ├── auth/
|
|
394
|
+
│ │ ├── API.md
|
|
395
|
+
│ │ └── README.md
|
|
396
|
+
│ └── utils/
|
|
397
|
+
│ └── README.md
|
|
398
|
+
└── README.md
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Error Handling
|
|
402
|
+
|
|
403
|
+
**Batch Worker**: Tool fallback per module, batch isolation, clear status reporting
|
|
404
|
+
**Coordinator**: Invalid path abort, user decline handling, verification with cleanup
|
|
405
|
+
**Fallback Triggers**: Non-zero exit code, script timeout, unexpected output
|
|
406
|
+
|
|
407
|
+
## Output Structure
|
|
408
|
+
|
|
409
|
+
```
|
|
410
|
+
.workflow/docs/{project_name}/
|
|
411
|
+
├── src/ # Mirrors source structure
|
|
412
|
+
│ ├── modules/
|
|
413
|
+
│ │ ├── README.md # Navigation
|
|
414
|
+
│ │ ├── auth/
|
|
415
|
+
│ │ │ ├── API.md # API signatures
|
|
416
|
+
│ │ │ ├── README.md # Module docs
|
|
417
|
+
│ │ │ └── middleware/
|
|
418
|
+
│ │ │ ├── API.md
|
|
419
|
+
│ │ │ └── README.md
|
|
420
|
+
│ │ └── api/
|
|
421
|
+
│ │ ├── API.md
|
|
422
|
+
│ │ └── README.md
|
|
423
|
+
│ └── utils/
|
|
424
|
+
│ └── README.md
|
|
425
|
+
├── lib/
|
|
426
|
+
│ └── core/
|
|
427
|
+
│ ├── API.md
|
|
428
|
+
│ └── README.md
|
|
429
|
+
├── README.md # ✨ Project root overview (auto-generated)
|
|
430
|
+
├── ARCHITECTURE.md # ✨ System design (auto-generated)
|
|
431
|
+
├── EXAMPLES.md # ✨ Usage examples (auto-generated)
|
|
432
|
+
└── api/ # ✨ Optional (auto-generated if HTTP API detected)
|
|
433
|
+
└── README.md # HTTP API reference
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Usage Examples
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Full project documentation generation
|
|
440
|
+
/memory:docs-full-cli
|
|
441
|
+
|
|
442
|
+
# Target specific directory
|
|
443
|
+
/memory:docs-full-cli src/features/auth
|
|
444
|
+
/memory:docs-full-cli .claude
|
|
445
|
+
|
|
446
|
+
# Use specific tool
|
|
447
|
+
/memory:docs-full-cli --tool qwen
|
|
448
|
+
/memory:docs-full-cli src --tool qwen
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
## Key Advantages
|
|
452
|
+
|
|
453
|
+
- **Efficiency**: 30 modules → 8 agents (73% reduction from sequential)
|
|
454
|
+
- **Resilience**: 3-tier tool fallback per module
|
|
455
|
+
- **Performance**: Parallel batches, no concurrency limits
|
|
456
|
+
- **Observability**: Per-module tool usage, batch-level metrics
|
|
457
|
+
- **Automation**: Zero configuration - strategy auto-selected by directory depth
|
|
458
|
+
- **Path Mirroring**: Clear 1:1 mapping between source and documentation structure
|
|
459
|
+
|
|
460
|
+
## Template Reference
|
|
461
|
+
|
|
462
|
+
Templates used from `~/.claude/workflows/cli-templates/prompts/documentation/`:
|
|
463
|
+
- `api.txt`: Code API documentation (Part A: Code API, Part B: HTTP API)
|
|
464
|
+
- `module-readme.txt`: Module purpose, usage, dependencies
|
|
465
|
+
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
|
466
|
+
|
|
467
|
+
## Related Commands
|
|
468
|
+
|
|
469
|
+
- `/memory:docs` - Agent-based documentation planning workflow
|
|
470
|
+
- `/memory:docs-related-cli` - Update docs for changed modules only
|
|
471
|
+
- `/workflow:execute` - Execute documentation tasks (when using agent mode)
|