@npie/cli 0.1.0-npie.5 → 0.1.0-npie.7
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 +9 -9
- package/bin/t3.mjs +49 -17
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -17,13 +17,13 @@ npx @npie/cli@latest # 首次运行会拉取源码并构建,需要几
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install -g @npie/cli
|
|
19
19
|
t3 # 启动服务端并打开 Web 界面
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
npie serve # 只启动服务端
|
|
21
|
+
npie pair # 生成配对链接,供手机或其它设备连接
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## 它做了什么
|
|
25
25
|
|
|
26
|
-
第一次运行 `
|
|
26
|
+
第一次运行 `npie` 时,它会:
|
|
27
27
|
|
|
28
28
|
1. 从 GitHub 下载对应版本的源码
|
|
29
29
|
2. 运行 `pnpm install --frozen-lockfile`
|
|
@@ -36,12 +36,12 @@ t3 pair # 生成配对链接,供手机或其它设备连
|
|
|
36
36
|
|
|
37
37
|
## 前置要求
|
|
38
38
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
| Node.js | **24 或更新**(`node --version` 检查)
|
|
42
|
-
| pnpm
|
|
43
|
-
| 磁盘
|
|
44
|
-
| 智能体
|
|
39
|
+
| | |
|
|
40
|
+
| ------- | ------------------------------------------------------------- |
|
|
41
|
+
| Node.js | **24 或更新**(`node --version` 检查) |
|
|
42
|
+
| pnpm | 通过 `corepack enable pnpm` 启用,Node 自带 |
|
|
43
|
+
| 磁盘 | 首次构建约需 1.5 GB(依赖 + 产物) |
|
|
44
|
+
| 智能体 | 至少安装并登录一个,例如 `claude auth login` 或 `codex login` |
|
|
45
45
|
|
|
46
46
|
## 为什么要先构建
|
|
47
47
|
|
package/bin/t3.mjs
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Npie CLI bootstrap.
|
|
3
|
-
//
|
|
4
|
-
// Npie ships source only. This launcher keeps a checkout in NPIE_HOME (default
|
|
5
|
-
// ~/.npie-cli/source), fetches the requested version, installs dependencies once, builds the
|
|
6
|
-
// server, and then runs it. The bin is still called `t3` because every doc, service unit
|
|
7
|
-
// and keybinding in the product uses that name.
|
|
8
|
-
//
|
|
9
|
-
// Why not ship prebuilt binaries: signing macOS and Windows builds needs certificates
|
|
10
|
-
// this project does not hold yet. A bootstrap is honest about what it does and works on
|
|
11
|
-
// every platform Node runs on.
|
|
2
|
+
// Npie CLI bootstrap: builds a checkout from source in NPIE_HOME, then runs it.
|
|
3
|
+
// No prebuilt binaries: signing needs certificates this project does not hold.
|
|
12
4
|
|
|
13
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
14
7
|
import fs from "node:fs";
|
|
15
8
|
import os from "node:os";
|
|
16
9
|
import path from "node:path";
|
|
@@ -21,8 +14,14 @@ const { version } = JSON.parse(
|
|
|
21
14
|
);
|
|
22
15
|
|
|
23
16
|
const REPOSITORY = "BannyLon/npie";
|
|
24
|
-
|
|
17
|
+
// The release attaches a source archive and SHA256SUMS.txt covering it. Prefer those over
|
|
18
|
+
// GitHub's auto-generated tarball so the download can be verified against a published digest.
|
|
19
|
+
const RELEASE_BASE = `https://github.com/${REPOSITORY}/releases/download/v${version}`;
|
|
20
|
+
const TARBALL_NAME = `npie-v${version}-source.tar.gz`;
|
|
21
|
+
const TARBALL = `${RELEASE_BASE}/${TARBALL_NAME}`;
|
|
22
|
+
const CHECKSUMS = `${RELEASE_BASE}/SHA256SUMS.txt`;
|
|
25
23
|
const REQUIRED_NODE_MAJOR = 24;
|
|
24
|
+
const REQUIRED_NODE_MINOR = 10;
|
|
26
25
|
|
|
27
26
|
function npiHome() {
|
|
28
27
|
const raw = (process.env.NPIE_HOME || "").trim();
|
|
@@ -53,7 +52,32 @@ function run(command, args, options = {}) {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
async function
|
|
55
|
+
async function fetchText(url) {
|
|
56
|
+
const response = await fetch(url, { redirect: "follow" });
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(`could not download ${url} (HTTP ${response.status})`);
|
|
59
|
+
}
|
|
60
|
+
return response.text();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Downloads the release source archive and verifies it against the published digest. */
|
|
64
|
+
async function downloadSource(target) {
|
|
65
|
+
let expected;
|
|
66
|
+
try {
|
|
67
|
+
const sums = await fetchText(CHECKSUMS);
|
|
68
|
+
const line = sums.split("\n").find((entry) => entry.trim().endsWith(TARBALL_NAME));
|
|
69
|
+
expected = line?.trim().split(/\s+/)[0];
|
|
70
|
+
} catch (error) {
|
|
71
|
+
fail(
|
|
72
|
+
`could not read the checksums for v${version}`,
|
|
73
|
+
`${String(error?.message ?? error)}\nCheck that the tag exists: https://github.com/${REPOSITORY}/releases`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
// Publishing an archive without a matching digest is a release bug, not something to skip.
|
|
77
|
+
if (!expected || !/^[0-9a-f]{64}$/i.test(expected)) {
|
|
78
|
+
fail(`v${version} has no SHA256 digest for ${TARBALL_NAME}; refusing an unverified download.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
57
81
|
let response;
|
|
58
82
|
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
|
59
83
|
response = await fetch(TARBALL, { redirect: "follow" });
|
|
@@ -67,7 +91,12 @@ async function downloadTarball(target) {
|
|
|
67
91
|
`Check that the tag exists: https://github.com/${REPOSITORY}/releases`,
|
|
68
92
|
);
|
|
69
93
|
}
|
|
70
|
-
|
|
94
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
95
|
+
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
96
|
+
if (actual !== expected.toLowerCase()) {
|
|
97
|
+
fail(`checksum mismatch for ${TARBALL_NAME}`, `expected ${expected}, got ${actual}`);
|
|
98
|
+
}
|
|
99
|
+
fs.writeFileSync(target, bytes);
|
|
71
100
|
}
|
|
72
101
|
|
|
73
102
|
/** One checkout per version, marked complete only after dependencies and the build land. */
|
|
@@ -76,10 +105,13 @@ async function bootstrap(sourceDir) {
|
|
|
76
105
|
if (fs.existsSync(complete) && fs.readFileSync(complete, "utf8").trim() === version) return;
|
|
77
106
|
|
|
78
107
|
if (!which("node")) fail("Node.js is required but was not found on PATH.");
|
|
79
|
-
const major =
|
|
80
|
-
if (
|
|
108
|
+
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
109
|
+
if (
|
|
110
|
+
major < REQUIRED_NODE_MAJOR ||
|
|
111
|
+
(major === REQUIRED_NODE_MAJOR && minor < REQUIRED_NODE_MINOR)
|
|
112
|
+
) {
|
|
81
113
|
fail(
|
|
82
|
-
`Npie needs Node.js ${REQUIRED_NODE_MAJOR} or newer; this is ${process.versions.node}.`,
|
|
114
|
+
`Npie needs Node.js ${REQUIRED_NODE_MAJOR}.${REQUIRED_NODE_MINOR} or newer; this is ${process.versions.node}.`,
|
|
83
115
|
"Install it from https://nodejs.org, then run this command again.",
|
|
84
116
|
);
|
|
85
117
|
}
|
|
@@ -95,7 +127,7 @@ async function bootstrap(sourceDir) {
|
|
|
95
127
|
const staging = fs.mkdtempSync(`${sourceDir}.staging-`);
|
|
96
128
|
process.stderr.write(`npie: fetching Npie v${version}…\n`);
|
|
97
129
|
const tarball = path.join(staging, "source.tar.gz");
|
|
98
|
-
await
|
|
130
|
+
await downloadSource(tarball);
|
|
99
131
|
|
|
100
132
|
process.stderr.write("npie: unpacking…\n");
|
|
101
133
|
run("tar", ["-xzf", tarball, "-C", staging, "--strip-components=1"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npie/cli",
|
|
3
|
-
"version": "0.1.0-npie.
|
|
3
|
+
"version": "0.1.0-npie.7",
|
|
4
4
|
"description": "Npie CLI. Bootstraps an Npie checkout and runs it. 嗯哌 —— 开源的 AI 编程智能体控制台。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"cli"
|
|
17
17
|
],
|
|
18
18
|
"bin": {
|
|
19
|
-
"
|
|
19
|
+
"npie": "bin/t3.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"bin",
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=24.10"
|
|
27
27
|
},
|
|
28
28
|
"t3code": {
|
|
29
29
|
"databaseMigration": 119
|