nexum-code 0.6.14 → 0.6.16
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 +84 -322
- package/dist/{aiflowy-bot-sync-BMV5Lg3y.mjs → aiflowy-bot-sync-C0WrAYbG.mjs} +2 -2
- package/dist/{aiflowy-bot-sync-CY50Z6GW.mjs → aiflowy-bot-sync-DhoRtQfn.mjs} +1 -1
- package/dist/{app-LAoILm5g.mjs → app-0T4efY5b.mjs} +38489 -6252
- package/dist/esm-RYfZ46Tf.mjs +3593 -0
- package/dist/index.min-D4utBuC7.mjs +2990 -0
- package/dist/main.mjs +1 -1
- package/dist/pdf-F2kQiIQy.mjs +26642 -0
- package/dist/pdf.worker-ByxNbF6P.mjs +82061 -0
- package/dist/{src-BMbLXrAA.mjs → src-kwvD0ssv.mjs} +12 -12
- package/package.json +26 -22
- package/scripts/postinstall.mjs +115 -13
- package/dist/esm-CmfJNv9s.mjs +0 -8590
|
@@ -5,13 +5,13 @@ const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
6
|
import { n as __esmMin } from "./chunk-apG1qJts.mjs";
|
|
7
7
|
import { c as init_fetch_blob, i as init_esm_min, n as FormData, r as formDataToBlob, s as Blob, t as init_from } from "./from-CKE2n10i.mjs";
|
|
8
|
-
import
|
|
8
|
+
import As, { 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
|
/**
|
|
@@ -131,7 +131,7 @@ async function consumeBody(data) {
|
|
|
131
131
|
const { body } = data;
|
|
132
132
|
if (body === null) return Buffer$1.alloc(0);
|
|
133
133
|
/* c8 ignore next 3 */
|
|
134
|
-
if (!(body instanceof
|
|
134
|
+
if (!(body instanceof As)) return Buffer$1.alloc(0);
|
|
135
135
|
const accum = [];
|
|
136
136
|
let accumBytes = 0;
|
|
137
137
|
try {
|
|
@@ -162,7 +162,7 @@ var init_body = __esmMin((() => {
|
|
|
162
162
|
init_fetch_error();
|
|
163
163
|
init_base();
|
|
164
164
|
init_is();
|
|
165
|
-
pipeline$1 = promisify(
|
|
165
|
+
pipeline$1 = promisify(As.pipeline);
|
|
166
166
|
INTERNALS$2 = Symbol("Body internals");
|
|
167
167
|
Body = class {
|
|
168
168
|
constructor(body, { size = 0 } = {}) {
|
|
@@ -171,13 +171,13 @@ var init_body = __esmMin((() => {
|
|
|
171
171
|
else if (isURLSearchParameters(body)) body = Buffer$1.from(body.toString());
|
|
172
172
|
else if (isBlob(body)) {} else if (Buffer$1.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) body = Buffer$1.from(body);
|
|
173
173
|
else if (ArrayBuffer.isView(body)) body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
|
|
174
|
-
else if (body instanceof
|
|
174
|
+
else if (body instanceof As) {} else if (body instanceof FormData) {
|
|
175
175
|
body = formDataToBlob(body);
|
|
176
176
|
boundary = body.type.split("=")[1];
|
|
177
177
|
} else body = Buffer$1.from(String(body));
|
|
178
178
|
let stream = body;
|
|
179
|
-
if (Buffer$1.isBuffer(body)) stream =
|
|
180
|
-
else if (isBlob(body)) stream =
|
|
179
|
+
if (Buffer$1.isBuffer(body)) stream = As.Readable.from(body);
|
|
180
|
+
else if (isBlob(body)) stream = As.Readable.from(body.stream());
|
|
181
181
|
this[INTERNALS$2] = {
|
|
182
182
|
body,
|
|
183
183
|
stream,
|
|
@@ -186,7 +186,7 @@ var init_body = __esmMin((() => {
|
|
|
186
186
|
error: null
|
|
187
187
|
};
|
|
188
188
|
this.size = size;
|
|
189
|
-
if (body instanceof
|
|
189
|
+
if (body instanceof As) body.on("error", (error_) => {
|
|
190
190
|
const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
|
|
191
191
|
this[INTERNALS$2].error = error;
|
|
192
192
|
});
|
|
@@ -268,7 +268,7 @@ var init_body = __esmMin((() => {
|
|
|
268
268
|
let p2;
|
|
269
269
|
let { body } = instance[INTERNALS$2];
|
|
270
270
|
if (instance.bodyUsed) throw new Error("cannot clone body after it is used");
|
|
271
|
-
if (body instanceof
|
|
271
|
+
if (body instanceof As && typeof body.getBoundary !== "function") {
|
|
272
272
|
p1 = new PassThrough({ highWaterMark });
|
|
273
273
|
p2 = new PassThrough({ highWaterMark });
|
|
274
274
|
body.pipe(p1);
|
|
@@ -287,7 +287,7 @@ var init_body = __esmMin((() => {
|
|
|
287
287
|
if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) return null;
|
|
288
288
|
if (body instanceof FormData) return `multipart/form-data; boundary=${request[INTERNALS$2].boundary}`;
|
|
289
289
|
if (body && typeof body.getBoundary === "function") return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
|
|
290
|
-
if (body instanceof
|
|
290
|
+
if (body instanceof As) return null;
|
|
291
291
|
return "text/plain;charset=UTF-8";
|
|
292
292
|
};
|
|
293
293
|
getTotalBytes = (request) => {
|
|
@@ -952,7 +952,7 @@ async function fetch(url, options_) {
|
|
|
952
952
|
const abort = () => {
|
|
953
953
|
const error = new AbortError("The operation was aborted.");
|
|
954
954
|
reject(error);
|
|
955
|
-
if (request.body && request.body instanceof
|
|
955
|
+
if (request.body && request.body instanceof As.Readable) request.body.destroy(error);
|
|
956
956
|
if (!response || !response.body) return;
|
|
957
957
|
response.body.emit("error", error);
|
|
958
958
|
};
|
|
@@ -1038,7 +1038,7 @@ async function fetch(url, options_) {
|
|
|
1038
1038
|
"cookie",
|
|
1039
1039
|
"cookie2"
|
|
1040
1040
|
]) requestOptions.headers.delete(name);
|
|
1041
|
-
if (response_.statusCode !== 303 && request.body && options_.body instanceof
|
|
1041
|
+
if (response_.statusCode !== 303 && request.body && options_.body instanceof As.Readable) {
|
|
1042
1042
|
reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
|
|
1043
1043
|
finalize();
|
|
1044
1044
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexum-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
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
|
+
}
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -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
|
-
|
|
268
|
-
|
|
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
|
}
|