@thedecipherist/mdd 1.5.2 → 1.5.4

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.
@@ -47,20 +47,21 @@ If multiple files are provided, merge all content into a single working document
47
47
 
48
48
  This phase runs in four steps. Build-order classification (IS2c) always precedes structure determination (IS2d) because the correct numbering depends on understanding what you build vs. what you reference.
49
49
 
50
- #### Step IS2a — Extract features
50
+ #### Step IS2a — Extract features + record source line ranges
51
51
 
52
52
  Read the entire merged working document. Identify every distinct feature, system, subsystem, or bounded capability described. A "feature" is any topic that could become a standalone MDD doc — something with a purpose, decisions, constraints, and a clear scope.
53
53
 
54
- For each identified feature, capture:
54
+ For each identified feature, record:
55
55
  - Name / title
56
- - Core purpose full description, as detailed as needed. Do NOT artificially limit this to a sentence count. Capture everything the spec says about what this feature is and does.
57
- - All key decisions, constraints, business rules, edge cases, and design rationale mentioned anywhere in the spec for this feature
58
- - AST types, data structures, config schemas, error formats, and TypeScript interfaces if described
56
+ - **The exact line ranges in the source file(s) that cover this feature.** Record every range, including secondary ranges where the feature is discussed again (e.g. a directive mentioned in the syntax section AND in the security section AND in the changelog). Format: `lines 254–340, 2401–2450, 4725–4741`
57
+ - A brief extraction note: what types of content are in those ranges (e.g. "syntax section: options table, processing pipeline, scope model; security section: filesystem confinement rules; changelog: file resolution model decisions")
59
58
  - Dependencies on other features identified in the same spec
60
59
 
61
- Track which spec sections contribute to each feature. When multiple spec sections cover the same concept (same feature re-discussed with refinements), **merge them** do not create duplicate docs. When versions of the same decision conflict, keep the most specific or most recent version and note the discarded variant.
60
+ This line-range map is used in IS4 to re-read the source before writing each doc. It is the most important output of IS2a. Do not skip or estimate ranges check your chunk boundaries if unsure.
62
61
 
63
- **Changelog and review-pass sections** (sections titled "v1.0 Review", "Changelog", "Decision Log", or similar retrospective formats) are not features they are design decision records. For each decision in such a section, identify which feature it belongs to and add it to that feature's content. Do not create a standalone "Changelog" feature doc.
62
+ Track which spec sections contribute to each feature. When multiple spec sections cover the same concept (same feature re-discussed with refinements), **merge them** do not create duplicate docs. Record all contributing ranges. When versions of the same decision conflict, keep the most specific or most recent version and note the discarded variant.
63
+
64
+ **Changelog and review-pass sections** (sections titled "v1.0 Review", "Changelog", "Decision Log", or similar retrospective formats) are not standalone features — they are design decision records. For each decision in such a section, identify which feature it belongs to and add its line range to that feature's source ranges. Do not create a standalone "Changelog" feature doc.
64
65
 
65
66
  #### Step IS2b — Assign paths
66
67
 
@@ -71,45 +72,131 @@ For each identified feature, determine its `path` value:
71
72
  - Title Case, 1–3 levels, `/`-separated
72
73
  - Siblings must use identical parent spelling (if `Auth/Login` exists, new auth docs use `Auth`, not `Authentication`)
73
74
 
74
- #### Step IS2c — Build-order classification
75
+ #### Step IS2c — Project type detection + wave ordering
75
76
 
76
- This is the most important step. Features are numbered in the order a developer would actually build them — not the order they appear in the spec.
77
+ This is the most important step. Features are numbered in the order a developer would actually build them — not the order they appear in the spec. The correct order depends entirely on what type of project is being built.
77
78
 
78
- **Classify every feature as one of two types:**
79
+ **Step 1 Detect project type from the spec.**
79
80
 
80
- **COMPONENT** Something that results in code: a module, class, package, service, server, or runtime. The thing you sit down and write. Examples: Parser, Template Engine, Renderer, MCP Server, CLI.
81
+ Read the spec for these signals:
81
82
 
