@cairnkeep/cli 1.0.2

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 (129) hide show
  1. package/AGENTS.md +45 -0
  2. package/CONTRIBUTING.md +49 -0
  3. package/LICENSE +201 -0
  4. package/README.md +149 -0
  5. package/SECURITY.md +37 -0
  6. package/bin/cairn +73 -0
  7. package/claude/agents/code-reviewer.md +174 -0
  8. package/claude/agents/security-investigator.md +112 -0
  9. package/claude/agents/security-target-selector.md +90 -0
  10. package/claude/agents/security-validator.md +97 -0
  11. package/claude/agents/wiki-ingester.md +108 -0
  12. package/claude/agents/wiki-lint-auditor.md +94 -0
  13. package/claude/agents/wiki-query-analyst.md +84 -0
  14. package/claude/commands/context-explore.md +40 -0
  15. package/claude/commands/graphify.md +150 -0
  16. package/claude/commands/memory-review.md +85 -0
  17. package/claude/commands/memory-sync.md +71 -0
  18. package/claude/commands/recall.md +32 -0
  19. package/claude/commands/remember.md +43 -0
  20. package/claude/commands/repo-review.md +191 -0
  21. package/claude/commands/security-audit.md +174 -0
  22. package/claude/commands/wiki-ingest.md +112 -0
  23. package/claude/commands/wiki-lint.md +86 -0
  24. package/claude/commands/wiki-query.md +92 -0
  25. package/claude/hooks/context-explore-pretask.sh +93 -0
  26. package/claude/hooks/memory-capture.sh +59 -0
  27. package/claude/hooks/memory-recall.sh +84 -0
  28. package/claude/hooks/memory-wakeup.sh +45 -0
  29. package/docs/building-an-overlay.md +117 -0
  30. package/docs/domain-knowledge.md +86 -0
  31. package/docs/git-providers.md +36 -0
  32. package/docs/operating.md +366 -0
  33. package/mcp-memory-server/dist/embeddings.js +122 -0
  34. package/mcp-memory-server/dist/explore-cache.js +97 -0
  35. package/mcp-memory-server/dist/index.js +1256 -0
  36. package/mcp-memory-server/package.json +36 -0
  37. package/opencode/agents/code-reviewer.md +173 -0
  38. package/opencode/agents/security-investigator.md +111 -0
  39. package/opencode/agents/security-target-selector.md +89 -0
  40. package/opencode/agents/security-validator.md +96 -0
  41. package/opencode/agents/wiki-ingester.md +107 -0
  42. package/opencode/agents/wiki-lint-auditor.md +93 -0
  43. package/opencode/agents/wiki-query-analyst.md +83 -0
  44. package/opencode/command/code-review.md +199 -0
  45. package/opencode/command/context-explore.md +42 -0
  46. package/opencode/command/graphify.md +153 -0
  47. package/opencode/command/memory-review.md +44 -0
  48. package/opencode/command/memory-sync.md +94 -0
  49. package/opencode/command/recall.md +38 -0
  50. package/opencode/command/remember.md +46 -0
  51. package/opencode/command/security-audit.md +80 -0
  52. package/opencode/command/wiki-ingest.md +55 -0
  53. package/opencode/command/wiki-lint.md +51 -0
  54. package/opencode/command/wiki-query.md +50 -0
  55. package/opencode/plugins/memory-capture.ts +188 -0
  56. package/opencode/plugins/memory-recall.ts +132 -0
  57. package/opencode/plugins/memory-wakeup.ts +102 -0
  58. package/opencode/templates/security-finding-register.yaml.template +51 -0
  59. package/opencode/templates/security-issue.md.template +43 -0
  60. package/opencode/templates/security-policy.md.template +29 -0
  61. package/opencode/templates/security-report.md.template +43 -0
  62. package/opencode/templates/wiki-contradictions.md.template +31 -0
  63. package/opencode/templates/wiki-index.md.template +40 -0
  64. package/opencode/templates/wiki-lint-report.md.template +38 -0
  65. package/opencode/templates/wiki-log.md.template +11 -0
  66. package/opencode/templates/wiki-policy.md.template +47 -0
  67. package/opencode/templates/wiki-query-answer.md.template +26 -0
  68. package/opencode/templates/wiki-source-summary.md.template +33 -0
  69. package/opencode/workflows/memory-review-workflow.md +66 -0
  70. package/opencode/workflows/security-audit-workflow.md +197 -0
  71. package/opencode/workflows/wiki-ingest-workflow.md +149 -0
  72. package/opencode/workflows/wiki-lint-workflow.md +128 -0
  73. package/opencode/workflows/wiki-query-workflow.md +122 -0
  74. package/package.json +56 -0
  75. package/scripts/bootstrap.sh +99 -0
  76. package/scripts/doctor.sh +91 -0
  77. package/scripts/install-audit-timer.sh +68 -0
  78. package/scripts/lib/assert-tool-event.mjs +50 -0
  79. package/scripts/memory-store.sh +71 -0
  80. package/scripts/memory-wiki-audit.sh +156 -0
  81. package/scripts/sync-claude-assets.sh +182 -0
  82. package/scripts/sync-opencode-explore-assets.sh +187 -0
  83. package/scripts/sync-opencode-graphify-assets.sh +152 -0
  84. package/scripts/sync-opencode-memory-assets.sh +160 -0
  85. package/scripts/sync-opencode-plugin-assets.sh +163 -0
  86. package/scripts/sync-opencode-security-assets.sh +195 -0
  87. package/scripts/sync-opencode-wiki-assets.sh +250 -0
  88. package/scripts/test-audit-timer.sh +29 -0
  89. package/scripts/test-bootstrap-untracked.sh +41 -0
  90. package/scripts/test-cli-dispatch.sh +21 -0
  91. package/scripts/test-doctor.sh +32 -0
  92. package/scripts/test-launcher-hooks.sh +66 -0
  93. package/scripts/test-memory-store.sh +44 -0
  94. package/scripts/test-remember-recall-assertions.sh +70 -0
  95. package/scripts/transcript-to-text.mjs +53 -0
  96. package/scripts/verify-docs-parity.sh +112 -0
  97. package/scripts/verify-explore-maturation.sh +288 -0
  98. package/scripts/verify-fastcontext-reliability.sh +624 -0
  99. package/scripts/verify-no-private-references.sh +145 -0
  100. package/scripts/verify-opencode-live-parity.sh +864 -0
  101. package/scripts/verify-routing-seam.sh +169 -0
  102. package/scripts/verify-token-savings-ab.sh +557 -0
  103. package/templates/PROJECT-INSTRUCTIONS.md.template +42 -0
  104. package/templates/alignment-gap-register.yaml.template +56 -0
  105. package/templates/alignment-policy.md.template +28 -0
  106. package/templates/alignment-pr-template.md.template +18 -0
  107. package/templates/alignment-report.md.template +56 -0
  108. package/templates/env.example.template +25 -0
  109. package/templates/graph-policy.md.template +37 -0
  110. package/templates/graphs-gitignore.template +3 -0
  111. package/templates/memory-wiki-audit.service.template +6 -0
  112. package/templates/memory-wiki-audit.timer.template +9 -0
  113. package/templates/memory.json.template +4 -0
  114. package/templates/planning-config.json.template +6 -0
  115. package/templates/project-brief.md.template +40 -0
  116. package/templates/security-finding-register.yaml.template +51 -0
  117. package/templates/security-issue.md.template +43 -0
  118. package/templates/security-policy.md.template +29 -0
  119. package/templates/security-report.md.template +43 -0
  120. package/templates/start-claude.sh.template +46 -0
  121. package/templates/start-opencode.sh.template +41 -0
  122. package/templates/structured-change-canvas.md.template +63 -0
  123. package/templates/wiki-contradictions.md.template +31 -0
  124. package/templates/wiki-index.md.template +40 -0
  125. package/templates/wiki-lint-report.md.template +38 -0
  126. package/templates/wiki-log.md.template +11 -0
  127. package/templates/wiki-policy.md.template +47 -0
  128. package/templates/wiki-query-answer.md.template +26 -0
  129. package/templates/wiki-source-summary.md.template +33 -0
