@thedecipherist/mdd 1.6.3 → 1.6.5

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/README.md CHANGED
@@ -42,7 +42,7 @@ Then in Claude Code:
42
42
  - [How It Works](#how-it-works)
43
43
  - [Installation](#installation)
44
44
  - [Quick Start](#quick-start)
45
- - [All 24 Modes at a Glance](#all-24-modes-at-a-glance)
45
+ - [All 25 Modes at a Glance](#all-25-modes-at-a-glance)
46
46
  - [Build Mode - Feature Development](#build-mode--feature-development)
47
47
  - [Audit Mode - Code Review](#audit-mode--code-review)
48
48
  - [Status & Notes](#status--notes)
@@ -236,10 +236,11 @@ Every feature doc and ops runbook has a `tags:` field (4–8 domain-concept keyw
236
236
 
237
237
  ---
238
238
 
239
- ## All 24 Modes at a Glance
239
+ ## All 25 Modes at a Glance
240
240
 
241
241
  ```
242
242
  /mdd <feature description> Build Mode - Document, plan, and implement
243
+ /mdd manual [--force] Manual Mode - Generate a print-ready user manual
243
244
  /mdd audit [section] Audit Mode - Scan code for violations and drift
244
245
  /mdd status Overview: docs, tests, audit state, initiatives
245
246
  /mdd scan Detect features whose source files changed
@@ -659,6 +660,38 @@ Converts one or more large spec or prompt documents — the kind produced by ext
659
660
 
660
661
  ---
661
662
 
663
+ ## Manual Mode
664
+
665
+ ### `/mdd manual [--force]`
666
+
667
+ Generates a comprehensive, print-ready user manual at `.mdd/manual/manual.md` from all MDD feature docs and ops runbooks. Uses content hashes so only changed sections are regenerated — running it repeatedly is fast.
668
+
669
+ ```bash
670
+ /mdd manual # incremental — only regenerate changed sections
671
+ /mdd manual --force # regenerate everything from scratch
672
+ ```
673
+
674
+ **What it produces:**
675
+
676
+ A single `manual.md` file with:
677
+ - **Table of Contents** — auto-generated with anchor links
678
+ - **Project Overview** — synthesized from `.mdd/.startup.md` and `README.md`
679
+ - **Feature sections** — one per MDD feature doc, written in plain English for a non-technical reader. Each section includes: what it does, how to use it, commands, API endpoints, configuration options, and examples.
680
+ - **Operations chapter** — runbooks from `.mdd/ops/` formatted as step-by-step procedures
681
+ - **Command Reference** — aggregated table of all CLI commands across all features
682
+ - **API Reference** — aggregated table of all HTTP endpoints (omitted if none)
683
+ - **Configuration** — aggregated table of all env vars and options (omitted if none)
684
+
685
+ **How the hash check works:**
686
+
687
+ On each run, MDD computes SHA256 of every doc file and compares against `.mdd/manual/.hashes.json`. Sections backed by unchanged docs are left as-is. Only changed, new, or deleted docs trigger section regeneration. `--force` bypasses this and rebuilds everything.
688
+
689
+ **Designed for publishing:** The output is clean markdown with no internal file paths, no jargon without definition, active voice, and real examples. Export to PDF, paste into a blog post, or use as source material for docs sites.
690
+
691
+ **Handles deletions:** If a feature doc is removed between runs, its section is cleanly removed from `manual.md` and its hash entry is dropped.
692
+
693
+ ---
694
+
662
695
  ## Feature Lifecycle
663
696
 
664
697
  ### `/mdd deprecate <feature-id>`
@@ -140,6 +140,7 @@ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
140
140
  - CLI command missing any of the universal flags (--env, --cwd, --verbose, --strict, --silent) — check all commands against the CLI feature doc's universal flags requirement
141
141
  - `file.*` filesystem helpers or path-resolving functions accept arbitrary paths without confinement to a documented jailRoot
142
142
  - Silent error swallow: catch block returns empty/undefined without pushing to warnings array
143
+ - Template/substitution function matches `{{varname}}` without spaces but not `{{ varname }}` with spaces — spec uses spaced form; use regex `\s*` not exact string
143
144
 
144
145
  ### P4 Low
145
146
  - Code style inconsistencies
@@ -287,6 +287,8 @@ Using a plain `const` array is not sufficient and will fail audit.
287
287
 
288
288
  **Node substitution completeness rule:** Any function that transforms, substitutes, or dispatches across AST node types must handle ALL node types defined in `types.ts` — either explicitly or with a documented explicit-skip decision. An unhandled node type that silently falls through is a bug, not a design choice.
289
289
 
290
+ **Template pattern matching rule:** Any function that matches `{{ expression }}` patterns (macro parameter substitution, interpolation, template engines) MUST use a regex with `\s*` around the identifier — e.g., `/\{\{\s*varname\s*\}\}/g` — not exact string matching like `'{{varname}}'`. The spec's canonical form uses spaces (`{{ param }}`); exact matching silently fails for spec-valid usage. This applies to any function that replaces, finds, or validates `{{ ... }}` syntax.
291
+
290
292
  **Existence gate for source_files:** When marking `status: complete`, all files listed in `source_files` must exist on disk. Missing files block completion. Add missing files to `known_issues` with a TODO, or implement them before closing the feature.
291
293
 
292
294
  **Determine the `path` field** before writing the doc. Read the `path` values of all existing docs in `.mdd/docs/` to understand established product vocabulary and category names. Then ask: "What would a user navigate to in order to reach this feature?" — answer in their mental model of the product, not the code structure. Use 1–3 segments, Title Case, product vocabulary (e.g. `Auth/Login`, `E-commerce/Cart`, `Dashboard/Analytics`). Siblings must use identical parent spelling — if `Auth/Login` exists, use `Auth` not `Authentication`. If you can infer the path from context with confidence, set it and show the user. If genuinely ambiguous (feature could belong in 2+ places), ask: "Where does this feature live in the product? (e.g. `Auth/Login` or `Dashboard/Reports`)"
@@ -0,0 +1,335 @@
1
+ ## MANUAL MODE — `/mdd manual [--force]`
2
+
3
+ Triggered when arguments start with `manual`.
4
+
5
+ Generates a comprehensive, print-ready user manual at `.mdd/manual/manual.md` from all
6
+ MDD feature docs and ops runbooks. Uses content hashes to detect what changed since the
7
+ last run — only stale sections are regenerated.
8
+
9
+ ---
10
+
11
+ ### Phase M1 — Scope & Hash Check
12
+
13
+ **Step 1 — Guard against empty projects**
14
+
15
+ Check `.mdd/docs/`. If it contains zero `.md` files:
16
+ ```
17
+ ⚠️ No feature docs found.
18
+ Run /mdd <feature> to create your first feature doc, then re-run /mdd manual.
19
+ ```
20
+ Stop here.
21
+
22
+ **Step 2 — Load stored hashes**
23
+
24
+ Read `.mdd/manual/.hashes.json` if it exists. If absent, treat every doc as new (full
25
+ generation run).
26
+
27
+ Stored hash format:
28
+ ```json
29
+ {
30
+ "docs/01-auth.md": "sha256hex",
31
+ "ops/deploy.md": "sha256hex",
32
+ "_generated": "2026-05-16T20:00:00Z",
33
+ "_manual_version": 1
34
+ }
35
+ ```
36
+
37
+ **Step 3 — Compute current hashes**
38
+
39
+ For every file in `.mdd/docs/*.md` and `.mdd/ops/*.md`, compute SHA256 of file contents:
40
+ ```bash
41
+ sha256sum .mdd/docs/*.md .mdd/ops/*.md 2>/dev/null
42
+ ```
43
+
44
+ **Step 4 — Classify each doc**
45
+
46
+ Compare current vs stored hashes:
47
+ - `unchanged` — hash matches stored value → skip section regeneration
48
+ - `changed` — hash differs → regenerate section
49
+ - `new` — no stored hash → generate section
50
+ - `deleted` — stored hash exists but file no longer present → remove section
51
+
52
+ If `--force` was passed: treat every doc as `changed` regardless of hashes.
53
+
54
+ **Step 5 — Report scope**
55
+
56
+ ```
57
+ 📖 MDD Manual Generator
58
+
59
+ Docs in scope: <N> feature docs, <N> ops runbooks
60
+ ✓ unchanged <N> (skipping)
61
+ ~ changed <N> (regenerating)
62
+ + new <N> (generating)
63
+ - deleted <N> (removing)
64
+
65
+ Output: .mdd/manual/manual.md
66
+ ```
67
+
68
+ If all docs are `unchanged` and `manual.md` already exists:
69
+ ```
70
+ ✓ Manual is up to date. No changes needed.
71
+ Run with --force to regenerate everything.
72
+ ```
73
+ Stop here.
74
+
75
+ ---
76
+
77
+ ### Phase M2 — Section Generation
78
+
79
+ For each `changed` or `new` doc, generate a user-friendly manual section. The section
80
+ must be readable by someone who has never seen the source code — focus on WHAT the
81
+ feature does and HOW to use it, not implementation details.
82
+
83
+ **Section structure per feature doc:**
84
+
85
+ ```markdown
86
+ <!-- mdd-section: <doc-id> -->
87
+ ### <Feature Title>
88
+
89
+ <2-3 sentence plain-English description of what this feature does and the problem it solves.>
90
+
91
+ #### What It Does
92
+ <Paragraph explaining the feature from a user perspective. No code internals.>
93
+
94
+ #### How To Use It
95
+ <Step-by-step user instructions. Include command syntax, options, examples.>
96
+
97
+ #### Commands
98
+ <If the feature has CLI commands — table with command, description, flags.>
99
+ | Command | Description | Flags |
100
+ |---------|-------------|-------|
101
+ | `mdd <cmd>` | … | `--flag` |
102
+
103
+ #### API Endpoints
104
+ <If the feature exposes HTTP endpoints — table with method, path, description.>
105
+ | Method | Path | Description | Auth |
106
+ |--------|------|-------------|------|
107
+
108
+ #### Configuration
109
+ <If the feature has configurable options — env vars, settings, flags.>
110
+ | Option | Type | Default | Description |
111
+ |--------|------|---------|-------------|
112
+
113
+ #### Examples
114
+ <1-3 concrete usage examples. Real commands, real output snippets.>
115
+
116
+ <!-- /mdd-section: <doc-id> -->
117
+ ```
118
+
119
+ For ops runbooks, use a condensed format:
120
+
121
+ ```markdown
122
+ <!-- mdd-section: ops/<slug> -->
123
+ ### <Runbook Title>
124
+
125
+ <Purpose of this runbook.>
126
+
127
+ #### When To Use
128
+ <Triggers or conditions that call for this runbook.>
129
+
130
+ #### Steps
131
+ <Numbered list of the procedure.>
132
+
133
+ <!-- /mdd-section: ops/<slug> -->
134
+ ```
135
+
136
+ **Parallelism:**
137
+ - 1–4 changed docs → generate in main conversation sequentially
138
+ - 5+ changed docs → launch one `general-purpose` agent per doc (max 8 concurrent). Each
139
+ agent receives: the full doc content, the section structure template above, and the
140
+ output section id. Collect all outputs before proceeding to Phase M3.
141
+
142
+ **Reading source files during generation:**
143
+ When the feature doc lists `source_files`, read those files briefly to verify the section
144
+ accurately reflects what is implemented — do not invent capabilities not present in code.
145
+ If source files don't exist yet (draft feature), note the section as "(planned)" in the
146
+ section header.
147
+
148
+ ---
149
+
150
+ ### Phase M3 — Assembly
151
+
152
+ **Step 1 — Load existing manual (if any)**
153
+
154
+ Read `.mdd/manual/manual.md`. If it does not exist, start with an empty string.
155
+
156
+ Identify the preface: everything before the first `<!-- mdd-section: -->` marker. This
157
+ is user-written content — preserve it exactly across runs. If the file is new, generate
158
+ a default preface (see Step 2).
159
+
160
+ **Step 2 — Build/update preface**
161
+
162
+ If generating for the first time (no existing manual), create a preface:
163
+
164
+ Read `.mdd/.startup.md` for: project name, stack, tagline. Read `package.json` (if
165
+ present) for version. Read `README.md` introduction (first 3 paragraphs, if present).
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>
176
+
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**
189
+
190
+ After patching all feature sections, regenerate these always (they aggregate across all docs):
191
+
192
+ **Command Reference** — scan every feature section for `#### Commands` tables. Merge into one master table, sorted alphabetically by command. Include a "Feature" column.
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**
203
+
204
+ The assembled `manual.md` must follow this order:
205
+
206
+ ```markdown
207
+ # <Project Name> — User Manual ← preface (preserved or generated)
208
+ > <tagline>
209
+
210
+ **Version:** … **Generated:** …
211
+
212
+ <overview paragraphs>
213
+
214
+ ---
215
+
216
+ ## Table of Contents ← always regenerated
217
+ 1. [Overview](#overview)
218
+ 2. [Features](#features)
219
+ - [Feature Name](#feature-name)
220
+ ...
221
+ 3. [Operations](#operations) ← omit if no ops runbooks
222
+ 4. [Command Reference](#command-reference)
223
+ 5. [API Reference](#api-reference) ← omit if no API endpoints found
224
+ 6. [Configuration](#configuration) ← omit if no config options found
225
+
226
+ ---
227
+
228
+ ## Overview ← static or regenerated from .startup.md
229
+
230
+ ---
231
+
232
+ ## Features
233
+
234
+ <!-- mdd-section: 01-... -->
235
+ ...
236
+ <!-- /mdd-section: 01-... -->
237
+
238
+ <!-- mdd-section: 02-... -->
239
+ ...
240
+
241
+ ---
242
+
243
+ ## Operations ← only if .mdd/ops/ has any files
244
+
245
+ <!-- mdd-section: ops/... -->
246
+ ...
247
+
248
+ ---
249
+
250
+ ## Command Reference
251
+ | Command | Description | Flags | Feature |
252
+
253
+ ---
254
+
255
+ ## API Reference
256
+ | Method | Path | Description | Auth | Feature |
257
+
258
+ ---
259
+
260
+ ## Configuration
261
+ | Option | Type | Default | Description | Feature |
262
+ ```
263
+
264
+ Omit any aggregated section (API Reference, Configuration) if no content was found across
265
+ all feature sections.
266
+
267
+ ---
268
+
269
+ ### Phase M4 — Write Output & Update Hashes
270
+
271
+ **Step 1 — Ensure output directory exists**
272
+ ```bash
273
+ mkdir -p .mdd/manual
274
+ ```
275
+
276
+ **Step 2 — Write manual**
277
+
278
+ Write the assembled document to `.mdd/manual/manual.md`.
279
+
280
+ **Step 3 — Update hash store**
281
+
282
+ Write `.mdd/manual/.hashes.json` with:
283
+ - One entry per doc that now exists on disk (use the current hash)
284
+ - Remove entries for deleted docs
285
+ - Update `_generated` to current ISO timestamp
286
+ - Set `_manual_version: 1` (or increment if already set)
287
+
288
+ **Step 4 — Report**
289
+
290
+ ```
291
+ ✅ Manual generated
292
+
293
+ Output: .mdd/manual/manual.md
294
+ Sections: <N> features, <N> ops runbooks
295
+ Generated: <N> new sections
296
+ Updated: <N> changed sections
297
+ Removed: <N> deleted sections
298
+ Unchanged: <N> sections (skipped)
299
+
300
+ Hashes: .mdd/manual/.hashes.json updated
301
+
302
+ Tip: manual.md is print-ready markdown. Open in any markdown viewer,
303
+ export to PDF, or use as source material for blog posts and docs.
304
+ ```
305
+
306
+ **Step 5 — Gitignore check**
307
+
308
+ Check whether `.mdd/manual/` is in `.gitignore`. If not, suggest:
309
+ ```
310
+ 💡 .mdd/manual/ is not gitignored. Add it if you prefer not to commit the
311
+ generated manual (it can be regenerated at any time with /mdd manual).
312
+ ```
313
+
314
+ ---
315
+
316
+ ### Flags
317
+
318
+ | Flag | Effect |
319
+ |------|--------|
320
+ | `--force` | Bypass hash check — regenerate all sections |
321
+ | (none) | Default — only regenerate changed/new sections |
322
+
323
+ ---
324
+
325
+ ### Notes on Quality
326
+
327
+ When generating each section, the goal is a document a non-technical user or executive
328
+ can read and understand. Rules for section writers:
329
+
330
+ - **No internal file paths** in body text (they belong in the feature doc, not the manual)
331
+ - **No jargon without definition** — if a term needs explanation, add it
332
+ - **Active voice** — "The auth system validates your token" not "Tokens are validated"
333
+ - **One idea per paragraph** — keep paragraphs to 3–5 sentences
334
+ - **Examples are mandatory** for any command or API endpoint listed
335
+ - **Planned features** are clearly marked `(planned — not yet implemented)`
package/commands/mdd.md CHANGED
@@ -3,7 +3,7 @@ description: "MDD workflow — Document → Audit → Fix → Verify. Build feat
3
3
  scope: project
4
4
  argument-hint: "<feature-description> or audit [section]"
5
5
  allowed-tools: Read, Write, Edit, Grep, Glob, Bash, AskUserQuestion, Agent
6
- mdd_version: 10
6
+ mdd_version: 11
7
7
  ---
8
8
 
9
9
  # MDD — Manual-Driven Development Workflow
@@ -130,6 +130,9 @@ Use whichever path contains `mdd-audit.md`. Store it as `$MDD_DIR` and use it fo
130
130
  - If arguments start with `ops`, `runop`, `update-op`, or `commands` →
131
131
  **Read `$MDD_DIR/mdd-ops.md` then follow the relevant OPS/COMMANDS mode instructions.**
132
132
 
133
+ - If arguments start with `manual` →
134
+ **Read `$MDD_DIR/mdd-manual.md` then follow MANUAL MODE instructions.**
135
+
133
136
  - If arguments are empty → ask the user what they want to do (build a feature, run an audit, check status, etc.)
134
137
 
135
138
  - Otherwise → **Read `$MDD_DIR/mdd-build.md` then follow BUILD MODE instructions.**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedecipherist/mdd",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "MDD — Manual-Driven Development workflow for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {