@cairnkeep/cli 2.8.0 → 2.11.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 (89) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/README.md +82 -27
  3. package/bin/cairn +6 -153
  4. package/bin/cairn-container +8 -0
  5. package/docs/building-an-overlay.md +41 -4
  6. package/docs/containers.md +10 -0
  7. package/docs/context-packs.md +94 -0
  8. package/docs/harness-compatibility.md +37 -3
  9. package/docs/learning/CURRICULUM-MAP.md +16 -5
  10. package/docs/learning/FEATURE-GUIDE.md +15 -4
  11. package/docs/learning/README.md +8 -2
  12. package/docs/learning/lessons/L00-why-cairnkeep.md +1 -1
  13. package/docs/learning/lessons/L01-safe-trial.md +3 -3
  14. package/docs/learning/lessons/L02-installation.md +11 -2
  15. package/docs/learning/lessons/L03-first-project.md +1 -1
  16. package/docs/learning/lessons/L19-validated-skill-improvement.md +52 -21
  17. package/docs/learning/lessons/L20-mcp-tool-profiles.md +67 -0
  18. package/docs/learning/lessons/L21-context-packs.md +79 -0
  19. package/docs/learning/lessons/L22-native-windows.md +83 -0
  20. package/docs/learning/lessons/L23-guided-setup.md +138 -0
  21. package/docs/learning/tracks/operator.md +10 -3
  22. package/docs/learning/tracks/quickstart.md +7 -3
  23. package/docs/mcp-tool-profiles.md +43 -0
  24. package/docs/native-windows.md +122 -0
  25. package/docs/operating.md +157 -18
  26. package/docs/privacy-and-data-flow.md +51 -1
  27. package/docs/storage.md +29 -0
  28. package/examples/eval/bundled-fake.json +1 -1
  29. package/mcp-memory-server/dist/artifact-store-windows-worker.js +74 -0
  30. package/mcp-memory-server/dist/artifact-store.js +196 -55
  31. package/mcp-memory-server/dist/capability-cli.js +2 -1
  32. package/mcp-memory-server/dist/capability-config.js +4 -3
  33. package/mcp-memory-server/dist/capability-harness.js +34 -7
  34. package/mcp-memory-server/dist/context-pack-cli.js +185 -0
  35. package/mcp-memory-server/dist/context-pack.js +889 -0
  36. package/mcp-memory-server/dist/eval-cli.js +6 -5
  37. package/mcp-memory-server/dist/eval-plan.js +35 -13
  38. package/mcp-memory-server/dist/eval-process.js +11 -4
  39. package/mcp-memory-server/dist/eval-report.js +8 -5
  40. package/mcp-memory-server/dist/eval-runner.js +2 -0
  41. package/mcp-memory-server/dist/eval-schema.js +1 -0
  42. package/mcp-memory-server/dist/graph-cli.js +7 -1
  43. package/mcp-memory-server/dist/index.js +87 -37
  44. package/mcp-memory-server/dist/mcp-tool-catalog.js +47 -0
  45. package/mcp-memory-server/dist/mcp-tool-cli.js +85 -0
  46. package/mcp-memory-server/dist/mcp-tool-profile.js +164 -0
  47. package/mcp-memory-server/dist/note-store.js +12 -3
  48. package/mcp-memory-server/dist/pi-mcp-bridge.js +185 -0
  49. package/mcp-memory-server/dist/platform-security.js +102 -0
  50. package/mcp-memory-server/dist/skill-store.js +27 -12
  51. package/mcp-memory-server/package.json +4 -1
  52. package/package.json +5 -4
  53. package/pi/extensions/cairnkeep-memory.ts +61 -0
  54. package/schemas/cairnkeep-setup-policy.schema.json +55 -0
  55. package/schemas/cairnkeep-setup.schema.json +36 -0
  56. package/schemas/context-pack.schema.json +33 -0
  57. package/schemas/eval-report.schema.json +1 -0
  58. package/scripts/cairn-cli.mjs +119 -0
  59. package/scripts/cairn-container-cli.mjs +121 -0
  60. package/scripts/cairn-hook.mjs +199 -0
  61. package/scripts/completion.sh +33 -5
  62. package/scripts/doctor.sh +96 -0
  63. package/scripts/fix-permissions.mjs +12 -0
  64. package/scripts/memory-wiki-audit.mjs +95 -0
  65. package/scripts/phase26-test-manifest.mjs +26 -0
  66. package/scripts/run-repository-tests.mjs +76 -0
  67. package/scripts/setup-core.mjs +310 -0
  68. package/scripts/setup-reconcile.mjs +331 -0
  69. package/scripts/setup.mjs +306 -0
  70. package/scripts/sync-pi-assets.sh +19 -4
  71. package/scripts/test-cli-dispatch.sh +6 -0
  72. package/scripts/test-completion.sh +44 -0
  73. package/scripts/test-doctor.sh +66 -0
  74. package/scripts/test-learning-docs.sh +53 -3
  75. package/scripts/test-package-install.sh +81 -0
  76. package/scripts/test-phase17-artifact-lifecycle.sh +1 -1
  77. package/scripts/test-phase18-capability-lifecycle.sh +1 -1
  78. package/scripts/test-pi-lifecycle.mjs +190 -0
  79. package/scripts/test-setup-compatibility.mjs +186 -0
  80. package/scripts/test-setup-output.sh +131 -0
  81. package/scripts/test-setup-overlay.sh +113 -0
  82. package/scripts/test-setup-preflight.mjs +281 -0
  83. package/scripts/test-setup-reconcile.mjs +257 -0
  84. package/scripts/test-uninstall.sh +71 -0
  85. package/scripts/test-windows-native.mjs +136 -0
  86. package/scripts/uninstall.sh +95 -7
  87. package/scripts/verify-pi-mcp-bridge.mjs +588 -0
  88. package/scripts/windows-platform.mjs +725 -0
  89. package/templates/env.example.template +11 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,71 @@ All notable user-facing changes are documented here. This project follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.11.0] - 2026-08-12
