create-claude-cabinet 0.46.0 → 0.48.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 (189) hide show
  1. package/README.md +3 -6
  2. package/lib/CLAUDE.md +218 -0
  3. package/lib/cli.js +397 -382
  4. package/lib/copy.js +182 -6
  5. package/lib/db-setup.js +122 -17
  6. package/lib/engagement-server-setup.js +1 -17
  7. package/lib/engagement-setup.js +1 -1
  8. package/lib/installer-gate.js +135 -0
  9. package/lib/metadata.js +51 -2
  10. package/lib/modules.js +292 -0
  11. package/lib/mux-setup.js +1 -17
  12. package/lib/project-context.js +16 -96
  13. package/lib/settings-merge.js +194 -13
  14. package/lib/site-audit-setup.js +23 -7
  15. package/lib/verify-setup.js +20 -9
  16. package/lib/watchtower-setup.js +23 -7
  17. package/package.json +1 -1
  18. package/templates/CLAUDE.md +959 -0
  19. package/templates/briefing/_briefing-template.md +6 -11
  20. package/templates/cabinet/advisories-state-schema.md +1 -1
  21. package/templates/cabinet/checklist-stats-schema.md +15 -1
  22. package/templates/cabinet/eval-protocol.md +27 -10
  23. package/templates/cabinet/memory-lifecycle-contract.md +135 -0
  24. package/templates/cabinet/pib-db-access.md +13 -0
  25. package/templates/cabinet/watchtower-contracts.md +453 -0
  26. package/templates/cabinet/worktree-invocation-contract.md +111 -0
  27. package/templates/engagement/OVERVIEW.md +12 -0
  28. package/templates/engagement/__tests__/checklist-visibility.test.mjs +76 -0
  29. package/templates/engagement/__tests__/engagement.test.mjs +177 -2
  30. package/templates/engagement/__tests__/invoice-doc.test.mjs +195 -0
  31. package/templates/engagement/engagement-checklist.mjs +26 -2
  32. package/templates/engagement/engagement-preview.mjs +100 -0
  33. package/templates/engagement/engagement-schema.md +248 -6
  34. package/templates/engagement/engagement.mjs +391 -11
  35. package/templates/engagement/pib-db-patches/pib-db-lib.mjs +49 -9
  36. package/templates/engagement/pib-db-patches/pib-db-mcp-server.mjs +5 -44
  37. package/templates/engagement/pib-db-patches/pib-db-schema.sql +1 -1
  38. package/templates/engagement/pib-db-patches/pib-db.mjs +9 -3
  39. package/templates/engagement/sql-constants.mjs +9 -1
  40. package/templates/engagement-server/__tests__/cross-tenant-auth.test.mjs +87 -0
  41. package/templates/engagement-server/server.mjs +65 -40
  42. package/templates/hooks/action-completion-gate.sh +19 -3
  43. package/templates/hooks/action-quality-gate.sh +10 -0
  44. package/templates/hooks/memory-index-guard.sh +17 -11
  45. package/templates/hooks/skill-telemetry.sh +10 -5
  46. package/templates/hooks/skill-tool-telemetry.sh +11 -5
  47. package/templates/hooks/watchtower-session-start.sh +24 -2
  48. package/templates/mcp/pib-db.json +1 -4
  49. package/templates/mux/bin/mux +8 -1
  50. package/templates/mux/config/help.txt +1 -0
  51. package/templates/rules/acknowledge-when-corrected.md +33 -0
  52. package/templates/rules/enforcement-pipeline.md +0 -12
  53. package/templates/rules/maintainability.md +11 -0
  54. package/templates/rules/memory-capture.md +26 -4
  55. package/templates/rules/plan-before-bulk-or-irreversible-actions.md +48 -0
  56. package/templates/rules/verify-before-asserting.md +79 -0
  57. package/templates/scripts/__tests__/ahead-check-origin.test.mjs +355 -0
  58. package/templates/scripts/__tests__/api-usage-idle-gate.test.mjs +81 -0
  59. package/templates/scripts/__tests__/batch-disposition.test.mjs +98 -0
  60. package/templates/scripts/__tests__/bsql-loader-verify.test.mjs +47 -0
  61. package/templates/scripts/__tests__/claude-churn-authored.test.mjs +90 -0
  62. package/templates/scripts/__tests__/cross-ring-reader.test.mjs +505 -0
  63. package/templates/scripts/__tests__/dx-captures-briefing.test.mjs +169 -0
  64. package/templates/scripts/__tests__/hook-runner.test.mjs +247 -0
  65. package/templates/scripts/__tests__/inbox-assessment.test.mjs +341 -0
  66. package/templates/scripts/__tests__/memory-reachability.test.mjs +150 -0
  67. package/templates/scripts/__tests__/narrative-corpus.test.mjs +247 -0
  68. package/templates/scripts/__tests__/phase-shim.test.mjs +112 -0
  69. package/templates/scripts/__tests__/qa-handoff-merge-state.test.mjs +162 -0
  70. package/templates/scripts/__tests__/resolve-cli.test.mjs +314 -0
  71. package/templates/scripts/__tests__/ring-state-ownership.test.mjs +120 -0
  72. package/templates/scripts/__tests__/ring1-content-detector.test.mjs +168 -0
  73. package/templates/scripts/__tests__/ring1-flagged-actions.test.mjs +135 -0
  74. package/templates/scripts/__tests__/ring1-pib-error-surfacing.test.mjs +69 -0
  75. package/templates/scripts/__tests__/ring1-script-drift.test.mjs +126 -0
  76. package/templates/scripts/__tests__/ring1-stale-open-counts.test.mjs +143 -0
  77. package/templates/scripts/__tests__/ring2-queue-reader.test.mjs +80 -0
  78. package/templates/scripts/__tests__/ring2-recall-canary.test.mjs +150 -0
  79. package/templates/scripts/__tests__/ring2-roster-review.test.mjs +311 -0
  80. package/templates/scripts/__tests__/ring3-chunk-merge.test.mjs +122 -0
  81. package/templates/scripts/__tests__/ring3-close-lenses.test.mjs +359 -0
  82. package/templates/scripts/__tests__/ring3-dedup.test.mjs +92 -12
  83. package/templates/scripts/__tests__/ring3-memory-titles.test.mjs +187 -0
  84. package/templates/scripts/__tests__/ring3-novelty-rescue.test.mjs +148 -0
  85. package/templates/scripts/__tests__/ring3-recent-slice.test.mjs +101 -0
  86. package/templates/scripts/__tests__/ring3-thread-capture.test.mjs +213 -0
  87. package/templates/scripts/__tests__/ring4-reconcile.test.mjs +393 -0
  88. package/templates/scripts/__tests__/shared-thread-reader.test.mjs +187 -0
  89. package/templates/scripts/__tests__/suppression-ledger.test.mjs +148 -0
  90. package/templates/scripts/__tests__/verify-backfill.test.mjs +103 -0
  91. package/templates/scripts/__tests__/verify-coverage.test.mjs +80 -0
  92. package/templates/scripts/__tests__/watchtower-snapshot.test.mjs +261 -0
  93. package/templates/scripts/__tests__/watchtower-status-ring4.test.mjs +89 -0
  94. package/templates/scripts/__tests__/watchtower-sync.test.mjs +311 -0
  95. package/templates/scripts/audit-coherence-check.mjs +123 -0
  96. package/templates/scripts/audit-synth.mjs +117 -0
  97. package/templates/scripts/load-triage-history.js +5 -2
  98. package/templates/scripts/merge-findings.js +4 -1
  99. package/templates/scripts/patterns-scope-check.mjs +122 -0
  100. package/templates/scripts/pib-db-lib.mjs +61 -11
  101. package/templates/scripts/pib-db-mcp-server.mjs +7 -45
  102. package/templates/scripts/pib-db-path.mjs +61 -0
  103. package/templates/scripts/pib-db.mjs +7 -3
  104. package/templates/scripts/review-server.mjs +7 -12
  105. package/templates/scripts/triage-server.mjs +7 -8
  106. package/templates/scripts/validate-memory.mjs +214 -16
  107. package/templates/scripts/watchtower-advisories.mjs +7 -3
  108. package/templates/scripts/watchtower-build-context.mjs +192 -8
  109. package/templates/scripts/watchtower-cross-ring-reader.mjs +714 -0
  110. package/templates/scripts/watchtower-hook-runner.mjs +422 -0
  111. package/templates/scripts/watchtower-inbox-assessment.mjs +706 -0
  112. package/templates/scripts/watchtower-lib.mjs +555 -8
  113. package/templates/scripts/watchtower-narrative-corpus.mjs +385 -0
  114. package/templates/scripts/watchtower-phase-shim.mjs +171 -0
  115. package/templates/scripts/watchtower-queue.mjs +341 -3
  116. package/templates/scripts/watchtower-ring1.mjs +481 -81
  117. package/templates/scripts/watchtower-ring2.mjs +748 -80
  118. package/templates/scripts/watchtower-ring3-close.mjs +1147 -167
  119. package/templates/scripts/watchtower-ring4-runner.sh +85 -0
  120. package/templates/scripts/watchtower-ring4.mjs +753 -0
  121. package/templates/scripts/watchtower-routines.mjs +1 -1
  122. package/templates/scripts/watchtower-snapshot.mjs +452 -0
  123. package/templates/scripts/watchtower-status.sh +17 -0
  124. package/templates/scripts/watchtower-sync.mjs +393 -0
  125. package/templates/scripts/work-tracker-server.mjs +26 -22
  126. package/templates/skills/audit/SKILL.md +18 -5
  127. package/templates/skills/audit/phases/structural-checks.md +22 -0
  128. package/templates/skills/briefing/SKILL.md +289 -41
  129. package/templates/skills/cabinet-accessibility/SKILL.md +1 -1
  130. package/templates/skills/cabinet-process-therapist/SKILL.md +28 -0
  131. package/templates/skills/cabinet-security/SKILL.md +11 -0
  132. package/templates/skills/catch-up/SKILL.md +113 -0
  133. package/templates/skills/cc-publish/SKILL.md +89 -18
  134. package/templates/skills/cc-remember/SKILL.md +45 -0
  135. package/templates/skills/close/SKILL.md +107 -0
  136. package/templates/skills/collab-client/SKILL.md +22 -5
  137. package/templates/skills/collab-consultant/SKILL.md +110 -2
  138. package/templates/skills/debrief/SKILL.md +21 -4
  139. package/templates/skills/debrief/phases/audit-pattern-capture.md +13 -0
  140. package/templates/skills/debrief-classic/SKILL.md +696 -0
  141. package/templates/skills/debrief-classic/calibration.md +44 -0
  142. package/templates/skills/debrief-classic/phases/audit-pattern-capture.md +78 -0
  143. package/templates/skills/debrief-classic/phases/auto-maintenance.md +48 -0
  144. package/templates/skills/debrief-classic/phases/checklist-feedback.md +123 -0
  145. package/templates/skills/debrief-classic/phases/close-work.md +163 -0
  146. package/templates/skills/debrief-classic/phases/health-checks.md +54 -0
  147. package/templates/skills/debrief-classic/phases/inventory.md +40 -0
  148. package/templates/skills/debrief-classic/phases/loose-ends.md +52 -0
  149. package/templates/skills/debrief-classic/phases/methodology-capture.md +223 -0
  150. package/templates/skills/debrief-classic/phases/qa-handoff-sweep.md +78 -0
  151. package/templates/skills/debrief-classic/phases/record-lessons.md +177 -0
  152. package/templates/skills/debrief-classic/phases/report.md +59 -0
  153. package/templates/skills/debrief-classic/phases/update-state.md +48 -0
  154. package/templates/skills/debrief-classic/phases/upstream-feedback.md +185 -0
  155. package/templates/skills/debrief-classic/phases/verify-coverage.md +101 -0
  156. package/templates/skills/execute/SKILL.md +71 -6
  157. package/templates/skills/execute/phases/commit-and-deploy.md +8 -0
  158. package/templates/skills/execute-group/SKILL.md +23 -26
  159. package/templates/skills/generate-plan-groups/SKILL.md +20 -0
  160. package/templates/skills/inbox/SKILL.md +177 -31
  161. package/templates/skills/memory/SKILL.md +22 -6
  162. package/templates/skills/orient/SKILL.md +75 -5
  163. package/templates/skills/orient-classic/SKILL.md +770 -0
  164. package/templates/skills/orient-classic/phases/auto-maintenance.md +52 -0
  165. package/templates/skills/orient-classic/phases/briefing.md +53 -0
  166. package/templates/skills/orient-classic/phases/cabinet.md +46 -0
  167. package/templates/skills/orient-classic/phases/checklist-status.md +54 -0
  168. package/templates/skills/orient-classic/phases/context.md +88 -0
  169. package/templates/skills/orient-classic/phases/data-sync.md +35 -0
  170. package/templates/skills/orient-classic/phases/deferred-check.md +55 -0
  171. package/templates/skills/orient-classic/phases/dx-captures.md +53 -0
  172. package/templates/skills/orient-classic/phases/health-checks.md +50 -0
  173. package/templates/skills/orient-classic/phases/verify-backfill.md +109 -0
  174. package/templates/skills/orient-classic/phases/work-scan.md +69 -0
  175. package/templates/skills/pulse/SKILL.md +10 -8
  176. package/templates/skills/qa-drain/SKILL.md +38 -0
  177. package/templates/skills/qa-handoff/SKILL.md +287 -46
  178. package/templates/skills/setup-accounts/SKILL.md +38 -16
  179. package/templates/skills/spring-clean/SKILL.md +1 -1
  180. package/templates/skills/spring-clean/phases/execute-decisions.md +1 -1
  181. package/templates/skills/threads/SKILL.md +4 -0
  182. package/templates/skills/validate/phases/validators.md +127 -0
  183. package/templates/skills/watchtower/SKILL.md +174 -30
  184. package/templates/verify-runtime/CONVENTIONS.md +9 -0
  185. package/templates/verify-runtime/README.md +37 -0
  186. package/templates/watchtower/config.json.template +8 -2
  187. package/templates/workflows/deliberative-audit.js +258 -87
  188. package/templates/workflows/execute-group-complete.js +26 -3
  189. package/templates/workflows/execute-group-implement.js +16 -2
