jinzd-ai-cli 0.2.23 → 0.2.25

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.
@@ -16,7 +16,7 @@ import {
16
16
  SUBAGENT_MAX_ROUNDS_LIMIT,
17
17
  VERSION,
18
18
  runTestsTool
19
- } from "./chunk-M6BBSIGR.js";
19
+ } from "./chunk-SVYDE375.js";
20
20
 
21
21
  // src/config/config-manager.ts
22
22
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -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.23";
11
+ var VERSION = "0.2.25";
12
12
  var APP_NAME = "ai-cli";
13
13
  var CONFIG_DIR_NAME = ".aicli";
14
14
  var CONFIG_FILE_NAME = "config.json";
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  theme,
37
37
  truncateOutput,
38
38
  undoStack
39
- } from "./chunk-QZR2SIUB.js";
39
+ } from "./chunk-Q7YDWBRA.js";
40
40
  import {
41
41
  AGENTIC_BEHAVIOR_GUIDELINE,
42
42
  AUTHOR,
@@ -56,7 +56,7 @@ import {
56
56
  REPO_URL,
57
57
  SKILLS_DIR_NAME,
58
58
  VERSION
59
- } from "./chunk-M6BBSIGR.js";
59
+ } from "./chunk-SVYDE375.js";
60
60
 
61
61
  // src/index.ts
62
62
  import { program } from "commander";
