claude-code-workflow 6.0.5 → 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/src/cli.js +7 -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 +531 -46
- 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 +11 -1
- 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 +90 -19
- 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/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 -8187
- 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,615 +1,615 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: docs
|
|
3
|
-
description: Plan documentation workflow with dynamic grouping (≤10 docs/task), generates IMPL tasks for parallel module trees, README, ARCHITECTURE, and HTTP API docs
|
|
4
|
-
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Documentation Workflow (/memory:docs)
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
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.
|
|
11
|
-
|
|
12
|
-
**Execution Strategy**:
|
|
13
|
-
- **Dynamic Task Grouping**: Level 1 tasks grouped by top-level directories with document count limit
|
|
14
|
-
- **Primary constraint**: Each task generates ≤10 documents (API.md + README.md count)
|
|
15
|
-
- **Optimization goal**: Prefer grouping 2 top-level directories per task for context sharing
|
|
16
|
-
- **Conflict resolution**: If 2 dirs exceed 10 docs, reduce to 1 dir/task; if 1 dir exceeds 10 docs, split by subdirectories
|
|
17
|
-
- **Context benefit**: Same-task directories analyzed together via single Gemini call
|
|
18
|
-
- **Parallel Execution**: Multiple Level 1 tasks execute concurrently for faster completion
|
|
19
|
-
- **Pre-computed Analysis**: Phase 2 performs unified analysis once, stored in `.process/` for reuse
|
|
20
|
-
- **Efficient Data Loading**: All existing docs loaded once in Phase 2, shared across tasks
|
|
21
|
-
|
|
22
|
-
**Path Mirroring**: Documentation structure mirrors source code under `.workflow/docs/{project_name}/`
|
|
23
|
-
- Example: `my_app/src/core/` → `.workflow/docs/my_app/src/core/API.md`
|
|
24
|
-
|
|
25
|
-
**Two Execution Modes**:
|
|
26
|
-
- **Default (Agent Mode)**: CLI analyzes in `pre_analysis` (MODE=analysis), agent writes docs
|
|
27
|
-
- **--cli-execute (CLI Mode)**: CLI generates docs in `implementation_approach` (MODE=write), agent executes CLI commands
|
|
28
|
-
|
|
29
|
-
## Path Mirroring Strategy
|
|
30
|
-
|
|
31
|
-
**Principle**: Documentation structure **mirrors** source code structure under project-specific directory.
|
|
32
|
-
|
|
33
|
-
| Source Path | Project Name | Documentation Path |
|
|
34
|
-
|------------|--------------|-------------------|
|
|
35
|
-
| `my_app/src/core/` | `my_app` | `.workflow/docs/my_app/src/core/API.md` |
|
|
36
|
-
| `my_app/src/modules/auth/` | `my_app` | `.workflow/docs/my_app/src/modules/auth/API.md` |
|
|
37
|
-
| `another_project/lib/utils/` | `another_project` | `.workflow/docs/another_project/lib/utils/API.md` |
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Parameters
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
/memory:docs [path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
- **path**: Source directory to analyze (default: current directory)
|
|
47
|
-
- Specifies the source code directory to be documented
|
|
48
|
-
- Documentation is generated in a separate `.workflow/docs/{project_name}/` directory at the workspace root, **not** within the source `path` itself
|
|
49
|
-
- The source path's structure is mirrored within the project-specific documentation folder
|
|
50
|
-
- Example: analyzing `src/modules` produces documentation at `.workflow/docs/{project_name}/src/modules/`
|
|
51
|
-
- **--mode**: Documentation generation mode (default: full)
|
|
52
|
-
- `full`: Complete documentation (modules + README + ARCHITECTURE + EXAMPLES + HTTP API)
|
|
53
|
-
- `partial`: Module documentation only (API.md + README.md)
|
|
54
|
-
- **--tool**: CLI tool selection (default: gemini)
|
|
55
|
-
- `gemini`: Comprehensive documentation, pattern recognition
|
|
56
|
-
- `qwen`: Architecture analysis, system design focus
|
|
57
|
-
- `codex`: Implementation validation, code quality
|
|
58
|
-
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
|
59
|
-
|
|
60
|
-
## Planning Workflow
|
|
61
|
-
|
|
62
|
-
### Phase 1: Initialize Session
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# Get target path, project name, and root
|
|
66
|
-
bash(pwd && basename "$(pwd)" && git rev-parse --show-toplevel 2>/dev/null || pwd && date +%Y%m%d-%H%M%S)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
// Create docs session (type: docs)
|
|
71
|
-
SlashCommand(command="/workflow:session:start --type docs --new \"{project_name}-docs-{timestamp}\"")
|
|
72
|
-
// Parse output to get sessionId
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
# Update workflow-session.json with docs-specific fields
|
|
77
|
-
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)
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Phase 2: Analyze Structure
|
|
81
|
-
|
|
82
|
-
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
|
83
|
-
|
|
84
|
-
**Commands** (collect data with simple bash):
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# 1. Run folder analysis
|
|
88
|
-
bash(
|
|
89
|
-
|
|
90
|
-
# 2. Get top-level directories (first 2 path levels)
|
|
91
|
-
bash(
|
|
92
|
-
|
|
93
|
-
# 3. Find existing docs (if directory exists)
|
|
94
|
-
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)
|
|
95
|
-
|
|
96
|
-
# 4. Read existing docs content (if files exist)
|
|
97
|
-
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)
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Data Processing**: Parse bash outputs, calculate statistics, use **Write tool** to create `${session_dir}/.process/doc-planning-data.json` with structure:
|
|
101
|
-
|
|
102
|
-
```json
|
|
103
|
-
{
|
|
104
|
-
"metadata": {
|
|
105
|
-
"generated_at": "2025-11-03T16:57:30.469669",
|
|
106
|
-
"project_name": "project_name",
|
|
107
|
-
"project_root": "/path/to/project"
|
|
108
|
-
},
|
|
109
|
-
"folder_analysis": [
|
|
110
|
-
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2}
|
|
111
|
-
],
|
|
112
|
-
"top_level_dirs": ["src/modules", "lib/core"],
|
|
113
|
-
"existing_docs": {
|
|
114
|
-
"file_list": [".workflow/docs/project/src/core/API.md"],
|
|
115
|
-
"content": "... existing docs content ..."
|
|
116
|
-
},
|
|
117
|
-
"unified_analysis": [],
|
|
118
|
-
"statistics": {
|
|
119
|
-
"total": 15,
|
|
120
|
-
"code": 8,
|
|
121
|
-
"navigation": 7,
|
|
122
|
-
"top_level": 3
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Then** use **Edit tool** to update `workflow-session.json` adding analysis field.
|
|
128
|
-
|
|
129
|
-
**Output**: Single `doc-planning-data.json` with all analysis data (no temp files or Python scripts).
|
|
130
|
-
|
|
131
|
-
**Auto-skipped**: Tests (`**/test/**`, `**/*.test.*`), Build (`**/node_modules/**`, `**/dist/**`), Config (root-level files), Vendor directories.
|
|
132
|
-
|
|
133
|
-
### Phase 3: Detect Update Mode
|
|
134
|
-
|
|
135
|
-
**Commands**:
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
# Count existing docs from doc-planning-data.json
|
|
139
|
-
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq '.existing_docs.file_list | length')
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Data Processing**: Use count result, then use **Edit tool** to update `workflow-session.json`:
|
|
143
|
-
- Add `"update_mode": "update"` if count > 0, else `"create"`
|
|
144
|
-
- Add `"existing_docs": <count>`
|
|
145
|
-
|
|
146
|
-
### Phase 4: Decompose Tasks
|
|
147
|
-
|
|
148
|
-
**Task Hierarchy** (Dynamic based on document count):
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
Small Projects (total ≤10 docs):
|
|
152
|
-
Level 1: IMPL-001 (all directories in single task, shared context)
|
|
153
|
-
Level 2: IMPL-002 (README, full mode only)
|
|
154
|
-
Level 3: IMPL-003 (ARCHITECTURE+EXAMPLES), IMPL-004 (HTTP API, optional)
|
|
155
|
-
|
|
156
|
-
Medium Projects (Example: 7 top-level dirs, 18 total docs):
|
|
157
|
-
Step 1: Count docs per top-level dir
|
|
158
|
-
├─ dir1: 3 docs, dir2: 4 docs → Group 1 (7 docs)
|
|
159
|
-
├─ dir3: 5 docs, dir4: 3 docs → Group 2 (8 docs)
|
|
160
|
-
├─ dir5: 2 docs → Group 3 (2 docs, can add more)
|
|
161
|
-
|
|
162
|
-
Step 2: Create tasks with ≤10 docs constraint
|
|
163
|
-
Level 1: IMPL-001 to IMPL-003 (parallel groups)
|
|
164
|
-
├─ IMPL-001: Group 1 (dir1 + dir2, 7 docs, shared context)
|
|
165
|
-
├─ IMPL-002: Group 2 (dir3 + dir4, 8 docs, shared context)
|
|
166
|
-
└─ IMPL-003: Group 3 (remaining dirs, ≤10 docs)
|
|
167
|
-
Level 2: IMPL-004 (README, depends on Level 1, full mode only)
|
|
168
|
-
Level 3: IMPL-005 (ARCHITECTURE+EXAMPLES), IMPL-006 (HTTP API, optional)
|
|
169
|
-
|
|
170
|
-
Large Projects (single dir >10 docs):
|
|
171
|
-
Step 1: Detect oversized directory
|
|
172
|
-
└─ src/modules/: 15 subdirs → 30 docs (exceeds limit)
|
|
173
|
-
|
|
174
|
-
Step 2: Split by subdirectories
|
|
175
|
-
Level 1: IMPL-001 to IMPL-003 (split oversized dir)
|
|
176
|
-
├─ IMPL-001: src/modules/ subdirs 1-5 (10 docs)
|
|
177
|
-
├─ IMPL-002: src/modules/ subdirs 6-10 (10 docs)
|
|
178
|
-
└─ IMPL-003: src/modules/ subdirs 11-15 (10 docs)
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**Grouping Algorithm**:
|
|
182
|
-
1. Count total docs for each top-level directory
|
|
183
|
-
2. Try grouping 2 directories (optimization for context sharing)
|
|
184
|
-
3. If group exceeds 10 docs, split to 1 dir/task
|
|
185
|
-
4. If single dir exceeds 10 docs, split by subdirectories
|
|
186
|
-
5. Create parallel Level 1 tasks with ≤10 docs each
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
**Commands**:
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
# 1. Get top-level directories from doc-planning-data.json
|
|
193
|
-
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq -r '.top_level_dirs[]')
|
|
194
|
-
|
|
195
|
-
# 2. Get mode from workflow-session.json
|
|
196
|
-
bash(cat .workflow/active/WFS-docs-{timestamp}/workflow-session.json | jq -r '.mode // "full"')
|
|
197
|
-
|
|
198
|
-
# 3. Check for HTTP API
|
|
199
|
-
bash(grep -r "router\.|@Get\|@Post" src/ 2>/dev/null && echo "API_FOUND" || echo "NO_API")
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**Data Processing**:
|
|
203
|
-
1. Count documents for each top-level directory (from folder_analysis):
|
|
204
|
-
- Code folders: 2 docs each (API.md + README.md)
|
|
205
|
-
- Navigation folders: 1 doc each (README.md only)
|
|
206
|
-
2. Apply grouping algorithm with ≤10 docs constraint:
|
|
207
|
-
- Try grouping 2 directories, calculate total docs
|
|
208
|
-
- If total ≤10 docs: create group
|
|
209
|
-
- If total >10 docs: split to 1 dir/group or subdivide
|
|
210
|
-
- If single dir >10 docs: split by subdirectories
|
|
211
|
-
3. Use **Edit tool** to update `doc-planning-data.json` adding groups field:
|
|
212
|
-
```json
|
|
213
|
-
"groups": {
|
|
214
|
-
"count": 3,
|
|
215
|
-
"assignments": [
|
|
216
|
-
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 5},
|
|
217
|
-
{"group_id": "002", "directories": ["lib/core"], "doc_count": 6},
|
|
218
|
-
{"group_id": "003", "directories": ["lib/helpers"], "doc_count": 3}
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**Task ID Calculation**:
|
|
224
|
-
```bash
|
|
225
|
-
group_count=$(jq '.groups.count' .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json)
|
|
226
|
-
readme_id=$((group_count + 1)) # Next ID after groups
|
|
227
|
-
arch_id=$((group_count + 2))
|
|
228
|
-
api_id=$((group_count + 3))
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Phase 5: Generate Task JSONs
|
|
232
|
-
|
|
233
|
-
**CLI Strategy**:
|
|
234
|
-
|
|
235
|
-
| Mode | cli_execute | Placement | CLI MODE | Approval Flag | Agent Role |
|
|
236
|
-
|------|-------------|-----------|----------|---------------|------------|
|
|
237
|
-
| **Agent** | false | pre_analysis | analysis | (none) | Generate docs in implementation_approach |
|
|
238
|
-
| **CLI** | true | implementation_approach | write | --approval-mode yolo | Execute CLI commands, validate output |
|
|
239
|
-
|
|
240
|
-
**Command Patterns**:
|
|
241
|
-
- Gemini/Qwen: `cd dir && gemini -p "..."`
|
|
242
|
-
- CLI Mode: `cd dir && gemini --approval-mode yolo -p "..."`
|
|
243
|
-
- Codex: `codex -C dir --full-auto exec "..." --skip-git-repo-check -s danger-full-access`
|
|
244
|
-
|
|
245
|
-
**Generation Process**:
|
|
246
|
-
1. Read configuration values (tool, cli_execute, mode) from workflow-session.json
|
|
247
|
-
2. Read group assignments from doc-planning-data.json
|
|
248
|
-
3. Generate Level 1 tasks (IMPL-001 to IMPL-N, one per group)
|
|
249
|
-
4. Generate Level 2+ tasks if mode=full (README, ARCHITECTURE, HTTP API)
|
|
250
|
-
|
|
251
|
-
## Task Templates
|
|
252
|
-
|
|
253
|
-
### Level 1: Module Trees Group Task (Unified)
|
|
254
|
-
|
|
255
|
-
**Execution Model**: Each task processes assigned directory group (max 2 directories) using pre-analyzed data from Phase 2.
|
|
256
|
-
|
|
257
|
-
```json
|
|
258
|
-
{
|
|
259
|
-
"id": "IMPL-${group_number}",
|
|
260
|
-
"title": "Document Module Trees Group ${group_number}",
|
|
261
|
-
"status": "pending",
|
|
262
|
-
"meta": {
|
|
263
|
-
"type": "docs-tree-group",
|
|
264
|
-
"agent": "@doc-generator",
|
|
265
|
-
"tool": "gemini",
|
|
266
|
-
"cli_execute": false,
|
|
267
|
-
"group_number": "${group_number}",
|
|
268
|
-
"total_groups": "${total_groups}"
|
|
269
|
-
},
|
|
270
|
-
"context": {
|
|
271
|
-
"requirements": [
|
|
272
|
-
"Process directories from group ${group_number} in doc-planning-data.json",
|
|
273
|
-
"Generate docs to .workflow/docs/${project_name}/ (mirrored structure)",
|
|
274
|
-
"Code folders: API.md + README.md; Navigation folders: README.md only",
|
|
275
|
-
"Use pre-analyzed data from Phase 2 (no redundant analysis)"
|
|
276
|
-
],
|
|
277
|
-
"focus_paths": ["${group_dirs_from_json}"],
|
|
278
|
-
"precomputed_data": {
|
|
279
|
-
"phase2_analysis": "${session_dir}/.process/doc-planning-data.json"
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"flow_control": {
|
|
283
|
-
"pre_analysis": [
|
|
284
|
-
{
|
|
285
|
-
"step": "load_precomputed_data",
|
|
286
|
-
"action": "Load Phase 2 analysis and extract group directories",
|
|
287
|
-
"commands": [
|
|
288
|
-
"bash(cat ${session_dir}/.process/doc-planning-data.json)",
|
|
289
|
-
"bash(jq '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories' ${session_dir}/.process/doc-planning-data.json)"
|
|
290
|
-
],
|
|
291
|
-
"output_to": "phase2_context",
|
|
292
|
-
"note": "Single JSON file contains all Phase 2 analysis results"
|
|
293
|
-
}
|
|
294
|
-
],
|
|
295
|
-
"implementation_approach": [
|
|
296
|
-
{
|
|
297
|
-
"step": 1,
|
|
298
|
-
"title": "Generate documentation for assigned directory group",
|
|
299
|
-
"description": "Process directories in Group ${group_number} using pre-analyzed data",
|
|
300
|
-
"modification_points": [
|
|
301
|
-
"Read group directories from [phase2_context].groups.assignments[${group_number}].directories",
|
|
302
|
-
"For each directory: parse folder types from folder_analysis, parse structure from unified_analysis",
|
|
303
|
-
"Map source_path to .workflow/docs/${project_name}/{path}",
|
|
304
|
-
"Generate API.md for code folders, README.md for all folders",
|
|
305
|
-
"Preserve user modifications from [phase2_context].existing_docs.content"
|
|
306
|
-
],
|
|
307
|
-
"logic_flow": [
|
|
308
|
-
"phase2 = parse([phase2_context])",
|
|
309
|
-
"dirs = phase2.groups.assignments[${group_number}].directories",
|
|
310
|
-
"for dir in dirs:",
|
|
311
|
-
" folder_info = find(dir, phase2.folder_analysis)",
|
|
312
|
-
" outline = find(dir, phase2.unified_analysis)",
|
|
313
|
-
" if folder_info.type == 'code': generate API.md + README.md",
|
|
314
|
-
" elif folder_info.type == 'navigation': generate README.md only",
|
|
315
|
-
" write to .workflow/docs/${project_name}/{dir}/"
|
|
316
|
-
],
|
|
317
|
-
"depends_on": [],
|
|
318
|
-
"output": "group_module_docs"
|
|
319
|
-
}
|
|
320
|
-
],
|
|
321
|
-
"target_files": [
|
|
322
|
-
".workflow/docs/${project_name}/*/API.md",
|
|
323
|
-
".workflow/docs/${project_name}/*/README.md"
|
|
324
|
-
]
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
**CLI Execute Mode Note**: When `cli_execute=true`, add Step 2 in `implementation_approach`:
|
|
330
|
-
```json
|
|
331
|
-
{
|
|
332
|
-
"step": 2,
|
|
333
|
-
"title": "Batch generate documentation via CLI",
|
|
334
|
-
"command": "bash(dirs=$(jq -r '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories[]' ${session_dir}/.process/doc-planning-data.json); for dir in $dirs; do cd \"$dir\" && gemini --approval-mode yolo -p \"PURPOSE: Generate module docs\\nTASK: Create documentation\\nMODE: write\\nCONTEXT: @**/* [phase2_context]\\nEXPECTED: API.md and README.md\\nRULES: Mirror structure\" || echo \"Failed: $dir\"; cd -; done)",
|
|
335
|
-
"depends_on": [1],
|
|
336
|
-
"output": "generated_docs"
|
|
337
|
-
}
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Level 2: Project README Task
|
|
341
|
-
|
|
342
|
-
**Task ID**: `IMPL-${readme_id}` (where `readme_id = group_count + 1`)
|
|
343
|
-
**Dependencies**: Depends on all Level 1 tasks completing.
|
|
344
|
-
|
|
345
|
-
```json
|
|
346
|
-
{
|
|
347
|
-
"id": "IMPL-${readme_id}",
|
|
348
|
-
"title": "Generate Project README",
|
|
349
|
-
"status": "pending",
|
|
350
|
-
"depends_on": ["IMPL-001", "...", "IMPL-${group_count}"],
|
|
351
|
-
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
352
|
-
"flow_control": {
|
|
353
|
-
"pre_analysis": [
|
|
354
|
-
{
|
|
355
|
-
"step": "load_existing_readme",
|
|
356
|
-
"command": "bash(cat .workflow/docs/${project_name}/README.md 2>/dev/null || echo 'No existing README')",
|
|
357
|
-
"output_to": "existing_readme"
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
"step": "load_module_docs",
|
|
361
|
-
"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)",
|
|
362
|
-
"output_to": "all_module_docs"
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
"step": "analyze_project",
|
|
366
|
-
"command": "bash(gemini \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")",
|
|
367
|
-
"output_to": "project_outline"
|
|
368
|
-
}
|
|
369
|
-
],
|
|
370
|
-
"implementation_approach": [
|
|
371
|
-
{
|
|
372
|
-
"step": 1,
|
|
373
|
-
"title": "Generate project README",
|
|
374
|
-
"description": "Generate project README with navigation links while preserving user modifications",
|
|
375
|
-
"modification_points": [
|
|
376
|
-
"Parse [project_outline] and [all_module_docs]",
|
|
377
|
-
"Generate README structure with navigation links",
|
|
378
|
-
"Preserve [existing_readme] user modifications"
|
|
379
|
-
],
|
|
380
|
-
"logic_flow": ["Parse data", "Generate README with navigation", "Preserve modifications"],
|
|
381
|
-
"depends_on": [],
|
|
382
|
-
"output": "project_readme"
|
|
383
|
-
}
|
|
384
|
-
],
|
|
385
|
-
"target_files": [".workflow/docs/${project_name}/README.md"]
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### Level 3: Architecture & Examples Documentation Task
|
|
391
|
-
|
|
392
|
-
**Task ID**: `IMPL-${arch_id}` (where `arch_id = group_count + 2`)
|
|
393
|
-
**Dependencies**: Depends on Level 2 (Project README).
|
|
394
|
-
|
|
395
|
-
```json
|
|
396
|
-
{
|
|
397
|
-
"id": "IMPL-${arch_id}",
|
|
398
|
-
"title": "Generate Architecture & Examples Documentation",
|
|
399
|
-
"status": "pending",
|
|
400
|
-
"depends_on": ["IMPL-${readme_id}"],
|
|
401
|
-
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
402
|
-
"flow_control": {
|
|
403
|
-
"pre_analysis": [
|
|
404
|
-
{"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"},
|
|
405
|
-
{"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"},
|
|
406
|
-
{"step": "analyze_architecture", "command": "bash(gemini \"PURPOSE: Analyze system architecture\\nTASK: Synthesize architectural overview and examples\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture + Examples outline\")", "output_to": "arch_examples_outline"}
|
|
407
|
-
],
|
|
408
|
-
"implementation_approach": [
|
|
409
|
-
{
|
|
410
|
-
"step": 1,
|
|
411
|
-
"title": "Generate architecture and examples documentation",
|
|
412
|
-
"modification_points": [
|
|
413
|
-
"Parse [arch_examples_outline] and [all_docs]",
|
|
414
|
-
"Generate ARCHITECTURE.md (system design, patterns)",
|
|
415
|
-
"Generate EXAMPLES.md (code snippets, usage)",
|
|
416
|
-
"Preserve [existing_arch_examples] modifications"
|
|
417
|
-
],
|
|
418
|
-
"depends_on": [],
|
|
419
|
-
"output": "arch_examples_docs"
|
|
420
|
-
}
|
|
421
|
-
],
|
|
422
|
-
"target_files": [".workflow/docs/${project_name}/ARCHITECTURE.md", ".workflow/docs/${project_name}/EXAMPLES.md"]
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
### Level 4: HTTP API Documentation Task (Optional)
|
|
428
|
-
|
|
429
|
-
**Task ID**: `IMPL-${api_id}` (where `api_id = group_count + 3`)
|
|
430
|
-
**Dependencies**: Depends on Level 3.
|
|
431
|
-
|
|
432
|
-
```json
|
|
433
|
-
{
|
|
434
|
-
"id": "IMPL-${api_id}",
|
|
435
|
-
"title": "Generate HTTP API Documentation",
|
|
436
|
-
"status": "pending",
|
|
437
|
-
"depends_on": ["IMPL-${arch_id}"],
|
|
438
|
-
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
439
|
-
"flow_control": {
|
|
440
|
-
"pre_analysis": [
|
|
441
|
-
{"step": "discover_api", "command": "bash(rg 'router\\.| @(Get|Post)' -g '*.{ts,js}')", "output_to": "endpoint_discovery"},
|
|
442
|
-
{"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"},
|
|
443
|
-
{"step": "analyze_api", "command": "bash(gemini \"PURPOSE: Document HTTP API\\nTASK: Analyze endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\")", "output_to": "api_outline"}
|
|
444
|
-
],
|
|
445
|
-
"implementation_approach": [
|
|
446
|
-
{
|
|
447
|
-
"step": 1,
|
|
448
|
-
"title": "Generate HTTP API documentation",
|
|
449
|
-
"modification_points": [
|
|
450
|
-
"Parse [api_outline] and [endpoint_discovery]",
|
|
451
|
-
"Document endpoints, request/response formats",
|
|
452
|
-
"Preserve [existing_api_docs] modifications"
|
|
453
|
-
],
|
|
454
|
-
"depends_on": [],
|
|
455
|
-
"output": "api_docs"
|
|
456
|
-
}
|
|
457
|
-
],
|
|
458
|
-
"target_files": [".workflow/docs/${project_name}/api/README.md"]
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
## Session Structure
|
|
464
|
-
|
|
465
|
-
**Unified Structure** (single JSON replaces multiple text files):
|
|
466
|
-
|
|
467
|
-
```
|
|
468
|
-
.workflow/active/
|
|
469
|
-
└── WFS-docs-{timestamp}/
|
|
470
|
-
├── workflow-session.json # Session metadata
|
|
471
|
-
├── IMPL_PLAN.md
|
|
472
|
-
├── TODO_LIST.md
|
|
473
|
-
├── .process/
|
|
474
|
-
│ └── doc-planning-data.json # All Phase 2 analysis data (replaces 7+ files)
|
|
475
|
-
└── .task/
|
|
476
|
-
├── IMPL-001.json # Small: all modules | Large: group 1
|
|
477
|
-
├── IMPL-00N.json # (Large only: groups 2-N)
|
|
478
|
-
├── IMPL-{N+1}.json # README (full mode)
|
|
479
|
-
├── IMPL-{N+2}.json # ARCHITECTURE+EXAMPLES (full mode)
|
|
480
|
-
└── IMPL-{N+3}.json # HTTP API (optional)
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**doc-planning-data.json Structure**:
|
|
484
|
-
```json
|
|
485
|
-
{
|
|
486
|
-
"metadata": {
|
|
487
|
-
"generated_at": "2025-11-03T16:41:06+08:00",
|
|
488
|
-
"project_name": "Claude_dms3",
|
|
489
|
-
"project_root": "/d/Claude_dms3"
|
|
490
|
-
},
|
|
491
|
-
"folder_analysis": [
|
|
492
|
-
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2},
|
|
493
|
-
{"path": "./src/utils", "type": "navigation", "code_count": 0, "dirs_count": 4}
|
|
494
|
-
],
|
|
495
|
-
"top_level_dirs": ["src/modules", "src/utils", "lib/core"],
|
|
496
|
-
"existing_docs": {
|
|
497
|
-
"file_list": [".workflow/docs/project/src/core/API.md"],
|
|
498
|
-
"content": "... concatenated existing docs ..."
|
|
499
|
-
},
|
|
500
|
-
"unified_analysis": [
|
|
501
|
-
{"module_path": "./src/core", "outline_summary": "Core functionality"}
|
|
502
|
-
],
|
|
503
|
-
"groups": {
|
|
504
|
-
"count": 4,
|
|
505
|
-
"assignments": [
|
|
506
|
-
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 6},
|
|
507
|
-
{"group_id": "002", "directories": ["lib/core", "lib/helpers"], "doc_count": 7}
|
|
508
|
-
]
|
|
509
|
-
},
|
|
510
|
-
"statistics": {
|
|
511
|
-
"total": 15,
|
|
512
|
-
"code": 8,
|
|
513
|
-
"navigation": 7,
|
|
514
|
-
"top_level": 3
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
**Workflow Session Structure** (workflow-session.json):
|
|
520
|
-
```json
|
|
521
|
-
{
|
|
522
|
-
"session_id": "WFS-docs-{timestamp}",
|
|
523
|
-
"project": "{project_name} documentation",
|
|
524
|
-
"status": "planning",
|
|
525
|
-
"timestamp": "2024-01-20T14:30:22+08:00",
|
|
526
|
-
"path": ".",
|
|
527
|
-
"target_path": "/path/to/project",
|
|
528
|
-
"project_root": "/path/to/project",
|
|
529
|
-
"project_name": "{project_name}",
|
|
530
|
-
"mode": "full",
|
|
531
|
-
"tool": "gemini",
|
|
532
|
-
"cli_execute": false,
|
|
533
|
-
"update_mode": "update",
|
|
534
|
-
"existing_docs": 5,
|
|
535
|
-
"analysis": {
|
|
536
|
-
"total": "15",
|
|
537
|
-
"code": "8",
|
|
538
|
-
"navigation": "7",
|
|
539
|
-
"top_level": "3"
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
## Generated Documentation
|
|
545
|
-
|
|
546
|
-
**Structure mirrors project source directories under project-specific folder**:
|
|
547
|
-
|
|
548
|
-
```
|
|
549
|
-
.workflow/docs/
|
|
550
|
-
└── {project_name}/ # Project-specific root
|
|
551
|
-
├── src/ # Mirrors src/ directory
|
|
552
|
-
│ ├── modules/
|
|
553
|
-
│ │ ├── README.md # Navigation
|
|
554
|
-
│ │ ├── auth/
|
|
555
|
-
│ │ │ ├── API.md # API signatures
|
|
556
|
-
│ │ │ ├── README.md # Module docs
|
|
557
|
-
│ │ │ └── middleware/
|
|
558
|
-
│ │ │ ├── API.md
|
|
559
|
-
│ │ │ └── README.md
|
|
560
|
-
│ │ └── api/
|
|
561
|
-
│ │ ├── API.md
|
|
562
|
-
│ │ └── README.md
|
|
563
|
-
│ └── utils/
|
|
564
|
-
│ └── README.md
|
|
565
|
-
├── lib/ # Mirrors lib/ directory
|
|
566
|
-
│ └── core/
|
|
567
|
-
│ ├── API.md
|
|
568
|
-
│ └── README.md
|
|
569
|
-
├── README.md # Project root
|
|
570
|
-
├── ARCHITECTURE.md # System design
|
|
571
|
-
├── EXAMPLES.md # Usage examples
|
|
572
|
-
└── api/ # Optional
|
|
573
|
-
└── README.md # HTTP API reference
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
## Execution Commands
|
|
577
|
-
|
|
578
|
-
```bash
|
|
579
|
-
# Execute entire workflow (auto-discovers active session)
|
|
580
|
-
/workflow:execute
|
|
581
|
-
|
|
582
|
-
# Or specify session
|
|
583
|
-
/workflow:execute --resume-session="WFS-docs-yyyymmdd-hhmmss"
|
|
584
|
-
|
|
585
|
-
# Individual task execution
|
|
586
|
-
/task:execute IMPL-001
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
## Template Reference
|
|
590
|
-
|
|
591
|
-
**Available Templates** (`~/.claude/workflows/cli-templates/prompts/documentation/`):
|
|
592
|
-
- `api.txt`: Code API (Part A) + HTTP API (Part B)
|
|
593
|
-
- `module-readme.txt`: Module purpose, usage, dependencies
|
|
594
|
-
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
|
595
|
-
- `project-readme.txt`: Project overview, getting started, navigation
|
|
596
|
-
- `project-architecture.txt`: System structure, module map, design patterns
|
|
597
|
-
- `project-examples.txt`: End-to-end usage examples
|
|
598
|
-
|
|
599
|
-
## Execution Mode Summary
|
|
600
|
-
|
|
601
|
-
| Mode | CLI Placement | CLI MODE | Approval Flag | Agent Role |
|
|
602
|
-
|------|---------------|----------|---------------|------------|
|
|
603
|
-
| **Agent (default)** | pre_analysis | analysis | (none) | Generates documentation content |
|
|
604
|
-
| **CLI (--cli-execute)** | implementation_approach | write | --approval-mode yolo | Executes CLI commands, validates output |
|
|
605
|
-
|
|
606
|
-
**Execution Flow**:
|
|
607
|
-
- **Phase 2**: Unified analysis once, results in `.process/`
|
|
608
|
-
- **Phase 4**: Dynamic grouping (max 2 dirs per group)
|
|
609
|
-
- **Level 1**: Parallel processing for module tree groups
|
|
610
|
-
- **Level 2+**: Sequential execution for project-level docs
|
|
611
|
-
|
|
612
|
-
## Related Commands
|
|
613
|
-
- `/workflow:execute` - Execute documentation tasks
|
|
614
|
-
- `/workflow:status` - View task progress
|
|
615
|
-
- `/workflow:session:complete` - Mark session complete
|
|
1
|
+
---
|
|
2
|
+
name: docs
|
|
3
|
+
description: Plan documentation workflow with dynamic grouping (≤10 docs/task), generates IMPL tasks for parallel module trees, README, ARCHITECTURE, and HTTP API docs
|
|
4
|
+
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Documentation Workflow (/memory:docs)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
**Execution Strategy**:
|
|
13
|
+
- **Dynamic Task Grouping**: Level 1 tasks grouped by top-level directories with document count limit
|
|
14
|
+
- **Primary constraint**: Each task generates ≤10 documents (API.md + README.md count)
|
|
15
|
+
- **Optimization goal**: Prefer grouping 2 top-level directories per task for context sharing
|
|
16
|
+
- **Conflict resolution**: If 2 dirs exceed 10 docs, reduce to 1 dir/task; if 1 dir exceeds 10 docs, split by subdirectories
|
|
17
|
+
- **Context benefit**: Same-task directories analyzed together via single Gemini call
|
|
18
|
+
- **Parallel Execution**: Multiple Level 1 tasks execute concurrently for faster completion
|
|
19
|
+
- **Pre-computed Analysis**: Phase 2 performs unified analysis once, stored in `.process/` for reuse
|
|
20
|
+
- **Efficient Data Loading**: All existing docs loaded once in Phase 2, shared across tasks
|
|
21
|
+
|
|
22
|
+
**Path Mirroring**: Documentation structure mirrors source code under `.workflow/docs/{project_name}/`
|
|
23
|
+
- Example: `my_app/src/core/` → `.workflow/docs/my_app/src/core/API.md`
|
|
24
|
+
|
|
25
|
+
**Two Execution Modes**:
|
|
26
|
+
- **Default (Agent Mode)**: CLI analyzes in `pre_analysis` (MODE=analysis), agent writes docs
|
|
27
|
+
- **--cli-execute (CLI Mode)**: CLI generates docs in `implementation_approach` (MODE=write), agent executes CLI commands
|
|
28
|
+
|
|
29
|
+
## Path Mirroring Strategy
|
|
30
|
+
|
|
31
|
+
**Principle**: Documentation structure **mirrors** source code structure under project-specific directory.
|
|
32
|
+
|
|
33
|
+
| Source Path | Project Name | Documentation Path |
|
|
34
|
+
|------------|--------------|-------------------|
|
|
35
|
+
| `my_app/src/core/` | `my_app` | `.workflow/docs/my_app/src/core/API.md` |
|
|
36
|
+
| `my_app/src/modules/auth/` | `my_app` | `.workflow/docs/my_app/src/modules/auth/API.md` |
|
|
37
|
+
| `another_project/lib/utils/` | `another_project` | `.workflow/docs/another_project/lib/utils/API.md` |
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Parameters
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
/memory:docs [path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **path**: Source directory to analyze (default: current directory)
|
|
47
|
+
- Specifies the source code directory to be documented
|
|
48
|
+
- Documentation is generated in a separate `.workflow/docs/{project_name}/` directory at the workspace root, **not** within the source `path` itself
|
|
49
|
+
- The source path's structure is mirrored within the project-specific documentation folder
|
|
50
|
+
- Example: analyzing `src/modules` produces documentation at `.workflow/docs/{project_name}/src/modules/`
|
|
51
|
+
- **--mode**: Documentation generation mode (default: full)
|
|
52
|
+
- `full`: Complete documentation (modules + README + ARCHITECTURE + EXAMPLES + HTTP API)
|
|
53
|
+
- `partial`: Module documentation only (API.md + README.md)
|
|
54
|
+
- **--tool**: CLI tool selection (default: gemini)
|
|
55
|
+
- `gemini`: Comprehensive documentation, pattern recognition
|
|
56
|
+
- `qwen`: Architecture analysis, system design focus
|
|
57
|
+
- `codex`: Implementation validation, code quality
|
|
58
|
+
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
|
59
|
+
|
|
60
|
+
## Planning Workflow
|
|
61
|
+
|
|
62
|
+
### Phase 1: Initialize Session
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Get target path, project name, and root
|
|
66
|
+
bash(pwd && basename "$(pwd)" && git rev-parse --show-toplevel 2>/dev/null || pwd && date +%Y%m%d-%H%M%S)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// Create docs session (type: docs)
|
|
71
|
+
SlashCommand(command="/workflow:session:start --type docs --new \"{project_name}-docs-{timestamp}\"")
|
|
72
|
+
// Parse output to get sessionId
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Update workflow-session.json with docs-specific fields
|
|
77
|
+
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)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Phase 2: Analyze Structure
|
|
81
|
+
|
|
82
|
+
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
|
83
|
+
|
|
84
|
+
**Commands** (collect data with simple bash):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 1. Run folder analysis
|
|
88
|
+
bash(ccw tool exec get_modules_by_depth '{}' | ccw tool exec classify_folders '{}')
|
|
89
|
+
|
|
90
|
+
# 2. Get top-level directories (first 2 path levels)
|
|
91
|
+
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)
|
|
92
|
+
|
|
93
|
+
# 3. Find existing docs (if directory exists)
|
|
94
|
+
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)
|
|
95
|
+
|
|
96
|
+
# 4. Read existing docs content (if files exist)
|
|
97
|
+
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)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Data Processing**: Parse bash outputs, calculate statistics, use **Write tool** to create `${session_dir}/.process/doc-planning-data.json` with structure:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"metadata": {
|
|
105
|
+
"generated_at": "2025-11-03T16:57:30.469669",
|
|
106
|
+
"project_name": "project_name",
|
|
107
|
+
"project_root": "/path/to/project"
|
|
108
|
+
},
|
|
109
|
+
"folder_analysis": [
|
|
110
|
+
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2}
|
|
111
|
+
],
|
|
112
|
+
"top_level_dirs": ["src/modules", "lib/core"],
|
|
113
|
+
"existing_docs": {
|
|
114
|
+
"file_list": [".workflow/docs/project/src/core/API.md"],
|
|
115
|
+
"content": "... existing docs content ..."
|
|
116
|
+
},
|
|
117
|
+
"unified_analysis": [],
|
|
118
|
+
"statistics": {
|
|
119
|
+
"total": 15,
|
|
120
|
+
"code": 8,
|
|
121
|
+
"navigation": 7,
|
|
122
|
+
"top_level": 3
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Then** use **Edit tool** to update `workflow-session.json` adding analysis field.
|
|
128
|
+
|
|
129
|
+
**Output**: Single `doc-planning-data.json` with all analysis data (no temp files or Python scripts).
|
|
130
|
+
|
|
131
|
+
**Auto-skipped**: Tests (`**/test/**`, `**/*.test.*`), Build (`**/node_modules/**`, `**/dist/**`), Config (root-level files), Vendor directories.
|
|
132
|
+
|
|
133
|
+
### Phase 3: Detect Update Mode
|
|
134
|
+
|
|
135
|
+
**Commands**:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Count existing docs from doc-planning-data.json
|
|
139
|
+
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq '.existing_docs.file_list | length')
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Data Processing**: Use count result, then use **Edit tool** to update `workflow-session.json`:
|
|
143
|
+
- Add `"update_mode": "update"` if count > 0, else `"create"`
|
|
144
|
+
- Add `"existing_docs": <count>`
|
|
145
|
+
|
|
146
|
+
### Phase 4: Decompose Tasks
|
|
147
|
+
|
|
148
|
+
**Task Hierarchy** (Dynamic based on document count):
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
Small Projects (total ≤10 docs):
|
|
152
|
+
Level 1: IMPL-001 (all directories in single task, shared context)
|
|
153
|
+
Level 2: IMPL-002 (README, full mode only)
|
|
154
|
+
Level 3: IMPL-003 (ARCHITECTURE+EXAMPLES), IMPL-004 (HTTP API, optional)
|
|
155
|
+
|
|
156
|
+
Medium Projects (Example: 7 top-level dirs, 18 total docs):
|
|
157
|
+
Step 1: Count docs per top-level dir
|
|
158
|
+
├─ dir1: 3 docs, dir2: 4 docs → Group 1 (7 docs)
|
|
159
|
+
├─ dir3: 5 docs, dir4: 3 docs → Group 2 (8 docs)
|
|
160
|
+
├─ dir5: 2 docs → Group 3 (2 docs, can add more)
|
|
161
|
+
|
|
162
|
+
Step 2: Create tasks with ≤10 docs constraint
|
|
163
|
+
Level 1: IMPL-001 to IMPL-003 (parallel groups)
|
|
164
|
+
├─ IMPL-001: Group 1 (dir1 + dir2, 7 docs, shared context)
|
|
165
|
+
├─ IMPL-002: Group 2 (dir3 + dir4, 8 docs, shared context)
|
|
166
|
+
└─ IMPL-003: Group 3 (remaining dirs, ≤10 docs)
|
|
167
|
+
Level 2: IMPL-004 (README, depends on Level 1, full mode only)
|
|
168
|
+
Level 3: IMPL-005 (ARCHITECTURE+EXAMPLES), IMPL-006 (HTTP API, optional)
|
|
169
|
+
|
|
170
|
+
Large Projects (single dir >10 docs):
|
|
171
|
+
Step 1: Detect oversized directory
|
|
172
|
+
└─ src/modules/: 15 subdirs → 30 docs (exceeds limit)
|
|
173
|
+
|
|
174
|
+
Step 2: Split by subdirectories
|
|
175
|
+
Level 1: IMPL-001 to IMPL-003 (split oversized dir)
|
|
176
|
+
├─ IMPL-001: src/modules/ subdirs 1-5 (10 docs)
|
|
177
|
+
├─ IMPL-002: src/modules/ subdirs 6-10 (10 docs)
|
|
178
|
+
└─ IMPL-003: src/modules/ subdirs 11-15 (10 docs)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Grouping Algorithm**:
|
|
182
|
+
1. Count total docs for each top-level directory
|
|
183
|
+
2. Try grouping 2 directories (optimization for context sharing)
|
|
184
|
+
3. If group exceeds 10 docs, split to 1 dir/task
|
|
185
|
+
4. If single dir exceeds 10 docs, split by subdirectories
|
|
186
|
+
5. Create parallel Level 1 tasks with ≤10 docs each
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
**Commands**:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# 1. Get top-level directories from doc-planning-data.json
|
|
193
|
+
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq -r '.top_level_dirs[]')
|
|
194
|
+
|
|
195
|
+
# 2. Get mode from workflow-session.json
|
|
196
|
+
bash(cat .workflow/active/WFS-docs-{timestamp}/workflow-session.json | jq -r '.mode // "full"')
|
|
197
|
+
|
|
198
|
+
# 3. Check for HTTP API
|
|
199
|
+
bash(grep -r "router\.|@Get\|@Post" src/ 2>/dev/null && echo "API_FOUND" || echo "NO_API")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Data Processing**:
|
|
203
|
+
1. Count documents for each top-level directory (from folder_analysis):
|
|
204
|
+
- Code folders: 2 docs each (API.md + README.md)
|
|
205
|
+
- Navigation folders: 1 doc each (README.md only)
|
|
206
|
+
2. Apply grouping algorithm with ≤10 docs constraint:
|
|
207
|
+
- Try grouping 2 directories, calculate total docs
|
|
208
|
+
- If total ≤10 docs: create group
|
|
209
|
+
- If total >10 docs: split to 1 dir/group or subdivide
|
|
210
|
+
- If single dir >10 docs: split by subdirectories
|
|
211
|
+
3. Use **Edit tool** to update `doc-planning-data.json` adding groups field:
|
|
212
|
+
```json
|
|
213
|
+
"groups": {
|
|
214
|
+
"count": 3,
|
|
215
|
+
"assignments": [
|
|
216
|
+
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 5},
|
|
217
|
+
{"group_id": "002", "directories": ["lib/core"], "doc_count": 6},
|
|
218
|
+
{"group_id": "003", "directories": ["lib/helpers"], "doc_count": 3}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Task ID Calculation**:
|
|
224
|
+
```bash
|
|
225
|
+
group_count=$(jq '.groups.count' .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json)
|
|
226
|
+
readme_id=$((group_count + 1)) # Next ID after groups
|
|
227
|
+
arch_id=$((group_count + 2))
|
|
228
|
+
api_id=$((group_count + 3))
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Phase 5: Generate Task JSONs
|
|
232
|
+
|
|
233
|
+
**CLI Strategy**:
|
|
234
|
+
|
|
235
|
+
| Mode | cli_execute | Placement | CLI MODE | Approval Flag | Agent Role |
|
|
236
|
+
|------|-------------|-----------|----------|---------------|------------|
|
|
237
|
+
| **Agent** | false | pre_analysis | analysis | (none) | Generate docs in implementation_approach |
|
|
238
|
+
| **CLI** | true | implementation_approach | write | --approval-mode yolo | Execute CLI commands, validate output |
|
|
239
|
+
|
|
240
|
+
**Command Patterns**:
|
|
241
|
+
- Gemini/Qwen: `cd dir && gemini -p "..."`
|
|
242
|
+
- CLI Mode: `cd dir && gemini --approval-mode yolo -p "..."`
|
|
243
|
+
- Codex: `codex -C dir --full-auto exec "..." --skip-git-repo-check -s danger-full-access`
|
|
244
|
+
|
|
245
|
+
**Generation Process**:
|
|
246
|
+
1. Read configuration values (tool, cli_execute, mode) from workflow-session.json
|
|
247
|
+
2. Read group assignments from doc-planning-data.json
|
|
248
|
+
3. Generate Level 1 tasks (IMPL-001 to IMPL-N, one per group)
|
|
249
|
+
4. Generate Level 2+ tasks if mode=full (README, ARCHITECTURE, HTTP API)
|
|
250
|
+
|
|
251
|
+
## Task Templates
|
|
252
|
+
|
|
253
|
+
### Level 1: Module Trees Group Task (Unified)
|
|
254
|
+
|
|
255
|
+
**Execution Model**: Each task processes assigned directory group (max 2 directories) using pre-analyzed data from Phase 2.
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"id": "IMPL-${group_number}",
|
|
260
|
+
"title": "Document Module Trees Group ${group_number}",
|
|
261
|
+
"status": "pending",
|
|
262
|
+
"meta": {
|
|
263
|
+
"type": "docs-tree-group",
|
|
264
|
+
"agent": "@doc-generator",
|
|
265
|
+
"tool": "gemini",
|
|
266
|
+
"cli_execute": false,
|
|
267
|
+
"group_number": "${group_number}",
|
|
268
|
+
"total_groups": "${total_groups}"
|
|
269
|
+
},
|
|
270
|
+
"context": {
|
|
271
|
+
"requirements": [
|
|
272
|
+
"Process directories from group ${group_number} in doc-planning-data.json",
|
|
273
|
+
"Generate docs to .workflow/docs/${project_name}/ (mirrored structure)",
|
|
274
|
+
"Code folders: API.md + README.md; Navigation folders: README.md only",
|
|
275
|
+
"Use pre-analyzed data from Phase 2 (no redundant analysis)"
|
|
276
|
+
],
|
|
277
|
+
"focus_paths": ["${group_dirs_from_json}"],
|
|
278
|
+
"precomputed_data": {
|
|
279
|
+
"phase2_analysis": "${session_dir}/.process/doc-planning-data.json"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"flow_control": {
|
|
283
|
+
"pre_analysis": [
|
|
284
|
+
{
|
|
285
|
+
"step": "load_precomputed_data",
|
|
286
|
+
"action": "Load Phase 2 analysis and extract group directories",
|
|
287
|
+
"commands": [
|
|
288
|
+
"bash(cat ${session_dir}/.process/doc-planning-data.json)",
|
|
289
|
+
"bash(jq '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories' ${session_dir}/.process/doc-planning-data.json)"
|
|
290
|
+
],
|
|
291
|
+
"output_to": "phase2_context",
|
|
292
|
+
"note": "Single JSON file contains all Phase 2 analysis results"
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"implementation_approach": [
|
|
296
|
+
{
|
|
297
|
+
"step": 1,
|
|
298
|
+
"title": "Generate documentation for assigned directory group",
|
|
299
|
+
"description": "Process directories in Group ${group_number} using pre-analyzed data",
|
|
300
|
+
"modification_points": [
|
|
301
|
+
"Read group directories from [phase2_context].groups.assignments[${group_number}].directories",
|
|
302
|
+
"For each directory: parse folder types from folder_analysis, parse structure from unified_analysis",
|
|
303
|
+
"Map source_path to .workflow/docs/${project_name}/{path}",
|
|
304
|
+
"Generate API.md for code folders, README.md for all folders",
|
|
305
|
+
"Preserve user modifications from [phase2_context].existing_docs.content"
|
|
306
|
+
],
|
|
307
|
+
"logic_flow": [
|
|
308
|
+
"phase2 = parse([phase2_context])",
|
|
309
|
+
"dirs = phase2.groups.assignments[${group_number}].directories",
|
|
310
|
+
"for dir in dirs:",
|
|
311
|
+
" folder_info = find(dir, phase2.folder_analysis)",
|
|
312
|
+
" outline = find(dir, phase2.unified_analysis)",
|
|
313
|
+
" if folder_info.type == 'code': generate API.md + README.md",
|
|
314
|
+
" elif folder_info.type == 'navigation': generate README.md only",
|
|
315
|
+
" write to .workflow/docs/${project_name}/{dir}/"
|
|
316
|
+
],
|
|
317
|
+
"depends_on": [],
|
|
318
|
+
"output": "group_module_docs"
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"target_files": [
|
|
322
|
+
".workflow/docs/${project_name}/*/API.md",
|
|
323
|
+
".workflow/docs/${project_name}/*/README.md"
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**CLI Execute Mode Note**: When `cli_execute=true`, add Step 2 in `implementation_approach`:
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"step": 2,
|
|
333
|
+
"title": "Batch generate documentation via CLI",
|
|
334
|
+
"command": "bash(dirs=$(jq -r '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories[]' ${session_dir}/.process/doc-planning-data.json); for dir in $dirs; do cd \"$dir\" && gemini --approval-mode yolo -p \"PURPOSE: Generate module docs\\nTASK: Create documentation\\nMODE: write\\nCONTEXT: @**/* [phase2_context]\\nEXPECTED: API.md and README.md\\nRULES: Mirror structure\" || echo \"Failed: $dir\"; cd -; done)",
|
|
335
|
+
"depends_on": [1],
|
|
336
|
+
"output": "generated_docs"
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Level 2: Project README Task
|
|
341
|
+
|
|
342
|
+
**Task ID**: `IMPL-${readme_id}` (where `readme_id = group_count + 1`)
|
|
343
|
+
**Dependencies**: Depends on all Level 1 tasks completing.
|
|
344
|
+
|
|
345
|
+
```json
|
|
346
|
+
{
|
|
347
|
+
"id": "IMPL-${readme_id}",
|
|
348
|
+
"title": "Generate Project README",
|
|
349
|
+
"status": "pending",
|
|
350
|
+
"depends_on": ["IMPL-001", "...", "IMPL-${group_count}"],
|
|
351
|
+
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
352
|
+
"flow_control": {
|
|
353
|
+
"pre_analysis": [
|
|
354
|
+
{
|
|
355
|
+
"step": "load_existing_readme",
|
|
356
|
+
"command": "bash(cat .workflow/docs/${project_name}/README.md 2>/dev/null || echo 'No existing README')",
|
|
357
|
+
"output_to": "existing_readme"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"step": "load_module_docs",
|
|
361
|
+
"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)",
|
|
362
|
+
"output_to": "all_module_docs"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"step": "analyze_project",
|
|
366
|
+
"command": "bash(gemini \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")",
|
|
367
|
+
"output_to": "project_outline"
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
"implementation_approach": [
|
|
371
|
+
{
|
|
372
|
+
"step": 1,
|
|
373
|
+
"title": "Generate project README",
|
|
374
|
+
"description": "Generate project README with navigation links while preserving user modifications",
|
|
375
|
+
"modification_points": [
|
|
376
|
+
"Parse [project_outline] and [all_module_docs]",
|
|
377
|
+
"Generate README structure with navigation links",
|
|
378
|
+
"Preserve [existing_readme] user modifications"
|
|
379
|
+
],
|
|
380
|
+
"logic_flow": ["Parse data", "Generate README with navigation", "Preserve modifications"],
|
|
381
|
+
"depends_on": [],
|
|
382
|
+
"output": "project_readme"
|
|
383
|
+
}
|
|
384
|
+
],
|
|
385
|
+
"target_files": [".workflow/docs/${project_name}/README.md"]
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Level 3: Architecture & Examples Documentation Task
|
|
391
|
+
|
|
392
|
+
**Task ID**: `IMPL-${arch_id}` (where `arch_id = group_count + 2`)
|
|
393
|
+
**Dependencies**: Depends on Level 2 (Project README).
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"id": "IMPL-${arch_id}",
|
|
398
|
+
"title": "Generate Architecture & Examples Documentation",
|
|
399
|
+
"status": "pending",
|
|
400
|
+
"depends_on": ["IMPL-${readme_id}"],
|
|
401
|
+
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
402
|
+
"flow_control": {
|
|
403
|
+
"pre_analysis": [
|
|
404
|
+
{"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"},
|
|
405
|
+
{"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"},
|
|
406
|
+
{"step": "analyze_architecture", "command": "bash(gemini \"PURPOSE: Analyze system architecture\\nTASK: Synthesize architectural overview and examples\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture + Examples outline\")", "output_to": "arch_examples_outline"}
|
|
407
|
+
],
|
|
408
|
+
"implementation_approach": [
|
|
409
|
+
{
|
|
410
|
+
"step": 1,
|
|
411
|
+
"title": "Generate architecture and examples documentation",
|
|
412
|
+
"modification_points": [
|
|
413
|
+
"Parse [arch_examples_outline] and [all_docs]",
|
|
414
|
+
"Generate ARCHITECTURE.md (system design, patterns)",
|
|
415
|
+
"Generate EXAMPLES.md (code snippets, usage)",
|
|
416
|
+
"Preserve [existing_arch_examples] modifications"
|
|
417
|
+
],
|
|
418
|
+
"depends_on": [],
|
|
419
|
+
"output": "arch_examples_docs"
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
"target_files": [".workflow/docs/${project_name}/ARCHITECTURE.md", ".workflow/docs/${project_name}/EXAMPLES.md"]
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Level 4: HTTP API Documentation Task (Optional)
|
|
428
|
+
|
|
429
|
+
**Task ID**: `IMPL-${api_id}` (where `api_id = group_count + 3`)
|
|
430
|
+
**Dependencies**: Depends on Level 3.
|
|
431
|
+
|
|
432
|
+
```json
|
|
433
|
+
{
|
|
434
|
+
"id": "IMPL-${api_id}",
|
|
435
|
+
"title": "Generate HTTP API Documentation",
|
|
436
|
+
"status": "pending",
|
|
437
|
+
"depends_on": ["IMPL-${arch_id}"],
|
|
438
|
+
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
|
439
|
+
"flow_control": {
|
|
440
|
+
"pre_analysis": [
|
|
441
|
+
{"step": "discover_api", "command": "bash(rg 'router\\.| @(Get|Post)' -g '*.{ts,js}')", "output_to": "endpoint_discovery"},
|
|
442
|
+
{"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"},
|
|
443
|
+
{"step": "analyze_api", "command": "bash(gemini \"PURPOSE: Document HTTP API\\nTASK: Analyze endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\")", "output_to": "api_outline"}
|
|
444
|
+
],
|
|
445
|
+
"implementation_approach": [
|
|
446
|
+
{
|
|
447
|
+
"step": 1,
|
|
448
|
+
"title": "Generate HTTP API documentation",
|
|
449
|
+
"modification_points": [
|
|
450
|
+
"Parse [api_outline] and [endpoint_discovery]",
|
|
451
|
+
"Document endpoints, request/response formats",
|
|
452
|
+
"Preserve [existing_api_docs] modifications"
|
|
453
|
+
],
|
|
454
|
+
"depends_on": [],
|
|
455
|
+
"output": "api_docs"
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
"target_files": [".workflow/docs/${project_name}/api/README.md"]
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Session Structure
|
|
464
|
+
|
|
465
|
+
**Unified Structure** (single JSON replaces multiple text files):
|
|
466
|
+
|
|
467
|
+
```
|
|
468
|
+
.workflow/active/
|
|
469
|
+
└── WFS-docs-{timestamp}/
|
|
470
|
+
├── workflow-session.json # Session metadata
|
|
471
|
+
├── IMPL_PLAN.md
|
|
472
|
+
├── TODO_LIST.md
|
|
473
|
+
├── .process/
|
|
474
|
+
│ └── doc-planning-data.json # All Phase 2 analysis data (replaces 7+ files)
|
|
475
|
+
└── .task/
|
|
476
|
+
├── IMPL-001.json # Small: all modules | Large: group 1
|
|
477
|
+
├── IMPL-00N.json # (Large only: groups 2-N)
|
|
478
|
+
├── IMPL-{N+1}.json # README (full mode)
|
|
479
|
+
├── IMPL-{N+2}.json # ARCHITECTURE+EXAMPLES (full mode)
|
|
480
|
+
└── IMPL-{N+3}.json # HTTP API (optional)
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**doc-planning-data.json Structure**:
|
|
484
|
+
```json
|
|
485
|
+
{
|
|
486
|
+
"metadata": {
|
|
487
|
+
"generated_at": "2025-11-03T16:41:06+08:00",
|
|
488
|
+
"project_name": "Claude_dms3",
|
|
489
|
+
"project_root": "/d/Claude_dms3"
|
|
490
|
+
},
|
|
491
|
+
"folder_analysis": [
|
|
492
|
+
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2},
|
|
493
|
+
{"path": "./src/utils", "type": "navigation", "code_count": 0, "dirs_count": 4}
|
|
494
|
+
],
|
|
495
|
+
"top_level_dirs": ["src/modules", "src/utils", "lib/core"],
|
|
496
|
+
"existing_docs": {
|
|
497
|
+
"file_list": [".workflow/docs/project/src/core/API.md"],
|
|
498
|
+
"content": "... concatenated existing docs ..."
|
|
499
|
+
},
|
|
500
|
+
"unified_analysis": [
|
|
501
|
+
{"module_path": "./src/core", "outline_summary": "Core functionality"}
|
|
502
|
+
],
|
|
503
|
+
"groups": {
|
|
504
|
+
"count": 4,
|
|
505
|
+
"assignments": [
|
|
506
|
+
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 6},
|
|
507
|
+
{"group_id": "002", "directories": ["lib/core", "lib/helpers"], "doc_count": 7}
|
|
508
|
+
]
|
|
509
|
+
},
|
|
510
|
+
"statistics": {
|
|
511
|
+
"total": 15,
|
|
512
|
+
"code": 8,
|
|
513
|
+
"navigation": 7,
|
|
514
|
+
"top_level": 3
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
**Workflow Session Structure** (workflow-session.json):
|
|
520
|
+
```json
|
|
521
|
+
{
|
|
522
|
+
"session_id": "WFS-docs-{timestamp}",
|
|
523
|
+
"project": "{project_name} documentation",
|
|
524
|
+
"status": "planning",
|
|
525
|
+
"timestamp": "2024-01-20T14:30:22+08:00",
|
|
526
|
+
"path": ".",
|
|
527
|
+
"target_path": "/path/to/project",
|
|
528
|
+
"project_root": "/path/to/project",
|
|
529
|
+
"project_name": "{project_name}",
|
|
530
|
+
"mode": "full",
|
|
531
|
+
"tool": "gemini",
|
|
532
|
+
"cli_execute": false,
|
|
533
|
+
"update_mode": "update",
|
|
534
|
+
"existing_docs": 5,
|
|
535
|
+
"analysis": {
|
|
536
|
+
"total": "15",
|
|
537
|
+
"code": "8",
|
|
538
|
+
"navigation": "7",
|
|
539
|
+
"top_level": "3"
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
## Generated Documentation
|
|
545
|
+
|
|
546
|
+
**Structure mirrors project source directories under project-specific folder**:
|
|
547
|
+
|
|
548
|
+
```
|
|
549
|
+
.workflow/docs/
|
|
550
|
+
└── {project_name}/ # Project-specific root
|
|
551
|
+
├── src/ # Mirrors src/ directory
|
|
552
|
+
│ ├── modules/
|
|
553
|
+
│ │ ├── README.md # Navigation
|
|
554
|
+
│ │ ├── auth/
|
|
555
|
+
│ │ │ ├── API.md # API signatures
|
|
556
|
+
│ │ │ ├── README.md # Module docs
|
|
557
|
+
│ │ │ └── middleware/
|
|
558
|
+
│ │ │ ├── API.md
|
|
559
|
+
│ │ │ └── README.md
|
|
560
|
+
│ │ └── api/
|
|
561
|
+
│ │ ├── API.md
|
|
562
|
+
│ │ └── README.md
|
|
563
|
+
│ └── utils/
|
|
564
|
+
│ └── README.md
|
|
565
|
+
├── lib/ # Mirrors lib/ directory
|
|
566
|
+
│ └── core/
|
|
567
|
+
│ ├── API.md
|
|
568
|
+
│ └── README.md
|
|
569
|
+
├── README.md # Project root
|
|
570
|
+
├── ARCHITECTURE.md # System design
|
|
571
|
+
├── EXAMPLES.md # Usage examples
|
|
572
|
+
└── api/ # Optional
|
|
573
|
+
└── README.md # HTTP API reference
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
## Execution Commands
|
|
577
|
+
|
|
578
|
+
```bash
|
|
579
|
+
# Execute entire workflow (auto-discovers active session)
|
|
580
|
+
/workflow:execute
|
|
581
|
+
|
|
582
|
+
# Or specify session
|
|
583
|
+
/workflow:execute --resume-session="WFS-docs-yyyymmdd-hhmmss"
|
|
584
|
+
|
|
585
|
+
# Individual task execution
|
|
586
|
+
/task:execute IMPL-001
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
## Template Reference
|
|
590
|
+
|
|
591
|
+
**Available Templates** (`~/.claude/workflows/cli-templates/prompts/documentation/`):
|
|
592
|
+
- `api.txt`: Code API (Part A) + HTTP API (Part B)
|
|
593
|
+
- `module-readme.txt`: Module purpose, usage, dependencies
|
|
594
|
+
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
|
595
|
+
- `project-readme.txt`: Project overview, getting started, navigation
|
|
596
|
+
- `project-architecture.txt`: System structure, module map, design patterns
|
|
597
|
+
- `project-examples.txt`: End-to-end usage examples
|
|
598
|
+
|
|
599
|
+
## Execution Mode Summary
|
|
600
|
+
|
|
601
|
+
| Mode | CLI Placement | CLI MODE | Approval Flag | Agent Role |
|
|
602
|
+
|------|---------------|----------|---------------|------------|
|
|
603
|
+
| **Agent (default)** | pre_analysis | analysis | (none) | Generates documentation content |
|
|
604
|
+
| **CLI (--cli-execute)** | implementation_approach | write | --approval-mode yolo | Executes CLI commands, validates output |
|
|
605
|
+
|
|
606
|
+
**Execution Flow**:
|
|
607
|
+
- **Phase 2**: Unified analysis once, results in `.process/`
|
|
608
|
+
- **Phase 4**: Dynamic grouping (max 2 dirs per group)
|
|
609
|
+
- **Level 1**: Parallel processing for module tree groups
|
|
610
|
+
- **Level 2+**: Sequential execution for project-level docs
|
|
611
|
+
|
|
612
|
+
## Related Commands
|
|
613
|
+
- `/workflow:execute` - Execute documentation tasks
|
|
614
|
+
- `/workflow:status` - View task progress
|
|
615
|
+
- `/workflow:session:complete` - Mark session complete
|