package/README.md CHANGED
@@ -129,13 +129,9 @@ you already use GitHub Issues, Linear, or something else.
129
129
  Claude Code has built-in file memory, but no guardrails around it.
130
130
  The memory module adds structure:
131
131
 
132
- - **`/cc-remember`** — write a new memory with automatic indexing.
133
- Every memory gets its own file and an entry in `MEMORY.md` so
134
- `/orient` can find it next session.
132
+ - **`/cc-remember`** — write a new memory with automatic indexing. Every memory gets its own file and is made reachable from `MEMORY.md` — by a direct entry or a region pointer — so `/orient` can find it next session.
135
133
  - **`/memory`** — browse and search what Claude remembers.
136
- - **Validation** — `validate-memory.mjs` checks that the index stays
137
- within Claude Code's session-start budget and that every file is
138
- indexed. A PostToolUse hook flags unindexed writes in real time.
134
+ - **Validation** — `validate-memory.mjs` checks that the index stays within Claude Code's session-start budget and that every memory file is reachable from `MEMORY.md`. A PostToolUse hook flags unreachable writes in real time.
139
135
 
140
136
  ### Compliance Stack (full install)
141
137
 
@@ -231,6 +227,7 @@ customization. You can pass multiple modules: `--modules verify,audit`.
231
227
  | **engagement-server** | Central multi-engagement API server (Railway/Fly deploy) |
