jinzd-ai-cli 0.4.188 → 0.4.190

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 (60) hide show
  1. package/dist/{agent-client-25TIQ6AP.js → agent-client-6GX6QQDU.js} +0 -1
  2. package/dist/{auth-OI4YRVRG.js → auth-FSTAKSYF.js} +2 -2
  3. package/dist/{batch-D6K2KHJK.js → batch-HF5RWUBL.js} +7 -15
  4. package/dist/{chat-index-JXTYDRCY.js → chat-index-FDSGKWQV.js} +2 -2
  5. package/dist/{chat-index-WDMVP7BN.js → chat-index-UBCWHBLR.js} +2 -2
  6. package/dist/{chunk-UK6E2563.js → chunk-4KMDKDAK.js} +1 -1
  7. package/dist/{chunk-J3XSJCO5.js → chunk-5CLH6XAW.js} +10 -8
  8. package/dist/chunk-6BUTA5VW.js +38 -0
  9. package/dist/{chunk-VRCBXH2W.js → chunk-A4GUGWEY.js} +1 -1
  10. package/dist/{chunk-YKVFZLSI.js → chunk-AEAYUKSY.js} +2 -2
  11. package/dist/{chunk-ZWVIDFGY.js → chunk-BXP6YZ2P.js} +4 -3
  12. package/dist/{chunk-OVWE4E46.js → chunk-CKH4KQ4E.js} +4 -3
  13. package/dist/{chunk-D6U75FHP.js → chunk-IEQAE3QG.js} +4 -3
  14. package/dist/chunk-IW3Q7AE5.js +40 -0
  15. package/dist/{chunk-VPTRE7IW.js → chunk-JATZIZJV.js} +2 -2
  16. package/dist/{chunk-GXB7YKF2.js → chunk-JVKAL5Q3.js} +5 -12
  17. package/dist/{chunk-DFQSQQEU.js → chunk-KHS7RSGR.js} +6 -5
  18. package/dist/{chunk-RIVZNS3K.js → chunk-MC34ISJU.js} +5 -4
  19. package/dist/{chunk-NRSAAMIF.js → chunk-NV6W7TZW.js} +1 -1
  20. package/dist/{chunk-VNNYHW6N.js → chunk-O6UFCEUZ.js} +1 -1
  21. package/dist/{chunk-DQ2OHJNF.js → chunk-RWM2GFRC.js} +5 -3
  22. package/dist/{chunk-SEFOKYYP.js → chunk-SQB66GP6.js} +1 -1
  23. package/dist/{chunk-HDSKW7Q3.js → chunk-T2NL5ZIA.js} +2 -2
  24. package/dist/{chunk-4UZE4ADL.js → chunk-TB4W4Y4T.js} +18 -52
  25. package/dist/{chunk-MUQZOUV5.js → chunk-UVW3WLSV.js} +1 -1
  26. package/dist/{chunk-KIGVJVX4.js → chunk-W7UKO3PS.js} +18 -50
  27. package/dist/{chunk-Q7SB3R25.js → chunk-X4J2DZB5.js} +1 -1
  28. package/dist/{chunk-A3I5WP5L.js → chunk-YUBD7T2R.js} +5 -4
  29. package/dist/{chunk-ODAAPNSL.js → chunk-ZN5IEPSS.js} +1 -1
  30. package/dist/{ci-42ZBP2SY.js → ci-X24WFUDF.js} +13 -7
  31. package/dist/{constants-NCWVAAI7.js → constants-4QBBHLU4.js} +1 -2
  32. package/dist/{doctor-cli-R3SWTL5Z.js → doctor-cli-EUOCY7VN.js} +5 -5
  33. package/dist/electron-server.js +52 -62
  34. package/dist/{file-checkpoint-UHSMHCRU.js → file-checkpoint-CGH6OJVI.js} +0 -1
  35. package/dist/{file-checkpoint-ZN7KE3TN.js → file-checkpoint-NKBHGC7L.js} +0 -1
  36. package/dist/{git-context-7KIP4X2V.js → git-context-EXOEHQSF.js} +0 -1
  37. package/dist/{hub-3ZGIM2FN.js → hub-YW3KLBZM.js} +3 -4
  38. package/dist/{hub-server-GSTG5MNE.js → hub-server-LJ2JSKZ2.js} +0 -1
  39. package/dist/index.js +36 -36
  40. package/dist/{indexer-S6UMGQKA.js → indexer-AKWMYNJI.js} +3 -3
  41. package/dist/indexer-BMYUUDLH.js +10 -0
  42. package/dist/{persist-A3R2IAYU.js → persist-L54DPLI7.js} +3 -3
  43. package/dist/{project-trust-EBGHD7LE.js → project-trust-MUG325AW.js} +4 -11
  44. package/dist/{project-trust-IFM7FXEV.js → project-trust-NKYHL3VZ.js} +4 -11
  45. package/dist/{run-tests-NS3SPH6S.js → run-tests-7ZUNEUEX.js} +2 -3
  46. package/dist/{run-tests-IJYP6BMT.js → run-tests-OTZE5CEN.js} +1 -2
  47. package/dist/{semantic-GJJWTI3A.js → semantic-FF6DDJI6.js} +4 -4
  48. package/dist/{semantic-FKOEXY75.js → semantic-PK7AUOJT.js} +4 -4
  49. package/dist/{server-TZRMRT3O.js → server-WMLZOLD5.js} +30 -30
  50. package/dist/{server-SVTSJ3PK.js → server-YMCGJOXV.js} +10 -10
  51. package/dist/{store-VMK543OQ.js → store-MWNHVGJT.js} +2 -2
  52. package/dist/{store-A3TZM6PS.js → store-VO37H6LS.js} +2 -2
  53. package/dist/{task-orchestrator-GMJ5PLVV.js → task-orchestrator-DEWKVJGQ.js} +14 -14
  54. package/dist/{usage-IYMFSHDX.js → usage-5LMWDGZ4.js} +4 -4
  55. package/dist/{vector-store-Z5OF4WWJ.js → vector-store-BBDXB5IQ.js} +2 -2
  56. package/dist/{vector-store-PLDSXF3V.js → vector-store-JBAE6PS4.js} +2 -2
  57. package/package.json +1 -1
  58. package/dist/chunk-3RG5ZIWI.js +0 -10
  59. package/dist/chunk-PDX44BCA.js +0 -11
  60. package/dist/indexer-ISSNIFQY.js +0 -10
