@cairnkeep/cli 2.3.1 → 2.5.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 (151) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +232 -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 +4 -3
  10. package/docs/design/meta-agent.md +439 -0
  11. package/docs/harness-compatibility.md +117 -0
  12. package/docs/learning/CURRICULUM-MAP.md +91 -0
  13. package/docs/learning/FEATURE-GUIDE.md +86 -0
  14. package/docs/learning/PRODUCTION-PLAN.md +45 -14
  15. package/docs/learning/README.md +20 -1
  16. package/docs/learning/instructor-guide.md +6 -0
  17. package/docs/learning/lessons/L00-why-cairnkeep.md +20 -8
  18. package/docs/learning/lessons/L01-safe-trial.md +3 -3
  19. package/docs/learning/lessons/L02-installation.md +23 -5
  20. package/docs/learning/lessons/L03-first-project.md +7 -2
  21. package/docs/learning/lessons/L04-memory-fundamentals.md +4 -0
  22. package/docs/learning/lessons/L05-daily-workflow.md +4 -0
  23. package/docs/learning/lessons/L07-privacy-and-storage.md +3 -0
  24. package/docs/learning/lessons/L10-context-exploration.md +4 -2
  25. package/docs/learning/lessons/L12-managed-overlays.md +2 -0
  26. package/docs/learning/lessons/L13-session-evidence.md +71 -0
  27. package/docs/learning/lessons/L14-typed-memory.md +51 -0
  28. package/docs/learning/lessons/L15-capability-governance.md +56 -0
  29. package/docs/learning/lessons/L16-evaluation.md +67 -0
  30. package/docs/learning/lessons/L17-agent-boundary.md +55 -0
  31. package/docs/learning/templates/lesson-template.md +4 -1
  32. package/docs/learning/tracks/evidence-and-evaluation.md +20 -0
  33. package/docs/learning/tracks/operator.md +8 -2
  34. package/docs/learning/tracks/practitioner.md +6 -1
  35. package/docs/learning/tracks/quickstart.md +3 -0
  36. package/docs/learning/video-scripts/L00-why-cairnkeep.md +21 -17
  37. package/docs/learning/video-scripts/L02-installation.md +9 -2
  38. package/docs/learning/video-scripts/L03-first-project.md +3 -0
  39. package/docs/operating.md +567 -7
  40. package/docs/privacy-and-data-flow.md +417 -0
  41. package/docs/storage.md +252 -0
  42. package/examples/eval/README.md +42 -0
  43. package/examples/eval/adapter.json +12 -0
  44. package/examples/eval/bundled-fake.json +1 -0
  45. package/examples/eval/task-set.json +1 -0
  46. package/mcp-memory-server/dist/artifact-cli.js +184 -0
  47. package/mcp-memory-server/dist/artifact-schema.js +218 -0
  48. package/mcp-memory-server/dist/artifact-store.js +812 -0
  49. package/mcp-memory-server/dist/capability-adapter.js +286 -0
  50. package/mcp-memory-server/dist/capability-cli.js +361 -0
  51. package/mcp-memory-server/dist/capability-config.js +310 -0
  52. package/mcp-memory-server/dist/capability-harness.js +496 -0
  53. package/mcp-memory-server/dist/capability-registry.js +123 -0
  54. package/mcp-memory-server/dist/capability-schema.js +65 -0
  55. package/mcp-memory-server/dist/capability-store.js +431 -0
  56. package/mcp-memory-server/dist/compaction-normalize.js +267 -0
  57. package/mcp-memory-server/dist/eval-cli.js +523 -0
  58. package/mcp-memory-server/dist/eval-plan.js +346 -0
  59. package/mcp-memory-server/dist/eval-process.js +273 -0
  60. package/mcp-memory-server/dist/eval-report.js +609 -0
  61. package/mcp-memory-server/dist/eval-runner.js +827 -0
  62. package/mcp-memory-server/dist/eval-schema.js +368 -0
  63. package/mcp-memory-server/dist/eval-statistics.js +161 -0
  64. package/mcp-memory-server/dist/eval-workspace.js +313 -0
  65. package/mcp-memory-server/dist/failure-signature.js +141 -0
  66. package/mcp-memory-server/dist/index.js +600 -55
  67. package/mcp-memory-server/dist/node-cli.js +84 -0
  68. package/mcp-memory-server/dist/node-schema.js +170 -0
  69. package/mcp-memory-server/dist/node-store.js +455 -0
  70. package/mcp-memory-server/dist/note-cli.js +235 -0
  71. package/mcp-memory-server/dist/note-distiller.js +177 -0
  72. package/mcp-memory-server/dist/note-enrichment.js +93 -0
  73. package/mcp-memory-server/dist/note-schema.js +4 -0
  74. package/mcp-memory-server/dist/note-store.js +985 -0
  75. package/mcp-memory-server/dist/trajectory-cli.js +141 -0
  76. package/mcp-memory-server/dist/trajectory-normalize.js +448 -0
  77. package/mcp-memory-server/dist/trajectory-redaction.js +155 -0
  78. package/mcp-memory-server/dist/trajectory-schema.js +73 -0
  79. package/mcp-memory-server/dist/trajectory-store.js +339 -0
  80. package/mcp-memory-server/package.json +24 -2
  81. package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.219.json +9 -0
  82. package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.220.json +9 -0
  83. package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-event.json +6 -0
  84. package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-messages.json +119 -0
  85. package/mcp-memory-server/scripts/fixtures/compaction-unknown-version.json +17 -0
  86. package/opencode/capability-contract/plugins/capability-command.ts +319 -0
  87. package/opencode/command/graphify.md +25 -14
  88. package/opencode/plugins/memory-capture.ts +76 -10
  89. package/opencode/plugins/memory-wakeup.ts +58 -6
  90. package/package.json +8 -4
  91. package/pi/extensions/cairnkeep-trajectory.ts +55 -0
  92. package/schemas/artifact.schema.json +133 -0
  93. package/schemas/capability-callback.schema.json +68 -0
  94. package/schemas/capability-contract.schema.json +126 -0
  95. package/schemas/eval-adapter.schema.json +43 -0
  96. package/schemas/eval-protocol.schema.json +114 -0
  97. package/schemas/eval-report.schema.json +423 -0
  98. package/schemas/eval-task-set.schema.json +114 -0
  99. package/schemas/memory-node.schema.json +90 -0
  100. package/schemas/note.schema.json +112 -0
  101. package/schemas/trajectory-redaction.schema.json +25 -0
  102. package/schemas/trajectory.schema.json +82 -0
  103. package/scripts/bootstrap.sh +6 -0
  104. package/scripts/completion.sh +119 -5
  105. package/scripts/doctor.sh +284 -0
  106. package/scripts/fake-eval-adapter.mjs +120 -0
  107. package/scripts/fixtures/capability-harness-contracts.json +408 -0
  108. package/scripts/install-audit-timer.sh +3 -1
  109. package/scripts/lib/capability-opencode-plugin-harness.mjs +291 -0
  110. package/scripts/lib/trajectory-opencode-plugin-harness.mjs +25 -0
  111. package/scripts/lib/trajectory-pi-extension-harness.mjs +42 -0
  112. package/scripts/memory-wiki-audit.sh +49 -0
  113. package/scripts/smoke-bash32.sh +9 -0
  114. package/scripts/sync-claude-assets.sh +99 -6
  115. package/scripts/sync-opencode-graphify-assets.sh +24 -3
  116. package/scripts/sync-opencode-plugin-assets.sh +31 -5
  117. package/scripts/sync-opencode-security-assets.sh +24 -3
  118. package/scripts/sync-opencode-wiki-assets.sh +24 -3
  119. package/scripts/sync-pi-assets.sh +72 -0
  120. package/scripts/test-audit-timer.sh +98 -0
  121. package/scripts/test-bootstrap-untracked.sh +49 -0
  122. package/scripts/test-cli-dispatch.sh +41 -2
  123. package/scripts/test-compaction-hooks.sh +495 -0
  124. package/scripts/test-completion.sh +77 -0
  125. package/scripts/test-doctor.sh +348 -1
  126. package/scripts/test-eval-cli.sh +175 -0
  127. package/scripts/test-launcher-hooks.sh +630 -3
  128. package/scripts/test-learning-docs.sh +20 -4
  129. package/scripts/test-notes-cli.sh +114 -0
  130. package/scripts/test-package-install.sh +254 -0
  131. package/scripts/test-phase16-node-lifecycle.sh +50 -0
  132. package/scripts/test-phase17-artifact-lifecycle.sh +370 -0
  133. package/scripts/test-phase18-capability-lifecycle.sh +504 -0
  134. package/scripts/test-phase18-harness-boundary.sh +1060 -0
  135. package/scripts/test-phase19-eval-lifecycle.sh +1015 -0
  136. package/scripts/test-trajectory-cli.sh +87 -0
  137. package/scripts/test-trajectory-hooks.sh +142 -0
  138. package/scripts/test-uninstall.sh +231 -5
  139. package/scripts/uninstall.sh +38 -5
  140. package/scripts/verify-dependency-security.mjs +121 -0
  141. package/scripts/verify-docs-parity.sh +527 -1
  142. package/scripts/verify-phase18-runtime-evidence.mjs +895 -0
  143. package/scripts/verify-phase19-runtime-evidence.mjs +947 -0
  144. package/templates/capabilities.json.template +7 -0
  145. package/templates/env.example.template +51 -0
  146. package/templates/memory-wiki-audit.service.template +1 -1
  147. package/templates/start-claude.sh.template +36 -0
  148. package/templates/start-kimi.sh.template +39 -0
  149. package/templates/start-opencode.sh.template +47 -5
  150. package/templates/start-pi.sh.template +30 -0
  151. package/templates/trajectory-redaction.json.template +4 -0
