jinzd-ai-cli 0.4.29 → 0.4.30

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.
@@ -9,7 +9,7 @@ import {
9
9
  SUBAGENT_DEFAULT_MAX_ROUNDS,
10
10
  SUBAGENT_MAX_ROUNDS_LIMIT,
11
11
  runTestsTool
12
- } from "./chunk-TE6QE7FJ.js";
12
+ } from "./chunk-4WGZEAGJ.js";
13
13
 
14
14
  // src/tools/builtin/bash.ts
15
15
  import { execSync } 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.29";
9
+ var VERSION = "0.4.30";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -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.29";
11
+ var VERSION = "0.4.30";
12
12
  var APP_NAME = "ai-cli";
13
13
  var CONFIG_DIR_NAME = ".aicli";
14
14
  var CONFIG_FILE_NAME = "config.json";
@@ -7,7 +7,7 @@ import {
7
7
  ProviderNotFoundError,
8
8
  RateLimitError,
9
9
  schemaToJsonSchema
10
- } from "./chunk-SXL6H7XR.js";
10
+ } from "./chunk-4EOFMJCR.js";
11
11
  import {
12
12
  APP_NAME,
13
13
  CONFIG_DIR_NAME,
@@ -20,7 +20,7 @@ import {
20
20
  MCP_TOOL_PREFIX,
21
21
  PLUGINS_DIR_NAME,
22
22
  VERSION
23
- } from "./chunk-TE6QE7FJ.js";
23
+ } from "./chunk-4WGZEAGJ.js";
24
24
 
25
25
  // src/config/config-manager.ts
26
26
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -1391,6 +1391,16 @@ function detectsCodeBlockPseudoCall(content) {
1391
1391
  return CODE_BLOCK_PATTERNS.some((pattern) => pattern.test(content));
1392
1392
  }
1393
1393
  var DEEPSEEK_CODE_BLOCK_CORRECTION = "You wrote a code block in your response text, but you did NOT actually execute it. Code blocks in text are NOT executed by the system. You MUST use the function calling API to invoke the appropriate tool (e.g., mcp__postgres__query for SQL queries, bash for shell commands). Please call the correct tool NOW to execute the query/command.";
