jinzd-ai-cli 0.4.227 → 0.4.229
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/dist/{batch-W2DJGST7.js → batch-XZHTNJXJ.js} +2 -2
- package/dist/{chunk-DKJ5EFKA.js → chunk-AEXWMIRE.js} +1 -1
- package/dist/{chunk-NBG2STGM.js → chunk-AXIMNQSY.js} +1 -1
- package/dist/{chunk-CYVVWFFO.js → chunk-B3POS7LB.js} +1 -1
- package/dist/{chunk-APBHCIPD.js → chunk-DMF6UHO6.js} +22 -17
- package/dist/{chunk-PUBCJF7E.js → chunk-EEQHP4GK.js} +19 -5
- package/dist/{chunk-6LQ6PUNZ.js → chunk-FEVOW3NQ.js} +31 -31
- package/dist/{chunk-2X2DOHA6.js → chunk-NR5U6LVG.js} +21 -3
- package/dist/{chunk-XPBEJB27.js → chunk-ODYTXQ26.js} +37 -0
- package/dist/{chunk-OMFVR2O7.js → chunk-PQLRX7US.js} +4 -4
- package/dist/{chunk-YK5DDJNH.js → chunk-QCGKCNBX.js} +1 -1
- package/dist/{chunk-WJJIP34H.js → chunk-QFOJ4GXC.js} +4 -4
- package/dist/{chunk-S4AKNVFK.js → chunk-SJ36SUG7.js} +2 -2
- package/dist/{chunk-7X5TVGVY.js → chunk-TEXAIWUJ.js} +1 -1
- package/dist/{chunk-CITDVXXM.js → chunk-YVMACMXW.js} +30 -1
- package/dist/{ci-PEOV2I3Z.js → ci-ZCVDKFXY.js} +6 -6
- package/dist/{ci-format-4O7SHP4F.js → ci-format-CKXDFTN3.js} +2 -2
- package/dist/{constants-HLNS4O5H.js → constants-J2MSGNFA.js} +1 -1
- package/dist/{doctor-cli-LA4AF6DK.js → doctor-cli-3VNTECP2.js} +6 -6
- package/dist/electron-server.js +110 -54
- package/dist/{hub-MAJE7GB7.js → hub-LIH5JEI7.js} +3 -3
- package/dist/{hub-server-XX36DX7O.js → hub-server-XA7HTVLD.js} +1 -1
- package/dist/index.js +21 -21
- package/dist/{pr-CDJFUPZX.js → pr-HY2QCVUY.js} +6 -6
- package/dist/{run-tests-DGV6D4L3.js → run-tests-QVXDTJ3O.js} +1 -1
- package/dist/{run-tests-QFYTNPSV.js → run-tests-WBGQI5V7.js} +2 -2
- package/dist/{server-GTIVGJ6S.js → server-5RXWIX4I.js} +5 -5
- package/dist/{server-ZQYQDQMT.js → server-LYTXYK6Y.js} +15 -15
- package/dist/{task-orchestrator-YSHHXWNT.js → task-orchestrator-FA4KOVD2.js} +7 -6
- package/dist/{usage-QDSXUKN7.js → usage-EHV6YVGH.js} +3 -3
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FEVOW3NQ.js";
|
|
5
5
|
import "./chunk-5ULLIOVC.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-B3POS7LB.js";
|
|
7
7
|
import {
|
|
8
8
|
atomicWriteFileSync
|
|
9
9
|
} from "./chunk-IW3Q7AE5.js";
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
runHook,
|
|
15
15
|
runLifecycleHooks,
|
|
16
16
|
runTool
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TEXAIWUJ.js";
|
|
18
18
|
import {
|
|
19
19
|
getDangerLevel,
|
|
20
20
|
isFileWriteTool,
|
|
21
21
|
runLeanAgentLoop
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ODYTXQ26.js";
|
|
23
23
|
import {
|
|
24
24
|
EnvLoader,
|
|
25
25
|
NetworkError,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
} from "./chunk-4BKXL7SM.js";
|
|
34
34
|
import {
|
|
35
35
|
runTestsTool
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-AEXWMIRE.js";
|
|
37
37
|
import {
|
|
38
38
|
CONFIG_DIR_NAME,
|
|
39
39
|
DEFAULT_MAX_TOOL_OUTPUT_CHARS_CAP,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
SUBAGENT_ALLOWED_TOOLS,
|
|
44
44
|
SUBAGENT_DEFAULT_MAX_ROUNDS,
|
|
45
45
|
SUBAGENT_MAX_ROUNDS_LIMIT
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-B3POS7LB.js";
|
|
47
47
|
import {
|
|
48
48
|
loadChatIndex,
|
|
49
49
|
searchChatMemory
|
|
@@ -558,14 +558,19 @@ Important rules:
|
|
|
558
558
|
);
|
|
559
559
|
}
|
|
560
560
|
if (status !== 0 || timedOut) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
561
|
+
const poolStdout = (stdout ?? "").trim();
|
|
562
|
+
const poolStderr = (stderr ?? "").trim();
|
|
563
|
+
const combined = [poolStdout, poolStderr].filter(Boolean).join("\n");
|
|
564
|
+
const hint = buildErrorHint(command, combined);
|
|
565
|
+
throw new ToolError(
|
|
566
|
+
"bash",
|
|
567
|
+
`Exit code ${status}:
|
|
568
|
+
${combined || `exit ${status}`}
|
|
569
|
+
|
|
570
|
+
` + (hint ? `${hint}
|
|
571
|
+
|
|
572
|
+
` : "") + `[Command failed. Report this error to the user. Do not retry with variant commands.]`
|
|
573
|
+
);
|
|
569
574
|
}
|
|
570
575
|
pushBashUndoEntries(beforeSnapshot, parsedTargetsBefore, effectiveCwd);
|
|
571
576
|
updateCwdFromCommand(command, effectiveCwd);
|
|
@@ -2264,7 +2269,7 @@ var ToolExecutor = class {
|
|
|
2264
2269
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "ok" }, { configDir: this.hookConfigDir });
|
|
2265
2270
|
return { callId: call.id, content, isError: false };
|
|
2266
2271
|
} catch (err) {
|
|
2267
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2272
|
+
const message = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
2268
2273
|
this.printToolResult(call.name, message, true, false);
|
|
2269
2274
|
runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "error" });
|
|
2270
2275
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "error", error: message }, { configDir: this.hookConfigDir });
|
|
@@ -2309,7 +2314,7 @@ var ToolExecutor = class {
|
|
|
2309
2314
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "ok" }, { configDir: this.hookConfigDir });
|
|
2310
2315
|
return { callId: call.id, content, isError: false };
|
|
2311
2316
|
} catch (err) {
|
|
2312
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2317
|
+
const message = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
2313
2318
|
this.printToolResult(call.name, message, true, false);
|
|
2314
2319
|
runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "error" });
|
|
2315
2320
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "error", error: message }, { configDir: this.hookConfigDir });
|
|
@@ -2330,7 +2335,7 @@ var ToolExecutor = class {
|
|
|
2330
2335
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "ok" }, { configDir: this.hookConfigDir });
|
|
2331
2336
|
return { callId: call.id, content, isError: false };
|
|
2332
2337
|
} catch (err) {
|
|
2333
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2338
|
+
const message = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
2334
2339
|
this.printToolResult(call.name, message, true, false);
|
|
2335
2340
|
runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "error" });
|
|
2336
2341
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "error", error: message }, { configDir: this.hookConfigDir });
|
|
@@ -2370,7 +2375,7 @@ var ToolExecutor = class {
|
|
|
2370
2375
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "ok" }, { configDir: this.hookConfigDir });
|
|
2371
2376
|
return { callId: call.id, content, isError: false };
|
|
2372
2377
|
} catch (err) {
|
|
2373
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2378
|
+
const message = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
2374
2379
|
this.printToolResult(call.name, message, true, false);
|
|
2375
2380
|
runHook(this.hookConfig?.postToolExecution, { tool: call.name, status: "error" });
|
|
2376
2381
|
runLifecycleHooks(this.hookConfig, "PostToolUse", { tool: call.name, status: "error", error: message }, { configDir: this.hookConfigDir });
|
|
@@ -2456,7 +2461,7 @@ var ToolExecutor = class {
|
|
|
2456
2461
|
this.printToolResult(call.name, rawContent, false, wasTruncated);
|
|
2457
2462
|
results[i] = { callId: call.id, content, isError: false };
|
|
2458
2463
|
} catch (err) {
|
|
2459
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2464
|
+
const message = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
2460
2465
|
this.printToolResult(call.name, message, true, false);
|
|
2461
2466
|
results[i] = { callId: call.id, content: message, isError: true };
|
|
2462
2467
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
detectsHallucinatedFileOp,
|
|
4
4
|
repairToolCallArguments,
|
|
5
5
|
schemaToJsonSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ODYTXQ26.js";
|
|
7
7
|
import {
|
|
8
8
|
AuthError,
|
|
9
9
|
ProviderError,
|
|
@@ -2250,18 +2250,32 @@ var ProviderRegistry = class {
|
|
|
2250
2250
|
configDir;
|
|
2251
2251
|
async initialize(getApiKey, getOptions, customProviderConfigs, configDir) {
|
|
2252
2252
|
this.configDir = configDir;
|
|
2253
|
-
|
|
2253
|
+
const initTasks = BUILT_IN_PROVIDERS.map(async (ProviderClass) => {
|
|
2254
2254
|
const provider = new ProviderClass();
|
|
2255
2255
|
const apiKey = getApiKey(provider.info.id);
|
|
2256
2256
|
if (apiKey || !provider.info.requiresApiKey) {
|
|
2257
2257
|
const options = getOptions?.(provider.info.id) ?? {};
|
|
2258
|
+
const pInit = provider.initialize(apiKey ?? "", options);
|
|
2259
|
+
return { provider, pInit, requiresApiKey: !!provider.info.requiresApiKey };
|
|
2260
|
+
}
|
|
2261
|
+
return null;
|
|
2262
|
+
});
|
|
2263
|
+
const settled = await Promise.allSettled(
|
|
2264
|
+
initTasks.map(async (task) => {
|
|
2265
|
+
const result = await task;
|
|
2266
|
+
if (!result) return;
|
|
2267
|
+
const { provider, pInit, requiresApiKey } = result;
|
|
2258
2268
|
try {
|
|
2259
|
-
await
|
|
2269
|
+
await pInit;
|
|
2260
2270
|
this.providers.set(provider.info.id, provider);
|
|
2261
2271
|
} catch (err) {
|
|
2262
|
-
if (
|
|
2272
|
+
if (requiresApiKey) throw err;
|
|
2263
2273
|
}
|
|
2264
|
-
}
|
|
2274
|
+
})
|
|
2275
|
+
);
|
|
2276
|
+
const keyErrors = settled.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
2277
|
+
if (keyErrors.length > 0) {
|
|
2278
|
+
throw keyErrors[0];
|
|
2265
2279
|
}
|
|
2266
2280
|
this.customConfigs = customProviderConfigs ?? [];
|
|
2267
2281
|
for (const cfg of this.customConfigs) {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
CONFIG_FILE_NAME,
|
|
9
9
|
HISTORY_DIR_NAME,
|
|
10
10
|
PLUGINS_DIR_NAME
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-B3POS7LB.js";
|
|
12
12
|
import {
|
|
13
13
|
atomicWriteFileSync
|
|
14
14
|
} from "./chunk-IW3Q7AE5.js";
|
|
@@ -21,22 +21,22 @@ import { homedir } from "os";
|
|
|
21
21
|
// src/config/schema.ts
|
|
22
22
|
import { z } from "zod";
|
|
23
23
|
var CustomModelSchema = z.object({
|
|
24
|
-
id: z.string(),
|
|
25
|
-
displayName: z.string().optional(),
|
|
24
|
+
id: z.string().max(100),
|
|
25
|
+
displayName: z.string().max(200).optional(),
|
|
26
26
|
contextWindow: z.number().optional()
|
|
27
27
|
});
|
|
28
28
|
var CustomProviderConfigSchema = z.object({
|
|
29
|
-
id: z.string(),
|
|
29
|
+
id: z.string().max(100),
|
|
30
30
|
// 唯一 ID,不能与内置 provider 重名
|
|
31
|
-
displayName: z.string(),
|
|
31
|
+
displayName: z.string().max(200),
|
|
32
32
|
// 显示名称
|
|
33
|
-
apiKey: z.string().optional(),
|
|
33
|
+
apiKey: z.string().max(4e3).optional(),
|
|
34
34
|
// 可选:直接在此写 key(也可通过 apiKeys 字段或环境变量提供)
|
|
35
|
-
baseUrl: z.string(),
|
|
35
|
+
baseUrl: z.string().max(2e3),
|
|
36
36
|
// OpenAI 兼容 API 的 base URL(必填)
|
|
37
|
-
defaultModel: z.string(),
|
|
37
|
+
defaultModel: z.string().max(200),
|
|
38
38
|
// 默认使用的模型 ID
|
|
39
|
-
models: z.array(CustomModelSchema).default([]),
|
|
39
|
+
models: z.array(CustomModelSchema).max(100).default([]),
|
|
40
40
|
timeout: z.number().optional()
|
|
41
41
|
// 请求超时(ms),覆盖全局默认值
|
|
42
42
|
});
|
|
@@ -51,19 +51,19 @@ var ModelParamsSchema = z.object({
|
|
|
51
51
|
});
|
|
52
52
|
var UserProfileSchema = z.object({
|
|
53
53
|
/** 真实姓名(如 "Jin Zhengdong") */
|
|
54
|
-
name: z.string().optional(),
|
|
54
|
+
name: z.string().max(100).optional(),
|
|
55
55
|
/** 昵称/称呼偏好(如 "东叔"),AI 会以此称呼你 */
|
|
56
|
-
nickname: z.string().optional(),
|
|
56
|
+
nickname: z.string().max(100).optional(),
|
|
57
57
|
/** 职业角色(如 "Full-stack developer"、"Data scientist") */
|
|
58
|
-
role: z.string().optional(),
|
|
58
|
+
role: z.string().max(200).optional(),
|
|
59
59
|
/** 个人简介 / 专长描述(1-3 句话) */
|
|
60
|
-
bio: z.string().optional(),
|
|
60
|
+
bio: z.string().max(1e4).optional(),
|
|
61
61
|
/** 兴趣领域或技术栈(如 ["TypeScript", "Rust", "AI/ML"]) */
|
|
62
|
-
interests: z.array(z.string()).default([]),
|
|
62
|
+
interests: z.array(z.string()).max(100).default([]),
|
|
63
63
|
/** 语言偏好(如 "zh-CN"、"en"),AI 将据此选择交流语言 */
|
|
64
|
-
locale: z.string().optional(),
|
|
64
|
+
locale: z.string().max(20).optional(),
|
|
65
65
|
/** 自定义人设补充(自由格式,直接注入 system prompt) */
|
|
66
|
-
extra: z.string().optional()
|
|
66
|
+
extra: z.string().max(5e3).optional()
|
|
67
67
|
}).default({});
|
|
68
68
|
var ConfigSchema = z.object({
|
|
69
69
|
version: z.string().default("1.0.0"),
|
|
@@ -85,7 +85,7 @@ var ConfigSchema = z.object({
|
|
|
85
85
|
// HTTP/HTTPS 代理地址(Node.js 不自动使用系统代理,需显式配置)
|
|
86
86
|
// 例:http://127.0.0.1:10809
|
|
87
87
|
// 也可通过环境变量 HTTPS_PROXY / HTTP_PROXY 覆盖
|
|
88
|
-
proxy: z.string().optional(),
|
|
88
|
+
proxy: z.string().max(500).optional(),
|
|
89
89
|
// 自定义 Provider 列表(OpenAI 兼容接口,无需改代码)
|
|
90
90
|
customProviders: z.array(CustomProviderConfigSchema).default([]),
|
|
91
91
|
// 按模型 ID 存储的推理参数(key 为模型 ID,如 "deepseek-chat")
|
|
@@ -119,7 +119,7 @@ var ConfigSchema = z.object({
|
|
|
119
119
|
session: z.object({
|
|
120
120
|
autoSave: z.boolean().default(true),
|
|
121
121
|
maxHistoryDays: z.number().default(30),
|
|
122
|
-
systemPrompt: z.string().optional()
|
|
122
|
+
systemPrompt: z.string().max(1e5).optional()
|
|
123
123
|
}).default({}),
|
|
124
124
|
// 项目上下文文件配置
|
|
125
125
|
// 启动时自动读取并注入 system prompt,类似 Claude Code 的 CLAUDE.md / Codex AGENTS.md 机制
|
|
@@ -127,14 +127,14 @@ var ConfigSchema = z.object({
|
|
|
127
127
|
// 设为 false 可禁用此功能;指定字符串时仅加载 cwd 下的该文件
|
|
128
128
|
contextFile: z.union([z.string(), z.literal(false)]).default("auto"),
|
|
129
129
|
context: z.object({
|
|
130
|
-
projectDocFallbackFilenames: z.array(z.string()).default([]),
|
|
130
|
+
projectDocFallbackFilenames: z.array(z.string().max(500)).max(20).default([]),
|
|
131
131
|
projectDocMaxBytes: z.number().int().positive().default(32 * 1024),
|
|
132
132
|
showLoadedContextSources: z.boolean().default(false)
|
|
133
133
|
}).default({}),
|
|
134
134
|
// Google Custom Search API 的 Search Engine ID (cx 参数)
|
|
135
135
|
// API Key 通过 apiKeys['google-search'] 或 AICLI_API_KEY_GOOGLESEARCH 环境变量配置
|
|
136
136
|
// CX 也可通过 AICLI_GOOGLE_CX 环境变量覆盖
|
|
137
|
-
googleSearchEngineId: z.string().optional(),
|
|
137
|
+
googleSearchEngineId: z.string().max(200).optional(),
|
|
138
138
|
// google_search 工具的安全开关(v0.4.135+)
|
|
139
139
|
// 默认 disabled。这个工具调用 Google Custom Search API,没有原生 daily-spend cap——
|
|
140
140
|
// 业内有多起 key 被盗后产生数万美元账单的真实案例。现在内置 web_search 工具走 Bing/Google
|
|
@@ -152,10 +152,10 @@ var ConfigSchema = z.object({
|
|
|
152
152
|
// 配置格式兼容 Claude Desktop(command + args + env)
|
|
153
153
|
// 示例:{ "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"] } }
|
|
154
154
|
mcpServers: z.record(z.object({
|
|
155
|
-
command: z.string(),
|
|
156
|
-
args: z.array(z.string()).default([]),
|
|
155
|
+
command: z.string().max(500),
|
|
156
|
+
args: z.array(z.string()).max(100).default([]),
|
|
157
157
|
env: z.record(z.string()).optional(),
|
|
158
|
-
timeout: z.number().default(3e4)
|
|
158
|
+
timeout: z.number().int().min(100).max(3e5).default(3e4)
|
|
159
159
|
})).default({}),
|
|
160
160
|
// Hooks 生命周期(v0.4.212+):兼容旧 pre/post 字符串,同时支持 events.<EventName> 结构化 JSON hook。
|
|
161
161
|
hooks: z.object({
|
|
@@ -189,8 +189,8 @@ var ConfigSchema = z.object({
|
|
|
189
189
|
networkPolicy: z.object({
|
|
190
190
|
enabled: z.boolean().default(false),
|
|
191
191
|
defaultAction: z.enum(["allow", "confirm", "deny"]).default("confirm"),
|
|
192
|
-
allowDomains: z.array(z.string()).default([]),
|
|
193
|
-
denyDomains: z.array(z.string()).default([]),
|
|
192
|
+
allowDomains: z.array(z.string().max(500)).max(100).default([]),
|
|
193
|
+
denyDomains: z.array(z.string().max(500)).max(100).default([]),
|
|
194
194
|
allowPorts: z.array(z.number().int().min(1).max(65535)).default([]),
|
|
195
195
|
denyPorts: z.array(z.number().int().min(1).max(65535)).default([]),
|
|
196
196
|
allowPrivateNetwork: z.boolean().default(false),
|
|
@@ -204,7 +204,7 @@ var ConfigSchema = z.object({
|
|
|
204
204
|
}).default({ enabled: false, defaultAction: "confirm", allowDomains: [], denyDomains: [], allowPorts: [], denyPorts: [], allowPrivateNetwork: false, tools: {} }),
|
|
205
205
|
// 权限 Profile(v0.4.211+):legacy 保持旧行为;其余 profile 提供更清晰的安全边界。
|
|
206
206
|
defaultPermissionProfile: z.enum(["legacy", "read-only", "workspace-write", "danger-full-access"]).default("legacy"),
|
|
207
|
-
allowedPermissionProfiles: z.array(z.string()).default(["legacy", "read-only", "workspace-write", "danger-full-access"]),
|
|
207
|
+
allowedPermissionProfiles: z.array(z.string().max(50)).max(20).default(["legacy", "read-only", "workspace-write", "danger-full-access"]),
|
|
208
208
|
permissionProfiles: z.record(z.object({
|
|
209
209
|
extends: z.enum(["legacy", "read-only", "workspace-write", "danger-full-access"]).optional(),
|
|
210
210
|
defaultAction: z.enum(["auto-approve", "deny", "confirm"]).optional(),
|
|
@@ -221,7 +221,7 @@ var ConfigSchema = z.object({
|
|
|
221
221
|
})).default({}),
|
|
222
222
|
// 工具权限规则(按顺序匹配第一个生效;作为当前权限 Profile 内的细粒度规则)
|
|
223
223
|
permissionRules: z.array(z.object({
|
|
224
|
-
tool: z.string(),
|
|
224
|
+
tool: z.string().max(100),
|
|
225
225
|
action: z.enum(["auto-approve", "deny", "confirm"]),
|
|
226
226
|
when: z.object({
|
|
227
227
|
dangerLevel: z.enum(["safe", "write", "destructive"]).optional(),
|
|
@@ -279,7 +279,7 @@ var ConfigSchema = z.object({
|
|
|
279
279
|
redactOnSave: z.boolean().default(true),
|
|
280
280
|
redactOnSend: z.boolean().default(false),
|
|
281
281
|
mode: z.enum(["default", "strict", "off"]).default("default"),
|
|
282
|
-
customPatterns: z.array(z.string()).default([])
|
|
282
|
+
customPatterns: z.array(z.string().max(200)).max(50).default([])
|
|
283
283
|
}).default({}),
|
|
284
284
|
// 智能模型路由(v0.4.68+)
|
|
285
285
|
// 按用户每轮输入的内容/标签/长度动态选择模型,在同一 provider 内切换,
|
|
@@ -291,13 +291,13 @@ var ConfigSchema = z.object({
|
|
|
291
291
|
enabled: z.boolean().default(false),
|
|
292
292
|
rules: z.array(z.object({
|
|
293
293
|
match: z.object({
|
|
294
|
-
contains: z.array(z.string()).optional(),
|
|
294
|
+
contains: z.array(z.string().max(200)).max(50).optional(),
|
|
295
295
|
maxLength: z.number().int().positive().optional(),
|
|
296
296
|
minLength: z.number().int().positive().optional(),
|
|
297
297
|
tag: z.string().optional()
|
|
298
298
|
}),
|
|
299
299
|
model: z.string(),
|
|
300
|
-
name: z.string().optional()
|
|
300
|
+
name: z.string().max(100).optional()
|
|
301
301
|
})).default([]),
|
|
302
302
|
fallback: z.string().optional()
|
|
303
303
|
}).default({ enabled: false, rules: [] }),
|
|
@@ -317,7 +317,7 @@ var ConfigSchema = z.object({
|
|
|
317
317
|
maxBackoffMs: z.number().int().positive().default(8e3),
|
|
318
318
|
/** 兜底 provider 链,每个 entry 仅尝试 1 次。model 省略则使用 provider 的 defaultModel。 */
|
|
319
319
|
chain: z.array(z.object({
|
|
320
|
-
provider: z.string(),
|
|
320
|
+
provider: z.string().max(100),
|
|
321
321
|
model: z.string().optional()
|
|
322
322
|
})).default([])
|
|
323
323
|
}).default({ enabled: false, retries: 2, initialBackoffMs: 500, maxBackoffMs: 8e3, chain: [] })
|
|
@@ -14,13 +14,31 @@ var ROLE_COLORS = [
|
|
|
14
14
|
chalk.rgb(148, 103, 189)
|
|
15
15
|
// purple
|
|
16
16
|
];
|
|
17
|
+
var CHALK_COLOR_NAMES = {
|
|
18
|
+
red: chalk.red,
|
|
19
|
+
green: chalk.green,
|
|
20
|
+
blue: chalk.blue,
|
|
21
|
+
yellow: chalk.yellow,
|
|
22
|
+
magenta: chalk.magenta,
|
|
23
|
+
cyan: chalk.cyan,
|
|
24
|
+
white: chalk.white,
|
|
25
|
+
gray: chalk.gray,
|
|
26
|
+
grey: chalk.grey,
|
|
27
|
+
black: chalk.black,
|
|
28
|
+
redBright: chalk.redBright,
|
|
29
|
+
greenBright: chalk.greenBright,
|
|
30
|
+
blueBright: chalk.blueBright,
|
|
31
|
+
yellowBright: chalk.yellowBright,
|
|
32
|
+
magentaBright: chalk.magentaBright,
|
|
33
|
+
cyanBright: chalk.cyanBright,
|
|
34
|
+
whiteBright: chalk.whiteBright
|
|
35
|
+
};
|
|
17
36
|
var colorMap = /* @__PURE__ */ new Map();
|
|
18
37
|
function assignRoleColors(roles) {
|
|
19
38
|
colorMap.clear();
|
|
20
|
-
const chalkColors = chalk;
|
|
21
39
|
roles.forEach((role, i) => {
|
|
22
|
-
if (role.color &&
|
|
23
|
-
colorMap.set(role.id,
|
|
40
|
+
if (role.color && CHALK_COLOR_NAMES[role.color]) {
|
|
41
|
+
colorMap.set(role.id, CHALK_COLOR_NAMES[role.color]);
|
|
24
42
|
} else {
|
|
25
43
|
colorMap.set(role.id, ROLE_COLORS[i % ROLE_COLORS.length]);
|
|
26
44
|
}
|
|
@@ -99,7 +99,44 @@ var HALLUCINATION_PATTERNS = [
|
|
|
99
99
|
// “以下是图片的内容:”“以下是修改后的内容:”这类描述/对话。
|
|
100
100
|
/以下是[^\n。.!!??]*?(?:教案|试卷|讲义|课件|课程|文件|文档|脚本|配置|程序|报告|表格|清单)[^\n。.!!??]{0,8}(?:内容)?[::]/
|
|
101
101
|
];
|
|
102
|
+
var QUICK_WRITE_KEYWORDS = [
|
|
103
|
+
// 中文写入动作
|
|
104
|
+
"\u5DF2\u4FDD\u5B58",
|
|
105
|
+
"\u5DF2\u5199\u5165",
|
|
106
|
+
"\u5DF2\u521B\u5EFA",
|
|
107
|
+
"\u5DF2\u751F\u6210",
|
|
108
|
+
"\u751F\u6210\u5B8C\u6210",
|
|
109
|
+
"\u4FDD\u5B58",
|
|
110
|
+
"\u5199\u5165",
|
|
111
|
+
"\u521B\u5EFA",
|
|
112
|
+
"\u751F\u6210",
|
|
113
|
+
// 中文文档名
|
|
114
|
+
"\u6587\u4EF6",
|
|
115
|
+
"\u6559\u6848",
|
|
116
|
+
"\u8BD5\u5377",
|
|
117
|
+
"\u8BB2\u4E49",
|
|
118
|
+
"\u8BFE\u4EF6",
|
|
119
|
+
"\u6587\u6863",
|
|
120
|
+
"\u811A\u672C",
|
|
121
|
+
"\u914D\u7F6E",
|
|
122
|
+
"\u7A0B\u5E8F",
|
|
123
|
+
"\u62A5\u544A",
|
|
124
|
+
"\u8868\u683C",
|
|
125
|
+
"\u6E05\u5355",
|
|
126
|
+
"\u7B14\u8BB0",
|
|
127
|
+
// 英文写入动作
|
|
128
|
+
"saved",
|
|
129
|
+
"written",
|
|
130
|
+
"created",
|
|
131
|
+
"File",
|
|
132
|
+
"file",
|
|
133
|
+
// emoji 勾选标记
|
|
134
|
+
"\u2705"
|
|
135
|
+
];
|
|
102
136
|
function detectsHallucinatedFileOp(content) {
|
|
137
|
+
if (!QUICK_WRITE_KEYWORDS.some((kw) => content.includes(kw))) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
103
140
|
return HALLUCINATION_PATTERNS.some((pattern) => pattern.test(content));
|
|
104
141
|
}
|
|
105
142
|
function hadPreviousWriteToolCalls(extraMessages) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
evaluateCiGate,
|
|
4
4
|
normalizeCiThresholds
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AXIMNQSY.js";
|
|
6
6
|
import {
|
|
7
7
|
buildReviewPrompt,
|
|
8
8
|
buildSecurityReviewPrompt,
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
} from "./chunk-HLWUDRBO.js";
|
|
11
11
|
import {
|
|
12
12
|
ProviderRegistry
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-EEQHP4GK.js";
|
|
14
14
|
import {
|
|
15
15
|
ConfigManager
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FEVOW3NQ.js";
|
|
17
17
|
import {
|
|
18
18
|
VERSION
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-B3POS7LB.js";
|
|
20
20
|
|
|
21
21
|
// src/cli/ci.ts
|
|
22
22
|
import { execFileSync } from "child_process";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ProviderRegistry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EEQHP4GK.js";
|
|
5
5
|
import {
|
|
6
6
|
getActivePluginAssets,
|
|
7
7
|
getPendingHookTrust,
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
listHooks,
|
|
12
12
|
listInstalledPlugins,
|
|
13
13
|
resetStats
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TEXAIWUJ.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigManager
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-FEVOW3NQ.js";
|
|
18
18
|
import {
|
|
19
19
|
getGitRoot
|
|
20
20
|
} from "./chunk-HOSJZMQS.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
MCP_PROJECT_CONFIG_NAME,
|
|
27
27
|
MEMORY_FILE_NAME,
|
|
28
28
|
VERSION
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-B3POS7LB.js";
|
|
30
30
|
|
|
31
31
|
// src/diagnostics/doctor-report.ts
|
|
32
32
|
import { existsSync as existsSync3, statSync as statSync2 } from "fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
truncateForPersist
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DMF6UHO6.js";
|
|
5
5
|
import {
|
|
6
6
|
APP_NAME,
|
|
7
7
|
CONFIG_DIR_NAME,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
MCP_PROTOCOL_VERSION,
|
|
12
12
|
MCP_TOOL_PREFIX,
|
|
13
13
|
VERSION
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-B3POS7LB.js";
|
|
15
15
|
import {
|
|
16
16
|
atomicWriteFileSync
|
|
17
17
|
} from "./chunk-IW3Q7AE5.js";
|
|
@@ -10,14 +10,18 @@ import {
|
|
|
10
10
|
// src/core/cost-tracker.ts
|
|
11
11
|
import { existsSync, readFileSync } from "fs";
|
|
12
12
|
import { join } from "path";
|
|
13
|
-
var CostTracker = class {
|
|
13
|
+
var CostTracker = class _CostTracker {
|
|
14
14
|
filePath;
|
|
15
15
|
records = [];
|
|
16
16
|
dirty = false;
|
|
17
|
+
/** P2-PERF-04: debounce timer to batch rapid addCost() calls into a single save. */
|
|
18
|
+
_saveTimer;
|
|
17
19
|
constructor(configDir) {
|
|
18
20
|
this.filePath = join(configDir, "cost-history.json");
|
|
19
21
|
this.load();
|
|
20
22
|
}
|
|
23
|
+
/** P2-PERF-04: debounce interval (ms) — coalesces multiple rapid addCost calls. */
|
|
24
|
+
static SAVE_DEBOUNCE_MS = 2e3;
|
|
21
25
|
load() {
|
|
22
26
|
try {
|
|
23
27
|
if (existsSync(this.filePath)) {
|
|
@@ -42,6 +46,10 @@ var CostTracker = class {
|
|
|
42
46
|
*/
|
|
43
47
|
save() {
|
|
44
48
|
if (!this.dirty) return;
|
|
49
|
+
if (this._saveTimer) {
|
|
50
|
+
clearTimeout(this._saveTimer);
|
|
51
|
+
this._saveTimer = void 0;
|
|
52
|
+
}
|
|
45
53
|
const snapshot = {
|
|
46
54
|
version: 1,
|
|
47
55
|
records: [...this.records]
|
|
@@ -81,6 +89,15 @@ var CostTracker = class {
|
|
|
81
89
|
m.cacheReadTokens += usage.cacheReadTokens ?? 0;
|
|
82
90
|
m.calls += 1;
|
|
83
91
|
this.dirty = true;
|
|
92
|
+
if (!this._saveTimer) {
|
|
93
|
+
this._saveTimer = setTimeout(() => {
|
|
94
|
+
this._saveTimer = void 0;
|
|
95
|
+
this.save();
|
|
96
|
+
}, _CostTracker.SAVE_DEBOUNCE_MS);
|
|
97
|
+
if (this._saveTimer && typeof this._saveTimer === "object" && "unref" in this._saveTimer) {
|
|
98
|
+
this._saveTimer.unref();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
84
101
|
if (this.records.length > 90) {
|
|
85
102
|
this.records = this.records.slice(-90);
|
|
86
103
|
}
|
|
@@ -222,6 +239,18 @@ var CostTracker = class {
|
|
|
222
239
|
lines.push(`Last 7 days: ${last7.join(" ")}`);
|
|
223
240
|
return lines.join("\n");
|
|
224
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* P2-PERF-04: flush pending cost records to disk immediately.
|
|
244
|
+
* Call this before process exit or before reading cost data for display
|
|
245
|
+
* to ensure the in-memory buffer is reflected on disk.
|
|
246
|
+
*/
|
|
247
|
+
flush() {
|
|
248
|
+
if (this._saveTimer) {
|
|
249
|
+
clearTimeout(this._saveTimer);
|
|
250
|
+
this._saveTimer = void 0;
|
|
251
|
+
}
|
|
252
|
+
this.save();
|
|
253
|
+
}
|
|
225
254
|
};
|
|
226
255
|
|
|
227
256
|
export {
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
CI_COMMENT_MARKER,
|
|
4
4
|
countSeverity,
|
|
5
5
|
runCi
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-PQLRX7US.js";
|
|
7
|
+
import "./chunk-AXIMNQSY.js";
|
|
8
8
|
import "./chunk-HLWUDRBO.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EEQHP4GK.js";
|
|
10
|
+
import "./chunk-ODYTXQ26.js";
|
|
11
|
+
import "./chunk-FEVOW3NQ.js";
|
|
12
12
|
import "./chunk-5ULLIOVC.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-B3POS7LB.js";
|
|
14
14
|
import "./chunk-IW3Q7AE5.js";
|
|
15
15
|
export {
|
|
16
16
|
CI_COMMENT_MARKER,
|