82
- **SPEC** Something that describes behaviour a COMPONENT must implement: a directive definition, an API contract, a security rule, a caching rule, a language feature. You consult a SPEC doc while building the COMPONENT that implements it. Examples: `@include` directive spec, Security Config spec, Cache Modes spec.
83
+ | Project type | Signals |
84
+ |---|---|
85
+ | **Language / Toolchain** | Has a Parser, AST, or grammar section. Describes directives, syntax, or a runtime. Has a CLI section. Describes an interpreter, compiler, or processing pipeline. |
86
+ | **Web API / Backend** | Describes endpoints, routes, REST, or GraphQL. Has auth/authorization sections. Describes DB models and migrations. |
87
+ | **Frontend / UI App** | Describes components, pages, or routing. Describes user interactions, forms, and layouts. Has a state management section. |
88
+ | **Library / SDK** | Describes a public API surface with exported types. Has integration or plugin sections. No server or UI sections. |
89
+ | **Extension / Plugin** | Spec is adding features to an existing product. Most features assume a host system already exists. |
83
90
 
84
- **Order COMPONENT features by build dependency:**
91
+ If signals from multiple types appear, pick the dominant one and note the mix.
85
92
 
86
- Start from the foundation (the component everything else depends on) and work outward. Ask: "What must exist before I can build this?" The component with no dependencies comes first. The component that depends on everything comes last.
93
+ **Step 2 Apply the wave ordering template for the detected type.**
87
94
 
88
- Example for a language toolchain:
95
+ **Language / Toolchain:**
96
+ ```
97
+ Wave 1 — Infrastructure Skeleton
98
+ Goal: a working program that can accept input and produce output, even if incomplete.
99
+ Build: Parser + AST types + core shared types + minimal CLI entry point
100
+ Demo-state: "can parse a source file and print the AST to stdout"
101
+
102
+ Wave 2 — First Shippable Artifact
103
+ Goal: the first thing an end user can actually use.
104
+ Build: Stripper / Renderer / Compiler — whatever produces the first real output
105
+ Demo-state: "can take a source file and produce correct output for the simplest case"
106
+
107
+ Wave 3 — Language Features
108
+ Goal: full language coverage. All directives, all syntax, all semantics.
109
+ Build: SPEC docs for every language feature + the Template Engine / Resolver that implements them
110
+ Demo-state: "all static features work correctly end to end"
111
+
112
+ Wave 4 — Dynamic / Live Features
113
+ Goal: features that require external connections (DB, HTTP, shell, AI client).
114
+ Build: MCP Server, Hook, live directive execution
115
+ Demo-state: "live data directives execute and return real results"
116
+
117
+ Wave 5 — Security, Hardening, Extras
118
+ Goal: production-safe. Sandboxed execution, audit logging, edge case handling.
119
+ Build: Security system, caching, graceful degradation
120
+ Demo-state: "untrusted documents are safe to run; audit log captures all executions"
121
+
122
+ Wave 6 — CLI, Distribution, Packaging
123
+ Goal: installable and usable by someone who has never seen the codebase.
124
+ Build: Full CLI, npm package, CI integration, documentation
125
+ Demo-state: "npm install -g, run against a real file, get correct output"
89
126
  ```
90
- Parser — foundation, no deps, must exist first
91
- Stripper — depends on Parser AST
92
- Renderer — depends on Parser AST, no connection deps
93
- Template Engine — depends on Parser + Renderer
94
- MCP Server — depends on Template Engine
95
- Hook — depends on MCP Server
96
- CLI — depends on all of the above
127
+
128
+ **Web API / Backend:**
97
129
  ```
130
+ Wave 1 — Project scaffold + DB + core models
131
+ Demo-state: "server starts, DB connects, migrations run"
98
132
 
99
- **Assign SPEC features to waves:** A SPEC feature belongs in the wave of the COMPONENT that implements it. The SPEC doc gets created alongside its implementing COMPONENT's wave so that both exist when building begins. The COMPONENT doc lists SPEC docs in its `depends_on`.
133
+ Wave 2 Auth
134
+ Demo-state: "can register, login, receive a JWT, access a protected route"
100
135
 
101
- **Determine wave breakdown:** Group COMPONENTs (and their associated SPECs) into waves by build phase. Each wave should have a clear demo-state a thing you can actually demonstrate when the wave is done.
136
+ Wave 3Core endpoints
137
+ Demo-state: "core CRUD for the main resource works end to end"
102
138
 
103
- Example wave structure for a language toolchain:
139
+ Wave 4 Business logic features
140
+ Demo-state: "main product workflow works end to end"
141
+
142
+ Wave 5 — Integrations, webhooks, external APIs
143
+ Demo-state: "third-party integrations work in staging"
144
+
145
+ Wave 6 — Admin, analytics, hardening
146
+ Demo-state: "production-ready: rate limiting, logging, admin panel live"
104
147
  ```
