nexum-code 0.6.14 → 0.6.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexum-code",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "A terminal-native AI agent for builders",
5
5
  "license": "MIT",
6
6
  "author": "NexumCli",
@@ -44,9 +44,24 @@
44
44
  "access": "public",
45
45
  "provenance": true
46
46
  },
47
+ "scripts": {
48
+ "build": "tsdown",
49
+ "dev": "node scripts/dev.mjs",
50
+ "dev:cli-only": "tsx --import ../../build/register-raw-text-loader.mjs ./src/main.ts",
51
+ "dev:prod": "node dist/main.mjs",
52
+ "clean": "rm -rf dist",
53
+ "typecheck": "tsc -p tsconfig.json --noEmit",
54
+ "test": "pnpm -w run build:packages && vitest run",
55
+ "e2e": "pnpm -w run build:packages && NEXUM_E2E=1 vitest run test/e2e",
56
+ "e2e:real": "pnpm -w run build:packages && NEXUM_E2E_REAL=1 vitest run test/e2e/real-llm-smoke.e2e.test.ts",
57
+ "preinstall": "node -e \"console.log('\\n正在安装 nexum-code,请稍候...\\n')\"",
58
+ "postinstall": "node scripts/postinstall.mjs",
59
+ "smoke": "node dist/main.mjs --version"
60
+ },
47
61
  "dependencies": {
48
62
  "@earendil-works/pi-tui": "^0.78.1",
49
63
  "@mariozechner/clipboard": "^0.3.2",
64
+ "@napi-rs/canvas": "1.0.1",
50
65
  "chalk": "^5.4.1",
51
66
  "cli-highlight": "^2.1.11",
52
67
  "commander": "^13.1.0",
@@ -54,31 +69,20 @@
54
69
  "smol-toml": "^1.6.1",
55
70
  "zod": "^4.3.6"
56
71
  },
72
+ "optionalDependencies": {
73
+ "canvas": "3.2.0"
74
+ },
57
75
  "devDependencies": {
58
76
  "@modelcontextprotocol/sdk": "^1.29.0",
77
+ "@nexum-cli/agent-core": "workspace:^",
78
+ "@nexum-cli/config": "workspace:^",
79
+ "@nexum-cli/migration-legacy": "workspace:^",
80
+ "@nexum-cli/nexum-code-sdk": "workspace:^",
81
+ "@nexum-code/memory": "workspace:*",
59
82
  "@types/semver": "^7.7.0",
60
- "tsx": "^4.22.4",
61
- "@nexum-cli/agent-core": "^0.6.8",
62
- "@nexum-cli/migration-legacy": "^0.6.8",
63
- "@nexum-cli/config": "^0.6.8",
64
- "@nexum-cli/nexum-code-sdk": "^0.6.8",
65
- "@nexum-code/memory": "0.6.8"
83
+ "tsx": "^4.22.4"
66
84
  },
67
85
  "engines": {
68
86
  "node": ">=22.19.0"
69
- },
70
- "scripts": {
71
- "build": "tsdown",
72
- "dev": "node scripts/dev.mjs",
73
- "dev:cli-only": "tsx --import ../../build/register-raw-text-loader.mjs ./src/main.ts",
74
- "dev:prod": "node dist/main.mjs",
75
- "clean": "rm -rf dist",
76
- "typecheck": "tsc -p tsconfig.json --noEmit",
77
- "test": "pnpm -w run build:packages && vitest run",
78
- "e2e": "pnpm -w run build:packages && NEXUM_E2E=1 vitest run test/e2e",
79
- "e2e:real": "pnpm -w run build:packages && NEXUM_E2E_REAL=1 vitest run test/e2e/real-llm-smoke.e2e.test.ts",
80
- "preinstall": "node -e \"console.log('\\n📦 正在安装 nexum-code,请稍候...\\n')\"",
81
- "postinstall": "node scripts/postinstall.mjs",
82
- "smoke": "node dist/main.mjs --version"
83
87
  }
84
- }
88
+ }
@@ -100,13 +100,15 @@
100
100
  * of the migration.
101
101
  */
102
102
 
