@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
@@ -0,0 +1,142 @@
1
+ # L23 - Guided setup and Pi memory
2
+
3
+ **Status:** Ready
4
+ **Track:** Quickstart and Operator
5
+ **Time:** 35 minutes
6
+ **Tested with:** Cairnkeep 2.12.0; Pi 0.84.1; Node.js 22, 24, and 26
7
+
8
+ ## Outcome
9
+
10
+ You can classify a missing or empty target, replay setup without a TTY, explain
11
+ the limitations of Git-less mode, verify Pi's local stdio memory bridge, and
12
+ recover or uninstall every managed asset without hidden machine changes.
13
+
14
+ The selected harnesses come from Cairnkeep's declarative registry. Codex is a
15
+ supported selection: it receives `.codex/config.toml` and a launcher, while Pi
16
+ continues to require its separate explicit machine sync.
17
+
18
+ ## Prerequisites
19
+
20
+ - Node.js 22 or newer, npm, and Git for the main exercise.
21
+ - Pi 0.84.1 or newer.
22
+ - A disposable parent directory containing no credentials, secrets, private
23
+ state, or identifying project data.
24
+
25
+ ## Exercise
26
+
27
+ Start with a missing target. The explicit flags make this deterministic and
28
+ safe to replay from a non-interactive or non-TTY process:
29
+
30
+ ```bash
31
+ lab=/tmp/cairnkeep-guided-setup-lab
32
+ cairn setup "$lab" --git init --harness pi --memory local --yes
33
+ cd "$lab"
34
+ cairn doctor
35
+ ```
36
+
37
+ Setup performs its classification before it creates `.ai`, `.planning`, or
38
+ `.agentfs`. It initializes Git only because `--git init` authorizes that action,
39
+ records the selected Pi harness in private `.ai/cairnkeep.json`, and reports
40
+ created, updated, unchanged, and skipped assets. Repeating the same `cairn
41
+ setup` command should report the managed files as unchanged.
42
+
43
+ Project setup never changes the Pi installation. Apply and check machine assets
44
+ explicitly, then diagnose the project again:
45
+
46
+ ```bash
47
+ cairn sync-pi --apply
48
+ cairn sync-pi --check
49
+ cairn doctor
50
+ ./.ai/start-pi.sh
51
+ ```
52
+
53
+ In the disposable Pi session, list the registered Cairnkeep tools and make one
54
+ harmless read-only memory call. The extension starts `cairn memory-server` as a
55
+ local stdio child in this project; it does not select HTTP or a remote server.
56
+ Cancel one in-flight call and confirm a later read still works. Exit Pi normally
57
+ and confirm shutdown completes rather than leaving a memory-server child
58
+ running. Cancellation is per call and an awaited session shutdown owns child
59
+ termination.
60
+
61
+ The bridge discovers the effective server catalog. Full, read-only, and custom
62
+ MCP profiles therefore expose only the tools allowed by the server. It preserves
63
+ tool names, stable order, input and output schemas, original content,
64
+ `structuredContent`, `_meta`, and the exact Phase 21 annotations in trusted
65
+ bridge metadata and result `details`. Pi 0.84.1 has no native annotations field
66
+ in its public tool API: do not interpret this preservation as native
67
+ model-facing annotation propagation and do not invent such a field.
68
+
69
+ To see the intentional Git-less boundary in another empty disposable target:
70
+
71
+ ```bash
72
+ limited=/tmp/cairnkeep-guided-setup-limited
73
+ cairn setup "$limited" --git none --harness pi --memory local --yes
74
+ cd "$limited"
75
+ cairn doctor
76
+ ```
77
+
78
+ The result is `limited`, not `complete`. Launchers and local stdio memory remain
79
+ available, but repository-identity and Git-dependent features do not. An
80
+ existing non-Git tree is never initialized without explicit `--git init`.
81
+
82
+ ## Recovery exercise
83
+
84
+ Delete one setup-owned launcher only in the disposable project, diagnose it,
85
+ then replay the exact recovery command:
86
+
87
+ ```bash
88
+ cd /tmp/cairnkeep-guided-setup-lab
89
+ rm .ai/start-pi.sh
90
+ cairn doctor
91
+ cairn setup . --git init --harness pi --memory local --yes
92
+ cairn sync-pi --apply
93
+ cairn sync-pi --check
94
+ cairn doctor
95
+ ```
96
+
97
+ Doctor reports project-state drift separately from missing or drifted Pi
98
+ machine assets. Setup repairs only recorded project assets; `cairn sync-pi
99
+ --apply` repairs only the package-owned Pi extension and prompt paths.
100
+
101
+ Preview backup-first removal before confirming it:
102
+
103
+ ```bash
104
+ cairn uninstall --dry-run /tmp/cairnkeep-guided-setup-lab
105
+ cairn uninstall --yes /tmp/cairnkeep-guided-setup-lab
106
+ ```
107
+
108
+ Inspect the printed backup bundle and generated revert script. Durable memory
109
+ and context packs remain unless their separate purge flags are supplied.
110
+
111
+ ## Common failures
112
+
113
+ | Symptom | Cause | Recovery |
114
+ |---|---|---|
115
+ | Setup refuses a missing target | The non-interactive command omitted an explicit choice or `--yes` | Supply the target, `--git`, `--harness`, `--memory`, and `--yes` together |
116
+ | Setup refuses `--git existing` | The target is not inside a Git work tree | Choose an existing repository, or explicitly authorize `--git init`; use `--git none` only when limited mode is intended |
117
+ | Doctor reports missing or drifted Pi assets | Project setup selected Pi but machine sync is incomplete | Run `cairn sync-pi --apply`, then `cairn sync-pi --check` and `cairn doctor` |
118
+ | A cancelled call ends the session | The Pi/bridge version does not satisfy the per-call cancellation contract | Preserve sanitized diagnostics, close the session, and do not claim release readiness |
119
+ | Pi exits but a child process remains | Shutdown did not complete or the tested extension drifted | Preserve process-state evidence, run the sync check, and treat the release gate as failed |
120
+ | A client expects native annotation hints | Pi's public tool API has no annotations field | Inspect trusted bridge metadata/result `details`; never claim native propagation |
121
+
122
+ ## Privacy and trust boundary
123
+
124
+ `.ai/cairnkeep.json` is private setup state. It records selected modes,
125
+ harnesses, and setup-owned asset digests—not credentials, secrets, endpoints, or
126
+ absolute paths. The Pi bridge is a local child-process boundary: it inherits the
127
+ operator environment needed by the local server, retains only bounded stderr
128
+ for failure diagnostics, and does not log tool arguments or results.
129
+
130
+ Use only synthetic values in exercises and evidence. Do not publish executable
131
+ paths, usernames, hostnames, repository names, environment values, child output,
132
+ memory content, or private state. The bridge adds tools only; it does not run
133
+ prompts, approve skills, create an autonomous loop, or add remote access.
134
+
135
+ ## Release boundary
136
+
137
+ Ready means this lesson and its deterministic contracts pass against v2.12.0.
138
+ Release readiness requires a non-skipping acceptance run
139
+ against separate Pi 0.84.1 minimum and explicitly versioned registry-current
140
+ installations, plus the documented Node.js, Bash 3.2, and native Windows matrix.
141
+ Those executable paths must differ, but both may report 0.84.1 while that is the
142
+ current release; a future registry advance requires its new exact version.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Audience:** advanced users and platform maintainers
4
4
  **Prerequisite:** Practitioner track; L13 before operating captured evidence
