jinzd-ai-cli 0.4.208 → 0.4.209

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.
Files changed (27) hide show
  1. package/README.md +5 -3
  2. package/dist/{batch-3T44NFLG.js → batch-45WLJUVP.js} +4 -4
  3. package/dist/{chunk-TD7JEHCR.js → chunk-ATNYI6JL.js} +19 -4
  4. package/dist/{chunk-SQB66GP6.js → chunk-BNERFXVO.js} +12 -9
  5. package/dist/{chunk-P7JY3SWA.js → chunk-D6M4E7SH.js} +1 -1
  6. package/dist/{chunk-TM4MS63K.js → chunk-DUZRQXIP.js} +6 -3
  7. package/dist/{chunk-VWYUB22Y.js → chunk-EN63JA7N.js} +1 -1
  8. package/dist/{chunk-QDY72ABW.js → chunk-EYID2AIR.js} +1 -1
  9. package/dist/{chunk-2OVMMSGQ.js → chunk-JVLRMIHA.js} +10 -9
  10. package/dist/{chunk-O6UFCEUZ.js → chunk-K3CF65QH.js} +12 -9
  11. package/dist/{chunk-J22B3OSQ.js → chunk-STIEOOOL.js} +1 -1
  12. package/dist/{chunk-KV4GYNEA.js → chunk-UPMBIS4T.js} +1 -1
  13. package/dist/{ci-6QWBVRJX.js → ci-PUE3MQ7J.js} +3 -2
  14. package/dist/{constants-SZTQNN7K.js → constants-VTZLKDAG.js} +1 -1
  15. package/dist/{doctor-cli-I2Y2YR4V.js → doctor-cli-IU6FSVLF.js} +4 -4
  16. package/dist/electron-server.js +82 -49
  17. package/dist/{hub-XVPFBODB.js → hub-4ETK4R2J.js} +1 -1
  18. package/dist/index.js +27 -28
  19. package/dist/{indexer-AKWMYNJI.js → indexer-2AG4G6B5.js} +1 -1
  20. package/dist/{indexer-BMYUUDLH.js → indexer-4WWS3VIL.js} +1 -1
  21. package/dist/{run-tests-D5SNUBYX.js → run-tests-NDS2IEMK.js} +2 -2
  22. package/dist/{run-tests-HZ2CRCTZ.js → run-tests-UAS5NJBM.js} +1 -1
  23. package/dist/{server-4EFTRFTN.js → server-4URLNC7P.js} +44 -22
  24. package/dist/{server-PVKLPRUP.js → server-72SAPLPS.js} +5 -5
  25. package/dist/{task-orchestrator-2A5VCFLS.js → task-orchestrator-6PZTB35T.js} +5 -5
  26. package/dist/{usage-Q24E5636.js → usage-ZNCKGF6U.js} +2 -2
  27. package/package.json +2 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![npm version](https://img.shields.io/npm/v/jinzd-ai-cli)](https://www.npmjs.com/package/jinzd-ai-cli)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
9
  [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org)
10
- [![Tests](https://img.shields.io/badge/tests-1097%20passing-brightgreen)]()
10
+ [![Tests](https://img.shields.io/badge/tests-1393%20passing-brightgreen)]()
11
11
  [![GitHub Release](https://img.shields.io/github/v/release/jinzhengdong/ai-cli)](https://github.com/jinzhengdong/ai-cli/releases)
12
12
  [![CI](https://github.com/jinzhengdong/ai-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/jinzhengdong/ai-cli/actions/workflows/ci.yml)
13
13
 
@@ -414,11 +414,13 @@ The Web UI (`aicli web`) provides a full-featured browser interface:
414
414
  ## Testing
415
415
 
416
416
  ```bash
417
- npm test # Run all 396 tests
417
+ npm test # Offline regression suite: 79 files, 1393 passed, 1 skipped
418
+ npm run test:providers # Real-provider smoke tests (network/API-key dependent)
419
+ npm run test:e2e-web # Playwright browser smoke; may need browser-process permission in sandboxes
418
420
  npm run test:watch # Watch mode
419
421
  ```
420
422
 
421
- 26 test suites covering: authentication, sessions, tool types & danger levels, permissions, output truncation, diff rendering, edit-file similarity, error hierarchy, config management, env loading, provider registry, web-fetch, grep-files, hub renderer, hub discussion, hub presets, dev-state, token estimator, tool registry budget, parallel tool execution, cost tracker, session tool history.
423
+ 79 offline test files covering: authentication, sessions, tool types & danger levels, permissions, output truncation, diff rendering, edit-file similarity, error hierarchy, config management, env loading, provider registry, web-fetch, grep-files, hub renderer, hub discussion, hub presets, dev-state, token estimator, tool registry budget, parallel tool execution, cost tracker, session tool history.
422
424
 
423
425
  ## Documentation
424
426
 
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConfigManager
4
- } from "./chunk-TM4MS63K.js";
4
+ } from "./chunk-DUZRQXIP.js";
5
5
  import "./chunk-TZQHYZKT.js";
6
- import "./chunk-KV4GYNEA.js";
6
+ import "./chunk-UPMBIS4T.js";
7
7
  import {
8
8
  atomicWriteFileSync
9
9
  } from "./chunk-IW3Q7AE5.js";
10
10
 
11
11
  // src/cli/batch.ts
12
12
  import Anthropic from "@anthropic-ai/sdk";
13
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
13
+ import { readFileSync, existsSync, mkdirSync } from "fs";
14
14
  import { join } from "path";
15
15
  function parseBatchInput(jsonl) {
16
16
  const lines = jsonl.split("\n").map((l) => l.trim()).filter(Boolean);
@@ -195,7 +195,7 @@ async function cmdResults(batchId, outPath) {
195
195
  }
196
196
  const body = lines.join("\n") + "\n";
197
197
  if (outPath) {
198
- writeFileSync(outPath, body, "utf-8");
198
+ atomicWriteFileSync(outPath, body);
199
199
  console.log(`Saved ${lines.length} result(s) to ${outPath} (${ok} succeeded, ${err} failed/errored).`);
200
200
  } else {
201
201
  process.stdout.write(body);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  truncateForPersist
4
- } from "./chunk-2OVMMSGQ.js";
4
+ } from "./chunk-JVLRMIHA.js";
5
5
  import {
6
6
  APP_NAME,
7
7
  CONFIG_DIR_NAME,
@@ -11,7 +11,10 @@ import {
11
11
  MCP_PROTOCOL_VERSION,
12
12
  MCP_TOOL_PREFIX,
13
13
  VERSION
14
- } from "./chunk-KV4GYNEA.js";
14
+ } from "./chunk-UPMBIS4T.js";
15
+ import {
16
+ atomicWriteFileSync
17
+ } from "./chunk-IW3Q7AE5.js";
15
18
 
16
19
  // src/mcp/client.ts
17
20
  import { spawn } from "child_process";
@@ -696,6 +699,17 @@ async function setupProxy(configProxy) {
696
699
  }
697
700
  }
698
701
 
702
+ // src/core/git-diff.ts
703
+ import { execFileSync } from "child_process";
704
+ function readGitDiff(options = {}) {
705
+ const args = ["diff"];
706
+ if (options.staged) args.push("--staged");
707
+ return execFileSync("git", args, {
708
+ encoding: "utf-8",
709
+ timeout: options.timeoutMs ?? 1e4
710
+ }).trim();
711
+ }
712
+
699
713
  // src/session/tool-history.ts
700
714
  var SESSION_SIZE_LIMIT = 2 * 1024 * 1024;
701
715
  function persistToolRound(session, toolCalls, toolResults, opts) {
@@ -784,7 +798,7 @@ function autoTrimSessionIfNeeded(session, sizeLimit = SESSION_SIZE_LIMIT) {
784
798
  }
785
799
 
786
800
  // src/repl/dev-state.ts
787
- import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
801
+ import { existsSync as existsSync2, readFileSync as readFileSync2, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
788
802
  import { join as join2 } from "path";
789
803
  import { homedir } from "os";
790
804
  var DEV_STATE_MAX_CHARS = 6e3;
@@ -855,7 +869,7 @@ function saveDevState(content) {
855
869
  }
856
870
  trimmed += "\n\n[...truncated]";
857
871
  }
858
- writeFileSync(getDevStatePath(), trimmed, "utf-8");
872
+ atomicWriteFileSync(getDevStatePath(), trimmed);
859
873
  }
860
874
  function loadDevState() {
861
875
  const path = getDevStatePath();
@@ -874,6 +888,7 @@ function clearDevState() {
874
888
  }
875
889
 
876
890
  export {
891
+ readGitDiff,
877
892
  parseSimpleYaml,
878
893
  persistToolRound,
879
894
  autoTrimSessionIfNeeded,
@@ -19,12 +19,13 @@ import { Parser, Language } from "web-tree-sitter";
19
19
  import { createRequire } from "module";
20
20
  import path from "path";
21
21
  import fs from "fs";
22
- import { fileURLToPath } from "url";
23
- var _metaUrl = import.meta?.url;
24
- var _cjsFilename = globalThis.__filename;
25
- var __filename_ = _metaUrl ? fileURLToPath(_metaUrl) : _cjsFilename ?? process.execPath;
26
- var __dirname_ = path.dirname(__filename_);
27
- var require_ = _metaUrl ? createRequire(_metaUrl) : createRequire(__filename_);
22
+ var entryCandidates = [
23
+ process.pkg?.entrypoint,
24
+ process.argv[1],
25
+ process.execPath
26
+ ].filter((p) => !!p);
27
+ var bundleDirs = [...new Set(entryCandidates.map((p) => path.dirname(path.resolve(p))))];
28
+ var require_ = createRequire(path.join(process.cwd(), "package.json"));
28
29
  var GRAMMAR_FILE = {
29
30
  typescript: "tree-sitter-typescript.wasm",
30
31
  tsx: "tree-sitter-tsx.wasm",
@@ -41,9 +42,11 @@ var languageCache = /* @__PURE__ */ new Map();
41
42
  var parserCache = /* @__PURE__ */ new Map();
42
43
  function resolveWasmPath(filename) {
43
44
  const candidates = [];
44
- candidates.push(path.join(__dirname_, "wasm", filename));
45
- candidates.push(path.join(__dirname_, "..", "wasm", filename));
46
- candidates.push(path.join(__dirname_, "..", "dist", "wasm", filename));
45
+ for (const dir of bundleDirs) {
46
+ candidates.push(path.join(dir, "wasm", filename));
47
+ candidates.push(path.join(dir, "..", "wasm", filename));
48
+ candidates.push(path.join(dir, "..", "dist", "wasm", filename));
49
+ }
47
50
  if (process.pkg) {
48
51
  candidates.push(path.join(path.dirname(process.execPath), "dist", "wasm", filename));
49
52
  candidates.push(path.join("/snapshot", "ai-cli", "dist", "wasm", filename));
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CONFIG_DIR_NAME,
4
4
  VERSION
5
- } from "./chunk-KV4GYNEA.js";
5
+ } from "./chunk-UPMBIS4T.js";
6
6
 
7
7
  // src/diagnostics/crash-log.ts
8
8
  import {
@@ -8,10 +8,13 @@ import {
8
8
  CONFIG_FILE_NAME,
9
9
  HISTORY_DIR_NAME,
10
10
  PLUGINS_DIR_NAME
11
- } from "./chunk-KV4GYNEA.js";
11
+ } from "./chunk-UPMBIS4T.js";
12
+ import {
13
+ atomicWriteFileSync
14
+ } from "./chunk-IW3Q7AE5.js";
12
15
 
13
16
  // src/config/config-manager.ts
14
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
17
+ import { readFileSync, existsSync, mkdirSync } from "fs";
15
18
  import { join } from "path";
16
19
  import { homedir } from "os";
17
20
 
@@ -347,7 +350,7 @@ ${err}`
347
350
  }
348
351
  save() {
349
352
  mkdirSync(this.configDir, { recursive: true });
350
- writeFileSync(this.configPath, JSON.stringify(this.config, null, 2), "utf-8");
353
+ atomicWriteFileSync(this.configPath, JSON.stringify(this.config, null, 2));
351
354
  }
352
355
  getApiKey(providerId) {
353
356
  const envKey = EnvLoader.getApiKey(providerId);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  TEST_TIMEOUT
4
- } from "./chunk-KV4GYNEA.js";
4
+ } from "./chunk-UPMBIS4T.js";
5
5
 
6
6
  // src/tools/builtin/run-tests.ts
7
7
  import { execSync, spawnSync } from "child_process";
@@ -6,7 +6,7 @@ import { platform } from "os";
6
6
  import chalk from "chalk";
7
7
 
8
8
  // src/core/constants.ts
9
- var VERSION = "0.4.208";
9
+ var VERSION = "0.4.209";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -5,10 +5,10 @@ import {
5
5
  } from "./chunk-T2NL5ZIA.js";
6
6
  import {
7
7
  runTestsTool
8
- } from "./chunk-VWYUB22Y.js";
8
+ } from "./chunk-EN63JA7N.js";
9
9
  import {
10
10
  runTool
11
- } from "./chunk-J22B3OSQ.js";
11
+ } from "./chunk-STIEOOOL.js";
12
12
  import {
13
13
  getDangerLevel,
14
14
  isFileWriteTool,
@@ -26,7 +26,7 @@ import {
26
26
  SUBAGENT_ALLOWED_TOOLS,
27
27
  SUBAGENT_DEFAULT_MAX_ROUNDS,
28
28
  SUBAGENT_MAX_ROUNDS_LIMIT
29
- } from "./chunk-KV4GYNEA.js";
29
+ } from "./chunk-UPMBIS4T.js";
30
30
  import {
31
31
  fileCheckpoints
32
32
  } from "./chunk-4BKXL7SM.js";
@@ -36,7 +36,7 @@ import {
36
36
  } from "./chunk-TB4W4Y4T.js";
37
37
  import {
38
38
  indexProject
39
- } from "./chunk-O6UFCEUZ.js";
39
+ } from "./chunk-K3CF65QH.js";
40
40
  import {
41
41
  loadIndex
42
42
  } from "./chunk-CKH4KQ4E.js";
@@ -2145,7 +2145,7 @@ Do NOT split a long document into many write_file(append=true) calls. That patte
2145
2145
  const mode = appendMode ? "appended" : "written";
2146
2146
  void (async () => {
2147
2147
  try {
2148
- const { updateFile } = await import("./indexer-AKWMYNJI.js");
2148
+ const { updateFile } = await import("./indexer-2AG4G6B5.js");
2149
2149
  await updateFile(process.cwd(), filePath);
2150
2150
  } catch {
2151
2151
  }
@@ -3929,7 +3929,7 @@ Any of these triggers means use save_last_response, NOT write_file:
3929
3929
  };
3930
3930
 
3931
3931
  // src/tools/builtin/save-memory.ts
3932
- import { existsSync as existsSync9, statSync as statSync6, appendFileSync as appendFileSync2, mkdirSync as mkdirSync3 } from "fs";
3932
+ import { existsSync as existsSync9, readFileSync as readFileSync6, statSync as statSync6, mkdirSync as mkdirSync3 } from "fs";
3933
3933
  import { join as join4 } from "path";
3934
3934
  import { homedir as homedir3 } from "os";
3935
3935
  function getMemoryFilePath() {
@@ -3966,7 +3966,8 @@ var saveMemoryTool = {
3966
3966
  ## ${timestamp}
3967
3967
  ${content}
3968
3968
  `;
3969
- appendFileSync2(memoryPath, entry, "utf-8");
3969
+ const previous = existsSync9(memoryPath) ? readFileSync6(memoryPath, "utf-8") : "";
3970
+ atomicWriteFileSync(memoryPath, previous + entry);
3970
3971
  const byteSize = statSync6(memoryPath).size;
3971
3972
  return `Memory saved successfully. File size: ${byteSize} bytes in ${MEMORY_FILE_NAME}`;
3972
3973
  }
@@ -5031,7 +5032,7 @@ ${commitOutput.trim()}`;
5031
5032
  };
5032
5033
 
5033
5034
  // src/tools/builtin/notebook-edit.ts
5034
- import { readFileSync as readFileSync6, existsSync as existsSync11 } from "fs";
5035
+ import { readFileSync as readFileSync7, existsSync as existsSync11 } from "fs";
5035
5036
  import { writeFile } from "fs/promises";
5036
5037
  import { resolve as resolve4, extname as extname2 } from "path";
5037
5038
  var notebookEditTool = {
@@ -5089,7 +5090,7 @@ var notebookEditTool = {
5089
5090
  if (!existsSync11(absPath)) {
5090
5091
  throw new ToolError("notebook_edit", `Notebook not found: ${filePath}`);
5091
5092
  }
5092
- const raw = readFileSync6(absPath, "utf-8");
5093
+ const raw = readFileSync7(absPath, "utf-8");
5093
5094
  const nb = parseNotebook(raw);
5094
5095
  const cellIdx0 = cellIndexRaw - 1;
5095
5096
  undoStack.push(absPath, `notebook_edit (${action}): ${filePath}`);
@@ -20,12 +20,13 @@ import { Parser, Language } from "web-tree-sitter";
20
20
  import { createRequire } from "module";
21
21
  import path from "path";
22
22
  import fs from "fs";
23
- import { fileURLToPath } from "url";
24
- var _metaUrl = import.meta?.url;
25
- var _cjsFilename = globalThis.__filename;
26
- var __filename_ = _metaUrl ? fileURLToPath(_metaUrl) : _cjsFilename ?? process.execPath;
27
- var __dirname_ = path.dirname(__filename_);
28
- var require_ = _metaUrl ? createRequire(_metaUrl) : createRequire(__filename_);
23
+ var entryCandidates = [
24
+ process.pkg?.entrypoint,
25
+ process.argv[1],
26
+ process.execPath
27
+ ].filter((p) => !!p);
28
+ var bundleDirs = [...new Set(entryCandidates.map((p) => path.dirname(path.resolve(p))))];
29
+ var require_ = createRequire(path.join(process.cwd(), "package.json"));
29
30
  var GRAMMAR_FILE = {
30
31
  typescript: "tree-sitter-typescript.wasm",
31
32
  tsx: "tree-sitter-tsx.wasm",
@@ -42,9 +43,11 @@ var languageCache = /* @__PURE__ */ new Map();
42
43
  var parserCache = /* @__PURE__ */ new Map();
43
44
  function resolveWasmPath(filename) {
44
45
  const candidates = [];
45
- candidates.push(path.join(__dirname_, "wasm", filename));
46
- candidates.push(path.join(__dirname_, "..", "wasm", filename));
47
- candidates.push(path.join(__dirname_, "..", "dist", "wasm", filename));
46
+ for (const dir of bundleDirs) {
47
+ candidates.push(path.join(dir, "wasm", filename));
48
+ candidates.push(path.join(dir, "..", "wasm", filename));
49
+ candidates.push(path.join(dir, "..", "dist", "wasm", filename));
50
+ }
48
51
  if (process.pkg) {
49
52
  candidates.push(path.join(path.dirname(process.execPath), "dist", "wasm", filename));
50
53
  candidates.push(path.join("/snapshot", "ai-cli", "dist", "wasm", filename));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR_NAME
4
- } from "./chunk-KV4GYNEA.js";
4
+ } from "./chunk-UPMBIS4T.js";
5
5
  import {
6
6
  atomicWriteFileSync
7
7
  } from "./chunk-IW3Q7AE5.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/core/constants.ts
4
- var VERSION = "0.4.208";
4
+ var VERSION = "0.4.209";
5
5
  var APP_NAME = "ai-cli";
6
6
  var CONFIG_DIR_NAME = ".aicli";
7
7
  var CONFIG_FILE_NAME = "config.json";
@@ -10,11 +10,12 @@ import {
10
10
  import "./chunk-XPBEJB27.js";
11
11
  import {
12
12
  ConfigManager
13
- } from "./chunk-TM4MS63K.js";
13
+ } from "./chunk-DUZRQXIP.js";
14
14
  import "./chunk-TZQHYZKT.js";
15
15
  import {
16
16
  VERSION
17
- } from "./chunk-KV4GYNEA.js";
17
+ } from "./chunk-UPMBIS4T.js";
18
+ import "./chunk-IW3Q7AE5.js";
18
19
 
19
20
  // src/cli/ci.ts
20
21
  import { execFileSync } from "child_process";
@@ -36,7 +36,7 @@ import {
36
36
  TEST_TIMEOUT,
37
37
  VERSION,
38
38
  buildUserIdentityPrompt
39
- } from "./chunk-KV4GYNEA.js";
39
+ } from "./chunk-UPMBIS4T.js";
40
40
  export {
41
41
  AGENTIC_BEHAVIOR_GUIDELINE,
42
42
  APP_NAME,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getConfigDirUsage,
4
4
  listRecentCrashes
5
- } from "./chunk-P7JY3SWA.js";
5
+ } from "./chunk-D6M4E7SH.js";
6
6
  import {
7
7
  ProviderRegistry
8
8
  } from "./chunk-QMXC327F.js";
@@ -11,17 +11,17 @@ import {
11
11
  getTopFailingTools,
12
12
  getTopUsedTools,
13
13
  resetStats
14
- } from "./chunk-J22B3OSQ.js";
14
+ } from "./chunk-STIEOOOL.js";
15
15
  import "./chunk-XPBEJB27.js";
16
16
  import {
17
17
  ConfigManager
18
- } from "./chunk-TM4MS63K.js";
18
+ } from "./chunk-DUZRQXIP.js";
19
19
  import "./chunk-TZQHYZKT.js";
20
20
  import {
21
21
  DEV_STATE_FILE_NAME,
22
22
  MEMORY_FILE_NAME,
23
23
  VERSION
24
- } from "./chunk-KV4GYNEA.js";
24
+ } from "./chunk-UPMBIS4T.js";
25
25
  import "./chunk-IW3Q7AE5.js";
26
26
 
27
27
  // src/diagnostics/doctor-cli.ts