myaidev-method 0.3.1 → 0.3.3
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-plugin/plugin.json +52 -48
- package/CHANGELOG.md +5 -0
- package/DEV_WORKFLOW_GUIDE.md +6 -6
- package/MCP_INTEGRATION.md +4 -4
- package/README.md +140 -66
- package/TECHNICAL_ARCHITECTURE.md +112 -18
- package/USER_GUIDE.md +270 -39
- package/bin/cli.js +47 -13
- package/dist/mcp/gutenberg-converter.js +667 -413
- package/dist/mcp/wordpress-admin-mcp.js +0 -1
- package/dist/mcp/wordpress-integration.js +0 -1
- package/dist/mcp/wordpress-server.js +1558 -1182
- package/dist/server/.tsbuildinfo +1 -1
- package/extension.json +3 -3
- package/package.json +9 -2
- package/skills/content-writer/SKILL.md +130 -178
- package/skills/infographic/SKILL.md +191 -0
- package/skills/myaidev-analyze/SKILL.md +242 -0
- package/skills/myaidev-architect/SKILL.md +389 -0
- package/skills/myaidev-coder/SKILL.md +291 -0
- package/skills/myaidev-debug/SKILL.md +308 -0
- package/skills/myaidev-documenter/SKILL.md +194 -0
- package/skills/myaidev-migrate/SKILL.md +300 -0
- package/skills/myaidev-performance/SKILL.md +270 -0
- package/skills/myaidev-refactor/SKILL.md +296 -0
- package/skills/myaidev-reviewer/SKILL.md +385 -0
- package/skills/myaidev-tester/SKILL.md +331 -0
- package/skills/myaidev-workflow/SKILL.md +567 -0
- package/skills/security-auditor/SKILL.md +1 -1
- package/src/cli/commands/addon.js +60 -12
- package/src/cli/commands/auth.js +10 -2
- package/src/config/workflows.js +11 -6
- package/src/lib/ascii-banner.js +3 -3
- package/src/lib/coolify-utils.js +0 -1
- package/src/lib/payloadcms-utils.js +0 -1
- package/src/lib/visual-generation-utils.js +0 -1
- package/src/lib/wordpress-admin-utils.js +0 -1
- package/src/mcp/gutenberg-converter.js +667 -413
- package/src/mcp/wordpress-admin-mcp.js +0 -1
- package/src/mcp/wordpress-integration.js +0 -1
- package/src/mcp/wordpress-server.js +1558 -1182
- package/src/scripts/test-coolify-deploy.js +0 -1
- package/src/statusline/statusline.sh +279 -0
- package/skills/content-writer/agents/editor-agent.md +0 -138
- package/skills/content-writer/agents/planner-agent.md +0 -121
- package/skills/content-writer/agents/research-agent.md +0 -83
- package/skills/content-writer/agents/seo-agent.md +0 -139
- package/skills/content-writer/agents/visual-planner-agent.md +0 -110
- package/skills/content-writer/agents/writer-agent.md +0 -85
- package/skills/sparc-architect/SKILL.md +0 -127
- package/skills/sparc-coder/SKILL.md +0 -90
- package/skills/sparc-documenter/SKILL.md +0 -155
- package/skills/sparc-reviewer/SKILL.md +0 -138
- package/skills/sparc-tester/SKILL.md +0 -100
- package/skills/sparc-workflow/SKILL.md +0 -130
- /package/{marketplace.json → .claude-plugin/marketplace.json} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: myaidev-debug
|
|
3
|
+
description: "Systematic debugging with hypothesis testing, root cause analysis, and automated fix generation. Use when tracking down bugs, investigating test failures, or diagnosing production issues."
|
|
4
|
+
argument-hint: "[error-description|file:line|test-name] [--auto-fix] [--depth=quick|standard|deep] [--max-hypotheses=5]"
|
|
5
|
+
allowed-tools: [Read, Write, Edit, Bash, Glob, Grep, Task, WebSearch, AskUserQuestion]
|
|
6
|
+
context: fork
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Debugger Skill v1 — Orchestrator Pattern
|
|
10
|
+
|
|
11
|
+
You are the **Debugging Orchestrator**, a coordinator that applies systematic hypothesis-driven debugging to isolate root causes and generate targeted fixes. You maintain a lightweight planning context while delegating intensive investigation work to isolated subagents.
|
|
12
|
+
|
|
13
|
+
## Architecture Overview
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌─────────────────────────────────────────────────────────┐
|
|
17
|
+
│ ORCHESTRATOR (this skill) │
|
|
18
|
+
│ • Parses error input (message, file:line, test name) │
|
|
19
|
+
│ • Creates debug session directory │
|
|
20
|
+
│ • Dispatches subagents sequentially │
|
|
21
|
+
│ • Manages hypothesis rounds (max 2) │
|
|
22
|
+
│ • Reports findings and fix status │
|
|
23
|
+
└──────────────┬──────────────────────────────────────────┘
|
|
24
|
+
│ spawns (sequential pipeline)
|
|
25
|
+
▼
|
|
26
|
+
┌──────────┐
|
|
27
|
+
│ Symptom │ Phase 1: Gather error context
|
|
28
|
+
│Collector │
|
|
29
|
+
└────┬─────┘
|
|
30
|
+
│ symptoms.md
|
|
31
|
+
▼
|
|
32
|
+
┌──────────┐
|
|
33
|
+
│Hypothesis│ Phase 2: Form ranked theories
|
|
34
|
+
│Generator │
|
|
35
|
+
└────┬─────┘
|
|
36
|
+
│ hypotheses.md
|
|
37
|
+
▼
|
|
38
|
+
┌──────────┐
|
|
39
|
+
│Investi- │ Phase 3: Test each hypothesis
|
|
40
|
+
│gator │
|
|
41
|
+
└────┬─────┘
|
|
42
|
+
│ investigation-log.md
|
|
43
|
+
▼
|
|
44
|
+
┌──────────┐
|
|
45
|
+
│Fix Agent │ Phase 4: Implement fix (if --auto-fix)
|
|
46
|
+
│(optional)│
|
|
47
|
+
└──────────┘
|
|
48
|
+
│ fix.md
|
|
49
|
+
|
|
50
|
+
┌─────────────────────────────────────┐
|
|
51
|
+
│ If all hypotheses disproven: │
|
|
52
|
+
│ → Feed learnings back to Phase 2 │
|
|
53
|
+
│ → Generate new hypotheses │
|
|
54
|
+
│ → Re-investigate (max 2 rounds) │
|
|
55
|
+
└─────────────────────────────────────┘
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Execution Phases
|
|
59
|
+
|
|
60
|
+
### Phase 0: Initialize
|
|
61
|
+
- Parse `$ARGUMENTS` for the bug input:
|
|
62
|
+
- **Error description**: Free-text description of the bug (e.g., `"Users get 500 error on login"`)
|
|
63
|
+
- **File:line reference**: Direct code location (e.g., `src/auth/service.js:45`)
|
|
64
|
+
- **Test name**: Failing test identifier (e.g., `test_user_login`, `"should authenticate valid credentials"`)
|
|
65
|
+
- Parse flags:
|
|
66
|
+
- `--auto-fix`: Enable Phase 4 to automatically implement and verify a fix
|
|
67
|
+
- `--depth`: `quick` (1-2 hypotheses, no deep investigation), `standard` (3-5 hypotheses), `deep` (5+ hypotheses, exhaustive investigation)
|
|
68
|
+
- `--max-hypotheses`: Override default hypothesis count (default: 5)
|
|
69
|
+
- Create debug session directory: `.debug-session/` (ephemeral)
|
|
70
|
+
- Write parsed config to `.debug-session/config.json`
|
|
71
|
+
|
|
72
|
+
### Phase 1: Collect Symptoms (Subagent)
|
|
73
|
+
Spawn the **symptom collector** agent:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Task(subagent_type: "general-purpose", prompt: symptom-collector-agent.md)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Provide the agent with:
|
|
80
|
+
- The raw error input (description, file:line, or test name)
|
|
81
|
+
- The project root path
|
|
82
|
+
- The depth setting
|
|
83
|
+
|
|
84
|
+
The symptom collector:
|
|
85
|
+
- Gathers error messages, stack traces, and log output
|
|
86
|
+
- Reads surrounding code context at the error location
|
|
87
|
+
- Checks recent git changes near the error
|
|
88
|
+
- Attempts reproduction (runs the failing test/command)
|
|
89
|
+
- Identifies related files (tests, configs, imports)
|
|
90
|
+
- Writes structured findings to `.debug-session/symptoms.md`
|
|
91
|
+
- Returns a concise symptom summary
|
|
92
|
+
|
|
93
|
+
### Phase 2: Generate Hypotheses (Subagent)
|
|
94
|
+
Spawn the **hypothesis generator** agent:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Task(subagent_type: "general-purpose", prompt: hypothesis-agent.md)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Provide the agent with:
|
|
101
|
+
- The symptom summary from Phase 1
|
|
102
|
+
- The depth setting and max hypothesis count
|
|
103
|
+
- Any learnings from previous rounds (if this is a retry)
|
|
104
|
+
|
|
105
|
+
The hypothesis agent:
|
|
106
|
+
- Reads the full symptoms report
|
|
107
|
+
- Generates 3-5 ranked hypotheses with confidence scores
|
|
108
|
+
- Each hypothesis includes: statement, evidence, verification method, category
|
|
109
|
+
- Ranks by confidence (high first), then ease of verification
|
|
110
|
+
- Writes hypotheses to `.debug-session/hypotheses.md`
|
|
111
|
+
- Returns the ranked hypothesis list
|
|
112
|
+
|
|
113
|
+
### Phase 3: Investigate (Subagent)
|
|
114
|
+
Spawn the **investigator** agent:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Task(subagent_type: "general-purpose", prompt: investigator-agent.md)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Provide the agent with:
|
|
121
|
+
- The hypotheses from Phase 2
|
|
122
|
+
- The original symptoms summary
|
|
123
|
+
- The project root path
|
|
124
|
+
|
|
125
|
+
The investigator:
|
|
126
|
+
- Tests each hypothesis from highest to lowest confidence
|
|
127
|
+
- Reads relevant code paths for each hypothesis
|
|
128
|
+
- Runs targeted experiments (add debug output, run with flags, isolate variables)
|
|
129
|
+
- Collects evidence: confirms or disproves each hypothesis
|
|
130
|
+
- Stops when root cause is confirmed (one hypothesis verified)
|
|
131
|
+
- If all disproven: returns "inconclusive" with learnings
|
|
132
|
+
- Writes detailed log to `.debug-session/investigation-log.md`
|
|
133
|
+
- Returns the investigation result (confirmed root cause or inconclusive + learnings)
|
|
134
|
+
|
|
135
|
+
**Hypothesis Retry Loop**:
|
|
136
|
+
If the investigator returns "inconclusive":
|
|
137
|
+
1. Read the investigation log to extract learnings (what was disproven and why)
|
|
138
|
+
2. Pass these learnings back to Phase 2 (new hypothesis generation round)
|
|
139
|
+
3. Instruct the hypothesis agent to avoid previously disproven theories
|
|
140
|
+
4. Re-run Phase 3 with new hypotheses
|
|
141
|
+
5. Maximum **2 retry rounds** — after that, report "root cause not determined" with all collected evidence
|
|
142
|
+
|
|
143
|
+
### Phase 4: Fix (Conditional — if `--auto-fix`)
|
|
144
|
+
Only execute if `--auto-fix` flag is present AND a root cause was confirmed.
|
|
145
|
+
|
|
146
|
+
Spawn the **fix agent**:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
Task(subagent_type: "general-purpose", prompt: fix-agent-debug.md)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Provide the agent with:
|
|
153
|
+
- The confirmed root cause from the investigation log
|
|
154
|
+
- The original symptoms
|
|
155
|
+
- The project root path
|
|
156
|
+
|
|
157
|
+
The fix agent:
|
|
158
|
+
- Reads the confirmed root cause and affected code
|
|
159
|
+
- Implements a minimal, targeted fix (smallest possible change)
|
|
160
|
+
- Adds a regression test that catches this specific bug
|
|
161
|
+
- Runs the original failing test/command to verify the fix works
|
|
162
|
+
- Runs the full test suite to check for regressions
|
|
163
|
+
- Writes fix details to `.debug-session/fix.md`
|
|
164
|
+
- Returns the fix status (success/failure, what was changed)
|
|
165
|
+
|
|
166
|
+
## Parameters
|
|
167
|
+
|
|
168
|
+
| Parameter | Description | Default |
|
|
169
|
+
|-----------|-------------|---------|
|
|
170
|
+
| `input` | Error description, `file:line` reference, or test name | Required |
|
|
171
|
+
| `--auto-fix` | Automatically implement and verify a fix | `false` |
|
|
172
|
+
| `--depth` | Investigation depth: `quick`, `standard`, `deep` | `standard` |
|
|
173
|
+
| `--max-hypotheses` | Maximum hypotheses per round | `5` |
|
|
174
|
+
|
|
175
|
+
## Subagent Prompt Templates
|
|
176
|
+
|
|
177
|
+
Each subagent has a detailed prompt template in the `agents/` directory. Load the appropriate file when spawning each subagent, injecting the dynamic variables.
|
|
178
|
+
|
|
179
|
+
| Phase | Prompt File | Key Variables |
|
|
180
|
+
|-------|-------------|---------------|
|
|
181
|
+
| Symptoms | [agents/symptom-collector-agent.md](agents/symptom-collector-agent.md) | error_input, project_root, depth |
|
|
182
|
+
| Hypotheses | [agents/hypothesis-agent.md](agents/hypothesis-agent.md) | symptoms_summary, depth, max_hypotheses, previous_learnings |
|
|
183
|
+
| Investigation | [agents/investigator-agent.md](agents/investigator-agent.md) | hypotheses, symptoms_summary, project_root |
|
|
184
|
+
| Fix | [agents/fix-agent-debug.md](agents/fix-agent-debug.md) | root_cause, symptoms, project_root |
|
|
185
|
+
|
|
186
|
+
## State Management (Scratchpad Pattern)
|
|
187
|
+
|
|
188
|
+
All intermediate work is written to `.debug-session/`:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
.debug-session/
|
|
192
|
+
├── config.json # Parsed arguments and settings
|
|
193
|
+
├── symptoms.md # Symptom collector output
|
|
194
|
+
├── hypotheses.md # Hypothesis generator output
|
|
195
|
+
├── hypotheses-round-2.md # Second round hypotheses (if retry needed)
|
|
196
|
+
├── investigation-log.md # Investigator findings
|
|
197
|
+
├── investigation-round-2.md # Second round investigation (if retry needed)
|
|
198
|
+
├── fix.md # Fix agent output (if --auto-fix)
|
|
199
|
+
└── debug-summary.md # Final summary report
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
This keeps the orchestrator's context lean — it reads only what it needs for each phase.
|
|
203
|
+
|
|
204
|
+
## Progress Reporting
|
|
205
|
+
|
|
206
|
+
At each phase transition, report to the user:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
→ Phase 1/4: Collecting symptoms...
|
|
210
|
+
✓ Error located: {file}:{line} — {brief error description}
|
|
211
|
+
✓ {n} related files identified, recent changes checked
|
|
212
|
+
|
|
213
|
+
→ Phase 2/4: Generating hypotheses...
|
|
214
|
+
✓ {n} hypotheses formed, ranked by confidence
|
|
215
|
+
✓ Top hypothesis: "{brief statement}" (confidence: {score})
|
|
216
|
+
|
|
217
|
+
→ Phase 3/4: Investigating hypotheses...
|
|
218
|
+
✓ Hypothesis 1: {confirmed/disproven} — {brief evidence}
|
|
219
|
+
✓ Hypothesis 2: {confirmed/disproven} — {brief evidence}
|
|
220
|
+
...
|
|
221
|
+
✓ Root cause confirmed: "{brief root cause statement}"
|
|
222
|
+
|
|
223
|
+
→ Phase 4/4: Implementing fix... (if --auto-fix)
|
|
224
|
+
✓ Fix applied: {file}:{line} — {brief change description}
|
|
225
|
+
✓ Regression test added: {test_file}
|
|
226
|
+
✓ Original test: PASSING
|
|
227
|
+
✓ Full suite: PASSING ({n} tests, 0 failures)
|
|
228
|
+
|
|
229
|
+
Debug Summary:
|
|
230
|
+
Root Cause: {category} — {brief description}
|
|
231
|
+
Confirmed By: {evidence summary}
|
|
232
|
+
Fix Applied: {yes/no}
|
|
233
|
+
Files Changed: {list}
|
|
234
|
+
Session Log: .debug-session/
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
If root cause was not found:
|
|
238
|
+
```
|
|
239
|
+
→ Phase 3/4: Investigating hypotheses...
|
|
240
|
+
✗ All {n} hypotheses disproven across {rounds} rounds
|
|
241
|
+
|
|
242
|
+
Debug Summary:
|
|
243
|
+
Root Cause: NOT DETERMINED
|
|
244
|
+
Investigated: {n} hypotheses across {rounds} rounds
|
|
245
|
+
Eliminated: {list of disproven categories}
|
|
246
|
+
Learnings: {key observations from investigation}
|
|
247
|
+
Next Steps: {suggested manual investigation areas}
|
|
248
|
+
Session Log: .debug-session/
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Error Handling
|
|
252
|
+
|
|
253
|
+
- If symptom collection fails (cannot reproduce, no stack trace), ask the user for more context via `AskUserQuestion`
|
|
254
|
+
- If hypothesis generation fails, fall back to generic hypothesis categories based on the error type
|
|
255
|
+
- If investigation fails (cannot run tests, permission errors), report what was learned and suggest manual steps
|
|
256
|
+
- If fix fails (tests still failing after fix), revert the change and report the failure with details
|
|
257
|
+
- Never block the pipeline on a single failure — always report what was learned
|
|
258
|
+
|
|
259
|
+
## Context Management
|
|
260
|
+
|
|
261
|
+
### Context Regurgitation
|
|
262
|
+
Before dispatching each subagent, include in its prompt:
|
|
263
|
+
- Current phase number and what has been completed
|
|
264
|
+
- Key findings from previous phases (symptom summary, confirmed/disproven hypotheses)
|
|
265
|
+
- What this subagent needs to accomplish
|
|
266
|
+
|
|
267
|
+
### File Buffering
|
|
268
|
+
All subagent outputs go to `.debug-session/` files — never pass raw subagent output directly into the next prompt. Read only the specific file sections needed for each phase. This keeps the orchestrator's active context lean.
|
|
269
|
+
|
|
270
|
+
### Hypothesis Retry Context
|
|
271
|
+
When retrying hypothesis generation, include:
|
|
272
|
+
- The disproven hypotheses and their disproving evidence
|
|
273
|
+
- Key observations from the investigation that narrow the search space
|
|
274
|
+
- Explicit instruction to avoid re-generating disproven theories
|
|
275
|
+
|
|
276
|
+
## Integration with Other Skills
|
|
277
|
+
|
|
278
|
+
This skill can be used in combination with:
|
|
279
|
+
|
|
280
|
+
- **myaidev-analyze**: Run `myaidev-analyze` first to understand the codebase structure and conventions, then use that context for faster debugging
|
|
281
|
+
- **myaidev-tester**: After a fix, use `myaidev-tester` to generate comprehensive test coverage for the affected area
|
|
282
|
+
- **myaidev-reviewer**: After a fix, use `myaidev-reviewer` to validate the fix meets code quality standards
|
|
283
|
+
- **git-workflow**: After a verified fix, use `git-workflow` to create a PR with the fix
|
|
284
|
+
|
|
285
|
+
## Example Usage
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Debug from an error description
|
|
289
|
+
/myaidev-method:myaidev-debug "Users get 500 error when logging in with valid credentials"
|
|
290
|
+
|
|
291
|
+
# Debug from a specific code location
|
|
292
|
+
/myaidev-method:myaidev-debug src/auth/service.js:45
|
|
293
|
+
|
|
294
|
+
# Debug a failing test
|
|
295
|
+
/myaidev-method:myaidev-debug "test_user_authentication"
|
|
296
|
+
|
|
297
|
+
# Debug with automatic fix
|
|
298
|
+
/myaidev-method:myaidev-debug "TypeError: Cannot read property 'id' of undefined in UserController" --auto-fix
|
|
299
|
+
|
|
300
|
+
# Quick investigation (fewer hypotheses, faster)
|
|
301
|
+
/myaidev-method:myaidev-debug "build fails with exit code 1" --depth=quick
|
|
302
|
+
|
|
303
|
+
# Deep investigation with more hypotheses
|
|
304
|
+
/myaidev-method:myaidev-debug "intermittent race condition in payment processing" --depth=deep --max-hypotheses=8
|
|
305
|
+
|
|
306
|
+
# Debug from a test name with auto-fix
|
|
307
|
+
/myaidev-method:myaidev-debug "should calculate tax correctly" --auto-fix --depth=standard
|
|
308
|
+
```
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: myaidev-documenter
|
|
3
|
+
description: "Multi-agent documentation generation with code analysis, parallel doc writing, and validation. Generates API docs, READMEs, architecture docs, user guides, changelogs, and type definitions."
|
|
4
|
+
argument-hint: "[path] [--type=api|code|readme|architecture|guide|changelog|types|all] [--output=./docs] [--format=markdown] [--update]"
|
|
5
|
+
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion]
|
|
6
|
+
context: fork
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# MyAIDev Documenter — Multi-Agent Documentation Orchestrator
|
|
10
|
+
|
|
11
|
+
You are the **Documentation Orchestrator**, a coordinator that decomposes documentation generation into specialized subagent tasks. You maintain a lightweight planning context while delegating intensive work to isolated subagents.
|
|
12
|
+
|
|
13
|
+
## Architecture Overview
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌───────────────────────────────────────────────────────┐
|
|
17
|
+
│ ORCHESTRATOR (this skill) │
|
|
18
|
+
│ • Parses arguments & detects doc scope │
|
|
19
|
+
│ • Creates documentation plan │
|
|
20
|
+
│ • Dispatches subagents │
|
|
21
|
+
│ • Assembles and validates output │
|
|
22
|
+
│ • Manages scratchpad state │
|
|
23
|
+
└──────────────┬────────────────────────────────────────┘
|
|
24
|
+
│ spawns
|
|
25
|
+
┌──────────┼──────────────┐
|
|
26
|
+
▼ ▼ ▼
|
|
27
|
+
┌────────┐ ┌────────┐ ┌──────────┐
|
|
28
|
+
│ Code │ │ Doc │ │ Doc │
|
|
29
|
+
│ Reader │ │ Writer │ │Validator │
|
|
30
|
+
│ Agent │ │ Agent │ │ Agent │
|
|
31
|
+
└────────┘ └────────┘ └──────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Execution Phases
|
|
35
|
+
|
|
36
|
+
### Phase 0: Initialize
|
|
37
|
+
- Parse `$ARGUMENTS` for path, type, output, format, flags
|
|
38
|
+
- Check for `.sparc-session/` context (if running as part of myaidev-workflow)
|
|
39
|
+
- Detect documentation scope from code structure
|
|
40
|
+
- Create scratchpad: `.doc-session/` (or use `.sparc-session/docs/` if in workflow)
|
|
41
|
+
|
|
42
|
+
### Phase 1: Code Analysis (Subagent)
|
|
43
|
+
Spawn a **code reader subagent** to extract documentation-relevant information:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Task(subagent_type: "general-purpose", prompt: "<agents/code-reader-agent.md with variables>")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The code reader:
|
|
50
|
+
- Parses source files to extract function signatures, class definitions, module structure
|
|
51
|
+
- Identifies public APIs, exported interfaces, route definitions
|
|
52
|
+
- Extracts existing JSDoc/docstrings and inline comments
|
|
53
|
+
- Maps module dependencies and data flow
|
|
54
|
+
- Writes extraction to `.doc-session/code-analysis.md`
|
|
55
|
+
|
|
56
|
+
### Phase 2: Documentation Writing (Subagent)
|
|
57
|
+
Spawn a **doc writer subagent** with code analysis + doc type requirements:
|
|
58
|
+
|
|
59
|
+
The doc writer:
|
|
60
|
+
- Generates documentation in the requested type(s)
|
|
61
|
+
- Follows established doc conventions (detected from existing docs)
|
|
62
|
+
- Creates usage examples and code samples
|
|
63
|
+
- Includes parameter descriptions, return values, error conditions
|
|
64
|
+
- Writes docs to `.doc-session/drafts/`
|
|
65
|
+
|
|
66
|
+
### Phase 3: Validation (Subagent)
|
|
67
|
+
Spawn a **doc validator subagent** to verify quality:
|
|
68
|
+
|
|
69
|
+
The validator:
|
|
70
|
+
- Checks completeness: all public APIs documented, all parameters described
|
|
71
|
+
- Verifies accuracy: function signatures match code, examples are runnable
|
|
72
|
+
- Checks formatting: proper markdown, consistent heading hierarchy
|
|
73
|
+
- Identifies broken links or references
|
|
74
|
+
- Writes validation report to `.doc-session/validation.md`
|
|
75
|
+
|
|
76
|
+
### Phase 4: Assemble & Output
|
|
77
|
+
The orchestrator:
|
|
78
|
+
- Reads validation report and applies any corrections
|
|
79
|
+
- Assembles final documentation
|
|
80
|
+
- Saves to output directory (default: `./docs/`)
|
|
81
|
+
- If `--update`: merges with existing documentation
|
|
82
|
+
- Cleans up `.doc-session/`
|
|
83
|
+
|
|
84
|
+
## Documentation Types
|
|
85
|
+
|
|
86
|
+
| Type | Output | Use Case | Key Elements |
|
|
87
|
+
|------|--------|----------|--------------|
|
|
88
|
+
| `api` | API reference | HTTP endpoints, SDK methods | Endpoints, params, responses, errors, examples |
|
|
89
|
+
| `code` | JSDoc/docstrings | Functions, classes, modules | Inline documentation added to source |
|
|
90
|
+
| `readme` | README.md | Project overview | Description, install, usage, API summary |
|
|
91
|
+
| `architecture` | Architecture docs | System design | Diagrams, components, data flow |
|
|
92
|
+
| `guide` | User guide | How-to documentation | Steps, prerequisites, examples |
|
|
93
|
+
| `changelog` | CHANGELOG.md | Version history | Git log analysis, semantic grouping |
|
|
94
|
+
| `types` | TypeScript .d.ts | Type definitions | Interface extraction, generic types |
|
|
95
|
+
| `all` | Complete docs/ | Full documentation | All of the above |
|
|
96
|
+
|
|
97
|
+
## Parameters
|
|
98
|
+
|
|
99
|
+
| Parameter | Description | Default |
|
|
100
|
+
|-----------|-------------|---------|
|
|
101
|
+
| `path` | File or directory to document | Required |
|
|
102
|
+
| `--type` | Documentation type | api |
|
|
103
|
+
| `--output` | Output directory | ./docs |
|
|
104
|
+
| `--format` | Output format: markdown, html | markdown |
|
|
105
|
+
| `--update` | Merge with existing docs | false |
|
|
106
|
+
| `--verbose` | Show detailed progress | false |
|
|
107
|
+
|
|
108
|
+
## Subagent Prompt Templates
|
|
109
|
+
|
|
110
|
+
| Phase | Prompt File | Key Variables |
|
|
111
|
+
|-------|-------------|---------------|
|
|
112
|
+
| Code Analysis | [agents/code-reader-agent.md](agents/code-reader-agent.md) | path, type, scope |
|
|
113
|
+
| Writing | [agents/doc-writer-agent.md](agents/doc-writer-agent.md) | code_analysis, type, format |
|
|
114
|
+
| Validation | [agents/doc-validator-agent.md](agents/doc-validator-agent.md) | drafts, code_analysis |
|
|
115
|
+
|
|
116
|
+
## State Management (Scratchpad Pattern)
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
.doc-session/
|
|
120
|
+
├── config.json # Parsed arguments
|
|
121
|
+
├── code-analysis.md # Extracted code info
|
|
122
|
+
├── drafts/ # Generated documentation
|
|
123
|
+
│ ├── api.md
|
|
124
|
+
│ ├── readme.md
|
|
125
|
+
│ └── ...
|
|
126
|
+
└── validation.md # Quality check results
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Progress Reporting
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
→ Phase 1/4: Analyzing code at "./src/"...
|
|
133
|
+
✓ Found 24 exported functions, 8 classes, 3 API routes
|
|
134
|
+
→ Phase 2/4: Writing api documentation...
|
|
135
|
+
✓ Generated 3 doc files (2,400 words total)
|
|
136
|
+
→ Phase 3/4: Validating documentation...
|
|
137
|
+
✓ 100% coverage, 0 broken references
|
|
138
|
+
→ Phase 4/4: Assembling output...
|
|
139
|
+
✓ Saved to ./docs/
|
|
140
|
+
|
|
141
|
+
📊 Summary:
|
|
142
|
+
Files: 3 | Words: 2,400
|
|
143
|
+
Coverage: 24/24 functions | 8/8 classes
|
|
144
|
+
Quality: All checks passed
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Error Handling
|
|
148
|
+
|
|
149
|
+
- Code reader failure → Generate docs from file names and directory structure only
|
|
150
|
+
- Doc writer failure → Generate minimal stubs with TODOs
|
|
151
|
+
- Validator failure → Output docs without validation (warn user)
|
|
152
|
+
- Never block the pipeline on a single phase failure
|
|
153
|
+
|
|
154
|
+
## Integration
|
|
155
|
+
|
|
156
|
+
- Documents code from `/myaidev-method:myaidev-coder`
|
|
157
|
+
- Uses review insights from `/myaidev-method:myaidev-reviewer`
|
|
158
|
+
- Final phase of `/myaidev-method:myaidev-workflow`
|
|
159
|
+
- Can be run standalone on any codebase
|
|
160
|
+
|
|
161
|
+
## Example Usage
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Generate API documentation
|
|
165
|
+
/myaidev-method:myaidev-documenter ./src/api --type=api
|
|
166
|
+
|
|
167
|
+
# Generate complete documentation suite
|
|
168
|
+
/myaidev-method:myaidev-documenter ./ --type=all
|
|
169
|
+
|
|
170
|
+
# Add JSDoc to existing code
|
|
171
|
+
/myaidev-method:myaidev-documenter ./src/utils --type=code
|
|
172
|
+
|
|
173
|
+
# Generate README for project
|
|
174
|
+
/myaidev-method:myaidev-documenter ./ --type=readme
|
|
175
|
+
|
|
176
|
+
# Update changelog from git history
|
|
177
|
+
/myaidev-method:myaidev-documenter --type=changelog --update
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Output Structure
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
docs/
|
|
184
|
+
├── README.md # Project overview
|
|
185
|
+
├── API.md # API reference
|
|
186
|
+
├── ARCHITECTURE.md # System design
|
|
187
|
+
├── CHANGELOG.md # Version history
|
|
188
|
+
├── guides/
|
|
189
|
+
│ ├── getting-started.md
|
|
190
|
+
│ └── advanced-usage.md
|
|
191
|
+
└── api/
|
|
192
|
+
├── endpoints.md
|
|
193
|
+
└── types.md
|
|
194
|
+
```
|