memorizz 0.1.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 ADDED
@@ -0,0 +1,31 @@
1
+ # memorizz (npm bootstrapper)
2
+
3
+ This npm package is a **convenience bridge** that installs the real
4
+ [`memorizz`](https://pypi.org/project/memorizz/) Python CLI for Node-first
5
+ developers. On `npm install -g memorizz` it:
6
+
7
+ 1. finds or installs [`uv`](https://docs.astral.sh/uv/) (a standalone binary that
8
+ manages its own Python — you do **not** need Python pre-installed), then
9
+ 2. runs `uv tool install memorizz`.
10
+
11
+ The `memorizz` command then execs the uv-installed CLI.
12
+
13
+ ## First-class install paths
14
+
15
+ If you already use Python tooling, prefer these:
16
+
17
+ ```bash
18
+ uv tool install memorizz # recommended
19
+ pipx install memorizz
20
+ ```
21
+
22
+ ## Uninstall
23
+
24
+ ```bash
25
+ npm uninstall -g memorizz
26
+ uv tool uninstall memorizz # the npm shim does not remove the uv-managed tool
27
+ ```
28
+
29
+ ## Env
30
+
31
+ - `MEMORIZZ_SKIP_POSTINSTALL=1` — skip the bootstrap during `npm install`.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) 2024 Richmond Alake. Licensed under PolyForm Noncommercial 1.0.0.
3
+ //
4
+ // Thin launcher: exec the uv-installed `memorizz`, forwarding argv/stdio/exit
5
+ // code. Falls back to `uv tool run memorizz` when the launcher isn't yet on PATH
6
+ // (e.g. a fresh shell after install, or a postinstall that failed soft).
7
+ "use strict";
8
+
9
+ const { spawnSync } = require("child_process");
10
+ const os = require("os");
11
+ const path = require("path");
12
+ const fs = require("fs");
13
+
14
+ function findExe(name) {
15
+ const finder = process.platform === "win32" ? "where" : "which";
16
+ const onPath = spawnSync(finder, [name], { encoding: "utf8" });
17
+ if (onPath.status === 0 && onPath.stdout.trim()) {
18
+ return onPath.stdout.split(/\r?\n/)[0].trim();
19
+ }
20
+ const home = os.homedir();
21
+ const exe = process.platform === "win32" ? `${name}.exe` : name;
22
+ for (const dir of [path.join(home, ".local", "bin"), path.join(home, ".cargo", "bin")]) {
23
+ const candidate = path.join(dir, exe);
24
+ if (fs.existsSync(candidate)) return candidate;
25
+ }
26
+ return null;
27
+ }
28
+
29
+ const args = process.argv.slice(2);
30
+ const exe = findExe("memorizz");
31
+
32
+ let res;
33
+ if (exe) {
34
+ res = spawnSync(exe, args, { stdio: "inherit" });
35
+ } else {
36
+ const uv = findExe("uv");
37
+ if (!uv) {
38
+ process.stderr.write(
39
+ "[memorizz] CLI not installed and uv not found.\n" +
40
+ " Try: npm rebuild -g memorizz (re-runs the bootstrapper)\n" +
41
+ " Or: uv tool install memorizz / pipx install memorizz\n"
42
+ );
43
+ process.exit(127);
44
+ }
45
+ res = spawnSync(uv, ["tool", "run", "memorizz", ...args], { stdio: "inherit" });
46
+ }
47
+
48
+ process.exit(res.status == null ? 1 : res.status);
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "memorizz",
3
+ "version": "0.1.0",
4
+ "description": "npm bootstrapper for the memorizz Python CLI — installs the real tool via uv.",
5
+ "license": "PolyForm-Noncommercial-1.0.0",
6
+ "homepage": "https://github.com/RichmondAlake/memorizz",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/RichmondAlake/memorizz.git",
10
+ "directory": "packaging/npm"
11
+ },
12
+ "keywords": ["memorizz", "ai", "agent", "cli", "memory", "llm", "ollama"],
13
+ "bin": {
14
+ "memorizz": "bin/memorizz.js"
15
+ },
16
+ "scripts": {
17
+ "postinstall": "node scripts/postinstall.js"
18
+ },
19
+ "files": ["bin/", "scripts/", "README.md"],
20
+ "engines": {
21
+ "node": ">=16"
22
+ },
23
+ "os": ["darwin", "linux", "win32"]
24
+ }
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) 2024 Richmond Alake. Licensed under PolyForm Noncommercial 1.0.0.
3
+ //
4
+ // Convenience bootstrapper: `npm i -g memorizz` installs the real Python CLI via
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 memorizz`
7
+ // and `pipx install memorizz` are first-class. Fails soft: a bootstrap error
8
+ // never bricks the package — bin/memorizz.js retries via `uv tool run` on first
9
+ // use.
10
+ "use strict";
11
+
12
+ const { spawnSync } = require("child_process");
13
+ const os = require("os");
14
+ const path = require("path");
15
+ const fs = require("fs");
16
+
17
+ const VERSION = require("../package.json").version;
18
+
19
+ const log = (m) => process.stdout.write(`[memorizz] ${m}\n`);
20
+ const warn = (m) => process.stderr.write(`[memorizz] ${m}\n`);
21
+
22
+ function which(cmd) {
23
+ const finder = process.platform === "win32" ? "where" : "which";
24
+ const r = spawnSync(finder, [cmd], { encoding: "utf8" });
25
+ if (r.status === 0 && r.stdout) return r.stdout.split(/\r?\n/)[0].trim();
26
+ return null;
27
+ }
28
+
29
+ function uvBinDirs() {
30
+ const home = os.homedir();
31
+ return [
32
+ path.join(home, ".local", "bin"),
33
+ path.join(home, ".cargo", "bin"),
34
+ path.join(home, ".local", "share", "uv", "bin"),
35
+ ];
36
+ }
37
+
38
+ function findUv() {
39
+ const onPath = which("uv");
40
+ if (onPath) return onPath;
41
+ const exe = process.platform === "win32" ? "uv.exe" : "uv";
42
+ for (const dir of uvBinDirs()) {
43
+ const candidate = path.join(dir, exe);
44
+ if (fs.existsSync(candidate)) return candidate;
45
+ }
46
+ return null;
47
+ }
48
+
49
+ function installUv() {
50
+ log("Installing uv (standalone, no Python required)…");
51
+ if (process.platform === "win32") {
52
+ spawnSync(
53
+ "powershell",
54
+ ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "irm https://astral.sh/uv/install.ps1 | iex"],
55
+ { stdio: "inherit" }
56
+ );
57
+ } else {
58
+ spawnSync("sh", ["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"], { stdio: "inherit" });
59
+ }
60
+ return findUv();
61
+ }
62
+
63
+ function main() {
64
+ if (process.env.MEMORIZZ_SKIP_POSTINSTALL) {
65
+ log("postinstall skipped (MEMORIZZ_SKIP_POSTINSTALL set)");
66
+ return;
67
+ }
68
+
69
+ let uv = findUv() || installUv();
70
+ if (uv) {
71
+ log(`Installing memorizz==${VERSION} via uv…`);
72
+ const r = spawnSync(uv, ["tool", "install", "--force", `memorizz==${VERSION}`], { stdio: "inherit" });
73
+ if (r.status === 0) {
74
+ log("Done. Run: memorizz");
75
+ return;
76
+ }
77
+ warn("uv install failed — trying pipx fallback.");
78
+ }
79
+
80
+ const pipx = which("pipx");
81
+ if (pipx) {
82
+ const r = spawnSync(pipx, ["install", "--force", `memorizz==${VERSION}`], { stdio: "inherit" });
83
+ if (r.status === 0) {
84
+ log("Done (via pipx). Run: memorizz");
85
+ return;
86
+ }
87
+ }
88
+
89
+ warn(
90
+ [
91
+ "Could not bootstrap memorizz automatically.",
92
+ "Install it manually with either:",
93
+ " curl -LsSf https://astral.sh/uv/install.sh | sh # then: uv tool install memorizz",
94
+ " pipx install memorizz",
95
+ "The `memorizz` launcher will also retry via `uv tool run` on first use.",
96
+ ].join("\n")
97
+ );
98
+ // Intentionally exit 0 (fail-soft).
99
+ }
100
+
101
+ main();