jinzd-ai-cli 0.4.211 → 0.4.213

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/README.md +30 -0
  2. package/README.zh-CN.md +30 -0
  3. package/dist/{batch-DE4RXKZD.js → batch-PKY63TME.js} +2 -2
  4. package/dist/{chat-index-UBCWHBLR.js → chat-index-R2E27VXN.js} +1 -1
  5. package/dist/{chunk-JBWA73GK.js → chunk-7NTFMLJJ.js} +1 -1
  6. package/dist/{chunk-C3OU2OPF.js → chunk-FGUKBIYO.js} +2 -2
  7. package/dist/{chunk-BE6ERF7M.js → chunk-G3PW3AOB.js} +1 -1
  8. package/dist/{chunk-E5XCM4A6.js → chunk-IWLVH32D.js} +1 -1
  9. package/dist/{chunk-ZY2N2N6T.js → chunk-J35V3IAH.js} +1 -1
  10. package/dist/{chunk-UOROWTGG.js → chunk-MRGWPCFQ.js} +26 -3
  11. package/dist/{chunk-W7UKO3PS.js → chunk-OQGVGPEK.js} +5 -0
  12. package/dist/{chunk-ZOPYREL5.js → chunk-THNECAAY.js} +464 -67
  13. package/dist/{chunk-6NS6643Y.js → chunk-UDMU4FUF.js} +1 -1
  14. package/dist/{ci-XMUEX526.js → ci-HBZ6CIW5.js} +2 -2
  15. package/dist/{constants-AWTIQIWG.js → constants-CAUBTSFW.js} +1 -1
  16. package/dist/{doctor-cli-SSI6ETFT.js → doctor-cli-5Z5UWYW6.js} +4 -4
  17. package/dist/electron-server.js +794 -241
  18. package/dist/{hub-INUJND2G.js → hub-ZRADBR76.js} +1 -1
  19. package/dist/index.js +205 -19
  20. package/dist/{run-tests-PACN4UYX.js → run-tests-7J3PNWVS.js} +1 -1
  21. package/dist/{run-tests-3MHWUF43.js → run-tests-DSOJBJWA.js} +2 -2
  22. package/dist/{server-7USZJJAH.js → server-PWBWHVYB.js} +4 -4
  23. package/dist/{server-BTSKOPQI.js → server-U4I7RI42.js} +175 -10
  24. package/dist/{task-orchestrator-OV4O25MX.js → task-orchestrator-RUXWRMQV.js} +4 -4
  25. package/dist/{usage-T2P6FTE7.js → usage-2P6TIBTN.js} +2 -2
  26. package/dist/web/client/app.js +1 -1
  27. package/package.json +1 -1
package/README.md CHANGED
@@ -364,6 +364,13 @@ Built-in profiles:
364
364
  ```
365
365
 
366
366
  `/status` and `/security status` show the active profile. The Web status payload also includes `permissionProfile` for UI surfaces.
367
+ ### Auto Mode
368
+
369
+ `/auto on|off|status` enables a session-scoped, rule-based action classifier. It is designed to reduce confirmation fatigue without widening `/yolo`: `/yolo` still only skips write confirmations, while destructive tools still require confirmation.
370
+
371
+ Auto Mode may auto-approve low-risk actions such as explicit writes inside the workspace/temp roots, read-only HTTP tools, plain non-force `git push`, and dependency installs already declared in `package.json` or a lockfile. It denies high-risk shapes such as `curl | bash`, force push, and likely secret exfiltration. Production deploys, database migrations, IaC destroy, credential/permission changes, and third-party agent loops fall back to confirmation.
372
+
373
+ Auto Mode is not enabled by project config. Use `/permissions recently-denied` to inspect actions it blocked, or `/permissions clear-denied` to clear that session list.
367
374
  ### Network Policy
368
375
 
369
376
  `networkPolicy` is disabled by default for backward compatibility. When enabled, it governs network-facing tools before execution: `web_fetch`, `web_search`, `google_search`, MCP tools, and shell commands that look like network access (`curl`, `wget`, `git clone/fetch/pull/push`, package installs, SSH/SCP, etc.).
@@ -388,6 +395,29 @@ Built-in profiles:
388
395
  ```
389
396
 
390
397
  Actions are `allow`, `confirm`, or `deny`. Domain entries match the exact host or subdomains; port lists match the resolved URL port. Private/internal hosts such as `localhost`, `127.0.0.1`, `10.0.0.0/8`, `192.168.0.0/16`, and private IPv6 ranges are blocked unless `allowPrivateNetwork` is true.