@@ -0,0 +1,126 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/cairnkeep/cairnkeep/main/schemas/capability-contract.schema.json",
4
+ "title": "Cairnkeep capability contract",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/managedConfig" },
7
+ { "$ref": "#/$defs/status" }
8
+ ],
9
+ "$defs": {
10
+ "capabilityId": {
11
+ "enum": [
12
+ "memory.write",
13
+ "memory.search",
14
+ "notes.distill",
15
+ "wiki",
16
+ "graph",
17
+ "security.audit",
18
+ "route.check",
19
+ "context.explore"
20
+ ]
21
+ },
22
+ "capabilityKind": {
23
+ "enum": ["mcp-tool", "offline-job", "operating-workflow"]
24
+ },
25
+ "source": {
26
+ "enum": ["environment", "project", "compatibility"]
27
+ },
28
+ "capabilityOverrides": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "properties": {
32
+ "memory.write": { "type": "boolean" },
33
+ "memory.search": { "type": "boolean" },
34
+ "notes.distill": { "type": "boolean" },
35
+ "wiki": { "type": "boolean" },
36
+ "graph": { "type": "boolean" },
37
+ "security.audit": { "type": "boolean" },
38
+ "route.check": { "type": "boolean" },
39
+ "context.explore": { "type": "boolean" }
40
+ }
41
+ },
42
+ "loggingConfig": {
43
+ "type": "object",
44
+ "additionalProperties": false,
45
+ "properties": {
46
+ "callbacks": { "type": "boolean" }
47
+ }
48
+ },
49
+ "managedConfig": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["schema_version", "capabilities", "logging"],
53
+ "properties": {
54
+ "schema_version": { "const": 1 },
55
+ "capabilities": { "$ref": "#/$defs/capabilityOverrides" },
56
+ "logging": { "$ref": "#/$defs/loggingConfig" }
57
+ }
58
+ },
59
+ "statusRow": {
60
+ "type": "object",
61
+ "additionalProperties": false,
62
+ "required": ["id", "kind", "enabled", "source", "restart_required"],
63
+ "properties": {
64
+ "id": { "$ref": "#/$defs/capabilityId" },
65
+ "kind": { "$ref": "#/$defs/capabilityKind" },
66
+ "enabled": { "type": "boolean" },
67
+ "source": { "$ref": "#/$defs/source" },
68
+ "restart_required": { "type": "boolean" }
69
+ }
70
+ },
71
+ "loggingStatus": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["enabled", "source"],
75
+ "properties": {
76
+ "enabled": { "type": "boolean" },
77
+ "source": { "$ref": "#/$defs/source" }
78
+ }
79
+ },
80
+ "issue": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": ["code"],
84
+ "properties": {
85
+ "code": {
86
+ "enum": [
87
+ "invalid-config",
88
+ "unknown-capability",
89
+ "invalid-capability-value",
90
+ "invalid-logging-value"
91
+ ]
92
+ },
93
+ "capability_id": { "$ref": "#/$defs/capabilityId" },
94
+ "setting": { "const": "logging.callbacks" }
95
+ }
96
+ },
97
+ "status": {
98
+ "type": "object",
99
+ "additionalProperties": false,
100
+ "required": [
101
+ "schema_version",
102
+ "contract_enabled",
103
+ "logging",
104
+ "configuration_digest",
105
+ "capabilities",
106
+ "issues"
107
+ ],
108
+ "properties": {
109
+ "schema_version": { "const": 1 },
110
+ "contract_enabled": { "type": "boolean" },
111
+ "logging": { "$ref": "#/$defs/loggingStatus" },
112
+ "configuration_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
113
+ "capabilities": {
114
+ "type": "array",
115
+ "minItems": 8,
116
+ "maxItems": 8,
117
+ "items": { "$ref": "#/$defs/statusRow" }
118
+ },
119
+ "issues": {
120
+ "type": "array",
121
+ "items": { "$ref": "#/$defs/issue" }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/cairnkeep/cairnkeep/main/schemas/eval-adapter.schema.json",
4
+ "title": "Cairnkeep evaluation adapter configuration v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema_version", "id", "command", "turn_semantics"],
8
+ "properties": {
9
+ "schema_version": { "const": 1 },
10
+ "id": { "$ref": "#/$defs/identifier" },
11
+ "command": { "$ref": "#/$defs/command" },
12
+ "turn_semantics": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["id", "description"],
16
+ "properties": {
17
+ "id": { "$ref": "#/$defs/identifier" },
18
+ "description": { "type": "string", "minLength": 1, "maxLength": 1024 }
19
+ }
20
+ }
21
+ },
22
+ "$defs": {
23
+ "identifier": {
24
+ "type": "string",
25
+ "minLength": 1,
26
+ "maxLength": 128,
27
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
28
+ },
29
+ "command": {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "required": ["program", "args"],
33
+ "properties": {
34
+ "program": { "type": "string", "minLength": 1, "maxLength": 4096, "pattern": "^[^\\u0000\\r\\n]+$" },
35
+ "args": {
36
+ "type": "array",
37
+ "maxItems": 256,
38
+ "items": { "type": "string", "maxLength": 16384, "pattern": "^[^\\u0000]*$" }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/cairnkeep/cairnkeep/main/schemas/eval-protocol.schema.json",
4
+ "title": "Cairnkeep evaluation adapter protocol v1",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/request" },
7
+ { "$ref": "#/$defs/result" }
8
+ ],
9
+ "$defs": {
10
+ "identifier": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$" },
11
+ "reference": { "type": "string", "minLength": 1, "maxLength": 1024, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/-]*$" },
12
+ "relativePath": {
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "maxLength": 1024,
16
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)(?!.*//)(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$"
17
+ },
18
+ "digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
19
+ "nonnegativeInteger": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
20
+ "limits": {
21
+ "type": "object",
22
+ "additionalProperties": false,
23
+ "required": ["elapsed_ms", "stdout_bytes"],
24
+ "properties": {
25
+ "elapsed_ms": { "type": "integer", "minimum": 1, "maximum": 86400000 },
26
+ "stdout_bytes": { "type": "integer", "minimum": 1, "maximum": 16777216 }
27
+ }
28
+ },
29
+ "request": {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "required": ["schema_version", "experiment_id", "task_id", "arm", "repetition", "pass", "workspace_path", "notes_path", "input", "limits", "seed", "expected_capability_digest", "output_path"],
33
+ "properties": {
34
+ "schema_version": { "const": 1 },
35
+ "experiment_id": { "$ref": "#/$defs/identifier" },
36
+ "task_id": { "$ref": "#/$defs/identifier" },
37
+ "arm": { "enum": ["baseline", "treatment"] },
38
+ "repetition": { "$ref": "#/$defs/nonnegativeInteger" },
39
+ "pass": { "enum": ["run1", "run2"] },
40
+ "workspace_path": { "$ref": "#/$defs/relativePath" },
41
+ "notes_path": { "oneOf": [{ "$ref": "#/$defs/relativePath" }, { "type": "null" }] },
42
+ "input": { "type": "string", "maxLength": 1048576 },
43
+ "limits": { "$ref": "#/$defs/limits" },
44
+ "seed": { "type": "string", "minLength": 1, "maxLength": 256 },
45
+ "expected_capability_digest": { "$ref": "#/$defs/digest" },
46
+ "output_path": { "$ref": "#/$defs/relativePath" }
47
+ }
48
+ },
49
+ "usage": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "properties": {
53
+ "input_tokens": { "$ref": "#/$defs/nonnegativeInteger" },
54
+ "output_tokens": { "$ref": "#/$defs/nonnegativeInteger" },
55
+ "reasoning_tokens": { "$ref": "#/$defs/nonnegativeInteger" },
56
+ "cache_read_tokens": { "$ref": "#/$defs/nonnegativeInteger" },
57
+ "cache_write_tokens": { "$ref": "#/$defs/nonnegativeInteger" },
58
+ "total_tokens": { "$ref": "#/$defs/nonnegativeInteger" }
59
+ }
60
+ },
61
+ "component": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": ["id"],
65
+ "properties": {
66
+ "id": { "$ref": "#/$defs/identifier" },
67
+ "version": { "type": "string", "minLength": 1, "maxLength": 128 }
68
+ }
69
+ },
70
+ "result": {
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "required": ["schema_version", "status"],
74
+ "properties": {
75
+ "schema_version": { "const": 1 },
76
+ "status": { "enum": ["completed", "adapter_error"] },
77
+ "error_code": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[a-z0-9][a-z0-9._-]*$" },
78
+ "turns": {
79
+ "type": "object",
80
+ "additionalProperties": false,
81
+ "required": ["value", "semantics"],
82
+ "properties": {
83
+ "value": { "$ref": "#/$defs/nonnegativeInteger" },
84
+ "semantics": { "$ref": "#/$defs/identifier" }
85
+ }
86
+ },
87
+ "usage": { "$ref": "#/$defs/usage" },
88
+ "cost": {
89
+ "type": "object",
90
+ "additionalProperties": false,
91
+ "required": ["amount", "currency"],
92
+ "properties": {
93
+ "amount": { "type": "number", "minimum": 0 },
94
+ "currency": { "type": "string", "pattern": "^[A-Z]{3}$" }
95
+ }
96
+ },
97
+ "harness": { "$ref": "#/$defs/component" },
98
+ "adapter": { "$ref": "#/$defs/component" },
99
+ "model": {
100
+ "type": "object",
101
+ "additionalProperties": false,
102
+ "required": ["id"],
103
+ "properties": {
104
+ "id": { "$ref": "#/$defs/identifier" },
105
+ "config_id": { "$ref": "#/$defs/identifier" }
106
+ }
107
+ },
108
+ "observed_capability_digest": { "$ref": "#/$defs/digest" },
109
+ "trajectory_ref": { "$ref": "#/$defs/reference" },
110
+ "artifact_refs": { "type": "array", "maxItems": 10000, "items": { "$ref": "#/$defs/reference" } }
111
+ }
112
+ }
113
+ }
114
+ }