package/AGENTS.md ADDED
@@ -0,0 +1,45 @@
1
+ # Cairnkeep — agent guide
2
+
3
+ Cairnkeep is a durable, harness-agnostic memory + context layer for coding
4
+ agents. This file is the operating contract for agents working *in this repo*.
5
+
6
+ ## Layout
7
+ - `mcp-memory-server/` — the memory MCP server (`cairn-memory`). TypeScript.
8
+ - `bin/cairn` — the CLI (`cairn bootstrap [path]`).
9
+ - `scripts/` — bootstrap and maintenance utilities.
10
+ - `templates/` — project scaffolding (launchers, env) + the derived-knowledge
11
+ layer (wiki, alignment, graphs, security, planning).
12
+
13
+ ## Build & test
14
+ ```bash
15
+ cd mcp-memory-server
16
+ npm ci
17
+ npm run build
18
+ npm test # offline smoke tests — no API key required
19
+ ```
20
+ `npm test` must pass before committing changes to the memory server.
21
+
22
+ ## Memory model (what the server exposes)
23
+ - Scoped, durable key/value memory over AgentFS: `memory_write`, `memory_read`,
24
+ `memory_search`, `memory_supersede`, `memory_history`, `memory_extract`.
25
+ - Keys are short kebab-case with a prefix: `decisions/`, `pitfalls/`,
26
+ `patterns/`, `bugs/`, `constraints/`, `conventions/`.
27
+ - Search uses embeddings when `CAIRN_LLM_API_KEY` and an endpoint URL are set;
28
+ otherwise it degrades to substring match.
29
+
30
+ ## Conventions
31
+ - Keep the core provider-neutral: no vendor names, no hardcoded endpoints. All
32
+ LLM configuration comes from `CAIRN_LLM_*` / `CAIRN_MEMORY_*` environment
33
+ variables.
34
+ - Keep the git-host layer configurable via `CAIRN_GIT_PROVIDER`
35
+ (see `docs/git-providers.md`); never hardcode a specific host.
36
+ - Match the existing style; prefer the smallest change that solves the task.
37
+ - Run the relevant checks before closing work.
38
+
39
+ ## Working rules (hard)
40
+ - This repo never references a specific employer, vendor, internal host/IP, or
41
+ private repo name — in code, comments, commit messages, or docs.
42
+ - No AI/assistant authorship references anywhere (commits, comments, docs).
43
+ - Scan every commit — the diff **and** the message — for the above before
44
+ creating it.
45
+ - Commit locally, review, then push.
@@ -0,0 +1,49 @@
1
+ # Contributing to Cairnkeep
2
+
3
+ Contributions are welcome through GitHub issues and pull requests.
4
+
5
+ ## Before starting
6
+
7
+ - Open or reference an issue for behavior changes that affect users, storage,
8
+ security boundaries, or public interfaces.
9
+ - Keep the core provider-neutral. Do not add employer names, private repository
10
+ names, internal endpoints, credentials, or environment-specific defaults.
11
+ - Do not include generated authorship or assistant attribution in commits,
12
+ source files, or documentation.
13
+ - Report security vulnerabilities privately as described in
14
+ [SECURITY.md](SECURITY.md), not through a public issue.
15
+
16
+ ## Development setup
17
+
18
+ The memory server requires Node.js 18 or newer. Node.js 20 is used in CI.
19
+
20
+ ```bash
21
+ git clone https://github.com/cairnkeep/cairnkeep.git
22
+ cd cairnkeep/mcp-memory-server
23
+ npm ci
24
+ npm test
25
+ ```
26
+
27
+ The repository-level checks exercise the CLI, bootstrap scripts, documentation
28
+ parity, and public-content guard:
29
+
30
+ ```bash
31
+ cd ..
32
+ npm run check:public
33
+ ```
34
+
35
+ Some integration verifiers require optional sibling tools or configured API
36
+ endpoints. They are not part of the default offline test suite.
37
+
38
+ ## Pull requests
39
+
40
+ - Create a focused branch from `main`.
41
+ - Keep commits coherent and use imperative commit subjects.
42
+ - Add or update tests for behavioral changes.
43
+ - Update user documentation when configuration or commands change.
44
+ - Confirm `npm run check:public` and `npm --prefix mcp-memory-server test` pass.
45
+ - Keep the working tree free of generated databases, logs, credentials, and
46
+ local planning artifacts not intended for publication.
47
+
48
+ By contributing, you agree that your contribution is licensed under the
49
+ Apache License 2.0 found in [LICENSE](LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Stefano Tondo
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Cairnkeep
2
+
3
+ > A durable, harness-agnostic **memory + context layer** for coding agents.
4
+
5
+ A *cairn* is a stack of stones left as a trail marker for whoever follows; a
6
+ *keep* is where you store what matters. **Cairnkeep** is where coding agents
7
+ stack durable memory — decisions, pitfalls, patterns — and follow the trail
8
+ across sessions, projects, and harnesses (Claude Code, OpenCode, …).
9
+
10
+ ## Status
11
+
12
+ Shipped: the memory server, the `cairn` CLI (`bootstrap`, `memory-server`, `sync`,
13
+ `doctor`, `memory`, `audit-timer`) installable via `npm i -g @cairnkeep/cli`, and the
14
+ operating layer (commands,
15
+ agents, hooks) installed on both Claude Code and OpenCode. The generic launchers
16
+ expose wrapper seams (`.ai/pre-launch.sh`, `CAIRN_EXTRA_SETTINGS`,
17
+ `.ai/post-exit.sh`) so an enterprise wrapper can add provider/credential setup
18
+ without forking them. Also shipped: context exploration (`/context-explore`) and
19
+ a thin routing seam (`route_check`), both of which delegate to
20
+ [token-miser](https://github.com/cairnkeep/token-miser), a public
21
+ cairnkeep-org sibling project.
22
+
23
+ ## Components
24
+
25
+ - **`mcp-memory-server/`** — an MCP server exposing durable, scoped memory
26
+ (`memory_write`, `memory_search`, …) backed by AgentFS, with optional
27
+ embedding-ranked search against any OpenAI-compatible endpoint.
28
+ - **`bin/cairn`** — the CLI. `cairn bootstrap [path]` scaffolds a project's
29
+ `.ai/` launchers + env; `cairn doctor` health-checks the configured pieces;
30
+ `cairn memory export|import` relocates the durable store between machines;
31
+ `cairn audit-timer` installs the scheduled memory+wiki audit.
32
+ - **`templates/`** — project scaffolding (generic launchers, env) plus the
33
+ derived-knowledge layer (wiki, alignment, graph, security, planning).
34
+ - **`scripts/`** — asset-sync and maintenance utilities.
35
+
36
+ ## Related projects
37
+
38
+ - **[token-miser](https://github.com/cairnkeep/token-miser)** — a public
39
+ cairnkeep-org sibling that owns context exploration and request routing;
40
+ cairnkeep's `context_explore` and `route_check` tools are thin delegates
41
+ to it.
42
+
43
+ ## Optional companion tools
44
+
45
+ cairnkeep runs standalone — none of the tools below are required. Its memory
46
+ server, `cairn bootstrap`, and derived-knowledge features work with none of
47
+ them. These are the accelerators the author pairs cairnkeep with; each is opt-in.
48
+
49
+ | Tool | What it adds | How it plugs in |
50
+ |------|--------------|-----------------|
51
+ | [lean-ctx](https://github.com/yvgude/lean-ctx) | Compressed reads/searches/shell/dir-maps — large token savings on exploration | Register as an MCP server in your harness |
52
+ | [token-miser](https://github.com/cairnkeep/token-miser) | Model routing (`route_check`) + codebase mapping (`context_explore`) | Already integrated, env-gated: `CAIRN_ROUTE_ENDPOINT` / `CAIRN_EXPLORE_BINARY` |
53
+ | [rtk](https://github.com/rtk-ai/rtk) | "Rust Token Killer": token-reduced proxy for git/npm/cargo output | Shell-level, no wiring needed |
54
+
55
+ ## Setup
56
+
57
+ A working workflow needs three things: the memory server registered, the
58
+ operating layer (commands, agents, hooks) installed into your harness, and a
59
+ bootstrapped project. `cairn bootstrap` does only the last of these — the full
60
+ ordered walkthrough is in **[docs/operating.md](docs/operating.md)**.
61
+
62
+ The short version for Claude Code:
63
+
64
+ ```bash
65
+ # 1. Install cairnkeep and register the memory server (server name: cairn-memory)
66
+ npm install -g @cairnkeep/cli
67
+ claude mcp add cairn-memory -s user -- cairn memory-server
68
+
69
+ # 2. Install the operating layer (commands, agents, hooks, scaffold templates)
70
+ cairn sync --apply # add --live-root <proj>/.claude to scope it
71
+
72
+ # 3. Scaffold a project and configure it
73
+ cairn bootstrap /path/to/project
74
+ cp /path/to/project/.ai/env.example /path/to/project/.ai/.env # then edit
75
+
76
+ # 4. Launch (and, optionally, check the wiring first)
77
+ cd /path/to/project && cairn doctor
78
+ ./.ai/start-claude.sh
79
+ ```
80
+
81
+ Prefer working from a clone? Build the server with `cd mcp-memory-server && npm
82
+ install && npm run build`, then use `scripts/sync-claude-assets.sh` and
83
+ `bin/cairn` in place of the installed `cairn`.
84
+
85
+ Step 2 is easy to miss and load-bearing: without it the memory server is
86
+ registered but none of the `/remember`, `/recall`, `/wiki-*`, `/security-audit`,
87
+ or `/repo-review` commands (and no memory hooks) exist. OpenCode uses the
88
+ `sync-opencode-*.sh` scripts instead — see the operating guide.
89
+
90
+ The launchers load `.ai/.env` and start the harness in the repo root. They stay
91
+ deliberately minimal — provider/profile specifics belong in your own wrapper,
92
+ which plugs in through the launcher seams below.
93
+
94
+ **Wrapper seams.** The generic launchers are no-ops beyond loading `.ai/.env`
95
+ unless a wrapper opts in:
96
+
97
+ - **`.ai/pre-launch.sh`** — sourced after `.env`, before the harness starts. May
98
+ export env (e.g. a provider base URL) or abort the launch by returning
99
+ non-zero. This is where credential refresh / connectivity setup lives.
100
+ - **`CAIRN_EXTRA_SETTINGS`** — path to a settings file layered onto the harness
101
+ (`--settings` for Claude Code, `--config` for OpenCode). Process env still
102
+ wins, so an inline value beats the profile.
103
+ - **`.ai/post-exit.sh`** — sourced after the harness exits, with
104
+ `CAIRN_EXIT_STATUS` set to its exit code.
105
+
106
+ **Contributor mode.** Working on a repo you don't own? `cairn bootstrap
107
+ --untracked /path/to/project` additionally writes the scaffolded paths
108
+ (`.ai/`, `.planning/`) into the repo's `.git/info/exclude`, so the workflow
109
+ files stay purely local: nothing to commit or push, invisible to every other
110
+ contributor, and no edit to the shared `.gitignore`. The trade-off is that
111
+ untracked planning state lives only on that clone — deleting the clone
112
+ deletes it. To move the durable memory itself between machines, use
113
+ `cairn memory export` / `cairn memory import`.
114
+
115
+ ## Configuration
116
+
117
+ The memory server and collaboration commands are configured entirely through
118
+ `.ai/.env` (any OpenAI-compatible API for extraction and embedding-ranked
119
+ search):
120
+
121
+ | Variable | Purpose |
122
+ |---|---|
123
+ | `CAIRN_LLM_API_KEY` | API key for the extraction / embeddings endpoint |
124
+ | `CAIRN_LLM_API_URL` | Base URL of the OpenAI-compatible endpoint |
125
+ | `CAIRN_LLM_EXTRACTION_MODEL` | Chat model used for memory extraction |
126
+ | `CAIRN_MEMORY_EMBEDDING_URL` | Embeddings endpoint (falls back to `CAIRN_LLM_API_URL`) |
127
+ | `CAIRN_MEMORY_EMBEDDING_MODEL` | Embedding model name (required for semantic search) |
128
+ | `CAIRN_AGENTFS_BASE_DIR` | Base dir for global memory scopes (default `~/.cairnkeep`) |
129
+ | `CAIRN_GIT_PROVIDER` | Git host for collaboration commands: `github`\|`gitlab`\|`codeberg`\|`forgejo`\|`none` ([docs/git-providers.md](docs/git-providers.md)) |
130
+ | `CAIRN_ROUTE_ENDPOINT` | Base URL of an already-running token-miser routing/tiering proxy (unset → `route_check` is inert) |
131
+ | `CAIRN_EXPLORE_BINARY` | Absolute path to the `token_miser` binary used by `context_explore` (unset → the tool throws) |
132
+ | `CAIRN_EXPLORE_REPO_ROOT` | Default repo root for `context_explore` when no per-call `repo_root` is given |
133
+ | `CAIRN_EXTRA_SETTINGS` | Optional settings/config file the launcher layers onto the harness (wrapper seam) |
134
+ | `CAIRN_ANYTHINGLLM_SYNC_SCRIPT` | Override path to the domain-knowledge sync script (when the integration lives outside the repo) |
135
+
136
+ Without an API key, search degrades gracefully to substring matching.
137
+
138
+ ## More
139
+
140
+ - **Optional document RAG** (`domain_knowledge_*` via AnythingLLM) — [docs/domain-knowledge.md](docs/domain-knowledge.md)
141
+ - **Building a private overlay** (wrap cairnkeep for your org/provider) — [docs/building-an-overlay.md](docs/building-an-overlay.md)
142
+ - **Full operating guide** — [docs/operating.md](docs/operating.md)
143
+ - **Git providers** — [docs/git-providers.md](docs/git-providers.md)
144
+ - **Contributing** — [CONTRIBUTING.md](CONTRIBUTING.md)
145
+ - **Security policy** — [SECURITY.md](SECURITY.md)
146
+
147
+ ## License
148
+
149
+ Apache-2.0 © 2026 Stefano Tondo
package/SECURITY.md ADDED
@@ -0,0 +1,37 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are applied to the latest released version of
6
+ `@cairnkeep/cli`. Users should upgrade to the newest npm release before
7
+ reporting an issue that may already be resolved.
8
+
9
+ ## Reporting a vulnerability
10
+
11
+ Do not open a public issue for a suspected vulnerability or include secrets,
12
+ private endpoints, memory databases, or reproduction data in public logs.
13
+
14
+ Use GitHub's private vulnerability reporting flow:
15
+
16
+ https://github.com/cairnkeep/cairnkeep/security/advisories/new
17
+
18
+ Include the affected version, impact, reproduction steps, and any suggested
19
+ mitigation. Use synthetic data and redact credentials and private repository
20
+ details.
21
+
22
+ The project will acknowledge the report, validate the issue, and coordinate a
23
+ fix and disclosure through the private advisory. No response-time guarantee is
24
+ provided, but confirmed issues will be prioritized according to impact.
25
+
26
+ ## Scope
27
+
28
+ Reports are especially useful for:
29
+
30
+ - memory-scope isolation or path traversal;
31
+ - unauthorized HTTP access to the MCP server;
32
+ - credential, cookie, or stored-memory disclosure;
33
+ - unsafe command or file execution;
34
+ - package or bootstrap integrity problems.
35
+
36
+ Configuration mistakes that deliberately disable documented safeguards are
37
+ normally outside scope unless the safe default is ineffective.
package/bin/cairn ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # cairn — Cairnkeep CLI. Thin dispatcher over the core scripts.
3
+ set -euo pipefail
4
+
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)
14
+
15
+ cmd="${1:-help}"
16
+ [[ $# -gt 0 ]] && shift
17
+
18
+ case "$cmd" in
19
+ bootstrap)
20
+ exec "$CAIRN_ROOT/scripts/bootstrap.sh" "$@"
21
+ ;;
22
+ doctor)
23
+ exec "$CAIRN_ROOT/scripts/doctor.sh" "$@"
24
+ ;;
25
+ memory)
26
+ exec "$CAIRN_ROOT/scripts/memory-store.sh" "$@"
27
+ ;;
28
+ memory-server)
29
+ # Run the memory MCP server (stdio by default). Use with your harness, e.g.
30
+ # claude mcp add cairn-memory -s user -- cairn memory-server
31
+ exec node "$CAIRN_ROOT/mcp-memory-server/dist/index.js" "$@"
32
+ ;;
33
+ sync)
34
+ exec "$CAIRN_ROOT/scripts/sync-claude-assets.sh" "$@"
35
+ ;;
36
+ audit-timer)
37
+ exec "$CAIRN_ROOT/scripts/install-audit-timer.sh" "$@"
38
+ ;;
39
+ version | --version | -v)
40
+ v=$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$CAIRN_ROOT/package.json" 2>/dev/null | head -1)
41
+ echo "cairnkeep ${v:-unknown}"
42
+ ;;
43
+ help | --help | -h | *)
44
+ cat <<'USAGE'
45
+ cairn — Cairnkeep CLI
46
+
47
+ Usage:
48
+ cairn bootstrap [--untracked] [path]
49
+ Scaffold .ai/ launchers + env into a project (default: .).
50
+ --untracked keeps the scaffold out of git via the repo's
51
+ .git/info/exclude (contributor mode: nothing to commit,
52
+ invisible to other contributors, local-only).
53
+ cairn memory-server Run the memory MCP server (stdio). Register it with your
54
+ harness, e.g. claude mcp add cairn-memory -s user -- cairn memory-server.
55
+ cairn sync [--apply] [--live-root DIR]
56
+ Install/update the Claude Code operating layer (commands,
57
+ agents, hooks) into ~/.claude, or into DIR for a single
58
+ project (--live-root <project>/.claude).
59
+ cairn doctor Health-check the configured pieces (memory server, LLM /
60
+ embedding endpoints, git provider, store); skips what is
61
+ unconfigured, fails only on a configured-but-unreachable dep.
62
+ cairn memory <path|export|import>
63
+ Relocate the durable memory store. `path` prints its
64
+ location; `export <file.tgz>` takes a WAL-safe snapshot;
65
+ `import <file.tgz>` restores it on another machine.
66
+ cairn audit-timer [--on-calendar SPEC] [--para-root PATH] [--render-only DIR]
67
+ Install (opt-in) a systemd user timer that runs the
68
+ memory+wiki audit on a schedule; prints a cron alternative.
69
+ cairn version Print version
70
+ cairn help Show this help
71
+ USAGE
72
+ ;;
73
+ esac