398
+ ### Trusted Hooks Lifecycle
399
+
400
+ Legacy `preToolExecution` / `postToolExecution` hooks still work. New lifecycle hooks live under `hooks.events.<EventName>` and receive a JSON payload through `AICLI_HOOK_EVENT_JSON`; if the command prints JSON, ai-cli reads decisions such as `allow`, `deny`, `ask`, `warning`, or `warnings`.
401
+
402
+ ```json
403
+ {
404
+ "hooks": {
405
+ "events": {
406
+ "PreToolUse": {
407
+ "command": "node ./scripts/aicli-pre-tool-hook.mjs",
408
+ "source": "project",
409
+ "description": "Block unsafe local commands"
410
+ },
411
+ "UserPromptSubmit": "node ./scripts/aicli-prompt-hook.mjs",
412
+ "Stop": { "command": "npm test -- --runInBand", "timeoutMs": 10000 }
413
+ }
414
+ }
415
+ }
416
+ ```
417
+
418
+ Supported lifecycle names are `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PreCompact`, `PostCompact`, `Stop`, `SubagentStart`, and `SubagentStop`. Project-sourced hooks must be trusted before execution; ai-cli stores trust records locally under the user config directory, keyed by hook hash, so changing hook content requires re-trust.
419
+
420
+ Use `/hooks list`, `/hooks inspect <id>`, `/hooks trust <id>`, `/hooks untrust <id>`, and `/hooks disable` to manage them. `/status`, `/security status`, and Web status show pending project hooks that require trust.
391
421
  **Recommended minimal config** — auto-approve all read-only tools to reduce y/N prompts:
392
422
 
393
423
  ```json
package/README.zh-CN.md CHANGED
@@ -370,6 +370,36 @@ HTTPS_PROXY=http://127.0.0.1:10809 aicli
370
370
  }
371
371
  ```
372
372
 
373
+ ### Auto Mode
374
+
375
+ `/auto on|off|status` 会开启会话级规则分类器,用来减少确认疲劳,但不会扩大 `/yolo` 的边界:`/yolo` 仍然只跳过 write 确认,destructive 仍需确认。
376
+
377
+ Auto Mode 可自动通过低风险动作,例如 workspace/temp 根目录内的显式写入、只读 HTTP 工具、非 force 的普通 `git push`、已经写在 `package.json` 或 lockfile 中的依赖安装。它会拒绝 `curl | bash`、force push、疑似 secret 外传;生产部署、数据库迁移、IaC destroy、IAM/token/key/权限变更、第三方 agent loop 默认进入确认。
378
+
379
+ Auto Mode 不会被项目配置静默开启。用 `/permissions recently-denied` 查看最近被 Auto Mode 拒绝的动作,用 `/permissions clear-denied` 清空本会话列表。
380
+ ### 可信 Hooks 生命周期
381
+
382
+ 旧版 `preToolExecution` / `postToolExecution` 仍然兼容。新版生命周期 hooks 配置在 `hooks.events.<EventName>` 下,通过 `AICLI_HOOK_EVENT_JSON` 接收 JSON 事件;命令 stdout 如果输出 JSON,ai-cli 会读取 `allow`、`deny`、`ask`、`warning` 或 `warnings` 等决策。
383
+
384
+ ```json
385
+ {
386
+ "hooks": {
387
+ "events": {
388
+ "PreToolUse": {
389
+ "command": "node ./scripts/aicli-pre-tool-hook.mjs",
390
+ "source": "project",
391
+ "description": "Block unsafe local commands"
392
+ },
393
+ "UserPromptSubmit": "node ./scripts/aicli-prompt-hook.mjs",
394
+ "Stop": { "command": "npm test -- --runInBand", "timeoutMs": 10000 }
395
+ }
396
+ }
397
+ }
398
+ ```
399
+
400
+ 支持的事件包括 `SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PermissionRequest`、`PostToolUse`、`PreCompact`、`PostCompact`、`Stop`、`SubagentStart`、`SubagentStop`。`source: "project"` 的 hook 默认不会执行,必须通过 `/hooks trust <id>` 写入本地信任记录;命令内容变化后 hash 会变化,需要重新信任。
401
+
402
+ 使用 `/hooks list`、`/hooks inspect <id>`、`/hooks trust <id>`、`/hooks untrust <id>`、`/hooks disable` 管理 hooks。`/status`、`/security status` 和 Web 状态栏会显示待信任项目 hooks 数量。
373
403
  ### 环境变量
374
404
 
375
405
  | 变量 | 说明 |
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConfigManager
4
- } from "./chunk-UOROWTGG.js";
4
+ } from "./chunk-MRGWPCFQ.js";
5
5
  import "./chunk-TZQHYZKT.js";
6
- import "./chunk-E5XCM4A6.js";
6
+ import "./chunk-IWLVH32D.js";
7
7
  import {
8
8
  atomicWriteFileSync
9
9
  } from "./chunk-IW3Q7AE5.js";
