@onebrain-ai/cli 2.1.0 → 2.1.4
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 +6 -3
- package/dist/onebrain +534 -1262
- package/dist/postinstall.js +138 -0
- package/package.json +5 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/scripts/postinstall.ts
|
|
21
|
+
import { chmod, createWriteStream, existsSync, rename, unlink } from "node:fs";
|
|
22
|
+
import { get as httpsGet } from "node:https";
|
|
23
|
+
import { dirname, join } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
var PLATFORM_MAP = {
|
|
26
|
+
"darwin-arm64": "onebrain-darwin-arm64",
|
|
27
|
+
"darwin-x64": "onebrain-darwin-x64",
|
|
28
|
+
"linux-arm64": "onebrain-linux-arm64",
|
|
29
|
+
"linux-x64": "onebrain-linux-x64",
|
|
30
|
+
"linux-arm64-musl": "onebrain-linux-arm64-musl",
|
|
31
|
+
"linux-x64-musl": "onebrain-linux-x64-musl",
|
|
32
|
+
"win32-x64": "onebrain-windows-x64.exe"
|
|
33
|
+
};
|
|
34
|
+
function getBinaryName(platform, arch, musl = false) {
|
|
35
|
+
const key = musl ? `${platform}-${arch}-musl` : `${platform}-${arch}`;
|
|
36
|
+
return PLATFORM_MAP[key] ?? null;
|
|
37
|
+
}
|
|
38
|
+
function detectMusl() {
|
|
39
|
+
if (process.platform !== "linux")
|
|
40
|
+
return false;
|
|
41
|
+
return existsSync("/lib/libc.musl-x86_64.so.1") || existsSync("/lib/libc.musl-aarch64.so.1") || existsSync("/lib/ld-musl-x86_64.so.1") || existsSync("/lib/ld-musl-aarch64.so.1");
|
|
42
|
+
}
|
|
43
|
+
function download(url, destPath) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const tmp = `${destPath}.tmp`;
|
|
46
|
+
function fetch(currentUrl, redirectsLeft) {
|
|
47
|
+
if (redirectsLeft === 0) {
|
|
48
|
+
reject(new Error("too many redirects"));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
httpsGet(currentUrl, { headers: { "User-Agent": "onebrain-postinstall" } }, (res) => {
|
|
52
|
+
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
53
|
+
res.resume();
|
|
54
|
+
fetch(res.headers.location, redirectsLeft - 1);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (res.statusCode !== 200) {
|
|
58
|
+
res.resume();
|
|
59
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const out = createWriteStream(tmp);
|
|
63
|
+
res.pipe(out);
|
|
64
|
+
out.on("finish", () => {
|
|
65
|
+
rename(tmp, destPath, (err) => {
|
|
66
|
+
if (err)
|
|
67
|
+
reject(err);
|
|
68
|
+
else
|
|
69
|
+
resolve();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
out.on("error", (err) => {
|
|
73
|
+
unlink(tmp, () => {});
|
|
74
|
+
reject(err);
|
|
75
|
+
});
|
|
76
|
+
res.on("error", (err) => {
|
|
77
|
+
unlink(tmp, () => {});
|
|
78
|
+
reject(err);
|
|
79
|
+
});
|
|
80
|
+
}).on("error", reject);
|
|
81
|
+
}
|
|
82
|
+
fetch(url, 5);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function chmodExec(filePath) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
chmod(filePath, 493, (err) => {
|
|
88
|
+
if (err)
|
|
89
|
+
reject(err);
|
|
90
|
+
else
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async function main() {
|
|
96
|
+
const platform = process.platform;
|
|
97
|
+
const arch = process.arch;
|
|
98
|
+
const musl = detectMusl();
|
|
99
|
+
const binaryName = getBinaryName(platform, arch, musl);
|
|
100
|
+
if (!binaryName) {
|
|
101
|
+
process.stderr.write(`[onebrain] Unsupported platform: ${platform}/${arch}${musl ? "-musl" : ""}.
|
|
102
|
+
Install Bun (https://bun.sh) to use the JS bundle fallback.
|
|
103
|
+
`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
107
|
+
const pkgPath = join(__dirname2, "..", "package.json");
|
|
108
|
+
let version;
|
|
109
|
+
try {
|
|
110
|
+
const { readFileSync } = await import("node:fs");
|
|
111
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
112
|
+
version = pkg.version;
|
|
113
|
+
} catch {
|
|
114
|
+
process.stderr.write(`[onebrain] Could not read package version — skipping binary download.
|
|
115
|
+
`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const destPath = join(__dirname2, "onebrain");
|
|
119
|
+
const url = `https://github.com/kengio/onebrain/releases/download/v${version}/${binaryName}`;
|
|
120
|
+
process.stdout.write(`[onebrain] Downloading ${binaryName} v${version}…
|
|
121
|
+
`);
|
|
122
|
+
try {
|
|
123
|
+
await download(url, destPath);
|
|
124
|
+
if (platform !== "win32")
|
|
125
|
+
await chmodExec(destPath);
|
|
126
|
+
process.stdout.write(`[onebrain] Ready.
|
|
127
|
+
`);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
130
|
+
process.stderr.write(`[onebrain] Download failed: ${msg}
|
|
131
|
+
Install Bun (https://bun.sh) to use the JS bundle fallback.
|
|
132
|
+
`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
main();
|
|
136
|
+
export {
|
|
137
|
+
getBinaryName
|
|
138
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onebrain-ai/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "CLI for OneBrain — personal AI OS for Obsidian with persistent memory, 24+ skills, and Claude Code integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"onebrain",
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
"bin": {
|
|
27
27
|
"onebrain": "dist/onebrain"
|
|
28
28
|
},
|
|
29
|
-
"files": ["dist/onebrain"],
|
|
29
|
+
"files": ["dist/onebrain", "dist/postinstall.js"],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "bun build src/index.ts --outfile dist/onebrain --target
|
|
31
|
+
"build": "bun build src/index.ts --outfile dist/onebrain --target bun",
|
|
32
|
+
"build:postinstall": "bun build src/scripts/postinstall.ts --outfile dist/postinstall.js --target node",
|
|
33
|
+
"postinstall": "node dist/postinstall.js",
|
|
32
34
|
"test": "bun test --pass-with-no-tests src/",
|
|
33
35
|
"typecheck": "tsc --noEmit"
|
|
34
36
|
},
|