9
+
10
+ ### Added
11
+
12
+ - Replace the Bash npm entry point with a cross-platform Node CLI while keeping
13
+ the established Unix scripts as compatibility implementations.
14
+ - Add native Windows x64 bootstrap and `.cmd`/PowerShell launchers, Claude/Pi/
15
+ Kimi asset synchronization, Node hook transports, diagnostics, PowerShell
16
+ completion, Task Scheduler registration, memory import/export plumbing, and
17
+ backup-first uninstall with a `revert.ps1` manifest.
18
+ - Enforce private Windows ACLs for least-authority MCP profiles and context-pack
19
+ state, make pack objects read-only, retry Windows atomic replacements, and
20
+ terminate evaluation adapter descendant trees through `taskkill.exe /T`.
21
+ - Add a PowerShell-only Windows CI matrix for Node 22/24/26, including native
22
+ lifecycle tests and a packed global npm installation under paths containing
23
+ spaces and Unicode.
24
+
25
+ ### Changed
26
+
27
+ - Add PowerShell to shell completion and document Windows x64 as a supported
28
+ native platform. Windows ARM64 remains an x64-emulation target until the
29
+ storage dependency ships a native ARM64 binding.
30
+
31
+ ### Added
32
+
33
+ - Add `cairn setup` as the recommended guided project entry point, with a fully
34
+ deterministic non-interactive form, explicit Git/harness/memory choices,
35
+ versioned private project state, selected-asset reconciliation, structured
36
+ output, doctor diagnostics, and recovery commands.
37
+ - Add a strict provider-neutral setup-policy schema for private overlays, with
38
+ command-line choices taking precedence over policy defaults and constraints
39
+ enforced on every resolved plan.
40
+ - Add the maintained Pi local stdio memory extension, dynamic MCP catalog
41
+ discovery, bounded child lifecycle, cancellation, exact response preservation,
42
+ and trusted annotation metadata. Pi 0.84.1 is the validated minimum.
43
+
44
+ ### Changed
45
+
46
+ - Make project setup report machine sync without running it automatically;
47
+ `cairn sync-pi --apply|--check`, `cairn doctor`, and backup-first uninstall
48
+ remain explicit lifecycle operations.
49
+ - Preserve `cairn bootstrap` and `--untracked` as backward-compatible scripted
50
+ primitives while recommending guided setup for new onboarding.
51
+
52
+ ## [2.9.0] - 2026-08-06
53
+
54
+ ### Added
55
+
56
+ - Publish complete, centralized MCP tool annotations and add project-scoped
57
+ `full`, derived `read-only`, and exact custom tool profiles with strict
58
+ environment precedence and canonical provenance digests.
59
+ - Add immutable context-pack manifests, local and commit-pinned Git installs,
60
+ atomic project enablement and confirmed updates, retained object storage,
61
+ integrity diagnostics, and explicit uninstall purge consent.
62
+ - Add read-only context-pack list/search/read tools behind separate local and
63
+ authenticated-HTTP consent gates. Documents include full provenance; skills
64
+ remain invisible until their exact project/pack/path/file digest is approved.
65
+ - Add deterministic Markdown chunking, optional embedding-ranked retrieval with
66
+ offline substring fallback, shell completion, lifecycle tests, operator docs,
67
+ and learning-path exercises.
68
+
69
+ Context packs add no runtime dependency, telemetry, background synchronization,
70
+ publisher-authenticity claim, ACL system, automatic skill activation, or
71
+ provider-specific runtime integration.
72
+
8
73
  ## [2.8.0] - 2026-08-03
9
74
 
10
75
  ### Added
@@ -252,7 +317,9 @@ stored memories.
252
317
  - Preserve executable permissions and Bash 3.2 portability on macOS.
253
318
  - Add backup-first uninstall and SQLite-safe memory export/import guidance.
254
319
 
