jinzd-ai-cli 0.4.186 → 0.4.188

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/dist/{batch-IPALJR2D.js → batch-D6K2KHJK.js} +2 -2
  2. package/dist/{chat-index-2I7ZHRE5.js → chat-index-JXTYDRCY.js} +1 -1
  3. package/dist/{chat-index-BE4TPLFH.js → chat-index-WDMVP7BN.js} +1 -1
  4. package/dist/{chunk-MM3F43H6.js → chunk-4UZE4ADL.js} +54 -23
  5. package/dist/{chunk-V7NTQ6UB.js → chunk-DFQSQQEU.js} +1 -1
  6. package/dist/{chunk-RADH6ECW.js → chunk-IQ7JE43O.js} +1442 -1318
  7. package/dist/{chunk-JBTVDYJM.js → chunk-J3XSJCO5.js} +4 -4
  8. package/dist/{chunk-T5VKNPLD.js → chunk-KIGVJVX4.js} +52 -23
  9. package/dist/{chunk-ZLWYP3RB.js → chunk-MUQZOUV5.js} +1 -1
  10. package/dist/{chunk-2CLMIRKL.js → chunk-NRSAAMIF.js} +1 -1
  11. package/dist/{chunk-7HMX2MTY.js → chunk-ODAAPNSL.js} +1 -1
  12. package/dist/{chunk-KNGDSMMF.js → chunk-Q7SB3R25.js} +1 -1
  13. package/dist/{chunk-MIXN7VBY.js → chunk-UK6E2563.js} +1 -1
  14. package/dist/{chunk-OFP5BE7H.js → chunk-VPTRE7IW.js} +2 -2
  15. package/dist/{ci-FYXVC5MX.js → ci-42ZBP2SY.js} +3 -3
  16. package/dist/{constants-RB5H7L34.js → constants-NCWVAAI7.js} +1 -1
  17. package/dist/{doctor-cli-ZWLHBS43.js → doctor-cli-R3SWTL5Z.js} +5 -5
  18. package/dist/electron-server.js +1341 -1131
  19. package/dist/{hub-X4OBH5A3.js → hub-3ZGIM2FN.js} +1 -1
  20. package/dist/index.js +480 -584
  21. package/dist/{run-tests-625NA546.js → run-tests-IJYP6BMT.js} +1 -1
  22. package/dist/{run-tests-CRVIUT4O.js → run-tests-NS3SPH6S.js} +2 -2
  23. package/dist/{server-Q3A737OP.js → server-SVTSJ3PK.js} +5 -5
  24. package/dist/{server-O6ZMNWNS.js → server-TZRMRT3O.js} +208 -260
  25. package/dist/{task-orchestrator-TLUGDQMO.js → task-orchestrator-GMJ5PLVV.js} +5 -5
  26. package/dist/{usage-B4OU5CDJ.js → usage-IYMFSHDX.js} +2 -2
  27. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConfigManager
4
- } from "./chunk-KNGDSMMF.js";
4
+ } from "./chunk-Q7SB3R25.js";
5
5
  import "./chunk-TZQHYZKT.js";
6
- import "./chunk-MIXN7VBY.js";
6
+ import "./chunk-UK6E2563.js";
7
7
  import "./chunk-PDX44BCA.js";
8
8
 
9
9
  // src/cli/batch.ts
@@ -6,7 +6,7 @@ import {
6
6
  getChatIndexStatus,
7
7
  loadChatIndex,
8
8
  searchChatMemory
9
- } from "./chunk-MM3F43H6.js";
9
+ } from "./chunk-4UZE4ADL.js";
10
10
  import "./chunk-KHYD3WXE.js";
11
11
  import "./chunk-SLSWPBK3.js";
12
12
  import "./chunk-PDX44BCA.js";
@@ -5,7 +5,7 @@ import {
5
5
  getChatIndexStatus,
6
6
  loadChatIndex,
7
7
  searchChatMemory
8
- } from "./chunk-T5VKNPLD.js";
8
+ } from "./chunk-KIGVJVX4.js";
9
9
  import "./chunk-JV5N65KN.js";
10
10
  import "./chunk-3RG5ZIWI.js";
