@cairnkeep/cli 2.9.0 → 2.12.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 (86) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/README.md +83 -29
  3. package/bin/cairn +6 -165
  4. package/bin/cairn-container +8 -0
  5. package/docs/building-an-overlay.md +42 -5
  6. package/docs/containers.md +10 -0
  7. package/docs/harness-compatibility.md +64 -3
  8. package/docs/learning/CURRICULUM-MAP.md +13 -6
  9. package/docs/learning/FEATURE-GUIDE.md +14 -3
  10. package/docs/learning/README.md +5 -2
  11. package/docs/learning/lessons/L00-why-cairnkeep.md +1 -1
  12. package/docs/learning/lessons/L01-safe-trial.md +3 -3
  13. package/docs/learning/lessons/L02-installation.md +24 -8
  14. package/docs/learning/lessons/L03-first-project.md +34 -15
  15. package/docs/learning/lessons/L19-validated-skill-improvement.md +1 -1
  16. package/docs/learning/lessons/L20-mcp-tool-profiles.md +1 -1
  17. package/docs/learning/lessons/L21-context-packs.md +1 -1
  18. package/docs/learning/lessons/L22-native-windows.md +83 -0
  19. package/docs/learning/lessons/L23-guided-setup.md +142 -0
  20. package/docs/learning/tracks/operator.md +8 -3
  21. package/docs/learning/tracks/quickstart.md +9 -4
  22. package/docs/native-windows.md +136 -0
  23. package/docs/operating.md +142 -20
  24. package/docs/privacy-and-data-flow.md +41 -1
  25. package/docs/quickstart.md +86 -0
  26. package/docs/storage.md +14 -2
  27. package/examples/eval/bundled-fake.json +1 -1
  28. package/mcp-memory-server/dist/artifact-store-windows-worker.js +74 -0
  29. package/mcp-memory-server/dist/artifact-store.js +196 -55
  30. package/mcp-memory-server/dist/capability-cli.js +2 -1
  31. package/mcp-memory-server/dist/capability-config.js +4 -3
  32. package/mcp-memory-server/dist/capability-harness.js +34 -7
  33. package/mcp-memory-server/dist/context-pack.js +84 -25
  34. package/mcp-memory-server/dist/eval-cli.js +6 -5
  35. package/mcp-memory-server/dist/eval-plan.js +35 -13
  36. package/mcp-memory-server/dist/eval-process.js +11 -4
  37. package/mcp-memory-server/dist/eval-report.js +7 -5
  38. package/mcp-memory-server/dist/graph-cli.js +7 -1
  39. package/mcp-memory-server/dist/index.js +19 -20
  40. package/mcp-memory-server/dist/mcp-tool-profile.js +6 -4
  41. package/mcp-memory-server/dist/note-store.js +12 -3
  42. package/mcp-memory-server/dist/pi-mcp-bridge.js +185 -0
  43. package/mcp-memory-server/dist/platform-security.js +102 -0
  44. package/mcp-memory-server/dist/skill-store.js +27 -12
  45. package/mcp-memory-server/package.json +2 -1
  46. package/package.json +6 -4
  47. package/pi/extensions/cairnkeep-memory.ts +61 -0
  48. package/schemas/cairnkeep-setup-policy.schema.json +55 -0
  49. package/schemas/cairnkeep-setup.schema.json +36 -0
  50. package/scripts/bootstrap.sh +7 -15
  51. package/scripts/cairn-cli.mjs +119 -0
  52. package/scripts/cairn-container-cli.mjs +121 -0
  53. package/scripts/cairn-hook.mjs +199 -0
  54. package/scripts/completion.sh +17 -6
  55. package/scripts/doctor.sh +58 -0
  56. package/scripts/fix-permissions.mjs +12 -0
  57. package/scripts/harness-registry.mjs +126 -0
  58. package/scripts/memory-wiki-audit.mjs +95 -0
  59. package/scripts/phase26-test-manifest.mjs +26 -0
  60. package/scripts/run-repository-tests.mjs +76 -0
  61. package/scripts/setup-core.mjs +312 -0
  62. package/scripts/setup-reconcile.mjs +332 -0
  63. package/scripts/setup.mjs +342 -0
  64. package/scripts/sync-pi-assets.sh +19 -4
  65. package/scripts/test-bootstrap-untracked.sh +2 -1
  66. package/scripts/test-completion.sh +41 -0
  67. package/scripts/test-doctor.sh +66 -0
  68. package/scripts/test-harness-registry.sh +94 -0
  69. package/scripts/test-learning-docs.sh +52 -3
  70. package/scripts/test-package-install.sh +69 -0
  71. package/scripts/test-phase17-artifact-lifecycle.sh +1 -1
  72. package/scripts/test-phase18-capability-lifecycle.sh +1 -1
  73. package/scripts/test-phase19-eval-lifecycle.sh +12 -2
  74. package/scripts/test-pi-lifecycle.mjs +190 -0
  75. package/scripts/test-setup-compatibility.mjs +187 -0
  76. package/scripts/test-setup-output.sh +131 -0
  77. package/scripts/test-setup-overlay.sh +113 -0
  78. package/scripts/test-setup-preflight.mjs +281 -0
  79. package/scripts/test-setup-reconcile.mjs +257 -0
  80. package/scripts/test-uninstall.sh +50 -0
  81. package/scripts/test-windows-native.mjs +159 -0
  82. package/scripts/uninstall.sh +73 -6
  83. package/scripts/verify-pi-mcp-bridge.mjs +588 -0
  84. package/scripts/windows-platform.mjs +733 -0
  85. package/templates/codex-config.toml.template +5 -0
  86. package/templates/start-codex.sh.template +30 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,69 @@ All notable user-facing changes are documented here. This project follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.12.0] - 2026-08-13
