owlmem 0.9.30 → 0.9.31
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 +5 -2
- package/owlmem.mjs +65 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,10 @@ npx -y owlmem install
|
|
|
11
11
|
Finds Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI and Claude Desktop on this computer and adds
|
|
12
12
|
OwlMem (`https://mcp.owlmem.com/mcp`) to each one. Config files are merged, not overwritten, and every file it
|
|
13
13
|
changes is backed up first (`<file>.bak-owlmem-<time>`). It also adds a short "Team memory" rules block to
|
|
14
|
-
`~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md` and `~/.gemini/GEMINI.md` (between `<!-- owlmem:start -->` markers)
|
|
14
|
+
`~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md` and `~/.gemini/GEMINI.md` (between `<!-- owlmem:start -->` markers),
|
|
15
|
+
and a SessionStart hook to `~/.claude/settings.json` that runs `owlmem hook session-start` at the start of
|
|
16
|
+
every Claude Code session, so a new session searches OwlMem with `kb_find` before reading code. The hook runs
|
|
17
|
+
a copy of the CLI kept under `~/.config/owlmem/wake/`, so it never waits on npm.
|
|
15
18
|
|
|
16
19
|
| Option | |
|
|
17
20
|
|---|---|
|
|
@@ -29,7 +32,7 @@ page, where you sign in and click **Allow**. AI agents can read the setup guide
|
|
|
29
32
|
|
|
30
33
|
An AI on your computer normally sees a task only when someone opens it. Auto-wake starts it as soon as it gets one:
|
|
31
34
|
a small background program long-polls OwlMem and runs that AI's command line unattended — Claude Code with
|
|
32
|
-
`claude -p`, Codex with `codex exec`, Antigravity
|
|
35
|
+
`claude -p`, Codex with `codex exec`, Antigravity in the app already running on the computer (the desktop app, or the `agy --hub` language server inside VS Code), falling back to `agy -p` only when neither is running (on a Mac without `agy` it opens the app and re-sends the task), Hermes with `hermes -z`, DeepSeek Harness with `dsh --profile headless` (for Codex and Antigravity, which refuse tool calls when nobody is watching, auto-wake approves just the two OwlMem tools used to report back: in `~/.codex/config.toml` and, for the `agy -p` fallback only, `~/.gemini/antigravity-cli/settings.json`; for Hermes, only if OwlMem is marked `trust: untrusted`, under `command_allowlist` in `~/.hermes/config.yaml`; for DeepSeek Harness, its headless profile gets the model and the OwlMem server copied from the web profile, and its credential store turned back on, in `~/.dsh/profiles/headless/cordis.patch.yml`) — with the task as the prompt. The AI marks the task done or declined as usual. When a task it gave out is done or declined, it is woken too, to read the result. The program updates itself (from npm, when nothing is running).
|
|
33
36
|
|
|
34
37
|
When someone turns auto-wake on for an AI in the console and no computer runs it yet, that AI is told so the next time it connects:
|
|
35
38
|
with your OK it runs `npx -y owlmem wake enable` itself and sends you the pairing link to approve.
|
package/owlmem.mjs
CHANGED
|
@@ -44,7 +44,7 @@ import { fileURLToPath } from "node:url";
|
|
|
44
44
|
import { spawn, spawnSync } from "node:child_process";
|
|
45
45
|
import { createConnection } from "node:net";
|
|
46
46
|
|
|
47
|
-
export const VERSION = "0.9.
|
|
47
|
+
export const VERSION = "0.9.31";
|
|
48
48
|
const BASE = (process.env.OWLMEM_URL || "https://owlmem.com").replace(/\/$/, "");
|
|
49
49
|
const DIR = process.env.OWLMEM_HOME || join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "owlmem");
|
|
50
50
|
const enc = new TextEncoder(), dec = new TextDecoder();
|
|
@@ -514,11 +514,22 @@ async function mcpServe() {
|
|
|
514
514
|
await new Promise((res) => process.stdin.on("end", res));
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
// ── hook: output for a Claude Code hook ──
|
|
518
|
+
// `owlmem hook session-start` prints the SessionStart additionalContext: the first
|
|
519
|
+
// step of every task is kb_find, before reading code. It runs at every session start,
|
|
520
|
+
// so it must be fast and offline: no network, no sign-in, nothing on stderr, and it
|
|
521
|
+
// ignores whatever Claude Code sends on stdin.
|
|
522
|
+
export const SESSION_START_CONTEXT = "Before reading any code or files, search OwlMem with kb_find: it is the first step of every task. In Claude Code, load it first with ToolSearch select:mcp__owlmem__kb_find. Then read code, run commands, and save reusable findings with kb_write.";
|
|
523
|
+
function hookCmd(sub) {
|
|
524
|
+
if (sub !== "session-start") throw new Fail("Usage: owlmem hook session-start");
|
|
525
|
+
console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: SESSION_START_CONTEXT } }));
|
|
526
|
+
}
|
|
527
|
+
|
|
517
528
|
// ── install: connect the AI apps on this machine to OwlMem's MCP server ──
|
|
518
529
|
// The snippets here must say the same as the website (design/owlmem/site.py CODE); tests/test_owlmem_install.py compares them.
|
|
519
530
|
export const MCP_URL = "https://mcp.owlmem.com/mcp";
|
|
520
531
|
export const RULES = `## Team memory (OwlMem)
|
|
521
|
-
- Before
|
|
532
|
+
- Before reading code or files, search OwlMem with kb_find (documents, files and memory at once); use kb_search only for an exact string such as a commit id, a path or an error message.
|
|
522
533
|
- When you learn something reusable — a fix, a gotcha, a decision — save it with kb_write
|
|
523
534
|
under lessons/ or projects/<name>/. Search first and update the existing page instead of
|
|
524
535
|
creating a duplicate.
|
|
@@ -653,6 +664,42 @@ export function withRules(text, uninstall) {
|
|
|
653
664
|
return t.trim() ? t.replace(/\s*$/, "\n\n") + block : block;
|
|
654
665
|
}
|
|
655
666
|
|
|
667
|
+
// Claude Code SessionStart hook: ~/.claude/settings.json gets an entry that runs
|
|
668
|
+
// `owlmem hook session-start` at session start. No matcher, so it covers startup,
|
|
669
|
+
// resume, clear and compact alike. The command runs the copy of this script the
|
|
670
|
+
// waker keeps under ~/.config/owlmem/wake/ (wakeDir), not npx: npx would hit the
|
|
671
|
+
// network on every session start, and the npx cache can be cleaned out. install
|
|
672
|
+
// copies this script there when it adds the hook; --uninstall removes only our
|
|
673
|
+
// entry and leaves the copy (auto-wake runs it too).
|
|
674
|
+
export function sessionStartCommand() {
|
|
675
|
+
return `node ${join(wakeDir(), "owlmem.mjs")} hook session-start`;
|
|
676
|
+
}
|
|
677
|
+
function sessionStartFile() {
|
|
678
|
+
return join(process.env.CLAUDE_CONFIG_DIR || join(home(), ".claude"), "settings.json");
|
|
679
|
+
}
|
|
680
|
+
const isSessionStartOurs = (e) => (e?.hooks || []).some((h) => typeof h?.command === "string" && h.command.includes("owlmem") && h.command.includes("hook session-start"));
|
|
681
|
+
export function planSessionStartHook(uninstall) {
|
|
682
|
+
const file = sessionStartFile();
|
|
683
|
+
const text = readText(file);
|
|
684
|
+
let obj = {};
|
|
685
|
+
if (text !== null && text.trim()) {
|
|
686
|
+
try { obj = JSON.parse(text); } catch { return null; } // bad JSON: leave alone
|
|
687
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return null;
|
|
688
|
+
}
|
|
689
|
+
if (obj.hooks !== undefined && (typeof obj.hooks !== "object" || Array.isArray(obj.hooks) || obj.hooks === null)) return null;
|
|
690
|
+
const hooks = obj.hooks || {};
|
|
691
|
+
if (hooks.SessionStart !== undefined && !Array.isArray(hooks.SessionStart)) return null;
|
|
692
|
+
const list = hooks.SessionStart || [];
|
|
693
|
+
if (uninstall) {
|
|
694
|
+
if (!list.some(isSessionStartOurs)) return null;
|
|
695
|
+
const next = { ...obj, hooks: { ...hooks, SessionStart: list.filter((e) => !isSessionStartOurs(e)) } };
|
|
696
|
+
return { file, text: JSON.stringify(next, null, 2) + "\n" };
|
|
697
|
+
}
|
|
698
|
+
if (list.some(isSessionStartOurs)) return null; // already installed
|
|
699
|
+
const next = { ...obj, hooks: { ...hooks, SessionStart: [...list, { hooks: [{ type: "command", command: sessionStartCommand() }] }] } };
|
|
700
|
+
return { file, text: JSON.stringify(next, null, 2) + "\n" };
|
|
701
|
+
}
|
|
702
|
+
|
|
656
703
|
export function plan(opts = {}) {
|
|
657
704
|
const only = opts.only ? new Set(opts.only) : null;
|
|
658
705
|
const out = [];
|
|
@@ -666,6 +713,13 @@ export function plan(opts = {}) {
|
|
|
666
713
|
if (after !== (before ?? "") && !(opts.uninstall && before === null)) { r.ops.push({ type: "write", file: c.rules, text: after, rules: true }); r.rulesChanged = true; }
|
|
667
714
|
r.rulesFile = c.rules;
|
|
668
715
|
}
|
|
716
|
+
if (c.id === "claude-code" && !opts.noRules && r.state !== "fail") {
|
|
717
|
+
const hop = planSessionStartHook(opts.uninstall);
|
|
718
|
+
if (hop) {
|
|
719
|
+
if (!opts.uninstall) r.ops.unshift({ type: "copy", file: join(wakeDir(), "owlmem.mjs") });
|
|
720
|
+
r.ops.push({ type: "write", file: hop.file, text: hop.text, hook: true });
|
|
721
|
+
}
|
|
722
|
+
}
|
|
669
723
|
out.push(r);
|
|
670
724
|
}
|
|
671
725
|
return out;
|
|
@@ -682,7 +736,11 @@ export function apply(items) {
|
|
|
682
736
|
r.backups = [];
|
|
683
737
|
try {
|
|
684
738
|
for (const op of r.ops) {
|
|
685
|
-
if (op.type === "
|
|
739
|
+
if (op.type === "copy") { // the SessionStart hook runs this script's wake copy, not npx
|
|
740
|
+
mkdirSync(dirname(op.file), { recursive: true });
|
|
741
|
+
const src = fileURLToPath(import.meta.url);
|
|
742
|
+
if (!existsSync(op.file) || readFileSync(op.file, "utf8") !== readFileSync(src, "utf8")) copyFileSync(src, op.file);
|
|
743
|
+
} else if (op.type === "write") {
|
|
686
744
|
mkdirSync(dirname(op.file), { recursive: true });
|
|
687
745
|
if (existsSync(op.file)) { const b = op.file + ".bak-owlmem-" + ts; copyFileSync(op.file, b); r.backups.push(b); }
|
|
688
746
|
writeFileSync(op.file, op.text);
|
|
@@ -710,6 +768,7 @@ function describe(r, done, uninstall) {
|
|
|
710
768
|
for (const op of r.ops) {
|
|
711
769
|
if (op.type === "run" && !done) lines.push(" run: " + op.argv.join(" "));
|
|
712
770
|
if (op.rules) lines.push(` ${done ? "" : "will "}${uninstall ? (done ? "removed" : "remove") : (done ? "wrote" : "write")} the OwlMem rules block in ${tilde(op.file)}`);
|
|
771
|
+
if (op.hook) lines.push(` ${done ? "" : "will "}${uninstall ? (done ? "removed" : "remove") : (done ? "added" : "add")} the SessionStart hook in ${tilde(op.file)}`);
|
|
713
772
|
}
|
|
714
773
|
if (done && r.backups?.length) lines.push(" backup: " + r.backups.join(", "));
|
|
715
774
|
return lines.join("\n");
|
|
@@ -2415,7 +2474,8 @@ const INSTALL_HELP = `Usage: npx -y owlmem install [options]
|
|
|
2415
2474
|
|
|
2416
2475
|
Connects Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI and Claude Desktop on this computer to
|
|
2417
2476
|
OwlMem (${MCP_URL}). Config files are merged, never overwritten; each changed file is backed up first
|
|
2418
|
-
as <file>.bak-owlmem-<time>. Also adds the OwlMem usage rules to CLAUDE.md / AGENTS.md / GEMINI.md
|
|
2477
|
+
as <file>.bak-owlmem-<time>. Also adds the OwlMem usage rules to CLAUDE.md / AGENTS.md / GEMINI.md, and a
|
|
2478
|
+
SessionStart hook to ~/.claude/settings.json so new Claude Code sessions search OwlMem before reading code.
|
|
2419
2479
|
|
|
2420
2480
|
--dry-run show what would change, change nothing
|
|
2421
2481
|
--yes, -y don't ask (non-interactive runs, e.g. an AI running this, never ask)
|
|
@@ -2434,6 +2494,7 @@ export async function main(argv) {
|
|
|
2434
2494
|
if (cmd === "uninstall") { await install(["--uninstall", ...argv.slice(1)]); return; }
|
|
2435
2495
|
if (cmd === "mcp") { await mcpServe(); return; }
|
|
2436
2496
|
if (cmd === "wake") { await wakeCmd(sub, rest); return; }
|
|
2497
|
+
if (cmd === "hook") { hookCmd(sub); return; }
|
|
2437
2498
|
if (cmd === "inbox") { // for a scheduled script (11-02): how many notes / tasks wait for this AI, without reading them (nothing is marked read)
|
|
2438
2499
|
const check = argv.includes("--check");
|
|
2439
2500
|
let r, data = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
4
4
|
"description": "OwlMem command line: connect your AI apps to OwlMem in one command (npx -y owlmem install), an end-to-end encrypted vault for your AI agents, and a local MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "owlmem": "owlmem.mjs" },
|