255
- [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.8.0...HEAD
320
+ [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.11.0...HEAD
321
+ [2.11.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.9.0...v2.11.0
322
+ [2.9.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.8.0...v2.9.0
256
323
  [2.8.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.7.0...v2.8.0
257
324
  [2.7.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.6.0...v2.7.0
258
325
  [2.6.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.5.0...v2.6.0
package/README.md CHANGED
@@ -14,19 +14,22 @@ Qwen Code, Pi, and other MCP clients).
14
14
 
15
15
  ## Status
16
16
 
17
- Shipped: the memory server, the `cairn` CLI (`bootstrap`, `memory-server`, `sync`, `sync-pi`, `sync-kimi`,
18
- `doctor`, `trajectory`, `artifact`, `notes`, `memory`, `eval`, `audit-timer`, `completion`, `uninstall`) installable via
17
+ Shipped: the memory server, the `cairn` CLI (`setup`, `bootstrap`, `memory-server`, `sync`, `sync-pi`, `sync-kimi`,
18
+ `doctor`, `trajectory`, `artifact`, `mcp-tools`, `pack`, `notes`, `memory`, `eval`, `audit-timer`, `completion`, `uninstall`) installable via
19
19
  `npm i -g @cairnkeep/cli`, and the
20
20
  operating layer (commands,
21
- agents, hooks) installed on Claude Code and OpenCode, plus a native Pi
21
+ agents, hooks) installed on Claude Code and OpenCode, plus the native Pi
22
22
  trajectory extension and thin Pi/Kimi graph adapters. The generic launchers
23
- expose wrapper seams (`.ai/pre-launch.sh`, `CAIRN_EXTRA_SETTINGS`,
24
- `.ai/post-exit.sh`) so an enterprise wrapper can add provider/credential setup
23
+ expose wrapper seams (`.ai/pre-launch.sh`/`.ai/pre-launch.ps1`,
24
+ `CAIRN_EXTRA_SETTINGS`, `.ai/post-exit.sh`/`.ai/post-exit.ps1`) so an enterprise wrapper can add provider/credential setup
25
25
  without forking them. Also shipped: context exploration (`/context-explore`) and
26
26
  a thin routing seam (`route_check`), both of which delegate to
27
27
  [token-miser](https://github.com/cairnkeep/token-miser), a public
28
28
  cairnkeep-org sibling project.
29
29
 
30
+ Version 2.11 adds guided `cairn setup`, the maintained Pi local stdio memory
31
+ extension, and the native Windows operating layer.
32
+
30
33
  ## Compatibility
31
34
 
32
35
  Node.js 22, 24, and 26 are supported. Cairnkeep 2.x requires Node.js 22 or
@@ -39,18 +42,22 @@ and 20 are end-of-life upstream.
39
42
  | OpenCode on Linux/macOS | Memory server plus commands, plugins, hooks, and launchers |
40
43
  | Kimi Code on Linux/macOS | Memory MCP server, project launcher, and opt-in `/graphify` Skill |
41
44
  | Qwen Code on Linux/macOS | Memory MCP server plus project launcher; no Cairnkeep operating-layer assets yet |
42
- | Pi on Linux/macOS | Native opt-in trajectory extension, launcher, and `/graphify` prompt; no bundled MCP bridge |
45
+ | Pi on Linux/macOS | Memory MCP through a maintained local stdio extension; native opt-in trajectory extension, launcher, and `/graphify` prompt; Pi 0.84.1 minimum for the bridge |
43
46
  | Codex CLI | Memory MCP server; no Cairnkeep operating-layer assets |
44
- | Other MCP clients | Memory and optional domain-knowledge MCP tools |
45
- | Native Windows | Not supported by the Bash-based installer; use WSL (not yet CI-verified) |
47
+ | Other MCP clients | Memory plus optional domain-knowledge and context-pack MCP tools |
48
+ | Native Windows x64 | Node-native CLI, guided setup, memory server, bootstrap compatibility, PowerShell/Command Prompt launchers, sync, hooks, doctor, storage lifecycle, Task Scheduler, completion, and uninstall |
49
+ | Windows ARM64 | Supported through Windows x64 emulation only; a native database binding is not currently shipped |
50
+ | WSL | Uses the normal Linux workflow; distinct from native Windows and Git Bash |
46
51
 
47
52
  The `cairn graph` CLI is harness-independent and can be run from a project
48
53
  shell used by Kimi Code, Pi, Qwen Code, Codex, or another client. Claude Code,
49
54
  OpenCode, Pi, and Kimi can receive thin `/graphify` adapters; those adapters do
50
55
  not imply equivalent hooks, agents, or MCP support.
51
56
 
52
- Linux, macOS, Bash 3.2 portability, and clean Node 22/24/26 runtime checks
53
- are exercised in CI.
57
+ Linux, macOS, Bash 3.2 portability, native PowerShell on Windows x64, global npm
58
+ installation, and clean Node 22/24/26 runtime checks are exercised in CI. See
59
+ [Native Windows operation](docs/native-windows.md) for platform-specific setup,
60
+ ACL, scheduling, process-tree, and recovery details.
54
61
 
55
62
  See [Harness compatibility](docs/harness-compatibility.md) for exact support
56
63
  levels, Kimi and Qwen configuration, and candidates that are not yet runtime-tested.
@@ -78,10 +85,14 @@ storage paths, secrets, and private derived images, see
78
85
  - **`mcp-memory-server/`** — an MCP server exposing durable, scoped memory
79
86
  (`memory_write`, `memory_search`, …) backed by AgentFS, with optional
80
87
  embedding-ranked search against any OpenAI-compatible endpoint.
81
- - **`bin/cairn`** — the CLI. `cairn bootstrap [path]` scaffolds a project's
82
- `.ai/` launchers + env; `cairn doctor` health-checks the configured pieces;
88
+ - **`bin/cairn`** — the CLI. `cairn setup [path]` guides or deterministically
89
+ reconciles selected project assets; `cairn bootstrap [path]` preserves the
90
+ established scripted scaffold contract; `cairn doctor` health-checks the configured pieces;
83
91
  `cairn trajectory list|show|prune` manages opt-in local session trajectories;
84
92
  `cairn artifact list|show|delete|prune` manages opt-in local artifacts;
93
+ `cairn mcp-tools list|status|set|reset` applies least-authority discovery
94
+ profiles; `cairn pack` validates, installs, pins, updates, and approves
95
+ immutable external context;
85
96
  `cairn eval validate|run|ablate|report|prune|delete` coordinates explicit
86
97
  local two-pass and one-capability-at-a-time measurements;
87
98
  `cairn skill harvest|list|show|review|propose|evaluate|apply|rollback`
@@ -96,7 +107,7 @@ storage paths, secrets, and private derived images, see
96
107
  (`export` requires the optional `sqlite3` CLI);
97
108
  `cairn audit-timer` installs the scheduled memory+wiki audit;
98
109
  `cairn completion bash|zsh|fish` generates shell completion definitions; and
99
- `cairn sync-pi` installs the native Pi trajectory extension and graph prompt;
110
+ `cairn sync-pi` installs the native Pi memory and trajectory extensions plus graph prompt;
100
111
  `cairn sync-kimi` installs the Kimi graph Skill;
101
112
  `cairn uninstall` reverses the install (backup-first, revertible).
102
113
  - **`templates/`** — project scaffolding (generic launchers, env) plus the
@@ -125,9 +136,11 @@ them. These are the accelerators the author pairs cairnkeep with; each is opt-in
125
136
  ## Setup
126
137
 
127
138
  A working workflow needs three things: the memory server registered, the
128
- operating layer (commands, agents, hooks) installed into your harness, and a
129
- bootstrapped project. `cairn bootstrap` does only the last of these — the full
130
- ordered walkthrough is in **[docs/operating.md](docs/operating.md)**.
139
+ operating layer installed into your harness, and a configured project. `cairn
140
+ setup` is the recommended guided entry point; `cairn bootstrap` remains the
141
+ deterministic compatibility primitive for established scripts. Project setup
142
+ reports but never performs machine-level sync. The full ordered walkthrough is
143
+ in **[docs/operating.md](docs/operating.md)**.
131
144
 
132
145
  This setup is local by default: the registered stdio server stores memory on
133
146
  the user's computer. Cairnkeep never discovers or selects a remote host.
@@ -144,8 +157,8 @@ claude mcp add cairn-memory -s user -- cairn memory-server
144
157
  # 2. Install the operating layer (commands, agents, hooks, scaffold templates)
145
158
  cairn sync --apply # add --live-root <proj>/.claude to scope it
146
159
 
147
- # 3. Scaffold a project and configure it
148
- cairn bootstrap /path/to/project
160
+ # 3. Configure a project deterministically
161
+ cairn setup /path/to/project --git init --harness claude --memory local --yes
149
162
  cp /path/to/project/.ai/env.example /path/to/project/.ai/.env # then edit
150
163
 
151
164
  # 4. Launch (and, optionally, check the wiring first)
@@ -182,18 +195,36 @@ headers. Review and approve project MCP configuration with
182
195
  `qwen mcp approve cairn-memory`, then launch with `./.ai/start-qwen.sh`. See
183
196
  [Harness compatibility](docs/harness-compatibility.md#qwen-code).
184
197
 
185
- For Pi, install the local trajectory adapter and use the scaffolded launcher:
198
+ For Pi, select Pi during project setup, explicitly install/check its machine
199
+ assets, run doctor, and use the generated launcher:
186
200
 
187
201
  ```bash
188
202
  cairn sync-pi --apply
189
- cairn bootstrap /path/to/project
190
- cd /path/to/project && ./.ai/start-pi.sh
203
+ cairn sync-pi --check
204
+ cairn setup /path/to/project --git init --harness pi --memory local --yes
205
+ cd /path/to/project && cairn doctor && ./.ai/start-pi.sh
191
206
  ```
192
207
 
193
- This installs trajectory capture plus the thin `/graphify` prompt. The prompt
194
- delegates exclusively to `cairn graph`. Cairnkeep does not bundle or select a
195
- Pi MCP bridge; configure a user-chosen bridge separately if you also want the
196
- MCP memory tools inside Pi.
208
+ This installs the maintained local stdio memory extension, trajectory capture,
209
+ and the thin `/graphify` prompt. The memory extension discovers the effective
210
+ server tool catalog and preserves annotations in trusted result details; Pi's
211
+ public API has no native annotations field. It adds tools only—no prompt runs,
212
+ skill activation, autonomous loop, or remote access. Pi 0.84.1 is the minimum
213
+ validated version; v2.11 also passed the registry-current Pi release and the
214
+ documented Node, Bash, and native Windows matrix.
215
+
216
+ Preview removal before confirming it. Uninstall backs up every managed file it
217
+ will change and prints the generated revert command; durable memory and context
218
+ packs remain unless their explicit purge flags are supplied:
219
+
220
+ ```bash
221
+ cairn uninstall --dry-run /path/to/project
222
+ cairn uninstall --yes /path/to/project
223
+ ```
224
+
225
+ If setup-owned project assets drift, rerun the exact `cairn setup ... --yes`
226
+ recovery command reported by `cairn doctor`. For Pi machine-asset drift, run
227
+ `cairn sync-pi --apply`, then `cairn sync-pi --check` and `cairn doctor`.
197
228
 
198
229
  Closed trajectories can be compiled into local hindsight notes without a model
199
230
  or embedding service. Capture and distillation are separate opt-ins:
@@ -262,6 +293,11 @@ search):
262
293
  | `CAIRN_MEMORY_EMBEDDING_MODEL` | Embedding model name (required for semantic search) |
263
294
  | `CAIRN_MEMORY_EMBEDDING_TIMEOUT_MS` | Embedding request timeout before substring fallback (default `15000`) |
264
295
  | `CAIRN_AGENTFS_BASE_DIR` | Base dir for global memory scopes (default `~/.cairnkeep`) |
296
+ | `CAIRN_MCP_TOOL_PROFILE` | Process override for MCP exposure: `full`, `read-only`, or `custom` |
297
+ | `CAIRN_MCP_ALLOWED_TOOLS` | Comma-separated exact allowlist required by a custom process profile |
298
+ | `CAIRN_CONTEXT_PACKS` | Opt in to local context-pack list/search/read tools (default off) |
299
+ | `CAIRN_CONTEXT_PACK_HTTP` | Separately consent to context-pack tools over authenticated HTTP (default off) |
300
+ | `CAIRN_PACK_BASE_DIR` | Immutable pack objects, source records, pointers, and retrieval cache (default `~/.cairnkeep/packs`) |
265
301
  | `CAIRN_TRAJECTORY_CAPTURE` | Opt in to local structured session capture (`1`, `true`, `yes`, or `on`; default off) |
266
302
  | `CAIRN_TRAJECTORY_SESSION_MAX_BYTES` | Maximum serialized bytes per captured session (default `5242880`, 5 MiB) |
267
303
  | `CAIRN_TRAJECTORY_STORE_MAX_BYTES` | Maximum logical bytes across local trajectories (default `268435456`, 256 MiB) |
@@ -295,6 +331,7 @@ search):
295
331
  | `CAIRN_EVAL` | Opt in to the local evaluation coordinator (default off; does not select a harness, model, endpoint, credential, or network) |
296
332
  | `CAIRN_GIT_PROVIDER` | Git host for collaboration commands: `github`\|`gitlab`\|`codeberg`\|`forgejo`\|`none` ([docs/git-providers.md](docs/git-providers.md)) |
297
333
  | `CAIRN_ROUTE_ENDPOINT` | Base URL of an already-running token-miser routing/tiering proxy (unset → `route_check` is inert) |
334
+ | `CAIRN_GRAPHIFY_BINARY` | Optional Graphify command/path override (default `graphify` from `PATH`; JavaScript helpers run through Node) |
298
335
  | `CAIRN_EXPLORE_BINARY` | Absolute path to the `token_miser` binary used by `context_explore` (unset → the tool throws) |
299
336
  | `CAIRN_EXPLORE_REPO_ROOT` | Default repo root for `context_explore` when no per-call `repo_root` is given |
300
337
  | `CAIRN_EXTRA_SETTINGS` | Optional settings/config file the launcher layers onto the harness (wrapper seam) |
@@ -308,6 +345,22 @@ remote memory, and delegated exploration can send content to endpoints you
308
345
  configure. Review [Privacy and data flow](docs/privacy-and-data-flow.md) before
309
346
  enabling them.
310
347
 
348
+ ### MCP authority and context packs
349
+
350
+ Every tool publishes a stable title and all four MCP annotation hints. Use
351
+ `cairn mcp-tools set read-only` for observation-only clients, or an exact custom
352
+ allowlist when a workflow needs fewer tools. Process settings override the
353
+ strict project file; the default remains `full`. Profiles only remove tools and
354
+ cannot bypass capability or feature gates. See
355
+ [MCP tool profiles](docs/mcp-tool-profiles.md).
356
+
357
+ Context packs are immutable, digest-addressed local document/skill bundles.
358
+ They are installed and project-pinned manually; no background Git sync occurs.
359
+ With `CAIRN_CONTEXT_PACKS=1`, enabled documents are searchable through three
360
+ read-only MCP tools. Skills remain invisible until their exact file digest is
361
+ approved, and are never copied or executed. See
362
+ [Immutable context packs](docs/context-packs.md).
363
+
311
364
  ### Managed capability contract (opt-in)
312
365
 
313
366
  `CAIRN_CAPABILITY_CONTRACT=1` enables one versioned, typed boundary around the
@@ -388,8 +441,8 @@ is neither a Cairnkeep result nor an acceptance target.
388
441
  Reports and note snapshots stay under
389
442
  `.agentfs/eval/experiments/<experiment-id>/`; default uninstall retains them,
390
443
  while explicit purge is backup-first and revertible. Cancellation retains an
391
- inspectable partial report. POSIX process-group cleanup is tested; Windows
392
- descendant-process-tree termination is not guaranteed. See the
444
+ inspectable partial report. POSIX process-group cleanup and Windows descendant-
445
+ tree cleanup through `taskkill.exe /T` are tested by their platform contracts. See the
393
446
  [operating guide](docs/operating.md#evaluation-harness-opt-in),
394
447
  [storage contract](docs/storage.md#evaluation-report-and-note-snapshot-storage),
395
448
  and [privacy flow](docs/privacy-and-data-flow.md#evaluation-adapter-and-report-flow).
@@ -482,6 +535,8 @@ exposes trajectory data. See the [operating guide](docs/operating.md#compaction-
482
535
  - **Memory storage and deployment** — [docs/storage.md](docs/storage.md)
483
536
  - **Podman and OCI containers** — [docs/containers.md](docs/containers.md)
484
537
  - **Privacy and data flow** — [docs/privacy-and-data-flow.md](docs/privacy-and-data-flow.md)
538
+ - **MCP tool profiles** — [docs/mcp-tool-profiles.md](docs/mcp-tool-profiles.md)
539
+ - **Immutable context packs** — [docs/context-packs.md](docs/context-packs.md)
485
540
  - **Validated skill improvement** — [docs/skill-improvement.md](docs/skill-improvement.md)
486
541
  - **Git providers** — [docs/git-providers.md](docs/git-providers.md)
487
542
  - **Support** — [SUPPORT.md](SUPPORT.md)
package/bin/cairn CHANGED
@@ -1,155 +1,8 @@
1
- #!/usr/bin/env bash
2
- # cairn — Cairnkeep CLI. Thin dispatcher over the core scripts.
3
- set -euo pipefail
1
+ #!/usr/bin/env node
4
2
 
5
- # Resolve through symlinks so this works when installed as an npm global bin
6
- # (which symlinks <prefix>/bin/cairn -> the packaged bin/cairn).
7
- SOURCE="${BASH_SOURCE[0]}"
8
- while [ -L "$SOURCE" ]; do
9
- DIR=$(cd -P "$(dirname "$SOURCE")" && pwd)
10
- SOURCE=$(readlink "$SOURCE")
11
- [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE"
12
- done
13
- CAIRN_ROOT=$(cd -P "$(dirname "$SOURCE")/.." && pwd)
3
+ import { main } from "../scripts/cairn-cli.mjs";
14
4
 
15
- cmd="${1:-help}"
16
- [[ $# -gt 0 ]] && shift
17
-
18
- usage() {
19
- cat <<'USAGE'
20
- cairn — Cairnkeep CLI
21
-
22
- Usage:
23
- cairn bootstrap [--untracked] [path]
24
- Scaffold launchers, planning files, and the private
25
- project-memory ignore guard (default path: .).
26
- --untracked keeps the scaffold out of git via the repo's
27
- .git/info/exclude (contributor mode: nothing to commit,
28
- invisible to other contributors, local-only).
29
- cairn memory-server Run the memory MCP server (stdio). Register it with your
30
- harness, e.g. claude mcp add cairn-memory -s user -- cairn memory-server.
31
- cairn sync [--apply] [--live-root DIR]
32
- Install/update the Claude Code operating layer (commands,
33
- agents, hooks) into ~/.claude, or into DIR for a single
34
- project (--live-root <project>/.claude).
35
- cairn sync-pi [--apply] [--live-root DIR]
36
- Install/update the Pi trajectory extension and thin
37
- /graphify prompt into ~/.pi/agent or isolated DIR.
38
- cairn sync-kimi [--apply] [--live-root DIR]
39
- Install/update the thin Kimi /graphify Skill into
40
- $KIMI_CODE_HOME, ~/.kimi-code, or isolated DIR.
41
- cairn doctor Health-check the memory server and configured LLM /
42
- embedding endpoints, git provider, and stores.
43
- Use --repair for derived trajectory/typed metadata,
44
- indexes, and interrupted note transactions.
45
- cairn trajectory <list|show|prune>
46
- Inspect and prune opt-in local session trajectories.
47
- cairn artifact <list|show|delete|prune>
48
- Inspect and delete opt-in local artifacts. List/show
49
- support --json; delete supports --dry-run; prune
50
- supports --dry-run and --include-protected.
51
- cairn capabilities <list|status|enable|disable|reset|logging>
52
- Inspect and manage project capability state. MCP changes
53
- require a memory-server restart; operating changes apply
54
- on the next invocation.
55
- cairn notes <distill|search-error|promote|doctor>
56
- Compile closed trajectories into local hindsight notes,
57
- search exact failure signatures, promote corroborated
58
- notes, or validate the note store.
59
- cairn eval <validate|run|ablate|report|prune|delete>
60
- Validate or run default-off local evaluations, inspect
61
- reports, and manage retained experiment results.
62
- cairn skill <harvest|list|show|review|propose|evaluate|apply|rollback>
63
- Turn recurring hindsight evidence into reviewed,
64
- evaluated, reversible skill-file improvements.
65
- cairn graph <build|query|status|diff|explain|path>
66
- Build the local code graph, inspect freshness and
67
- changes, or query exact symbols and paths.
68
- cairn memory <path|export|import>
69
- Relocate global-scope memory. `path` prints its location;
70
- `export <file.tgz>` takes a WAL-safe snapshot (requires
71
- sqlite3); `import <file.tgz>` restores it.
72
- cairn audit-timer [--on-calendar SPEC] [--para-root PATH] [--render-only DIR]
73
- Install (opt-in) a systemd user timer that runs the
74
- memory+wiki audit on a schedule; prints a cron alternative.
75
- cairn uninstall [--dry-run] [--yes] [--purge-memory] [--live-root DIR]
76
- [--pi-live-root DIR] [--kimi-live-root DIR] [PROJECT ...]
77
- Reverse what cairnkeep installed/modified (operating
78
- layer, hook registrations, MCP registration, audit
79
- timer, and any given projects' bootstrap scaffold).
80
- Backs everything up first with a revert.sh; keeps the
81
- durable memory store unless --purge-memory is given.
82
- cairn completion bash|zsh|fish
83
- Generate completion definitions for a major shell.
84
- cairn version Print version
85
- cairn help Show this help
86
- USAGE
87
- }
88
-
89
- case "$cmd" in
90
- bootstrap)
91
- exec "$CAIRN_ROOT/scripts/bootstrap.sh" "$@"
92
- ;;
93
- doctor)
94
- exec "$CAIRN_ROOT/scripts/doctor.sh" "$@"
95
- ;;
96
- uninstall)
97
- exec "$CAIRN_ROOT/scripts/uninstall.sh" "$@"
98
- ;;
99
- memory)
100
- exec "$CAIRN_ROOT/scripts/memory-store.sh" "$@"
101
- ;;
102
- memory-server)
103
- # Run the memory MCP server (stdio by default). Use with your harness, e.g.
104
- # claude mcp add cairn-memory -s user -- cairn memory-server
105
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/index.js" "$@"
106
- ;;
107
- trajectory)
108
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/trajectory-cli.js" "$@"
109
- ;;
110
- artifact)
111
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/artifact-cli.js" "$@"
112
- ;;
113
- capabilities)
114
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/capability-cli.js" "$@"
115
- ;;
116
- notes)
117
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/note-cli.js" "$@"
118
- ;;
119
- eval)
120
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/eval-cli.js" "$@"
121
- ;;
122
- skill)
123
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/skill-cli.js" "$@"
124
- ;;
125
- graph)
126
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/graph-cli.js" "$@"
127
- ;;
128
- sync)
129
- exec "$CAIRN_ROOT/scripts/sync-claude-assets.sh" "$@"
130
- ;;
131
- sync-pi)
132
- exec "$CAIRN_ROOT/scripts/sync-pi-assets.sh" "$@"
133
- ;;
134
- sync-kimi)
135
- exec "$CAIRN_ROOT/scripts/sync-kimi-assets.sh" "$@"
136
- ;;
137
- audit-timer)
138
- exec "$CAIRN_ROOT/scripts/install-audit-timer.sh" "$@"
139
- ;;
140
- completion)
141
- exec "$CAIRN_ROOT/scripts/completion.sh" "$@"
142
- ;;
143
- version | --version | -v)
144
- v=$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$CAIRN_ROOT/package.json" 2>/dev/null | head -1)
145
- echo "cairnkeep ${v:-unknown}"
146
- ;;
147
- help | --help | -h)
148
- usage
149
- ;;
150
- *)
151
- echo "Unknown command: $cmd" >&2
152
- usage >&2
153
- exit 2
154
- ;;
155
- esac
5
+ main(process.argv.slice(2)).catch((error) => {
6
+ console.error(`cairn: ${error instanceof Error ? error.message : String(error)}`);
7
+ process.exitCode = 1;
8
+ });
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { main } from "../scripts/cairn-container-cli.mjs";
4
+
5
+ main(process.argv.slice(2)).catch((error) => {
6
+ console.error(`cairn-container: ${error instanceof Error ? error.message : String(error)}`);
7
+ process.exitCode = 2;
8
+ });
@@ -54,19 +54,54 @@ export ANTHROPIC_BASE_URL="$MY_INTERNAL_GATEWAY"
54
54
  The user still runs the standard `./.ai/start-claude.sh`; the overlay's behaviour