9
+
10
+ ### Added
11
+
12
+ - Add one declarative harness registry for setup choices, project assets,
13
+ launcher generation, diagnostics, native Windows, and lifecycle tooling.
14
+ - Add first-class Codex CLI setup with a project-scoped local stdio MCP entry,
15
+ POSIX and native Windows launchers, explicit project-trust guidance, and a
16
+ memory-off path that creates no MCP configuration.
17
+ - Add a five-minute quickstart and Codex route to the public learning path.
18
+
19
+ ### Changed
20
+
21
+ - Derive guided setup policy validation and required-asset diagnosis from the
22
+ shared harness catalog. Codex/Qwen-only setup now reports that no machine
23
+ sync is required instead of suggesting unrelated operating assets.
24
+ - Extend bootstrap contributor mode, backup-first uninstall, schema validation,
25
+ package checks, and native Windows coverage to Codex-owned project files.
26
+
27
+ ## [2.11.0] - 2026-08-12
28
+
29
+ ### Added
30
+
31
+ - Replace the Bash npm entry point with a cross-platform Node CLI while keeping
32
+ the established Unix scripts as compatibility implementations.
33
+ - Add native Windows x64 bootstrap and `.cmd`/PowerShell launchers, Claude/Pi/
34
+ Kimi asset synchronization, Node hook transports, diagnostics, PowerShell
35
+ completion, Task Scheduler registration, memory import/export plumbing, and
36
+ backup-first uninstall with a `revert.ps1` manifest.
37
+ - Enforce private Windows ACLs for least-authority MCP profiles and context-pack
38
+ state, make pack objects read-only, retry Windows atomic replacements, and
39
+ terminate evaluation adapter descendant trees through `taskkill.exe /T`.
40
+ - Add a PowerShell-only Windows CI matrix for Node 22/24/26, including native
41
+ lifecycle tests and a packed global npm installation under paths containing
42
+ spaces and Unicode.
43
+
44
+ ### Changed
45
+
46
+ - Add PowerShell to shell completion and document Windows x64 as a supported
47
+ native platform. Windows ARM64 remains an x64-emulation target until the
48
+ storage dependency ships a native ARM64 binding.
49
+
50
+ ### Added
51
+
52
+ - Add `cairn setup` as the recommended guided project entry point, with a fully
53
+ deterministic non-interactive form, explicit Git/harness/memory choices,
54
+ versioned private project state, selected-asset reconciliation, structured
55
+ output, doctor diagnostics, and recovery commands.
56
+ - Add a strict provider-neutral setup-policy schema for private overlays, with
57
+ command-line choices taking precedence over policy defaults and constraints
58
+ enforced on every resolved plan.
59
+ - Add the maintained Pi local stdio memory extension, dynamic MCP catalog
60
+ discovery, bounded child lifecycle, cancellation, exact response preservation,
61
+ and trusted annotation metadata. Pi 0.84.1 is the validated minimum.
62
+
63
+ ### Changed
64
+
65
+ - Make project setup report machine sync without running it automatically;
66
+ `cairn sync-pi --apply|--check`, `cairn doctor`, and backup-first uninstall
67
+ remain explicit lifecycle operations.
68
+ - Preserve `cairn bootstrap` and `--untracked` as backward-compatible scripted
69
+ primitives while recommending guided setup for new onboarding.
70
+
8
71
  ## [2.9.0] - 2026-08-06
