@cairnkeep/cli 2.3.1 → 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.
- package/CHANGELOG.md +69 -0
- package/README.md +221 -6
- package/bin/cairn +43 -2
- package/claude/capability-contract/hooks/capability-command-finish.sh +81 -0
- package/claude/capability-contract/hooks/capability-command-start.sh +76 -0
- package/claude/hooks/compaction-capture.sh +34 -0
- package/claude/hooks/memory-capture.sh +47 -5
- package/claude/hooks/memory-wakeup.sh +55 -2
- package/docs/building-an-overlay.md +1 -1
- package/docs/design/meta-agent.md +439 -0
- package/docs/learning/lessons/L00-why-cairnkeep.md +1 -1
- package/docs/learning/lessons/L01-safe-trial.md +3 -3
- package/docs/learning/lessons/L02-installation.md +2 -2
- package/docs/learning/lessons/L03-first-project.md +1 -1
- package/docs/operating.md +531 -4
- package/docs/privacy-and-data-flow.md +417 -0
- package/docs/storage.md +252 -0
- package/examples/eval/README.md +42 -0
- package/examples/eval/adapter.json +12 -0
- package/examples/eval/bundled-fake.json +1 -0
- package/examples/eval/task-set.json +1 -0
- package/mcp-memory-server/dist/artifact-cli.js +184 -0
- package/mcp-memory-server/dist/artifact-schema.js +218 -0
- package/mcp-memory-server/dist/artifact-store.js +812 -0
- package/mcp-memory-server/dist/capability-adapter.js +286 -0
- package/mcp-memory-server/dist/capability-cli.js +361 -0
- package/mcp-memory-server/dist/capability-config.js +310 -0
- package/mcp-memory-server/dist/capability-harness.js +496 -0
- package/mcp-memory-server/dist/capability-registry.js +123 -0
- package/mcp-memory-server/dist/capability-schema.js +65 -0
- package/mcp-memory-server/dist/capability-store.js +431 -0
- package/mcp-memory-server/dist/compaction-normalize.js +267 -0
- package/mcp-memory-server/dist/eval-cli.js +523 -0
- package/mcp-memory-server/dist/eval-plan.js +346 -0
- package/mcp-memory-server/dist/eval-process.js +273 -0
- package/mcp-memory-server/dist/eval-report.js +609 -0
- package/mcp-memory-server/dist/eval-runner.js +827 -0
- package/mcp-memory-server/dist/eval-schema.js +368 -0
- package/mcp-memory-server/dist/eval-statistics.js +161 -0
- package/mcp-memory-server/dist/eval-workspace.js +313 -0
- package/mcp-memory-server/dist/failure-signature.js +141 -0
- package/mcp-memory-server/dist/index.js +600 -55
- package/mcp-memory-server/dist/node-cli.js +84 -0
- package/mcp-memory-server/dist/node-schema.js +170 -0
- package/mcp-memory-server/dist/node-store.js +455 -0
- package/mcp-memory-server/dist/note-cli.js +235 -0
- package/mcp-memory-server/dist/note-distiller.js +177 -0
- package/mcp-memory-server/dist/note-enrichment.js +93 -0
- package/mcp-memory-server/dist/note-schema.js +4 -0
- package/mcp-memory-server/dist/note-store.js +985 -0
- package/mcp-memory-server/dist/trajectory-cli.js +141 -0
- package/mcp-memory-server/dist/trajectory-normalize.js +448 -0
- package/mcp-memory-server/dist/trajectory-redaction.js +155 -0
- package/mcp-memory-server/dist/trajectory-schema.js +73 -0
- package/mcp-memory-server/dist/trajectory-store.js +339 -0
- package/mcp-memory-server/package.json +24 -2
- package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.219.json +9 -0
- package/mcp-memory-server/scripts/fixtures/compaction-claude-code-2.1.220.json +9 -0
- package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-event.json +6 -0
- package/mcp-memory-server/scripts/fixtures/compaction-opencode-1.17.20-messages.json +119 -0
- package/mcp-memory-server/scripts/fixtures/compaction-unknown-version.json +17 -0
- package/opencode/capability-contract/plugins/capability-command.ts +319 -0
- package/opencode/command/graphify.md +25 -14
- package/opencode/plugins/memory-capture.ts +76 -10
- package/opencode/plugins/memory-wakeup.ts +58 -6
- package/package.json +8 -4
- package/pi/extensions/cairnkeep-trajectory.ts +55 -0
- package/schemas/artifact.schema.json +133 -0
- package/schemas/capability-callback.schema.json +68 -0
- package/schemas/capability-contract.schema.json +126 -0
- package/schemas/eval-adapter.schema.json +43 -0
- package/schemas/eval-protocol.schema.json +114 -0
- package/schemas/eval-report.schema.json +423 -0
- package/schemas/eval-task-set.schema.json +114 -0
- package/schemas/memory-node.schema.json +90 -0
- package/schemas/note.schema.json +112 -0
- package/schemas/trajectory-redaction.schema.json +25 -0
- package/schemas/trajectory.schema.json +82 -0
- package/scripts/bootstrap.sh +4 -0
- package/scripts/completion.sh +119 -5
- package/scripts/doctor.sh +284 -0
- package/scripts/fake-eval-adapter.mjs +120 -0
- package/scripts/fixtures/capability-harness-contracts.json +408 -0
- package/scripts/install-audit-timer.sh +3 -1
- package/scripts/lib/capability-opencode-plugin-harness.mjs +291 -0
- package/scripts/lib/trajectory-opencode-plugin-harness.mjs +25 -0
- package/scripts/lib/trajectory-pi-extension-harness.mjs +42 -0
- package/scripts/memory-wiki-audit.sh +49 -0
- package/scripts/smoke-bash32.sh +9 -0
- package/scripts/sync-claude-assets.sh +99 -6
- package/scripts/sync-opencode-graphify-assets.sh +24 -3
- package/scripts/sync-opencode-plugin-assets.sh +31 -5
- package/scripts/sync-opencode-security-assets.sh +24 -3
- package/scripts/sync-opencode-wiki-assets.sh +24 -3
- package/scripts/sync-pi-assets.sh +72 -0
- package/scripts/test-audit-timer.sh +98 -0
- package/scripts/test-bootstrap-untracked.sh +48 -0
- package/scripts/test-cli-dispatch.sh +41 -2
- package/scripts/test-compaction-hooks.sh +495 -0
- package/scripts/test-completion.sh +77 -0
- package/scripts/test-doctor.sh +348 -1
- package/scripts/test-eval-cli.sh +175 -0
- package/scripts/test-launcher-hooks.sh +602 -3
- package/scripts/test-notes-cli.sh +114 -0
- package/scripts/test-package-install.sh +251 -0
- package/scripts/test-phase16-node-lifecycle.sh +50 -0
- package/scripts/test-phase17-artifact-lifecycle.sh +370 -0
- package/scripts/test-phase18-capability-lifecycle.sh +504 -0
- package/scripts/test-phase18-harness-boundary.sh +1060 -0
- package/scripts/test-phase19-eval-lifecycle.sh +1015 -0
- package/scripts/test-trajectory-cli.sh +87 -0
- package/scripts/test-trajectory-hooks.sh +142 -0
- package/scripts/test-uninstall.sh +231 -5
- package/scripts/uninstall.sh +37 -5
- package/scripts/verify-dependency-security.mjs +121 -0
- package/scripts/verify-docs-parity.sh +527 -1
- package/scripts/verify-phase18-runtime-evidence.mjs +895 -0
- package/scripts/verify-phase19-runtime-evidence.mjs +947 -0
- package/templates/capabilities.json.template +7 -0
- package/templates/env.example.template +51 -0
- package/templates/memory-wiki-audit.service.template +1 -1
- package/templates/start-claude.sh.template +36 -0
- package/templates/start-opencode.sh.template +47 -5
- package/templates/start-pi.sh.template +30 -0
- package/templates/trajectory-redaction.json.template +4 -0
|
@@ -17,6 +17,57 @@
|
|
|
17
17
|
# scopes default to ~/.cairnkeep; project scope uses <server-cwd>/.agentfs/.
|
|
18
18
|
# CAIRN_AGENTFS_BASE_DIR=~/.cairnkeep
|
|
19
19
|
#
|
|
20
|
+
# Typed metadata, filters, logical note address spaces, and memory_import are
|
|
21
|
+
# OFF by default. Restart the memory server after changing this construction-
|
|
22
|
+
# time tool-schema flag. No model, API key, or network endpoint is required.
|
|
23
|
+
# CAIRN_TYPED_MEMORY_NODES=1
|
|
24
|
+
#
|
|
25
|
+
# The managed capability contract is OFF by default. Project state is managed
|
|
26
|
+
# with `cairn capabilities`; these environment variables are optional strict
|
|
27
|
+
# per-process overrides. Strict booleans: 1 | true | yes | on; 0 | false | no | off.
|
|
28
|
+
# Leave every key below unset unless the current process needs an explicit
|
|
29
|
+
# override. MCP capability changes require a memory-server restart.
|
|
30
|
+
# CAIRN_CAPABILITY_CONTRACT=
|
|
31
|
+
# CAIRN_CAPABILITY_LOGGING=
|
|
32
|
+
# CAIRN_CAPABILITY_MEMORY_WRITE=
|
|
33
|
+
# CAIRN_CAPABILITY_MEMORY_SEARCH=
|
|
34
|
+
# CAIRN_CAPABILITY_NOTES_DISTILL=
|
|
35
|
+
# CAIRN_CAPABILITY_WIKI=
|
|
36
|
+
# CAIRN_CAPABILITY_GRAPH=
|
|
37
|
+
# CAIRN_CAPABILITY_SECURITY_AUDIT=
|
|
38
|
+
# CAIRN_CAPABILITY_ROUTE_CHECK=
|
|
39
|
+
# CAIRN_CAPABILITY_CONTEXT_EXPLORE=
|
|
40
|
+
#
|
|
41
|
+
# CAIRN_NOTE_DISTILLATION remains a compatibility input for the existing
|
|
42
|
+
# offline note job; enabling the master contract does not enable notes or graph.
|
|
43
|
+
# CAIRN_NOTE_DISTILLATION=
|
|
44
|
+
# Callback logging also requires the master contract and local capture consent:
|
|
45
|
+
# CAIRN_TRAJECTORY_CAPTURE is separate required consent and remains OFF by default.
|
|
46
|
+
#
|
|
47
|
+
# Structured session trajectories are local and OFF by default. When enabled,
|
|
48
|
+
# Claude Code SessionEnd and OpenCode session-idle capture redacted events in
|
|
49
|
+
# <project>/.agentfs/trajectory.db. See docs/privacy-and-data-flow.md first.
|
|
50
|
+
# CAIRN_TRAJECTORY_CAPTURE=1
|
|
51
|
+
# CAIRN_TRAJECTORY_SESSION_MAX_BYTES=5242880
|
|
52
|
+
# CAIRN_TRAJECTORY_STORE_MAX_BYTES=268435456
|
|
53
|
+
# CAIRN_TRAJECTORY_RETENTION_DAYS=30
|
|
54
|
+
# Bootstrap creates .ai/trajectory-redaction.json for optional custom patterns.
|
|
55
|
+
# CAIRN_TRAJECTORY_REDACTION_FILE=.ai/trajectory-redaction.json
|
|
56
|
+
#
|
|
57
|
+
# Harness-produced compaction continuity and explicit artifact access are local
|
|
58
|
+
# and OFF by default. Either capability may be enabled independently; neither
|
|
59
|
+
# needs a model, API key, or network endpoint. HTTP artifact tools require the
|
|
60
|
+
# separate HTTP flag in addition to the existing authenticated HTTP settings.
|
|
61
|
+
# CAIRN_COMPACTION_CAPTURE=1
|
|
62
|
+
# CAIRN_ARTIFACT_STORE=1
|
|
63
|
+
# CAIRN_ARTIFACT_HTTP=1
|
|
64
|
+
# CAIRN_ARTIFACT_MAX_BYTES=1048576
|
|
65
|
+
# CAIRN_ARTIFACT_SESSION_MAX_BYTES=16777216
|
|
66
|
+
# CAIRN_ARTIFACT_STORE_MAX_BYTES=268435456
|
|
67
|
+
# CAIRN_ARTIFACT_RETENTION_DAYS=30
|
|
68
|
+
# CAIRN_COMPACTION_MAX_REVISIONS=8
|
|
69
|
+
# CAIRN_ARTIFACT_GENERATED_FILE_SNAPSHOT_MAX_BYTES=262144
|
|
70
|
+
#
|
|
20
71
|
# The memory server runs locally over stdio by default. These HTTP settings are
|
|
21
72
|
# for the SERVER host of an explicit remote deployment, not a normal local
|
|
22
73
|
# client. Setting MCP_HTTP_PORT REQUIRES a bearer token, or startup fails.
|
|
@@ -15,6 +15,31 @@
|
|
|
15
15
|
# with $CAIRN_EXIT_STATUS set to the harness exit code.
|
|
16
16
|
set -euo pipefail
|
|
17
17
|
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
18
|
+
|
|
19
|
+
capability_contract_enabled() {
|
|
20
|
+
local value="${CAIRN_CAPABILITY_CONTRACT:-}"
|
|
21
|
+
value="${value#"${value%%[![:space:]]*}"}"
|
|
22
|
+
value="${value%"${value##*[![:space:]]}"}"
|
|
23
|
+
case "$value" in
|
|
24
|
+
1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Oo][Nn]) return 0 ;;
|
|
25
|
+
*) return 1 ;;
|
|
26
|
+
esac
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resolve_cairn_root() {
|
|
30
|
+
local source dir
|
|
31
|
+
if ! source=$(type -P cairn); then
|
|
32
|
+
echo "cairn: capability contract requires the cairn executable on PATH" >&2
|
|
33
|
+
return 127
|
|
34
|
+
fi
|
|
35
|
+
while [[ -L "$source" ]]; do
|
|
36
|
+
dir=$(cd -P "$(dirname "$source")" && pwd)
|
|
37
|
+
source=$(readlink "$source")
|
|
38
|
+
[[ "$source" == /* ]] || source="$dir/$source"
|
|
39
|
+
done
|
|
40
|
+
cd -P "$(dirname "$source")/.." && pwd
|
|
41
|
+
}
|
|
42
|
+
|
|
18
43
|
if [[ -f "$ROOT_DIR/.ai/.env" ]]; then
|
|
19
44
|
set -a
|
|
20
45
|
# shellcheck disable=SC1091
|
|
@@ -25,6 +50,17 @@ if [[ -f "$ROOT_DIR/.ai/pre-launch.sh" ]]; then
|
|
|
25
50
|
# shellcheck disable=SC1091
|
|
26
51
|
. "$ROOT_DIR/.ai/pre-launch.sh"
|
|
27
52
|
fi
|
|
53
|
+
|
|
54
|
+
if capability_contract_enabled; then
|
|
55
|
+
CAIRN_RUNTIME_ROOT=$(resolve_cairn_root)
|
|
56
|
+
node "$CAIRN_RUNTIME_ROOT/mcp-memory-server/dist/capability-cli.js" \
|
|
57
|
+
harness-recover </dev/null >/dev/null 2>&1 || true
|
|
58
|
+
CLAUDE_CAPABILITY_ROOT="$ROOT_DIR/.ai/capability-contract/claude"
|
|
59
|
+
"$CAIRN_RUNTIME_ROOT/scripts/sync-claude-assets.sh" \
|
|
60
|
+
--apply --capability-overlay --live-root "$CLAUDE_CAPABILITY_ROOT" >/dev/null
|
|
61
|
+
export CLAUDE_CONFIG_DIR="$CLAUDE_CAPABILITY_ROOT"
|
|
62
|
+
fi
|
|
63
|
+
|
|
28
64
|
cd "$ROOT_DIR"
|
|
29
65
|
|
|
30
66
|
launch_args=()
|
|
@@ -6,11 +6,37 @@
|
|
|
6
6
|
# Wrapper seams (all optional, all no-ops when absent):
|
|
7
7
|
# .ai/pre-launch.sh sourced after .env, before launch. May export env
|
|
8
8
|
# or abort the launch by returning / exiting non-zero.
|
|
9
|
-
# CAIRN_EXTRA_SETTINGS path to an OpenCode config file layered via
|
|
9
|
+
# CAIRN_EXTRA_SETTINGS path to an OpenCode config file layered via
|
|
10
|
+
# OPENCODE_CONFIG.
|
|
10
11
|
# .ai/post-exit.sh sourced after OpenCode exits, with $CAIRN_EXIT_STATUS
|
|
11
12
|
# set to the exit code.
|
|
12
13
|
set -euo pipefail
|
|
13
14
|
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
15
|
+
|
|
16
|
+
capability_contract_enabled() {
|
|
17
|
+
local value="${CAIRN_CAPABILITY_CONTRACT:-}"
|
|
18
|
+
value="${value#"${value%%[![:space:]]*}"}"
|
|
19
|
+
value="${value%"${value##*[![:space:]]}"}"
|
|
20
|
+
case "$value" in
|
|
21
|
+
1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Oo][Nn]) return 0 ;;
|
|
22
|
+
*) return 1 ;;
|
|
23
|
+
esac
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
resolve_cairn_root() {
|
|
27
|
+
local source dir
|
|
28
|
+
if ! source=$(type -P cairn); then
|
|
29
|
+
echo "cairn: capability contract requires the cairn executable on PATH" >&2
|
|
30
|
+
return 127
|
|
31
|
+
fi
|
|
32
|
+
while [[ -L "$source" ]]; do
|
|
33
|
+
dir=$(cd -P "$(dirname "$source")" && pwd)
|
|
34
|
+
source=$(readlink "$source")
|
|
35
|
+
[[ "$source" == /* ]] || source="$dir/$source"
|
|
36
|
+
done
|
|
37
|
+
cd -P "$(dirname "$source")/.." && pwd
|
|
38
|
+
}
|
|
39
|
+
|
|
14
40
|
if [[ -f "$ROOT_DIR/.ai/.env" ]]; then
|
|
15
41
|
set -a
|
|
16
42
|
# shellcheck disable=SC1091
|
|
@@ -21,16 +47,32 @@ if [[ -f "$ROOT_DIR/.ai/pre-launch.sh" ]]; then
|
|
|
21
47
|
# shellcheck disable=SC1091
|
|
22
48
|
. "$ROOT_DIR/.ai/pre-launch.sh"
|
|
23
49
|
fi
|
|
50
|
+
|
|
51
|
+
if capability_contract_enabled; then
|
|
52
|
+
CAIRN_RUNTIME_ROOT=$(resolve_cairn_root)
|
|
53
|
+
node "$CAIRN_RUNTIME_ROOT/mcp-memory-server/dist/capability-cli.js" \
|
|
54
|
+
harness-recover </dev/null >/dev/null 2>&1 || true
|
|
55
|
+
OPENCODE_CAPABILITY_ROOT="$ROOT_DIR/.ai/capability-contract/opencode"
|
|
56
|
+
"$CAIRN_RUNTIME_ROOT/scripts/sync-opencode-wiki-assets.sh" \
|
|
57
|
+
--apply --capability-overlay --live-root "$OPENCODE_CAPABILITY_ROOT" >/dev/null
|
|
58
|
+
"$CAIRN_RUNTIME_ROOT/scripts/sync-opencode-graphify-assets.sh" \
|
|
59
|
+
--apply --capability-overlay --live-root "$OPENCODE_CAPABILITY_ROOT" >/dev/null
|
|
60
|
+
"$CAIRN_RUNTIME_ROOT/scripts/sync-opencode-security-assets.sh" \
|
|
61
|
+
--apply --capability-overlay --live-root "$OPENCODE_CAPABILITY_ROOT" >/dev/null
|
|
62
|
+
"$CAIRN_RUNTIME_ROOT/scripts/sync-opencode-plugin-assets.sh" \
|
|
63
|
+
--apply --capability-overlay --live-root "$OPENCODE_CAPABILITY_ROOT" >/dev/null
|
|
64
|
+
export OPENCODE_CONFIG_DIR="$OPENCODE_CAPABILITY_ROOT"
|
|
65
|
+
fi
|
|
66
|
+
|
|
24
67
|
cd "$ROOT_DIR"
|
|
25
68
|
|
|
26
|
-
launch_args=()
|
|
27
69
|
if [[ -n "${CAIRN_EXTRA_SETTINGS:-}" ]]; then
|
|
28
|
-
|
|
70
|
+
export OPENCODE_CONFIG="$CAIRN_EXTRA_SETTINGS"
|
|
29
71
|
fi
|
|
30
72
|
|
|
31
73
|
if [[ -f "$ROOT_DIR/.ai/post-exit.sh" ]]; then
|
|
32
74
|
set +e
|
|
33
|
-
opencode "
|
|
75
|
+
opencode "$@"
|
|
34
76
|
CAIRN_EXIT_STATUS=$?
|
|
35
77
|
set -e
|
|
36
78
|
export CAIRN_EXIT_STATUS
|
|
@@ -38,4 +80,4 @@ if [[ -f "$ROOT_DIR/.ai/post-exit.sh" ]]; then
|
|
|
38
80
|
. "$ROOT_DIR/.ai/post-exit.sh" || true
|
|
39
81
|
exit "$CAIRN_EXIT_STATUS"
|
|
40
82
|
fi
|
|
41
|
-
exec opencode "
|
|
83
|
+
exec opencode "$@"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Cairnkeep launcher for Pi. Loads this repo's private .ai/.env, runs the same
|
|
3
|
+
# optional pre/post seams as the other launchers, and otherwise passes every
|
|
4
|
+
# argument to Pi unchanged. Pi has no generic settings-file layering flag, so
|
|
5
|
+
# CAIRN_EXTRA_SETTINGS is intentionally not translated into a CLI option.
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
8
|
+
if [[ -f "$ROOT_DIR/.ai/.env" ]]; then
|
|
9
|
+
set -a
|
|
10
|
+
# shellcheck disable=SC1091
|
|
11
|
+
. "$ROOT_DIR/.ai/.env"
|
|
12
|
+
set +a
|
|
13
|
+
fi
|
|
14
|
+
if [[ -f "$ROOT_DIR/.ai/pre-launch.sh" ]]; then
|
|
15
|
+
# shellcheck disable=SC1091
|
|
16
|
+
. "$ROOT_DIR/.ai/pre-launch.sh"
|
|
17
|
+
fi
|
|
18
|
+
cd "$ROOT_DIR"
|
|
19
|
+
|
|
20
|
+
if [[ -f "$ROOT_DIR/.ai/post-exit.sh" ]]; then
|
|
21
|
+
set +e
|
|
22
|
+
pi "$@"
|
|
23
|
+
CAIRN_EXIT_STATUS=$?
|
|
24
|
+
set -e
|
|
25
|
+
export CAIRN_EXIT_STATUS
|
|
26
|
+
# shellcheck disable=SC1091
|
|
27
|
+
. "$ROOT_DIR/.ai/post-exit.sh" || true
|
|
28
|
+
exit "$CAIRN_EXIT_STATUS"
|
|
29
|
+
fi
|
|
30
|
+
exec pi "$@"
|