create-claude-cabinet 0.45.0 → 0.47.0

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 (165) hide show
  1. package/README.md +6 -10
  2. package/lib/cli.js +374 -91
  3. package/lib/copy.js +108 -6
  4. package/lib/db-setup.js +122 -17
  5. package/lib/engagement-server-setup.js +34 -9
  6. package/lib/metadata.js +51 -2
  7. package/lib/migrate-from-omega.js +13 -1
  8. package/lib/mux-setup.js +33 -9
  9. package/lib/settings-merge.js +52 -10
  10. package/lib/watchtower-setup.js +230 -0
  11. package/package.json +5 -1
  12. package/templates/cabinet/_cabinet-member-template.md +8 -3
  13. package/templates/cabinet/advisories-state-schema.md +34 -7
  14. package/templates/cabinet/checklist-stats-schema.md +15 -1
  15. package/templates/cabinet/composition-patterns.md +4 -3
  16. package/templates/cabinet/memory-lifecycle-contract.md +135 -0
  17. package/templates/cabinet/pib-db-access.md +13 -0
  18. package/templates/cabinet/skill-output-conventions.md +35 -1
  19. package/templates/cabinet/watchtower-contracts.md +503 -1
  20. package/templates/cabinet/worktree-invocation-contract.md +87 -0
  21. package/templates/engagement/OVERVIEW.md +12 -0
  22. package/templates/engagement/__tests__/engagement.test.mjs +177 -2
  23. package/templates/engagement/__tests__/invoice-doc.test.mjs +195 -0
  24. package/templates/engagement/engagement-preview.mjs +100 -0
  25. package/templates/engagement/engagement-schema.md +240 -0
  26. package/templates/engagement/engagement.mjs +391 -11
  27. package/templates/engagement/pib-db-patches/pib-db-lib.mjs +10 -1
  28. package/templates/engagement/pib-db-patches/pib-db-mcp-server.mjs +5 -44
  29. package/templates/engagement/pib-db-patches/pib-db.mjs +5 -2
  30. package/templates/hooks/action-completion-gate.sh +9 -3
  31. package/templates/hooks/memory-index-guard.sh +17 -11
  32. package/templates/hooks/watchtower-session-start.sh +24 -2
  33. package/templates/mcp/pib-db.json +1 -4
  34. package/templates/mux/__tests__/mux-fail-loud.fixture.sh +44 -0
  35. package/templates/mux/__tests__/station-liveness.fixture.sh +234 -0
  36. package/templates/mux/__tests__/station-liveness.test.mjs +47 -0
  37. package/templates/mux/bin/mux +289 -56
  38. package/templates/mux/config/help.txt +1 -0
  39. package/templates/rules/acknowledge-when-corrected.md +33 -0
  40. package/templates/rules/maintainability.md +11 -0
  41. package/templates/rules/memory-capture.md +26 -4
  42. package/templates/rules/plan-before-bulk-or-irreversible-actions.md +48 -0
  43. package/templates/rules/verify-before-asserting.md +79 -0
  44. package/templates/scripts/__tests__/advisor-pass.test.mjs +238 -0
  45. package/templates/scripts/__tests__/advisories.test.mjs +262 -0
  46. package/templates/scripts/__tests__/ahead-check-origin.test.mjs +355 -0
  47. package/templates/scripts/__tests__/batch-disposition.test.mjs +235 -0
  48. package/templates/scripts/__tests__/claude-churn-authored.test.mjs +90 -0
  49. package/templates/scripts/__tests__/cross-ring-reader.test.mjs +505 -0
  50. package/templates/scripts/__tests__/dx-captures-briefing.test.mjs +169 -0
  51. package/templates/scripts/__tests__/feedback-outbox-flush.test.mjs +232 -0
  52. package/templates/scripts/__tests__/hook-runner.test.mjs +247 -0
  53. package/templates/scripts/__tests__/narrative-corpus.test.mjs +247 -0
  54. package/templates/scripts/__tests__/phase-shim.test.mjs +112 -0
  55. package/templates/scripts/__tests__/qa-handoff-gate.test.mjs +68 -0
  56. package/templates/scripts/__tests__/qa-handoff-merge-state.test.mjs +162 -0
  57. package/templates/scripts/__tests__/resolve-cli.test.mjs +314 -0
  58. package/templates/scripts/__tests__/ring-state-ownership.test.mjs +228 -3
  59. package/templates/scripts/__tests__/ring1-content-detector.test.mjs +168 -0
  60. package/templates/scripts/__tests__/ring1-flagged-actions.test.mjs +135 -0
  61. package/templates/scripts/__tests__/ring1-script-drift.test.mjs +126 -0
  62. package/templates/scripts/__tests__/ring2-queue-reader.test.mjs +80 -0
  63. package/templates/scripts/__tests__/ring2-recall-canary.test.mjs +150 -0
  64. package/templates/scripts/__tests__/ring2-roster-review.test.mjs +311 -0
  65. package/templates/scripts/__tests__/ring2-thread-context.test.mjs +189 -0
  66. package/templates/scripts/__tests__/ring3-chunk-merge.test.mjs +122 -0
  67. package/templates/scripts/__tests__/ring3-close-lenses.test.mjs +359 -0
  68. package/templates/scripts/__tests__/ring3-dedup.test.mjs +467 -0
  69. package/templates/scripts/__tests__/ring3-memory-titles.test.mjs +187 -0
  70. package/templates/scripts/__tests__/ring3-novelty-rescue.test.mjs +148 -0
  71. package/templates/scripts/__tests__/ring3-recent-slice.test.mjs +101 -0
  72. package/templates/scripts/__tests__/ring4-reconcile.test.mjs +393 -0
  73. package/templates/scripts/__tests__/routine-dispatch.test.mjs +312 -0
  74. package/templates/scripts/__tests__/shared-thread-reader.test.mjs +187 -0
  75. package/templates/scripts/__tests__/suppression-ledger.test.mjs +148 -0
  76. package/templates/scripts/__tests__/verify-backfill.test.mjs +103 -0
  77. package/templates/scripts/__tests__/verify-coverage.test.mjs +80 -0
  78. package/templates/scripts/__tests__/watchtower-snapshot.test.mjs +261 -0
  79. package/templates/scripts/__tests__/watchtower-sync.test.mjs +311 -0
  80. package/templates/scripts/load-triage-history.js +5 -2
  81. package/templates/scripts/pib-db-mcp-server.mjs +5 -44
  82. package/templates/scripts/pib-db-path.mjs +61 -0
  83. package/templates/scripts/pib-db.mjs +5 -2
  84. package/templates/scripts/validate-memory.mjs +214 -16
  85. package/templates/scripts/watchtower-advisories.mjs +309 -0
  86. package/templates/scripts/watchtower-build-context.mjs +301 -18
  87. package/templates/scripts/watchtower-cross-ring-reader.mjs +700 -0
  88. package/templates/scripts/watchtower-hook-runner.mjs +422 -0
  89. package/templates/scripts/watchtower-lib.mjs +447 -2
  90. package/templates/scripts/watchtower-narrative-corpus.mjs +385 -0
  91. package/templates/scripts/watchtower-phase-shim.mjs +171 -0
  92. package/templates/scripts/watchtower-queue.mjs +484 -1
  93. package/templates/scripts/watchtower-ring1.mjs +533 -53
  94. package/templates/scripts/watchtower-ring2.mjs +787 -48
  95. package/templates/scripts/watchtower-ring3-close.mjs +1357 -99
  96. package/templates/scripts/watchtower-ring4-runner.sh +85 -0
  97. package/templates/scripts/watchtower-ring4.mjs +753 -0
  98. package/templates/scripts/watchtower-routines.mjs +358 -0
  99. package/templates/scripts/watchtower-snapshot.mjs +452 -0
  100. package/templates/scripts/watchtower-status.sh +1 -1
  101. package/templates/scripts/watchtower-sync.mjs +393 -0
  102. package/templates/skills/audit/SKILL.md +5 -1
  103. package/templates/skills/briefing/SKILL.md +584 -236
  104. package/templates/skills/cabinet-anthropic-insider/SKILL.md +14 -6
  105. package/templates/skills/cabinet-historian/SKILL.md +14 -11
  106. package/templates/skills/cabinet-process-therapist/SKILL.md +28 -0
  107. package/templates/skills/cabinet-security/SKILL.md +11 -0
  108. package/templates/skills/cabinet-system-advocate/SKILL.md +22 -21
  109. package/templates/skills/cabinet-user-advocate/SKILL.md +13 -7
  110. package/templates/skills/catch-up/SKILL.md +113 -0
  111. package/templates/skills/cc-publish/SKILL.md +148 -25
  112. package/templates/skills/cc-remember/SKILL.md +45 -0
  113. package/templates/skills/close/SKILL.md +107 -0
  114. package/templates/skills/collab-client/SKILL.md +22 -5
  115. package/templates/skills/collab-consultant/SKILL.md +110 -2
  116. package/templates/skills/debrief/SKILL.md +148 -16
  117. package/templates/skills/debrief-classic/SKILL.md +696 -0
  118. package/templates/skills/debrief-classic/calibration.md +44 -0
  119. package/templates/skills/debrief-classic/phases/audit-pattern-capture.md +78 -0
  120. package/templates/skills/debrief-classic/phases/auto-maintenance.md +48 -0
  121. package/templates/skills/debrief-classic/phases/checklist-feedback.md +123 -0
  122. package/templates/skills/debrief-classic/phases/close-work.md +163 -0
  123. package/templates/skills/debrief-classic/phases/health-checks.md +54 -0
  124. package/templates/skills/debrief-classic/phases/inventory.md +40 -0
  125. package/templates/skills/debrief-classic/phases/loose-ends.md +52 -0
  126. package/templates/skills/debrief-classic/phases/methodology-capture.md +223 -0
  127. package/templates/skills/debrief-classic/phases/qa-handoff-sweep.md +78 -0
  128. package/templates/skills/debrief-classic/phases/record-lessons.md +177 -0
  129. package/templates/skills/debrief-classic/phases/report.md +59 -0
  130. package/templates/skills/debrief-classic/phases/update-state.md +48 -0
  131. package/templates/skills/debrief-classic/phases/upstream-feedback.md +185 -0
  132. package/templates/skills/debrief-classic/phases/verify-coverage.md +101 -0
  133. package/templates/skills/execute/SKILL.md +77 -6
  134. package/templates/skills/execute/phases/commit-and-deploy.md +8 -0
  135. package/templates/skills/execute-group/SKILL.md +23 -26
  136. package/templates/skills/generate-plan-groups/SKILL.md +20 -0
  137. package/templates/skills/inbox/SKILL.md +124 -7
  138. package/templates/skills/memory/SKILL.md +22 -6
  139. package/templates/skills/orient/SKILL.md +140 -52
  140. package/templates/skills/orient-classic/SKILL.md +770 -0
  141. package/templates/skills/orient-classic/phases/auto-maintenance.md +52 -0
  142. package/templates/skills/orient-classic/phases/briefing.md +53 -0
  143. package/templates/skills/orient-classic/phases/cabinet.md +46 -0
  144. package/templates/skills/orient-classic/phases/checklist-status.md +54 -0
  145. package/templates/skills/orient-classic/phases/context.md +88 -0
  146. package/templates/skills/orient-classic/phases/data-sync.md +35 -0
  147. package/templates/skills/orient-classic/phases/deferred-check.md +55 -0
  148. package/templates/skills/orient-classic/phases/dx-captures.md +53 -0
  149. package/templates/skills/orient-classic/phases/health-checks.md +50 -0
  150. package/templates/skills/orient-classic/phases/verify-backfill.md +109 -0
  151. package/templates/skills/orient-classic/phases/work-scan.md +69 -0
  152. package/templates/skills/plan/SKILL.md +8 -0
  153. package/templates/skills/qa-drain/SKILL.md +157 -0
  154. package/templates/skills/qa-handoff/SKILL.md +287 -46
  155. package/templates/skills/session-handoff/SKILL.md +175 -6
  156. package/templates/skills/setup-accounts/SKILL.md +38 -16
  157. package/templates/skills/threads/SKILL.md +4 -0
  158. package/templates/skills/triage-audit/SKILL.md +6 -0
  159. package/templates/skills/validate/phases/validators.md +41 -0
  160. package/templates/skills/watchtower/SKILL.md +199 -2
  161. package/templates/verify-runtime/CONVENTIONS.md +9 -0
  162. package/templates/verify-runtime/README.md +37 -0
  163. package/templates/watchtower/config.json.template +10 -2
  164. package/templates/watchtower/queue/items/item.json.schema +1 -1
  165. package/templates/workflows/execute-group-complete.js +10 -1