@@ -3,9 +3,12 @@ import {
3
3
  embed,
4
4
  embedOne
5
5
  } from "./chunk-JV5N65KN.js";
6
+ import {
7
+ atomicWriteFileSync
8
+ } from "./chunk-6BUTA5VW.js";
6
9
 
7
10
  // src/memory/chat-index.ts
8
- import fs2 from "fs";
11
+ import fs from "fs";
9
12
  import path from "path";
10
13
  import os from "os";
11
14
  import crypto from "crypto";
@@ -118,41 +121,6 @@ function redactJson(value, options) {
118
121
  return { value: redacted, hits: allHits };
119
122
  }
120
123
 
121
- // src/core/atomic-write.ts
122
- import fs from "fs";
123
- var RETRYABLE_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
124
- var MAX_RENAME_RETRIES = 10;
125
- function sleepSync(ms) {
126
- const sab = new Int32Array(new SharedArrayBuffer(4));
127
- Atomics.wait(sab, 0, 0, ms);
128
- }
129
- function atomicWriteFileSync(target, data) {
130
- const tmp = `${target}.tmp`;
131
- fs.writeFileSync(tmp, data);
132
- for (let attempt = 0; ; attempt++) {
133
- try {
134
- fs.renameSync(tmp, target);
135
- return;
136
- } catch (err) {
137
- const code = err.code;
138
- if (attempt < MAX_RENAME_RETRIES && code && RETRYABLE_CODES.has(code)) {
139
- sleepSync(5 * (attempt + 1));
140
- continue;
141
- }
142
- try {
143
- fs.writeFileSync(target, data);
144
- try {
145
- fs.unlinkSync(tmp);
146
- } catch {
147
- }
148
- return;
149
- } catch {
150
- throw err;
151
- }
152
- }
153
- }
154
- }
155
-
156
124
  // src/memory/chat-index.ts
157
125
  var MEMORY_DIR_NAME = "memory-index";
158
126
  var CHUNKS_FILE = "chunks.json";
@@ -240,7 +208,7 @@ function writeVectorsFile(chunks, vectors) {
240
208
  );
241
209
  }
242
210
  const dir = memoryIndexDir();
243
- fs2.mkdirSync(dir, { recursive: true });
211
+ fs.mkdirSync(dir, { recursive: true });
244
212
  const totalBytes = VEC_HEADER_BYTES + vectors.byteLength;
245
213
  const buf = Buffer.alloc(totalBytes);
246
214
  buf.writeUInt32LE(VEC_MAGIC, 0);
@@ -252,10 +220,10 @@ function writeVectorsFile(chunks, vectors) {
252
220
  }