5
- **Total time:** about 5 hours
5
+ **Total time:** about 5 hours 35 minutes
6
6
 
7
7
  1. [L09 - Domain knowledge with RAG](../lessons/L09-domain-knowledge.md)
8
8
  2. [L10 - Faster context exploration](../lessons/L10-context-exploration.md)
@@ -12,11 +12,16 @@
12
12
  6. [L16 - Evaluation and ablation](../lessons/L16-evaluation.md)
13
13
  7. [L20 - Least-authority MCP tool profiles](../lessons/L20-mcp-tool-profiles.md)
14
14
  8. [L21 - Immutable context packs and skill approval](../lessons/L21-context-packs.md)
15
+ 9. [L22 - Operate Cairnkeep on native Windows](../lessons/L22-native-windows.md)
16
+ 10. [L23 - Guided setup and Pi memory](../lessons/L23-guided-setup.md)
15
17
 
16
18
  All modules are optional. The track is complete when the operator can add and
17
19
  remove each integration without breaking the standalone local workflow and can
18
- explain its storage, network, credential, and rollback boundaries.
20
+ explain its storage, network, credential, and rollback boundaries. L23 adds the
21
+ v2.11 setup/Pi lifecycle only after the earlier storage, governance, trust, and
22
+ native-platform boundaries.
19
23
 
20
24
  Hands-on spine: `course-04-operation`, `course-06-governance`, and