@@ -0,0 +1,135 @@
1
+ # Memory Lifecycle Contract
2
+
3
+ The shared contract for how built-in memory stays bounded as it grows.
4
+ Every component that reads or writes the memory dir follows this:
5
+ `validate-memory.mjs`, `write-memory-file.mjs`, the `/cc-remember` and
6
+ `/memory` skills, the `memory-index-guard` hook, and (Stage 2) the
7
+ lifecycle verbs. Full design + cabinet critique: see
8
+ `.claude/plans/cross-store-memory-redesign.md` (act:02d15a70 = Stage 1,
9
+ this contract; act:45fb9169 = Stage 2, gated).
10
+
11
+ ## The core principle
12
+
13
+ `MEMORY.md` is loaded **in full at every session start** — it competes
14
+ for the model's context window, so it has a hard budget (≤200 lines /
15
+ ≤25KB). The disease this contract cures: the old rule required the
16
+ eagerly-loaded index to enumerate EVERY memory file (one line each), so
17
+ its size tracked total memory count and it overflowed forever — the
18
+ prune→overflow→prune treadmill.
19
+
20
+ The fix decouples the eager index from total volume: `MEMORY.md` is a
21
+ bounded **working set**, not a complete catalogue. Total memory can grow
22
+ without bound (disk and search both scale for decades); only what loads
23
+ eagerly is bounded. This is the same shape watchtower threads already
24
+ use — surface the current cursor, leave the history on disk.
25
+
26
+ ## The three blocks of MEMORY.md
27
+
28
+ A well-formed `MEMORY.md` working set has three kinds of content:
29
+
30
+ 1. **Pinned tier (decay-exempt).** Load-bearing knowledge a fresh
31
+ session needs surfaced *unbidden* — hard constraints, identity, hard
32
+ preferences, active-project pointers. These are valuable precisely
33
+ because they are stable and often OLD; they must never decay out on
34
+ recency. The defining test: *would a session that has never seen this
35
+ fail without it, and would it not know to go looking?* (e.g. "CC
36
+ hooks read tool input from stdin, not `$CLAUDE_TOOL_INPUT`".) Mark a
37
+ pinned entry with `pinned: true` in its file frontmatter (the Stage-1
38
+ default authority; revisit in Stage 2).
39
+
40
+ 2. **Recency block.** The recent window of curated entries, newest
41
+ first, filling the remaining budget to roughly 80% of the cap.
42
+ Recency is a fine proxy for "likely relevant next session" for
43
+ episodic material — and a BAD proxy for load-bearing constraints,
44
+ which is exactly why they go in the pinned tier instead.
45
+
46
+ 3. **Region pointers.** The cue-based-retrieval tier (see below) that
47
+ lets everything outside the working set stay reachable without a line
48
+ each.
49
+
50
+ ## Reachability replaces enumeration
51
+
52
+ The validator invariant is no longer "every file has its own index
53
+ line." It is: **every on-disk memory file is reachable from
54
+ `MEMORY.md`** — by one of:
55
+
56
+ - a direct working-set or `MEMORY-archive.md` index line, OR
57
+ - a **region pointer** whose glob matches the file.
58
+
59
+ A file that is none of these is an orphan and fails validation.
60
+ "Present on disk" alone is **not** reachable — that test would be
61
+ vacuous (every file is grep-able), which would silently delete the
62
+ guarantee rather than relax it. The point of relaxing enumeration is to
63
+ allow *bounded* indexing (a region covers N files with one line), not to
64
+ allow invisible files.
65
+
66
+ ## Region pointers
67
+
68
+ A region pointer declares that a whole class of files is reachable
69
+ without enumerating them. Format — the **backtick-quoted glob is the
70
+ only part the validator reads**; the rest is free-text guidance:
71
+
72
+ ```
73
+ - region `lesson_*.md` → older lessons; grep the memory dir
74
+ - region `session_summary_*.md` → past session records; grep by date
75
+ ```
76
+
77
+ Rules:
78
+
79
+ - **Globs use `*` and `?` only**, matched against the bare filename.
80
+ - **Region pointers are DERIVED, never authoritative.** They are
81
+ regenerated from what's actually on disk (by hand in Stage 1, by the
82
+ consolidation pass in Stage 2). A pointer whose glob matches **zero**
83
+ files on disk is a stale, confidently-wrong retrieval cue — *worse
84
+ than no map* — and **fails validation**. Fix the glob or remove it;
85
+ never hand-edit a pointer to claim a region that isn't there.
86
+ - **Region pointers are for recoverable history you'd think to search**
87
+ (old session narratives, cooled lesson archives). They are the WRONG
88
+ home for latent constraints — those stay in the pinned tier, eagerly
89
+ present, because their value is that you retrieve them *without*
90
+ knowing to look.
91
+
92
+ ## Spill-rate instrumentation (the Stage-2 gate)
93
+
94
+ `validate-memory.mjs` appends a working-set pressure sample to
95
+ `<memoryDir>/.memory-pressure.jsonl` (a dotfile — invisible to the
96
+ orphan scan) at most once per day, only when utilization is ≥90% of the
97
+ budget. This measures how often the working set actually runs near its
98
+ limit, so Stage 2 (the lifecycle verbs + a background forcing function)
99
+ is built only if the data shows recurring pressure on authored files —
100
+ not on a felt "it keeps overflowing" metaphor. Stage 1 alone stops the
101
+ acute treadmill; the sampler decides whether Stage 2 is warranted.
102
+
103
+ ## Stage 2 (designed, gated — NOT yet built)
104
+
105
+ The lifecycle verbs and their forcing function are specified in the plan
106
+ but gated on the spill-rate data. When built they will carry these
107
+ already-decided constraints (recorded here so Stage 1 doesn't paint them
108
+ into a corner):
109
+
110
+ - **decay** — drop an entry from the working set; the file stays
111
+ reachable (via a region pointer or the archive). Reversible.
112
+ - **consolidate** — merge a cluster into one gist that ALWAYS keeps a
113
+ lossless `consolidated_from:` provenance pointer (lossy = dropped from
114
+ the working set, never erased from disk). A cluster containing a
115
+ pinned/load-bearing entry files to the inbox; it never auto-applies,
116
+ because the *gist* becomes the retrieved truth and a wrong gist erases
117
+ a load-bearing detail.
118
+ - **supersede** — mark an entry false/obsolete so retrieval stops
119
+ surfacing it as live truth (kept on disk for audit, with a reverse
120
+ breadcrumb in its successor). Deferred until the frontmatter-parsing
121
+ question is resolved (line-scan vs. a deliberately-added dependency —
122
+ the repo currently refuses a YAML parser; see
123
+ `lesson_parsefrontmatter_flow_sequences`). supersede is a reference
124
+ graph: dangling targets, cycles, and re-pointing working-set/region
125
+ references to the superseded slug must all be validated.
126
+ - **Cross-store fold** — for session-summaries carrying design
127
+ reasoning, the durable target is a committed `.claude/methodology/`
128
+ gist, NEVER the thread cursor (which holds understanding, not
129
+ narration) and NEVER a delete-in-the-same-pass (the memory dir and
130
+ threads are both local-only/ungit'd; append-verify-then-mark
131
+ `folded_into:`, reclaim in a separate idempotent sweep).
132
+ - **Forcing function** — memory hygiene (decay/consolidate) extends
133
+ Ring 2-slow's existing `runMemoryHygiene`; only drift-supersede is the
134
+ Ring 4 memory pass. No new ring for hygiene. First passes run
135
+ dry-run-with-report.
@@ -23,6 +23,19 @@ Check: are pib_* MCP tools available?
23
23
  NO → use node scripts/pib-db.mjs list-projects, etc.
