jinzd-ai-cli 0.4.65 → 0.4.66

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.
@@ -8,7 +8,7 @@ import {
8
8
  RateLimitError,
9
9
  schemaToJsonSchema,
10
10
  truncateForPersist
11
- } from "./chunk-SKN6HBBT.js";
11
+ } from "./chunk-X5RX2VGQ.js";
12
12
  import {
13
13
  APP_NAME,
14
14
  CONFIG_DIR_NAME,
@@ -21,7 +21,7 @@ import {
21
21
  MCP_TOOL_PREFIX,
22
22
  PLUGINS_DIR_NAME,
23
23
  VERSION
24
- } from "./chunk-AQNAV4H4.js";
24
+ } from "./chunk-NIJZBQ6I.js";
25
25
 
26
26
  // src/config/config-manager.ts
27
27
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -3819,18 +3819,34 @@ function trimOldToolOutput(messages, keepRecentRounds = 10) {
3819
3819
  }
3820
3820
  return trimmed;
3821
3821
  }
3822
+ function cloneMessages(messages) {
3823
+ return messages.map((m) => ({ ...m }));
3824
+ }
3822
3825
  function autoTrimSessionIfNeeded(session, sizeLimit = SESSION_SIZE_LIMIT) {
3823
- const json = JSON.stringify(session.toJSON());
3824
- if (json.length <= sizeLimit) return false;
3826
+ const originalSize = JSON.stringify(session.toJSON()).length;
3827
+ if (originalSize <= sizeLimit) return false;
3828
+ const snapshotLen = session.messages.length;
3829
+ let working = cloneMessages(session.messages.slice(0, snapshotLen));
3830
+ let committedSize = originalSize;
3831
+ let anyTrim = false;
3825
3832
  let keepRecent = 10;
3826
3833
  while (keepRecent >= 2) {
3827
- const trimmed = trimOldToolOutput(session.messages, keepRecent);
3828
- if (trimmed === 0) break;
3834
+ const trimmedCount = trimOldToolOutput(working, keepRecent);
3835
+ if (trimmedCount === 0) break;
3836
+ anyTrim = true;
3837
+ const originalMessages = session.messages;
3838
+ session.messages = [...working, ...originalMessages.slice(snapshotLen)];
3829
3839
  const newSize = JSON.stringify(session.toJSON()).length;
3830
- if (newSize <= sizeLimit) return true;
3840
+ session.messages = originalMessages;
3841
+ committedSize = newSize;
3842
+ if (newSize <= sizeLimit) break;
3831
3843
  keepRecent = Math.max(2, Math.floor(keepRecent / 2));
3844
+ if (keepRecent < 2) break;
3832
3845
  }
3833
- return true;
3846
+ if (!anyTrim) return false;
3847
+ const appended = session.messages.slice(snapshotLen);
3848
+ session.messages.splice(0, session.messages.length, ...working, ...appended);
3849
+ return committedSize < originalSize;
3834
3850
  }
3835
3851
 
3836
3852
  // src/repl/dev-state.ts
@@ -8,7 +8,7 @@ import { platform } from "os";
8
8
  import chalk from "chalk";
9
9
 
10
10
  // src/core/constants.ts
11
- var VERSION = "0.4.65";
11
+ var VERSION = "0.4.66";
12
12
  var APP_NAME = "ai-cli";
13
13
  var CONFIG_DIR_NAME = ".aicli";
14
14
  var CONFIG_FILE_NAME = "config.json";
@@ -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.65";
9
+ var VERSION = "0.4.66";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -10,7 +10,7 @@ import {
10
10
  SUBAGENT_DEFAULT_MAX_ROUNDS,
11
11
  SUBAGENT_MAX_ROUNDS_LIMIT,
12
12
  runTestsTool
13
- } from "./chunk-AQNAV4H4.js";
13
+ } from "./chunk-NIJZBQ6I.js";
14
14
 
15
15
  // src/tools/builtin/bash.ts
16
16
  import { execSync } from "child_process";
@@ -385,7 +385,7 @@ ${content}`);
385
385
  }
386
386
  }
387
387
  async function runTaskMode(config, providers, configManager, topic) {
388
- const { TaskOrchestrator } = await import("./task-orchestrator-4DCUYIRI.js");
388
+ const { TaskOrchestrator } = await import("./task-orchestrator-KOCFBDPK.js");
389
389
  const orchestrator = new TaskOrchestrator(config, providers, configManager);
390
390
  let interrupted = false;
391
391
  const onSigint = () => {
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  saveDevState,
32
32
  sessionHasMeaningfulContent,
33
33
  setupProxy
34
- } from "./chunk-2B2EVU6Z.js";
34
+ } from "./chunk-HOBLE365.js";
35
35
  import {
36
36
  ToolExecutor,
37
37
  ToolRegistry,
@@ -46,7 +46,7 @@ import {
46
46
  spawnAgentContext,
47
47
  theme,
48
48
  undoStack
49
- } from "./chunk-SKN6HBBT.js";
49
+ } from "./chunk-X5RX2VGQ.js";
50
50
  import {
51
51
  fileCheckpoints
52
52
  } from "./chunk-4BKXL7SM.js";
@@ -71,7 +71,7 @@ import {
71
71
  SKILLS_DIR_NAME,
72
72
  VERSION,
73
73
  buildUserIdentityPrompt
74
- } from "./chunk-AQNAV4H4.js";
74
+ } from "./chunk-NIJZBQ6I.js";
75
75
 
76
76
  // src/index.ts
77
77
  import { program } from "commander";
@@ -2193,7 +2193,7 @@ ${hint}` : "")
2193
2193
  usage: "/test [command|filter]",
