jinzd-ai-cli 0.2.9 → 0.2.11
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.
- package/README.md +7 -2
- package/README.zh-CN.md +7 -2
- package/dist/{chunk-UR5QRBEG.js → chunk-HLR3T3PP.js} +3 -2
- package/dist/{chunk-J6SXTNJO.js → chunk-NT7GYZEL.js} +8 -1
- package/dist/index.js +32 -6
- package/dist/{run-tests-ITCKU6DW.js → run-tests-TGHLGADJ.js} +1 -1
- package/dist/{server-ZMMVUF7Q.js → server-HERHWMR4.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[]()
|
|
11
11
|
[](https://github.com/jinzhengdong/ai-cli/releases)
|
|
12
|
+
[](https://github.com/jinzhengdong/ai-cli/actions/workflows/ci.yml)
|
|
12
13
|
|
|
13
14
|
**ai-cli** is a powerful AI assistant that connects to 7 providers and executes tasks autonomously through agentic tool calling. Use it as a terminal REPL, a browser-based Web UI, or a standalone Electron desktop app.
|
|
14
15
|
|
|
@@ -26,13 +27,15 @@
|
|
|
26
27
|
- **Streaming Tool Use** — Real-time streaming of AI reasoning and tool calls as they happen
|
|
27
28
|
- **Sub-Agents** — Delegate complex subtasks to isolated child agents with independent tool loops
|
|
28
29
|
- **Extended Thinking** — Claude deep reasoning mode with `/think` toggle
|
|
29
|
-
- **Plan Mode** — Read-only planning phase (`/plan`) where AI analyzes before executing
|
|
30
|
+
- **Plan Mode** — Read-only planning phase (`/plan`) where AI analyzes before executing, with loop detection
|
|
31
|
+
- **Auto-Pause** — Automatically pauses every 10 rounds for user review and redirection
|
|
30
32
|
- **MCP Protocol** — Connect external MCP servers for dynamic tool discovery
|
|
31
33
|
- **Multi-User Auth** — Web UI supports multiple users with password authentication
|
|
32
34
|
- **PWA Support** — Install Web UI as a desktop/mobile app, accessible over LAN
|
|
33
35
|
- **Hierarchical Context** — 3-layer context files (global / project / subdirectory) auto-injected
|
|
34
36
|
- **Headless Mode** — `ai-cli -p "prompt"` for CI/CD pipelines and scripting
|
|
35
37
|
- **35+ REPL Commands** — Session management, checkpointing, code review, scaffolding, and more
|
|
38
|
+
- **GitHub Actions CI/CD** — Automated testing on Node 20/22 + npm publish on release tags
|
|
36
39
|
- **Cross-Platform** — Windows, macOS, Linux
|
|
37
40
|
|
|
38
41
|
## Installation
|
|
@@ -125,7 +128,7 @@ AI autonomously invokes these 16 tools during conversations:
|
|
|
125
128
|
| `bash` | varies | Execute shell commands (PowerShell on Windows, $SHELL on Unix) |
|
|
126
129
|
| `read_file` | safe | Read file contents (10 MB limit, image support) |
|
|
127
130
|
| `write_file` | write | Create/overwrite files (diff preview + confirmation) |
|
|
128
|
-
| `edit_file` | write | Precise string replacement with fuzzy matching hints |
|
|
131
|
+
| `edit_file` | write | Precise string replacement with fuzzy matching hints + `replaceAll` mode |
|
|
129
132
|
| `list_dir` | safe | List directory contents |
|
|
130
133
|
| `grep_files` | safe | Regex search across files |
|
|
131
134
|
| `glob_files` | safe | Match files by glob pattern |
|
|
@@ -167,6 +170,8 @@ AI autonomously invokes these 16 tools during conversations:
|
|
|
167
170
|
| `/config` | Open configuration wizard |
|
|
168
171
|
| `/help` | Show all available commands |
|
|
169
172
|
|
|
173
|
+
**Multi-line input**: Use `\` at end of line for continuation, or paste multi-line content directly (auto-detected and merged).
|
|
174
|
+
|
|
170
175
|
See the [full command reference](USAGE.md) for all 35+ commands.
|
|
171
176
|
|
|
172
177
|
## CLI Parameters
|
package/README.zh-CN.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[]()
|
|
11
11
|
[](https://github.com/jinzhengdong/ai-cli/releases)
|
|
12
|
+
[](https://github.com/jinzhengdong/ai-cli/actions/workflows/ci.yml)
|
|
12
13
|
|
|
13
14
|
## 特性亮点
|
|
14
15
|
|
|
@@ -18,13 +19,15 @@
|
|
|
18
19
|
- **流式工具调用** — 实时流式展示 AI 推理过程和工具调用
|
|
19
20
|
- **子代理系统** — 将复杂子任务委派给独立子代理执行
|
|
20
21
|
- **深度推理** — Claude Extended Thinking,`/think` 一键切换
|
|
21
|
-
- **规划模式** — `/plan` 进入只读规划,AI
|
|
22
|
+
- **规划模式** — `/plan` 进入只读规划,AI 先分析后执行,内置死循环检测
|
|
23
|
+
- **自动暂停** — 每 10 轮自动暂停,用户可审查进度或重定向 AI
|
|
22
24
|
- **MCP 协议** — 接入外部 MCP 服务器,动态发现工具
|
|
23
25
|
- **多用户认证** — Web UI 支持多用户密码登录
|
|
24
26
|
- **PWA 支持** — Web UI 可安装为桌面/移动应用,支持局域网访问
|
|
25
27
|
- **三层级上下文** — 全局 / 项目 / 子目录上下文文件自动注入
|
|
26
28
|
- **无头模式** — `aicli -p "提示词"` 用于 CI/CD 管道和脚本
|
|
27
29
|
- **35+ REPL 命令** — 会话管理、检查点、代码审查、脚手架等
|
|
30
|
+
- **GitHub Actions CI/CD** — Node 20/22 自动测试 + Release tag 自动发布 npm
|
|
28
31
|
- **跨平台** — Windows、macOS、Linux
|
|
29
32
|
|
|
30
33
|
## 安装
|
|
@@ -117,7 +120,7 @@ AI 在对话中可自主调用 16 个工具:
|
|
|
117
120
|
| `bash` | 动态判断 | 执行 shell 命令(Windows: PowerShell,Unix: $SHELL) |
|
|
118
121
|
| `read_file` | 安全 | 读取文件内容(10 MB 限制,支持图片) |
|
|
119
122
|
| `write_file` | 写入 | 创建/覆盖文件(diff 预览 + 确认) |
|
|
120
|
-
| `edit_file` | 写入 | 精确字符串替换,模糊匹配提示 |
|
|
123
|
+
| `edit_file` | 写入 | 精确字符串替换,模糊匹配提示 + `replaceAll` 全局替换模式 |
|
|
121
124
|
| `list_dir` | 安全 | 列出目录内容 |
|
|
122
125
|
| `grep_files` | 安全 | 正则搜索文件内容 |
|
|
123
126
|
| `glob_files` | 安全 | 按 glob 模式匹配文件 |
|
|
@@ -159,6 +162,8 @@ AI 在对话中可自主调用 16 个工具:
|
|
|
159
162
|
| `/config` | 打开配置向导 |
|
|
160
163
|
| `/help` | 显示所有命令 |
|
|
161
164
|
|
|
165
|
+
**多行输入**:行末加 `\` 续行,或直接粘贴多行内容(自动检测合并)。
|
|
166
|
+
|
|
162
167
|
完整命令参考见 [使用说明](USAGE.md)。
|
|
163
168
|
|
|
164
169
|
## CLI 参数
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
SUBAGENT_MAX_ROUNDS_LIMIT,
|
|
17
17
|
VERSION,
|
|
18
18
|
runTestsTool
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NT7GYZEL.js";
|
|
20
20
|
|
|
21
21
|
// src/config/config-manager.ts
|
|
22
22
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
@@ -1482,7 +1482,8 @@ var DeepSeekProvider = class extends OpenAICompatibleProvider {
|
|
|
1482
1482
|
*/
|
|
1483
1483
|
async chatWithTools(request, tools) {
|
|
1484
1484
|
const result = await super.chatWithTools(request, tools);
|
|
1485
|
-
|
|
1485
|
+
const hasBashTool = tools.some((t) => t.name === "bash");
|
|
1486
|
+
if (hasBashTool && "content" in result && result.content && detectsCodeBlockPseudoCall(result.content)) {
|
|
1486
1487
|
process.stderr.write(
|
|
1487
1488
|
`[deepseek] \u26A0 Detected code block pseudo-tool-call (DeepSeek wrote code in text instead of calling a tool). Forcing retry...
|
|
1488
1489
|
`
|
|
@@ -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.2.
|
|
11
|
+
var VERSION = "0.2.11";
|
|
12
12
|
var APP_NAME = "ai-cli";
|
|
13
13
|
var CONFIG_DIR_NAME = ".aicli";
|
|
14
14
|
var CONFIG_FILE_NAME = "config.json";
|
|
@@ -54,6 +54,13 @@ You are currently in read-only planning (Plan) mode.
|
|
|
54
54
|
- Execution order and dependencies
|
|
55
55
|
- Potential risks and considerations
|
|
56
56
|
|
|
57
|
+
**CRITICAL RULES**:
|
|
58
|
+
- Do NOT attempt to call bash, write_file, edit_file, or any disabled tool \u2014 they will fail silently.
|
|
59
|
+
- Do NOT write shell commands, SQL queries, or code in your text response as a substitute for tool calls \u2014 the user's system will misinterpret this as a pseudo-tool-call error.
|
|
60
|
+
- If the user asks you to run commands, test connections, or modify files, respond with: "This requires execution tools. Please type \`/plan execute\` to switch to execute mode, then I can perform these operations."
|
|
61
|
+
- Do NOT call write_todos repeatedly with the same content \u2014 call it once, then give a text response.
|
|
62
|
+
- Focus your analysis on reading files and producing actionable plans.
|
|
63
|
+
|
|
57
64
|
Once planning is complete, clearly inform the user: type \`/plan execute\` to begin executing the plan, or \`/plan exit\` to discard it.`;
|
|
58
65
|
var SUBAGENT_DEFAULT_MAX_ROUNDS = 10;
|
|
59
66
|
var SUBAGENT_MAX_ROUNDS_LIMIT = 15;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
theme,
|
|
36
36
|
truncateOutput,
|
|
37
37
|
undoStack
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-HLR3T3PP.js";
|
|
39
39
|
import {
|
|
40
40
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
41
41
|
AUTHOR,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
REPO_URL,
|
|
56
56
|
SKILLS_DIR_NAME,
|
|
57
57
|
VERSION
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-NT7GYZEL.js";
|
|
59
59
|
|
|
60
60
|
// src/index.ts
|
|
61
61
|
import { program } from "commander";
|
|
@@ -1904,7 +1904,7 @@ ${hint}` : "")
|
|
|
1904
1904
|
description: "Run project tests and show structured report",
|
|
1905
1905
|
usage: "/test [command|filter]",
|
|
1906
1906
|
async execute(args, _ctx) {
|
|
1907
|
-
const { executeTests } = await import("./run-tests-
|
|
1907
|
+
const { executeTests } = await import("./run-tests-TGHLGADJ.js");
|
|
1908
1908
|
const argStr = args.join(" ").trim();
|
|
1909
1909
|
let testArgs = {};
|
|
1910
1910
|
if (argStr) {
|
|
@@ -3311,7 +3311,8 @@ ${content}
|
|
|
3311
3311
|
}
|
|
3312
3312
|
var MAX_TOOL_ROUNDS = 25;
|
|
3313
3313
|
var FREE_ROUND_TOOLS = /* @__PURE__ */ new Set(["write_todos"]);
|
|
3314
|
-
var MAX_CONSECUTIVE_FREE_ROUNDS =
|
|
3314
|
+
var MAX_CONSECUTIVE_FREE_ROUNDS = 3;
|
|
3315
|
+
var MAX_REPEATED_TOOL_CALLS = 2;
|
|
3315
3316
|
var AUTO_PAUSE_INTERVAL = 10;
|
|
3316
3317
|
function fmtTokens(n) {
|
|
3317
3318
|
if (n >= 1e6) return `${Math.round(n / 1e5) / 10}M`;
|
|
@@ -4818,6 +4819,8 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
|
|
|
4818
4819
|
const roundUsage = { inputTokens: 0, outputTokens: 0 };
|
|
4819
4820
|
const supportsStreamingTools = useStreaming && typeof provider.chatWithToolsStream === "function";
|
|
4820
4821
|
let consecutiveFreeRounds = 0;
|
|
4822
|
+
let lastToolCallSignature = "";
|
|
4823
|
+
let repeatedToolCallCount = 0;
|
|
4821
4824
|
this.setupInterjectionListener();
|
|
4822
4825
|
process.stdout.write(theme.dim(" (Type a message + Enter to redirect AI at any time)\n"));
|
|
4823
4826
|
try {
|
|
@@ -4901,7 +4904,8 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
|
|
|
4901
4904
|
if ("content" in result) {
|
|
4902
4905
|
const hasWriteTools = toolDefs.some((t) => t.name === "write_file" || t.name === "edit_file");
|
|
4903
4906
|
const alreadyWrote = hadPreviousWriteToolCalls(extraMessages);
|
|
4904
|
-
if (
|
|
4907
|
+
if (!this.planMode && // Plan Mode 下跳过虚假声明检测
|
|
4908
|
+
hasWriteTools && !alreadyWrote && result.content && detectsHallucinatedFileOp(result.content) && round < MAX_TOOL_ROUNDS - 1) {
|
|
4905
4909
|
const providerName = this.currentProvider;
|
|
4906
4910
|
process.stderr.write(
|
|
4907
4911
|
`[${providerName}] \u26A0 Hallucinated completion detected (AI claimed file was written but no tool was called), forcing retry...
|
|
@@ -5043,6 +5047,28 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
|
|
|
5043
5047
|
} else {
|
|
5044
5048
|
consecutiveFreeRounds = 0;
|
|
5045
5049
|
}
|
|
5050
|
+
const currentSignature = result.toolCalls.map((tc) => `${tc.name}:${JSON.stringify(tc.arguments)}`).join("|");
|
|
5051
|
+
if (currentSignature === lastToolCallSignature) {
|
|
5052
|
+
repeatedToolCallCount++;
|
|
5053
|
+
if (repeatedToolCallCount >= MAX_REPEATED_TOOL_CALLS) {
|
|
5054
|
+
spinner.stop();
|
|
5055
|
+
process.stderr.write(
|
|
5056
|
+
theme.warning(`
|
|
5057
|
+
\u26A0 Detected ${repeatedToolCallCount + 1} identical consecutive tool calls \u2014 breaking loop.
|
|
5058
|
+
`)
|
|
5059
|
+
);
|
|
5060
|
+
extraMessages.push({
|
|
5061
|
+
role: "user",
|
|
5062
|
+
content: "You are stuck in a loop calling the same tool with the same arguments repeatedly. Stop calling tools and give the user a final text response summarizing what you found and what needs to be done next. " + (this.planMode ? "If you need to execute commands (bash, psql, etc.), tell the user to type `/plan execute` first." : "")
|
|
5063
|
+
});
|
|
5064
|
+
repeatedToolCallCount = 0;
|
|
5065
|
+
lastToolCallSignature = "";
|
|
5066
|
+
continue;
|
|
5067
|
+
}
|
|
5068
|
+
} else {
|
|
5069
|
+
lastToolCallSignature = currentSignature;
|
|
5070
|
+
repeatedToolCallCount = 0;
|
|
5071
|
+
}
|
|
5046
5072
|
if (this._userInterjection) {
|
|
5047
5073
|
const msg = this._userInterjection;
|
|
5048
5074
|
this._userInterjection = null;
|
|
@@ -5411,7 +5437,7 @@ program.command("web").description("Start Web UI server with browser-based chat
|
|
|
5411
5437
|
console.error("Error: Invalid port number. Must be between 1 and 65535.");
|
|
5412
5438
|
process.exit(1);
|
|
5413
5439
|
}
|
|
5414
|
-
const { startWebServer } = await import("./server-
|
|
5440
|
+
const { startWebServer } = await import("./server-HERHWMR4.js");
|
|
5415
5441
|
await startWebServer({ port, host: options.host });
|
|
5416
5442
|
});
|
|
5417
5443
|
program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
setupProxy,
|
|
24
24
|
spawnAgentContext,
|
|
25
25
|
truncateOutput
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HLR3T3PP.js";
|
|
27
27
|
import {
|
|
28
28
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
29
29
|
CONTEXT_FILE_CANDIDATES,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
PLAN_MODE_SYSTEM_ADDON,
|
|
36
36
|
SKILLS_DIR_NAME,
|
|
37
37
|
VERSION
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-NT7GYZEL.js";
|
|
39
39
|
import {
|
|
40
40
|
AuthManager
|
|
41
41
|
} from "./chunk-CPLT6CD3.js";
|