memorizz 0.6.0 → 0.6.3
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 +4 -3
- package/bin/memorizz.js +57 -8
- package/package.json +1 -1
- package/scripts/postinstall.js +10 -4
package/README.md
CHANGED
|
@@ -6,8 +6,9 @@ developers. On `npm install -g memorizz` it:
|
|
|
6
6
|
|
|
7
7
|
1. finds or installs [`uv`](https://docs.astral.sh/uv/) (a standalone binary that
|
|
8
8
|
manages its own Python — you do **not** need Python pre-installed), then
|
|
9
|
-
2. runs `uv tool install "memorizz[mcp]"` so the full CLI,
|
|
10
|
-
client/server commands, is available
|
|
9
|
+
2. runs `uv tool install --python 3.12 "memorizz[mcp]"` so the full CLI,
|
|
10
|
+
including MCP client/server commands, is available even when the host's
|
|
11
|
+
default Python is older.
|
|
11
12
|
|
|
12
13
|
The `memorizz` command then execs the uv-installed CLI.
|
|
13
14
|
|
|
@@ -20,7 +21,7 @@ vendor CLIs; inspect local readiness with `memorizz harness doctor`.
|
|
|
20
21
|
If you already use Python tooling, prefer these:
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
uv tool install "memorizz[mcp]"
|
|
24
|
+
uv tool install --python 3.12 "memorizz[mcp]" # recommended complete CLI
|
|
24
25
|
pipx install "memorizz[mcp]"
|
|
25
26
|
```
|
|
26
27
|
|
package/bin/memorizz.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Copyright (c) 2024 Richmond Alake. Licensed under PolyForm Noncommercial 1.0.0.
|
|
3
3
|
//
|
|
4
|
-
// Thin launcher: exec the uv-installed `memorizz`, forwarding
|
|
5
|
-
// code. Falls back to `uv tool run
|
|
6
|
-
//
|
|
4
|
+
// Thin launcher: exec the exact uv-installed `memorizz`, forwarding
|
|
5
|
+
// argv/stdio/exit code. Falls back to `uv tool run` with the pinned package
|
|
6
|
+
// specification when the managed binary is missing or stale.
|
|
7
7
|
"use strict";
|
|
8
8
|
|
|
9
9
|
const { spawnSync } = require("child_process");
|
|
@@ -11,7 +11,19 @@ const os = require("os");
|
|
|
11
11
|
const path = require("path");
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
const VERSION = require("../package.json").version;
|
|
14
|
+
const PYTHON_VERSION = "3.12";
|
|
14
15
|
const PACKAGE_SPEC = `memorizz[mcp]==${VERSION}`;
|
|
16
|
+
const EXPECTED_VERSION = `memorizz ${VERSION}`;
|
|
17
|
+
|
|
18
|
+
function realpath(value) {
|
|
19
|
+
try {
|
|
20
|
+
return fs.realpathSync(value);
|
|
21
|
+
} catch (_) {
|
|
22
|
+
return path.resolve(value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const LAUNCHER_PATH = realpath(__filename);
|
|
15
27
|
|
|
16
28
|
function findExe(name) {
|
|
17
29
|
const finder = process.platform === "win32" ? "where" : "which";
|
|
@@ -28,23 +40,60 @@ function findExe(name) {
|
|
|
28
40
|
return null;
|
|
29
41
|
}
|
|
30
42
|
|
|
43
|
+
function uvToolBinDir(uv) {
|
|
44
|
+
const result = spawnSync(uv, ["tool", "dir", "--bin"], {
|
|
45
|
+
encoding: "utf8",
|
|
46
|
+
});
|
|
47
|
+
if (result.status !== 0 || !result.stdout.trim()) return null;
|
|
48
|
+
return result.stdout.trim().split(/\r?\n/).pop();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isExpectedCli(candidate) {
|
|
52
|
+
if (!candidate || !fs.existsSync(candidate)) return false;
|
|
53
|
+
if (realpath(candidate) === LAUNCHER_PATH) return false;
|
|
54
|
+
const result = spawnSync(candidate, ["--version"], { encoding: "utf8" });
|
|
55
|
+
return result.status === 0 && result.stdout.trim() === EXPECTED_VERSION;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findUvManagedCli(uv) {
|
|
59
|
+
const binDir = uvToolBinDir(uv);
|
|
60
|
+
if (!binDir) return null;
|
|
61
|
+
const executable = process.platform === "win32" ? "memorizz.exe" : "memorizz";
|
|
62
|
+
const candidate = path.join(binDir, executable);
|
|
63
|
+
return isExpectedCli(candidate) ? candidate : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function findCompatibleCliOnPath() {
|
|
67
|
+
const executable = process.platform === "win32" ? "memorizz.exe" : "memorizz";
|
|
68
|
+
for (const directory of (process.env.PATH || "").split(path.delimiter)) {
|
|
69
|
+
if (!directory) continue;
|
|
70
|
+
const candidate = path.join(directory, executable);
|
|
71
|
+
if (isExpectedCli(candidate)) return candidate;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
31
76
|
const args = process.argv.slice(2);
|
|
32
|
-
const
|
|
77
|
+
const uv = findExe("uv");
|
|
78
|
+
const exe = (uv && findUvManagedCli(uv)) || findCompatibleCliOnPath();
|
|
33
79
|
|
|
34
80
|
let res;
|
|
35
81
|
if (exe) {
|
|
36
82
|
res = spawnSync(exe, args, { stdio: "inherit" });
|
|
37
83
|
} else {
|
|
38
|
-
const uv = findExe("uv");
|
|
39
84
|
if (!uv) {
|
|
40
85
|
process.stderr.write(
|
|
41
|
-
|
|
86
|
+
`[memorizz] MemoRizz ${VERSION} is not installed and uv was not found.\n` +
|
|
42
87
|
" Try: npm rebuild -g memorizz (re-runs the bootstrapper)\n" +
|
|
43
|
-
|
|
88
|
+
` Or: uv tool install --python ${PYTHON_VERSION} '${PACKAGE_SPEC}'\n`
|
|
44
89
|
);
|
|
45
90
|
process.exit(127);
|
|
46
91
|
}
|
|
47
|
-
res = spawnSync(
|
|
92
|
+
res = spawnSync(
|
|
93
|
+
uv,
|
|
94
|
+
["tool", "run", "--python", PYTHON_VERSION, "--from", PACKAGE_SPEC, "memorizz", ...args],
|
|
95
|
+
{ stdio: "inherit" }
|
|
96
|
+
);
|
|
48
97
|
}
|
|
49
98
|
|
|
50
99
|
process.exit(res.status == null ? 1 : res.status);
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Convenience bootstrapper: `npm i -g memorizz` installs the real Python CLI via
|
|
5
5
|
// `uv` (a standalone binary that manages its own Python — no pre-existing Python
|
|
6
|
-
// required). This is NOT the canonical install path; `uv tool install
|
|
7
|
-
// and `pipx install memorizz` are first-class. Fails
|
|
6
|
+
// required). This is NOT the canonical install path; `uv tool install
|
|
7
|
+
// --python 3.12 memorizz` and `pipx install memorizz` are first-class. Fails
|
|
8
|
+
// soft: a bootstrap error
|
|
8
9
|
// never bricks the package — bin/memorizz.js retries via `uv tool run` on first
|
|
9
10
|
// use.
|
|
10
11
|
"use strict";
|
|
@@ -15,6 +16,7 @@ const path = require("path");
|
|
|
15
16
|
const fs = require("fs");
|
|
16
17
|
|
|
17
18
|
const VERSION = require("../package.json").version;
|
|
19
|
+
const PYTHON_VERSION = "3.12";
|
|
18
20
|
// The npm bridge represents the complete command-line product, including MCP
|
|
19
21
|
// client/server commands whose Python dependencies are optional for library-only
|
|
20
22
|
// installs.
|
|
@@ -73,7 +75,11 @@ function main() {
|
|
|
73
75
|
let uv = findUv() || installUv();
|
|
74
76
|
if (uv) {
|
|
75
77
|
log(`Installing ${PACKAGE_SPEC} via uv…`);
|
|
76
|
-
const r = spawnSync(
|
|
78
|
+
const r = spawnSync(
|
|
79
|
+
uv,
|
|
80
|
+
["tool", "install", "--python", PYTHON_VERSION, "--force", PACKAGE_SPEC],
|
|
81
|
+
{ stdio: "inherit" }
|
|
82
|
+
);
|
|
77
83
|
if (r.status === 0) {
|
|
78
84
|
log("Done. Run: memorizz");
|
|
79
85
|
return;
|
|
@@ -95,7 +101,7 @@ function main() {
|
|
|
95
101
|
"Could not bootstrap memorizz automatically.",
|
|
96
102
|
"Install it manually with either:",
|
|
97
103
|
" curl -LsSf https://astral.sh/uv/install.sh | sh",
|
|
98
|
-
` uv tool install '${PACKAGE_SPEC}'`,
|
|
104
|
+
` uv tool install --python ${PYTHON_VERSION} '${PACKAGE_SPEC}'`,
|
|
99
105
|
` pipx install '${PACKAGE_SPEC}'`,
|
|
100
106
|
"The `memorizz` launcher will also retry via `uv tool run` on first use.",
|
|
101
107
|
].join("\n")
|