55
55
  is injected by the file's presence.
56
56
 
57
+ ## Guided setup policy seam
58
+
59
+ An overlay may provide a data-only JSON policy to `cairn setup --policy PATH`.
60
+ The public schema is
61
+ [`schemas/cairnkeep-setup-policy.schema.json`](../schemas/cairnkeep-setup-policy.schema.json).
62
+ It is strict and provider-neutral: `schema_version` is `1`; `defaults` may set
63
+ `git`, `harnesses`, and `memory`; and `constraints` may restrict those values
64
+ and require selected harnesses. Unknown properties are rejected.
65
+
66
+ Precedence is explicit command-line choices, then policy defaults, then
67
+ interactive input. Constraints validate the resolved plan regardless of which
68
+ source supplied a choice. Non-interactive use still requires an explicit
69
+ target and `--yes`, and every unresolved Git, harness, or memory choice is an
70
+ error. A policy is a regular non-symlink JSON file no larger than 1 MiB; on
71
+ POSIX it must not be executable. Keep organization-specific endpoints,
72
+ credentials, and launcher logic outside this file.
73
+
74
+ For deterministic onboarding, pin a reviewed policy beside the overlay and
75
+ invoke:
76
+
77
+ ```bash
78
+ cairn setup /path/to/project --policy /path/to/setup-policy.json \
79
+ --git existing --harness claude,pi --memory local --yes
80
+ cairn sync-pi --apply
81
+ cairn sync-pi --check
82
+ ```
83
+
84
+ Setup reconciles only the selected project assets and reports machine sync
85
+ without running it. The overlay remains responsible for applying and checking
86
+ machine assets explicitly. Preserve `.ai/cairnkeep.json`: it is the private,
87
+ versioned project ownership record used by status, doctor, recovery, and
88
+ backup-first uninstall.
89
+
57
90
  ## An overlay install script
