iterate-harness 1.12.7 → 1.12.8
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 +12 -5
- package/README.zh-CN.md +7 -2
- package/package.json +5 -3
- package/scripts/postinstall.js +42 -0
package/README.md
CHANGED
|
@@ -20,7 +20,9 @@ The harness itself is a **Python package**. This npm package is a thin
|
|
|
20
20
|
distribution wrapper: it does not re-implement anything, it just makes `ih`
|
|
21
21
|
installable with npm and keeps it up to date.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Right after `npm install` finishes, a `postinstall` hook creates the managed
|
|
24
|
+
venv and installs the harness — so `ih` is ready to use immediately. The
|
|
25
|
+
delegation logic used at install time and at runtime is the same:
|
|
24
26
|
|
|
25
27
|
1. Finds a Python interpreter >= 3.10 (`py -3` / `python` / `python3`,
|
|
26
28
|
overridable via `ITERATE_HARNESS_PYTHON`).
|
|
@@ -28,15 +30,20 @@ On first run the wrapper:
|
|
|
28
30
|
(overridable via `ITERATE_HARNESS_NPM_HOME`).
|
|
29
31
|
3. `pip install`s the harness **pinned to this npm package's version** — npm
|
|
30
32
|
`1.6.0` always installs harness `v1.6.0`. Upgrading the npm package
|
|
31
|
-
automatically re-installs the matching harness version
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
automatically re-installs the matching harness version. The preferred
|
|
34
|
+
artifact is the **pre-built wheel** uploaded to the GitHub release
|
|
35
|
+
(`iterate_harness-<version>-py3-none-any.whl`, which already bundles the
|
|
36
|
+
compiled frontend assets — exactly like iterate-skill-installer ships
|
|
35
37
|
pre-wrapped assets). If the wheel is missing, the wrapper falls back to the
|
|
36
38
|
pinned **source archive** as a last resort.
|
|
37
39
|
4. Delegates to the venv's real `ih` executable with argv, stdio, signals and
|
|
38
40
|
exit codes forwarded.
|
|
39
41
|
|
|
42
|
+
If the install during `npm install` can't complete (no Python, no network, or
|
|
43
|
+
`ITERATE_HARNESS_SKIP_INSTALL=1`), the hook prints a notice without failing
|
|
44
|
+
the npm install, and `ih` still installs on its first run — a lazy fallback
|
|
45
|
+
keeps the package usable either way.
|
|
46
|
+
|
|
40
47
|
The React TUI's frontend dependencies (`node_modules`) are installed
|
|
41
48
|
automatically by the harness itself on first TUI launch — npm users always
|
|
42
49
|
have Node, so the TUI always works.
|
package/README.zh-CN.md
CHANGED
|
@@ -19,19 +19,24 @@ ih --version # 首次运行引导安装 Python 端,随后打印版本
|
|
|
19
19
|
harness 本身是**一个 Python 包**。这个 npm 包是一个薄分发包装器:它不重新实现任何
|
|
20
20
|
逻辑,只是让 `ih` 可以通过 npm 安装并保持更新。
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
`npm install` 一结束,`postinstall` 钩子就会创建托管虚拟环境并安装 harness——
|
|
23
|
+
所以 `ih` 装完即用。安装时与运行时共用同一套代理逻辑:
|
|
23
24
|
|
|
24
25
|
1. 找到一个 >= 3.10 的 Python 解释器(`py -3` / `python` / `python3`,
|
|
25
26
|
可通过 `ITERATE_HARNESS_PYTHON` 覆盖)。
|
|
26
27
|
2. 在 `~/.iterate-harness-npm/venv` 创建托管虚拟环境
|
|
27
28
|
(可通过 `ITERATE_HARNESS_NPM_HOME` 覆盖)。
|
|
28
29
|
3. `pip install` **与本 npm 包版本锁定的** harness 发布版本 —— npm 的 `1.6.0`
|
|
29
|
-
总会安装 harness `v1.6.0`。升级 npm
|
|
30
|
+
总会安装 harness `v1.6.0`。升级 npm 包会自动重装对应的 harness 版本。
|
|
30
31
|
优先下载 GitHub 发布里的**预构建 wheel**(`iterate_harness-<version>-py3-none-any.whl`,
|
|
31
32
|
已内置编译好的前端资源——和 iterate-skill-installer 分发预打包资源一致)。
|
|
32
33
|
若 wheel 缺失,再兑底使用锁定的**源码归档**。
|
|
33
34
|
4. 代理调用 venv 里真正的 `ih` 可执行文件,转发 argv、stdio、信号与退出码。
|
|
34
35
|
|
|
36
|
+
若 `npm install` 期间无法完成安装(无 Python、无网络,或
|
|
37
|
+
`ITERATE_HARNESS_SKIP_INSTALL=1`),钩子只会打印提示而不让 npm 安装失败,
|
|
38
|
+
`ih` 会在首次运行时补装——惰性兑底保证两种情况下包都可用。
|
|
39
|
+
|
|
35
40
|
React TUI 的前端依赖(`node_modules`)会在首次启动 TUI 时由 harness 自动安装——
|
|
36
41
|
npm 用户必然有 Node,所以 TUI 始终可用。
|
|
37
42
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterate-harness",
|
|
3
|
-
"version": "1.12.
|
|
4
|
-
"description": "npm distribution wrapper for iterate-harness — installs the Python harness (ih CLI) into a managed venv on
|
|
3
|
+
"version": "1.12.8",
|
|
4
|
+
"description": "npm distribution wrapper for iterate-harness — installs the Python harness (ih CLI) into a managed venv on install and exposes it as a global command",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"bin",
|
|
24
24
|
"lib",
|
|
25
|
+
"scripts",
|
|
25
26
|
"README.md",
|
|
26
27
|
"LICENSE"
|
|
27
28
|
],
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"installer"
|
|
34
35
|
],
|
|
35
36
|
"scripts": {
|
|
36
|
-
"test": "node --test test/bootstrap.test.js"
|
|
37
|
+
"test": "node --test test/bootstrap.test.js test/postinstall.test.js",
|
|
38
|
+
"postinstall": "node scripts/postinstall.js"
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* npm `postinstall` hook for the iterate-harness wrapper.
|
|
4
|
+
*
|
|
5
|
+
* Runs right after `npm install`/`npm install -g` finishes, so the Python
|
|
6
|
+
* harness is ready the moment npm finishes — no wait on the first `ih` run.
|
|
7
|
+
*
|
|
8
|
+
* It deliberately NEVER fails the npm install: if the managed venv cannot be
|
|
9
|
+
* created here (e.g. no Python interpreter, no network, user opted out with
|
|
10
|
+
* ITERATE_HARNESS_SKIP_INSTALL=1), we print a notice and exit 0. The regular
|
|
11
|
+
* `ih` entry point keeps its own lazy-bootstrap fallback, so the first run
|
|
12
|
+
* still installs the harness on demand.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
"use strict";
|
|
16
|
+
|
|
17
|
+
const { ensureRuntime, reportBootstrapFailure, SKIP_INSTALL_ENV_VAR } = require("../lib/bootstrap");
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
if (process.env[SKIP_INSTALL_ENV_VAR] === "1") {
|
|
21
|
+
process.stderr.write(
|
|
22
|
+
`[iterate-harness] skipped install during npm install (${SKIP_INSTALL_ENV_VAR}=1); ` +
|
|
23
|
+
"the harness will be installed on the first `ih` run.\n"
|
|
24
|
+
);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await ensureRuntime();
|
|
29
|
+
process.stderr.write("[iterate-harness] harness installed during npm install.\n");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
reportBootstrapFailure(error);
|
|
32
|
+
process.stderr.write(
|
|
33
|
+
"[iterate-harness] could not install the harness during npm install " +
|
|
34
|
+
"(see above). It will be retried automatically on the first `ih` run.\n"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main().catch((error) => {
|
|
40
|
+
reportBootstrapFailure(error);
|
|
41
|
+
process.exit(0);
|
|
42
|
+
});
|