11
11
  export {
@@ -9,10 +9,47 @@ import {
9
9
  } from "./chunk-SLSWPBK3.js";
10
10
 
11
11
  // src/memory/chat-index.ts
12
- import fs from "fs";
12
+ import fs2 from "fs";
13
13
  import path from "path";
14
14
  import os from "os";
15
15
  import crypto from "crypto";
16
+
17
+ // src/core/atomic-write.ts
18
+ import fs from "fs";
19
+ var RETRYABLE_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
20
+ var MAX_RENAME_RETRIES = 10;
21
+ function sleepSync(ms) {
22
+ const sab = new Int32Array(new SharedArrayBuffer(4));
23
+ Atomics.wait(sab, 0, 0, ms);
24
+ }
25
+ function atomicWriteFileSync(target, data) {
26
+ const tmp = `${target}.tmp`;
27
+ fs.writeFileSync(tmp, data);
28
+ for (let attempt = 0; ; attempt++) {
29
+ try {
30
+ fs.renameSync(tmp, target);
31
+ return;
32
+ } catch (err) {
33
+ const code = err.code;
34
+ if (attempt < MAX_RENAME_RETRIES && code && RETRYABLE_CODES.has(code)) {
35
+ sleepSync(5 * (attempt + 1));
36
+ continue;
37
+ }
38
+ try {
39
+ fs.writeFileSync(target, data);
40
+ try {
41
+ fs.unlinkSync(tmp);
42
+ } catch {
43
+ }
44
+ return;
45
+ } catch {
46
+ throw err;
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ // src/memory/chat-index.ts
16
53
  var MEMORY_DIR_NAME = "memory-index";
17
54
  var CHUNKS_FILE = "chunks.json";
18
55
  var VECTORS_FILE = "vectors.vec";
@@ -99,7 +136,7 @@ function writeVectorsFile(chunks, vectors) {
99
136
  );
100
137
  }
101
138
  const dir = memoryIndexDir();
102
- fs.mkdirSync(dir, { recursive: true });
139
+ fs2.mkdirSync(dir, { recursive: true });
103
140
  const totalBytes = VEC_HEADER_BYTES + vectors.byteLength;
104
141
  const buf = Buffer.alloc(totalBytes);
105
142
  buf.writeUInt32LE(VEC_MAGIC, 0);
@@ -107,17 +144,14 @@ function writeVectorsFile(chunks, vectors) {
107
144
  buf.writeUInt32LE(chunks.length, 8);
108
145
  buf.writeUInt32LE(EMBEDDING_DIM, 12);
109
146
  Buffer.from(vectors.buffer, vectors.byteOffset, vectors.byteLength).copy(buf, VEC_HEADER_BYTES);
110
- const target = vectorsPath();
111
- const tmp = `${target}.tmp`;
112
- fs.writeFileSync(tmp, buf);
113
- fs.renameSync(tmp, target);
147
+ atomicWriteFileSync(vectorsPath(), buf);
114
148
  }
115
149
  function readVectorsFile(expectedCount) {
116
150
  const p = vectorsPath();
117
- if (!fs.existsSync(p)) return null;
151
+ if (!fs2.existsSync(p)) return null;
118
152
  let buf;
119
153
  try {
120
- buf = fs.readFileSync(p);
154
+ buf = fs2.readFileSync(p);
121
155
  } catch {
122
156
  return null;
123
157
  }
@@ -136,17 +170,14 @@ function readVectorsFile(expectedCount) {
136
170
  }
137
171
  function writeIndexFile(idx) {
138
172
  const dir = memoryIndexDir();
139
- fs.mkdirSync(dir, { recursive: true });
140
- const target = chunksPath();
141
- const tmp = `${target}.tmp`;
142
- fs.writeFileSync(tmp, JSON.stringify(idx, null, 2), "utf-8");
143
- fs.renameSync(tmp, target);
173
+ fs2.mkdirSync(dir, { recursive: true });
174
+ atomicWriteFileSync(chunksPath(), JSON.stringify(idx, null, 2));
144
175
  }
145
176
  function readIndexFile() {
146
177
  const p = chunksPath();
147
- if (!fs.existsSync(p)) return null;
178
+ if (!fs2.existsSync(p)) return null;
148
179
  try {
149
- const raw = fs.readFileSync(p, "utf-8");
180
+ const raw = fs2.readFileSync(p, "utf-8");
150
181
  const data = JSON.parse(raw);
151
182
  if (data.version !== 1) return null;
152
183
  return data;
@@ -163,24 +194,24 @@ function loadChatIndex() {
163
194
  }
164
195
  function clearChatIndex() {
165
196
  try {
166
- if (fs.existsSync(chunksPath())) fs.unlinkSync(chunksPath());
197
+ if (fs2.existsSync(chunksPath())) fs2.unlinkSync(chunksPath());
167
198
  } catch {
168
199
  }
169
200
  try {
170
- if (fs.existsSync(vectorsPath())) fs.unlinkSync(vectorsPath());
201
+ if (fs2.existsSync(vectorsPath())) fs2.unlinkSync(vectorsPath());
171
202
  } catch {
172
203
  }
173
204
  }
174
205
  function listSessionFiles() {
175
206
  const dir = historyDir();
176
- if (!fs.existsSync(dir)) return [];
207
+ if (!fs2.existsSync(dir)) return [];
177
208
  const out = [];
178
- for (const name of fs.readdirSync(dir)) {
209
+ for (const name of fs2.readdirSync(dir)) {
179
210
  if (!name.endsWith(".json")) continue;
180
211
  const id = name.replace(/\.json$/, "");
181
212
  const p = path.join(dir, name);
182
213
  try {
183
- const st = fs.statSync(p);
214
+ const st = fs2.statSync(p);
184
215
  out.push({ id, path: p, mtime: st.mtimeMs });
185
216
  } catch {
186
217
  }
@@ -189,7 +220,7 @@ function listSessionFiles() {
189
220
  }
190
221
  function readSession(p) {
191
222
  try {
192
- const data = JSON.parse(fs.readFileSync(p, "utf-8"));
223
+ const data = JSON.parse(fs2.readFileSync(p, "utf-8"));
193
224
  if (!data.id || !Array.isArray(data.messages)) return null;
194
225
  return data;
195
226
  } catch {
@@ -332,8 +363,8 @@ function getChatIndexStatus() {
332
363
  chunksFileSizeBytes: 0
333
364
  };
334
365
  try {
335
- if (fs.existsSync(vectorsPath())) status.vecFileSizeBytes = fs.statSync(vectorsPath()).size;
336
- if (fs.existsSync(chunksPath())) status.chunksFileSizeBytes = fs.statSync(chunksPath()).size;
366
+ if (fs2.existsSync(vectorsPath())) status.vecFileSizeBytes = fs2.statSync(vectorsPath()).size;
367
+ if (fs2.existsSync(chunksPath())) status.chunksFileSizeBytes = fs2.statSync(chunksPath()).size;
337
368
  } catch {
338
369
  }
339
370
  const idx = readIndexFile();
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR_NAME
4
- } from "./chunk-MIXN7VBY.js";
4
+ } from "./chunk-UK6E2563.js";
5
5
 
6
6
  // src/diagnostics/tool-stats.ts
7
7
  import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from "fs";