@cairnkeep/cli 2.3.0 → 2.4.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 (125) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +221 -6
  3. package/bin/cairn +43 -2
  4. package/claude/capability-contract/hooks/capability-command-finish.sh +81 -0
  5. package/claude/capability-contract/hooks/capability-command-start.sh +76 -0
  6. package/claude/hooks/compaction-capture.sh +34 -0
  7. package/claude/hooks/memory-capture.sh +47 -5
  8. package/claude/hooks/memory-wakeup.sh +55 -2
  9. package/docs/building-an-overlay.md +1 -1
  10. package/docs/design/meta-agent.md +439 -0
  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 +2 -2
  14. package/docs/learning/lessons/L03-first-project.md +1 -1
  15. package/docs/operating.md +531 -4
  16. package/docs/privacy-and-data-flow.md +417 -0
  17. package/docs/storage.md +252 -0
  18. package/examples/eval/README.md +42 -0
  19. package/examples/eval/adapter.json +12 -0
  20. package/examples/eval/bundled-fake.json +1 -0
  21. package/examples/eval/task-set.json +1 -0
  22. package/mcp-memory-server/dist/artifact-cli.js +184 -0
  23. package/mcp-memory-server/dist/artifact-schema.js +218 -0
  24. package/mcp-memory-server/dist/artifact-store.js +812 -0
  25. package/mcp-memory-server/dist/capability-adapter.js +286 -0
  26. package/mcp-memory-server/dist/capability-cli.js +361 -0
  27. package/mcp-memory-server/dist/capability-config.js +310 -0
  28. package/mcp-memory-server/dist/capability-harness.js +496 -0
  29. package/mcp-memory-server/dist/capability-registry.js +123 -0
  30. package/mcp-memory-server/dist/capability-schema.js +65 -0
  31. package/mcp-memory-server/dist/capability-store.js +431 -0
  32. package/mcp-memory-server/dist/compaction-normalize.js +267 -0
  33. package/mcp-memory-server/dist/eval-cli.js +523 -0
  34. package/mcp-memory-server/dist/eval-plan.js +346 -0
  35. package/mcp-memory-server/dist/eval-process.js +273 -0
  36. package/mcp-memory-server/dist/eval-report.js +609 -0
  37. package/mcp-memory-server/dist/eval-runner.js +827 -0
  38. package/mcp-memory-server/dist/eval-schema.js +368 -0
  39. package/mcp-memory-server/dist/eval-statistics.js +161 -0
  40. package/mcp-memory-server/dist/eval-workspace.js +313 -0
  41. package/mcp-memory-server/dist/failure-signature.js +141 -0
  42. package/mcp-memory-server/dist/index.js +600 -55
  43. package/mcp-memory-server/dist/node-cli.js +84 -0
  44. package/mcp-memory-server/dist/node-schema.js +170 -0
  45. package/mcp-memory-server/dist/node-store.js +455 -0
  46. package/mcp-memory-server/dist/note-cli.js +235 -0
  47. package/mcp-memory-server/dist/note-distiller.js +177 -0
  48. package/mcp-memory-server/dist/note-enrichment.js +93 -0
  49. package/mcp-memory-server/dist/note-schema.js +4 -0
  50. package/mcp-memory-server/dist/note-store.js +985 -0
  51. package/mcp-memory-server/dist/trajectory-cli.js +141 -0
  52. package/mcp-memory-server/dist/trajectory-normalize.js +448 -0
  53. package/mcp-memory-server/dist/trajectory-redaction.js +155 -0
  54. package/mcp-memory-server/dist/trajectory-schema.js +73 -0
  55. package/mcp-memory-server/dist/trajectory-store.js +339 -0
  56. package/mcp-memory-server/package.json +24 -2
  57. package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.219.json +9 -0
  58. package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.220.json +9 -0
  59. package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-event.json +6 -0
  60. package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-messages.json +119 -0
  61. package/mcp-memory-server/scripts/fixtures/compaction-unknown-version.json +17 -0
  62. package/opencode/capability-contract/plugins/capability-command.ts +319 -0
  63. package/opencode/command/graphify.md +25 -14
  64. package/opencode/plugins/memory-capture.ts +76 -10
  65. package/opencode/plugins/memory-wakeup.ts +58 -6
  66. package/package.json +9 -4
  67. package/pi/extensions/cairnkeep-trajectory.ts +55 -0
  68. package/schemas/artifact.schema.json +133 -0
  69. package/schemas/capability-callback.schema.json +68 -0
  70. package/schemas/capability-contract.schema.json +126 -0
  71. package/schemas/eval-adapter.schema.json +43 -0
  72. package/schemas/eval-protocol.schema.json +114 -0
  73. package/schemas/eval-report.schema.json +423 -0
  74. package/schemas/eval-task-set.schema.json +114 -0
  75. package/schemas/memory-node.schema.json +90 -0
  76. package/schemas/note.schema.json +112 -0
  77. package/schemas/trajectory-redaction.schema.json +25 -0
  78. package/schemas/trajectory.schema.json +82 -0
  79. package/scripts/bootstrap.sh +4 -0
  80. package/scripts/completion.sh +119 -5
  81. package/scripts/doctor.sh +284 -0
  82. package/scripts/fake-eval-adapter.mjs +120 -0
  83. package/scripts/fixtures/capability-harness-contracts.json +408 -0
  84. package/scripts/install-audit-timer.sh +3 -1
  85. package/scripts/lib/capability-opencode-plugin-harness.mjs +291 -0
  86. package/scripts/lib/trajectory-opencode-plugin-harness.mjs +25 -0
  87. package/scripts/lib/trajectory-pi-extension-harness.mjs +42 -0
  88. package/scripts/memory-wiki-audit.sh +49 -0
  89. package/scripts/smoke-bash32.sh +9 -0
  90. package/scripts/sync-claude-assets.sh +99 -6
  91. package/scripts/sync-opencode-graphify-assets.sh +24 -3
  92. package/scripts/sync-opencode-plugin-assets.sh +31 -5
  93. package/scripts/sync-opencode-security-assets.sh +24 -3
  94. package/scripts/sync-opencode-wiki-assets.sh +24 -3
  95. package/scripts/sync-pi-assets.sh +72 -0
  96. package/scripts/test-audit-timer.sh +98 -0
  97. package/scripts/test-bootstrap-untracked.sh +48 -0
  98. package/scripts/test-cli-dispatch.sh +41 -2
  99. package/scripts/test-compaction-hooks.sh +495 -0
  100. package/scripts/test-completion.sh +77 -0
  101. package/scripts/test-doctor.sh +348 -1
  102. package/scripts/test-eval-cli.sh +175 -0
  103. package/scripts/test-launcher-hooks.sh +602 -3
  104. package/scripts/test-notes-cli.sh +114 -0
  105. package/scripts/test-package-install.sh +251 -0
  106. package/scripts/test-phase16-node-lifecycle.sh +50 -0
  107. package/scripts/test-phase17-artifact-lifecycle.sh +370 -0
  108. package/scripts/test-phase18-capability-lifecycle.sh +504 -0
  109. package/scripts/test-phase18-harness-boundary.sh +1060 -0
  110. package/scripts/test-phase19-eval-lifecycle.sh +1015 -0
  111. package/scripts/test-trajectory-cli.sh +87 -0
  112. package/scripts/test-trajectory-hooks.sh +142 -0
  113. package/scripts/test-uninstall.sh +231 -5
  114. package/scripts/uninstall.sh +37 -5
  115. package/scripts/verify-dependency-security.mjs +121 -0
  116. package/scripts/verify-docs-parity.sh +527 -1
  117. package/scripts/verify-phase18-runtime-evidence.mjs +895 -0
  118. package/scripts/verify-phase19-runtime-evidence.mjs +947 -0
  119. package/templates/capabilities.json.template +7 -0
  120. package/templates/env.example.template +51 -0
  121. package/templates/memory-wiki-audit.service.template +1 -1
  122. package/templates/start-claude.sh.template +36 -0
  123. package/templates/start-opencode.sh.template +47 -5
  124. package/templates/start-pi.sh.template +30 -0
  125. package/templates/trajectory-redaction.json.template +4 -0