@@ -1905,7 +1905,7 @@ ${hint}` : "")
1905
1905
  description: "Run project tests and show structured report",
1906
1906
  usage: "/test [command|filter]",
1907
1907
  async execute(args, _ctx) {
1908
- const { executeTests } = await import("./run-tests-A74MA54Z.js");
1908
+ const { executeTests } = await import("./run-tests-XBOM5EGQ.js");
1909
1909
  const argStr = args.join(" ").trim();
1910
1910
  let testArgs = {};
1911
1911
  if (argStr) {
@@ -2283,6 +2283,24 @@ Summary: ${fileMap.size} file(s) \u2014 ${newFiles} new, ${modifiedFiles} modifi
2283
2283
  }
2284
2284
  }
2285
2285
  },
2286
+ {
2287
+ name: "yolo",
2288
+ description: "Toggle session auto-approve (skip all confirmations)",
2289
+ usage: "/yolo [on|off]",
2290
+ execute(args, ctx) {
2291
+ const sub = args[0]?.toLowerCase();
2292
+ const executor = ctx.getToolExecutor();
2293
+ if (sub === "off") {
2294
+ executor.sessionAutoApprove = false;
2295
+ console.log(theme.info(" \u{1F512} Auto-approve disabled \u2014 confirmations restored for this session."));
2296
+ } else {
2297
+ executor.sessionAutoApprove = true;
2298
+ console.log(theme.warning(" \u26A1 YOLO mode ON \u2014 all write/destructive tools auto-approved for this session."));
2299
+ console.log(theme.dim(" Use /yolo off to re-enable confirmations."));
2300
+ }
2301
+ console.log();
2302
+ }
2303
+ },
2286
2304
  {
2287
2305
  name: "exit",
2288
2306
  description: "Exit the REPL",
@@ -2479,6 +2497,11 @@ var ToolExecutor = class {
2479
2497
  pendingSlashCommand = null;
2480
2498
  /** confirm() 的取消回调,由 SIGINT handler 调用 */
2481
2499
  cancelConfirmFn = null;
2500
+ /**
2501
+ * 会话级 auto-approve:跳过所有 write/destructive 确认(仅当前会话有效)。
2502
+ * 通过 /yolo 命令切换。destructive 操作仍会显示警告但不阻塞。
2503
+ */
2504
+ sessionAutoApprove = false;
2482
2505
  /**
2483
2506
  * 由外部(repl.ts SIGINT handler)调用,将当前 confirm() 等待视为用户按 N 取消。
2484
2507
  * 若当前没有 confirm() 进行中,无操作。
@@ -2547,6 +2570,24 @@ var ToolExecutor = class {
2547
2570
  }
2548
2571
  }
2549
2572
  }
2573
+ if (this.sessionAutoApprove && dangerLevel !== "safe") {
2574
+ this.printToolCall(call);
2575
+ if (dangerLevel === "write") this.printDiffPreview(call);
2576
+ console.log(theme.warning(" \u26A1 Auto-approved (session /yolo mode)"));
2577
+ try {
2578
+ const rawContent = await tool.execute(call.arguments);
2579
+ const content = truncateOutput(rawContent, call.name);
2580
+ const wasTruncated = content !== rawContent;
2581
+ this.printToolResult(call.name, rawContent, false, wasTruncated);
2582
+ runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "ok" });
2583
+ return { callId: call.id, content, isError: false };
2584
+ } catch (err) {
2585
+ const message = err instanceof Error ? err.message : String(err);
2586
+ this.printToolResult(call.name, message, true, false);
2587
+ runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "error" });
2588
+ return { callId: call.id, content: message, isError: true };
2589
+ }
2590
+ }
2550
2591
  if (dangerLevel === "write") {
2551
2592
  this.printToolCall(call);
2552
2593
  this.printDiffPreview(call);
@@ -2635,7 +2676,10 @@ var ToolExecutor = class {
2635
2676
  this.printDiffPreview(call);
2636
2677
  }
2637
2678
  console.log(theme.dim("\u2500".repeat(50)));
2638
- const decision = await this.batchConfirm(calls.length);
2679
+ const decision = this.sessionAutoApprove ? "all" : await this.batchConfirm(calls.length);
2680
+ if (this.sessionAutoApprove) {
2681
+ console.log(theme.warning(" \u26A1 All auto-approved (session /yolo mode)"));
2682
+ }
2639
2683
  const results = [];
2640
2684
  for (let i = 0; i < calls.length; i++) {
2641
2685
  const call = calls[i];
@@ -3394,14 +3438,8 @@ var Repl = class {
3394
3438
  _escHandler = null;
3395
3439
  /** User interjection: completed line queued for injection into agentic loop */
3396
3440
  _userInterjection = null;
3397
- /** User interjection: typing-trigger stdin handler (detects first printable char) */
3398
- _interjectionTrigger = null;
3399
- /** Whether interjection system is active (agentic loop) */
3441
+ /** Whether interjection system is active (agentic loop) currently disabled */
3400
3442
  _interjectionActive = false;
3401
- /** Whether user is currently in interjection typing mode (rl.question active) */
3402
- _interjectionTyping = false;
3403
- /** Reference to the current spinner, so interjection can pause/resume it */
3404
- _currentSpinner = null;
3405
3443
  /** Multi-line input buffer: accumulates lines ending with \ */
3406
3444
  _multilineBuf = [];
3407
3445
  /** 运行时动态添加的额外上下文目录(/add-dir 命令) */
@@ -4549,49 +4587,12 @@ Session '${this.resumeSessionId}' not found.
4549
4587
  setupInterjectionListener() {
4550
4588
  this._userInterjection = null;
4551
4589
  this._interjectionActive = true;
4552
- this._interjectionTyping = false;
4553
- const trigger = (data) => {
4554
- if (this.toolExecutor.confirming || askUserContext.prompting) return;
4555
- if (this._interjectionTyping) return;
4556
- const byte = data[0];
4557
- if (byte < 32 || byte === 127 || byte === 27) return;
4558
- this._interjectionTyping = true;
4559
- if (this._currentSpinner) this._currentSpinner.stop();
4560
- const rlAny = this.rl;
4561
- const savedOutput = rlAny.output;
4562
- rlAny.output = process.stdout;
4563
- process.stdout.write(theme.dim("\n \u25B8 "));
4564
- const firstChar = data.toString("utf-8").replace(/[\x00-\x1f\x7f]/g, "");
4565
- if (firstChar) process.stdout.write(firstChar);
4566
- this.rl.question("", (answer) => {
4567
- const fullLine = (firstChar + answer).trim();
4568
- rlAny.output = savedOutput;
4569
- this._interjectionTyping = false;
4570
- if (fullLine.length === 0) {
4571
- } else if (fullLine.startsWith("/")) {
4572
- this.toolExecutor.pendingSlashCommand = fullLine;
4573
- process.stdout.write(theme.dim(` (command "${fullLine}" queued)
4574
- `));
4575
- } else {
4576
- this._userInterjection = fullLine;
4577
- }
4578
- if (this._currentSpinner) this._currentSpinner.start();
4579
- });
4580
- };
4581
- this._interjectionTrigger = trigger;
4582
- process.stdin.prependListener("data", trigger);
4583
- process.stdin.resume();
4584
4590
  }
4585
4591
  /**
4586
4592
  * Remove the interjection listener, clean up state.
4587
4593
  */
4588
4594
  teardownInterjectionListener() {
4589
- if (this._interjectionTrigger) {
4590
- process.stdin.removeListener("data", this._interjectionTrigger);
4591
- this._interjectionTrigger = null;
4592
- }
4593
4595
  this._interjectionActive = false;
4594
- this._interjectionTyping = false;
4595
4596
  }
4596
4597
  /**
4597
4598
  * 注册 Ctrl+V 剪贴板图片粘贴快捷键。
@@ -4846,7 +4847,6 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
4846
4847
  const modelParams = this.getModelParams();
4847
4848
  const useStreaming = this.config.get("ui").streaming;
4848
4849
  const spinner = this.renderer.showSpinner("Thinking...");
4849
- this._currentSpinner = spinner;
4850
4850
  const roundUsage = { inputTokens: 0, outputTokens: 0 };
4851
4851
  const supportsStreamingTools = useStreaming && typeof provider.chatWithToolsStream === "function";
4852
4852
  let consecutiveFreeRounds = 0;
@@ -4854,7 +4854,6 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
4854
4854
  let repeatedToolCallCount = 0;
4855
4855
  const roundToolHistory = [];
4856
4856
  this.setupInterjectionListener();
4857
- process.stdout.write(theme.dim(" (Type a message + Enter to redirect AI at any time)\n"));
4858
4857
  try {
4859
4858
  for (let round = 0; round < MAX_TOOL_ROUNDS; round++) {
4860
4859
  this.toolExecutor.setRoundInfo(round + 1, MAX_TOOL_ROUNDS);
@@ -5098,9 +5097,7 @@ You have a maximum of ${MAX_TOOL_ROUNDS} tool call rounds for this task. Plan ef
5098
5097
  }
5099
5098
  }
5100
5099
  }
5101
- if (this._interjectionActive) {
5102
- process.stdin.resume();
5103
- }
5100
+ process.stdin.resume();
5104
5101
  const reasoningContent = "reasoningContent" in result ? result.reasoningContent : void 0;
5105
5102
  const newMsgs = provider.buildToolResultMessages(result.toolCalls, toolResults, reasoningContent);
5106
5103
  extraMessages.push(...newMsgs);
@@ -5254,7 +5251,6 @@ Tip: You can continue the conversation by asking the AI to proceed.`
5254
5251
  }