253
221
  function readVectorsFile(expectedCount) {
254
222
  const p = vectorsPath();
255
- if (!fs2.existsSync(p)) return null;
223
+ if (!fs.existsSync(p)) return null;
256
224
  let buf;
257
225
  try {
258
- buf = fs2.readFileSync(p);
226
+ buf = fs.readFileSync(p);
259
227
  } catch {
260
228
  return null;
261
229
  }
@@ -274,14 +242,14 @@ function readVectorsFile(expectedCount) {
274
242
  }
275
243
  function writeIndexFile(idx) {
276
244
  const dir = memoryIndexDir();
277
- fs2.mkdirSync(dir, { recursive: true });
245
+ fs.mkdirSync(dir, { recursive: true });
278
246
  atomicWriteFileSync(chunksPath(), JSON.stringify(idx, null, 2));
279
247
  }
280
248
  function readIndexFile() {
281
249
  const p = chunksPath();
282
- if (!fs2.existsSync(p)) return null;
250
+ if (!fs.existsSync(p)) return null;
283
251
  try {
284
- const raw = fs2.readFileSync(p, "utf-8");
252
+ const raw = fs.readFileSync(p, "utf-8");
285
253
  const data = JSON.parse(raw);
286
254
  if (data.version !== 1) return null;
287
255
  return data;
@@ -298,24 +266,24 @@ function loadChatIndex() {
298
266
  }
299
267
  function clearChatIndex() {
300
268
  try {
301
- if (fs2.existsSync(chunksPath())) fs2.unlinkSync(chunksPath());
269
+ if (fs.existsSync(chunksPath())) fs.unlinkSync(chunksPath());
302
270
  } catch {
303
271
  }
304
272
  try {
305
- if (fs2.existsSync(vectorsPath())) fs2.unlinkSync(vectorsPath());
273
+ if (fs.existsSync(vectorsPath())) fs.unlinkSync(vectorsPath());
306
274
  } catch {
307
275
  }
308
276
  }
309
277
  function listSessionFiles() {
310
278
  const dir = historyDir();
311
- if (!fs2.existsSync(dir)) return [];
279
+ if (!fs.existsSync(dir)) return [];
312
280
  const out = [];
313
- for (const name of fs2.readdirSync(dir)) {
281
+ for (const name of fs.readdirSync(dir)) {
314
282
  if (!name.endsWith(".json")) continue;
315
283
  const id = name.replace(/\.json$/, "");
316
284
  const p = path.join(dir, name);
317
285
  try {
318
- const st = fs2.statSync(p);
286
+ const st = fs.statSync(p);
319
287
  out.push({ id, path: p, mtime: st.mtimeMs });
320
288
  } catch {
321
289
  }
@@ -324,7 +292,7 @@ function listSessionFiles() {
324
292
  }
325
293
  function readSession(p) {
326
294
  try {
327
- const data = JSON.parse(fs2.readFileSync(p, "utf-8"));
295
+ const data = JSON.parse(fs.readFileSync(p, "utf-8"));
328
296
  if (!data.id || !Array.isArray(data.messages)) return null;
329
297
  return data;
330
298
  } catch {
@@ -467,8 +435,8 @@ function getChatIndexStatus() {
467
435
  chunksFileSizeBytes: 0
468
436
  };
469
437
  try {
470
- if (fs2.existsSync(vectorsPath())) status.vecFileSizeBytes = fs2.statSync(vectorsPath()).size;
471
- if (fs2.existsSync(chunksPath())) status.chunksFileSizeBytes = fs2.statSync(chunksPath()).size;
438
+ if (fs.existsSync(vectorsPath())) status.vecFileSizeBytes = fs.statSync(vectorsPath()).size;
439
+ if (fs.existsSync(chunksPath())) status.chunksFileSizeBytes = fs.statSync(chunksPath()).size;
472
440
  } catch {
473
441
  }
474
442
  const idx = readIndexFile();
@@ -8,7 +8,7 @@ import {
8
8
  CONFIG_FILE_NAME,
9
9
  HISTORY_DIR_NAME,
10
10
  PLUGINS_DIR_NAME
11
- } from "./chunk-UK6E2563.js";
11
+ } from "./chunk-4KMDKDAK.js";
12
12
 
13
13
  // src/config/config-manager.ts
14
14
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -3,9 +3,12 @@ import {
3
3
  computeCost,
4
4
  formatCost
5
5
  } from "./chunk-V37XOYOE.js";
6
+ import {
7
+ atomicWriteFileSync
8
+ } from "./chunk-IW3Q7AE5.js";
6
9
 
7
10
  // src/core/cost-tracker.ts
8
- import { existsSync, readFileSync, writeFileSync, renameSync } from "fs";
11
+ import { existsSync, readFileSync } from "fs";
9
12
  import { join } from "path";
10
13
  var CostTracker = class {
11
14
  filePath;
@@ -45,9 +48,7 @@ var CostTracker = class {
45
48
  // shallow copy — records are plain data
46
49
  };
47
50
  try {
48
- const tmp = this.filePath + ".tmp";
49
- writeFileSync(tmp, JSON.stringify(snapshot, null, 2), "utf-8");
50
- renameSync(tmp, this.filePath);
51
+ atomicWriteFileSync(this.filePath, JSON.stringify(snapshot, null, 2));
51
52
  this.dirty = false;
52
53
  } catch (err) {
53
54
  console.error("[cost-tracker] Failed to persist cost history:", err);
@@ -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.188";
9
+ var VERSION = "0.4.190";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -10,12 +10,11 @@ import {
10
10
  import "./chunk-HIU2SH4V.js";
11
11
  import {
12
12
  ConfigManager
13
- } from "./chunk-Q7SB3R25.js";
13
+ } from "./chunk-X4J2DZB5.js";
14
14
  import "./chunk-TZQHYZKT.js";
15
15
  import {
16
16
  VERSION
17
- } from "./chunk-UK6E2563.js";
18
- import "./chunk-PDX44BCA.js";
17
+ } from "./chunk-4KMDKDAK.js";
19
18
 
20
19
  // src/cli/ci.ts
21
20
  import { execFileSync, execSync } from "child_process";
@@ -76,7 +75,7 @@ function countSeverity(md) {
76
75
  async function runOnePrompt(registry, providerId, modelId, prompt) {
77
76
  const provider = registry.get(providerId);
78
77
  const resp = await provider.chat({
79
- messages: [{ role: "user", content: prompt }],
78
+ messages: [{ role: "user", content: prompt, timestamp: /* @__PURE__ */ new Date() }],
80
79
  model: modelId,
81
80
  stream: false,
82
81
  temperature: 0.3,
@@ -150,9 +149,16 @@ async function runCi(opts) {
150
149
  const { diff: trimmedDiff, truncated } = truncateDiff(diff, maxDiff);
151
150
  const gitCtx = buildGitContextStr(opts);
152
151
  const config = new ConfigManager();
153
- await config.load();
154
- const registry = new ProviderRegistry(config);
155
- await registry.initialize();
152
+ const registry = new ProviderRegistry();
153
+ await registry.initialize(
154
+ (id) => config.getApiKey(id),
155
+ (id) => ({
156
+ baseUrl: config.get("customBaseUrls")[id],
157
+ timeout: config.get("timeouts")[id],
158
+ proxy: config.get("proxy")
159
+ }),
160
+ config.get("customProviders")
161
+ );
156
162
  const providerId = opts.provider ?? config.getDefaultProvider();
157
163
  if (!registry.has(providerId)) {
158
164
  return {
@@ -36,8 +36,7 @@ import {
36
36
  TEST_TIMEOUT,
37
37
  VERSION,
38
38
  buildUserIdentityPrompt
39
- } from "./chunk-UK6E2563.js";
40
- import "./chunk-PDX44BCA.js";
39
+ } from "./chunk-4KMDKDAK.js";
41
40
  export {
42
41
  AGENTIC_BEHAVIOR_GUIDELINE,
43
42
  APP_NAME,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getConfigDirUsage,
4
4
  listRecentCrashes
5
- } from "./chunk-MUQZOUV5.js";
5
+ } from "./chunk-UVW3WLSV.js";
6
6
  import {
7
7
  ProviderRegistry
8
8
  } from "./chunk-IQ7JE43O.js";
@@ -11,18 +11,18 @@ import {
11
11
  getTopFailingTools,
12
12
  getTopUsedTools,
13
13
  resetStats
14
- } from "./chunk-DFQSQQEU.js";
14
+ } from "./chunk-KHS7RSGR.js";
15
15
  import "./chunk-HIU2SH4V.js";
16
16
  import {
17
17
  ConfigManager
18
- } from "./chunk-Q7SB3R25.js";
18
+ } from "./chunk-X4J2DZB5.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-UK6E2563.js";
25
- import "./chunk-PDX44BCA.js";
24
+ } from "./chunk-4KMDKDAK.js";
25
+ import "./chunk-IW3Q7AE5.js";
26
26
 
27
27
  // src/diagnostics/doctor-cli.ts
28
28
  import { existsSync, statSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SKET65WZ.js";
4
4
  import {
5
5
  indexProject
6
- } from "./chunk-SEFOKYYP.js";
6
+ } from "./chunk-SQB66GP6.js";
7
7
  import {
8
8
  AGENTIC_BEHAVIOR_GUIDELINE,
9
9
  APP_NAME,
@@ -36,22 +36,24 @@ import {
36
36
  VERSION,
37
37
  buildUserIdentityPrompt,
38
38
  runTestsTool
39
- } from "./chunk-ODAAPNSL.js";
39
+ } from "./chunk-ZN5IEPSS.js";
40
40
  import {
41
41
  hasSemanticIndex,
42
42
  semanticSearch
43
- } from "./chunk-YKVFZLSI.js";
43
+ } from "./chunk-AEAYUKSY.js";
44
44
  import {
45
45
  loadIndex
46
- } from "./chunk-DQ2OHJNF.js";
47
- import "./chunk-D6U75FHP.js";
46
+ } from "./chunk-RWM2GFRC.js";
47
+ import "./chunk-IEQAE3QG.js";
48
48
  import {
49
49
  loadChatIndex,
50
50
  redactJson,
51
51
  searchChatMemory
52
- } from "./chunk-KIGVJVX4.js";
52
+ } from "./chunk-W7UKO3PS.js";
53
53
  import "./chunk-JV5N65KN.js";
54
- import "./chunk-3RG5ZIWI.js";
54
+ import {
55
+ atomicWriteFileSync
56
+ } from "./chunk-6BUTA5VW.js";
55
57
 
56
58
  // src/web/server.ts
57
59
  import express from "express";
@@ -3765,7 +3767,7 @@ var ProviderRegistry = class {
3765
3767
  };
3766
3768
 
3767
3769
  // src/session/session-manager.ts
3768
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, unlinkSync, renameSync, openSync, readSync, closeSync } from "fs";
3770
+ import { readFileSync as readFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, unlinkSync, openSync, readSync, closeSync } from "fs";
3769
3771
  import { join as join2 } from "path";
3770
3772
  import { v4 as uuidv4 } from "uuid";
3771
3773
 
@@ -4351,9 +4353,7 @@ var SessionManager = class {
4351
4353
  const opts = this.redactOptionsForSave();
4352
4354
  const { value: payload, hits } = redactJson(raw, opts);
4353
4355
  this.lastRedactionHits = hits.length;
4354
- const tmpPath = filePath + ".tmp";
4355
- writeFileSync2(tmpPath, JSON.stringify(payload, null, 2), "utf-8");
4356
- renameSync(tmpPath, filePath);
4356
+ atomicWriteFileSync(filePath, JSON.stringify(payload, null, 2));
4357
4357
  }
4358
4358
  loadSession(id) {
4359
4359
  const filePath = join2(this.historyDir, `${id}.json`);
@@ -4541,7 +4541,7 @@ import { platform } from "os";
4541
4541
  import { resolve } from "path";
4542
4542
 
4543
4543
  // src/tools/undo-stack.ts
4544
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, rmdirSync, existsSync as existsSync3 } from "fs";
4544
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2, rmdirSync, existsSync as existsSync3 } from "fs";
4545
4545
  var MAX_UNDO_DEPTH = 20;
4546
4546
  var UndoStack = class {
4547
4547
  stack = [];
@@ -4624,7 +4624,7 @@ var UndoStack = class {
4624
4624
  return { entry, result: `Deleted newly created file: ${entry.filePath}` };
4625
4625
  }
4626
4626
  } else {
4627
- writeFileSync3(entry.filePath, entry.previousContent, "utf-8");
4627
+ writeFileSync2(entry.filePath, entry.previousContent, "utf-8");
4628
4628
  const lines = entry.previousContent.split("\n").length;
4629
4629
  return {
4630
4630
  entry,
@@ -5474,7 +5474,7 @@ ${content}`;
5474
5474
  };
5475
5475
 
5476
5476
  // src/tools/builtin/write-file.ts
5477
- import { writeFileSync as writeFileSync5, appendFileSync, mkdirSync as mkdirSync4 } from "fs";
5477
+ import { writeFileSync as writeFileSync3, appendFileSync, mkdirSync as mkdirSync4 } from "fs";
5478
5478
  import { dirname as dirname3 } from "path";
5479
5479
 
5480
5480
  // src/tools/executor.ts
@@ -5876,7 +5876,7 @@ var theme = new Proxy(DARK_THEME, {
5876
5876
  });
5877
5877
 
5878
5878
  // src/diagnostics/tool-stats.ts
5879
- import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, renameSync as renameSync2 } from "fs";
5879
+ import { existsSync as existsSync6, readFileSync as readFileSync5, mkdirSync as mkdirSync3 } from "fs";
5880
5880
  import { join as join3, dirname as dirname2 } from "path";
5881
5881
  import { homedir as homedir3 } from "os";
5882
5882
  var STATS_FILE_NAME = "tool-stats.json";
@@ -5955,9 +5955,7 @@ function flush() {
5955
5955
  const path3 = statsFilePath();
5956
5956
  try {
5957
5957
  mkdirSync3(dirname2(path3), { recursive: true });
5958
- const tmp = path3 + ".tmp";
5959
- writeFileSync4(tmp, JSON.stringify(state, null, 2), "utf-8");
5960
- renameSync2(tmp, path3);
5958
+ atomicWriteFileSync(path3, JSON.stringify(state, null, 2));
5961
5959
  dirty = false;
5962
5960
  pendingWrites = 0;
5963
5961
  } catch {
@@ -6613,13 +6611,13 @@ Do NOT split a long document into many write_file(append=true) calls. That patte
6613
6611
  if (appendMode) {
6614
6612
  appendFileSync(filePath, content, encoding);
6615
6613
  } else {
6616
- writeFileSync5(filePath, content, encoding);
6614
+ writeFileSync3(filePath, content, encoding);
6617
6615
  }
6618
6616
  const lines = content.split("\n").length;
6619
6617
  const mode = appendMode ? "appended" : "written";
6620
6618
  void (async () => {
6621
6619
  try {
6622
- const { updateFile } = await import("./indexer-ISSNIFQY.js");
6620
+ const { updateFile } = await import("./indexer-BMYUUDLH.js");
6623
6621
  await updateFile(process.cwd(), filePath);
6624
6622
  } catch {
6625
6623
  }
@@ -6629,7 +6627,7 @@ Do NOT split a long document into many write_file(append=true) calls. That patte
6629
6627
  };
6630
6628
 
6631
6629
  // src/tools/builtin/edit-file.ts
6632
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, existsSync as existsSync8 } from "fs";
6630
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, existsSync as existsSync8 } from "fs";
6633
6631
 
6634
6632
  // src/tools/builtin/patch-apply.ts
6635
6633
  function parseUnifiedDiff(patch) {
@@ -7028,7 +7026,7 @@ Note: Path can be absolute or relative to cwd.`,
7028
7026
  if (res.ok && res.appliedCount > 0 && res.content !== void 0) {
7029
7027
  undoStack.push(filePath, `edit_file (patch ${res.appliedCount}/${hunks.length}): ${filePath}`);
7030
7028
  fileCheckpoints.snapshot(filePath, ToolExecutor.currentMessageIndex);
7031
- writeFileSync6(filePath, res.content, encoding);
7029
+ writeFileSync4(filePath, res.content, encoding);
7032
7030
  }
7033
7031
  return lines.join("\n");
7034
7032
  }
@@ -7062,7 +7060,7 @@ Note: Path can be absolute or relative to cwd.`,
7062
7060
  if (writeChanges) {
7063
7061
  undoStack.push(filePath, `edit_file (batch ${appliedCount}/${edits.length}): ${filePath}`);
7064
7062
  fileCheckpoints.snapshot(filePath, ToolExecutor.currentMessageIndex);
7065
- writeFileSync6(filePath, working, encoding);
7063
+ writeFileSync4(filePath, working, encoding);
7066
7064
  }
7067
7065
  const lines = [];
7068
7066
  if (anyFailed && stopOnError) {
@@ -7100,7 +7098,7 @@ Please read the file first and use exact text.`;
7100
7098
  const label = res.info?.mode === "ignore_whitespace" ? "edit_file (ws-replace)" : res.info?.mode === "replace_all" ? "edit_file (replace_all)" : "edit_file (replace)";
7101
7099
  undoStack.push(filePath, `${label}: ${filePath}`);
7102
7100
  fileCheckpoints.snapshot(filePath, ToolExecutor.currentMessageIndex);
7103
- writeFileSync6(filePath, res.content, encoding);
7101
+ writeFileSync4(filePath, res.content, encoding);
7104
7102
  if (res.info?.mode === "replace_all") {
7105
7103
  return `Successfully edited ${filePath}${modeLabel}
7106
7104
  Replaced: ${res.info.replacedCount} occurrence(s) of ${truncatePreview(oldStr)}
@@ -7124,7 +7122,7 @@ Please read the file first and use exact text.`;
7124
7122
  undoStack.push(filePath, `edit_file (insert): ${filePath}`);
7125
7123
  fileCheckpoints.snapshot(filePath, ToolExecutor.currentMessageIndex);
7126
7124
  lines.splice(afterLine, 0, content);
7127
- writeFileSync6(filePath, lines.join("\n"), encoding);
7125
+ writeFileSync4(filePath, lines.join("\n"), encoding);
7128
7126
  return `Successfully inserted ${content.split("\n").length} line(s) after line ${afterLine} in ${filePath}`;
7129
7127
  }
7130
7128
  if (args["delete_from_line"] !== void 0) {
@@ -7140,7 +7138,7 @@ Please read the file first and use exact text.`;
7140
7138
  undoStack.push(filePath, `edit_file (delete): ${filePath}`);
7141
7139
  fileCheckpoints.snapshot(filePath, ToolExecutor.currentMessageIndex);
7142
7140
  const deleted = lines.splice(fromLine - 1, toLine - fromLine + 1);
7143
- writeFileSync6(filePath, lines.join("\n"), encoding);
7141
+ writeFileSync4(filePath, lines.join("\n"), encoding);
7144
7142
  return `Successfully deleted lines ${fromLine}-${toLine} (${deleted.length} lines) from ${filePath}`;
7145
7143
  }
7146
7144
  throw new ToolError(
@@ -7985,6 +7983,8 @@ var webFetchTool = {
7985
7983
  redirect: "manual",
7986
7984
  // 手动控制重定向
7987
7985
  dispatcher
7986
+ // dual undici-types:`dispatcher` 字段在 undici 与 @types/node 内置的
7987
+ // undici-types 两份 RequestInit 间判不兼容,localized 转换。
7988
7988
  });
7989
7989
  if (r.status >= 300 && r.status < 400) {
7990
7990
  if (hop >= MAX_REDIRECTS) {
@@ -8329,7 +8329,7 @@ ${preamble}`;
8329
8329
  }
8330
8330
 
8331
8331
  // src/tools/builtin/save-last-response.ts
8332
- import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync5 } from "fs";
8332
+ import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
8333
8333
  import { dirname as dirname4 } from "path";
8334
8334
  var lastResponseStore = { content: "" };
8335
8335
  var saveLastResponseTool = {
@@ -8370,7 +8370,7 @@ Any of these triggers means use save_last_response, NOT write_file:
8370
8370
  }
8371
8371
  undoStack.push(filePath, `save_last_response: ${filePath}`);
8372
8372
  mkdirSync5(dirname4(filePath), { recursive: true });
8373
- writeFileSync7(filePath, content, "utf-8");
8373
+ writeFileSync5(filePath, content, "utf-8");
8374
8374
  const lines = content.split("\n").length;
8375
8375
  return `File saved: ${filePath} (${lines} lines, ${content.length} bytes)`;
8376
8376
  }
@@ -11174,7 +11174,7 @@ import { existsSync as existsSync19, readFileSync as readFileSync13 } from "fs";
11174
11174
  import { join as join12 } from "path";
11175
11175
 
11176
11176
  // src/repl/dev-state.ts
11177
- import { existsSync as existsSync18, readFileSync as readFileSync12, writeFileSync as writeFileSync8, unlinkSync as unlinkSync3, mkdirSync as mkdirSync9 } from "fs";
11177
+ import { existsSync as existsSync18, readFileSync as readFileSync12, writeFileSync as writeFileSync6, unlinkSync as unlinkSync3, mkdirSync as mkdirSync9 } from "fs";
11178
11178
  import { join as join11 } from "path";
11179
11179
  import { homedir as homedir6 } from "os";
11180
11180
  function getDevStatePath() {
@@ -11448,7 +11448,7 @@ function autoTrimSessionIfNeeded(session, sizeLimit = SESSION_SIZE_LIMIT) {
11448
11448
  }
11449
11449
 
11450
11450
  // src/web/session-handler.ts
11451
- import { existsSync as existsSync21, readFileSync as readFileSync14, appendFileSync as appendFileSync3, writeFileSync as writeFileSync9, mkdirSync as mkdirSync10, readdirSync as readdirSync9, statSync as statSync8, createWriteStream, unlinkSync as unlinkSync4 } from "fs";
11451
+ import { existsSync as existsSync21, readFileSync as readFileSync14, appendFileSync as appendFileSync3, writeFileSync as writeFileSync7, mkdirSync as mkdirSync10, readdirSync as readdirSync9, statSync as statSync8, createWriteStream, unlinkSync as unlinkSync4 } from "fs";
11452
11452
  import { join as join15, resolve as resolve5, dirname as dirname5 } from "path";
11453
11453
  import { execSync as execSync3 } from "child_process";
11454
11454
 
@@ -12984,9 +12984,9 @@ This fresh stream has NO tools. Produce ONLY the document body: start with a mar
12984
12984
  this.send({
12985
12985
  type: "tool_call_result",
12986
12986
  callId: call.id,
12987
- result: summary,
12988
- isError: true,
12989
- endTime: Date.now()
12987
+ toolName: call.name,
12988
+ content: summary,
12989
+ isError: true
12990
12990
  });
12991
12991
  return { content: "", summary, isError: true };
12992
12992
  }
@@ -12994,7 +12994,7 @@ This fresh stream has NO tools. Produce ONLY the document body: start with a mar
12994
12994
  if (pseudoMatch) {
12995
12995
  const cleaned = stripPseudoToolCalls(fullContent);
12996
12996
  if (looksLikeDocumentBody(cleaned)) {
12997
- writeFileSync9(saveToFile, cleaned, "utf-8");
12997
+ writeFileSync7(saveToFile, cleaned, "utf-8");
12998
12998
  fullContent = cleaned;
12999
12999
  const lines = cleaned.split("\n").length;
13000
13000
  const bytes = Buffer.byteLength(cleaned, "utf-8");
@@ -13838,9 +13838,9 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
13838
13838
  case "index": {
13839
13839
  const sub = (args[0] ?? "status").toLowerCase();
13840
13840
  const root = process.cwd();
13841
- const { loadIndex: loadIndex2, clearIndex } = await import("./store-A3TZM6PS.js");
13842
- const { indexProject: indexProject2 } = await import("./indexer-ISSNIFQY.js");
13843
- const { loadVectorStore, clearVectorStore } = await import("./vector-store-PLDSXF3V.js");
13841
+ const { loadIndex: loadIndex2, clearIndex } = await import("./store-VO37H6LS.js");
13842
+ const { indexProject: indexProject2 } = await import("./indexer-BMYUUDLH.js");
13843
+ const { loadVectorStore, clearVectorStore } = await import("./vector-store-JBAE6PS4.js");
13844
13844
  if (sub === "status") {
13845
13845
  const idx = loadIndex2(root);
13846
13846
  const vec = loadVectorStore(root);
@@ -13889,7 +13889,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
13889
13889
  message: `Building semantic index for ${idx.symbolCount} symbols\u2026 (first run downloads ~117 MB model)`
13890
13890
  });
13891
13891
  try {
13892
- const { rebuildSemanticIndex } = await import("./semantic-GJJWTI3A.js");
13892
+ const { rebuildSemanticIndex } = await import("./semantic-FF6DDJI6.js");
13893
13893
  const stats = await rebuildSemanticIndex(root);
13894
13894
  const first = stats.modelFirstLoadMs ? ` (model load+first batch ${stats.modelFirstLoadMs}ms)` : "";
13895
13895
  this.send({
@@ -14037,7 +14037,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
14037
14037
  if (rewindSub === "list" || !rewindSub) {
14038
14038
  const lines = [`Conversation messages (${session.messages.length} total):
14039
14039
  `];
14040
- const cpIndices = (await import("./file-checkpoint-UHSMHCRU.js")).fileCheckpoints.getMessageIndices();
14040
+ const cpIndices = (await import("./file-checkpoint-CGH6OJVI.js")).fileCheckpoints.getMessageIndices();
14041
14041
  for (let i = 0; i < session.messages.length; i++) {
14042
14042
  const m = session.messages[i];
14043
14043
  const text = getContentText(m.content).replace(/\n/g, " ").slice(0, 60);
@@ -14053,7 +14053,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
14053
14053
  this.send({ type: "error", message: `Invalid message number: ${rewindSub}. Range: 1-${session.messages.length}` });
14054
14054
  break;
14055
14055
  }
14056
- const { fileCheckpoints: fc } = await import("./file-checkpoint-UHSMHCRU.js");
14056
+ const { fileCheckpoints: fc } = await import("./file-checkpoint-CGH6OJVI.js");
14057
14057
  const rewindRemoved = session.messages.length - rewindN;
14058
14058
  const rewindResult = fc.restoreToMessageIndex(rewindN);
14059
14059
  session.messages = session.messages.slice(0, rewindN);
@@ -14076,7 +14076,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
14076
14076
  case "test": {
14077
14077
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
14078
14078
  try {
14079
- const { executeTests } = await import("./run-tests-IJYP6BMT.js");
14079
+ const { executeTests } = await import("./run-tests-OTZE5CEN.js");
14080
14080
  const argStr = args.join(" ").trim();
14081
14081
  let testArgs = {};
14082
14082
  if (argStr) {
@@ -14105,7 +14105,7 @@ Use /init --force to overwrite.` });
14105
14105
  const projectInfo = this.scanProject(cwd);
14106
14106
  const prompt = this.buildInitPrompt(projectInfo, cwd);
14107
14107
  const content = await this.chatOnce(prompt, { temperature: 0.3, maxTokens: 4096 });
14108
- writeFileSync9(targetPath, content, "utf-8");
14108
+ writeFileSync7(targetPath, content, "utf-8");
14109
14109
  this.send({ type: "info", message: `\u2713 Generated: ${targetPath} (${content.length} chars)
14110
14110
  Use /context reload to load it.` });
14111
14111
  } catch (err) {
@@ -14584,7 +14584,7 @@ Add .md files to create commands.` });
14584
14584
  const configDir = this.config.getConfigDir();
14585
14585
  const memPath = join15(configDir, MEMORY_FILE_NAME);
14586
14586
  try {
14587
- writeFileSync9(memPath, "", "utf-8");
14587
+ writeFileSync7(memPath, "", "utf-8");
14588
14588
  this.send({ type: "info", message: "\u{1F5D1}\uFE0F Persistent memory cleared." });
14589
14589
  } catch (err) {
14590
14590
  this.send({ type: "error", message: `Failed to clear memory: ${err.message}` });
@@ -14600,7 +14600,7 @@ Add .md files to create commands.` });
14600
14600
  return;
14601
14601
  }
14602
14602
  try {
14603
- const { searchChatMemory: searchChatMemory2, loadChatIndex: loadChatIndex2 } = await import("./chat-index-WDMVP7BN.js");
14603
+ const { searchChatMemory: searchChatMemory2, loadChatIndex: loadChatIndex2 } = await import("./chat-index-UBCWHBLR.js");
14604
14604
  const loaded = loadChatIndex2();
14605
14605
  if (!loaded || loaded.idx.chunks.length === 0) {
14606
14606
  this.send({ type: "memory_hits", query: q, hits: [], indexMissing: true });
@@ -14636,7 +14636,7 @@ Add .md files to create commands.` });
14636
14636
  }
14637
14637
  async handleMemoryStatus() {
14638
14638
  try {
14639
- const { getChatIndexStatus } = await import("./chat-index-WDMVP7BN.js");
14639
+ const { getChatIndexStatus } = await import("./chat-index-UBCWHBLR.js");
14640
14640
  const s = getChatIndexStatus();
14641
14641
  this.send({
14642
14642
  type: "memory_status",
@@ -14661,7 +14661,7 @@ Add .md files to create commands.` });
14661
14661
  type: "info",
14662
14662
  message: full ? "\u{1F9E0} Rebuilding chat memory index (this may take a while on first run \u2014 ~117 MB embedder)." : "\u{1F9E0} Refreshing chat memory index (incremental)\u2026"
14663
14663
  });
14664
- const { buildChatIndex } = await import("./chat-index-WDMVP7BN.js");
14664
+ const { buildChatIndex } = await import("./chat-index-UBCWHBLR.js");
14665
14665
  const stats = await buildChatIndex({
14666
14666
  full,
14667
14667
  onProgress: (p) => {
@@ -15060,7 +15060,7 @@ async function setupProxy(configProxy) {
15060
15060
  }
15061
15061
 
15062
15062
  // src/web/auth.ts
15063
- import { existsSync as existsSync22, readFileSync as readFileSync15, writeFileSync as writeFileSync10, mkdirSync as mkdirSync11, readdirSync as readdirSync10, copyFileSync, renameSync as renameSync3, unlinkSync as unlinkSync5 } from "fs";
15063
+ import { existsSync as existsSync22, readFileSync as readFileSync15, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11, readdirSync as readdirSync10, copyFileSync } from "fs";
15064
15064
  import { join as join16 } from "path";
15065
15065
  import { createHmac, randomBytes, timingSafeEqual, pbkdf2Sync } from "crypto";
15066
15066
  var USERS_FILE = "users.json";
@@ -15262,7 +15262,7 @@ var AuthManager = class {
15262
15262
  if (existsSync22(globalConfig)) {
15263
15263
  try {
15264
15264
  const content = readFileSync15(globalConfig, "utf-8");
15265
- writeFileSync10(join16(userDir, "config.json"), content, "utf-8");
15265
+ writeFileSync8(join16(userDir, "config.json"), content, "utf-8");
15266
15266
  } catch {
15267
15267
  }
15268
15268
  }
@@ -15270,7 +15270,7 @@ var AuthManager = class {
15270
15270
  if (existsSync22(globalMemory)) {
15271
15271
  try {
15272
15272
  const content = readFileSync15(globalMemory, "utf-8");
15273
- writeFileSync10(join16(userDir, "memory.md"), content, "utf-8");
15273
+ writeFileSync8(join16(userDir, "memory.md"), content, "utf-8");
15274
15274
  } catch {
15275
15275
  }
15276
15276
  }
@@ -15311,17 +15311,7 @@ var AuthManager = class {
15311
15311
  }
15312
15312
  saveDB(db) {
15313
15313
  mkdirSync11(this.baseDir, { recursive: true });
15314
- const tmp = `${this.usersFile}.tmp`;
15315
- try {
15316
- writeFileSync10(tmp, JSON.stringify(db, null, 2), "utf-8");
15317
- renameSync3(tmp, this.usersFile);
15318
- } catch (err) {
15319
- try {
15320
- unlinkSync5(tmp);
15321
- } catch {
15322
- }
15323
- throw err;
15324
- }
15314
+ atomicWriteFileSync(this.usersFile, JSON.stringify(db, null, 2));
15325
15315
  }
15326
15316
  /** Legacy hash — kept only for migrating old users (v0.2.x) */
15327
15317
  hashPasswordLegacy(password, salt) {
@@ -15394,7 +15384,7 @@ async function startWebServer(options = {}) {
15394
15384
  const projectMcpResolved = mcpEnabled ? resolveProjectMcpPath() : null;
15395
15385
  let projectMcpServers = {};
15396
15386
  if (projectMcpResolved) {
15397
- const { checkTrust } = await import("./project-trust-EBGHD7LE.js");
15387
+ const { checkTrust } = await import("./project-trust-MUG325AW.js");
15398
15388
  const verdict = checkTrust(config.getConfigDir(), projectMcpResolved);
15399
15389
  if (verdict.trusted) {
15400
15390
  projectMcpServers = loadProjectMcpConfig() ?? {};
@@ -15618,7 +15608,7 @@ async function startWebServer(options = {}) {
15618
15608
  }
15619
15609
  });
15620
15610
  app.get("/api/sessions/:id/replay", requireAuth, (req, res) => {
15621
- const id = req.params.id;
15611
+ const id = String(req.params.id);
15622
15612
  if (!/^[a-f0-9-]{36}$/i.test(id)) {
15623
15613
  res.status(400).json({ error: "Invalid session id" });
15624
15614
  return;