@nurix/etna 0.18.10 → 0.18.12

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.
Files changed (119) hide show
  1. package/README.md +13 -13
  2. package/bin/etna.js +98 -2
  3. package/data/harness-index.json +9 -1
  4. package/data/harnesses/code/CLAUDE.md +9 -10
  5. package/data/harnesses/code/agents/brainstorm.md +3 -3
  6. package/data/harnesses/code/agents/change-review.md +4 -4
  7. package/data/harnesses/code/agents/maintenance.md +177 -59
  8. package/data/harnesses/code/agents/spec-mode.md +3 -3
  9. package/data/harnesses/code/harness.json +2 -2
  10. package/data/harnesses/code/hooks/generate-ownership-index.mjs +148 -0
  11. package/data/harnesses/code/hooks/hooks.json +12 -0
  12. package/data/harnesses/code/skills/boundary/references/boundary-taxonomy.md +3 -3
  13. package/data/harnesses/code/skills/brainstorm/README.md +11 -9
  14. package/data/harnesses/code/skills/brainstorm/SKILL.md +2 -2
  15. package/data/harnesses/code/skills/brainstorm/harvest.md +5 -6
  16. package/data/harnesses/code/skills/distiller/SKILL.md +3 -3
  17. package/data/harnesses/code/skills/distiller/references/docs-mode.md +7 -7
  18. package/data/harnesses/code/skills/documentation/SKILL.md +23 -23
  19. package/data/harnesses/code/skills/documentation/references/templates.md +26 -64
  20. package/data/harnesses/etna/.prettierignore +12 -0
  21. package/data/harnesses/etna/.prettierrc.json +3 -0
  22. package/data/harnesses/etna/.vscode/settings.json +10 -0
  23. package/data/harnesses/etna/CLAUDE.md +151 -0
  24. package/data/harnesses/etna/agents/brainstorm.md +35 -0
  25. package/data/harnesses/etna/agents/change-review.md +251 -0
  26. package/data/harnesses/etna/agents/maintenance.md +240 -0
  27. package/data/harnesses/etna/agents/performance-review.md +223 -0
  28. package/data/harnesses/etna/agents/spec-mode.md +56 -0
  29. package/data/harnesses/etna/harness.json +11 -0
  30. package/data/harnesses/etna/hooks/generate-ownership-index.mjs +148 -0
  31. package/data/harnesses/etna/hooks/hooks.json +39 -0
  32. package/data/harnesses/etna/hooks/lib/redact.mjs +35 -0
  33. package/data/harnesses/etna/hooks/prompt-recall.mjs +155 -0
  34. package/data/harnesses/etna/hooks/session-reflect.mjs +285 -0
  35. package/data/harnesses/etna/rules/general.md +86 -0
  36. package/data/harnesses/etna/rules/kb.md +13 -0
  37. package/data/harnesses/etna/rules/nomenclature.md +41 -0
  38. package/data/harnesses/etna/rules/npm-cli.md +88 -0
  39. package/data/harnesses/etna/skills/boundary/SKILL.md +49 -0
  40. package/data/harnesses/etna/skills/boundary/references/boundary-taxonomy.md +796 -0
  41. package/data/harnesses/etna/skills/brainstorm/README.md +138 -0
  42. package/data/harnesses/etna/skills/brainstorm/SKILL.md +135 -0
  43. package/data/harnesses/etna/skills/brainstorm/harvest.md +25 -0
  44. package/data/harnesses/etna/skills/brainstorm/templates/backlog.md +39 -0
  45. package/data/harnesses/etna/skills/brainstorm/templates/build.md +37 -0
  46. package/data/harnesses/etna/skills/brainstorm/templates/decisions.md +29 -0
  47. package/data/harnesses/etna/skills/brainstorm/templates/doctrine.md +31 -0
  48. package/data/harnesses/etna/skills/brainstorm/templates/domain-model.md +25 -0
  49. package/data/harnesses/etna/skills/brainstorm/templates/glossary.md +20 -0
  50. package/data/harnesses/etna/skills/brainstorm/templates/milestones.md +43 -0
  51. package/data/harnesses/etna/skills/brainstorm/templates/non-goals.md +17 -0
  52. package/data/harnesses/etna/skills/brainstorm/templates/plan-doc.md +61 -0
  53. package/data/harnesses/etna/skills/brainstorm/templates/questions.md +36 -0
  54. package/data/harnesses/etna/skills/brainstorm/templates/references.md +28 -0
  55. package/data/harnesses/etna/skills/brainstorm/templates/rejected.md +29 -0
  56. package/data/harnesses/etna/skills/brainstorm/templates/state.md +1 -0
  57. package/data/harnesses/etna/skills/brainstorm/templates/tech.md +23 -0
  58. package/data/harnesses/etna/skills/brainstorm/templates/thesis.md +21 -0
  59. package/data/harnesses/etna/skills/distiller/SKILL.md +90 -0
  60. package/data/harnesses/etna/skills/distiller/references/docs-mode.md +299 -0
  61. package/data/harnesses/etna/skills/distiller/references/method.md +94 -0
  62. package/data/harnesses/etna/skills/documentation/SKILL.md +124 -0
  63. package/data/harnesses/etna/skills/documentation/references/examples.md +162 -0
  64. package/data/harnesses/etna/skills/documentation/references/style-guide.md +308 -0
  65. package/data/harnesses/etna/skills/documentation/references/templates.md +853 -0
  66. package/data/harnesses/etna/skills/workflow-mapper/SKILL.md +451 -0
  67. package/data/harnesses/etna/skills/workflow-mapper/references/patterns.md +214 -0
  68. package/data/harnesses/hr/harness.json +1 -1
  69. package/data/harnesses/hr/skills/evaluator/criteria/testing.md +4 -4
  70. package/data/harnesses/mobile/.prettierignore +12 -0
  71. package/data/harnesses/mobile/.prettierrc.json +3 -0
  72. package/data/harnesses/mobile/.vscode/settings.json +10 -0
  73. package/data/harnesses/mobile/CLAUDE.md +128 -0
  74. package/data/harnesses/mobile/agents/brainstorm.md +35 -0
  75. package/data/harnesses/mobile/agents/change-review.md +251 -0
  76. package/data/harnesses/mobile/agents/maintenance.md +240 -0
  77. package/data/harnesses/mobile/agents/performance-review.md +223 -0
  78. package/data/harnesses/mobile/agents/spec-mode.md +56 -0
  79. package/data/harnesses/mobile/harness.json +11 -0
  80. package/data/harnesses/mobile/hooks/generate-ownership-index.mjs +148 -0
  81. package/data/harnesses/mobile/hooks/hooks.json +39 -0
  82. package/data/harnesses/mobile/hooks/lib/redact.mjs +35 -0
  83. package/data/harnesses/mobile/hooks/prompt-recall.mjs +155 -0
  84. package/data/harnesses/mobile/hooks/session-reflect.mjs +285 -0
  85. package/data/harnesses/mobile/rules/general.md +86 -0
  86. package/data/harnesses/mobile/rules/nomenclature.md +41 -0
  87. package/data/harnesses/mobile/rules/react-native.md +132 -0
  88. package/data/harnesses/mobile/rules/typescript.md +40 -0
  89. package/data/harnesses/mobile/skills/boundary/SKILL.md +49 -0
  90. package/data/harnesses/mobile/skills/boundary/references/boundary-taxonomy.md +796 -0
  91. package/data/harnesses/mobile/skills/brainstorm/README.md +138 -0
  92. package/data/harnesses/mobile/skills/brainstorm/SKILL.md +135 -0
  93. package/data/harnesses/mobile/skills/brainstorm/harvest.md +25 -0
  94. package/data/harnesses/mobile/skills/brainstorm/templates/backlog.md +39 -0
  95. package/data/harnesses/mobile/skills/brainstorm/templates/build.md +37 -0
  96. package/data/harnesses/mobile/skills/brainstorm/templates/decisions.md +29 -0
  97. package/data/harnesses/mobile/skills/brainstorm/templates/doctrine.md +31 -0
  98. package/data/harnesses/mobile/skills/brainstorm/templates/domain-model.md +25 -0
  99. package/data/harnesses/mobile/skills/brainstorm/templates/glossary.md +20 -0
  100. package/data/harnesses/mobile/skills/brainstorm/templates/milestones.md +43 -0
  101. package/data/harnesses/mobile/skills/brainstorm/templates/non-goals.md +17 -0
  102. package/data/harnesses/mobile/skills/brainstorm/templates/plan-doc.md +61 -0
  103. package/data/harnesses/mobile/skills/brainstorm/templates/questions.md +36 -0
  104. package/data/harnesses/mobile/skills/brainstorm/templates/references.md +28 -0
  105. package/data/harnesses/mobile/skills/brainstorm/templates/rejected.md +29 -0
  106. package/data/harnesses/mobile/skills/brainstorm/templates/state.md +1 -0
  107. package/data/harnesses/mobile/skills/brainstorm/templates/tech.md +23 -0
  108. package/data/harnesses/mobile/skills/brainstorm/templates/thesis.md +21 -0
  109. package/data/harnesses/mobile/skills/distiller/SKILL.md +90 -0
  110. package/data/harnesses/mobile/skills/distiller/references/docs-mode.md +299 -0
  111. package/data/harnesses/mobile/skills/distiller/references/method.md +94 -0
  112. package/data/harnesses/mobile/skills/documentation/SKILL.md +124 -0
  113. package/data/harnesses/mobile/skills/documentation/references/examples.md +162 -0
  114. package/data/harnesses/mobile/skills/documentation/references/style-guide.md +308 -0
  115. package/data/harnesses/mobile/skills/documentation/references/templates.md +853 -0
  116. package/data/harnesses/mobile/skills/workflow-mapper/SKILL.md +451 -0
  117. package/data/harnesses/mobile/skills/workflow-mapper/references/patterns.md +214 -0
  118. package/package.json +1 -1
  119. package/data/harnesses/code/agents/harness-manager.md +0 -184