58
91
 
59
92
  Make it one idempotent command from a fresh machine:
60
93
 
61
94
  ```bash
62
- # 1. Get cairnkeep at a pinned version (npm or a pinned clone)
63
- npm i -g @cairnkeep/cli@1.0.2 # or: git clone … && git checkout v1.0.2
95
+ # 1. Get cairnkeep at a reviewed, pinned version (npm or a pinned clone)
96
+ npm i -g @cairnkeep/cli@<version>
64
97
 
65
98
  # 2. Register the memory server with your harness
66
99
  claude mcp add cairn-memory -s user -- cairn memory-server
67
100
 
68
- # 3. Scaffold the target project (contributor mode if you don't own the repo)
69
- cairn bootstrap --untracked /path/to/project
101
+ # 3. Reconcile the target project deterministically
102
+ cairn setup /path/to/project --git existing --harness claude --memory local --yes
103
+ # Existing bootstrap automation remains supported:
104
+ # cairn bootstrap --untracked /path/to/project
70
105
 
71
106
  # 4. Install the operating layer — GLOBAL or PROJECT-SCOPED (below)
72
107
  sync-claude-assets.sh --apply # global ~/.claude
@@ -128,6 +163,8 @@ secret storage, not generated project files.
128
163
  - [ ] Operating layer scoped as intended (global vs `--live-root`)
129
164
  - [ ] Optional integrations wired only where wanted
130
165
  - [ ] A single documented command takes a fresh machine to a working setup
166
+ - [ ] Setup policy is data-only, schema-valid, and contains no secrets or endpoints
167
+ - [ ] Machine sync/check is explicit; project setup never runs it automatically
131
168
  - [ ] Managed machines resolve `cairn` to the overlay distribution, not raw core
132
169
  - [ ] `cairn config explain` reports memory and RAG destinations without secrets
133
170
  - [ ] A project profile lock prevents silent cross-overlay reconfiguration
@@ -38,6 +38,13 @@ podman run --rm -i \
38
38
 
39
39
  Pin a version instead of `latest` for managed installations.
40
40
 
41
+ On native Windows, the installed `cairn-container.cmd` invokes the same
42
+ argument-safe Node launcher and defaults to `podman.exe`; set
43
+ `CONTAINER_ENGINE` to an explicit compatible engine path if needed. Podman
44
+ Desktop must be configured for Linux containers. Named-volume modes preserve
45
+ the container-side contract, while host paths are passed as single arguments
46
+ so drive letters and spaces are not split by a shell.
47
+
41
48
  ## Authenticated HTTP
42
49
 
43
50
  Generate the bearer token into a private file and start a loopback-only
@@ -57,6 +64,9 @@ The launcher refuses token files that are symlinks or have a mode other than
57
64
  `0400` or `0600`. It mounts the token read-only instead of putting it in the
58
65
  container environment or image.
59
66
 
67
+ On Windows, the equivalent check rejects symlinks and any token ACL granting
68
+ access beyond the current SID, Local System, or built-in Administrators.
69
+
60
70
  The listener is deliberately published only on `127.0.0.1`. For access from
61
71
  other machines, keep it on loopback behind a TLS reverse proxy or encrypted
62
72
  private network. Add the externally visible `Host` header to the DNS-rebinding
@@ -0,0 +1,94 @@
1
+ # Immutable context packs
2
+
3
+ Context packs provide project-approved reference documents and skills without
4
+ copying them into a harness or promoting them into durable memory. They are
5
+ local, immutable, disabled by default, and never execute instructions.
6
+
7
+ ## Format and identity
8
+
9
+ The root `context-pack.json` follows
10
+ [`schemas/context-pack.schema.json`](../schemas/context-pack.schema.json). It
11
+ declares a kebab-case ID, semantic version, descriptive metadata, license, and
12
+ an ordered list of UTF-8 `document` or `skill` files with SHA-256 digests.
13
+
14
+ Validation rejects unknown manifest fields, absolute or traversing paths,
15
+ symlinks, devices, duplicate, missing or undeclared files, invalid UTF-8, and
16
+ digest mismatches. Limits are 1 MiB per file, 1,024 entries, and 64 MiB total.
17
+ The authoritative pack digest covers the exact manifest bytes plus sorted
18
+ path/content bytes. The version label is informative; the digest is identity.
19
+
20
+ ```bash
21
+ cairn pack init ./my-pack --id my-pack --version 1.0.0 \
22
+ --title "My pack" --description "Reviewed local guidance" --license Apache-2.0
23
+ # Edit metadata/kinds if needed, then refresh file hashes.
24
+ cairn pack lock ./my-pack
25
+ cairn pack validate ./my-pack
26
+ ```
27
+
28
+ ## Installation and project pinning
29
+
30
+ ```bash
31
+ cairn pack install ./my-pack
32
+ cairn pack install https://example.invalid/repository.git --ref v1.0.0
33
+ cairn pack list
34
+ cairn pack show PACK-DIGEST
35
+ cairn pack enable PACK-DIGEST --project ./project
36
+ cairn pack disable my-pack --project ./project
37
+ cairn pack remove PACK-DIGEST
38
+ ```
39
+
40
+ Local installation performs no network operation. Git installation requires
41
+ `--ref`, invokes the system `git` executable with an argument array, records
42
+ the exact resolved commit, rejects credentials embedded in URLs, and stores no
43
+ checkout metadata. Immutable objects live under `CAIRN_PACK_BASE_DIR` (default
44
+ `~/.cairnkeep/packs`). Project pointers are atomic and digest-pinned. Remote
45
+ administration may use a validated `--project-id` instead of a local path.
46
+
47
+ Objects are retained until explicitly removed. Removal is refused while any
48
+ project points to the digest. Ordinary uninstall retains them; use
49
+ `cairn uninstall --purge-packs` only after reviewing the dry run and backup.
50
+
51
+ Updates never synchronize in the background:
52
+
53
+ ```bash
54
+ cairn pack update my-pack --check --project ./project
55
+ cairn pack update my-pack --apply --confirm CANDIDATE-DIGEST --project ./project
56
+ ```
57
+
58
+ `--check` does not install or switch a project. `--apply` re-inspects the source,
59
+ requires the candidate digest, installs an immutable object, and atomically
60
+ switches only the named project.
61
+
62
+ ## Retrieval and skill approval
63
+
64
+ Set `CAIRN_CONTEXT_PACKS=1` and restart the memory server to register the three
65
+ read-only, closed-world tools: `context_pack_list`, `context_pack_search`, and
66
+ `context_pack_read`. Every file or search result includes pack ID, version,
67
+ pack digest, path, kind, and file digest. Search uses the existing optional
68
+ embedding configuration and falls back to deterministic substring matching if
69
+ configuration or the endpoint is unavailable. Embedding cache data is stored
70
+ outside immutable objects.
71
+
72
+ Markdown is split deterministically at headings and paragraphs, with chunks
73
+ bounded to 8 KiB and 512-byte overlap. Only packs enabled for the current
74
+ project are searched.
75
+
76
+ Skills remain invisible until their exact file digest is approved:
77
+
78
+ ```bash
79
+ cairn pack skills --project ./project
80
+ cairn pack approve-skill PACK-DIGEST path/to/SKILL.md \
81
+ --confirm FILE-DIGEST --project ./project
82
+ cairn pack revoke-skill PACK-DIGEST path/to/SKILL.md --project ./project
83
+ ```
84
+
85
+ Approval binds the project identity, pack digest, path, and file digest. A pack
86
+ update invalidates approval. Approved skills are only discoverable/readable
87
+ through the context-pack tools; Cairnkeep does not copy, activate, or execute
88
+ them.
89
+
90
+ Authenticated HTTP deployments need the separate
91
+ `CAIRN_CONTEXT_PACK_HTTP=1` consent flag in addition to
92
+ `CAIRN_CONTEXT_PACKS=1`, the existing bearer token, Host/CORS guards, and a
93
+ project header. Pack digests prove integrity, not publisher authenticity.
94
+ Publisher signatures remain future work.