local-agentic-ai-mem 0.1.0 → 0.1.1
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/dist/commands/install.js +38 -3
- package/package.json +1 -1
package/dist/commands/install.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRuntimeRoot = resolveRuntimeRoot;
|
|
3
4
|
exports.installHooks = installHooks;
|
|
4
5
|
exports.registerSettings = registerSettings;
|
|
5
6
|
exports.install = install;
|
|
@@ -11,8 +12,10 @@ exports.install = install;
|
|
|
11
12
|
* ask — so registering them correctly matters more than the MCP entry.
|
|
12
13
|
*/
|
|
13
14
|
const fs_1 = require("fs");
|
|
15
|
+
const child_process_1 = require("child_process");
|
|
14
16
|
const os_1 = require("os");
|
|
15
17
|
const path_1 = require("path");
|
|
18
|
+
const PKG = "local-agentic-ai-mem";
|
|
16
19
|
const db_1 = require("../db");
|
|
17
20
|
const uninstall_legacy_1 = require("./uninstall-legacy");
|
|
18
21
|
const HOOK_EVENTS = {
|
|
@@ -28,13 +31,45 @@ function templatesDir() {
|
|
|
28
31
|
}
|
|
29
32
|
throw new Error("agentic-memory templates not found");
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Where the hooks should load this package from.
|
|
36
|
+
*
|
|
37
|
+
* Running through `npx` puts the package in ~/.npm/_npx/<hash>/, which npm
|
|
38
|
+
* garbage-collects. Stamping that path into the hooks means they work today
|
|
39
|
+
* and break silently whenever the cache is cleared — with no error the user
|
|
40
|
+
* would connect to memory having stopped. So when the installer is itself
|
|
41
|
+
* running from an npx cache, it installs a copy (and its native dependencies)
|
|
42
|
+
* somewhere stable first, and points the hooks there.
|
|
43
|
+
*/
|
|
44
|
+
function resolveRuntimeRoot(home = (0, os_1.homedir)()) {
|
|
45
|
+
const here = (0, path_1.resolve)(__dirname, "..", "..");
|
|
46
|
+
if (!/[/\\]_npx[/\\]/.test(here))
|
|
47
|
+
return here;
|
|
48
|
+
const runtime = (0, path_1.join)(home, ".agentic-memory", "runtime");
|
|
49
|
+
const target = (0, path_1.join)(runtime, "node_modules", PKG);
|
|
50
|
+
const version = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(here, "package.json"), "utf8")).version;
|
|
51
|
+
const installed = (0, fs_1.existsSync)((0, path_1.join)(target, "package.json"))
|
|
52
|
+
? JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(target, "package.json"), "utf8")).version
|
|
53
|
+
: null;
|
|
54
|
+
if (installed === version)
|
|
55
|
+
return target;
|
|
56
|
+
(0, fs_1.mkdirSync)(runtime, { recursive: true });
|
|
57
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(runtime, "package.json"))) {
|
|
58
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(runtime, "package.json"), JSON.stringify({ name: "agentic-memory-runtime", private: true }) + "\n");
|
|
59
|
+
}
|
|
60
|
+
console.log(` Installing runtime to ${runtime} (npx's cache is not durable)…`);
|
|
61
|
+
(0, child_process_1.execFileSync)("npm", ["install", `${PKG}@${version}`, "--prefix", runtime, "--no-audit", "--no-fund", "--loglevel=error"], {
|
|
62
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
63
|
+
});
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
31
66
|
function installHooks(home = (0, os_1.homedir)()) {
|
|
32
67
|
const hooksDir = (0, path_1.join)(home, ".claude", "hooks", "agentic-memory");
|
|
33
68
|
(0, fs_1.mkdirSync)(hooksDir, { recursive: true });
|
|
34
69
|
const tpl = (0, path_1.join)(templatesDir(), "hooks");
|
|
35
70
|
// The hooks run from ~/.claude/hooks/, outside any node_modules tree, so a
|
|
36
|
-
// bare specifier would not resolve. Stamp in
|
|
37
|
-
const root = (
|
|
71
|
+
// bare specifier would not resolve. Stamp in a durable absolute root.
|
|
72
|
+
const root = resolveRuntimeRoot(home);
|
|
38
73
|
const written = [];
|
|
39
74
|
for (const f of (0, fs_1.readdirSync)(tpl)) {
|
|
40
75
|
const dest = (0, path_1.join)(hooksDir, f);
|
|
@@ -71,7 +106,7 @@ function registerSettings(home = (0, os_1.homedir)()) {
|
|
|
71
106
|
settings.mcpServers ??= {};
|
|
72
107
|
settings.mcpServers["agentic-memory"] = {
|
|
73
108
|
command: "npx",
|
|
74
|
-
args: ["-y",
|
|
109
|
+
args: ["-y", PKG, "mcp"],
|
|
75
110
|
};
|
|
76
111
|
(0, fs_1.writeFileSync)(path, JSON.stringify(settings, null, 2) + "\n");
|
|
77
112
|
}
|