feat(coding): add ai-memory client module, drop Pi and babysitter
coding.aiMemory wires Claude Code and OpenCode2 to the central ai-memory server: Nix owns the client config (server URL + bearer token file), the OpenCode MCP entry, and the scope markers (home workspace plus one marker per workspaceDirs entry); activation runs ai-memory's own installers for hooks, the Claude MCP bridge and the skills. The token never lands in a generated file: hooks and the bridge read [auth].bearer_token_file, the OpenCode plugin reads the data-dir auth-token symlink. Pi (and its babysitter profile) are no longer used; LifeOS is being removed from the hosts as well. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
d608fb29b1
commit
c3b51b3546
6 files changed
+464
-389
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# Eval checks for coding.aiMemory against m3-kratos in nixos-config, using
|
||||
# this checkout of m3ta-home. Usage: ai-memory.test.sh [path/to/nixos-config]
|
||||
set -euo pipefail
|
||||
|
||||
home_repo="$(cd "$(dirname "$0")/../../../.." && pwd)"
|
||||
nixos_repo="${1:-$home_repo/../nixos-config}"
|
||||
hm="#nixosConfigurations.m3-kratos.config.home-manager.users.m3tam3re"
|
||||
fail=0
|
||||
|
||||
ev() { # attr [extra nix eval args...]
|
||||
local attr="$1"; shift
|
||||
nix eval --raw --override-input m3ta-home "path:$home_repo" "$nixos_repo$hm.$attr" "$@" 2>/dev/null
|
||||
}
|
||||
|
||||
check() { # name, haystack, needle
|
||||
if [[ "$2" == *"$3"* ]]; then echo "ok $1"; else echo "FAIL $1: missing '$3'"; fail=1; fi
|
||||
}
|
||||
refute() { # name, haystack, needle
|
||||
if [[ "$2" == *"$3"* ]]; then echo "FAIL $1: found '$3'"; fail=1; else echo "ok $1"; fi
|
||||
}
|
||||
|
||||
check "server url" "$(ev home.sessionVariables.AI_MEMORY_SERVER_URL)" "https://memory.m3ta.dev"
|
||||
|
||||
conf="$(ev 'home.file.".local/share/ai-memory/config.toml".text')"
|
||||
check "client config server_url" "$conf" 'server_url = "https://memory.m3ta.dev"'
|
||||
check "client config token file" "$conf" 'bearer_token_file = "/run/agenix/ai-memory-token"'
|
||||
|
||||
mcp="$(ev programs.mcp.servers.ai-memory.args --apply 'builtins.concatStringsSep " "')"
|
||||
check "mcp bridge" "$mcp" "mcp-bridge --no-session-id --server-url https://memory.m3ta.dev/mcp"
|
||||
refute "mcp carries no token" "$mcp" "ai-memory-token"
|
||||
|
||||
opencode="$(cat "$(nix build --no-link --print-out-paths --override-input m3ta-home "path:$home_repo" \
|
||||
"$nixos_repo$hm.xdg.configFile.\"opencode/opencode.json\".source" 2>/dev/null)")"
|
||||
check "opencode gets mcp" "$opencode" "mcp-bridge"
|
||||
|
||||
marker="$(ev 'home.file.".ai-memory.toml".text')"
|
||||
check "home marker workspace" "$marker" 'workspace = "private"'
|
||||
check "marker section" "$marker" "[capture]"
|
||||
for p in "/run/agenix/**" "~/.config/sops/**" "~/.ssh/**" "**/.env*"; do
|
||||
check "marker $p" "$marker" "\"$p\""
|
||||
done
|
||||
|
||||
az="$(ev 'home.file."p/AZ/.ai-memory.toml".text' 2>/dev/null || true)"
|
||||
check "AZ marker workspace" "$az" 'workspace = "az"'
|
||||
check "AZ marker repeats capture" "$az" "[capture]"
|
||||
|
||||
act="$(ev home.activation.aiMemoryInstall.data)"
|
||||
check "hooks claude-code" "$act" "install-hooks --agent claude-code --apply"
|
||||
check "hooks opencode2" "$act" "install-hooks --agent opencode2 --apply"
|
||||
check "auth-token symlink" "$act" "ln -sfn /run/agenix/ai-memory-token "
|
||||
refute "no token on command lines" "$act" "--auth-token"
|
||||
refute "activation must not write opencode.json (home-manager symlink)" "$act" "install-mcp --client opencode"
|
||||
|
||||
# Missing token file: skip with a warning, exit 0, never call ai-memory.
|
||||
script="$(printf '%s\n' "$act" | sed 's|/run/agenix/ai-memory-token|/nonexistent/ai-memory-token|g')"
|
||||
out="$(run() { echo "CALLED $*"; }; eval "$script" 2>&1)"
|
||||
check "skip warning" "$out" "token file /nonexistent/ai-memory-token missing, skipping"
|
||||
refute "no installer without token" "$out" "CALLED"
|
||||
|
||||
exit "$fail"
|
||||
Reference in new issue
Block a user