232
228
  | **watchtower** | Continuous background state management replacing orient/debrief |
233
229
  | **mux** | Multi-project terminal manager — desks, auto-worktrees with shared identity, trail logging, DX captures, portal color-switching, durable tmux bindings, clipboard copy with hard-wrap removal, screenshot-to-clipboard launchd watcher |
230
+ | **bash-compress** | PostToolUse hook that compresses noisy Bash stdout (git status walls, npm/yarn install output) to reclaim context in long sessions; stderr and error lines pass through verbatim, fail-open |
234
231
 
235
232
  ## CLI Options
236
233
 
package/lib/CLAUDE.md ADDED
@@ -0,0 +1,218 @@
1
+ # `lib/` — Installer Internals (detailed reference)
2
+
3
+ This is the on-demand detail tier for `lib/`. Root `CLAUDE.md` § Key Files
4
+ carries the one-line current contract for each file; this file carries the
5
+ full per-file contract **and** the layered `act:`-by-`act:` evolution history.
6
+ Read this when working in `lib/`; skim root `CLAUDE.md` otherwise.
7
+
8
+ `lib/` is the installer core plus one setup engine per heavier subsystem.
9
+ No build step; CommonJS.
10
+
11
+ ## Installer core
12
+
13
+ - `lib/cli.js` — main orchestration and all CLI logic. The `MODULES`
14
+ registry MOVED to `lib/modules.js` (act:e82baead, architecture-0005);
15
+ `cli.js` re-exports it for back-compat (`require('../lib/cli').MODULES`
16
+ still works). `cli.js` keeps orchestration, arg parsing, the postInstall
17
+ pipeline, and generators.
18
+ The `--reindex` flag (act:98d41fa2) regenerates
19
+ `.claude/skills/_index.json` in place and exits (no install body, no
20
+ global side effects; no-op without `.claude/skills/`) — so a consumer
21
+ editing its `directives-project.yaml` overlay (a new session-close
22
+ mandate or routine, both read from `_index.json`) can pick it up
23
+ without a full reinstall. `generateSkillIndex` is exported.
24
+ The `--freeze`/`--unfreeze`/`--list-frozen` flags (act:c1013967) edit
25
+ `.ccrc.json` `frozenModules` and exit; the install body then expands
26
+ the declared list by its `requires` closure (`expandFrozenClosure` —
27
+ freezing engagement also pins work-tracking), intersects with what's
28
+ actually installed (`effectiveFrozen` — never the raw declared list),
29
+ and HOLDS those modules' CC-owned files at the current version (loud
30
+ per-module frozen report; an auto pib.db backup runs first when a
31
+ frozen install still has a pending schema migration). The
32
+ upstream-cleanup classifier is extracted to a pure `computeRemovals`;
33
+ it, `expandFrozenClosure`, and the hoisted top-level `manifestPath`
34
+ are exported + unit-tested. `generateAgentWrappers()` (see root
35
+ § Generated artifacts) also lives here.
36
+ - `lib/modules.js` — the `MODULES` manifest: every module → the template
37
+ paths it copies into `.claude/` (architecture-0005; extracted from
38
+ `cli.js` in act:e82baead). `cli.js` requires + re-exports it for
39
+ back-compat. This is the SINGLE source for "which files does module X
40
+ ship" — the module template arrays that older docs said "live in
41
+ `lib/cli.js`" now live here. Exports `{ MODULES }`. Unit-tested that
42
+ each module ships its declared scripts (e.g. the audit module ships
43
+ `patterns-scope-check.mjs`).
44
+ - `lib/installer-gate.js` — shared version/hash gating for the setup
45
+ engines (Wave 1, act:a6377c82). Exports `sha256`, `compareVersions`,
46
+ `hashSourceDir`, `tarballIsStale`. Before it, `sha256()` was
47
+ copy-pasted three times and `compareVersions()` twice, and the
48
+ equal-version "don't hard-skip, fall through to a per-file hash-compare"
49
+ rule was re-implemented per installer. Per-file-manifest installers
50
+ (mux, watchtower, engagement-server) use `sha256` + `compareVersions`;
51
+ versioned-tarball installers (verify, site-audit) use `tarballIsStale`
52
+ + `hashSourceDir` for the equal-version source-hash re-pack. All five
53
+ setup engines delegate here.
54
+ - `lib/copy.js` — template copying with conflict detection; exports
55
+ `recordSkip()`, the single skip-ownership helper used by every skip
56
+ site in both `lib/cli.js` and `lib/copy.js` (skipped project-created
57
+ files are omitted from the `.ccrc.json` manifest — omission means
58
+ "not ours", so a reinstall can't claim them). Also exports
59
+ `isProjectOwnedSeed()` (act:2001bf54): the basename rule for files
60
+ shipped as STARTER content but PROJECT-OWNED by declaration the moment
61
+ they land — today `directives-project.yaml`. The installer seeds them
62
+ if absent, NEVER overwrites them, and ALWAYS omits them from the
63
+ manifest (a recorded seed false-blocks the very first edit via
64
+ cc-upstream-guard and a `--yes` reinstall would clobber it). The
65
+ cli.js upstream-cleanup loop exempts these too — dropping the key
66
+ means "project-owned", NOT "removed upstream", so the freeing
67
+ reinstall can't delete the consumer's overlay. Also exports
68
+ `classifyFileOwnership()` (Wave 1, act:a6377c82): the single-file
69
+ ownership cascade used by cli.js's single-file branch — it closes the
70
+ missing `isProjectOwnedSeed` guard on that path, so a project-owned
71
+ seed reached via the single-file route is classified the same as via
72
+ the directory walk. Also exports `freezeRetain()` (act:c1013967): the
73
+ canonical FREEZE rule — a THIRD ownership state between CC-owned and
74
+ project-owned. When a module is frozen (`.ccrc.json` `frozenModules`,
75
+ threaded as `copyTemplates({frozen})`), a differing CC-managed file is
76
+ HELD instead of overwritten: an ALREADY-CC-owned file (in the prior
77
+ manifest) is RETAINED in the new manifest at its ON-DISK hash (keeps
78
+ cc-drift-check/reset green and the cleanup loop from deleting it, while
79
+ cc-upstream-guard keeps it edit-blocked), recorded in `results.frozen[]`;
80
+ a project-owned file FALLS THROUGH to skip-and-omit (retaining it would
81
+ adopt + clobber it on unfreeze). A held-back NEW file in a frozen module
82
+ is reported but gets no manifest entry (no on-disk content to hash).
83
+ Single source of truth for the rule across both copy paths (the
84
+ directory walk and cli.js's single-file branch). 23 tests in `test/freeze/`.
85
+ - `lib/metadata.js` — `.ccrc.json` read/write/merge/create. `create()`
86
+ accepts + persists `dbSchemaVersion` (top-level field, set only when a
87
+ real version is confirmed — undefined rides the prior value through via
88
+ `...existing`); `lib/cli.js` threads `setupDb`'s returned `schemaVersion`
89
+ into it. Also exposes `readFrozenModules`/`setFrozenModules`
90
+ (act:c1013967): the `.ccrc.json` `frozenModules` accessors for the
91
+ freeze-module mechanism (a non-array reads as empty — shape-drift
92
+ defensive; `create()` preserves the field via `...existing`).
93
+ `normalize()` guards shape drift (non-object top level reads as
94
+ 'no metadata').
95
+ - `lib/settings-merge.js` — merges CC hooks into `.claude/settings.json`.
96
+ CC-owned hook commands ship with a `$CLAUDE_PROJECT_DIR/` prefix so they
97
+ resolve from any cwd (a bare-relative `.claude/hooks/X.sh` breaks when a
98
+ hook fires from a non-root directory; commit 81693f8). A reinstall
99
+ migration REPLACES (not duplicates) any superseded bare-relative form
100
+ with the prefixed one — `bareForm()` derives the legacy spelling,
101
+ `dropHookCommands()` removes it, then the prefixed form is added;
102
+ exact-match on CC-owned command strings only, so consumer-custom hooks
103
+ are never touched. `mergeSettings` ALSO migrates the stale pib action
104
+ gate matchers to their `mcp__pib-db__*` MCP tool-name form (act:ff693d4c —
105
+ the old bare matchers never matched the real MCP tool names, so the
106
+ gates were dead since shipping); the fired-at-least-once telemetry record
107
+ in `.claude/state/hooks-fired.jsonl` is written by the gate SCRIPTS
108
+ themselves (`action-quality-gate.sh`, `action-completion-gate.sh`), NOT by
109
+ settings-merge. Also heals `~/.claude/settings.json` by
110
+ stripping CC hook entries with project-relative paths (runs
111
+ unconditionally on every install). Exports `mergeBashCompressHooks()`
112
+ for the opt-in bash-compress module; `mergeSkillOverrides()` — the
113
+ installer sets the 34 cabinet-* skills to `skillOverrides: name-only`
114
+ so their long descriptions don't overflow the skill-listing budget
115
+ (act:bee0fa16); and `mergeCcDevHooks()` + `CC_DEV_HOOKS` — the
116
+ repo-local `node --check` PostToolUse dev hook
117
+ (`$CLAUDE_PROJECT_DIR/scripts/node-check-hook.sh`), gated on
118
+ package.json name === `create-claude-cabinet` so it installs only in
119
+ the source repo, never in consumers (act:ff693d4c). 10 tests in
120
+ `test/settings-merge/settings-merge.test.js`.
121
+ - `lib/reset.js` — manifest-safe uninstall/removal. Exports `reset()`:
122
+ removes CC-managed files per the `.ccrc.json` manifest and strips
123
+ CC-managed hook entries from `.claude/settings.json` (matched against
124
+ `CC_HOOK_PATTERNS` / `DEFAULT_HOOKS`), never touching project-owned files.
125
+
126
+ ## Work-tracking / DB
127
+
128
+ - `lib/db-setup.js` — pib-db init step (runs after the copy loop). Exports
129
+ the pure helpers `isAbiMismatch`, `readBundledSchemaVersion`,
130
+ `shouldSkipInit` plus `setupDb(projectDir, opts)` (injectable
131
+ `opts.exec`/`opts.log` for tests). `setupDb` returns `{results,
132
+ schemaVersion}` (a bare array before act:f5dab71f). LAZY-INIT: skips DB
133
+ init when the recorded `.ccrc.json` `dbSchemaVersion` already equals the
134
+ bundled `SCHEMA_VERSION` (read as TEXT from `pib-db-lib.mjs`, never
135
+ imported — so a no-migration reinstall never loads the native module).
136
+ SELF-HEALS a better-sqlite3 ABI mismatch (`npm rebuild` + retry once,
137
+ else one actionable line — never a throw or silent skip; act:e7c69b5c).
138
+ `schemaVersion` is null when init couldn't confirm a version, so the
139
+ caller never records a false 'schema current' claim. 10 tests in
140
+ `test/db-setup/db-setup.test.js`.
141
+ - `lib/engagement-setup.js` — extends the pib-db files with the engagement
142
+ schema when the engagement module is installed. Dispatched from cli.js's
143
+ postInstall pipeline. Two duties: (1) a marker-aware FILE OVERLAY —
144
+ copies the engagement-inclusive pib-db files over the base versions,
145
+ deciding by whether the installed file already contains engagement code
146
+ (not just its `SCHEMA_VERSION` number), so an equal-version reinstall
147
+ still upgrades a base→engagement file; (2) a postInstall schema-ensure.
148
+ Exports `setupEngagement()`.
149
+
150
+ ## Project identity
151
+
152
+ - `lib/project-context.js` — a THIN RE-EXPORT of
153
+ `templates/scripts/project-context.cjs` (Wave 1, act:a6377c82). The
154
+ logic lives in the template copy (co-located with the memory scripts,
155
+ which `require` it as a sibling; consumers have no `lib/`); this file
156
+ re-exports it so CC-source-repo callers (`lib/` code and the
157
+ memory/orient SKILL.md best-effort `require('./lib/project-context')`)
158
+ resolve the exact same implementation. Collapsed the byte-identical
159
+ twins that had already drifted once ("one concept, one place").
160
+
161
+ ## Setup engines (per opt-in module)
162
+
163
+ - `lib/verify-setup.js` — cabinet-verify runtime installer (creates
164
+ `~/.claude-cabinet/verify/<version>/dist/cabinet-verify-<version>.tgz`
165
+ via `npm pack`; writes `~/.claude-cabinet/verify/current/VERSION`
166
+ pointer; equal-version source-hash re-pack via `installer-gate.js`).
167
+ - `lib/site-audit-setup.js` — site-audit runtime installer (mirrors
168
+ verify-setup; packs `templates/site-audit-runtime/` to
169
+ `~/.claude-cabinet/site-audit/<version>/`; equal-version source-hash
170
+ re-pack via `installer-gate.js`).
171
+ - `lib/engagement-server-setup.js` — engagement-server runtime installer
172
+ (copies server files to `~/.claude-cabinet/engagement-server/`;
173
+ follows mux-setup.js pattern with global manifest SHA256 tracking,
174
+ incl. the equal-version hash-compare fall-through of act:df1a1dc3 —
175
+ equal versions copy only changed files, `'unchanged'` when none do).
176
+ - `lib/mux-setup.js` — mux runtime installer (copies bin/mux, config
177
+ scripts, and popup to user-level paths; creates data dirs;
178
+ `setupDarwinIntegration()` appends source-file to `~/.tmux.conf`,
179
+ reloads live tmux, and writes/bootstraps the
180
+ `com.mux.screenshot-to-clipboard` launchd plist; migrates legacy
181
+ `com.orenmagid.*` agent). Version gate (act:df1a1dc3): equal
182
+ CC-vs-installed version does NOT early-return — it falls through to
183
+ the SHA256 manifest hash-compare and copies only changed files
184
+ (new `'unchanged'` status when nothing differs), so a
185
+ dogfood-from-source template edit without a version bump still
186
+ propagates on reinstall.
187
+ - `lib/watchtower-setup.js` — global watchtower runtime refresher
188
+ (`refreshWatchtowerRuntime`, act:2da80102). REFRESH-ONLY: content-hash
189
+ refreshes the EXISTING `~/.claude-cabinet/watchtower/` runtime
190
+ (scripts/ = all globbed `watchtower-*.mjs` + the shell runners,
191
+ hooks/ = the session hooks, cabinet/ = the two docs) on every
192
+ reinstall by comparing each template against the runtime file's ACTUAL
193
+ on-disk bytes — act:4e05ff53 SEVERED the old manifest-driven skip, so
194
+ the shared `global-manifest.json` SHA256 record is now bookkeeping only,
195
+ not the skip signal; a stale or hand-edited runtime file therefore
196
+ reconverges on the next reinstall (self-heal). Dests keyed by absolute
197
+ path so no collision with mux's entries. No-ops with status `'absent'`
198
+ and zero writes when no runtime exists yet — fresh setup (launchd/cron,
199
+ config.json, migrate-keys, coherence assertion) stays the
200
+ `/watchtower install` SKILL.md step's job. Wired in lib/cli.js after the
201
+ postInstall loop, gated on `selectedModules.includes('watchtower')`. 5
202
+ hermetic tests in `test/watchtower-runtime-refresh/`.
203
+
204
+ ## Memory migration (one-time, off omega)
205
+
206
+ - `lib/migrate-from-omega.js` — one-time omega → built-in memory migration
207
+ engine (`--migrate-memory`): exports omega memories to Claude Code's
208
+ built-in memory layout (fresh-write or additive `omega-migrated/` merge
209
+ when native memory already exists), backs up first, then tears down
210
+ omega hooks/MCP. Never overwrites native files.
211
+ - `lib/migrate-memory-cmd.js` — CLI command wrapper for the migration
212
+ (`--migrate-memory`, `--dry-run`, `--unmigrate-memory` rollback).
213
+ - `lib/migration-snapshot.js` — captures pre-migration omega state to a
214
+ JSON snapshot so `--migrate-memory` can do DETERMINISTIC removal of
215
+ hooks / MCP entries / the OMEGA block (match against captured contents,
216
+ not pattern-guess against live state). Searches all three MCP config
217
+ locations and matches omega by command path (contains `omega-venv`)
218
+ rather than key name.