105
- Wave 1 — Foundation: Parser + all language directive SPECs
106
- Wave 2 Static Output: Stripper + Renderer
107
- Wave 3 — Engine: Template Engine + Caching SPECs
108
- Wave 4Live Data: MCP Server + Hook + Security SPECs
109
- Wave 5 CLI: CLI + Distribution
148
+
149
+ **Frontend / UI App:**
150
+ ```
151
+ Wave 1Routing + layout shell
152
+ Demo-state: "app loads, all routes navigate without error"
153
+
154
+ Wave 2 — Auth + core state
155
+ Demo-state: "can log in and see the main dashboard"
156
+
157
+ Wave 3 — Core features
158
+ Demo-state: "primary user workflow works end to end"
159
+
160
+ Wave 4 — Secondary features + integrations
161
+ Demo-state: "all documented features work"
162
+
163
+ Wave 5 — Polish, performance, accessibility
164
+ Demo-state: "passes lighthouse audit, all a11y checks green"
110
165
  ```
111
166
 
112
- **If no COMPONENT/SPEC distinction applies** (e.g. a feature-extension spec for an existing product), order features by: user-facing value first, infrastructure last. Earlier features should be shippable without later features.
167
+ **Library / SDK:**
168
+ ```
169
+ Wave 1 — Core types + core algorithm
170
+ Demo-state: "library installs, core function produces correct output"
171
+
172
+ Wave 2 — Full public API
173
+ Demo-state: "all documented methods work, test suite passes"
174
+
175
+ Wave 3 — Extensions, plugins, advanced options
176
+ Demo-state: "extension points work, plugin example runs"
177
+
178
+ Wave 4 — Distribution, docs, examples
179
+ Demo-state: "published to registry, README example runs from a fresh install"
180
+ ```
181
+
182
+ **Extension / Plugin:**
183
+ ```
184
+ Order by user-facing value — the most impactful feature first. Each wave should be independently usable without later waves. Infrastructure last.
185
+ ```
186
+
187
+ **Step 3 — Classify every feature.**
188
+
189
+ With the wave structure determined, classify each feature:
190
+
191
+ **COMPONENT** — results in code files: a module, class, package, service, server, or runtime. The thing you sit down and write.
192
+
193
+ **SPEC** — describes behaviour a COMPONENT must implement: a directive definition, an API contract, a security rule, a protocol. You consult a SPEC while building the COMPONENT. SPEC docs belong in the same wave as their implementing COMPONENT.
194
+
195
+ **Step 4 — Assign features to waves.**
196
+
197
+ Place each feature in the wave where it logically gets built. Ask: "At which wave would a developer need this?" Not: "In which section does the spec describe it?"
198
+
199
+ SPEC docs and their implementing COMPONENT always go in the same wave. The COMPONENT `depends_on` the SPECs it implements.
113
200
 
114
201
  #### Step IS2d — Determine output structure
115
202
 
@@ -233,6 +320,19 @@ Is the build order correct? Does each wave's demo-state make sense?
233
320
 
234
321
  ### Phase IS4 — Write Files
235
322
 