1394
+ var DEEPSEEK_ANTI_HALLUCINATION = `
1395
+
1396
+ [CRITICAL: Anti-Hallucination Enforcement \u2014 DeepSeek Specific]
1397
+ You have a known tendency to claim files were "saved" or "created" without actually calling write_file. This is UNACCEPTABLE.
1398
+ Rules you MUST follow:
1399
+ - NEVER type file content into your response text. ALL file content goes through write_file tool calls ONLY.
1400
+ - After calling write_file, do NOT describe the file content again in text \u2014 just confirm the tool call result.
1401
+ - When generating multiple files: call write_file for file 1 \u2192 call write_file for file 2 \u2192 ... \u2192 THEN summarize.
1402
+ - If you catch yourself writing markdown/code that should be a file, STOP and use write_file instead.
1403
+ - The system will detect and reject phantom claims. Each failed detection wastes a round. Be honest.`;
1394
1404
  var DeepSeekProvider = class extends OpenAICompatibleProvider {
1395
1405
  defaultBaseUrl = "https://api.deepseek.com/v1";
1396
1406
  /** 禁用流式工具调用,确保 chatWithTools 覆写(代码块检测)生效 */
@@ -1427,7 +1437,11 @@ var DeepSeekProvider = class extends OpenAICompatibleProvider {
1427
1437
  * 检测到后注入纠正消息强制重试一次。
1428
1438
  */
1429
1439
  async chatWithTools(request, tools) {
1430
- const result = await super.chatWithTools(request, tools);
1440
+ const enhancedRequest = {
1441
+ ...request,
1442
+ systemPrompt: (request.systemPrompt ?? "") + DEEPSEEK_ANTI_HALLUCINATION
1443
+ };
1444
+ const result = await super.chatWithTools(enhancedRequest, tools);
1431
1445
  const hasBashTool = tools.some((t) => t.name === "bash");
1432
1446
  if (hasBashTool && "content" in result && result.content && detectsCodeBlockPseudoCall(result.content)) {
1433
1447
  process.stderr.write(
@@ -1545,8 +1559,20 @@ var HALLUCINATION_PATTERNS = [
1545
1559
  // File written to / saved as(要求介词)
1546
1560
  /生成完成[!!]/,
1547
1561
  // 生成完成!
1548
- /✅\s*(?:文件|已[生保写创]|第)\S*\.\w{1,5}/
1562
+ /✅\s*(?:文件|已[生保写创]|第)\S*\.\w{1,5}/,
1549
1563
  // ✅ 文件已保存 path.ext(要求文件扩展名)
1564
+ /文件已[成功]?创建/,
1565
+ // 文件已成功创建 / 文件已创建
1566
+ /教案已[成功]?[生创保写]/,
1567
+ // 教案已成功生成 / 教案已保存
1568
+ /已成功[保写创生]入?[::!!\s`'"]/,
1569
+ // 已成功保存 / 已成功写入 / 已成功创建
1570
+ /保存[到至]了?\s*[`'"]/,
1571
+ // 保存到了 `path` / 保存至 'path'
1572
+ /内容如下[::]/,
1573
+ // 内容如下:(后跟大段文件内容)
1574
+ /以下是.*(?:教案|文件|内容)[::]/
1575
+ // 以下是xx教案内容:(Kimi 常见模式)
1550
1576
  ];
1551
1577
  function detectsHallucinatedFileOp(content) {
1552
1578
  return HALLUCINATION_PATTERNS.some((pattern) => pattern.test(content));
@@ -1585,7 +1611,20 @@ When you need to create, write, or modify files, you MUST use the function calli
1585
1611
  NEVER claim "file saved", "file created", "written to", etc. in your response text without actually calling the tool.
1586
1612
  Describing file content in text without calling the tool = the file does not exist = task failure.
1587
1613
  If multiple files need to be generated, you MUST call write_file separately for each file \u2014 do not skip any.
1588
- Do NOT output fake "completion summaries" unless you have actually completed all file writes via tool_calls.`;
1614
+ Do NOT output fake "completion summaries" unless you have actually completed all file writes via tool_calls.
1615
+
1616
+ CRITICAL \u2014 Batch file generation rules:
1617
+ 1. You MUST call write_file once per file. There are NO shortcuts.
1618
+ 2. After writing file N, immediately proceed to call write_file for file N+1. Do NOT stop to summarize.
1619
+ 3. If you find yourself typing file content into your response text instead of into a write_file call, STOP and use the tool.
1620
+ 4. Only produce a text summary AFTER all write_file calls have been made and returned success.
1621
+ 5. The system compares every "file saved" claim against actual tool calls. Phantom claims trigger an automatic retry \u2014 do not waste rounds.`;
1622
+ function buildWriteRoundReminder(writtenCount) {
1623
+ return `
1624
+
1625
+ [Write Progress Reminder]
1626
+ You have successfully called write_file ${writtenCount} time(s) so far in this turn. If there are more files to write, call write_file NOW for the next file. Do NOT produce a text summary until ALL files have been written via tool calls.`;
1627
+ }
1589
1628
  var HALLUCINATION_CORRECTION_MESSAGE = "You did NOT actually call the write_file tool \u2014 the file was NOT created! Please immediately use the write_file tool via the function calling API to perform the actual file write. Do NOT describe file content in text \u2014 you MUST invoke write_file through the tool_calls mechanism.";
1590
1629
  function extractClaimedFilePaths(content) {
1591
1630
  const paths = /* @__PURE__ */ new Set();
@@ -1683,7 +1722,16 @@ var KIMI_XML_REMINDER = `
1683
1722
  [IMPORTANT: Tool Call Format Rules - Kimi Specific]
1684
1723
  When calling any tool (write_file, bash, read_file, etc.), you MUST use the API's structured function calling interface exclusively.
1685
1724
  NEVER output XML-formatted pseudo tool call tags (such as <write_file>, <bash>, <read_file>, etc.) in your reply text.
1686
- XML tags in text will NOT be executed by the system, resulting in files not being written, commands not being run, and complete task failure.`;
1725
+ XML tags in text will NOT be executed by the system, resulting in files not being written, commands not being run, and complete task failure.
1726
+
1727
+ [CRITICAL: Anti-Hallucination Enforcement]
1728
+ You have a known tendency to claim files were "saved" or "created" without actually calling write_file. This is UNACCEPTABLE.
1729
+ Rules you MUST follow:
1730
+ - NEVER type file content into your response text. ALL file content goes through write_file tool calls ONLY.
1731
+ - After calling write_file, do NOT describe the file content again in text \u2014 just confirm the tool call result.
1732
+ - When generating multiple files: call write_file for file 1 \u2192 call write_file for file 2 \u2192 ... \u2192 THEN summarize.
1733
+ - If you catch yourself writing markdown/code that should be a file, STOP and use write_file instead.
1734
+ - The system will detect and reject phantom claims. Each failed detection wastes a round. Be honest.`;
1687
1735
  var KimiProvider = class extends OpenAICompatibleProvider {
1688
1736
  defaultBaseUrl = "https://api.moonshot.ai/v1";
1689
1737
  // 禁用流式工具调用:Kimi 的 XML 伪调用检测(方案 A)需要完整响应
@@ -3423,7 +3471,9 @@ export {
3423
3471
  detectsHallucinatedFileOp,
3424
3472
  hadPreviousWriteToolCalls,
3425
3473
  TOOL_CALL_REMINDER,
3474
+ buildWriteRoundReminder,
3426
3475
  HALLUCINATION_CORRECTION_MESSAGE,
3476
+ extractWrittenFilePaths,
3427
3477
  findPhantomClaims,
3428
3478
  buildPhantomCorrectionMessage,
3429
3479
  ProviderRegistry,
@@ -387,7 +387,7 @@ ${content}`);
387
387
  }
388
388
  }
389
389
  async function runTaskMode(config, providers, configManager, topic) {
390
- const { TaskOrchestrator } = await import("./task-orchestrator-LLCLCGR2.js");
390
+ const { TaskOrchestrator } = await import("./task-orchestrator-VUAHWAAP.js");
391
391
  const orchestrator = new TaskOrchestrator(config, providers, configManager);
392
392
  let interrupted = false;
393
393
  const onSigint = () => {
package/dist/index.js CHANGED
@@ -9,8 +9,10 @@ import {
9
9
  SkillManager,
10
10
  TOOL_CALL_REMINDER,
11
11
  buildPhantomCorrectionMessage,
12
+ buildWriteRoundReminder,
12
13
  clearDevState,
13
14
  detectsHallucinatedFileOp,
15
+ extractWrittenFilePaths,
14
16
  findPhantomClaims,
15
17
  formatGitContextForPrompt,
16
18
  getContentText,
@@ -22,7 +24,7 @@ import {
22
24
  saveDevState,
23
25
  sessionHasMeaningfulContent,
24
26
  setupProxy
25
- } from "./chunk-JHVH276O.js";
27
+ } from "./chunk-HNS4LEHL.js";
26
28
  import {
27
29
  ToolExecutor,
28
30
  ToolRegistry,
@@ -35,7 +37,7 @@ import {
35
37
  spawnAgentContext,
36
38
  theme,
37
39
  undoStack
38
- } from "./chunk-SXL6H7XR.js";
40
+ } from "./chunk-4EOFMJCR.js";
39
41
  import {
40
42
  fileCheckpoints
41
43
  } from "./chunk-4BKXL7SM.js";
@@ -59,7 +61,7 @@ import {
59
61
  SKILLS_DIR_NAME,
60
62
  VERSION,
61
63
  buildUserIdentityPrompt
62
- } from "./chunk-TE6QE7FJ.js";
64
+ } from "./chunk-4WGZEAGJ.js";
63
65
 
64
66
  // src/index.ts
65
67
  import { program } from "commander";
@@ -2085,7 +2087,7 @@ ${hint}` : "")
2085
2087
  usage: "/test [command|filter]",
2086
2088
  async execute(args, ctx) {
2087
2089
  try {
2088
- const { executeTests } = await import("./run-tests-FNWRWJUI.js");
2090
+ const { executeTests } = await import("./run-tests-NBCWIU4B.js");
2089
2091
  const argStr = args.join(" ").trim();
2090
2092
  let testArgs = {};
2091
2093
  if (argStr) {
@@ -4967,6 +4969,18 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
4967
4969
  const reasoningContent = "reasoningContent" in result ? result.reasoningContent : void 0;
4968
4970
  const newMsgs = provider.buildToolResultMessages(result.toolCalls, toolResults, reasoningContent);
4969
4971
  extraMessages.push(...newMsgs);
4972
+ const thisRoundHadWrite = result.toolCalls.some(
4973
+ (tc) => tc.name === "write_file" || tc.name === "edit_file"
4974
+ );
4975
+ if (thisRoundHadWrite) {
4976
+ const totalWritten = extractWrittenFilePaths(extraMessages).length;
4977
+ if (totalWritten > 0) {
4978
+ extraMessages.push({
4979
+ role: "user",
4980
+ content: buildWriteRoundReminder(totalWritten)
4981
+ });
4982
+ }
4983
+ }
4970
4984
  const allFree = result.toolCalls.every((tc) => FREE_ROUND_TOOLS.has(tc.name));
4971
4985
  if (allFree) {
4972
4986
  consecutiveFreeRounds++;
@@ -5383,7 +5397,7 @@ program.command("web").description("Start Web UI server with browser-based chat
5383
5397
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
5384
5398
  process.exit(1);
5385
5399
  }
5386
- const { startWebServer } = await import("./server-DSICPNYM.js");
5400
+ const { startWebServer } = await import("./server-67B52TFH.js");
5387
5401
  await startWebServer({ port, host: options.host });
5388
5402
  });
5389
5403
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
@@ -5616,7 +5630,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
5616
5630
  }),
5617
5631
  config.get("customProviders")
5618
5632
  );
5619
- const { startHub } = await import("./hub-RMUO6RN2.js");
5633
+ const { startHub } = await import("./hub-FKLTP6IO.js");
5620
5634
  await startHub(
5621
5635
  {
5622
5636
  topic: topic ?? "",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-FETMBU6E.js";
4
+ } from "./chunk-4TUVB27S.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-TE6QE7FJ.js";
5
+ } from "./chunk-4WGZEAGJ.js";
6
6
  export {
7
7
  executeTests,
8
8
  runTestsTool
@@ -15,7 +15,7 @@ import {
15
15
  hadPreviousWriteToolCalls,
16
16
  loadDevState,
17
17
  setupProxy
18
- } from "./chunk-JHVH276O.js";
18
+ } from "./chunk-HNS4LEHL.js";
19
19
  import {
20
20
  AuthManager
21
21
  } from "./chunk-BYNY5JPB.js";
@@ -33,7 +33,7 @@ import {
33
33
  spawnAgentContext,
34
34
  truncateOutput,
35
35
  undoStack
36
- } from "./chunk-SXL6H7XR.js";
36
+ } from "./chunk-4EOFMJCR.js";
37
37
  import "./chunk-4BKXL7SM.js";
38
38
  import {
39
39
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -52,7 +52,7 @@ import {
52
52
  SKILLS_DIR_NAME,
53
53
  VERSION,
54
54
  buildUserIdentityPrompt
55
- } from "./chunk-TE6QE7FJ.js";
55
+ } from "./chunk-4WGZEAGJ.js";
56
56
 
57
57
  // src/web/server.ts
58
58
  import express from "express";
@@ -1606,7 +1606,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
1606
1606
  case "test": {
1607
1607
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
1608
1608
  try {
1609
- const { executeTests } = await import("./run-tests-FNWRWJUI.js");
1609
+ const { executeTests } = await import("./run-tests-NBCWIU4B.js");
1610
1610
  const argStr = args.join(" ").trim();
1611
1611
  let testArgs = {};
1612
1612
  if (argStr) {
@@ -4,11 +4,11 @@ import {
4
4
  getDangerLevel,
5
5
  googleSearchContext,
6
6
  truncateOutput
7
- } from "./chunk-SXL6H7XR.js";
7
+ } from "./chunk-4EOFMJCR.js";
8
8
  import "./chunk-4BKXL7SM.js";
9
9
  import {
10
10
  SUBAGENT_ALLOWED_TOOLS
11
- } from "./chunk-TE6QE7FJ.js";
11
+ } from "./chunk-4WGZEAGJ.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.29",
3
+ "version": "0.4.30",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",