@@ -0,0 +1,853 @@
1
+ # Documentation Templates
2
+
3
+ Templates for all documentation needs.
4
+
5
+ ---
6
+
7
+ ## 1. docs/README.md (Documentation Root)
8
+
9
+ Use for: the entry point for all documentation in a repo. Created during baseline audit.
10
+
11
+ ```
12
+ # {Project Name} Documentation
13
+
14
+ Technical documentation for {project description}.
15
+
16
+ > For documentation organization, authority map, and folder rules, see **[structure.md](structure.md)**.
17
+
18
+ ---
19
+
20
+ ## Quick Links
21
+
22
+ | Document | Description |
23
+ | --------------------------------- | ------------------------------------ |
24
+ | [Structure](structure.md) | Documentation entry point and rules |
25
+ | [Setup](operations/setup.md) | Installation and configuration guide |
26
+
27
+ ---
28
+
29
+ ## Architecture
30
+
31
+ System design, patterns, and technical decisions.
32
+
33
+ - [system-design.md](architecture/system-design.md) - High-level system architecture
34
+ {list all architecture docs}
35
+
36
+ ---
37
+
38
+ ## Features
39
+
40
+ Living reference docs for implemented features (how things currently work).
41
+
42
+ - [feature-name.md](features/feature-name.md) - Feature description
43
+ {list all feature docs}
44
+
45
+ ---
46
+
47
+ ## Operations
48
+
49
+ How to run, develop, and deploy.
50
+
51
+ - [setup.md](operations/setup.md) - Installation and configuration guide
52
+ {list all operations docs}
53
+
54
+ ---
55
+
56
+ ## History
57
+
58
+ Everything frozen or append-only.
59
+
60
+ - [CHANGELOG.md](history/CHANGELOG.md) - Master changelog index
61
+ - [changelog/](history/changelog/) - Individual changelog entries
62
+ - [plans/](history/plans/) - Historical implementation plans
63
+ - [research/](history/research/) - Deep-research artifacts (one folder per topic)
64
+ - [backlog.md](history/backlog.md) - Tracked work items and technical debt
65
+
66
+ ---
67
+
68
+ ## Contributing
69
+
70
+ See [CLAUDE.md](../CLAUDE.md) for documentation guidelines.
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 2. docs/structure.md (Authority Map)
76
+
77
+ Use for: defining which folder owns which topic and how docs are maintained.
78
+
79
+ ```
80
+ ---
81
+ harness-version: 1.0.0
82
+ ---
83
+
84
+ # Documentation Structure
85
+
86
+ > This file is the entry point for understanding the docs folder.
87
+ > `harness-version` above is the repo's single baseline/version sentinel — the `maintenance` agent (baseline mode) owns it and stamps the installed harness version (semver) on every reconcile.
88
+
89
+ ## Authority Map
90
+
91
+ Each topic has one canonical location. Read from here, not from plans or changelogs.
92
+
93
+ | Topic | Authority | Key Files |
94
+ | ----- | --------- | --------- |
95
+ | Code-path ownership (path → doc + module) | feature `owns:` frontmatter | the generated ownership index |
96
+ | System architecture + steering | `docs/architecture/` | domain-model, glossary, non-goals, references, adr/ |
97
+ | Feature behavior | `docs/features/` | {key files} |
98
+ | Setup & development | `docs/operations/` | {key files} |
99
+ | Historical plans | `docs/history/plans/` | YYYY-MM-DD-name.md |
100
+ | Change records | `docs/history/changelog/` | Individual entries |
101
+ | Deep-research artifacts | `docs/history/research/{topic}/` | README.md + findings.md + sources.md |
102
+ | Brainstorm design records | `docs/brainstorm/{topic}/` | state.md + pillars/ |
103
+ | Backlog | `docs/history/` | backlog.md |
104
+
105
+ ## Document Lifecycle
106
+
107
+ Plan (Status: Draft) → Implementation → Feature Doc or Architecture Update → Changelog Entry
108
+
109
+ - Plans freeze at completion — never updated to reflect current code
110
+ - Changelogs summarize + link to feature docs — no duplicated schemas
111
+ - Feature docs are the living reference — updated when code changes
112
+
113
+ ## Folder Rules
114
+
115
+ - `docs/features/`: Living reference for implemented features. Each feature doc **carries** the `owns:` / `module:` / `keywords:` / `status:` frontmatter — `owns:` declares the code-path globs it owns (the only ownership key), `module:` is an optional bounded-context label, `keywords:` are discovery terms, `status:` is `active`/`draft`/`deprecated`. The SessionStart hook unions every feature's `owns:` globs into the injected ownership index. (An optional `anchors:` block — a qmd drift tripwire, see §3 — is a separate tooling key a doc may additionally carry.)
116
+ - `docs/architecture/`: System-wide patterns and the cross-module steering layer (domain model, glossary, non-goals, references, ADRs). A module's cross-cutting prose lives here (or in a browse-folder `Readme.md`). Update when cross-cutting concerns change.
117
+ - `docs/operations/`: How-to procedures for setup, development, and deployment. Update when workflows change.
118
+ - `docs/history/plans/`: Historical. Must have `Status:` field. Never modify after completion.
119
+ - `docs/history/changelog/`: Historical. Append-only.
120
+ - `docs/history/research/{topic}/`: Deep-research artifacts — the dumped output of a research pass, one folder per topic (conventionally `README.md` synthesis + `findings.md` verified claims & citations + `sources.md`). A point-in-time, cited record — **not** a living authority doc: it owns no code (no `owns:` frontmatter) and is never edited to "stay current." A spec/plan links to it for grounding; a new question gets a new topic folder.
121
+ - `docs/brainstorm/{topic}/`: Kept design records — the committed Brainstorming-Mode session for a topic (`state.md` + `pillars/`), written by the `brainstorm` skill and **kept** after harvest as the provenance the steering pillars distil from. Author-created (never scaffolded empty), one subfolder per design conversation. Owns no code (no `owns:` frontmatter); the harvest copies its conclusions into `architecture/`/`history/` while the record stays in place. Retire a topic's folder by hand only when the design line is dead.
122
+ - `docs/history/backlog.md`: Tracked work items. Append new items under appropriate priority.
123
+
124
+ ## Health Log
125
+
126
+ <!-- Updated by maintenance agent -->
127
+ | Date | Review Summary |
128
+ | ---- | -------------- |
129
+ | {today} | Initial baseline — v{harness-version} structure established |
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 3. Code-Path Ownership & Anchors
135
+
136
+ **Ownership.** A feature doc is the canonical reference for the code paths in its **`owns:` frontmatter** — the only ownership key. To find what a doc owns, read its `owns:` globs; to find the doc for a path, match the path against the injected ownership index (the union of every feature's `owns:` globs), narrower glob wins. See **Frontmatter Derivation** in `SKILL.md` for turning code into `owns:` globs.
137
+
138
+ **Anchors (optional tooling key).** A doc may additionally carry an `anchors:` block — a qmd drift tripwire, orthogonal to ownership:
139
+
140
+ ```yaml
141
+ ---
142
+ anchors:
143
+ - "qmd query: feature-name persistence shape"
144
+ ---
145
+ ```
146
+
147
+ `anchors` is an optional list of qmd queries (or `#docid`s) that re-resolve to the code a doc abstracts as it moves. It is a drift tripwire, never a contract — an anchor that returns nothing IS the drift signal, and nothing auto-rewrites from an anchor result. It is read on demand by the maintenance anchor-drift check, never injected, and inert when qmd is absent.
148
+
149
+ ---
150
+
151
+ ## 4. Scaffold Files (create if missing)
152
+
153
+ These standard files must exist after every baseline. Create them with these scaffolds if the repo doesn't already have them.
154
+
155
+ ### docs/history/CHANGELOG.md
156
+
157
+ ```
158
+ # Changelog
159
+
160
+ All notable changes to {Project Name} will be documented in this file.
161
+
162
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
163
+
164
+ ---
165
+
166
+ ## [Unreleased]
167
+
168
+ {entries added here as work proceeds}
169
+
170
+ ---
171
+
172
+ ## Links
173
+
174
+ - [Setup Guide](../operations/setup.md)
175
+ - [Architecture](../architecture/)
176
+
177
+ ---
178
+
179
+ ## How to Update This Changelog
180
+
181
+ 1. Create a dated change file in `docs/history/changelog/`:
182
+ `docs/history/changelog/YYYY-MM-DD-feature-name.md`
183
+
184
+ 2. Update this CHANGELOG.md with a high-level summary linking to the detail file
185
+
186
+ 3. Follow Keep a Changelog categories:
187
+ - **Added** for new features
188
+ - **Changed** for changes in existing functionality
189
+ - **Deprecated** for soon-to-be removed features
190
+ - **Removed** for now removed features
191
+ - **Fixed** for bug fixes
192
+ - **Security** for security improvements
193
+ ```
194
+
195
+ ### docs/history/backlog.md
196
+
197
+ ```
198
+ # Backlog
199
+
200
+ Tracked work items, technical debt, and planned improvements. Append new items under the appropriate priority.
201
+
202
+ ---
203
+
204
+ ## Format
205
+
206
+ - **[P0]** Description — discovered by [plan-name or agent-name]
207
+
208
+ ---
209
+
210
+ ## P0 — Critical
211
+
212
+ {items here}
213
+
214
+ ## P1 — High
215
+
216
+ {items here}
217
+
218
+ ## P2 — Medium
219
+
220
+ {items here}
221
+
222
+ ## P3 — Low
223
+
224
+ {items here}
225
+ ```
226
+
227
+ ### docs/memory/index.md
228
+
229
+ ```
230
+ ---
231
+ type: cross-session-learnings
232
+ description: Shared knowledge accumulated across agent sessions. All agents should consult and update this file.
233
+ ---
234
+
235
+ # Cross-Session Learnings
236
+
237
+ ## Documentation Baseline
238
+
239
+ - **Baselined:** {today}
240
+ - **Structure:** v{harness-version} (architecture, features, operations, history, memory; + tests/ when present)
241
+ - **Spec version:** v{harness-version}
242
+ <!-- v{harness-version} resolves to the installed harness version — read it from `.claude/harness.json` (`version`) / `docs/structure.md` frontmatter (`harness-version`); never hardcode a literal version here. -->
243
+
244
+ ## Knowledge Tiers
245
+
246
+ Memory is a gradient — volume falls, signal rises, one hop down each tier. Tiers describe themselves here even before they fill:
247
+
248
+ - **Inbox** (`docs/memory/inbox/`) — per-actor queue of session lessons, written by the `session-reflect` hook at session end and consumed by the distiller on digestion. Transient by design, rarely read directly.
249
+ - **Fact-cards** (`docs/memory/facts/`) — distilled, provenance-linked atomic facts, written by the distiller (`facts` mode) from inbox entries and resurfaced at prompt time by the `prompt-recall` hook.
250
+ - **This index** — the curated read tier: the learnings list below, distilled from the colder tiers and hand-appended.
251
+
252
+ ## Learnings
253
+
254
+ {Agents append learnings here as they discover gotchas, patterns, and architecture notes}
255
+ ```
256
+
257
+ ### docs/memory/main.md
258
+
259
+ ```
260
+ ---
261
+ type: project-memory
262
+ owner: main-agent
263
+ description: Project-wide patterns and conventions confirmed in this codebase. Project facts only — user-centric facts go in ~/.claude/.
264
+ ---
265
+
266
+ # Main Agent — Project Memory
267
+
268
+ Append entries below, oldest at bottom. Format:
269
+
270
+ ## YYYY-MM-DD — {topic}
271
+
272
+ {1-3 line fact, with file paths or references where relevant}
273
+
274
+ ---
275
+
276
+ ## {today} — Baseline
277
+
278
+ Memory file initialized during documentation baseline.
279
+ ```
280
+
281
+ > The per-actor memory **inbox** (`docs/memory/inbox/`) is _not_ a baseline scaffold — the `session-reflect` hook creates it mechanically on the first reflected session. See **§11 Memory inbox entry** for its format.
282
+
283
+ ---
284
+
285
+ ## 5. Feature Documentation (docs/features/{feature}.md)
286
+
287
+ Use for: every feature in `docs/features/`. The same file persists from design (Status: Draft) through implementation to live reference (Status: Active). Sections fill in as the feature matures — no template swap.
288
+
289
+ The four research-derived sections (**Affected Modules**, **Conventions to Follow**, **Current Behavior**, **Ownership Conflicts**) map 1:1 to spec-mode's return shape. The orchestrator drops spec-mode's findings into those slots without restructuring.
290
+
291
+ ```yaml
292
+ ---
293
+ owns: ["src/feature/**", "src/other/file.ts"] # required — code-path globs this doc owns (the only ownership key)
294
+ module: billing # optional — single bounded-context label; omit if cross-cutting
295
+ keywords: [invoice, pdf] # required — discovery terms
296
+ status: active # required — active | draft | deprecated
297
+ anchors: # optional extra — a qmd drift tripwire; see §3
298
+ - "qmd query: wire envelope invariants"
299
+ ---
300
+ ```
301
+
302
+ > Declare the code paths it owns in its `owns:` frontmatter — projected at Draft, confirmed against real code at Active.
303
+
304
+ ```
305
+ # {Feature Name}
306
+
307
+ <!-- Lifecycle lives in the frontmatter `status:` key (active | draft | deprecated) — the single source of truth. Don't restate it in the body. -->
308
+ **Plan:** [history/plans/YYYY-MM-DD-feature-name.md](../history/plans/YYYY-MM-DD-feature-name.md) <!-- added once a plan exists -->
309
+
310
+ ## Goal
311
+
312
+ One sentence. What this feature accomplishes, in user-facing terms.
313
+
314
+ ## Goals & Non-Goals
315
+
316
+ **In scope**
317
+ - Bullet 1
318
+ - Bullet 2
319
+
320
+ **Out of scope**
321
+ - Bullet 1
322
+
323
+ ## Background
324
+
325
+ Why this feature exists. The user need, the business trigger, the constraint that pushed it above the line. One paragraph.
326
+
327
+ (For Product-level work, also include: problem statement, key hypotheses, open questions.)
328
+
329
+ ## Approach
330
+
331
+ High-level shape of the solution. ASCII diagram if it helps. Implementation specifics belong in the plan.
332
+
333
+ ## Affected Modules
334
+
335
+ (From spec-mode research) Files, routes, components, slices this feature involves. Group by module.
336
+
337
+ | Module | Path | Role in this feature |
338
+ |--------|------|----------------------|
339
+
340
+ ## Conventions to Follow
341
+
342
+ (From spec-mode research) Naming patterns, structural patterns, doc-fit heuristics confirmed for the area being touched. Cite the source file(s) where the convention is established.
343
+
344
+ ## Current Behavior
345
+
346
+ (From spec-mode research) How the relevant part of the system works *today*, before this feature lands. Without this baseline the design intent is hard to evaluate.
347
+
348
+ ## Ownership Conflicts
349
+
350
+ (From spec-mode research) Existing feature docs whose `owns:` globs overlap with the projected scope. Resolve before the plan starts — leave nothing unresolved.
351
+
352
+ | Conflicting doc | Overlapping path(s) | Resolution |
353
+ |-----------------|---------------------|------------|
354
+
355
+ ## Architecture
356
+
357
+ [ASCII diagram. Fill once implementation lands. See style-guide.md for box-drawing patterns.]
358
+
359
+ ## Key Functions
360
+
361
+ ### `functionName(param1, param2)`
362
+ **Goal:** What it accomplishes
363
+ **Input:**
364
+ - `param1` (type) - Description
365
+ - `param2` (type) - Description
366
+ **Output:** Return type and shape
367
+ **Side Effects:** DB writes, API calls, state updates
368
+
369
+ ### `hookName(config)`
370
+ **Goal:** What it provides
371
+ **Returns:** `{ data, loading, error }`
372
+ **Triggers:** On mount, on change, manual
373
+
374
+ ## State
375
+
376
+ **Frontend (at persistence):**
377
+ {
378
+ "data": [],
379
+ "changes": { "added": [], "updated": [], "removed": [] }
380
+ // "cache": {} // UNUSED: Deprecated
381
+ }
382
+
383
+ **Storage:** localStorage `app_state`
384
+
385
+ **Backend:**
386
+ model Resource {
387
+ id String @id
388
+ data Json
389
+ // oldField String? // UNUSED: Legacy
390
+ }
391
+
392
+ **API Shape:**
393
+ { "status": 1, "data": {...} }
394
+
395
+ ## Redux (if applicable)
396
+
397
+ **Slice:** `sliceName`
398
+
399
+ **Actions:**
400
+ - `setData(payload)` - Replace all data
401
+ - `upsertItem(item)` - Add or update single item
402
+
403
+ **Selectors:**
404
+ - `selectAll(state)` → `Array<Item>`
405
+ - `selectById(state, id)` → `Item | undefined`
406
+
407
+ ## Files
408
+
409
+ - `src/path/to/main.js` - Core logic
410
+ - `src/path/to/hooks.js` - React hooks
411
+
412
+ ## Open Questions
413
+
414
+ - Question — who decides, by when
415
+ - (Resolved questions: fold the resolution into Background.)
416
+
417
+ ## Risks
418
+
419
+ - Risk — likelihood / impact / mitigation
420
+ ```
421
+
422
+ ### Section evolution
423
+
424
+ Sections fill in across the feature's lifecycle. No template swap — they accumulate in place.
425
+
426
+ | When | Sections written | Source |
427
+ | --- | --- | --- |
428
+ | Status: Draft (design) | Goal, Goals & Non-Goals, Background, Approach, Open Questions, Risks | User interview |
429
+ | Status: Draft (research) | Affected Modules, Conventions to Follow, Current Behavior, Ownership Conflicts | spec-mode agent |
430
+ | Status: Draft → Active (implementation lands) | Architecture, Key Functions, State, Redux, Files; `owns:` globs confirmed against real code | Main agent (from actual code) |
431
+
432
+ Resolved Open Questions can be summarized into Background; unresolved ones stay visible.
433
+
434
+ ---
435
+
436
+ ## 6. Changelog
437
+
438
+ Use for: recording code changes with function-level detail.
439
+
440
+ ```
441
+ # YYYY-MM-DD - [Title]
442
+
443
+ ## Summary
444
+
445
+ Brief description of what changed and why.
446
+
447
+ ## Changes
448
+
449
+ ### Added
450
+ - `newFunction(params)` in `path/to/file.js`
451
+ - Purpose: What it does
452
+ - Used by: Where it's called
453
+
454
+ ### Modified
455
+ - `existingFunction()` in `path/to/file.js`
456
+ - Changed: What's different
457
+ - Reason: Why it changed
458
+ - Migration: What callers must do
459
+
460
+ ### Removed
461
+ - `oldFunction()` from `path/to/file.js`
462
+ - Replaced by: `newFunction()`
463
+
464
+ ## Breaking Changes
465
+
466
+ ⚠️ **[Change description]**
467
+ - Old: Previous behavior
468
+ - New: Current behavior
469
+ - Impact: What breaks
470
+ - Migration: How to fix
471
+
472
+ ## Migration Steps
473
+
474
+ - [ ] Step 1
475
+ - [ ] Step 2
476
+
477
+ ## Files Changed
478
+
479
+ - `src/path/file1.js` - Core changes
480
+ - `src/path/file2.js` - Supporting updates
481
+ ```
482
+
483
+ ---
484
+
485
+ ## 7. Plan (docs/history/plans/YYYY-MM-DD-feature-name.md)
486
+
487
+ Use for: every implementation plan. Plans are created here directly with `Status: Draft`, flip to `Status: In Progress` when work starts, and freeze at `Status: Complete` or `Status: Abandoned`. Once frozen, never edit — write a new dated plan if scope changes.
488
+
489
+ The `boundary` skill parses the **Proposed Changes** sections to check boundary impact before execution. Keep that structure stable — section headings and bullet shape are load-bearing for the parser.
490
+
491
+ ```
492
+ # {Feature Name}
493
+
494
+ **Status:** Draft | In Progress | Complete | Abandoned
495
+ **Spec:** [docs/features/{feature}.md](../../features/{feature}.md)
496
+ **Started:** YYYY-MM-DD
497
+ **Completed:** YYYY-MM-DD <!-- fill when status flips to Complete -->
498
+
499
+ ## Background
500
+
501
+ Why this work is happening *now*. Link to the spec for *what* we're building; this section is the motivation and the trigger. One paragraph.
502
+
503
+ ## Proposed Changes
504
+
505
+ ### New Files
506
+
507
+ - `src/path/new-file.js` — purpose
508
+
509
+ ### Modified Files
510
+
511
+ - `src/path/existing.js` — what changes and why
512
+
513
+ ### New Entities / State
514
+
515
+ - `entities.foo` — new Redux slice / DB table / persisted shape
516
+ - Persisted state addition: `state.bar.baz` (default `null` for existing users on rehydrate)
517
+
518
+ ### API Changes
519
+
520
+ - `POST /api/foo` — new route, request `{...}`, response `{status, data}`
521
+ - `PUT /api/bar` — request shape changes; see Migration
522
+
523
+ ### Cross-Module Contracts Affected
524
+
525
+ - List which cross-cutting contracts this plan affects (db schema, wire envelope, auth, events, env/config, …)
526
+ - "None" is a valid answer and means the `boundary` check will pass cleanly
527
+
528
+ ## Implementation Steps
529
+
530
+ 1. Concrete, ordered, testable
531
+ 2. Each step ends with something verifiable
532
+ 3. ...
533
+
534
+ ## Done Criteria
535
+
536
+ - [ ] Implementation complete and verified
537
+ - [ ] Affected docs updated (use the injected ownership index to find them)
538
+ - [ ] Changelog entry created in `docs/history/changelog/`
539
+ - [ ] Plan marked `Status: Complete`, **Completed:** date filled
540
+
541
+ ## Open Questions
542
+
543
+ - Question — who decides, by when
544
+
545
+ ## Risks
546
+
547
+ - Risk — likelihood / impact / mitigation
548
+ ```
549
+
550
+ ---
551
+
552
+ ## 8. Protected Files
553
+
554
+ Use for: documenting critical files that need approval before modification.
555
+
556
+ ```
557
+ # Protected Files
558
+
559
+ Critical files requiring approval before modification.
560
+
561
+ ## File List
562
+
563
+ # Category 1 - Description
564
+ path/to/critical/file1.js
565
+ path/to/critical/file2.js
566
+
567
+ # Category 2 - Description
568
+ path/to/another/file.js
569
+
570
+ ## Risk Summary
571
+
572
+ | Category | Risk if Broken |
573
+ |------------|-----------------|
574
+ | Category 1 | Specific impact |
575
+ | Category 2 | Specific impact |
576
+
577
+ ## Critical Logic
578
+
579
+ ### Category 1: [Name]
580
+
581
+ **Purpose:** What these files do
582
+
583
+ **Key Functions:**
584
+
585
+ | Function | Input | Output | Purpose |
586
+ |------------|-------|--------|----------------|
587
+ | `func1()` | Type | Type | What it does |
588
+ | `func2()` | Type | Type | What it does |
589
+
590
+ **Critical Behavior:**
591
+ - Important point 1
592
+ - Important point 2
593
+ ```
594
+
595
+ ---
596
+
597
+ ## 9. Architecture Decision Record (ADR)
598
+
599
+ Use for: capturing a single, point-in-time architectural decision with its context, alternatives considered, and consequences. Lives in `docs/architecture/adr/` — co-located with the architecture it decides. An ADR is **immutable** once shipped: it records the decision as made, not the deployed-design source of truth (the living prose in `docs/architecture/`). When the design later changes, update `docs/architecture/` and write a new superseding ADR; never rewrite a shipped ADR.
600
+
601
+ ### When to write an ADR
602
+
603
+ Write an ADR when **all three** apply:
604
+
605
+ 1. The decision is architectural — affects system shape, contracts, or substrate choice, not internal implementation
606
+ 2. Alternatives were genuinely considered and rejected
607
+ 3. Future maintainers will ask "why did we do it this way?"
608
+
609
+ Don't write an ADR for:
610
+
611
+ - Standing principles or style preferences (those are stances, not decisions — put them in `docs/architecture/`)
612
+ - Routine implementation choices with no rejected alternatives
613
+ - Anything you'd be happy reversing without ceremony
614
+
615
+ ### Lifecycle
616
+
617
+ `Proposed` → `Accepted` → `Deprecated` → `Superseded by ADR-NNN`
618
+
619
+ ADRs are **immutable after acceptance**. If the decision changes, write a new ADR that supersedes it. Update only the old ADR's `status` frontmatter field — never its body.
620
+
621
+ ### Naming
622
+
623
+ `ADR-NNN-short-title.md` — three-digit zero-padded number, kebab-case title. Numbers are assigned sequentially across the project and never reused.
624
+
625
+ ### Structure
626
+
627
+ Three sections are required: **Decision**, **Context**, **Consequences**. Everything else is optional — include only when warranted. Decision-first: readers should see the answer in the first paragraph.
628
+
629
+ ### Template
630
+
631
+ ```markdown
632
+ ---
633
+ title: "ADR-NNN: Short title in sentence case"
634
+ status: Accepted # Proposed | Accepted | Deprecated | Superseded by ADR-NNN
635
+ date: YYYY-MM-DD
636
+ decision-owner: Name
637
+ reviewers: [] # optional
638
+ supersedes: # optional, e.g., ADR-005
639
+ tags: [adr]
640
+ ---
641
+
642
+ # ADR-NNN: Short Title
643
+
644
+ ## Decision
645
+
646
+ [One paragraph, active voice. "We will…" Lead with the answer.]
647
+
648
+ ## Context
649
+
650
+ [The forces in play. What is the problem? Why does it need a decision now? Technical, political, social, and project-local pressures.]
651
+
652
+ ## Consequences
653
+
654
+ **Positive:**
655
+
656
+ - [What becomes easier]
657
+
658
+ **Negative:**
659
+
660
+ - [What becomes harder, what we accept reluctantly]
661
+
662
+ **Risks:**
663
+
664
+ - [Second-order effects you can already see, with mitigations if known]
665
+
666
+ <!-- Optional sections below. Include only when warranted by the decision's weight. -->
667
+
668
+ ## Decision Drivers
669
+
670
+ [Hard non-negotiables vs. strong levers. Include when alternatives exist and the criteria aren't self-evident from Context.]
671
+
672
+ ## Options Considered
673
+
674
+ | Option | Pros | Cons | Outcome |
675
+ | ------------ | ---- | ---- | --------------------- |
676
+ | **Option A** | … | … | **CHOSEN** |
677
+ | Option B | … | … | Eliminated — [reason] |
678
+
679
+ ## Deep Comparison
680
+
681
+ [Honest framing of the strongest alternative(s). Include when the table doesn't make the reasoning obvious. State the *real* reason each was rejected — not a strawman.]
682
+
683
+ ## Architecture in Detail
684
+
685
+ [Diagrams, code shape, layer responsibilities. Include when the decision implies non-trivial structure that readers need to understand alongside the *why*.]
686
+
687
+ ## Implementation Plan
688
+
689
+ | Phase | Scope | Duration |
690
+ | ----- | ----- | -------- |
691
+ | 1 | … | … |
692
+
693
+ ## Open Questions
694
+
695
+ 1. **[Question]** — _Default_: [stated default until resolved].
696
+
697
+ ## Acknowledgements
698
+
699
+ [Credit reviewers; name what they corrected. Include when reviewers materially shaped the doc.]
700
+
701
+ ## References
702
+
703
+ - [External link or cross-reference]
704
+ ```
705
+
706
+ ### Rules
707
+
708
+ - One decision per ADR. If you find yourself describing two decisions, split into two ADRs.
709
+ - Decision-first. The first paragraph after the heading is the answer; readers should not need to scroll.
710
+ - No section numbering (`§5.1.1`). Use markdown headings only — inserting a section shouldn't renumber everything.
711
+ - Frontmatter `status` is the single source of truth for lifecycle. Don't also write "Status: Accepted" in the body.
712
+ - When superseding, set the old ADR's `status: "Superseded by ADR-NNN"` and the new ADR's `supersedes: ADR-OLD`.
713
+ - The body is frozen at `Accepted`. Corrections to facts that were wrong at the time get a new ADR; typos and formatting fixes are fine.
714
+
715
+ ---
716
+
717
+ ## 10. Project Root README
718
+
719
+ Use for: the human-facing entry point at the repository root (`/README.md`) — what visitors and new contributors land on. Distinct from `docs/README.md` (the agent/doc index — see §1). The two coexist; don't merge them.
720
+
721
+ ### Strategy
722
+
723
+ The root README answers, in order:
724
+
725
+ 1. **What is this?** — one to two sentences, no marketing claims
726
+ 2. **What do I get if I install it?** — capability families
727
+ 3. **What's it built on?** — terse stack list with versions
728
+ 4. **How do I run it?** — the three or four scripts that matter
729
+ 5. **How is it laid out?** — directory tree, one-liner per significant folder
730
+ 6. **How do I extend it?** — numbered contribution checklist
731
+ 7. **What state is it in?** — pre-publish, beta, stable, internal
732
+
733
+ Skip any section that doesn't apply. Don't pad to fill the template.
734
+
735
+ ### Writing rules
736
+
737
+ - **Sentence-case headings.** "Getting started", not "Getting Started".
738
+ - **Concrete over abstract.** Real versions, real paths, real commands. No "leverages cutting-edge…".
739
+ - **The tagline answers "what is this?"** — not "why is it great?". Two sentences max.
740
+ - **Tables for enumeration** (routes, commands, endpoints). **Bullets for families and categories.**
741
+ - **Directory tree as a code block**, not a nested markdown list.
742
+ - **Numbered checklist** for "how to add a thing" — readers should be able to follow it top-to-bottom without re-reading.
743
+ - **Point to `docs/` for depth.** The root README links into deep docs; it doesn't host them.
744
+ - **Detect the package manager from the lockfile** (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, otherwise npm) and write commands accordingly. Don't hardcode `npm` if the repo uses pnpm.
745
+
746
+ ### Template
747
+
748
+ ```markdown
749
+ # {package-name}
750
+
751
+ {One- to two-sentence positioning. What it is and what scope it covers. No superlatives, no value claims.}
752
+
753
+ ## What's in the box
754
+
755
+ - **{Family 1}** — {what's in it; a few specific items, comma-listed.}
756
+ - **{Family 2}** — {what's in it.}
757
+ - **{Family 3}** — {what's in it.}
758
+
759
+ The full surface lives in [`{path/to/public-index}`]({path/to/public-index}). ← optional pointer for libraries
760
+
761
+ ## Stack
762
+
763
+ - {Framework} {version} · {Language} {version}
764
+ - {Build tool} {version}
765
+ - {Other load-bearing deps}
766
+
767
+ ## Getting started
768
+
769
+ \`\`\`bash {pm} install {pm} run dev # what it does (port, URL) {pm} run build # what it does {pm} run preview # what it does (omit if not applicable) \`\`\`
770
+
771
+ {Optional one-liner about first-run behavior — e.g., "Dev server lands on /playground."}
772
+
773
+ ## {Runtime entry point} ← optional; e.g., "The playground", "CLI", "API endpoints"
774
+
775
+ {Brief description of the dev/runtime surface.}
776
+
777
+ | {Thing} | {What it shows / does} |
778
+ | -------------------- | ---------------------- |
779
+ | `{route or command}` | {description} |
780
+
781
+ ## Layout
782
+
783
+ \`\`\` src/ ├── {entry-file} # {purpose} ├── {folder}/ # {purpose} │ └── ... └── {folder}/ # {purpose} \`\`\`
784
+
785
+ ## Adding a {primary unit}
786
+
787
+ 1. {Drop the source under the right family/folder.}
788
+ 2. {Re-export from the public surface.}
789
+ 3. {Wire into the playground / example app / test harness so reviewers can see it render.}
790
+ 4. {Document any divergence from upstream in `docs/{...}`.}
791
+
792
+ ## Styling ← optional; replace with whichever cross-cutting concern matters most
793
+
794
+ {Configuration notes that affect every consumer — design tokens, conventions, opt-outs.}
795
+
796
+ ## Status
797
+
798
+ {Pre-publish, beta, stable, internal-only. State what's stable and what's still moving — readers should know whether the API can be relied on.}
799
+
800
+ ## License
801
+
802
+ {License name — scope. e.g., "UNLICENSED — internal use only", "MIT".}
803
+ ```
804
+
805
+ ### Baseline scaffolding behavior
806
+
807
+ The baseline audit **does** scaffold the project root README when missing. The risk this template guards against — template-shaped placeholders that look abandoned — is mitigated by the writing rules above: fill every section with concrete details from the repo (real package manager from the lockfile, real scripts, real layout, real status). Skip sections that genuinely don't apply rather than leaving stubs.
808
+
809
+ **Never overwrite an existing root README** during a baseline. If one is present — even sparse or outdated — leave it untouched. Treat updates to a pre-existing root README as a separate, explicit request.
810
+
811
+ ---
812
+
813
+ ## 11. Memory inbox entry (docs/memory/inbox/{actor}.md)
814
+
815
+ Use for: the capture tier of the knowledge gradient — the durable lessons of each session (corrections, root-caused failures, decisions with rationale, discovered constraints), reflected by the `session-reflect` hook at session end. It is the raw input to distillation: `distiller facts` digests entries into fact-cards and **consumes** them, so the file holds exactly what is undigested.
816
+
817
+ ### File grain
818
+
819
+ One file **per actor**: `docs/memory/inbox/{actor}.md`. `actor` is `git config user.name` lowercased and kebab-slugged; fall back to `$USER`, then `agent`. Two actors write to different files, so the inbox is **append-only without merge conflicts** — no shared file to contend over, no lock, no last-writer-wins.
820
+
821
+ ### File header
822
+
823
+ Written once, on the first entry:
824
+
825
+ ```
826
+ # Memory inbox — {actor}
827
+ Session lessons awaiting distillation — appended by the session-reflect hook, consumed by `distiller facts`.
828
+ ```
829
+
830
+ ### Entry shape
831
+
832
+ One block per reflected session, at most 6 bullets. Each bullet is one complete, self-contained sentence tagged `[project]` (true of the repo or its tooling) or `[user]` (true of the user) — the tag routes it at distillation: project facts → `docs/memory/facts/`, user facts → user-level memory.
833
+
834
+ ```
835
+ ## YYYY-MM-DD HH:MM · session <id> · {repo}@{branch}
836
+ - [project] <one self-contained sentence, names and identifiers spelled out>
837
+ - [user] <one self-contained sentence>
838
+ ```
839
+
840
+ ### Examples
841
+
842
+ ```
843
+ ## 2026-06-08 22:26 · session bc06c4fc · etna@dev
844
+ - [project] The read_network_requests Chrome CDP tool only captures after its first call — arm it, trigger traffic, then read.
845
+ - [user] jane-doe prefers minimal fixes over defensive machinery; fail loudly instead of engineering around a problem.
846
+ ```
847
+
848
+ ### Rules
849
+
850
+ - **Hooks append, the distiller consumes.** A digested entry block is deleted by `distiller facts`; nothing else edits or reorders the file. A human may hand-append a lesson in the same shape — it rides the same queue.
851
+ - **Sessions are deduped by id.** The reflect hook skips a session whose id already appears in the file (SessionEnd re-fires on resume).
852
+ - **Secrets are redacted on write.** The privacy filter replaces secret shapes with `[redacted:{kind}]` (e.g. `[redacted:api-key]`, `[redacted:bearer]`, `[redacted:pem]`) before any line is appended — never paste a raw token in by hand either.
853
+ - **Don't curate here.** Promotion to fact-cards and `docs/memory/main.md` happens at distillation; the inbox stays a transient queue.