@thedecipherist/mdd 1.6.5 → 1.6.6
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/commands/mdd-manual.md +169 -63
- package/package.json +1 -1
package/commands/mdd-manual.md
CHANGED
|
@@ -6,6 +6,10 @@ Generates a comprehensive, print-ready user manual at `.mdd/manual/manual.md` fr
|
|
|
6
6
|
MDD feature docs and ops runbooks. Uses content hashes to detect what changed since the
|
|
7
7
|
last run — only stale sections are regenerated.
|
|
8
8
|
|
|
9
|
+
Sections are written to disk **immediately after each generation batch completes** — never
|
|
10
|
+
held in memory until the end. This means compaction mid-run loses at most one batch of
|
|
11
|
+
sections, and the next run can resume from the saved state.
|
|
12
|
+
|
|
9
13
|
---
|
|
10
14
|
|
|
11
15
|
### Phase M1 — Scope & Hash Check
|
|
@@ -15,7 +19,7 @@ last run — only stale sections are regenerated.
|
|
|
15
19
|
Check `.mdd/docs/`. If it contains zero `.md` files:
|
|
16
20
|
```
|
|
17
21
|
⚠️ No feature docs found.
|
|
18
|
-
Run /mdd <feature> to create your first
|
|
22
|
+
Run /mdd <feature> to create your first doc, then re-run /mdd manual.
|
|
19
23
|
```
|
|
20
24
|
Stop here.
|
|
21
25
|
|
|
@@ -74,7 +78,79 @@ Stop here.
|
|
|
74
78
|
|
|
75
79
|
---
|
|
76
80
|
|
|
77
|
-
### Phase M2 —
|
|
81
|
+
### Phase M2 — Skeleton Init (before generating any sections)
|
|
82
|
+
|
|
83
|
+
Before generating any sections, ensure `manual.md` is in a writable state on disk.
|
|
84
|
+
This protects against compaction — each section written to disk is durable.
|
|
85
|
+
|
|
86
|
+
**Step 1 — Ensure output directory exists**
|
|
87
|
+
```bash
|
|
88
|
+
mkdir -p .mdd/manual
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Step 2 — Load existing manual or build skeleton**
|
|
92
|
+
|
|
93
|
+
Read `.mdd/manual/manual.md` if it exists. Identify the preface: everything before the
|
|
94
|
+
first `<!-- mdd-section: -->` marker. If the file is new, generate a default preface
|
|
95
|
+
(see Phase M3 Step 2 below for the preface format) and write the skeleton immediately:
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
# <Project Name> — User Manual
|
|
99
|
+
|
|
100
|
+
> <tagline>
|
|
101
|
+
|
|
102
|
+
**Version:** <version>
|
|
103
|
+
**Generated:** <date>
|
|
104
|
+
|
|
105
|
+
<overview paragraphs>
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Table of Contents
|
|
110
|
+
<!-- toc -->
|
|
111
|
+
(regenerated on completion)
|
|
112
|
+
<!-- /toc -->
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Overview
|
|
117
|
+
|
|
118
|
+
<overview content>
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Features
|
|
123
|
+
|
|
124
|
+
(sections generating — re-run /mdd manual if interrupted)
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Operations
|
|
129
|
+
|
|
130
|
+
(sections generating — re-run /mdd manual if interrupted)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Command Reference
|
|
135
|
+
|
|
136
|
+
(regenerated on completion)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Write this skeleton to `.mdd/manual/manual.md` now, before any agents are launched.
|
|
142
|
+
This ensures the file exists on disk even if compaction occurs mid-generation.
|
|
143
|
+
|
|
144
|
+
**Step 3 — Remove deleted sections**
|
|
145
|
+
|
|
146
|
+
For each doc classified as `deleted`: find and remove the entire
|
|
147
|
+
`<!-- mdd-section: <id> -->` … `<!-- /mdd-section: <id> -->` block (including
|
|
148
|
+
surrounding blank lines) from the current manual.md on disk. Write the file after
|
|
149
|
+
each removal.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### Phase M3 — Section Generation (incremental, batch-by-batch)
|
|
78
154
|
|
|
79
155
|
For each `changed` or `new` doc, generate a user-friendly manual section. The section
|
|
80
156
|
must be readable by someone who has never seen the source code — focus on WHAT the
|
|
@@ -133,11 +209,37 @@ For ops runbooks, use a condensed format:
|
|
|
133
209
|
<!-- /mdd-section: ops/<slug> -->
|
|
134
210
|
```
|
|
135
211
|
|
|
136
|
-
**Parallelism:**
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
212
|
+
**Parallelism and incremental writing — CRITICAL:**
|
|
213
|
+
|
|
214
|
+
- **1–4 changed docs** → generate sequentially in main conversation. After EACH section
|
|
215
|
+
is generated, immediately patch it into `manual.md` on disk (see patching rules below)
|
|
216
|
+
before generating the next section.
|
|
217
|
+
|
|
218
|
+
- **5+ changed docs** → split into batches of up to 8. For each batch:
|
|
219
|
+
1. Launch one `general-purpose` agent per doc in the batch (all agents in the batch
|
|
220
|
+
run concurrently). Each agent receives: the full doc content, the section structure
|
|
221
|
+
template above, and the output section id.
|
|
222
|
+
2. **Wait for ALL agents in this batch to complete.**
|
|
223
|
+
3. Immediately patch ALL returned sections into `manual.md` on disk (one Write call
|
|
224
|
+
per section, or one Write call with all sections patched at once).
|
|
225
|
+
4. Report progress: ` ✓ Batch <N>/<total> written to disk (<M> sections)`
|
|
226
|
+
5. Then launch the next batch.
|
|
227
|
+
|
|
228
|
+
**Never hold results across batches.** Each batch's sections must be on disk before
|
|
229
|
+
the next batch starts. Compaction mid-batch loses at most 8 sections; those will be
|
|
230
|
+
regenerated on the next `/mdd manual` run (their hashes won't be in `.hashes.json`
|
|
231
|
+
since that's only written at the very end).
|
|
232
|
+
|
|
233
|
+
**Section patching rules (applied after each batch or each sequential section):**
|
|
234
|
+
|
|
235
|
+
For each returned section:
|
|
236
|
+
- Find the `<!-- mdd-section: <id> -->` … `<!-- /mdd-section: <id> -->` block in the
|
|
237
|
+
current `manual.md`.
|
|
238
|
+
- If found: replace the entire block with the new section.
|
|
239
|
+
- If not found (new doc): append the section after the last `<!-- /mdd-section: -->` tag
|
|
240
|
+
in the Features chapter (or Operations chapter for ops runbooks). If neither marker
|
|
241
|
+
exists yet, append after the `## Features` or `## Operations` heading.
|
|
242
|
+
- Write `manual.md` to disk after each patch.
|
|
141
243
|
|
|
142
244
|
**Reading source files during generation:**
|
|
143
245
|
When the feature doc lists `source_files`, read those files briefly to verify the section
|
|
@@ -147,59 +249,33 @@ section header.
|
|
|
147
249
|
|
|
148
250
|
---
|
|
149
251
|
|
|
150
|
-
### Phase
|
|
252
|
+
### Phase M4 — Final Assembly
|
|
151
253
|
|
|
152
|
-
|
|
254
|
+
After all sections are on disk, perform final assembly passes on `manual.md`.
|
|
153
255
|
|
|
154
|
-
|
|
256
|
+
**Step 1 — Rebuild aggregated reference sections**
|
|
155
257
|
|
|
156
|
-
|
|
157
|
-
is user-written content — preserve it exactly across runs. If the file is new, generate
|
|
158
|
-
a default preface (see Step 2).
|
|
258
|
+
Scan every `<!-- mdd-section: -->` block in the current `manual.md` for:
|
|
159
259
|
|
|
160
|
-
**
|
|
260
|
+
**Command Reference** — find all `#### Commands` tables. Merge into one master table,
|
|
261
|
+
sorted alphabetically by command. Include a "Feature" column. Replace the existing
|
|
262
|
+
`## Command Reference` section (or append if missing).
|
|
161
263
|
|
|
162
|
-
|
|
264
|
+
**API Reference** — find all `#### API Endpoints` tables. Merge into one master table,
|
|
265
|
+
sorted by path. Include a "Feature" column. Replace the existing `## API Reference`
|
|
266
|
+
section (or append if missing). Omit this section entirely if no API endpoints were found.
|
|
163
267
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```markdown
|
|
168
|
-
# <Project Name> — User Manual
|
|
169
|
-
|
|
170
|
-
> <tagline or one-sentence description>
|
|
171
|
-
|
|
172
|
-
**Version:** <version from package.json, or "—">
|
|
173
|
-
**Generated:** <date>
|
|
174
|
-
|
|
175
|
-
<2-3 paragraph project overview synthesized from README and .startup.md>
|
|
268
|
+
**Configuration** — find all `#### Configuration` tables. Merge into one master table,
|
|
269
|
+
grouped by feature. Replace the existing `## Configuration` section (or append if
|
|
270
|
+
missing). Omit this section entirely if no configuration options were found.
|
|
176
271
|
|
|
177
|
-
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
**Step 3 — Patch sections**
|
|
181
|
-
|
|
182
|
-
Apply changes to the existing manual body:
|
|
183
|
-
|
|
184
|
-
- **Changed/new sections:** Find the `<!-- mdd-section: <id> -->` … `<!-- /mdd-section: <id> -->` block in the existing body and replace it with the newly generated section. If no existing block is found (new doc), append after the last existing `<!-- /mdd-section -->` tag in the Features or Operations chapter.
|
|
185
|
-
- **Deleted sections:** Find and remove the entire `<!-- mdd-section: <id> -->` … `<!-- /mdd-section: <id> -->` block including surrounding blank lines.
|
|
186
|
-
- **Unchanged sections:** Leave exactly as-is.
|
|
187
|
-
|
|
188
|
-
**Step 4 — Rebuild aggregated reference sections**
|
|
272
|
+
**Step 2 — Regenerate TOC**
|
|
189
273
|
|
|
190
|
-
|
|
274
|
+
Scan the assembled document for all `##` and `###` headings. Build a markdown TOC with
|
|
275
|
+
anchor links. Replace the `<!-- toc -->` … `<!-- /toc -->` block (between
|
|
276
|
+
`## Table of Contents` and the next `---` divider) with the new TOC.
|
|
191
277
|
|
|
192
|
-
**
|
|
193
|
-
|
|
194
|
-
**API Reference** — scan every feature section for `#### API Endpoints` tables. Merge into one master table, sorted by path. Include a "Feature" column.
|
|
195
|
-
|
|
196
|
-
**Configuration** — scan every feature section for `#### Configuration` tables. Merge into one master table, grouped by feature.
|
|
197
|
-
|
|
198
|
-
**Step 5 — Regenerate TOC**
|
|
199
|
-
|
|
200
|
-
Scan the assembled document for all `##` and `###` headings. Build a markdown TOC with anchor links. Replace the existing TOC block (between `## Table of Contents` and the next `---` divider) with the new one.
|
|
201
|
-
|
|
202
|
-
**Step 6 — Final document structure**
|
|
278
|
+
**Step 3 — Final document structure**
|
|
203
279
|
|
|
204
280
|
The assembled `manual.md` must follow this order:
|
|
205
281
|
|
|
@@ -214,6 +290,7 @@ The assembled `manual.md` must follow this order:
|
|
|
214
290
|
---
|
|
215
291
|
|
|
216
292
|
## Table of Contents ← always regenerated
|
|
293
|
+
<!-- toc -->
|
|
217
294
|
1. [Overview](#overview)
|
|
218
295
|
2. [Features](#features)
|
|
219
296
|
- [Feature Name](#feature-name)
|
|
@@ -222,6 +299,7 @@ The assembled `manual.md` must follow this order:
|
|
|
222
299
|
4. [Command Reference](#command-reference)
|
|
223
300
|
5. [API Reference](#api-reference) ← omit if no API endpoints found
|
|
224
301
|
6. [Configuration](#configuration) ← omit if no config options found
|
|
302
|
+
<!-- /toc -->
|
|
225
303
|
|
|
226
304
|
---
|
|
227
305
|
|
|
@@ -261,23 +339,33 @@ The assembled `manual.md` must follow this order:
|
|
|
261
339
|
| Option | Type | Default | Description | Feature |
|
|
262
340
|
```
|
|
263
341
|
|
|
264
|
-
|
|
265
|
-
all feature sections.
|
|
342
|
+
**Step 2 — Build/update preface** (if generating for the first time)
|
|
266
343
|
|
|
267
|
-
|
|
344
|
+
If the preface was newly generated in Phase M2, ensure it uses this content:
|
|
268
345
|
|
|
269
|
-
|
|
346
|
+
Read `.mdd/.startup.md` for: project name, stack, tagline. Read `package.json` (if
|
|
347
|
+
present) for version. Read `README.md` introduction (first 3 paragraphs, if present).
|
|
270
348
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
349
|
+
```markdown
|
|
350
|
+
# <Project Name> — User Manual
|
|
351
|
+
|
|
352
|
+
> <tagline or one-sentence description>
|
|
353
|
+
|
|
354
|
+
**Version:** <version from package.json, or "—">
|
|
355
|
+
**Generated:** <date>
|
|
356
|
+
|
|
357
|
+
<2-3 paragraph project overview synthesized from README and .startup.md>
|
|
358
|
+
|
|
359
|
+
---
|
|
274
360
|
```
|
|
275
361
|
|
|
276
|
-
|
|
362
|
+
Write the final assembled `manual.md` to disk.
|
|
363
|
+
|
|
364
|
+
---
|
|
277
365
|
|
|
278
|
-
|
|
366
|
+
### Phase M5 — Write Hashes & Report
|
|
279
367
|
|
|
280
|
-
**Step
|
|
368
|
+
**Step 1 — Update hash store**
|
|
281
369
|
|
|
282
370
|
Write `.mdd/manual/.hashes.json` with:
|
|
283
371
|
- One entry per doc that now exists on disk (use the current hash)
|
|
@@ -285,7 +373,11 @@ Write `.mdd/manual/.hashes.json` with:
|
|
|
285
373
|
- Update `_generated` to current ISO timestamp
|
|
286
374
|
- Set `_manual_version: 1` (or increment if already set)
|
|
287
375
|
|
|
288
|
-
**
|
|
376
|
+
**Only write this file after manual.md is fully complete.** The hash file is the
|
|
377
|
+
completion marker — if `.hashes.json` is missing or stale, the next run will know
|
|
378
|
+
to regenerate all sections.
|
|
379
|
+
|
|
380
|
+
**Step 2 — Report**
|
|
289
381
|
|
|
290
382
|
```
|
|
291
383
|
✅ Manual generated
|
|
@@ -303,7 +395,7 @@ Tip: manual.md is print-ready markdown. Open in any markdown viewer,
|
|
|
303
395
|
export to PDF, or use as source material for blog posts and docs.
|
|
304
396
|
```
|
|
305
397
|
|
|
306
|
-
**Step
|
|
398
|
+
**Step 3 — Gitignore check**
|
|
307
399
|
|
|
308
400
|
Check whether `.mdd/manual/` is in `.gitignore`. If not, suggest:
|
|
309
401
|
```
|
|
@@ -333,3 +425,17 @@ can read and understand. Rules for section writers:
|
|
|
333
425
|
- **One idea per paragraph** — keep paragraphs to 3–5 sentences
|
|
334
426
|
- **Examples are mandatory** for any command or API endpoint listed
|
|
335
427
|
- **Planned features** are clearly marked `(planned — not yet implemented)`
|
|
428
|
+
|
|
429
|
+
### Recovery from Interrupted Runs
|
|
430
|
+
|
|
431
|
+
If `/mdd manual` was interrupted mid-generation (context compaction, session end, etc.):
|
|
432
|
+
|
|
433
|
+
1. Re-run `/mdd manual`. The hash check will find that `.hashes.json` is missing or
|
|
434
|
+
incomplete (since it's only written at the very end in Phase M5).
|
|
435
|
+
2. Sections already written to `manual.md` (from completed batches) will be detected as
|
|
436
|
+
present — but since their hashes aren't in `.hashes.json`, they'll be classified as
|
|
437
|
+
`new` and regenerated.
|
|
438
|
+
3. The regenerated sections will simply replace what was already there. No data is lost.
|
|
439
|
+
|
|
440
|
+
To skip regenerating sections that look complete, a user can run `--force` after manually
|
|
441
|
+
verifying the manual looks correct, then let Phase M5 write the hash file to seal the run.
|