kannaka 0.11.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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # kannaka
2
+
3
+ Wave-interference (Holographic Resonance Medium) memory for AI agents — the
4
+ native `kannaka` CLI, distributed over npm.
5
+
6
+ ```sh
7
+ # one-off, no install
8
+ npx kannaka --version
9
+
10
+ # or install globally
11
+ npm install -g kannaka
12
+ kannaka remember "the grid hums at 72.83Hz" --importance 0.8
13
+ kannaka recall "what frequency" --top-k 5
14
+ ```
15
+
16
+ ## How it works
17
+
18
+ This package ships a tiny launcher. On install, its `postinstall` step
19
+ downloads the native `kannaka` binary for your platform from the matching
20
+ [GitHub release](https://github.com/NickFlach/kannaka-memory/releases),
21
+ verifies its published `sha256`, and places it next to the launcher. No native
22
+ binary is bundled in the tarball, so one small package serves every platform.
23
+
24
+ Supported platforms: **linux**, **macOS**, **windows** on **x86_64** and
25
+ **aarch64** (Linux builds are static musl, so they run on any distro).
26
+
27
+ ## Environment
28
+
29
+ - `KANNAKA_SKIP_DOWNLOAD=1` — skip the postinstall download (offline / CI /
30
+ source builds). The launcher then reports the binary is missing until you
31
+ provide one.
32
+ - `KANNAKA_DATA_DIR` — where the HRM store lives (default `~/.kannaka`).
33
+
34
+ ## Alternatives
35
+
36
+ - Direct install script: `curl -sSf https://install.ninja-portal.com/kannaka | sh`
37
+ - Docker: `docker run --rm ghcr.io/nickflach/kannaka --version`
38
+ - Build from source: <https://github.com/NickFlach/kannaka-memory>
39
+
40
+ MIT licensed. The version of this package tracks the kannaka release it installs.
package/bin/kannaka.js ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Thin launcher: exec the native kannaka binary fetched by install.js, passing
4
+ * through argv and forwarding its exit code / signals. Keeps `npx kannaka` and
5
+ * a global install behaving exactly like the native CLI.
6
+ */
7
+ "use strict";
8
+
9
+ const { spawnSync } = require("child_process");
10
+ const path = require("path");
11
+ const fs = require("fs");
12
+
13
+ const ext = process.platform === "win32" ? ".exe" : "";
14
+ const bin = path.join(__dirname, `kannaka-bin${ext}`);
15
+
16
+ if (!fs.existsSync(bin)) {
17
+ console.error(
18
+ "kannaka: native binary not found — the postinstall download did not run or failed.\n" +
19
+ "Reinstall with network access (e.g. `npm install -g kannaka`), or install directly:\n" +
20
+ " curl -sSf https://install.ninja-portal.com/kannaka | sh",
21
+ );
22
+ process.exit(1);
23
+ }
24
+
25
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
26
+ if (res.error) {
27
+ console.error(`kannaka: ${res.error.message}`);
28
+ process.exit(1);
29
+ }
30
+ if (res.signal) {
31
+ // Re-raise the terminating signal so shells report it correctly.
32
+ process.kill(process.pid, res.signal);
33
+ return;
34
+ }
35
+ process.exit(res.status == null ? 1 : res.status);
package/install.js ADDED
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Postinstall: fetch the platform-matched native `kannaka` binary from the
4
+ * GitHub release that matches this package's version, verify its published
5
+ * sha256, and drop it next to the launcher. No native binary is shipped inside
6
+ * the npm tarball — it is downloaded here so one small package serves every
7
+ * platform.
8
+ *
9
+ * Env:
10
+ * KANNAKA_SKIP_DOWNLOAD=1 skip the download (CI / offline / source builds)
11
+ */
12
+ "use strict";
13
+
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+ const https = require("https");
17
+ const crypto = require("crypto");
18
+
19
+ const pkg = require("./package.json");
20
+ const VERSION = pkg.version;
21
+ const REPO = "NickFlach/kannaka-memory";
22
+
23
+ const OS_MAP = { linux: "linux", darwin: "macos", win32: "windows" };
24
+ const ARCH_MAP = { x64: "x86_64", arm64: "aarch64" };
25
+
26
+ function target() {
27
+ const os = OS_MAP[process.platform];
28
+ const arch = ARCH_MAP[process.arch];
29
+ if (!os || !arch) {
30
+ throw new Error(
31
+ `unsupported platform ${process.platform}/${process.arch}. Prebuilt ` +
32
+ `kannaka binaries exist for linux/macos/windows on x86_64/aarch64. ` +
33
+ `Build from source: https://github.com/${REPO}`,
34
+ );
35
+ }
36
+ const ext = process.platform === "win32" ? ".exe" : "";
37
+ return { os, arch, ext };
38
+ }
39
+
40
+ /** GET a URL, following GitHub's redirect to the asset CDN, resolving to a Buffer. */
41
+ function get(url, redirects = 0) {
42
+ return new Promise((resolve, reject) => {
43
+ if (redirects > 5) return reject(new Error("too many redirects"));
44
+ https
45
+ .get(url, { headers: { "User-Agent": "kannaka-npm-installer" } }, (res) => {
46
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
47
+ res.resume();
48
+ resolve(get(res.headers.location, redirects + 1));
49
+ return;
50
+ }
51
+ if (res.statusCode !== 200) {
52
+ res.resume();
53
+ reject(new Error(`HTTP ${res.statusCode} for ${url}`));
54
+ return;
55
+ }
56
+ const chunks = [];
57
+ res.on("data", (c) => chunks.push(c));
58
+ res.on("end", () => resolve(Buffer.concat(chunks)));
59
+ res.on("error", reject);
60
+ })
61
+ .on("error", reject);
62
+ });
63
+ }
64
+
65
+ async function main() {
66
+ if (process.env.KANNAKA_SKIP_DOWNLOAD === "1") {
67
+ console.log("kannaka: KANNAKA_SKIP_DOWNLOAD=1 — skipping binary download.");
68
+ return;
69
+ }
70
+
71
+ const { os, arch, ext } = target();
72
+ const asset = `kannaka-${os}-${arch}${ext}`;
73
+ const base = `https://github.com/${REPO}/releases/download/v${VERSION}`;
74
+ const binDir = path.join(__dirname, "bin");
75
+ fs.mkdirSync(binDir, { recursive: true });
76
+ const dest = path.join(binDir, `kannaka-bin${ext}`);
77
+
78
+ console.log(`kannaka: downloading ${asset} (v${VERSION})…`);
79
+ const bin = await get(`${base}/${asset}`);
80
+
81
+ // Verify against the published <asset>.sha256 (format: "<hex> <name>" or bare hex).
82
+ try {
83
+ const shaText = (await get(`${base}/${asset}.sha256`)).toString("utf8").trim();
84
+ const expected = shaText.split(/\s+/)[0].toLowerCase();
85
+ const actual = crypto.createHash("sha256").update(bin).digest("hex");
86
+ if (expected && expected !== actual) {
87
+ throw new Error(`sha256 mismatch for ${asset}: expected ${expected}, got ${actual}`);
88
+ }
89
+ console.log("kannaka: sha256 verified.");
90
+ } catch (e) {
91
+ if (String(e && e.message).includes("mismatch")) throw e;
92
+ console.warn(`kannaka: could not verify sha256 (${e && e.message}); proceeding.`);
93
+ }
94
+
95
+ fs.writeFileSync(dest, bin);
96
+ if (process.platform !== "win32") fs.chmodSync(dest, 0o755);
97
+ console.log(`kannaka: installed ${dest}`);
98
+ }
99
+
100
+ main().catch((e) => {
101
+ console.error(`kannaka: install failed: ${e && e.message}`);
102
+ console.error(
103
+ "You can retry with network access, or install the binary directly:\n" +
104
+ " curl -sSf https://install.ninja-portal.com/kannaka | sh",
105
+ );
106
+ process.exit(1);
107
+ });
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "kannaka",
3
+ "version": "0.11.1",
4
+ "description": "Kannaka — wave-interference (Holographic Resonance Medium) memory for AI agents. Installs the native `kannaka` CLI.",
5
+ "bin": {
6
+ "kannaka": "bin/kannaka.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "bin/kannaka.js",
13
+ "install.js",
14
+ "README.md"
15
+ ],
16
+ "keywords": [
17
+ "kannaka",
18
+ "memory",
19
+ "agent",
20
+ "hrm",
21
+ "holographic",
22
+ "resonance",
23
+ "wave-interference",
24
+ "vector",
25
+ "cli"
26
+ ],
27
+ "homepage": "https://github.com/NickFlach/kannaka-memory#readme",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/NickFlach/kannaka-memory.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/NickFlach/kannaka-memory/issues"
34
+ },
35
+ "license": "MIT",
36
+ "engines": {
37
+ "node": ">=16"
38
+ },
39
+ "os": [
40
+ "linux",
41
+ "darwin",
42
+ "win32"
43
+ ],
44
+ "cpu": [
45
+ "x64",
46
+ "arm64"
47
+ ]
48
+ }