5255
5252
  } finally {
5256
5253
  this.teardownInterjectionListener();
5257
- this._currentSpinner = null;
5258
5254
  spinner.stop();
5259
5255
  await this.checkContextPressure();
5260
5256
  }
@@ -5416,6 +5412,7 @@ Tip: You can continue the conversation by asking the AI to proceed.`
5416
5412
  removeContextDir: (dirPath) => this.removeExtraContextDir(dirPath),
5417
5413
  listContextDirs: () => [...this.extraContextDirs],
5418
5414
  forkSession: (messageCount, title) => this.sessions.forkSession(messageCount, title),
5415
+ getToolExecutor: () => this.toolExecutor,
5419
5416
  exit: () => this.handleExit()
5420
5417
  };
5421
5418
  await cmd.execute(args, ctx);
@@ -5518,7 +5515,7 @@ program.command("web").description("Start Web UI server with browser-based chat
5518
5515
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
5519
5516
  process.exit(1);
5520
5517
  }
5521
- const { startWebServer } = await import("./server-LMXSNPOQ.js");
5518
+ const { startWebServer } = await import("./server-XFUSRZEO.js");
5522
5519
  await startWebServer({ port, host: options.host });
5523
5520
  });
5524
5521
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-M6BBSIGR.js";
5
+ } from "./chunk-SVYDE375.js";
6
6
  export {
7
7
  executeTests,
8
8
  runTestsTool
@@ -24,7 +24,7 @@ import {
24
24
  setupProxy,
25
25
  spawnAgentContext,
26
26
  truncateOutput
27
- } from "./chunk-QZR2SIUB.js";
27
+ } from "./chunk-Q7YDWBRA.js";
28
28
  import {
29
29
  AGENTIC_BEHAVIOR_GUIDELINE,
30
30
  CONTEXT_FILE_CANDIDATES,
@@ -36,7 +36,7 @@ import {
36
36
  PLAN_MODE_SYSTEM_ADDON,
37
37
  SKILLS_DIR_NAME,
38
38
  VERSION
39
- } from "./chunk-M6BBSIGR.js";
39
+ } from "./chunk-SVYDE375.js";
40
40
  import {
41
41
  AuthManager
42
42
  } from "./chunk-CPLT6CD3.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",