dsh-aiterm 0.5.0 → 0.5.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/README.md CHANGED
@@ -45,6 +45,11 @@ npm pack # → dsh-aiterm-0.5.0.tgz
45
45
 
46
46
  装好后浏览器 `Ctrl+F5` 硬刷新一次:客户端半边由宿主重打包,SPA 内切页不够。
47
47
 
48
+ > **不会触发 pnpm 的构建脚本门禁。** `ssh2` 本身是纯 JS,但它的两个**可选**原生加速件
49
+ > (`cpu-features` 与内建的 `sshcrypto` 绑定)带 `install` / `node-gyp rebuild` 脚本,
50
+ > pnpm 10+ 会因此挂起安装等人工批准。本包已把 ssh2 打成 `vendor/ssh2.cjs` 随包发布,
51
+ > **依赖图里没有任何安装脚本**;缺少原生件时 ssh2 自动回落纯 JS,功能不受影响。
52
+
48
53
  ### 从 ssh-telnet 升级(破坏性)
49
54
 
50
55
  0.5.0 把工具名、路由、数据目录、凭据作用域和存储键全部从 `ssh-telnet` 改成 `aiterm`,**不保留旧别名**。
@@ -388,6 +393,7 @@ print('hello from the remote host')
388
393
  npm install # 运行时依赖 ssh2 / @xterm/headless / @xterm/addon-serialize,
389
394
  # 以及构建用 devDeps:esbuild、@xterm/xterm、@xterm/addon-fit
390
395
  npm run build # 从 client/**.jsx 重新生成 lib/client.js(模块 id 取自 package.json 的 name)
396
+ npm run build:vendor # 重新打包 vendor/ssh2.cjs(需要 devDependency ssh2 + esbuild)
391
397
  npm run lint # node --check 全部 Host 端源码
392
398
  npm test # 客户端冒烟:槽位注册、locale 键、RPC 方法覆盖
393
399
  ```
@@ -19,7 +19,7 @@ import os from 'node:os'
19
19
  import path from 'node:path'
20
20
  import { createHash } from 'node:crypto'
21
21
  import { promises as fs } from 'node:fs'
22
- import ssh2 from 'ssh2'
22
+ import ssh2 from '../../../vendor/ssh2.cjs'
23
23
 
24
24
  const { Client } = ssh2
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aiterm",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "SSH and Telnet terminals for DeepSeek Harness: one real terminal shared by you and the AI, with per-session AI permissions and token-cheap delta reads.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,22 +42,24 @@
42
42
  "icon.svg",
43
43
  "README.md",
44
44
  "LICENSE",
45
- "CONTRACTS.md"
45
+ "CONTRACTS.md",
46
+ "vendor"
46
47
  ],
47
48
  "scripts": {
48
49
  "build": "node scripts/build-client.mjs",
49
50
  "lint": "node --check lib/index.js && for f in lib/host/*.js lib/host/transports/*.js; do node --check \"$f\" || exit 1; done",
50
- "test": "node scripts/smoke-client.mjs"
51
+ "test": "node scripts/smoke-client.mjs",
52
+ "build:vendor": "node scripts/build-vendor.mjs"
51
53
  },
52
54
  "dependencies": {
53
55
  "@xterm/addon-serialize": "^0.14.0",
54
- "@xterm/headless": "^6.0.0",
55
- "ssh2": "^1.17.0"
56
+ "@xterm/headless": "^6.0.0"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@xterm/addon-fit": "^0.11.0",
59
60
  "@xterm/xterm": "^6.0.0",
60
- "esbuild": "^0.28.2"
61
+ "esbuild": "^0.28.2",
62
+ "ssh2": "1.17.0"
61
63
  },
62
64
  "dsh": {
63
65
  "bundle": {
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Build `vendor/ssh2.cjs` — the pure-JS `ssh2` bundle shipped inside this package.
3
+ *
4
+ * Why: `ssh2` is already pure JS, but it carries two *optional* native extras
5
+ * (`cpu-features` and its own `sshcrypto` node-gyp binding). Both are loaded
6
+ * inside `try/catch` with a pure-JS fallback, yet their `install` / `rebuild`
7
+ * scripts make pnpm 10+ stop and ask for build approval — which rolls back the
8
+ * whole DSH profile install. Vendoring removes them from the dependency graph.
9
+ *
10
+ * Usage: `npm install && npm run build:vendor`
11
+ */
12
+ import { execFileSync } from 'node:child_process'
13
+ import { createRequire } from 'node:module'
14
+ import { dirname, resolve } from 'node:path'
15
+ import { fileURLToPath } from 'node:url'
16
+
17
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
18
+ const require = createRequire(import.meta.url)
19
+ const entry = require.resolve('ssh2')
20
+ const esbuild = resolve(root, 'node_modules', '.bin', 'esbuild')
21
+ const outfile = resolve(root, 'vendor', 'ssh2.cjs')
22
+
23
+ execFileSync(esbuild, [
24
+ entry,
25
+ '--bundle',
26
+ '--platform=node',
27
+ '--format=cjs',
28
+ '--target=node20',
29
+ `--outfile=${outfile}`,
30
+ '--external:cpu-features',
31
+ '--external:nan',
32
+ '--external:./crypto/build/Release/sshcrypto.node',
33
+ '--log-level=warning',
34
+ ], { stdio: 'inherit' })
35
+
36
+ const { statSync } = await import('node:fs')
37
+ console.log(`build-vendor: wrote ${outfile} (${Math.round(statSync(outfile).size / 1024)} KiB)`)
@@ -0,0 +1,31 @@
1
+ # vendor/ssh2.cjs
2
+
3
+ `ssh2` 1.17.0 的**纯 JS** 构建产物,由 `scripts/build-vendor.mjs` 用 esbuild 打包成单文件。
4
+
5
+ ## 为什么要打包
6
+
7
+ `ssh2` 本身是纯 JS(协议实现全在 `lib/**.js`),但它有两个**可选**的原生加速件:
8
+
9
+ - `cpu-features`(探测 CPU 指令集,用于调优包大小)——在 `lib/protocol/constants.js` 里 `try/catch` 加载;
10
+ - 内建的 `sshcrypto` 绑定(`lib/protocol/crypto.js` 里的 `try/catch`)——由 `ssh2` 自己的 `install` 脚本尝试用 node-gyp 编译。
11
+
12
+ 两者都**缺失时 ssh2 自动回落到纯 JS 实现**,功能不受影响。
13
+
14
+ 问题是 pnpm 10+ 默认**拦截一切安装脚本**:只要依赖图里出现 `install`/`postinstall`,
15
+ 安装就会被挂起等人工批准(`ssh2` 的 `install` 脚本 + `cpu-features` 的 `node-gyp rebuild`)。
16
+ 把它打包进本包之后,`dsh-aiterm` 的依赖图里**不再有任何安装脚本**,装包即用。
17
+
18
+ ## 怎么重新生成
19
+
20
+ ```bash
21
+ npm install # 需要 devDependency ssh2 与 esbuild
22
+ npm run build:vendor # 重新生成 vendor/ssh2.cjs
23
+ ```
24
+
25
+ 打包时显式把两个原生件标记为 external,保持它们在运行时的 `try/catch` 里失败并回落:
26
+
27
+ ```
28
+ --external:cpu-features --external:nan --external:./crypto/build/Release/sshcrypto.node
29
+ ```
30
+
31
+ `ssh2` 的许可证见同目录 `ssh2.LICENSE`(MIT)。
@@ -0,0 +1,19 @@
1
+ Copyright Brian White. All rights reserved.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ IN THE SOFTWARE.