2194
2194
  async execute(args, ctx) {
2195
2195
  try {
2196
- const { executeTests } = await import("./run-tests-C4CEOYZP.js");
2196
+ const { executeTests } = await import("./run-tests-47TTKJTB.js");
2197
2197
  const argStr = args.join(" ").trim();
2198
2198
  let testArgs = {};
2199
2199
  if (argStr) {
@@ -3280,14 +3280,31 @@ var CostTracker = class {
3280
3280
  this.records = [];
3281
3281
  }
3282
3282
  }
3283
- /** Save to disk (atomic write). */
3283
+ /**
3284
+ * Save to disk (atomic write).
3285
+ *
3286
+ * H2: Snapshot records before writing and only clear the dirty flag after
3287
+ * the write succeeds. If writeFileSync/renameSync throws, dirty remains
3288
+ * true so the next save() retries — prevents silent data loss on transient
3289
+ * disk errors. writeFileSync is sync in Node.js so there's no interleaving
3290
+ * risk within a single save() call; the snapshot mainly protects against
3291
+ * future refactors to async I/O.
3292
+ */
3284
3293
  save() {
3285
3294
  if (!this.dirty) return;
3286
- const data = { version: 1, records: this.records };
3287
- const tmp = this.filePath + ".tmp";
3288
- writeFileSync2(tmp, JSON.stringify(data, null, 2), "utf-8");
3289
- renameSync(tmp, this.filePath);
3290
- this.dirty = false;
3295
+ const snapshot = {
3296
+ version: 1,
3297
+ records: [...this.records]
3298
+ // shallow copy — records are plain data
3299
+ };
3300
+ try {
3301
+ const tmp = this.filePath + ".tmp";
3302
+ writeFileSync2(tmp, JSON.stringify(snapshot, null, 2), "utf-8");
3303
+ renameSync(tmp, this.filePath);
3304
+ this.dirty = false;
3305
+ } catch (err) {
3306
+ console.error("[cost-tracker] Failed to persist cost history:", err);
3307
+ }
3291
3308
  }
3292
3309
  /**
3293
3310
  * Record cost from a completed session/interaction.
@@ -5905,7 +5922,7 @@ program.command("web").description("Start Web UI server with browser-based chat
5905
5922
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
5906
5923
  process.exit(1);
5907
5924
  }
5908
- const { startWebServer } = await import("./server-CDRR3DC7.js");
5925
+ const { startWebServer } = await import("./server-A3SB52SS.js");
5909
5926
  await startWebServer({ port, host: options.host });
5910
5927
  });
5911
5928
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
@@ -6138,7 +6155,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
6138
6155
  }),
6139
6156
  config.get("customProviders")
6140
6157
  );
6141
- const { startHub } = await import("./hub-TKYPJZEX.js");
6158
+ const { startHub } = await import("./hub-JA7HH44N.js");
6142
6159
  await startHub(
6143
6160
  {
6144
6161
  topic: topic ?? "",
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-AQNAV4H4.js";
5
+ } from "./chunk-NIJZBQ6I.js";
6
6
  export {
7
7
  executeTests,
8
8
  runTestsTool
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-UNLZJRCY.js";
4
+ } from "./chunk-UIFW7G4A.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -21,7 +21,7 @@ import {
21
21
  persistToolRound,
22
22
  rebuildExtraMessages,
23
23
  setupProxy
24
- } from "./chunk-2B2EVU6Z.js";
24
+ } from "./chunk-HOBLE365.js";
25
25
  import {
26
26
  AuthManager
27
27
  } from "./chunk-BYNY5JPB.js";
@@ -41,7 +41,7 @@ import {
41
41
  spawnAgentContext,
42
42
  truncateOutput,
43
43
  undoStack
44
- } from "./chunk-SKN6HBBT.js";
44
+ } from "./chunk-X5RX2VGQ.js";
45
45
  import "./chunk-4BKXL7SM.js";
46
46
  import {
47
47
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -61,7 +61,7 @@ import {
61
61
  SKILLS_DIR_NAME,
62
62
  VERSION,
63
63
  buildUserIdentityPrompt
64
- } from "./chunk-AQNAV4H4.js";
64
+ } from "./chunk-NIJZBQ6I.js";
65
65
 
66
66
  // src/web/server.ts
67
67
  import express from "express";
@@ -1971,7 +1971,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
1971
1971
  case "test": {
1972
1972
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
1973
1973
  try {
1974
- const { executeTests } = await import("./run-tests-C4CEOYZP.js");
1974
+ const { executeTests } = await import("./run-tests-47TTKJTB.js");
1975
1975
  const argStr = args.join(" ").trim();
1976
1976
  let testArgs = {};
1977
1977
  if (argStr) {
@@ -4,11 +4,11 @@ import {
4
4
  getDangerLevel,
5
5
  googleSearchContext,
6
6
  truncateOutput
7
- } from "./chunk-SKN6HBBT.js";
7
+ } from "./chunk-X5RX2VGQ.js";
8
8
  import "./chunk-4BKXL7SM.js";
9
9
  import {
10
10
  SUBAGENT_ALLOWED_TOOLS
11
- } from "./chunk-AQNAV4H4.js";
11
+ } from "./chunk-NIJZBQ6I.js";
12
12
 
13
13
  // src/hub/task-orchestrator.ts
14
14
  import { createInterface } from "readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.4.65",
3
+ "version": "0.4.66",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",