@snoai/mem-claude 1.7.1 → 2.0.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/README.md CHANGED
@@ -4,6 +4,8 @@ Close a Claude Code session and most of what it learned is gone. Sno Memory keep
4
4
  encrypted memory on your own machine that Claude Code fills as you work and reads from at the
5
5
  start of every session.
6
6
 
7
+ **New in 2.0: Tag Team.** Run `sno reach pair "Fix the login redirect"` and two agents take the task: one builds, one challenges, and the work reaches you already argued over. Your status line says when they need you, and `sno squad` shows the whole squad. An interrupted task comes back, or you are told it did not, and a lesson you approve works from the next reply. [What changed](https://github.com/sno-ai/sno-station#new-in-20-tag-team).
8
+
7
9
  ## What you get
8
10
 
9
11
  - **It remembers without being asked.** Each session is captured in the background once it has been quiet for 30 minutes or has ended.
@@ -29,7 +31,7 @@ start of every session.
29
31
  2. Install the plugin (Node.js 22.22.3+, 24.15.0+ or 25.9.0+, and `git`):
30
32
 
31
33
  ```bash
32
- sh -c 'sno_installer_body=$(curl -fsSL https://sno.ai/install) && printf "%s\n" "$sno_installer_body" | sh'
34
+ curl -fsSL https://sno.ai/install | sh
33
35
  ```
34
36
 
35
37
  3. Open a new Claude Code session inside a git repository, then try it:
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { homedir } from "node:os";
3
3
  import { isAbsolute, join } from "node:path";
4
+ import { composeContinuityContext, observeAgentEvent, refreshContinuityBrief, renderAgentStatusLine } from "@snoai/memory/coding-skin";
4
5
  import { doctor } from "./doctor.js";
5
6
  import { correctCommand, getCommand, recallCommand, rememberCommand } from "./explicit.js";
6
7
  import { postToolUse, preToolUse, sessionEnd, sessionStart, stop, userPromptSubmit } from "./hooks.js";
@@ -10,23 +11,34 @@ import { MESSAGES } from "./messages.js";
10
11
  import { isTemporaryDirectory, workspaceRoot } from "./scope.js";
11
12
  import { runWorker } from "./worker.js";
12
13
  async function readStdin() {
14
+ const text = await readStdinText();
15
+ return text.trim() ? JSON.parse(text) : {};
16
+ }
17
+ async function readStdinText() {
13
18
  const chunks = [];
14
19
  for await (const chunk of process.stdin)
15
20
  chunks.push(Buffer.from(chunk));
16
- const text = Buffer.concat(chunks).toString("utf8").trim();
17
- return text ? JSON.parse(text) : {};
21
+ return Buffer.concat(chunks).toString("utf8");
18
22
  }
19
23
  function option(args, name) {
20
24
  const index = args.indexOf(name);
21
25
  return index >= 0 ? args[index + 1] : undefined;
22
26
  }
23
- const HOOK_COMMANDS = ["session-start", "user-prompt-submit", "stop", "session-end", "pre-tool-use", "post-tool-use"];
27
+ const HOOK_COMMANDS = ["session-start", "user-prompt-submit", "stop", "session-end", "pre-tool-use", "post-tool-use", "pre-compact"];
24
28
  async function main() {
25
29
  const [command, ...args] = process.argv.slice(2);
30
+ if (command === "status-line")
31
+ return renderAgentStatusLine("claude", option(args, "--sno-original") ?? "W10=", await readStdinText());
32
+ if (command === "agent-state-hook") {
33
+ await observeAgentEvent("claude", args[0] ?? "unknown", await readStdin());
34
+ return 0;
35
+ }
26
36
  const input = HOOK_COMMANDS.includes(command ?? "") ? await readStdin() : undefined;
27
37
  // The Cursor IDE runs Claude Code hooks with Cursor-shaped input; Sno's Cursor hooks own Cursor, so these do nothing there.
28
38
  if (input && typeof input === "object" && "cursor_version" in input)
29
39
  return 0;
40
+ if (input !== undefined && command)
41
+ await observeAgentEvent("claude", command, input);
30
42
  // Scripted runs (a temporary directory, `claude -p`) and background-task notices are not conversations; the
31
43
  // real-agent release journeys set SNO_CAPTURE_SCRIPTED=1 to be recorded anyway. Measured 2026-10-13: 616 of 785 queued turns.
32
44
  if (input && process.env["SNO_CAPTURE_SCRIPTED"] !== "1" && typeof input === "object") {
@@ -39,11 +51,15 @@ async function main() {
39
51
  return 0;
40
52
  }
41
53
  if (command === "session-start") {
42
- process.stdout.write(`${await sessionStart(input)}\n`);
54
+ process.stdout.write(`${await composeContinuityContext("claude", "SessionStart", input, () => sessionStart(input))}\n`);
43
55
  return 0;
44
56
  }
45
57
  if (command === "user-prompt-submit") {
46
- process.stdout.write(`${await userPromptSubmit(input)}\n`);
58
+ process.stdout.write(`${await composeContinuityContext("claude", "UserPromptSubmit", input, () => userPromptSubmit(input))}\n`);
59
+ return 0;
60
+ }
61
+ if (command === "pre-compact") {
62
+ await refreshContinuityBrief("claude", input);
47
63
  return 0;
48
64
  }
49
65
  if (command === "stop") {
@@ -128,13 +144,13 @@ async function main() {
128
144
  }
129
145
  main().then(code => {
130
146
  process.exitCode = code;
131
- if (["session-start", "user-prompt-submit", "stop", "session-end", "pre-tool-use", "post-tool-use", "worker"].includes(process.argv[2] ?? "")) {
147
+ if ([...HOOK_COMMANDS, "agent-state-hook", "worker"].includes(process.argv[2] ?? "")) {
132
148
  process.stdout.write("", () => process.exit(code));
133
149
  }
134
150
  }, error => {
135
151
  const reason = error instanceof Error ? error.message : "engine-failed";
136
152
  const command = process.argv[2];
137
- const silentHooks = ["stop", "session-end", "pre-tool-use", "post-tool-use"];
153
+ const silentHooks = ["stop", "session-end", "pre-tool-use", "post-tool-use", "agent-state-hook"];
138
154
  if (command === "session-start" || command === "user-prompt-submit" || (command !== undefined && silentHooks.includes(command))) {
139
155
  process.stderr.write(`${JSON.stringify({ event: command, reason: "invalid-input" })}\n`);
140
156
  if (command === "session-start" || command === "user-prompt-submit") {
package/dist/install.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
2
  import { basename, dirname, isAbsolute, join } from "node:path";
3
- import { CODING_SKIN_HOOKS, codingSkinHookCommand, isCodingSkinHookCommand, snoProgramPath, shellQuote, } from "@snoai/memory/coding-skin";
3
+ import { fileURLToPath } from "node:url";
4
+ import { CODING_SKIN_HOOKS, composeAgentStatusLine, codingSkinHookCommand, continuityBriefPath, isCodingSkinHookCommand, snoProgramPath, shellQuote, } from "@snoai/memory/coding-skin";
4
5
  import { z } from "zod";
5
6
  import { APP_NAME } from "./constants.js";
6
7
  import { MESSAGES } from "./messages.js";
@@ -11,6 +12,14 @@ const settingsSchema = z.looseObject({
11
12
  permissions: z.looseObject({ allow: z.array(z.string()).optional() }).optional(),
12
13
  disableAllHooks: z.boolean().optional(),
13
14
  });
15
+ const CLAUDE_HOOKS = {
16
+ ...CODING_SKIN_HOOKS,
17
+ PreCompact: { subcommand: "pre-compact", timeout: 5 },
18
+ PermissionRequest: { subcommand: "permission-request", timeout: 5 },
19
+ Notification: { subcommand: "notification", timeout: 5 },
20
+ StopFailure: { subcommand: "stop-failure", timeout: 5 },
21
+ };
22
+ const CLI_ENTRY = fileURLToPath(new URL("../dist/cli.js", import.meta.url));
14
23
  function isOwnedProgram(program) {
15
24
  return basename(program) === APP_NAME || /\/mem-claude\/(?:dist|src)\/cli\.(?:js|ts)$/.test(program);
16
25
  }
@@ -31,6 +40,8 @@ export function isOwnedHookCommand(command, subcommand) {
31
40
  return isOwnedProgram(program);
32
41
  }
33
42
  export function isOwnedPermissionRule(rule) {
43
+ if (/^(?:Read|Edit)\(\/\/.+\/station\/handoff\/\*\*\)$/.test(rule))
44
+ return true;
34
45
  if (!rule.startsWith("Bash(") || !rule.endsWith(" *)"))
35
46
  return false;
36
47
  const body = rule.slice(5, -3);
@@ -63,8 +74,8 @@ export async function readSettings(configDir) {
63
74
  }
64
75
  function updateSettings(settings, programPath) {
65
76
  settings.hooks ??= {};
66
- for (const event of Object.keys(CODING_SKIN_HOOKS)) {
67
- const details = CODING_SKIN_HOOKS[event];
77
+ for (const event of Object.keys(CLAUDE_HOOKS)) {
78
+ const details = CLAUDE_HOOKS[event];
68
79
  const groups = settings.hooks[event] ?? [];
69
80
  let installed = false;
70
81
  const hook = {
@@ -90,13 +101,14 @@ function updateSettings(settings, programPath) {
90
101
  }
91
102
  settings.permissions ??= {};
92
103
  const allow = settings.permissions.allow ?? [];
93
- const rule = `Bash(${programPath} memory *)`;
104
+ // Reading and editing the task brief directory, and nothing else, so keeping the brief never asks for approval.
105
+ const briefs = `/${dirname(continuityBriefPath("session"))}/**`;
106
+ const rules = [`Bash(${programPath} memory *)`, `Read(${briefs})`, `Edit(${briefs})`];
94
107
  const index = allow.findIndex(isOwnedPermissionRule);
95
- if (index < 0)
96
- allow.push(rule);
97
- else
98
- allow.splice(index, allow.length - index, rule, ...allow.slice(index + 1).filter(current => !isOwnedPermissionRule(current)));
99
- settings.permissions.allow = allow;
108
+ const kept = allow.filter(current => !isOwnedPermissionRule(current));
109
+ kept.splice(index < 0 ? kept.length : index, 0, ...rules);
110
+ settings.permissions.allow = kept;
111
+ composeAgentStatusLine(settings, CLI_ENTRY, "claude", true);
100
112
  }
101
113
  // Removes the hooks, rule and skill installClaude wrote; every other setting stays as it was.
102
114
  export async function uninstallClaude(options) {
@@ -104,11 +116,12 @@ export async function uninstallClaude(options) {
104
116
  if (!settings)
105
117
  throw new Error(MESSAGES.settingsUnparsable);
106
118
  const before = JSON.stringify(settings);
107
- for (const event of Object.keys(CODING_SKIN_HOOKS)) {
119
+ composeAgentStatusLine(settings, CLI_ENTRY, "claude", false);
120
+ for (const event of Object.keys(CLAUDE_HOOKS)) {
108
121
  const groups = settings.hooks?.[event];
109
122
  if (!settings.hooks || !groups)
110
123
  continue;
111
- const kept = groups.map(group => ({ ...group, hooks: group.hooks.filter(hook => !hook.command || !isOwnedHookCommand(hook.command, CODING_SKIN_HOOKS[event].subcommand)) }))
124
+ const kept = groups.map(group => ({ ...group, hooks: group.hooks.filter(hook => !hook.command || !isOwnedHookCommand(hook.command, CLAUDE_HOOKS[event].subcommand)) }))
112
125
  .filter(group => group.hooks.length > 0);
113
126
  if (kept.length)
114
127
  settings.hooks[event] = kept;
package/dist/worker.d.ts CHANGED
@@ -37,7 +37,7 @@ export interface WorkerDependencies {
37
37
  reason: string;
38
38
  } | {
39
39
  kind: "error";
40
- category: "transport";
40
+ category: "transport" | "auth" | "exhausted";
41
41
  message: string;
42
42
  }>;
43
43
  now?(): number;
@@ -58,9 +58,10 @@ export declare function runClaudeChild(prompt: string, cwd: string, timeoutMs?:
58
58
  reason: string;
59
59
  } | {
60
60
  kind: "error";
61
- category: "transport";
61
+ category: "transport" | "auth" | "exhausted";
62
62
  message: string;
63
63
  }>;
64
+ export declare function claudeChildResult(status: number | null, stdout: string, stderr: string, cwd?: string): Awaited<ReturnType<WorkerDependencies["runChild"]>>;
64
65
  type SpoolEntry = {
65
66
  path: string;
66
67
  record: z.infer<typeof spoolSchema>;
package/dist/worker.js CHANGED
@@ -71,25 +71,35 @@ export async function runClaudeChild(prompt, cwd, timeoutMs = CODING_SKIN_CHILD_
71
71
  });
72
72
  if (result.error && "code" in result.error && result.error.code === "ETIMEDOUT")
73
73
  return { kind: "cancelled", reason: "deadline" };
74
- if (result.status !== 0)
75
- return { kind: "error", category: "transport", message: `claude-exit-${result.status ?? "signal"}` };
74
+ return claudeChildResult(result.status, result.stdout ?? "", result.stderr ?? "", cwd);
75
+ }
76
+ export function claudeChildResult(status, stdout, stderr, cwd) {
76
77
  let output;
77
78
  try {
78
- output = JSON.parse(result.stdout);
79
+ output = JSON.parse(stdout);
79
80
  }
80
81
  catch {
81
- return { kind: "error", category: "transport", message: "invalid-json" };
82
+ output = undefined;
82
83
  }
83
84
  const parsed = z.object({
84
85
  result: z.string().optional(),
85
86
  is_error: z.boolean(),
86
87
  usage: z.object({ cache_creation_input_tokens: z.number().optional(), cache_read_input_tokens: z.number().optional(), input_tokens: z.number().optional(), output_tokens: z.number().optional() }).optional(),
87
88
  }).safeParse(output);
89
+ if (status === 0 && parsed.success && cwd !== undefined)
90
+ console.log(JSON.stringify({ event: "claude-child", cwd, usage: parsed.data.usage, claudeCodeUnset: true }));
91
+ if (status !== 0 || (parsed.success && parsed.data.is_error)) {
92
+ const failure = `${parsed.success ? parsed.data.result ?? "" : stdout}\n${stderr}`;
93
+ if (/\b401\b|unauthori[sz]ed|invalid x-api-key|authentication_error|not logged in|run \/login|authentication required|authentication failed|invalid (?:api key|auth token)|oauth token (?:expired|revoked)|login expired/i.test(failure))
94
+ return { kind: "error", category: "auth", message: "Claude login unavailable" };
95
+ if (/you['’]ve (?:hit|reached) your|usage limit reached|out of (?:extra usage|usage credits)|credit balance.{0,20}too low/i.test(failure))
96
+ return { kind: "error", category: "exhausted", message: "Claude usage limit reached" };
97
+ return { kind: "error", category: "transport", message: status !== 0 ? `claude-exit-${status ?? "signal"}` : "claude-is-error" };
98
+ }
99
+ if (output === undefined)
100
+ return { kind: "error", category: "transport", message: "invalid-json" };
88
101
  if (!parsed.success)
89
102
  return { kind: "error", category: "transport", message: "invalid-result" };
90
- console.log(JSON.stringify({ event: "claude-child", cwd, usage: parsed.data.usage, claudeCodeUnset: true }));
91
- if (parsed.data.is_error)
92
- return { kind: "error", category: "transport", message: "claude-is-error" };
93
103
  const text = parsed.data.result?.trim();
94
104
  if (!text)
95
105
  return { kind: "error", category: "transport", message: "empty-output" };
@@ -298,9 +308,15 @@ export async function runWorker(dependencies = productionDependencies()) {
298
308
  let currentImport = false;
299
309
  let server;
300
310
  let handoff = false;
311
+ let modelUnavailable = false;
301
312
  try {
302
313
  mkdirSync(childCwd, { recursive: true, mode: 0o700 });
303
- const callback = await callbackServer(credential, () => currentCwd ?? childCwd, () => currentImport, () => { lastCallbackAt = now(); }, (prompt, cwd, requesterMs) => dependencies.runChild(prompt, cwd, Math.min(CODING_SKIN_CHILD_DEADLINE_MS, requesterMs ?? Infinity)));
314
+ const callback = await callbackServer(credential, () => currentCwd ?? childCwd, () => currentImport, () => { lastCallbackAt = now(); }, async (prompt, cwd, requesterMs) => {
315
+ const result = await dependencies.runChild(prompt, cwd, Math.min(CODING_SKIN_CHILD_DEADLINE_MS, requesterMs ?? Infinity));
316
+ if (result.kind === "error" && (result.category === "auth" || result.category === "exhausted"))
317
+ modelUnavailable = true;
318
+ return result;
319
+ });
304
320
  server = callback.server;
305
321
  await readSpoolNames();
306
322
  const client = await dependencies.connect();
@@ -337,6 +353,7 @@ export async function runWorker(dependencies = productionDependencies()) {
337
353
  }
338
354
  currentCwd = childCwd;
339
355
  currentImport = record.kind === "import";
356
+ modelUnavailable = false;
340
357
  try {
341
358
  const messages = batch.flatMap(({ record: turn }) => turn.kind === "import"
342
359
  ? [{ role: "user", content: turn.user, at: turn.at }]
@@ -347,6 +364,8 @@ export async function runWorker(dependencies = productionDependencies()) {
347
364
  // A capture in flight is never abandoned for the lifetime: the sidecar would go on extracting it while this
348
365
  // worker's model callback is gone. Its route deadline bounds it, and the lifetime is checked before the next one.
349
366
  const result = await client.capture({ turnId: record.turnId, rewindEpoch: 0, messages }, { principal, project: record.project, session: record.sessionId, host: { sessionId: record.sessionId, workspace: record.project } });
367
+ if (modelUnavailable)
368
+ throw new Error("host model unavailable");
350
369
  if (result.degraded)
351
370
  throw new Error(result.reason);
352
371
  if (!result.committed && !result.accepted && !result.skipped && !result.partial)
@@ -360,6 +379,10 @@ export async function runWorker(dependencies = productionDependencies()) {
360
379
  break;
361
380
  }
362
381
  catch (error) {
382
+ if (modelUnavailable) {
383
+ console.log(JSON.stringify({ event: "capture-deferred", turnId: record.turnId, reason: "host-model-unavailable" }));
384
+ return "failed";
385
+ }
363
386
  for (const entry of batch)
364
387
  await updateImportReceipt(entry.record.importReceipt, "failures");
365
388
  const attempts = record.attempts + 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snoai/mem-claude",
3
- "version": "1.7.1",
3
+ "version": "2.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": { "access": "public" },
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "directory": "apps/mem-claude"
10
10
  },
11
11
  "type": "module",
12
- "description": "Give Claude Code a memory. It remembers what you worked on and brings it back next session.",
12
+ "description": "Put Claude Code on a squad: one memory with your other agents, a status line that says who needs you, and a task that survives compaction.",
13
13
  "files": [
14
14
  "dist",
15
15
  "skills",
@@ -25,7 +25,7 @@
25
25
  "lint:fix": "biome check --write src/"
26
26
  },
27
27
  "dependencies": {
28
- "@snoai/memory": "^1.7.0",
28
+ "@snoai/memory": "^2.0.0",
29
29
  "fs-native-extensions": "^1.5.1",
30
30
  "zod": "^4.5.4"
31
31
  },