@@ -0,0 +1,408 @@
1
+ {
2
+ "schema_version": 1,
3
+ "fixture_policy": "Strict target-version shapes with synthetic, value-free samples only.",
4
+ "claude": {
5
+ "version": "2.1.220",
6
+ "source": {
7
+ "kind": "official-current-documentation",
8
+ "url": "https://code.claude.com/docs/en/hooks",
9
+ "verified_on": "2026-07-27",
10
+ "notes": "The documentation identifies version-specific behavior through 2.1.220-era fields; this fixture pins the supported contract to Claude Code 2.1.220."
11
+ },
12
+ "common_input": {
13
+ "required_fields": [
14
+ "session_id",
15
+ "transcript_path",
16
+ "cwd",
17
+ "hook_event_name"
18
+ ],
19
+ "optional_fields": [
20
+ "prompt_id",
21
+ "permission_mode",
22
+ "effort",
23
+ "agent_id",
24
+ "agent_type"
25
+ ],
26
+ "additional_properties": false
27
+ },
28
+ "events": {
29
+ "UserPromptExpansion": {
30
+ "phase": "admission-before-expansion",
31
+ "matcher_field": "command_name",
32
+ "can_block": true,
33
+ "required_fields": [
34
+ "session_id",
35
+ "transcript_path",
36
+ "cwd",
37
+ "hook_event_name",
38
+ "expansion_type",
39
+ "command_name",
40
+ "command_args",
41
+ "command_source",
42
+ "prompt"
43
+ ],
44
+ "optional_fields": [
45
+ "prompt_id",
46
+ "permission_mode",
47
+ "effort",
48
+ "agent_id",
49
+ "agent_type"
50
+ ],
51
+ "enum_fields": {
52
+ "hook_event_name": ["UserPromptExpansion"],
53
+ "expansion_type": ["slash_command", "mcp_prompt"]
54
+ },
55
+ "sample": {
56
+ "session_id": "session-fixture",
57
+ "transcript_path": "/fixture/transcript.jsonl",
58
+ "cwd": "/fixture/project",
59
+ "permission_mode": "default",
60
+ "hook_event_name": "UserPromptExpansion",
61
+ "expansion_type": "slash_command",
62
+ "command_name": "wiki-query",
63
+ "command_args": "",
64
+ "command_source": "project",
65
+ "prompt": "/wiki-query"
66
+ }
67
+ },
68
+ "UserPromptSubmit": {
69
+ "phase": "admission-before-processing",
70
+ "matcher_field": null,
71
+ "can_block": true,
72
+ "required_fields": [
73
+ "session_id",
74
+ "transcript_path",
75
+ "cwd",
76
+ "hook_event_name",
77
+ "prompt"
78
+ ],
79
+ "optional_fields": [
80
+ "prompt_id",
81
+ "permission_mode",
82
+ "effort",
83
+ "agent_id",
84
+ "agent_type"
85
+ ],
86
+ "enum_fields": {
87
+ "hook_event_name": ["UserPromptSubmit"]
88
+ },
89
+ "sample": {
90
+ "session_id": "session-fixture",
91
+ "transcript_path": "/fixture/transcript.jsonl",
92
+ "cwd": "/fixture/project",
93
+ "permission_mode": "default",
94
+ "hook_event_name": "UserPromptSubmit",
95
+ "prompt": "/wiki-query"
96
+ }
97
+ },
98
+ "Stop": {
99
+ "phase": "success-terminal",
100
+ "can_block": true,
101
+ "required_fields": [
102
+ "session_id",
103
+ "transcript_path",
104
+ "cwd",
105
+ "hook_event_name",
106
+ "stop_hook_active",
107
+ "last_assistant_message",
108
+ "background_tasks",
109
+ "session_crons"
110
+ ],
111
+ "optional_fields": [
112
+ "prompt_id",
113
+ "permission_mode",
114
+ "effort",
115
+ "agent_id",
116
+ "agent_type"
117
+ ],
118
+ "enum_fields": {
119
+ "hook_event_name": ["Stop"]
120
+ },
121
+ "sample": {
122
+ "session_id": "session-fixture",
123
+ "transcript_path": "/fixture/transcript.jsonl",
124
+ "cwd": "/fixture/project",
125
+ "hook_event_name": "Stop",
126
+ "stop_hook_active": false,
127
+ "last_assistant_message": "fixture-complete",
128
+ "background_tasks": [],
129
+ "session_crons": []
130
+ }
131
+ },
132
+ "StopFailure": {
133
+ "phase": "error-terminal",
134
+ "can_block": false,
135
+ "output_and_exit_ignored": true,
136
+ "required_fields": [
137
+ "session_id",
138
+ "transcript_path",
139
+ "cwd",
140
+ "hook_event_name",
141
+ "error"
142
+ ],
143
+ "optional_fields": [
144
+ "prompt_id",
145
+ "permission_mode",
146
+ "effort",
147
+ "agent_id",
148
+ "agent_type",
149
+ "error_details",
150
+ "last_assistant_message"
151
+ ],
152
+ "enum_fields": {
153
+ "hook_event_name": ["StopFailure"],
154
+ "error": [
155
+ "rate_limit",
156
+ "overloaded",
157
+ "authentication_failed",
158
+ "oauth_org_not_allowed",
159
+ "billing_error",
160
+ "invalid_request",
161
+ "model_not_found",
162
+ "server_error",
163
+ "max_output_tokens",
164
+ "unknown"
165
+ ]
166
+ },
167
+ "sample": {
168
+ "session_id": "session-fixture",
169
+ "transcript_path": "/fixture/transcript.jsonl",
170
+ "cwd": "/fixture/project",
171
+ "hook_event_name": "StopFailure",
172
+ "error": "server_error"
173
+ }
174
+ },
175
+ "CwdChanged": {
176
+ "phase": "identity-observation",
177
+ "can_block": false,
178
+ "required_fields": [
179
+ "session_id",
180
+ "transcript_path",
181
+ "cwd",
182
+ "hook_event_name",
183
+ "old_cwd",
184
+ "new_cwd"
185
+ ],
186
+ "optional_fields": [
187
+ "prompt_id",
188
+ "permission_mode",
189
+ "effort",
190
+ "agent_id",
191
+ "agent_type"
192
+ ],
193
+ "enum_fields": {
194
+ "hook_event_name": ["CwdChanged"]
195
+ },
196
+ "sample": {
197
+ "session_id": "session-fixture",
198
+ "transcript_path": "/fixture/transcript.jsonl",
199
+ "cwd": "/fixture/decoy",
200
+ "hook_event_name": "CwdChanged",
201
+ "old_cwd": "/fixture/project",
202
+ "new_cwd": "/fixture/decoy"
203
+ }
204
+ },
205
+ "SessionEnd": {
206
+ "phase": "abandonment-cleanup-only",
207
+ "can_block": false,
208
+ "required_fields": [
209
+ "session_id",
210
+ "transcript_path",
211
+ "cwd",
212
+ "hook_event_name",
213
+ "reason"
214
+ ],
215
+ "optional_fields": [
216
+ "prompt_id",
217
+ "permission_mode",
218
+ "effort",
219
+ "agent_id",
220
+ "agent_type"
221
+ ],
222
+ "enum_fields": {
223
+ "hook_event_name": ["SessionEnd"],
224
+ "reason": [
225
+ "clear",
226
+ "resume",
227
+ "logout",
228
+ "prompt_input_exit",
229
+ "bypass_permissions_disabled",
230
+ "other"
231
+ ]
232
+ },
233
+ "sample": {
234
+ "session_id": "session-fixture",
235
+ "transcript_path": "/fixture/transcript.jsonl",
236
+ "cwd": "/fixture/project",
237
+ "hook_event_name": "SessionEnd",
238
+ "reason": "other"
239
+ }
240
+ }
241
+ },
242
+ "outputs": {
243
+ "allow": {},
244
+ "block": {
245
+ "decision": "block",
246
+ "reason": "capability disabled"
247
+ },
248
+ "exit_code_block": 2
249
+ },
250
+ "lifecycle": {
251
+ "success_terminal": "Stop",
252
+ "error_terminal": "StopFailure",
253
+ "abandonment_only": "SessionEnd",
254
+ "identity_drift_signal": "CwdChanged"
255
+ }
256
+ },
257
+ "opencode": {
258
+ "version": "1.17.20",
259
+ "source": {
260
+ "kind": "official-tagged-source",
261
+ "repository": "https://github.com/anomalyco/opencode",
262
+ "tag": "v1.17.20",
263
+ "commit": "4473fc3c9055046183990a965d68df3db7ea6f62",
264
+ "plugin_types": "packages/plugin/src/index.ts",
265
+ "event_types": "packages/sdk/js/src/gen/types.gen.ts",
266
+ "dispatch": "packages/opencode/src/session/prompt.ts",
267
+ "verified_on": "2026-07-27"
268
+ },
269
+ "installed_analog": {
270
+ "version": "1.17.15",
271
+ "path": "@opencode-ai/plugin/dist/index.d.ts",
272
+ "authority": false,
273
+ "target_delta": "No command.execute.before signature delta was found; 1.17.20 event and dispatch source remains authoritative."
274
+ },
275
+ "hook": {
276
+ "name": "command.execute.before",
277
+ "phase": "admission-before-prompt",
278
+ "input": {
279
+ "required_fields": ["command", "sessionID", "arguments"],
280
+ "optional_fields": [],
281
+ "additional_properties": false,
282
+ "sample": {
283
+ "command": "wiki-query",
284
+ "sessionID": "session-fixture",
285
+ "arguments": ""
286
+ }
287
+ },
288
+ "output": {
289
+ "required_fields": ["parts"],
290
+ "optional_fields": [],
291
+ "additional_properties": false,
292
+ "sample": {
293
+ "parts": []
294
+ }
295
+ },
296
+ "blocking": "A rejected hook promise propagates before prompt() is called."
297
+ },
298
+ "dispose": {
299
+ "name": "dispose",
300
+ "phase": "plugin-shutdown",
301
+ "input_fields": [],
302
+ "additional_properties": false,
303
+ "source_file": "packages/plugin/src/index.ts",
304
+ "source_commit": "4473fc3c9055046183990a965d68df3db7ea6f62",
305
+ "purpose": "Release plugin-owned resources after the host stops using the plugin instance."
306
+ },
307
+ "events": {
308
+ "session.idle": {
309
+ "phase": "success-terminal",
310
+ "required_fields": ["type", "properties"],
311
+ "optional_fields": ["id"],
312
+ "properties_required_fields": ["sessionID"],
313
+ "properties_optional_fields": [],
314
+ "sample": {
315
+ "id": "event-fixture-idle",
316
+ "type": "session.idle",
317
+ "properties": {
318
+ "sessionID": "session-fixture"
319
+ }
320
+ }
321
+ },
322
+ "session.error": {
323
+ "phase": "error-terminal",
324
+ "required_fields": ["type", "properties"],
325
+ "optional_fields": ["id"],
326
+ "properties_required_fields": [],
327
+ "properties_optional_fields": ["sessionID", "error"],
328
+ "error_variants": [
329
+ "ProviderAuthError",
330
+ "UnknownError",
331
+ "MessageOutputLengthError",
332
+ "MessageAbortedError",
333
+ "APIError"
334
+ ],
335
+ "sample": {
336
+ "id": "event-fixture-error",
337
+ "type": "session.error",
338
+ "properties": {
339
+ "sessionID": "session-fixture"
340
+ }
341
+ }
342
+ },
343
+ "session.status": {
344
+ "phase": "status-terminal-when-idle",
345
+ "required_fields": ["type", "properties"],
346
+ "optional_fields": ["id"],
347
+ "properties_required_fields": ["sessionID", "status"],
348
+ "properties_optional_fields": [],
349
+ "status_variants": [
350
+ { "type": "idle" },
351
+ { "type": "retry", "attempt": 1, "message": "fixture-retry", "next": 2 },
352
+ { "type": "busy" }
353
+ ],
354
+ "sample": {
355
+ "id": "event-fixture-status",
356
+ "type": "session.status",
357
+ "properties": {
358
+ "sessionID": "session-fixture",
359
+ "status": {
360
+ "type": "idle"
361
+ }
362
+ }
363
+ }
364
+ },
365
+ "session.deleted": {
366
+ "phase": "abandonment-cleanup-only",
367
+ "required_fields": ["type", "properties"],
368
+ "optional_fields": ["id"],
369
+ "properties_required_fields": ["info"],
370
+ "properties_optional_fields": [],
371
+ "info_required_fields": [
372
+ "id",
373
+ "projectID",
374
+ "directory",
375
+ "title",
376
+ "version",
377
+ "time"
378
+ ],
379
+ "info_optional_fields": ["parentID", "summary", "share", "revert"],
380
+ "time_required_fields": ["created", "updated"],
381
+ "time_optional_fields": ["compacting"],
382
+ "sample": {
383
+ "id": "event-fixture-deleted",
384
+ "type": "session.deleted",
385
+ "properties": {
386
+ "info": {
387
+ "id": "session-fixture",
388
+ "projectID": "project-fixture",
389
+ "directory": "/fixture/project",
390
+ "title": "fixture",
391
+ "version": "1.17.20",
392
+ "time": {
393
+ "created": 1,
394
+ "updated": 2
395
+ }
396
+ }
397
+ }
398
+ }
399
+ }
400
+ },
401
+ "lifecycle": {
402
+ "success_terminals": ["session.idle", "session.status:idle"],
403
+ "error_terminal": "session.error",
404
+ "abandonment_only": "session.deleted",
405
+ "event_callback_is_awaited": false
406
+ }
407
+ }
408
+ }
@@ -3,7 +3,9 @@
3
3
  #
4
4
  # Renders a systemd user service + timer from templates/ and enables the timer,
5
5
  # so the deterministic memory/wiki invalidation audit runs on a schedule. A cron
6
- # alternative is printed for hosts without systemd.
6
+ # alternative is printed for hosts without systemd. When the inherited
7
+ # CAIRN_NOTE_DISTILLATION flag is enabled, the same job also launches the
8
+ # packaged one-shot notes command after the deterministic wiki scan.
7
9
  #
8
10
  # Usage: install-audit-timer.sh [--para-root PATH] [--on-calendar SPEC]
9
11
  # [--report PATH] [--render-only DIR]