323
+ **First — ensure the MDD directory structure exists.** Run these before writing any file:
324
+
325
+ ```bash
326
+ mkdir -p .mdd/initiatives
327
+ mkdir -p .mdd/waves
328
+ mkdir -p .mdd/docs
329
+ ```
330
+
331
+ These are the exact directories MDD uses. Do not write initiative or wave files anywhere else. Full paths on disk:
332
+ - Initiatives: `.mdd/initiatives/<slug>.md`
333
+ - Waves: `.mdd/waves/<slug>-wave-N.md`
334
+ - Feature docs: `.mdd/docs/<NN>-<slug>.md`
335
+
236
336
  Write in this order: CLAUDE.md (if approved) → initiative → waves → feature docs.
237
337
 
238
338
  #### CLAUDE.md (if approved in IS2.5)
@@ -318,10 +418,39 @@ Compute and write the `hash:` field after writing.
318
418
 
319
419
  #### Feature docs
320
420
 
421
+ **Critical framing — these are build instructions, not reference documentation.**
422
+
423
+ When a developer runs `/mdd NN`, Claude reads this doc and uses it to write code. That is the only reader that matters. Write every section as if answering the question: "What exactly do I build, and how do I know when it's done?" Not: "What does this feature do?" — a passive description is useless to a builder.
424
+
321
425
  For each feature in the approved plan, in wave order:
322
426
 
323
427
  1. Auto-number continuing from the highest existing doc number in `.mdd/docs/`
324
- 2. Write `.mdd/docs/<NN>-<slug>.md`:
428
+
429
+ 2. **Re-read the source before writing.** Look up the line ranges recorded for this feature in IS2a. Re-read each range from the original spec file now — do not write from the IS2a extraction summary alone. The summary identified what exists; the re-read provides the actual content. Use the same chunked read strategy as IS1 if a range is large.
430
+
431
+ ```
432
+ Re-reading source for <slug>...
433
+ lines <X>–<Y> (<section name>) ✓
434
+ lines <X>–<Y> (<section name>) ✓
435
+ Writing doc...
436
+ ```
437
+
438
+ 3. **Run the completeness checklist against the freshly-read source before writing the doc.** For each item present in the source, it must appear in the doc:
439
+
440
+ - [ ] Every options / parameters table — every row, every column, every default value
441
+ - [ ] Every CLI subcommand and its flags (including rare/advanced flags)
442
+ - [ ] Every config JSON structure — exact keys, types, nesting, defaults
443
+ - [ ] Every TypeScript interface and type alias defined in the spec
444
+ - [ ] Every AST node type and its fields
445
+ - [ ] Every error message format and the exact condition that triggers it
446
+ - [ ] Every behavioral table (evaluation tables, state tables, format tables, platform tables)
447
+ - [ ] Every "always" / "never" / "must not" / "only valid when" rule
448
+ - [ ] Every example that illustrates an edge case or non-obvious behaviour
449
+ - [ ] Every named distinction where two similar things behave differently (e.g. `column` singular vs `columns` plural)
450
+
451
+ If any item is present in the source but not yet captured in your notes, add it now before writing the doc. Do not skip this step.
452
+
453
+ 4. Write `.mdd/docs/<NN>-<slug>.md`:
325
454
 