21
- `course-07-evaluation`, and `course-10-trust-context` in the public
25
+ `course-07-evaluation`, `course-10-trust-context`, and
26
+ `course-12-guided-setup` in the public
22
27
  [course labs](https://github.com/cairnkeep/cairnkeep-course-labs).
@@ -1,17 +1,22 @@
1
1
  # Quickstart Track
2
2
 
3
3
  **Audience:** developers evaluating Cairnkeep
4
- **Total time:** about 75 minutes
4
+ **Total time:** about 110 minutes
5
5
  **Infrastructure:** local machine; Podman is optional
6
6
 
7
7
  1. [L00 - Why Cairnkeep?](../lessons/L00-why-cairnkeep.md)
8
8
  2. [L01 - Try it safely](../lessons/L01-safe-trial.md)
9
9
  3. [L02 - Install the local workflow](../lessons/L02-installation.md)
10
- 4. [L03 - Bootstrap the first project](../lessons/L03-first-project.md)
10
+ 4. [L03 - Set up the first project](../lessons/L03-first-project.md)
11
+ 5. [L23 - Guided setup and Pi memory](../lessons/L23-guided-setup.md)
11
12
 
12
13
  The track is complete when a learner can start a new harness session, retrieve
13
14
  a previously accepted fact, and explain that default stdio memory is stored on
14
- the local machine rather than a discovered remote service.
15
+ the local machine rather than a discovered remote service. L03 uses the
16
+ recommended guided entry point and offers Codex's project-scoped path without a
17
+ separate machine sync; L23 extends that contract to Pi's maintained local stdio
18
+ bridge while keeping its machine sync explicit.
15
19
 
16
- Hands-on spine: `course-00-app` through `course-01-bootstrap` in the public
20
+ Hands-on spine: `course-00-app` through `course-01-bootstrap`, followed by
21
+ `course-12-guided-setup`, in the public
17
22
  [course labs](https://github.com/cairnkeep/cairnkeep-course-labs).
@@ -0,0 +1,136 @@
1
+ # Native Windows operation
2
+
3
+ Cairnkeep supports Windows x64 directly from PowerShell and Command Prompt.
4
+ The supported path does not invoke WSL, Git Bash, or a POSIX shell. Windows
5
+ ARM64 may use Windows x64 emulation, but it is not a native ARM64 support claim
6
+ until the database dependency publishes and passes an ARM64 Windows binding.
7
+
8
+ ## Install and guided setup
9
+
10
+ Prerequisites are Node.js 22 or newer, npm, and the harness you intend to use.
11
+ Git is required for `--git init`, `--git existing`, Git-backed context packs,
12
+ and `--untracked` bootstrap. Explicit `--git none` provides the same documented
13
+ limited mode as POSIX setup.
14
+ The optional `sqlite3.exe` command enables WAL-safe `cairn memory export`.
15
+
16
+ ```powershell
17
+ npm install --global @cairnkeep/cli
18
+ cairn version
19
+ $Project = 'C:\src\my-project'
20
+ cairn setup $Project --git init --harness claude,pi --memory local --yes
21
+ cairn sync --apply
22
+ cairn sync-pi --apply
23
+ cairn sync-pi --check
24
+ Set-Location $Project
25
+ cairn doctor
26
+ .\.ai\start-claude.cmd
27
+ ```
28
+
29
+ Guided setup exposes the same target classification, confirmation, Git,
30
+ harness, memory, reconciliation, counts, JSON result, diagnostics, launch, and
31
+ recovery contract as POSIX. It writes a restricted `.ai/cairnkeep.json` setup
32
+ record and never syncs machine assets automatically. `cairn bootstrap` remains
33
+ the deterministic compatibility primitive for existing scripts.
34
+
35
+ For Codex memory without a harness-wide sync, select only Codex:
36
+
37
+ ```powershell
38
+ cairn setup $Project --git init --harness codex --memory local --yes
39
+ Set-Location $Project
40
+ cairn doctor
41
+ .\.ai\start-codex.cmd
42
+ ```
43
+
44
+ Review `.codex\config.toml` and accept Codex's project-trust prompt. Setup does
45
+ not edit the user-wide Codex configuration or grant trust. It preserves a
46
+ different existing project configuration and doctor verifies a manually merged
47
+ `mcp_servers.cairn-memory` table.
48
+
49
+ Setup and bootstrap write both the established Unix launchers and native Windows
50
+ launchers. Each `.cmd` file enters `start-harness.ps1`, loads `.ai/.env`, changes
51
+ to the project root, and forwards arguments without shell interpolation.
52
+ Optional `.ai/pre-launch.ps1` and `.ai/post-exit.ps1` seams run in the same
53
+ PowerShell process, so exported environment changes reach the harness. The post
54
+ hook receives `$env:CAIRN_EXIT_STATUS`.
55
+
56
+ ## MCP and operating assets
57
+
58
+ Register the stdio server exactly as on other platforms:
59
+
60
+ ```powershell
61
+ claude mcp add cairn-memory -s user -- cairn memory-server
62
+ cairn sync --check
63
+ ```
64
+
65
+ `cairn sync --apply` installs native `.cmd` hook transports and registers them
66
+ in the harness settings. The hook logic itself is Node and remains fail-open
67
+ except for capability admission, which preserves its fail-closed contract.
68
+ `cairn sync-pi` and `cairn sync-kimi` use native filesystem operations. Pi sync
69
+ installs the maintained local stdio memory extension explicitly; setup does not
70
+ start it or add remote access. Pi 0.84.1 is the validated minimum; the v2.11
71
+ release matrix also exercised a separate installation of the exact
72
+ registry-current Pi release. The two executable paths were distinct, while
73
+ both reported 0.84.1 because that was also the current release.
74
+
75
+ ## PowerShell completion
76
+
77
+ Load completion for the current session:
78
+
79
+ ```powershell
80
+ Invoke-Expression (& cairn completion powershell | Out-String)
81
+ ```
82
+
83
+ Place the same expression in `$PROFILE` to load it in future sessions.
84
+
85
+ ## Storage and permissions
86
+
87
+ Cairnkeep retains the same storage paths and formats. `~` resolves to the
88
+ Windows user profile. Sensitive managed JSON files do not rely on meaningless
89
+ Unix mode bits: Cairnkeep removes inherited ACLs and grants access only to the
90
+ current SID, Local System, and built-in Administrators. Context-pack content is
91
+ digest-verified before receiving restricted ACLs and a read-only attribute.
92
+ The guided setup state uses this same private ACL and contains no credentials,
93
+ endpoints, or absolute paths.
94
+
95
+ The embedded AgentFS database driver retains Windows file handles until its
96
+ Node process exits. Cairnkeep therefore runs artifact-store operations in
97
+ short-lived local Node helpers on Windows. Hard deletion and pruning build a
98
+ compacted replacement, release all handles when the helper exits, and only then
99
+ atomically replace the live database. This does not add a daemon, network
100
+ access, or background synchronization.
101
+
102
+ `cairn memory import` uses an internal path-validating tar/gzip reader. Export
103
+ uses `sqlite3.exe` `.backup` for a consistent snapshot of each live WAL database
104
+ and then writes the same portable `.tgz` format used on Unix.
105
+
106
+ ## Scheduling and process cleanup
107
+
108
+ `cairn audit-timer` registers the opt-in `Cairnkeep Memory Audit` task through
109
+ Windows Task Scheduler. `--render-only DIR` writes the command without changing
110
+ the scheduler. Evaluation cancellation targets the exact child PID and its
111
+ descendant tree through `taskkill.exe /T`, then escalates through `/F` after the
112
+ configured grace period.
113
+
114
+ ## Uninstall and recovery
115
+
116
+ Preview first, then confirm explicitly:
117
+
118
+ ```powershell
119
+ cairn uninstall --dry-run C:\src\my-project
120
+ cairn uninstall --yes C:\src\my-project
121
+ ```
122
+
123
+ Uninstall removes only managed assets and their hook registrations. Before
124
+ mutation it creates a timestamped bundle under
125
+ `~/cairnkeep-uninstall-backups/` containing exact files, a strict manifest, and
126
+ `revert.ps1`. Durable memory and context packs remain unless their separate
127
+ purge flags are supplied.
128
+
129
+ ## Verification boundary
130
+
131
+ The release gate runs from `windows-latest` using PowerShell for Node 22, 24,
132
+ and 26. It builds the TypeScript server, runs its Node tests, exercises guided
133
+ setup and bootstrap, sync/check (including Pi), native hooks, safe archive
134
+ import, backup-first uninstall, spaces and Unicode paths, packs the npm artifact,
135
+ installs it globally, invokes `cairn.cmd`, and runs `cairn doctor`. Git Bash is
136
+ never selected as the job shell.
package/docs/operating.md CHANGED
@@ -7,20 +7,23 @@ Cairnkeep has three moving parts:
7
7
 
8
8
  1. **The memory server** (`cairn-memory`) — an MCP server your harness talks to.
9
9
  2. **The project scaffold** — `.ai/` launchers and the `.planning/` knowledge
10
- layer, written by `cairn bootstrap`.
10
+ layer, written by `cairn setup` or the compatibility-oriented
11
+ `cairn bootstrap` primitive.
11
12
  3. **The operating layer** — the commands, agents, and hooks that live in your
12
13
  harness config and drive the workflow.
13
14
 
14
- `cairn bootstrap` only does step 2. Steps 1 and 3 are one-time-per-machine
15
- installs. This guide covers all three in order.
15
+ `cairn setup` is the recommended project entry point. `cairn bootstrap`
16
+ retains its established deterministic behavior for existing automation. Steps
17
+ 1 and 3 are one-time-per-machine installs; project setup reports the explicit
18
+ sync command but never runs it automatically. This guide covers all three.
16
19
 
17
20
  ## Prerequisites
18
21
 
19
22
  - Node.js 22 or newer (for the memory server) and a supported harness. Claude
20
23
  Code and OpenCode receive the full operating layer. Kimi Code receives the
21
24
  memory MCP, launcher, and opt-in graph Skill; Qwen Code receives the memory
22
- MCP and launcher. Pi receives its native trajectory adapter, graph prompt,
23
- and launcher.
25
+ MCP and launcher. Pi receives a maintained local stdio MCP extension, native
26
+ trajectory adapter, graph prompt, and launcher after explicit machine sync.
24
27
  - Optional: the `sqlite3` CLI for `cairn memory export`. Runtime memory and
25
28
  `cairn memory import` do not require it.
26
29
  - Optional: an OpenAI-compatible LLM endpoint for memory extraction and
@@ -29,6 +32,12 @@ installs. This guide covers all three in order.
29
32
  - Optional: rootless Podman for the containerized memory server and isolated
30
33
  workspace base described in [Containers](containers.md).
31
34
 
35
+ Native Windows x64 is supported directly from PowerShell or Command Prompt;
36
+ WSL and Git Bash are not required. The npm package installs a Node entry point,
37
+ and bootstrap emits `.cmd` plus PowerShell launchers. See
38
+ [Native Windows operation](native-windows.md) for the exact setup and recovery
39
+ contract. Windows ARM64 currently uses x64 emulation.
40
+
32
41
  ## Shell completion
33
42
 
34
43
  Generate completion definitions directly from the CLI:
@@ -37,12 +46,86 @@ Generate completion definitions directly from the CLI:
37
46
  cairn completion bash
38
47
  cairn completion zsh
39
48
  cairn completion fish
49
+ cairn completion powershell
40
50
  ```
41
51
 
42
52
  Distributions can install these outputs into the platform's normal completion
43
53
  directories. They can also be loaded for the current shell, for example with
44
54
  `source <(cairn completion bash)`.
45
55
 
56
+ In PowerShell, load completion for the current session with:
57
+
58
+ ```powershell
59
+ Invoke-Expression (& cairn completion powershell | Out-String)
60
+ ```
61
+
62
+ ## Guided project setup
63
+
64
+ Interactive terminals may run `cairn setup` and answer the target, Git,
65
+ harness, memory, and confirmation questions. Automation must make every choice
66
+ explicit:
67
+
68
+ ```bash
69
+ cairn setup /path/to/project --git init --harness claude,pi --memory local --yes
70
+ ```
71
+
72
+ The deterministic form accepts `--git init|existing|none`, a comma-separated
73
+ subset of `claude,opencode,pi,kimi,qwen,codex`, and `--memory local|none`. `--git
74
+ existing` requires the target to be in an existing work tree. `--git init`
75
+ requires Git and is the only non-interactive authorization to initialize a
76
+ repository. `--git none` is an explicit limited mode: repository-aware features
77
+ remain unavailable, and both setup output and `cairn doctor` say so. A missing
78
+ or empty interactive target recommends initialization and asks before writing;
79
+ an existing non-Git tree is never initialized silently.
80
+
81
+ Setup first classifies the target and Git state without writing, then creates or
82
+ reconciles only the selected project launchers and common scaffold assets.
83
+ Identical managed files remain unchanged, changed managed files are updated,
84
+ and unrelated files are preserved. The result reports created, updated,
85
+ unchanged, and skipped counts; `cairn doctor`; an exact launcher per selected
86
+ harness; and the deterministic setup command to use for recovery. `--json`
87
+ returns the same schema-v1 result. The private mode-`0600`
88
+ `.ai/cairnkeep.json` record stores the package version, Git and memory modes,
89
+ selected harnesses, and digests/modes/template identifiers for setup-owned
90
+ assets. It contains no credentials, endpoints, or absolute paths.
91
+
92
+ Setup never installs or refreshes machine-level harness assets. Its
93
+ `machine_sync.automatic` field is always false, and the human output labels the
94
+ reported command as not run automatically. For selections such as Codex and
95
+ Qwen that need no machine sync, `machine_sync.command` is `null` and the human
96
+ output says that sync is not required. Apply any reported command explicitly,
97
+ check it, then diagnose and launch:
98
+
99
+ ```bash
100
+ cairn sync --apply # Claude Code operating assets
101
+ cairn sync-pi --apply # Pi extension and prompt
102
+ cairn sync-pi --check
103
+ cd /path/to/project && cairn doctor
104
+ ./.ai/start-pi.sh
105
+ ```
106
+
107
+ `cairn bootstrap [--untracked] PATH` remains available for scripts that depend
108
+ on its original scaffold and Git-exclusion contract.
109
+
110
+ ## Setup order (Codex CLI)
111
+
112
+ Codex uses project-scoped configuration, so setup owns the complete local MCP
113
+ wiring without editing user-wide state:
114
+
115
+ ```bash
116
+ npm install -g @cairnkeep/cli
117
+ cairn setup /path/to/project --git init --harness codex --memory local --yes
118
+ cd /path/to/project
119
+ cairn doctor
120
+ ./.ai/start-codex.sh # native Windows: .\.ai\start-codex.cmd
121
+ ```
122
+
123
+ Review `.codex/config.toml` and accept Codex's project-trust prompt before use.
124
+ An existing different file is preserved and reported as skipped; merge the
125
+ generated `mcp_servers.cairn-memory` table into it, then run `cairn doctor`.
126
+ Uninstall leaves that operator-owned file intact. Selecting
127
+ `--memory none` creates the launcher but deliberately omits the MCP entry.
128
+
46
129
  ## Setup order (Claude Code)
47
130
 
48
131
  The commands below install the default local topology: `cairn-memory` runs as a
@@ -206,8 +289,9 @@ cairn graph diff
206
289
  ```
207
290
 
208
291
  The same direct CLI works with Qwen Code, Codex, and other shell-capable
209
- clients. This does not add a Pi MCP bridge or imply that those harnesses receive
210
- the rest of Cairnkeep's operating layer.
292
+ clients. Pi sync separately installs Cairnkeep's maintained local stdio MCP
293
+ extension; the graph prompt remains a thin adapter and does not expand the rest
294
+ of Pi's operating surface.
211
295
 
212
296
  All six modes delegate to `cairn graph`. Managed builds run Graphify's local
213
297
  code-only `update` path with provider credentials removed from the subprocess
@@ -217,6 +301,9 @@ so Graphify cannot re-index its own generated HTML/report/JSON. Managed builds
217
301
  do not perform Graphify's optional semantic document extraction. Prefer exact
218
302
  function, class, or file names; broad natural-language graph queries are less
219
303
  precise. Cairnkeep does not install or update Graphify automatically.
304
+ Set `CAIRN_GRAPHIFY_BINARY` to override the `graphify` command when Graphify is
305
+ installed at a specific path. Native executables run directly; `.js`, `.mjs`,
306
+ and `.cjs` helpers run through the active Node runtime on every platform.
220
307
 
221
308
  Graphify also maintains an incremental `graphify-out/` work directory at the
222
309
  repository root. It is separate from Cairnkeep's published
@@ -299,26 +386,52 @@ configuration, approval behavior, and overlay guidance.
299
386
 
300
387
  ## Setup order (Pi)
301
388
 
302
- Pi trajectory capture uses the same project scaffold and store. Its sync also
303
- installs a thin `/graphify` prompt into Pi's agent root:
389
+ Pi uses the same project scaffold and local memory store. Its explicit sync
390
+ installs the maintained memory extension, native trajectory extension, and thin
391
+ `/graphify` prompt into Pi's agent root:
304
392
 
305
393
  ```bash
306
394
  npm install -g @cairnkeep/cli
307
395
  cairn sync-pi --apply # default: ~/.pi/agent
308
- cairn bootstrap /path/to/project
396
+ cairn setup /path/to/project --git init --harness pi --memory local --yes
309
397
  cp /path/to/project/.ai/env.example /path/to/project/.ai/.env
310
398
  cd /path/to/project && cairn doctor && ./.ai/start-pi.sh
311
399
  ```
312
400
 
313
- This command does not install an MCP bridge. Cairnkeep does not own or select a
314
- Pi bridge; if you want `cairn memory-server` tools inside Pi as well, configure
315
- a user-chosen Pi extension/bridge separately.
401
+ The memory extension starts `cairn memory-server` as a local stdio child from
402
+ the project root. It dynamically discovers the effective server catalog, so
403
+ feature gates, capability state, and the current MCP tool profile remain
404
+ authoritative. It does not contain a second hard-coded catalog. Startup is
405
+ bounded to 10 seconds, calls to 30 seconds, results to 4 MiB, and retained child
406
+ stderr to the newest 16 KiB. Cancellation is propagated, child or protocol
407
+ failure is surfaced, and session shutdown closes the child.
408
+
409
+ Tool names, descriptions, input and output schemas, content,
410
+ `structuredContent`, `_meta`, and failure behavior cross the bridge without
411
+ semantic rewriting. The exact MCP annotations are preserved in the trusted Pi
412
+ result `details`, together with the discovered tool metadata and original
413
+ content. Pi 0.84.1 has no native annotations field in its public tool API, so
414
+ Cairnkeep does not claim native model-facing annotation propagation or invent a
415
+ substitute field.
416
+
417
+ The bridge is tools-only: it does not run prompts, activate context-pack skills,
418
+ create an autonomous loop, add remote access, or bypass server-side tool
419
+ restrictions. Removing `MCP_HTTP_PORT` from the child environment deliberately
420
+ keeps this integration on local stdio.
316
421
 
317
422
  Use `cairn sync-pi --check` to report drift without writing, or
318
423
  `--live-root DIR` to target an isolated Pi agent root. The command owns exactly
319
- `extensions/cairnkeep-trajectory.ts` and `prompts/graphify.md`; `cairn
320
- uninstall --pi-live-root DIR` removes those files backup-first and leaves every
321
- other Pi asset untouched.
424
+ `extensions/cairnkeep-memory.ts`, `extensions/cairnkeep-trajectory.ts`, and
425
+ `prompts/graphify.md`; `cairn doctor` reports a selected Pi extension that is
426
+ missing or drifted and points to `cairn sync-pi --apply`. `cairn uninstall
427
+ --pi-live-root DIR` removes those files backup-first and leaves every other Pi
428
+ asset untouched.
429
+
430
+ Pi 0.84.1 is the validated minimum supported version for this extension. The
431
+ v2.11 release passed the complete setup and bridge matrix on separate Pi 0.84.1
432
+ minimum and registry-current installations, Node.js 22, 24, and 26, Bash 3.2,
433
+ and native Windows. The two Pi executable paths differed, while both reported
434
+ 0.84.1 because that was also the registry-current release.
322
435
 
323
436
  The extension listens for Pi's native `session_shutdown` event and reads only
324
437
  the active branch from the read-only session manager. It returns before doing
@@ -381,6 +494,7 @@ vendor or host.
381
494
  | `CAIRN_HARNESS_STATE_DIR` | Optional absolute local root for recoverable native capability leases (default `${XDG_STATE_HOME:-~/.local/state}/cairn/harness`) |
382
495
  | `CAIRN_GIT_PROVIDER` | Git host for collaboration commands: `github`\|`gitlab`\|`codeberg`\|`forgejo`\|`none`. See [git-providers.md](git-providers.md) |
383
496
  | `CAIRN_ROUTE_ENDPOINT` | Base URL of an already-running token-miser routing/tiering proxy (unset → the `route_check` tool is inert) |
497
+ | `CAIRN_GRAPHIFY_BINARY` | Optional Graphify command/path override; JavaScript helpers run through the active Node runtime (default `graphify` from `PATH`) |
384
498
  | `CAIRN_EXPLORE_BINARY` | Absolute path to the `token_miser` binary used by `context_explore` (unset → the tool throws at call time) |
385
499
  | `CAIRN_EXPLORE_REPO_ROOT` | Default repo root for `context_explore` when no per-call `repo_root` is given (unset + no param → the tool throws) |
386
500
  | `CAIRN_EXPLORE_CACHE` | Caches `context_explore` results keyed on query + repo HEAD + dirty-state; default ON, set to `0` to disable |
@@ -772,13 +886,13 @@ maintain a running install — without forking the core. All are opt-in.
772
886
  ### Launcher seams
773
887
 
774
888
  The generic launchers (`.ai/start-claude.sh`, `.ai/start-opencode.sh`,
775
- `.ai/start-kimi.sh`, `.ai/start-qwen.sh`, and `.ai/start-pi.sh`) run optional hooks around the
889
+ `.ai/start-kimi.sh`, `.ai/start-qwen.sh`, `.ai/start-codex.sh`, and `.ai/start-pi.sh`) run optional hooks around the
776
890
  harness, each a no-op when absent:
777
891
 
778
892
  | Seam | When | Purpose |
779
893
  |---|---|---|
780
894
  | `.ai/pre-launch.sh` | sourced after `.env`, before launch | export env (e.g. a provider base URL / auth), refresh credentials, or abort by returning non-zero |
781
- | `CAIRN_EXTRA_SETTINGS` | read just before launch | path to a settings file layered on Claude Code (`--settings`) or OpenCode (`OPENCODE_CONFIG`); Kimi, Qwen, and Pi leave the variable available to hooks but do not interpret it |
895
+ | `CAIRN_EXTRA_SETTINGS` | read just before launch | path to a settings file layered on Claude Code (`--settings`) or OpenCode (`OPENCODE_CONFIG`); Kimi, Qwen, Codex, and Pi leave the variable available to hooks but do not interpret it |
782
896
  | `.ai/post-exit.sh` | sourced after the harness exits | teardown; `CAIRN_EXIT_STATUS` holds the exit code |
783
897
 
784
898
  A wrapper that needs a non-default provider drops a `pre-launch.sh` that renders
@@ -809,6 +923,13 @@ rebuild only derived indexes/dedupe/pointers from valid authoritative records.
809
923
  Unsupported schema, SQLite failure, invalid full records, or digest corruption
810
924
  fails untouched with guidance to preserve the database before manual recovery.
811
925
 
926
+ When `.ai/cairnkeep.json` exists, doctor also validates its private state,
927
+ selected assets, digests, and modes. It reports `limited` for explicit
928
+ `--git none`, fails an incomplete or drifted setup with the recorded
929
+ deterministic `cairn setup` recovery command, and checks the Pi machine
930
+ extension when Pi was selected. `cairn sync-pi --apply` repairs that
931
+ machine-level drift; setup itself never performs the sync.
932
+
812
933
  ### Evaluation harness (opt-in)
813
934
 
814
935
  `cairn eval` is a local, serial experiment coordinator. It is disabled unless
@@ -897,8 +1018,9 @@ claims.
897
1018
  SIGINT or SIGTERM stops schedule admission, terminates the active adapter,
898
1019
  checkpoints a `cancelled` observation, waits for bounded cleanup, and retains
899
1020
  an inspectable partial report. On POSIX systems the runner targets the child
900
- process group with TERM then bounded KILL escalation. Windows descendant-tree
901
- termination is not guaranteed and is not a supported evaluation claim.
1021
+ process group with TERM then bounded KILL escalation. Native Windows targets
1022
+ the adapter and its descendant tree with `taskkill.exe /T`, escalating to `/F`
1023
+ after the bounded grace period.
902
1024
 
903
1025
  See [storage](storage.md#evaluation-report-and-note-snapshot-storage) for local
904
1026
  retention/removal and [privacy](privacy-and-data-flow.md#evaluation-adapter-and-report-flow)
@@ -36,6 +36,9 @@ request unless the corresponding endpoint and credential are configured.
36
36
  | Automatic compaction recovery | None | Structured categories are injected locally; raw summary and other bodies are excluded |
37
37
  | Explicit artifact read/show | The redacted body only when HTTP is separately enabled and the operator/client explicitly reads it | Local terminal/stdio, or the explicitly registered authenticated server |
38
38
  | Opt-in evaluation coordinator | Adapter-defined inference may leave the machine only according to the explicit operator-owned adapter and inherited environment | Local adapter subprocess; Cairnkeep supplies no provider, endpoint, credential, model, or network default |
39
+ | Guided project setup | None | Selected scaffold assets and private `.ai/cairnkeep.json` state in the target; machine sync is never automatic |
40
+ | Codex project setup and launcher | None | Local `.codex/config.toml` starts `cairn memory-server` over stdio only after the operator trusts the project |
41
+ | Pi memory extension | None | Local `cairn memory-server` stdio child; no HTTP transport is inherited |
39
42
 
40
43
  Model endpoints may be local or remote. Cairnkeep cannot determine a provider's
41
44
  retention, training, or logging policy; verify it before sending confidential
@@ -91,6 +94,41 @@ and its generated `revert.sh` restores exact bytes, modes, and layout. Explicit
91
94
  `cairn eval delete` and `prune` remove selected contained experiment trees with
92
95
  no hidden tombstone.
93
96
 
97
+ ## Guided setup, Codex, and Pi bridge
98
+
99
+ Guided setup performs a read-only target and Git preflight before project
100
+ writes. Its schema-v1 `.ai/cairnkeep.json` record contains the package version,
101
+ Git and memory choices, selected harness names, and setup-owned asset paths,
102
+ digests, modes, and template identifiers. It does not contain credentials,
103
+ endpoints, absolute paths, prompts, or memory values. The file is mode `0600`
104
+ on POSIX and receives the private managed-file ACL on native Windows. Setup
105
+ never invokes machine sync, and it does not start a harness or server child.
106
+
107
+ Selecting Codex with local memory adds a non-secret project MCP table that
108
+ invokes `cairn memory-server`. Setup never edits user-wide Codex configuration,
109
+ grants project trust, or overwrites a different `.codex/config.toml`. Doctor can
110
+ validate a manually merged Cairnkeep table without claiming ownership of the
111
+ surrounding operator configuration, and uninstall leaves that file intact.
112
+
113
+ When the explicitly installed Pi memory extension starts a session, it spawns
114
+ `cairn memory-server` as a child in the project directory over local stdio. The
115
+ bridge removes `MCP_HTTP_PORT` from the child environment, retains only the
116
+ newest 16 KiB of child stderr for bounded failure diagnostics, caps startup,
117
+ calls, catalogs, and results, and closes the child at shutdown. The child still
118
+ inherits the remaining operator environment needed by the normal local server,
119
+ so those environment values and the project directory are a child-process trust
120
+ boundary even though they are not persisted by the bridge.
121
+
122
+ Catalog and call replay is allow-listed to MCP tool metadata and result fields.
123
+ Names, schemas, annotations, content, `structuredContent`, `_meta`, and error
124
+ state are preserved without sanitizing away protocol meaning; Pi receives the
125
+ annotations in trusted result `details` because Pi 0.84.1 has no native
126
+ annotations field. The bridge does not log requests or results, create a second
127
+ catalog, activate prompts or skills, add remote access, or persist a transcript.
128
+ Sanitized test replay uses synthetic tool arguments, results, stderr, and
129
+ project paths only; release evidence must not include credentials, private
130
+ endpoints, memory values, or identifying local paths.
131
+
94
132
  ## Evaluation adapter and report flow
95
133
 
96
134
  `CAIRN_EVAL` is unset/off by default. With it off, `cairn eval` returns a fixed
@@ -169,7 +207,9 @@ network-free, and permanently scoped as framework-only evidence.
169
207
  SIGINT/SIGTERM stops new schedule admission, terminates the active adapter,
170
208
  checkpoints cancellation, performs bounded cleanup, and retains a partial
171
209
  report. POSIX process groups receive TERM followed by bounded KILL escalation.
172
- There is no Windows descendant-process-tree termination guarantee.
210
+ Native Windows uses `taskkill.exe /T` for the exact child tree and `/F` for
211
+ bounded force escalation; it does not enumerate or terminate unrelated
212
+ processes.
173
213
 
174
214
  Turns aggregate only under exact matching compatibility IDs. Missing token
175
215
  components/totals, unknown verifier outcomes, incompatible turn semantics, and