103
- import {
104
- detectPackageManager,
105
- findFirstResolvableNexum,
106
- isGlobalInstall,
107
- ownPackageRoot,
108
- postinstallPaths,
109
- } from './postinstall/reach.mjs';
103
+ import {
104
+ detectPackageManager,
105
+ findFirstResolvableNexum,
106
+ isGlobalInstall,
107
+ ownPackageRoot,
108
+ postinstallPaths,
109
+ } from './postinstall/reach.mjs';
110
+ import { execFile } from 'node:child_process';
111
+ import { access } from 'node:fs/promises';
110
112
  import {
111
113
  classifyShim,
112
114
  deleteShim,
@@ -122,13 +124,15 @@ import {
122
124
  notify,
123
125
  } from './postinstall/ui.mjs';
124
126
 
125
- async function main() {
127
+ async function main() {
126
128
  // Step 1: skip non-global installs (npx, local project deps,
127
129
  // workspace bootstraps). Windows is supported natively; the
128
130
  // platform-specific bits (PATHEXT-aware PATH walk, whole-file
129
131
  // marker sniff for uv's launcher .exe, extension-preserving
130
132
  // rename) live in the helpers.
131
- if (!isGlobalInstall()) return;
133
+ if (!isGlobalInstall()) return;
134
+
135
+ await ensureDocumentOcrRuntime();
132
136
 
133
137
  // Step 2: locate our own installed package root once and share it
134
138
  // with both detection (skip files inside our package) and
@@ -262,10 +266,108 @@ async function main() {
262
266
  },
263
267
  pm,
264
268
  );
265
- }
266
-
267
- try {
268
- createDesktopShortcut();
269
+ }
270
+
271
+ async function ensureDocumentOcrRuntime() {
272
+ if (process.env.NEXUM_DOC_SKIP_OCR_SETUP === '1') return;
273
+
274
+ try {
275
+ let executable = await findTesseractExecutable();
276
+ if (executable === undefined && process.platform === 'win32' && await commandWorks('winget', ['--version'])) {
277
+ await execFileQuiet('winget', [
278
+ 'install',
279
+ '--id',
280
+ 'UB-Mannheim.TesseractOCR',
281
+ '-e',
282
+ '--accept-package-agreements',
283
+ '--accept-source-agreements',
284
+ ]);
285
+ executable = await findTesseractExecutable();
286
+ }
287
+
288
+ if (executable === undefined) {
289
+ notify('[nexum-code] /doc OCR note: scanned images need Tesseract OCR. Text PDF, DOCX, and Excel still work.');
290
+ return;
291
+ }
292
+
293
+ const languages = await listTesseractLanguages(executable);
294
+ if (!languages.includes('chi_sim')) {
295
+ notify(
296
+ '[nexum-code] /doc OCR note: Tesseract is installed, but chi_sim language data was not found. ' +
297
+ 'Chinese OCR needs chi_sim.traineddata or NEXUM_OCR_LANGUAGE=eng for English-only OCR.',
298
+ );
299
+ }
300
+ } catch (error) {
301
+ const message = error instanceof Error ? error.message : String(error);
302
+ notify(`[nexum-code] /doc OCR setup warning: ${message}`);
303
+ }
304
+ }
305
+
306
+ async function findTesseractExecutable() {
307
+ const configured = process.env.NEXUM_TESSERACT_PATH;
308
+ if (configured !== undefined && configured.length > 0 && await fileExists(configured)) {
309
+ return configured;
310
+ }
311
+
312
+ if (await commandWorks('tesseract', ['--version'])) {
313
+ return 'tesseract';
314
+ }
315
+
316
+ if (process.platform === 'win32') {
317
+ const candidates = [
318
+ 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe',
319
+ 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe',
320
+ ];
321
+ for (const candidate of candidates) {
322
+ if (await fileExists(candidate)) {
323
+ return candidate;
324
+ }
325
+ }
326
+ }
327
+
328
+ return undefined;
329
+ }
330
+
331
+ async function listTesseractLanguages(executable) {
332
+ const { stdout } = await execFileQuiet(executable, ['--list-langs']);
333
+ return stdout
334
+ .split(/\r?\n/g)
335
+ .map((line) => line.trim())
336
+ .filter((line) => line.length > 0 && !line.startsWith('List of available languages'));
337
+ }
338
+
339
+ async function commandWorks(command, args) {
340
+ try {
341
+ await execFileQuiet(command, args);
342
+ return true;
343
+ } catch {
344
+ return false;
345
+ }
346
+ }
347
+
348
+ async function fileExists(filePath) {
349
+ try {
350
+ await access(filePath);
351
+ return true;
352
+ } catch {
353
+ return false;
354
+ }
355
+ }
356
+
357
+ function execFileQuiet(command, args) {
358
+ return new Promise((resolve, reject) => {
359
+ execFile(command, args, { windowsHide: true, maxBuffer: 16 * 1024 * 1024 }, (error, stdout, stderr) => {
360
+ if (error) {
361
+ reject(new Error(stderr || error.message));
362
+ return;
363
+ }
364
+ resolve({ stdout, stderr });
365
+ });
366
+ });
367
+ }
368
+
369
+ try {
370
+ createDesktopShortcut();
269
371
  } catch {
270
372
  // Never fail the install over a shortcut.
271
373
  }
@@ -8,10 +8,10 @@ import { c as init_fetch_blob, i as init_esm_min, n as FormData, r as formDataTo
8
8
  import Ds, { PassThrough, pipeline } from "node:stream";
9
9
  import http from "node:http";
10
10
  import { format } from "node:url";
11
+ import { deprecate, promisify, types } from "node:util";
11
12
  import https from "node:https";
12
13
  import zlib from "node:zlib";
13
14
  import { Buffer as Buffer$1 } from "node:buffer";
14
- import { deprecate, promisify, types } from "node:util";
15
15
  import { isIP } from "node:net";
16
16
  //#region ../../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
17
17
  /**