9
72
 
10
73
  ### Added
@@ -273,7 +336,9 @@ stored memories.
273
336
  - Preserve executable permissions and Bash 3.2 portability on macOS.
274
337
  - Add backup-first uninstall and SQLite-safe memory export/import guidance.
275
338
 
276
- [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.9.0...HEAD
339
+ [Unreleased]: https://github.com/cairnkeep/cairnkeep/compare/v2.12.0...HEAD
340
+ [2.12.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.11.0...v2.12.0
341
+ [2.11.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.9.0...v2.11.0
277
342
  [2.9.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.8.0...v2.9.0
278
343
  [2.8.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.7.0...v2.8.0
279
344
  [2.7.0]: https://github.com/cairnkeep/cairnkeep/compare/v2.6.0...v2.7.0
package/README.md CHANGED
@@ -9,24 +9,44 @@
9
9
  A *cairn* is a stack of stones left as a trail marker for whoever follows; a
10
10
  *keep* is where you store what matters. **Cairnkeep** is where coding agents
11
11
  stack durable memory — decisions, pitfalls, patterns — and follow the trail
12
- across sessions, projects, and harnesses (Claude Code, OpenCode, Kimi Code,
13
- Qwen Code, Pi, and other MCP clients).
12
+ across sessions, projects, and harnesses (Claude Code, Codex CLI, OpenCode,
13
+ Kimi Code, Qwen Code, Pi, and other MCP clients).
14
+
15
+ ## Five-minute start
16
+
17
+ For Codex CLI, Cairnkeep can install the complete project-local memory wiring
18
+ in one command:
19
+
20
+ ```bash
21
+ npm install --global @cairnkeep/cli
22
+ cairn setup /path/to/project --git init --harness codex --memory local --yes
23
+ cd /path/to/project
24
+ ./.ai/start-codex.sh # Windows: .\.ai\start-codex.cmd
25
+ ```
26
+
27
+ Review `.codex/config.toml` and accept Codex's project-trust prompt on first
28
+ use. No separate MCP registration or machine-level asset sync is needed. See
29
+ the **[quickstart](docs/quickstart.md)** for existing repositories, Claude Code,
30
+ verification, and the first remember/recall cycle.
14
31
 
15
32
  ## Status
16
33
 
17
- Shipped: the memory server, the `cairn` CLI (`bootstrap`, `memory-server`, `sync`, `sync-pi`, `sync-kimi`,
34
+ Shipped: the memory server, the `cairn` CLI (`setup`, `bootstrap`, `memory-server`, `sync`, `sync-pi`, `sync-kimi`,
18
35
  `doctor`, `trajectory`, `artifact`, `mcp-tools`, `pack`, `notes`, `memory`, `eval`, `audit-timer`, `completion`, `uninstall`) installable via
19
36
  `npm i -g @cairnkeep/cli`, and the
20
37
  operating layer (commands,
21
- agents, hooks) installed on Claude Code and OpenCode, plus a native Pi
38
+ agents, hooks) installed on Claude Code and OpenCode, plus the native Pi
22
39
  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
40
+ expose wrapper seams (`.ai/pre-launch.sh`/`.ai/pre-launch.ps1`,
41
+ `CAIRN_EXTRA_SETTINGS`, `.ai/post-exit.sh`/`.ai/post-exit.ps1`) so an enterprise wrapper can add provider/credential setup
25
42
  without forking them. Also shipped: context exploration (`/context-explore`) and
26
43
  a thin routing seam (`route_check`), both of which delegate to
27
44
  [token-miser](https://github.com/cairnkeep/token-miser), a public
28
45
  cairnkeep-org sibling project.
29
46
 
47
+ Version 2.12 adds a declarative harness registry, first-class Codex project
48
+ setup, and a shorter path from installation to verified recall.
49
+
30
50
  ## Compatibility
31
51
 
32
52
  Node.js 22, 24, and 26 are supported. Cairnkeep 2.x requires Node.js 22 or
@@ -39,21 +59,25 @@ and 20 are end-of-life upstream.
39
59
  | OpenCode on Linux/macOS | Memory server plus commands, plugins, hooks, and launchers |
40
60
  | Kimi Code on Linux/macOS | Memory MCP server, project launcher, and opt-in `/graphify` Skill |
41
61
  | 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 |
43
- | Codex CLI | Memory MCP server; no Cairnkeep operating-layer assets |
62
+ | 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 |
63
+ | Codex CLI on Linux/macOS | Project-scoped memory MCP configuration and launcher; no Cairnkeep-specific commands or hooks |
44
64
  | Other MCP clients | Memory plus optional domain-knowledge and context-pack MCP tools |
45
- | Native Windows | Not supported by the Bash-based installer; use WSL (not yet CI-verified) |
65
+ | 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 |
66
+ | Windows ARM64 | Supported through Windows x64 emulation only; a native database binding is not currently shipped |
67
+ | WSL | Uses the normal Linux workflow; distinct from native Windows and Git Bash |
46
68
 
47
69
  The `cairn graph` CLI is harness-independent and can be run from a project
48
70
  shell used by Kimi Code, Pi, Qwen Code, Codex, or another client. Claude Code,
49
71
  OpenCode, Pi, and Kimi can receive thin `/graphify` adapters; those adapters do
50
72
  not imply equivalent hooks, agents, or MCP support.
51
73
 
52
- Linux, macOS, Bash 3.2 portability, and clean Node 22/24/26 runtime checks
53
- are exercised in CI.
74
+ Linux, macOS, Bash 3.2 portability, native PowerShell on Windows x64, global npm
75
+ installation, and clean Node 22/24/26 runtime checks are exercised in CI. See
76
+ [Native Windows operation](docs/native-windows.md) for platform-specific setup,
77
+ ACL, scheduling, process-tree, and recovery details.
54
78
 
55
79
  See [Harness compatibility](docs/harness-compatibility.md) for exact support
56
- levels, Kimi and Qwen configuration, and candidates that are not yet runtime-tested.
80
+ levels, trust boundaries, and candidates that are not yet runtime-tested.
57
81
 
58
82
  ## Try with Podman
59
83
 
@@ -78,8 +102,9 @@ storage paths, secrets, and private derived images, see
78
102
  - **`mcp-memory-server/`** — an MCP server exposing durable, scoped memory
79
103
  (`memory_write`, `memory_search`, …) backed by AgentFS, with optional
80
104
  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;
105
+ - **`bin/cairn`** — the CLI. `cairn setup [path]` guides or deterministically
106
+ reconciles selected project assets; `cairn bootstrap [path]` preserves the
107
+ established scripted scaffold contract; `cairn doctor` health-checks the configured pieces;
83
108
  `cairn trajectory list|show|prune` manages opt-in local session trajectories;
84
109
  `cairn artifact list|show|delete|prune` manages opt-in local artifacts;
85
110
  `cairn mcp-tools list|status|set|reset` applies least-authority discovery
@@ -99,7 +124,7 @@ storage paths, secrets, and private derived images, see
99
124
  (`export` requires the optional `sqlite3` CLI);
100
125
  `cairn audit-timer` installs the scheduled memory+wiki audit;
101
126
  `cairn completion bash|zsh|fish` generates shell completion definitions; and
102
- `cairn sync-pi` installs the native Pi trajectory extension and graph prompt;
127
+ `cairn sync-pi` installs the native Pi memory and trajectory extensions plus graph prompt;
103
128
  `cairn sync-kimi` installs the Kimi graph Skill;
104
129
  `cairn uninstall` reverses the install (backup-first, revertible).
105
130
  - **`templates/`** — project scaffolding (generic launchers, env) plus the
@@ -128,9 +153,12 @@ them. These are the accelerators the author pairs cairnkeep with; each is opt-in
128
153
  ## Setup
129
154
 
130
155
  A working workflow needs three things: the memory server registered, the
131
- operating layer (commands, agents, hooks) installed into your harness, and a
132
- bootstrapped project. `cairn bootstrap` does only the last of these — the full
133
- ordered walkthrough is in **[docs/operating.md](docs/operating.md)**.
156
+ operating layer installed into your harness, and a configured project. `cairn
157
+ setup` is the recommended guided entry point; `cairn bootstrap` remains the
158
+ deterministic compatibility primitive for established scripts. Project setup
159
+ reports but never performs machine-level sync. The full ordered walkthrough is
160
+ in **[the quickstart](docs/quickstart.md)**; the complete operator reference is
161
+ in **[docs/operating.md](docs/operating.md)**.
134
162
 
135
163
  This setup is local by default: the registered stdio server stores memory on
136
164
  the user's computer. Cairnkeep never discovers or selects a remote host.
@@ -147,8 +175,8 @@ claude mcp add cairn-memory -s user -- cairn memory-server
147
175
  # 2. Install the operating layer (commands, agents, hooks, scaffold templates)
148
176
  cairn sync --apply # add --live-root <proj>/.claude to scope it
149
177
 
150
- # 3. Scaffold a project and configure it
151
- cairn bootstrap /path/to/project
178
+ # 3. Configure a project deterministically
179
+ cairn setup /path/to/project --git init --harness claude --memory local --yes
152
180
  cp /path/to/project/.ai/env.example /path/to/project/.ai/.env # then edit
153
181
 
154
182
  # 4. Launch (and, optionally, check the wiring first)
@@ -169,6 +197,13 @@ patterns/transactional-migrations: Use transactional migrations for schema chang
169
197
  The exact command rendering depends on the client. Any MCP client can call
170
198
  `memory_write` and `memory_search` directly.
171
199
 
200
+ For Codex CLI, `cairn setup --harness codex --memory local` writes the
201
+ project-scoped `.codex/config.toml` entry and both POSIX and native Windows
202
+ launchers. Review the configuration and trust the project before launching.
203
+ Existing operator-owned `.codex/config.toml` files are never overwritten; a
204
+ reported `skipped` file must be merged by the operator and checked with
205
+ `cairn doctor`.
206
+
172
207
  For Kimi Code, bootstrap supplies a launcher and Kimi reads the repository's
173
208
  MCP configuration. A local stdio entry uses `cairn memory-server`. Remote Kimi
174
209
  configuration requires a literal URL and supports a token reference through
@@ -185,18 +220,36 @@ headers. Review and approve project MCP configuration with
185
220
  `qwen mcp approve cairn-memory`, then launch with `./.ai/start-qwen.sh`. See
186
221
  [Harness compatibility](docs/harness-compatibility.md#qwen-code).
187
222
 
188
- For Pi, install the local trajectory adapter and use the scaffolded launcher:
223
+ For Pi, select Pi during project setup, explicitly install/check its machine
224
+ assets, run doctor, and use the generated launcher:
189
225
 
190
226
  ```bash
191
227
  cairn sync-pi --apply
192
- cairn bootstrap /path/to/project
193
- cd /path/to/project && ./.ai/start-pi.sh
228
+ cairn sync-pi --check
229
+ cairn setup /path/to/project --git init --harness pi --memory local --yes
230
+ cd /path/to/project && cairn doctor && ./.ai/start-pi.sh
231
+ ```
232
+
233
+ This installs the maintained local stdio memory extension, trajectory capture,
234
+ and the thin `/graphify` prompt. The memory extension discovers the effective
235
+ server tool catalog and preserves annotations in trusted result details; Pi's
236
+ public API has no native annotations field. It adds tools only—no prompt runs,
237
+ skill activation, autonomous loop, or remote access. Pi 0.84.1 is the minimum
238
+ validated version; v2.11 also passed the registry-current Pi release and the
239
+ documented Node, Bash, and native Windows matrix.
240
+
241
+ Preview removal before confirming it. Uninstall backs up every managed file it
242
+ will change and prints the generated revert command; durable memory and context
243
+ packs remain unless their explicit purge flags are supplied:
244
+
245
+ ```bash
246
+ cairn uninstall --dry-run /path/to/project
247
+ cairn uninstall --yes /path/to/project
194
248
  ```
195
249
 
196
- This installs trajectory capture plus the thin `/graphify` prompt. The prompt
197
- delegates exclusively to `cairn graph`. Cairnkeep does not bundle or select a
198
- Pi MCP bridge; configure a user-chosen bridge separately if you also want the
199
- MCP memory tools inside Pi.
250
+ If setup-owned project assets drift, rerun the exact `cairn setup ... --yes`
251
+ recovery command reported by `cairn doctor`. For Pi machine-asset drift, run
252
+ `cairn sync-pi --apply`, then `cairn sync-pi --check` and `cairn doctor`.
200
253
 
201
254
  Closed trajectories can be compiled into local hindsight notes without a model
202
255
  or embedding service. Capture and distillation are separate opt-ins:
@@ -303,6 +356,7 @@ search):
303
356
  | `CAIRN_EVAL` | Opt in to the local evaluation coordinator (default off; does not select a harness, model, endpoint, credential, or network) |
304
357
  | `CAIRN_GIT_PROVIDER` | Git host for collaboration commands: `github`\|`gitlab`\|`codeberg`\|`forgejo`\|`none` ([docs/git-providers.md](docs/git-providers.md)) |
305
358
  | `CAIRN_ROUTE_ENDPOINT` | Base URL of an already-running token-miser routing/tiering proxy (unset → `route_check` is inert) |
359
+ | `CAIRN_GRAPHIFY_BINARY` | Optional Graphify command/path override (default `graphify` from `PATH`; JavaScript helpers run through Node) |
306
360
  | `CAIRN_EXPLORE_BINARY` | Absolute path to the `token_miser` binary used by `context_explore` (unset → the tool throws) |
307
361
  | `CAIRN_EXPLORE_REPO_ROOT` | Default repo root for `context_explore` when no per-call `repo_root` is given |
308
362
  | `CAIRN_EXTRA_SETTINGS` | Optional settings/config file the launcher layers onto the harness (wrapper seam) |
@@ -412,8 +466,8 @@ is neither a Cairnkeep result nor an acceptance target.
412
466
  Reports and note snapshots stay under
413
467
  `.agentfs/eval/experiments/<experiment-id>/`; default uninstall retains them,
414
468
  while explicit purge is backup-first and revertible. Cancellation retains an
415
- inspectable partial report. POSIX process-group cleanup is tested; Windows
416
- descendant-process-tree termination is not guaranteed. See the
469
+ inspectable partial report. POSIX process-group cleanup and Windows descendant-
470
+ tree cleanup through `taskkill.exe /T` are tested by their platform contracts. See the
417
471
  [operating guide](docs/operating.md#evaluation-harness-opt-in),
418
472
  [storage contract](docs/storage.md#evaluation-report-and-note-snapshot-storage),
419
473
  and [privacy flow](docs/privacy-and-data-flow.md#evaluation-adapter-and-report-flow).
package/bin/cairn CHANGED
@@ -1,167 +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 mcp-tools <list|status|set|reset>
56
- Inspect and restrict MCP tool exposure with full,
57
- read-only, or exact custom project profiles.
58
- cairn pack <init|lock|validate|install|list|show|remove|enable|disable|update|skills|approve-skill|revoke-skill>
59
- Build, verify, install, pin, and retrieve immutable
60
- context packs. Packs stay local and disabled by default.
61
- cairn notes <distill|search-error|promote|doctor>
62
- Compile closed trajectories into local hindsight notes,
63
- search exact failure signatures, promote corroborated
64
- notes, or validate the note store.
65
- cairn eval <validate|run|ablate|report|prune|delete>
66
- Validate or run default-off local evaluations, inspect
67
- reports, and manage retained experiment results.
68
- cairn skill <harvest|list|show|review|propose|evaluate|apply|rollback>
69
- Turn recurring hindsight evidence into reviewed,
70
- evaluated, reversible skill-file improvements.
71
- cairn graph <build|query|status|diff|explain|path>
72
- Build the local code graph, inspect freshness and
73
- changes, or query exact symbols and paths.
74
- cairn memory <path|export|import>
75
- Relocate global-scope memory. `path` prints its location;
76
- `export <file.tgz>` takes a WAL-safe snapshot (requires
77
- sqlite3); `import <file.tgz>` restores it.
78
- cairn audit-timer [--on-calendar SPEC] [--para-root PATH] [--render-only DIR]
79
- Install (opt-in) a systemd user timer that runs the
80
- memory+wiki audit on a schedule; prints a cron alternative.
81
- cairn uninstall [--dry-run] [--yes] [--purge-memory] [--purge-packs] [--live-root DIR]
82
- [--pi-live-root DIR] [--kimi-live-root DIR] [PROJECT ...]
83
- Reverse what cairnkeep installed/modified (operating
84
- layer, hook registrations, MCP registration, audit
85
- timer, and any given projects' bootstrap scaffold).
86
- Backs everything up first with a revert.sh; keeps the
87
- durable memory store unless --purge-memory is given.
88
- cairn completion bash|zsh|fish
89
- Generate completion definitions for a major shell.
90
- cairn version Print version
91
- cairn help Show this help
92
- USAGE
93
- }
94
-
95
- case "$cmd" in
96
- bootstrap)
97
- exec "$CAIRN_ROOT/scripts/bootstrap.sh" "$@"
98
- ;;
99
- doctor)
100
- exec "$CAIRN_ROOT/scripts/doctor.sh" "$@"
101
- ;;
102
- uninstall)
103
- exec "$CAIRN_ROOT/scripts/uninstall.sh" "$@"
104
- ;;
105
- memory)
106
- exec "$CAIRN_ROOT/scripts/memory-store.sh" "$@"
107
- ;;
108
- memory-server)
109
- # Run the memory MCP server (stdio by default). Use with your harness, e.g.
110
- # claude mcp add cairn-memory -s user -- cairn memory-server
111
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/index.js" "$@"
112
- ;;
113
- trajectory)
114
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/trajectory-cli.js" "$@"
115
- ;;
116
- artifact)
117
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/artifact-cli.js" "$@"
118
- ;;
119
- capabilities)
120
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/capability-cli.js" "$@"
121
- ;;
122
- mcp-tools)
123
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/mcp-tool-cli.js" "$@"
124
- ;;
125
- pack)
126
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/context-pack-cli.js" "$@"
127
- ;;
128
- notes)
129
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/note-cli.js" "$@"
130
- ;;
131
- eval)
132
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/eval-cli.js" "$@"
133
- ;;
134
- skill)
135
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/skill-cli.js" "$@"
136
- ;;
137
- graph)
138
- exec node "$CAIRN_ROOT/mcp-memory-server/dist/graph-cli.js" "$@"
139
- ;;
140
- sync)
141
- exec "$CAIRN_ROOT/scripts/sync-claude-assets.sh" "$@"
142
- ;;
143
- sync-pi)
144
- exec "$CAIRN_ROOT/scripts/sync-pi-assets.sh" "$@"
145
- ;;
146
- sync-kimi)
147
- exec "$CAIRN_ROOT/scripts/sync-kimi-assets.sh" "$@"
148
- ;;
149
- audit-timer)
150
- exec "$CAIRN_ROOT/scripts/install-audit-timer.sh" "$@"
151
- ;;
152
- completion)
153
- exec "$CAIRN_ROOT/scripts/completion.sh" "$@"
154
- ;;
155
- version | --version | -v)
156
- v=$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$CAIRN_ROOT/package.json" 2>/dev/null | head -1)
157
- echo "cairnkeep ${v:-unknown}"
158
- ;;
159
- help | --help | -h)
160
- usage
161
- ;;
162
- *)
163
- echo "Unknown command: $cmd" >&2
164
- usage >&2
165
- exit 2
166
- ;;
167
- 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
+ });
@@ -28,7 +28,7 @@ manifest, profile-lock, private-registry, and rollback contract.
28
28
  ## The launcher seams
29
29
 
30
30
  The generic launchers (`.ai/start-claude.sh`, `.ai/start-opencode.sh`,
31
- `.ai/start-kimi.sh`, `.ai/start-qwen.sh`, and `.ai/start-pi.sh`, scaffolded by `cairn bootstrap`) run
31
+ `.ai/start-kimi.sh`, `.ai/start-qwen.sh`, `.ai/start-codex.sh`, and `.ai/start-pi.sh`, scaffolded by `cairn bootstrap`) run
32
32
  optional hooks, each a no-op when absent:
33
33
 
34
34
  | Seam | When | Use it for |
@@ -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