326
455
  ```markdown
327
456
  ---
@@ -349,29 +478,37 @@ known_issues: []
349
478
 
350
479
  # <NN> — <Feature Title>
351
480
 
352
- ## Purpose
481
+ ## What to Build
353
482
 
354
- <Full description of what this feature is and does. Include the core design rationale the "why" behind the decisions. Do not limit this to a sentence count. If the spec says a lot about this feature, capture it all here. A developer reading only this doc should fully understand what they are building.>
483
+ <Answer: "What exactly am I being asked to create?" For a COMPONENT: name the files/modules to create, what they take as input, what they produce as output, and what they must never do. For a SPEC: describe the exact behaviour contract the implementing COMPONENT must satisfy — what inputs it must accept, what output it must produce, what errors it must raise. Be concrete. "A parser that reads .md files" is too vague. "A parser that reads a .md source file and produces an array of ASTNode objects, one per directive" is correct.>
355
484
 
356
485
  ## Architecture
357
486
 
358
- <How this feature fits into the system. For a COMPONENT: describe its responsibilities, inputs, outputs, and what it must never do. For a SPEC: describe the behaviour contract the implementing COMPONENT must satisfy. Include TypeScript interfaces, AST node types, and data structures if the spec defines them.>
487
+ <How this feature fits into the system and what it depends on. For a COMPONENT: its place in the pipeline, what calls it, what it calls, what it must never reach into directly. For a SPEC: which COMPONENT implements this spec and how. Include TypeScript interfaces, AST node types, and data structures exactly as defined in the spec copy them verbatim, do not paraphrase.>
488
+
489
+ ## Implementation Notes
490
+
491
+ <Key decisions Claude must follow when implementing this feature. This is not boilerplate — write only what is non-obvious or constraining. Examples: "use a single-pass regex scanner, not a recursive descent parser"; "never buffer the full file in memory"; "the AST must be immutable after construction". If the spec gives explicit implementation guidance, it belongs here.>
359
492
 
360
493
  ## Data Model
361
494
 
362
- <Data structures, schemas, config formats described in the spec. Include the exact field names, types, and constraints. Omit section only if the spec truly defines no data structures for this feature.>
495
+ <Data structures, schemas, config formats. Include exact field names, types, nesting, and defaults. Copy JSON examples from the spec verbatim. Omit only if the spec truly defines no data structures for this feature.>
363
496
 
364
497
  ## API / Interface
365
498
 
366
- <Public interface this feature exposes: function signatures, tool names, command syntax, config keys. Omit if not applicable.>
499
+ <The exact public interface this feature exposes. Function signatures, exported types, CLI commands and flags, config keys, MCP tool names. Every option, every flag, every subcommand — do not omit rare or advanced ones. A developer should be able to write the module's index.ts exports from this section alone.>
367
500
 
368
501
  ## Business Rules
369
502
 
370
- <Every decision, constraint, validation rule, edge case, error behaviour, and "never do X" described in the spec for this feature. This section should be exhaustive — if it is in the spec, it is here. Use bullet points or numbered lists for clarity.>
503
+ <Every constraint, validation rule, edge case, error behaviour, platform difference, and "always/never/only valid when" rule from the spec. Exhaustive. If it is in the spec for this feature, it is here. Use a numbered or bulleted list. Include exact error message formats and the conditions that trigger them.>
504
+
505
+ ## Acceptance Criteria
506
+
507
+ <How do you know this feature is done? Write concrete, verifiable statements. Each criterion should be something Claude can check with a test or a manual run. Examples: "mai strip input.md produces output with zero @ directives remaining"; "parsing a file with a circular @include chain throws CIRCULAR_REFERENCE_ERROR with the full chain in the message"; "all 11 content masking patterns fire correctly on the test fixtures".>
371
508
 
372
509
  ## Dependencies
373
510
 
374
- <Other feature docs this one requires. List by ID and title. For SPECs, name the COMPONENT that implements this spec.>
511
+ <Other feature docs this one requires, by ID and title. For SPECs, state which COMPONENT implements this spec.>
375
512
 
376
513
  ## Known Issues
377
514
 
@@ -385,12 +522,12 @@ known_issues: []
385
522
  ```
386
523
  Writing files...
387
524
  ✅ CLAUDE.md
388
- ✅ initiatives/markdownai.md
389
- ✅ waves/markdownai-wave-1.md (Wave 1 — Foundation)
390
- ✅ waves/markdownai-wave-2.md (Wave 2 — Static Pipeline)
525
+ .mdd/initiatives/<slug>.md
526
+ .mdd/waves/<slug>-wave-1.md (Wave 1 — <name>)
527
+ .mdd/waves/<slug>-wave-2.md (Wave 2 — <name>)
391
528
  ...
392
- ✅ docs/01-<slug>.md [COMPONENT] <path>
393
- ✅ docs/02-<slug>.md [SPEC] <path>
529
+ .mdd/docs/01-<slug>.md [COMPONENT] <path>
530
+ .mdd/docs/02-<slug>.md [SPEC] <path>
394
531
  ...
395
532
  ```
396
533
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedecipherist/mdd",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "MDD — Manual-Driven Development workflow for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {