@dinoxx/dinox-cli 2.18.0 → 2.18.2

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
@@ -65,10 +65,16 @@ npm -v
65
65
 
66
66
  ### 2.2 安装 Dinox CLI
67
67
 
68
- 推荐直接全局安装:
68
+ 先确认 `node -v` 是 v22、v23、v24 或 v25,再全局安装。npm 11.16 及以后默认不编译 `better-sqlite3` 和 `sharp`,安装命令要放行这两个包:
69
69
 
70
70
  ```bash
71
- npm install -g @dinoxx/dinox-cli
71
+ npm install -g @dinoxx/dinox-cli@latest --allow-scripts=better-sqlite3,sharp
72
+ ```
73
+
74
+ `npm -v` 低于 11.16 时没有 `--allow-scripts`,去掉这个参数再装。用 pnpm 10.15 及以后时:
75
+
76
+ ```bash
77
+ pnpm add -g @dinoxx/dinox-cli@latest --allow-build=better-sqlite3 --allow-build=sharp
72
78
  ```
73
79
 
74
80
  安装完成后,验证是否成功:
@@ -79,14 +85,20 @@ dino info
79
85
 
80
86
  看到版本号就表示安装成功。
81
87
 
82
- > 说明:安装后通常可以使用 `dino` 或 `dinox` 两个命令名,本文统一使用 `dino`。
88
+ > 说明:安装后通常可以使用 `dino` 或 `dinox` 两个命令名,本文统一使用 `dino`。`dino` 用的是安装时 PATH 里的那个 `node`。
83
89
 
84
90
  ### 2.3 macOS 安装 Node.js(如果你还没装)
85
91
 
92
+ Homebrew 的 `node` 公式现在是 Node.js 26,CLI 不能用它。安装 Node.js 24:
93
+
86
94
  ```bash
87
- brew install node
95
+ brew install node@24
96
+ export PATH="$(brew --prefix node@24)/bin:$PATH"
97
+ node -v
88
98
  ```
89
99
 
100
+ `node -v` 应显示 v24。再执行上面的安装命令。
101
+
90
102
  ### 2.4 Windows 安装 Node.js(如果你还没装)
91
103
 
92
104
  PowerShell 中可使用:
@@ -103,6 +115,8 @@ winget install OpenJS.NodeJS.LTS
103
115
  dino update
104
116
  ```
105
117
 
118
+ 它会安装 `@latest`,所以可以从 1.x 升到 2.x。npm 11.16+ 会自动加上 `--allow-scripts=better-sqlite3,sharp`,pnpm 10.15+ 会自动加上 `--allow-build`。旧版 `dino update` 只在 1.x 里更新,版本停在 1.x 时改用上面的安装命令。
119
+
106
120
  它会自动根据你当前的安装方式选择合适的包管理器执行更新。升级完成后会检查本机已安装的 Agent:有 `claude` 但没有 ACP 命令时安装 `@agentclientprotocol/claude-agent-acp`,有 `codex` 时安装 `@agentclientprotocol/codex-acp`,有 `zcode` 时安装 `zcode-acp`,有 `pi` 时安装 `pi-acp`,有 `agy` 时安装 `agy-acp`,有 `muse` 时安装 `@bex-co/muse-code-acp`。已经装过的适配器会跳过;某个适配器安装失败只给出警告,不影响 CLI 升级本身。
107
121
 
108
122
  ---
@@ -1006,7 +1020,21 @@ schema 包含命令路径、风险级别、参数、选项、输出字段和示
1006
1020
 
1007
1021
  ## 8. 常见问题
1008
1022
 
1009
- ### Q1:报错 `Missing resolved userId for the current authorization`
1023
+ ### Q1:安装或升级后出现 `allowScripts` / `Ignored build scripts`,或者一用就报 `better-sqlite3`
1024
+
1025
+ 原因:本地数据库依赖 `better-sqlite3`,图片处理依赖 `sharp`。npm 11.16+ 和 pnpm 10.15+ 默认不运行这两个包的安装脚本,本机程序就没有装上。Node.js 26 也不在支持范围内,Homebrew 的 `brew install node` 现在装的就是 26。
1026
+
1027
+ 解决:换成 Node.js 24,再重新安装。
1028
+
1029
+ ```bash
1030
+ node -v
1031
+ npm install -g @dinoxx/dinox-cli@latest --allow-scripts=better-sqlite3,sharp
1032
+ dino info
1033
+ ```
1034
+
1035
+ `node -v` 必须是 v22 到 v25。黄字警告本身不是升级失败;版本号没有变成最新版时,用上面这条命令,不要继续用旧的 `dino update`。
1036
+
1037
+ ### Q2:报错 `Missing resolved userId for the current authorization`
1010
1038
 
1011
1039
  原因:你还没有完成登录,或当前 `DINOX_TOKEN` 环境变量覆盖了本地 token,CLI 需要先在线解析这个 token 对应的用户身份。
1012
1040
 
@@ -1025,7 +1053,7 @@ dino auth status --format json
1025
1053
  dino sync
1026
1054
  ```
1027
1055
 
1028
- ### Q2:创建笔记时报 `Unknown tags` 或 `Unknown zettel box names`
1056
+ ### Q3:创建笔记时报 `Unknown tags` 或 `Unknown zettel box names`
1029
1057
 
1030
1058
  原因:你引用了不存在的标签或卡片盒。
1031
1059
 
@@ -1036,7 +1064,7 @@ dino tag add "你的标签"
1036
1064
  dino box add "你的卡片盒"
1037
1065
  ```
1038
1066
 
1039
- ### Q3:我已经同步过了,能不能完全离线查询?
1067
+ ### Q4:我已经同步过了,能不能完全离线查询?
1040
1068
 
1041
1069
  可以。很多读命令都支持:
1042
1070
 
@@ -1053,7 +1081,7 @@ dino graph stats --offline --format json
1053
1081
 
1054
1082
  前提是:你之前至少成功同步过一次,本地缓存里已经有数据。
1055
1083
 
1056
- ### Q4:`note update` 为什么不是“追加标签”?
1084
+ ### Q5:`note update` 为什么不是“追加标签”?
1057
1085
 
1058
1086
  因为它的设计就是“全量替换”。
1059
1087
 
@@ -1071,7 +1099,7 @@ dino note update <note-id> --tags "工作,AI"
1071
1099
  dino note tag <note-id> --add "工作,AI"
1072
1100
  ```
1073
1101
 
1074
- ### Q5:`todo append` 不传 `--note-id` 时会发生什么?
1102
+ ### Q6:`todo append` 不传 `--note-id` 时会发生什么?
1075
1103
 
1076
1104
  CLI 会自动选一条最近的、适合追加任务的笔记作为目标。
1077
1105
 
@@ -1081,7 +1109,7 @@ CLI 会自动选一条最近的、适合追加任务的笔记作为目标。
1081
1109
  dino todo append --note-id <note-id> --task "补交报销单"
1082
1110
  ```
1083
1111
 
1084
- ### Q6:Windows 下 `@file` 参数解析不稳定怎么办?
1112
+ ### Q7:Windows 下 `@file` 参数解析不稳定怎么办?
1085
1113
 
1086
1114
  在 PowerShell 中,建议把 `@文件路径` 放进引号里。
1087
1115
 
@@ -1091,7 +1119,7 @@ dino todo append --note-id <note-id> --task "补交报销单"
1091
1119
  dino note create --title "测试" --content "@.\note.md" --type note
1092
1120
  ```
1093
1121
 
1094
- ### Q7:怎么知道某个命令到底支持哪些参数?
1122
+ ### Q8:怎么知道某个命令到底支持哪些参数?
1095
1123
 
1096
1124
  最直接的方法:
1097
1125
 
@@ -26,6 +26,9 @@ export declare function detectPackageManager(input?: {
26
26
  env?: NodeJS.ProcessEnv;
27
27
  scriptPath?: string;
28
28
  }): PackageManager;
29
+ export declare function versionAtLeast(version: string, minimum: string): boolean;
30
+ /** Lets native dependencies compile. npm 11.16+ and pnpm 10.15+ skip those scripts unless named. */
31
+ export declare function appendNativeBuildPermissions(pm: PackageManager, args: string[], toolVersion: string | null): string[];
29
32
  type UpdateSpawnSpec = {
30
33
  command: string;
31
34
  args: string[];
@@ -52,6 +52,36 @@ const PM_COMMANDS = {
52
52
  yarn: { bin: 'yarn', args: ['global', 'add', `${PACKAGE_NAME}@latest`] },
53
53
  bun: { bin: 'bun', args: ['add', '--global', `${PACKAGE_NAME}@latest`] },
54
54
  };
55
+ const NATIVE_BUILD_PACKAGES = 'better-sqlite3,sharp';
56
+ function versionParts(version) {
57
+ const [major = 0, minor = 0, patch = 0] = version
58
+ .trim()
59
+ .replace(/^v/, '')
60
+ .split('.')
61
+ .map((part) => Number(part.replace(/\D.*$/, '')) || 0);
62
+ return [major, minor, patch];
63
+ }
64
+ export function versionAtLeast(version, minimum) {
65
+ const current = versionParts(version);
66
+ const floor = versionParts(minimum);
67
+ for (let index = 0; index < current.length; index += 1) {
68
+ if (current[index] !== floor[index])
69
+ return current[index] > floor[index];
70
+ }
71
+ return true;
72
+ }
73
+ /** Lets native dependencies compile. npm 11.16+ and pnpm 10.15+ skip those scripts unless named. */
74
+ export function appendNativeBuildPermissions(pm, args, toolVersion) {
75
+ if (!toolVersion)
76
+ return args;
77
+ if (pm === 'npm' && versionAtLeast(toolVersion, '11.16.0')) {
78
+ return [...args, `--allow-scripts=${NATIVE_BUILD_PACKAGES}`];
79
+ }
80
+ if (pm === 'pnpm' && versionAtLeast(toolVersion, '10.15.0')) {
81
+ return [...args, '--allow-build=better-sqlite3', '--allow-build=sharp'];
82
+ }
83
+ return args;
84
+ }
55
85
  export function resolvePackageManagerSpawn(pm, args, platform = process.platform) {
56
86
  const usesWindowsCommandShim = platform === 'win32' && pm !== 'bun';
57
87
  if (usesWindowsCommandShim) {
@@ -131,8 +161,21 @@ function runPackageManager(pm, packageArgs, options) {
131
161
  });
132
162
  });
133
163
  }
134
- function runUpdate(pm, options) {
135
- return runPackageManager(pm, PM_COMMANDS[pm].args, options);
164
+ function readToolVersion(pm) {
165
+ const { command, args, shell } = resolvePackageManagerSpawn(pm, ['--version']);
166
+ return new Promise((resolve) => {
167
+ let stdout = '';
168
+ const child = spawn(command, args, { shell, stdio: ['ignore', 'pipe', 'ignore'] });
169
+ child.stdout?.on('data', (chunk) => {
170
+ stdout = appendBoundedOutput(stdout, chunk);
171
+ });
172
+ child.on('close', (code) => resolve(code === 0 ? stdout.trim() : null));
173
+ child.on('error', () => resolve(null));
174
+ });
175
+ }
176
+ async function runUpdate(pm, options) {
177
+ const toolVersion = pm === 'npm' || pm === 'pnpm' ? await readToolVersion(pm) : null;
178
+ return runPackageManager(pm, appendNativeBuildPermissions(pm, PM_COMMANDS[pm].args, toolVersion), options);
136
179
  }
137
180
  function adapterErrorMessage(error) {
138
181
  return error instanceof Error ? error.message : String(error);
package/dist/dinox.js CHANGED
@@ -3,7 +3,8 @@ import { commandExecutionTarget, tryForwardToDaemon } from './daemon/forward.js'
3
3
  import { applyDefaultFormat } from './utils/defaultFormat.js';
4
4
  import { getPackageVersion } from './utils/version.js';
5
5
  import { requestIdFromArgv, runWithRequestId } from './requests/store.js';
6
- import { isDinoxError } from './utils/errors.js';
6
+ import { DinoxError, isDinoxError } from './utils/errors.js';
7
+ import { NODE_INSTALL_SUGGESTION, unsupportedNodeMessage } from './utils/nodeRuntime.js';
7
8
  import { exitProcessAfterFlushing } from './utils/processExit.js';
8
9
  import { localCommandExecution } from './utils/requestContext.js';
9
10
  /** `--progress` before `--`: the daemon streams events back while it runs the command. */
@@ -16,6 +17,16 @@ let fatalError;
16
17
  try {
17
18
  argv = applyDefaultFormat(argv);
18
19
  const versionOnly = argv.length === 1 && ['--version', '-V'].includes(argv[0]);
20
+ if (!versionOnly) {
21
+ const nodeMessage = unsupportedNodeMessage(process.versions.node);
22
+ if (nodeMessage) {
23
+ throw new DinoxError(nodeMessage, {
24
+ code: 'PRECONDITION_FAILED',
25
+ suggestion: NODE_INSTALL_SUGGESTION,
26
+ recoverable: true,
27
+ });
28
+ }
29
+ }
19
30
  const forwarded = versionOnly
20
31
  ? { stdout: `${getPackageVersion()}\n`, stderr: '', exitCode: 0 }
21
32
  : await tryForwardToDaemon(argv, wantsProgress(argv) ? { onProgress: (text) => process.stderr.write(text) } : {});
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinox-editor-dsh",
3
- "version": "2.18.0",
3
+ "version": "2.18.2",
4
4
  "private": true,
5
5
  "description": "Dinox note editor for DeepSeek Harness Desktop (built by @dinoxx/dinox-cli)",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "node": "/opt/hostedtoolcache/node/22.13.0/x64/bin/node",
3
3
  "cli": "/home/runner/work/dinox-cli/dinox-cli/dist/dinox.js",
4
- "version": "2.18.0"
4
+ "version": "2.18.2"
5
5
  }
@@ -21,6 +21,15 @@ export type InstallOptions = {
21
21
  };
22
22
  /** The dsh CLI that ships with Desktop matches its runtime; fall back to PATH. */
23
23
  export declare function findDshCli(options?: Pick<InstallOptions, 'dsh' | 'env'>): string | null;
24
+ /**
25
+ * On Windows the dsh CLI on PATH is an npm `dsh.cmd` shim, which `execFile`
26
+ * cannot start directly (EINVAL since Node 20.12.2); route it through cmd.exe.
27
+ */
28
+ export declare function dshInvocation(file: string, args: string[], platform?: NodeJS.Platform): {
29
+ file: string;
30
+ args: string[];
31
+ options: import("child_process").SpawnOptions;
32
+ };
24
33
  export declare function installDsh(options?: InstallOptions): Promise<{
25
34
  host: "dsh";
26
35
  profile: string;
@@ -4,6 +4,7 @@ import { rename, writeFile } from 'node:fs/promises';
4
4
  import { homedir } from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { promisify } from 'node:util';
7
+ import { agentLaunch } from '../gateway/spawnAgent.js';
7
8
  import { DinoxError } from '../utils/errors.js';
8
9
  import { getPackageVersion } from '../utils/version.js';
9
10
  import { editorPackageRoot } from './paths.js';
@@ -77,8 +78,24 @@ function samePath(a, b) {
77
78
  return path.resolve(a) === path.resolve(b);
78
79
  }
79
80
  }
81
+ /**
82
+ * On Windows the dsh CLI on PATH is an npm `dsh.cmd` shim, which `execFile`
83
+ * cannot start directly (EINVAL since Node 20.12.2); route it through cmd.exe.
84
+ */
85
+ export function dshInvocation(file, args, platform = process.platform) {
86
+ const launch = agentLaunch(file, args, { windowsHide: true }, platform);
87
+ return { file: launch.command, args: [...launch.args], options: launch.options };
88
+ }
80
89
  function defaultExec(file, args) {
81
- return run(file, args, { timeout: 180_000, maxBuffer: 8 * 1024 * 1024 }).then(() => undefined, (error) => {
90
+ let invocation;
91
+ try {
92
+ invocation = dshInvocation(file, args);
93
+ }
94
+ catch (error) {
95
+ return Promise.reject(new DinoxError(`dsh plugin failed: ${error.message}`, { code: 'COMMAND_FAILED' }));
96
+ }
97
+ const options = { ...invocation.options, timeout: 180_000, maxBuffer: 8 * 1024 * 1024 };
98
+ return run(invocation.file, invocation.args, options).then(() => undefined, (error) => {
82
99
  const detail = String(error.stderr ?? '').trim().split('\n').slice(-5).join('\n');
83
100
  throw new DinoxError(`dsh plugin failed: ${detail || error.message}`, { code: 'COMMAND_FAILED' });
84
101
  });
@@ -0,0 +1,4 @@
1
+ export declare function nodeMajor(version: string): number;
2
+ /** Returns a user-facing message when this Node cannot run the CLI. */
3
+ export declare function unsupportedNodeMessage(version: string): string | null;
4
+ export declare const NODE_INSTALL_SUGGESTION = "Install Node.js 24, confirm `node -v` prints v24, then run: npm install -g @dinoxx/dinox-cli@latest --allow-scripts=better-sqlite3,sharp";
@@ -0,0 +1,12 @@
1
+ const SUPPORTED_NODE_MAJORS = new Set([22, 23, 24, 25]);
2
+ export function nodeMajor(version) {
3
+ return Number(version.trim().replace(/^v/, '').split('.')[0] ?? 0) || 0;
4
+ }
5
+ /** Returns a user-facing message when this Node cannot run the CLI. */
6
+ export function unsupportedNodeMessage(version) {
7
+ const major = nodeMajor(version);
8
+ if (SUPPORTED_NODE_MAJORS.has(major))
9
+ return null;
10
+ return `Dinox CLI supports Node.js 22, 23, 24, and 25. This process is Node.js ${version}.`;
11
+ }
12
+ export const NODE_INSTALL_SUGGESTION = 'Install Node.js 24, confirm `node -v` prints v24, then run: npm install -g @dinoxx/dinox-cli@latest --allow-scripts=better-sqlite3,sharp';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dinoxx/dinox-cli",
3
- "version": "2.18.0",
3
+ "version": "2.18.2",
4
4
  "description": "Dinox CLI",
5
5
  "main": "dist/dinox.js",
6
6
  "scripts": {