@entelligentsia/grove 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/bin/grove.js +16 -0
- package/install.js +101 -0
- package/package.json +26 -0
package/bin/grove.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin launcher: exec the prebuilt binary that install.js placed in vendor/.
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { spawnSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const binName = process.platform === "win32" ? "grove.exe" : "grove";
|
|
9
|
+
const bin = path.join(__dirname, "..", "vendor", binName);
|
|
10
|
+
|
|
11
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
12
|
+
if (r.error) {
|
|
13
|
+
console.error(`grove: failed to run binary (${r.error.message}). Try reinstalling.`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
process.exit(r.status === null ? 1 : r.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// postinstall: download the prebuilt grove binary matching this package's
|
|
3
|
+
// version from the GitHub Release, verify its sha256, and extract it into
|
|
4
|
+
// vendor/. The bin shim (bin/grove.js) execs whatever lands there.
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const https = require("https");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const os = require("os");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const crypto = require("crypto");
|
|
12
|
+
const { execFileSync } = require("child_process");
|
|
13
|
+
|
|
14
|
+
const REPO = "Entelligentsia/grove";
|
|
15
|
+
const { version } = require("./package.json");
|
|
16
|
+
|
|
17
|
+
const TARGETS = {
|
|
18
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
19
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
20
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
21
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
22
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function fail(msg) {
|
|
26
|
+
console.error(`grove: ${msg}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function get(url, dest) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
https
|
|
33
|
+
.get(url, { headers: { "User-Agent": "grove-npm-installer" } }, (res) => {
|
|
34
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
35
|
+
res.resume();
|
|
36
|
+
return resolve(get(res.headers.location, dest));
|
|
37
|
+
}
|
|
38
|
+
if (res.statusCode !== 200) {
|
|
39
|
+
res.resume();
|
|
40
|
+
return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
41
|
+
}
|
|
42
|
+
const out = fs.createWriteStream(dest);
|
|
43
|
+
res.pipe(out);
|
|
44
|
+
out.on("finish", () => out.close(resolve));
|
|
45
|
+
out.on("error", reject);
|
|
46
|
+
})
|
|
47
|
+
.on("error", reject);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function getText(url) {
|
|
52
|
+
const tmp = path.join(os.tmpdir(), `grove-sha-${process.pid}`);
|
|
53
|
+
await get(url, tmp);
|
|
54
|
+
const t = fs.readFileSync(tmp, "utf8");
|
|
55
|
+
fs.unlinkSync(tmp);
|
|
56
|
+
return t;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const key = `${process.platform}-${process.arch}`;
|
|
61
|
+
const target = TARGETS[key];
|
|
62
|
+
if (!target) {
|
|
63
|
+
fail(`no prebuilt for ${key}. Install from source: cargo install --git https://github.com/${REPO}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isWin = process.platform === "win32";
|
|
67
|
+
const ext = isWin ? "zip" : "tar.gz";
|
|
68
|
+
const asset = `grove-${target}.${ext}`;
|
|
69
|
+
const base = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
70
|
+
const url = `${base}/${asset}`;
|
|
71
|
+
|
|
72
|
+
const vendor = path.join(__dirname, "vendor");
|
|
73
|
+
fs.mkdirSync(vendor, { recursive: true });
|
|
74
|
+
const archive = path.join(vendor, asset);
|
|
75
|
+
|
|
76
|
+
console.error(`grove: downloading ${asset} (v${version})`);
|
|
77
|
+
await get(url, archive);
|
|
78
|
+
|
|
79
|
+
// Verify checksum when the sidecar is present.
|
|
80
|
+
try {
|
|
81
|
+
const expected = (await getText(`${url}.sha256`)).trim().split(/\s+/)[0];
|
|
82
|
+
const actual = crypto.createHash("sha256").update(fs.readFileSync(archive)).digest("hex");
|
|
83
|
+
if (expected && expected !== actual) {
|
|
84
|
+
fail(`checksum mismatch: expected ${expected}, got ${actual}`);
|
|
85
|
+
}
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error(`grove: skipping checksum verification (${e.message})`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// System tar extracts both .tar.gz and .zip (bsdtar on Windows 10+, GNU/bsd tar on unix).
|
|
91
|
+
execFileSync("tar", ["-xf", archive, "-C", vendor], { stdio: "inherit" });
|
|
92
|
+
fs.unlinkSync(archive);
|
|
93
|
+
|
|
94
|
+
const binName = isWin ? "grove.exe" : "grove";
|
|
95
|
+
const bin = path.join(vendor, binName);
|
|
96
|
+
if (!fs.existsSync(bin)) fail(`binary ${binName} not found after extract`);
|
|
97
|
+
if (!isWin) fs.chmodSync(bin, 0o755);
|
|
98
|
+
console.error(`grove: installed ${bin}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main().catch((e) => fail(e.message));
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@entelligentsia/grove",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Structural, byte-precise, token-cheap access to a codebase for coding agents — tree-sitter over a CLI and an MCP server.",
|
|
5
|
+
"homepage": "https://github.com/Entelligentsia/grove",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Entelligentsia/grove.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bin": {
|
|
12
|
+
"grove": "bin/grove.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/grove.js",
|
|
19
|
+
"install.js"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=16"
|
|
23
|
+
},
|
|
24
|
+
"os": ["darwin", "linux", "win32"],
|
|
25
|
+
"cpu": ["x64", "arm64"]
|
|
26
|
+
}
|