@@ -5,7 +5,7 @@ import {
5
5
  getChatIndexStatus,
6
6
  loadChatIndex,
7
7
  searchChatMemory
8
- } from "./chunk-W7UKO3PS.js";
8
+ } from "./chunk-OQGVGPEK.js";
9
9
  import "./chunk-JV5N65KN.js";
10
10
  import "./chunk-6BUTA5VW.js";
11
11
  export {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR_NAME
4
- } from "./chunk-E5XCM4A6.js";
4
+ } from "./chunk-IWLVH32D.js";
5
5
  import {
6
6
  atomicWriteFileSync
7
7
  } from "./chunk-IW3Q7AE5.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  truncateForPersist
4
- } from "./chunk-ZOPYREL5.js";
4
+ } from "./chunk-THNECAAY.js";
5
5
  import {
6
6
  APP_NAME,
7
7
  CONFIG_DIR_NAME,
@@ -13,7 +13,7 @@ import {
13
13
  MCP_PROTOCOL_VERSION,
14
14
  MCP_TOOL_PREFIX,
15
15
  VERSION
16
- } from "./chunk-E5XCM4A6.js";
16
+ } from "./chunk-IWLVH32D.js";
17
17
  import {
18
18
  atomicWriteFileSync
19
19
  } from "./chunk-IW3Q7AE5.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CONFIG_DIR_NAME,
4
4
  VERSION
5
- } from "./chunk-E5XCM4A6.js";
5
+ } from "./chunk-IWLVH32D.js";
6
6
 
7
7
  // src/diagnostics/crash-log.ts
8
8
  import {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/core/constants.ts
4
- var VERSION = "0.4.211";
4
+ var VERSION = "0.4.213";
5
5
  var APP_NAME = "ai-cli";
6
6
  var CONFIG_DIR_NAME = ".aicli";
7
7
  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.211";
9
+ var VERSION = "0.4.213";
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 {
8
8
  CONFIG_FILE_NAME,
9
9
  HISTORY_DIR_NAME,
10
10
  PLUGINS_DIR_NAME
11
- } from "./chunk-E5XCM4A6.js";
11
+ } from "./chunk-IWLVH32D.js";
12
12
  import {
13
13
  atomicWriteFileSync
14
14
  } from "./chunk-IW3Q7AE5.js";
@@ -157,10 +157,33 @@ var ConfigSchema = z.object({
157
157
  env: z.record(z.string()).optional(),
158
158
  timeout: z.number().default(3e4)
159
159
  })).default({}),
160
- // 工具执行钩子(shell 命令,模板变量:{tool} {dangerLevel} {args} {status})
160
+ // Hooks 生命周期(v0.4.212+):兼容旧 pre/post 字符串,同时支持 events.<EventName> 结构化 JSON hook。
161
161
  hooks: z.object({
162
+ enabled: z.boolean().default(true),
162
163
  preToolExecution: z.string().optional(),
163
- postToolExecution: z.string().optional()
164
+ postToolExecution: z.string().optional(),
165
+ events: z.record(z.union([
166
+ z.string(),
167
+ z.object({
168
+ command: z.string(),
169
+ source: z.enum(["user", "project", "managed"]).default("user"),
170
+ description: z.string().optional(),
171
+ required: z.boolean().default(false),
172
+ timeoutMs: z.number().int().min(100).max(3e4).default(5e3),
173
+ disabled: z.boolean().default(false)
174
+ }),
175
+ z.array(z.union([
176
+ z.string(),
177
+ z.object({
178
+ command: z.string(),
179
+ source: z.enum(["user", "project", "managed"]).default("user"),
180
+ description: z.string().optional(),
181
+ required: z.boolean().default(false),
182
+ timeoutMs: z.number().int().min(100).max(3e4).default(5e3),
183
+ disabled: z.boolean().default(false)
184
+ })
185
+ ]))
186
+ ])).default({})
164
187
  }).optional(),
165
188
  // 网络访问治理(v0.4.211+):默认关闭以保持兼容;开启后统一治理 web/search/MCP/shell 网络出口。
166
189
  networkPolicy: z.object({
@@ -120,6 +120,10 @@ function redactJson(value, options) {
120
120
  const redacted = walk(value);
121
121
  return { value: redacted, hits: allHits };
122
122
  }
123
+ function scanString(input, options) {
124
+ const { hits } = redactString(input, { ...options, enabled: true });
125
+ return hits;
126
+ }
123
127
 
124
128
  // src/memory/chat-index.ts
125
129
  var MEMORY_DIR_NAME = "memory-index";
@@ -451,6 +455,7 @@ function getChatIndexStatus() {
451
455
 
452
456
  export {
453
457
  redactJson,
458
+ scanString,
454
459
  chunkSession,
455
460
  loadChatIndex,
456
461
  clearChatIndex,