@ukibbb/buli 0.1.0-rc.10
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/LICENSE +21 -0
- package/README.md +18 -0
- package/bin/buli.mjs +16 -0
- package/install.d.mts +12 -0
- package/install.mjs +136 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ukibbb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @ukibbb/buli
|
|
2
|
+
|
|
3
|
+
Installs the native Buli CLI for macOS or Linux from the matching GitHub
|
|
4
|
+
Release. The installer verifies the published SHA-256 checksum before placing
|
|
5
|
+
the executable and its private ripgrep sidecar inside this npm package.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --global @ukibbb/buli
|
|
9
|
+
buli --version
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Release candidates are published under the npm `next` dist-tag.
|
|
13
|
+
|
|
14
|
+
For npm-managed installations, update through npm:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --global @ukibbb/buli@next
|
|
18
|
+
```
|
package/bin/buli.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
|
|
7
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
8
|
+
const executable = join(packageRoot, "vendor", "bin", "buli");
|
|
9
|
+
const result = spawnSync(executable, process.argv.slice(2), { stdio: "inherit" });
|
|
10
|
+
|
|
11
|
+
if (result.error) {
|
|
12
|
+
console.error(`Cannot start Buli: ${result.error.message}`);
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
} else {
|
|
15
|
+
process.exitCode = result.status ?? 1;
|
|
16
|
+
}
|
package/install.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IInstallBinaryOptions {
|
|
2
|
+
readonly version?: string;
|
|
3
|
+
readonly platform?: NodeJS.Platform;
|
|
4
|
+
readonly architecture?: string;
|
|
5
|
+
readonly destination?: string;
|
|
6
|
+
readonly fetchAsset?: (
|
|
7
|
+
input: string | URL | Request,
|
|
8
|
+
init?: RequestInit,
|
|
9
|
+
) => Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function installBinary(options?: IInstallBinaryOptions): Promise<void>;
|
package/install.mjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import {
|
|
4
|
+
chmod,
|
|
5
|
+
mkdir,
|
|
6
|
+
mkdtemp,
|
|
7
|
+
readFile,
|
|
8
|
+
rename,
|
|
9
|
+
rm,
|
|
10
|
+
writeFile,
|
|
11
|
+
} from "node:fs/promises";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
|
|
16
|
+
const REPOSITORY = "ukibbb/buliV2";
|
|
17
|
+
const packageRoot = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
|
|
19
|
+
export async function installBinary(options = {}) {
|
|
20
|
+
const metadata = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"));
|
|
21
|
+
const version = options.version ?? metadata.version;
|
|
22
|
+
const platform = options.platform ?? process.platform;
|
|
23
|
+
const architecture = options.architecture ?? process.arch;
|
|
24
|
+
const fetchAsset = options.fetchAsset ?? fetch;
|
|
25
|
+
const destination = options.destination ?? join(packageRoot, "vendor");
|
|
26
|
+
const target = releaseTarget(platform, architecture);
|
|
27
|
+
const asset = `buli-${target}.tar.gz`;
|
|
28
|
+
const baseUrl = `https://github.com/${REPOSITORY}/releases/download/v${version}`;
|
|
29
|
+
const temporaryDirectory = await mkdtemp(join(tmpdir(), "buli-npm-install-"));
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const [archiveResponse, checksumResponse] = await Promise.all([
|
|
33
|
+
fetchAsset(`${baseUrl}/${asset}`, requestOptions()),
|
|
34
|
+
fetchAsset(`${baseUrl}/${asset}.sha256`, requestOptions()),
|
|
35
|
+
]);
|
|
36
|
+
if (!archiveResponse.ok || !checksumResponse.ok) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`cannot download Buli ${version}: archive HTTP ${archiveResponse.status}, `
|
|
39
|
+
+ `checksum HTTP ${checksumResponse.status}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const archive = new Uint8Array(await archiveResponse.arrayBuffer());
|
|
44
|
+
const expectedChecksum = (await checksumResponse.text()).trim().split(/\s+/)[0];
|
|
45
|
+
if (!expectedChecksum || !/^[0-9a-fA-F]{64}$/.test(expectedChecksum)) {
|
|
46
|
+
throw new Error("release checksum has an invalid format");
|
|
47
|
+
}
|
|
48
|
+
const actualChecksum = createHash("sha256").update(archive).digest("hex");
|
|
49
|
+
if (actualChecksum.toLowerCase() !== expectedChecksum.toLowerCase()) {
|
|
50
|
+
throw new Error(`checksum verification failed for ${asset}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const archivePath = join(temporaryDirectory, asset);
|
|
54
|
+
const extractionDirectory = join(temporaryDirectory, "extracted");
|
|
55
|
+
await writeFile(archivePath, archive);
|
|
56
|
+
await mkdir(extractionDirectory);
|
|
57
|
+
await run("tar", [
|
|
58
|
+
"--extract",
|
|
59
|
+
"--gzip",
|
|
60
|
+
"--file",
|
|
61
|
+
archivePath,
|
|
62
|
+
"--directory",
|
|
63
|
+
extractionDirectory,
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
const bundle = join(extractionDirectory, `buli-${target}`);
|
|
67
|
+
const executable = join(bundle, "bin", "buli");
|
|
68
|
+
const ripgrep = join(bundle, "lib", "buli", "rg");
|
|
69
|
+
await Promise.all([chmod(executable, 0o755), chmod(ripgrep, 0o755)]);
|
|
70
|
+
const installedVersion = (await run(executable, ["--version"], true)).trim();
|
|
71
|
+
if (installedVersion !== version) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`downloaded Buli reports version ${JSON.stringify(installedVersion)}, `
|
|
74
|
+
+ `expected ${JSON.stringify(version)}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
await run(ripgrep, ["--version"]);
|
|
78
|
+
await readFile(join(bundle, "THIRD_PARTY_LICENSES"));
|
|
79
|
+
|
|
80
|
+
const stagedDestination = join(temporaryDirectory, "vendor");
|
|
81
|
+
await rename(bundle, stagedDestination);
|
|
82
|
+
await rm(destination, { recursive: true, force: true });
|
|
83
|
+
await rename(stagedDestination, destination);
|
|
84
|
+
} finally {
|
|
85
|
+
await rm(temporaryDirectory, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function releaseTarget(platform, architecture) {
|
|
90
|
+
const releasePlatform = platform === "darwin"
|
|
91
|
+
? "darwin"
|
|
92
|
+
: platform === "linux" ? "linux" : undefined;
|
|
93
|
+
const releaseArchitecture = architecture === "arm64"
|
|
94
|
+
? "arm64"
|
|
95
|
+
: architecture === "x64" ? "x64" : undefined;
|
|
96
|
+
if (!releasePlatform || !releaseArchitecture) {
|
|
97
|
+
throw new Error(`unsupported platform ${platform}-${architecture}`);
|
|
98
|
+
}
|
|
99
|
+
return `${releasePlatform}-${releaseArchitecture}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function requestOptions() {
|
|
103
|
+
return {
|
|
104
|
+
headers: { "User-Agent": "@ukibbb/buli npm installer" },
|
|
105
|
+
signal: AbortSignal.timeout(30_000),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function run(command, args, capture = false) {
|
|
110
|
+
const child = spawn(command, args, {
|
|
111
|
+
stdio: ["ignore", capture ? "pipe" : "ignore", "pipe"],
|
|
112
|
+
});
|
|
113
|
+
let stdout = "";
|
|
114
|
+
let stderr = "";
|
|
115
|
+
child.stdout?.setEncoding("utf8");
|
|
116
|
+
child.stderr.setEncoding("utf8");
|
|
117
|
+
child.stdout?.on("data", (chunk) => { stdout += chunk; });
|
|
118
|
+
child.stderr.on("data", (chunk) => { stderr += chunk; });
|
|
119
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
120
|
+
child.once("error", reject);
|
|
121
|
+
child.once("close", resolve);
|
|
122
|
+
});
|
|
123
|
+
if (exitCode !== 0) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`command failed with exit code ${exitCode}: ${command} ${args.join(" ")}\n${stderr.trim()}`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return stdout;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === fileURLToPath(new URL(`file://${process.argv[1]}`))) {
|
|
132
|
+
installBinary().catch((error) => {
|
|
133
|
+
console.error(`buli npm installer: ${error instanceof Error ? error.message : String(error)}`);
|
|
134
|
+
process.exitCode = 1;
|
|
135
|
+
});
|
|
136
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ukibbb/buli",
|
|
3
|
+
"version": "0.1.0-rc.10",
|
|
4
|
+
"description": "Buli terminal coding agent",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/ukibbb/buliV2.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/ukibbb/buliV2#readme",
|
|
11
|
+
"bugs": "https://github.com/ukibbb/buliV2/issues",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"bin": {
|
|
14
|
+
"buli": "bin/buli.mjs"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin",
|
|
18
|
+
"install.mjs",
|
|
19
|
+
"install.d.mts",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"postinstall": "node install.mjs"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"os": [
|
|
30
|
+
"darwin",
|
|
31
|
+
"linux"
|
|
32
|
+
],
|
|
33
|
+
"cpu": [
|
|
34
|
+
"arm64",
|
|
35
|
+
"x64"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|