24
24
  ```
25
25
 
26
+ ### MCP invocation specifics (read before first use, not after a failure)
27
+
28
+ Two details that otherwise cost a failed call + a `ToolSearch` round-trip
29
+ every session:
30
+
31
+ - **Full tool names are prefixed `mcp__pib-db__`** (e.g.
32
+ `mcp__pib-db__pib_query`). When loading deferred tools via `ToolSearch`,
33
+ query `select:mcp__pib-db__pib_query,mcp__pib-db__pib_list_actions` —
34
+ the bare `pib_*` names will not match.
35
+ - **`pib_query`'s parameter is `sql`, not `query`.** Calling it with a
36
+ `query` argument fails (and can fail quietly). The CLI form is
37
+ `query "SQL"`; the MCP form is `{ "sql": "SELECT ..." }`.
38
+
26
39
  ## Available Operations
27
40
 
28
41
  | MCP Tool | CLI Equivalent | Description |
@@ -133,7 +133,41 @@ that format here; reference it.
133
133
  user's actual situation. This applies whether the choice is rendered via
134
134
  AskUserQuestion or prose — the primitive changes, the posture doesn't.
135
135
 
136
- ## 9. Calibration Examples
136
+ ## 9. Operator-Facing Register: Plain English by Default
137
+
138
+ When a skill addresses the operator about substantial work — a plan, an
139
+ audit finding, a checkpoint decision, a status report — there are **two
140
+ readers, and they need two registers:**
141
+
142
+ - **The filed artifact** (the plan in pib-db, the finding's record, the
143
+ report on disk) stays **technical and complete** — exact file paths,
144
+ function names, fids, acceptance criteria. A future session executes
145
+ from it cold, so precision is the whole point.
146
+ - **What you SAY to the operator** is **plain English** — concept first,
147
+ the stakes spelled out, any decision framed as options with tradeoffs.
148
+ Keep file paths and symbol names out of the spoken prose; they live in
149
+ the filed artifact, reachable on request or behind a collapsed
150
+ "full detail" pointer.
151
+
152
+ The operator is the director, not the implementer (see the user-role
153
+ brief): they decide *what* and *why* and must be able to weigh in without
154
+ parsing every technical detail. A wall of paths and identifiers is noise
155
+ to that judgment — it buries the one thing they're being asked to decide.
156
+ Lead with what changed and why it matters; keep the file-and-line
157
+ narrative for the record.
158
+
159
+ This is the **default register** for operator-facing skill output. It
160
+ does NOT relax the filed artifact's rigor — a plan still files
161
+ QA-compliant notes, an audit still records exact locations. The split is
162
+ between the *record* (technical) and the *briefing* (plain). When in
163
+ doubt, write the briefing as if explaining to a sharp colleague who
164
+ hasn't seen the code.
165
+
166
+ This is a *register* rule (how to phrase), distinct from §5 (prose vs
167
+ dialog as the *primitive*) and §8 (present-don't-prescribe as the
168
+ *posture*) — all three compose.
169
+
170
+ ## 10. Calibration Examples
137
171
 
138
172
  **Before/after — engagement decision items** (the Tier 1 conversion):
139
173