owlmem 0.9.32 → 0.9.33
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/owlmem.mjs +31 -4
- package/package.json +1 -1
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.33";
|
|
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();
|
|
@@ -517,12 +517,38 @@ async function mcpServe() {
|
|
|
517
517
|
// ── hook: output for a Claude Code hook ──
|
|
518
518
|
// `owlmem hook session-start` prints the SessionStart additionalContext: the first
|
|
519
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
|
|
521
|
-
//
|
|
520
|
+
// so it must be fast and offline: no network, no sign-in, nothing on stderr. It reads
|
|
521
|
+
// only the session cwd from stdin (to name this project's handoff key) and ignores
|
|
522
|
+
// anything else Claude Code sends there.
|
|
522
523
|
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.";
|
|
524
|
+
// The project this session runs in: the folder name of the git repository the cwd sits in
|
|
525
|
+
// (walk up to the first folder holding `.git`, a dir or a worktree's file), else the cwd's
|
|
526
|
+
// own folder name. No git binary, no network: just the filesystem.
|
|
527
|
+
function normalizeProjectName(name) {
|
|
528
|
+
return name.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "project";
|
|
529
|
+
}
|
|
530
|
+
function projectName(cwd) {
|
|
531
|
+
const start = isAbsolute(cwd) ? cwd : join(process.cwd(), cwd);
|
|
532
|
+
let dir = start;
|
|
533
|
+
while (!existsSync(join(dir, ".git"))) {
|
|
534
|
+
const parent = dirname(dir);
|
|
535
|
+
if (parent === dir) return normalizeProjectName(basename(start));
|
|
536
|
+
dir = parent;
|
|
537
|
+
}
|
|
538
|
+
return normalizeProjectName(basename(dir));
|
|
539
|
+
}
|
|
540
|
+
// The hook's stdin JSON carries the session cwd; only read it when stdin isn't a TTY,
|
|
541
|
+
// and tolerate empty or bad input (fall back to the process cwd).
|
|
542
|
+
function hookStdinCwd() {
|
|
543
|
+
if (process.stdin.isTTY) return null;
|
|
544
|
+
try { const p = JSON.parse(readFileSync(0, "utf8")); return typeof p?.cwd === "string" && p.cwd ? p.cwd : null; }
|
|
545
|
+
catch { return null; }
|
|
546
|
+
}
|
|
523
547
|
function hookCmd(sub) {
|
|
524
548
|
if (sub !== "session-start") throw new Fail("Usage: owlmem hook session-start");
|
|
525
|
-
|
|
549
|
+
const key = `<your name>-handoff-${projectName(hookStdinCwd() || process.cwd())}`;
|
|
550
|
+
const ctx = SESSION_START_CONTEXT + ` Handoff key for this project: \`${key}\` (kb_retain to save, kb_find to read; don't read another project's).`;
|
|
551
|
+
console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: ctx } }));
|
|
526
552
|
}
|
|
527
553
|
|
|
528
554
|
// ── install: connect the AI apps on this machine to OwlMem's MCP server ──
|
|
@@ -535,6 +561,7 @@ export const RULES = `## Team memory (OwlMem)
|
|
|
535
561
|
creating a duplicate.
|
|
536
562
|
- Store facts that change (prices, versions, status) with kb_retain and snapshot=true or an
|
|
537
563
|
expiry, so they retire on their own.
|
|
564
|
+
- Save a handoff with kb_retain under \`<your name>-handoff-<project>\`, where <project> is the folder name of the git repo you work in (else the working folder).
|
|
538
565
|
- Never put passwords or API keys in documents or memory. Use the OwlMem vault.`;
|
|
539
566
|
const MARK_START = "<!-- owlmem:start -->", MARK_END = "<!-- owlmem:end -->";
|
|
540
567
|
const DOCS = "https://owlmem.com/docs#";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.33",
|
|
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" },
|