jinzd-ai-cli 0.4.330 → 0.4.331
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-GXITPLER.js → batch-OOHC5POO.js} +2 -2
- package/dist/{chunk-DX2U6QK4.js → chunk-56ME7PB2.js} +1 -1
- package/dist/{chunk-GWEBO4RF.js → chunk-6BGW25LG.js} +1 -1
- package/dist/{chunk-E2W2MI6H.js → chunk-C6GA7H5D.js} +1 -72
- package/dist/{chunk-QU74ONFF.js → chunk-CM5C7ZSM.js} +1 -1
- package/dist/{chunk-3YVZJHTF.js → chunk-DTVN2LDU.js} +1 -1
- package/dist/{chunk-265M6ZLH.js → chunk-EWARNWJ4.js} +4 -4
- package/dist/{chunk-CCFCPAKN.js → chunk-IJNDIOOQ.js} +1 -1
- package/dist/{chunk-LLXHA2LA.js → chunk-L3FDFFD2.js} +8 -8
- package/dist/{chunk-LUJ4JVMI.js → chunk-MJSK6ZYR.js} +4 -4
- package/dist/{chunk-C2Z77RTU.js → chunk-MN25ELTF.js} +15 -4
- package/dist/{chunk-72AR23R2.js → chunk-NOLK5C4U.js} +54 -2
- package/dist/{chunk-HMQA2R3O.js → chunk-Q26V2PNA.js} +1 -1
- package/dist/{chunk-GEC3MEVQ.js → chunk-QFF2PTI3.js} +6 -4
- package/dist/{chunk-2SYDIWRU.js → chunk-R3XIU7NS.js} +1 -1
- package/dist/{chunk-M5B6G6AY.js → chunk-RZDRBFAB.js} +9 -7
- package/dist/{chunk-DU44SD6A.js → chunk-TF2FNRDZ.js} +1 -1
- package/dist/chunk-W4P2KJZN.js +75 -0
- package/dist/{chunk-AJITHMRE.js → chunk-YCDF6FNR.js} +1 -1
- package/dist/{ci-6K3JNHB4.js → ci-HNYUXJUE.js} +7 -6
- package/dist/{ci-format-2L3RFJVH.js → ci-format-ZLBEAU7Z.js} +2 -2
- package/dist/{constants-DLJECTGQ.js → constants-4EH6Y6VI.js} +1 -1
- package/dist/{constants-J5SJ232X.js → constants-JM6MK5SS.js} +1 -1
- package/dist/{doctor-cli-BHS7G2XY.js → doctor-cli-VCNERMX5.js} +7 -6
- package/dist/electron-server.js +193 -130
- package/dist/{hub-PPG4N6QQ.js → hub-3OXLWTEP.js} +8 -18
- package/dist/{hub-server-JLC7CNP7.js → hub-server-LJWXNEWK.js} +2 -1
- package/dist/index.js +20 -19
- package/dist/{persistent-memory-3XTSZ3QR.js → persistent-memory-LMVWIHMX.js} +2 -2
- package/dist/{persistent-memory-O4T2OTVV.js → persistent-memory-PAS7NAPQ.js} +2 -2
- package/dist/{pr-M6ZY4CEK.js → pr-IMR62OHN.js} +7 -6
- package/dist/{run-tests-H3DIUCDB.js → run-tests-2TVEWCQI.js} +2 -2
- package/dist/{run-tests-WQE3XTUL.js → run-tests-MQVGE6FK.js} +2 -2
- package/dist/{server-J2B26DZK.js → server-55X6MCGX.js} +7 -6
- package/dist/{server-5NQSYQ2T.js → server-6MS2NGEJ.js} +29 -19
- package/dist/{task-orchestrator-CI7EDT25.js → task-orchestrator-KIDJB7NP.js} +9 -7
- package/dist/{usage-AJYZ5A7P.js → usage-X2CQYAUA.js} +2 -2
- package/dist/web/client/app.js +19 -0
- package/dist/web/client/app.js.br +0 -0
- package/dist/web/client/app.js.gz +0 -0
- package/package.json +1 -1
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-RS7SKYTS.js";
|
|
5
5
|
import {
|
|
6
6
|
ConfigManager
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CM5C7ZSM.js";
|
|
8
8
|
import "./chunk-TU3L3PW7.js";
|
|
9
9
|
import {
|
|
10
10
|
atomicWriteFileSync
|
|
11
11
|
} from "./chunk-BMLQPSHP.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-YCDF6FNR.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/batch.ts
|
|
15
15
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
MEMORY_FILE_NAME,
|
|
14
14
|
MEMORY_MAX_CHARS,
|
|
15
15
|
MEMORY_STORE_FILE_NAME
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YCDF6FNR.js";
|
|
17
17
|
|
|
18
18
|
// src/memory/persistent-memory.ts
|
|
19
19
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync } from "fs";
|
|
@@ -1270,74 +1270,6 @@ async function runLeanAgentLoop(opts) {
|
|
|
1270
1270
|
return { content, usage, roundsUsed, toolCallCount };
|
|
1271
1271
|
}
|
|
1272
1272
|
|
|
1273
|
-
// src/tools/types.ts
|
|
1274
|
-
function isFileWriteTool(name) {
|
|
1275
|
-
return name === "write_file" || name === "edit_file" || name === "notebook_edit";
|
|
1276
|
-
}
|
|
1277
|
-
function getDangerLevel(toolName, args) {
|
|
1278
|
-
if (toolName.startsWith("mcp__")) {
|
|
1279
|
-
const rawName = toolName.split("__").pop() ?? "";
|
|
1280
|
-
const normalized = rawName.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
1281
|
-
if (/^(read|get|list|search|find|query|fetch|status|describe|inspect|show|lookup)(?:_|$)/.test(normalized)) {
|
|
1282
|
-
return "safe";
|
|
1283
|
-
}
|
|
1284
|
-
return "write";
|
|
1285
|
-
}
|
|
1286
|
-
if (toolName === "bash") {
|
|
1287
|
-
const cmd = String(args["command"] ?? "");
|
|
1288
|
-
if (/\bgit\s+(?:clean\b|reset\s+--hard\b|push\b[^\n]*(?:--force\b|\s-f\b))/i.test(cmd)) return "destructive";
|
|
1289
|
-
if (/\brm\s+[^\n]*(?:-\w*[rRfF]\w*|--recursive|--force)\b/.test(cmd)) return "destructive";
|
|
1290
|
-
if (/\brm\s+\S/.test(cmd)) return "destructive";
|
|
1291
|
-
if (/\brmdir\b|\bmkfs\b|\bdd\s+if=|\bshred\b|\bfdisk\b|\bparted\b/.test(cmd)) return "destructive";
|
|
1292
|
-
if (/(?:^|[;&|(\n]\s*)format(?:\.com)?\s+[A-Za-z]:/im.test(cmd)) return "destructive";
|
|
1293
|
-
if (/\bshutdown\b|\breboot\b|\bhalt\b|\bpoweroff\b/.test(cmd)) return "destructive";
|
|
1294
|
-
if (/\bkill\s+-9\b|\bkillall\b/.test(cmd)) return "destructive";
|
|
1295
|
-
if (/\bRemove-Item\b|\bri\s+\S/i.test(cmd)) return "destructive";
|
|
1296
|
-
if (/\brd\s+\/s\b|\brmdir\s+\/s\b/i.test(cmd)) return "destructive";
|
|
1297
|
-
if (/\bdel\s+\S/.test(cmd)) return "destructive";
|
|
1298
|
-
if (/\bShutdown(-Computer)?\b|\bRestart-Computer\b/i.test(cmd)) return "destructive";
|
|
1299
|
-
if (/(?:^|[\s|;&])>>?\s*\S/.test(cmd)) return "write";
|
|
1300
|
-
if (/\btee\b|\bcp\b|\bmv\b|\bln\s+-s/.test(cmd)) return "write";
|
|
1301
|
-
if (/\bchmod\b|\bchown\b/.test(cmd)) return "write";
|
|
1302
|
-
if (/\bSet-Content\b|\bOut-File\b|\bAdd-Content\b|\bCopy-Item\b|\bMove-Item\b|\bSet-ItemProperty\b|\bNew-ItemProperty\b/i.test(cmd)) return "write";
|
|
1303
|
-
if (/\b(python3?|node|deno|bun|perl|ruby|php|bash|sh|zsh|pwsh|powershell)(\.exe)?\b[^\n]*?\s-(?:Command|EncodedCommand|c|e|p|r)\b/i.test(cmd)) return "write";
|
|
1304
|
-
if (/\bcmd(\.exe)?\s+\/[ck]\b/i.test(cmd)) return "write";
|
|
1305
|
-
if (!/[;&|`$<>\n\r(){}]/.test(cmd) && (/^(?:pwd|ls|cat|head|tail|wc|Get-ChildItem|Get-Location|Get-Content)(?:\s+[\w ./\\:*?=,@'"-]+)?\s*$/i.test(cmd.trim()) || /^echo(?:\s+[\w .,'"-]+)?\s*$/.test(cmd.trim()) || /^(?:node|python3?)\s+(?:-v|--version)\s*$/.test(cmd.trim()) || /^git\s+(?:status|log)(?:\s+(?:--short|--porcelain|--oneline|-\d+))*\s*$/.test(cmd.trim()))) return "safe";
|
|
1306
|
-
return "write";
|
|
1307
|
-
}
|
|
1308
|
-
if (toolName === "run_tests") return "write";
|
|
1309
|
-
if (toolName === "write_file") return "write";
|
|
1310
|
-
if (toolName === "edit_file") return "write";
|
|
1311
|
-
if (toolName === "save_last_response") return "write";
|
|
1312
|
-
if (toolName === "run_interactive") {
|
|
1313
|
-
const exe = String(args["executable"] ?? "").toLowerCase();
|
|
1314
|
-
if (/\b(rm|rmdir|del|format|mkfs|Remove-Item)\b/i.test(exe)) return "destructive";
|
|
1315
|
-
if (/\b(bash|sh|zsh|cmd|powershell|pwsh|python|node|ruby|perl)\b/i.test(exe)) return "write";
|
|
1316
|
-
return "write";
|
|
1317
|
-
}
|
|
1318
|
-
if (toolName === "task_create" || toolName === "task_stop") return "write";
|
|
1319
|
-
if (toolName === "task_list") return "safe";
|
|
1320
|
-
if (toolName === "git_commit") return "write";
|
|
1321
|
-
if (toolName === "git_status" || toolName === "git_diff" || toolName === "git_log") return "safe";
|
|
1322
|
-
if (toolName === "notebook_edit") return "write";
|
|
1323
|
-
if (toolName === "read_file" || toolName === "list_dir" || toolName === "grep_files" || toolName === "glob_files" || toolName === "web_fetch" || toolName === "save_memory" || toolName === "ask_user" || toolName === "write_todos" || toolName === "google_search" || toolName === "spawn_agent") return "safe";
|
|
1324
|
-
return "write";
|
|
1325
|
-
}
|
|
1326
|
-
function schemaToJsonSchema(schema) {
|
|
1327
|
-
const result = {
|
|
1328
|
-
type: schema.type,
|
|
1329
|
-
description: schema.description
|
|
1330
|
-
};
|
|
1331
|
-
if (schema.enum) result["enum"] = schema.enum;
|
|
1332
|
-
if (schema.items) result["items"] = schemaToJsonSchema(schema.items);
|
|
1333
|
-
if (schema.properties) {
|
|
1334
|
-
result["properties"] = Object.fromEntries(
|
|
1335
|
-
Object.entries(schema.properties).map(([k, v]) => [k, schemaToJsonSchema(v)])
|
|
1336
|
-
);
|
|
1337
|
-
}
|
|
1338
|
-
return result;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
1273
|
export {
|
|
1342
1274
|
detectsHallucinatedFileOp,
|
|
1343
1275
|
TOOL_CALL_REMINDER,
|
|
@@ -1360,8 +1292,5 @@ export {
|
|
|
1360
1292
|
accumulateUsage,
|
|
1361
1293
|
buildRoundBudgetHint,
|
|
1362
1294
|
runAgentLoop,
|
|
1363
|
-
runLeanAgentLoop
|
|
1364
|
-
isFileWriteTool,
|
|
1365
|
-
getDangerLevel,
|
|
1366
|
-
schemaToJsonSchema
|
|
1295
|
+
runLeanAgentLoop
|
|
1367
1296
|
};
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
listHooks,
|
|
9
9
|
listInstalledPlugins,
|
|
10
10
|
resetStats
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-Q26V2PNA.js";
|
|
12
12
|
import {
|
|
13
13
|
ProviderRegistry
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-QFF2PTI3.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigManager
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-CM5C7ZSM.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-YCDF6FNR.js";
|
|
30
30
|
|
|
31
31
|
// src/diagnostics/doctor-report.ts
|
|
32
32
|
import { existsSync as existsSync3, statSync as statSync2 } from "fs";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
setPreferredAgentName,
|
|
17
17
|
truncateForPersist,
|
|
18
18
|
undoStack
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RZDRBFAB.js";
|
|
20
20
|
import {
|
|
21
21
|
buildReviewPrompt,
|
|
22
22
|
buildSecurityReviewPrompt
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
touchMemoryReferences,
|
|
52
52
|
updateMemoryApproval,
|
|
53
53
|
updateMemoryEntry
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-56ME7PB2.js";
|
|
55
55
|
import {
|
|
56
56
|
theme
|
|
57
57
|
} from "./chunk-5C76XDDF.js";
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
buildDoctorReport,
|
|
67
67
|
formatDoctorReport
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-EWARNWJ4.js";
|
|
69
69
|
import {
|
|
70
70
|
describePlugin,
|
|
71
71
|
getActivePluginAssets,
|
|
@@ -80,11 +80,11 @@ import {
|
|
|
80
80
|
trustHook,
|
|
81
81
|
trustPlugin,
|
|
82
82
|
untrustHook
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-Q26V2PNA.js";
|
|
84
84
|
import {
|
|
85
85
|
isCleanDocumentBody,
|
|
86
86
|
stripOuterCodeFence
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-C6GA7H5D.js";
|
|
88
88
|
import {
|
|
89
89
|
formatGitContextForPrompt,
|
|
90
90
|
getGitContext
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
MCP_TOOL_PREFIX,
|
|
110
110
|
REPO_URL,
|
|
111
111
|
VERSION
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-YCDF6FNR.js";
|
|
113
113
|
|
|
114
114
|
// src/skills/manager.ts
|
|
115
115
|
import { existsSync, readdirSync, mkdirSync, statSync } from "fs";
|
|
@@ -2445,7 +2445,7 @@ No tools match "${filter}".
|
|
|
2445
2445
|
const { join: join6 } = await import("path");
|
|
2446
2446
|
const { existsSync: existsSync6 } = await import("fs");
|
|
2447
2447
|
const { getGitRoot } = await import("./git-context-EXOEHQSF.js");
|
|
2448
|
-
const { MCP_PROJECT_CONFIG_NAME } = await import("./constants-
|
|
2448
|
+
const { MCP_PROJECT_CONFIG_NAME } = await import("./constants-4EH6Y6VI.js");
|
|
2449
2449
|
const { approveProject, hashMcpFile } = await import("./project-trust-KGG2BWKC.js");
|
|
2450
2450
|
const cwd = process.cwd();
|
|
2451
2451
|
const projectRoot = getGitRoot(cwd) ?? cwd;
|
|
@@ -3553,7 +3553,7 @@ function createReviewCommands() {
|
|
|
3553
3553
|
usage: "/test [command|filter]",
|
|
3554
3554
|
async execute(args, ctx) {
|
|
3555
3555
|
try {
|
|
3556
|
-
const { executeTests } = await import("./run-tests-
|
|
3556
|
+
const { executeTests } = await import("./run-tests-2TVEWCQI.js");
|
|
3557
3557
|
const argStr = args.join(" ").trim();
|
|
3558
3558
|
let testArgs = {};
|
|
3559
3559
|
if (argStr) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
evaluateCiGate,
|
|
4
4
|
normalizeCiThresholds
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-IJNDIOOQ.js";
|
|
6
6
|
import {
|
|
7
7
|
buildReviewPrompt,
|
|
8
8
|
buildSecurityReviewPrompt,
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
} from "./chunk-6YZEZFX5.js";
|
|
14
14
|
import {
|
|
15
15
|
ProviderRegistry
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QFF2PTI3.js";
|
|
17
17
|
import {
|
|
18
18
|
ConfigManager
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CM5C7ZSM.js";
|
|
20
20
|
import {
|
|
21
21
|
VERSION
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-YCDF6FNR.js";
|
|
23
23
|
|
|
24
24
|
// src/cli/ci.ts
|
|
25
25
|
import { execFileSync } from "child_process";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ThinkTagFilter
|
|
4
|
+
} from "./chunk-C6GA7H5D.js";
|
|
2
5
|
|
|
3
6
|
// src/hub/convergence.ts
|
|
4
7
|
function convergenceThreshold(total) {
|
|
@@ -19,8 +22,12 @@ function stripConvergedMarker(content) {
|
|
|
19
22
|
|
|
20
23
|
// src/hub/agent.ts
|
|
21
24
|
var PASS_MARKER = "[PASS]";
|
|
25
|
+
function stripThinkBlocks(raw) {
|
|
26
|
+
const filter = new ThinkTagFilter();
|
|
27
|
+
return filter.push(raw) + filter.flush();
|
|
28
|
+
}
|
|
22
29
|
function parseTurn(raw) {
|
|
23
|
-
const trimmed = raw.trim();
|
|
30
|
+
const trimmed = stripThinkBlocks(raw).trim();
|
|
24
31
|
const upper = trimmed.toUpperCase();
|
|
25
32
|
if (upper.startsWith(PASS_MARKER) || upper === PASS_MARKER) {
|
|
26
33
|
return { content: "", passed: true, converged: false };
|
|
@@ -100,6 +107,7 @@ var HubAgent = class {
|
|
|
100
107
|
const systemPrompt = this.buildSystemPrompt(topic, round, maxRounds, opts?.voteConverge);
|
|
101
108
|
const messages = this.buildMessages(history);
|
|
102
109
|
let raw = "";
|
|
110
|
+
const thinkFilter = new ThinkTagFilter();
|
|
103
111
|
const stream = provider.chatStream({
|
|
104
112
|
messages,
|
|
105
113
|
model: this.modelId,
|
|
@@ -114,13 +122,16 @@ var HubAgent = class {
|
|
|
114
122
|
for await (const chunk of stream) {
|
|
115
123
|
if (chunk.delta) {
|
|
116
124
|
raw += chunk.delta;
|
|
117
|
-
|
|
125
|
+
const visible = thinkFilter.push(chunk.delta);
|
|
126
|
+
if (visible) onToken?.(visible);
|
|
118
127
|
}
|
|
119
128
|
if (opts?.signal?.aborted) break;
|
|
120
129
|
}
|
|
121
130
|
} catch (error) {
|
|
122
131
|
if (!opts?.signal?.aborted) throw error;
|
|
123
132
|
}
|
|
133
|
+
const tail = thinkFilter.flush();
|
|
134
|
+
if (tail) onToken?.(tail);
|
|
124
135
|
const { content, passed, converged } = parseTurn(raw);
|
|
125
136
|
return {
|
|
126
137
|
speaker: this.role.id,
|
|
@@ -155,7 +166,7 @@ var HubAgent = class {
|
|
|
155
166
|
maxTokens: 4096,
|
|
156
167
|
...this.thinking ?? {}
|
|
157
168
|
});
|
|
158
|
-
return response.content.trim();
|
|
169
|
+
return stripThinkBlocks(response.content).trim();
|
|
159
170
|
}
|
|
160
171
|
// ── Private ──────────────────────────────────────────────────────
|
|
161
172
|
buildSystemPrompt(topic, round, maxRounds, voteConverge) {
|
|
@@ -236,7 +247,7 @@ Produce a structured, decision-oriented synthesis with these exact sections:
|
|
|
236
247
|
4. **Action Items** \u2014 concrete next steps as a checklist. For each, suggest which role/expertise should own it, e.g. "- [ ] (\u67B6\u6784\u5E08) \u8BC4\u4F30\u670D\u52A1\u62C6\u5206\u8FB9\u754C".
|
|
237
248
|
5. **Risks & Open Questions** \u2014 unresolved issues and what to watch.
|
|
238
249
|
|
|
239
|
-
Keep it tight (within ~600 words). Use the same language as the discussion.`;
|
|
250
|
+
Keep it tight (within ~600 words). Use the same language as the discussion \u2014 including the section headings (translate them, e.g. \u51B3\u7B56 / \u5EFA\u8BAE\u3001\u5173\u952E\u5171\u8BC6\u3001\u5206\u6B67\u70B9\u3001\u884C\u52A8\u9879\u3001\u98CE\u9669\u4E0E\u5F00\u653E\u95EE\u9898 for a Chinese discussion).`;
|
|
240
251
|
}
|
|
241
252
|
};
|
|
242
253
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HubAgent,
|
|
4
4
|
isConverged
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MN25ELTF.js";
|
|
6
6
|
|
|
7
7
|
// src/hub/discuss.ts
|
|
8
8
|
var DiscussionOrchestrator = class {
|
|
@@ -379,9 +379,61 @@ function resolveRoleProviders(roles, lookup, defaultProvider, defaultModel, avai
|
|
|
379
379
|
return { roles: outRoles, assignments, warnings };
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
// src/hub/custom-presets.ts
|
|
383
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
384
|
+
import { join, basename } from "path";
|
|
385
|
+
var CUSTOM_PRESET_PREFIX = "custom:";
|
|
386
|
+
var HUB_ROLES_DIRNAME = "hub-roles";
|
|
387
|
+
function parseRolesJson(parsed) {
|
|
388
|
+
const rawRoles = Array.isArray(parsed) ? parsed : parsed?.roles;
|
|
389
|
+
if (!Array.isArray(rawRoles) || rawRoles.length === 0) {
|
|
390
|
+
throw new Error("roles must be a non-empty array");
|
|
391
|
+
}
|
|
392
|
+
return rawRoles.map((r) => ({
|
|
393
|
+
id: r.id ?? r.name?.toLowerCase().replace(/\s+/g, "-") ?? "agent",
|
|
394
|
+
name: r.name ?? r.id ?? "Agent",
|
|
395
|
+
persona: r.persona ?? r.description ?? `You are ${r.name ?? "an AI assistant"}.`,
|
|
396
|
+
...r.provider && { provider: r.provider },
|
|
397
|
+
...r.model && { model: r.model },
|
|
398
|
+
...r.color && { color: r.color }
|
|
399
|
+
}));
|
|
400
|
+
}
|
|
401
|
+
function loadCustomPresets(configDir) {
|
|
402
|
+
const dir = join(configDir, HUB_ROLES_DIRNAME);
|
|
403
|
+
const presets = [];
|
|
404
|
+
const warnings = [];
|
|
405
|
+
if (!existsSync(dir)) return { presets, warnings };
|
|
406
|
+
let files;
|
|
407
|
+
try {
|
|
408
|
+
files = readdirSync(dir).filter((f) => f.toLowerCase().endsWith(".json")).sort();
|
|
409
|
+
} catch (err) {
|
|
410
|
+
return { presets, warnings: [`${dir}: ${err.message}`] };
|
|
411
|
+
}
|
|
412
|
+
for (const file of files) {
|
|
413
|
+
const stem = basename(file, file.slice(file.lastIndexOf(".")));
|
|
414
|
+
try {
|
|
415
|
+
const parsed = JSON.parse(readFileSync(join(dir, file), "utf-8").replace(/^/, ""));
|
|
416
|
+
const roles = parseRolesJson(parsed);
|
|
417
|
+
const meta = Array.isArray(parsed) ? {} : parsed;
|
|
418
|
+
presets.push({
|
|
419
|
+
id: `${CUSTOM_PRESET_PREFIX}${stem}`,
|
|
420
|
+
name: typeof meta.name === "string" && meta.name.trim() ? meta.name.trim() : stem,
|
|
421
|
+
description: typeof meta.description === "string" && meta.description.trim() ? meta.description.trim() : roles.map((r) => r.name).join("\xB7"),
|
|
422
|
+
roles
|
|
423
|
+
});
|
|
424
|
+
} catch (err) {
|
|
425
|
+
warnings.push(`${HUB_ROLES_DIRNAME}/${file}: ${err.message}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return { presets, warnings };
|
|
429
|
+
}
|
|
430
|
+
|
|
382
431
|
export {
|
|
383
432
|
DiscussionOrchestrator,
|
|
384
433
|
getPreset,
|
|
385
434
|
listPresets,
|
|
386
|
-
resolveRoleProviders
|
|
435
|
+
resolveRoleProviders,
|
|
436
|
+
CUSTOM_PRESET_PREFIX,
|
|
437
|
+
parseRolesJson,
|
|
438
|
+
loadCustomPresets
|
|
387
439
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
detectsHallucinatedFileOp,
|
|
4
|
-
parseToolCallArguments,
|
|
5
3
|
schemaToJsonSchema
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-W4P2KJZN.js";
|
|
5
|
+
import {
|
|
6
|
+
detectsHallucinatedFileOp,
|
|
7
|
+
parseToolCallArguments
|
|
8
|
+
} from "./chunk-C6GA7H5D.js";
|
|
7
9
|
import {
|
|
8
10
|
AuthError,
|
|
9
11
|
ProviderError,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
} from "./chunk-BMLQPSHP.js";
|
|
16
18
|
import {
|
|
17
19
|
DEFAULT_MAX_TOKENS
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YCDF6FNR.js";
|
|
19
21
|
|
|
20
22
|
// src/providers/claude.ts
|
|
21
23
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
MEMORY_FILE_NAME,
|
|
13
13
|
MEMORY_MAX_CHARS,
|
|
14
14
|
MEMORY_STORE_FILE_NAME
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-DTVN2LDU.js";
|
|
16
16
|
|
|
17
17
|
// src/memory/persistent-memory.ts
|
|
18
18
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync } from "fs";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
searchPersistentMemories,
|
|
12
12
|
touchMemoryReferences,
|
|
13
13
|
updateMemoryEntry
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-56ME7PB2.js";
|
|
15
15
|
import {
|
|
16
16
|
indexProject
|
|
17
17
|
} from "./chunk-RWRZVQCB.js";
|
|
@@ -30,13 +30,15 @@ import {
|
|
|
30
30
|
runHook,
|
|
31
31
|
runLifecycleHooks,
|
|
32
32
|
runTool
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-Q26V2PNA.js";
|
|
34
34
|
import {
|
|
35
|
-
buildTruncatedArgumentsError,
|
|
36
35
|
getDangerLevel,
|
|
37
|
-
isFileWriteTool
|
|
36
|
+
isFileWriteTool
|
|
37
|
+
} from "./chunk-W4P2KJZN.js";
|
|
38
|
+
import {
|
|
39
|
+
buildTruncatedArgumentsError,
|
|
38
40
|
runLeanAgentLoop
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-C6GA7H5D.js";
|
|
40
42
|
import {
|
|
41
43
|
EnvLoader,
|
|
42
44
|
NetworkError,
|
|
@@ -64,7 +66,7 @@ import {
|
|
|
64
66
|
recoverGbkMojibake,
|
|
65
67
|
runTestsTool,
|
|
66
68
|
shellInvocation
|
|
67
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-6BGW25LG.js";
|
|
68
70
|
import {
|
|
69
71
|
CONFIG_DIR_NAME,
|
|
70
72
|
DEFAULT_MAX_TOOL_OUTPUT_CHARS_CAP,
|
|
@@ -73,7 +75,7 @@ import {
|
|
|
73
75
|
SUBAGENT_ALLOWED_TOOLS,
|
|
74
76
|
SUBAGENT_DEFAULT_MAX_ROUNDS,
|
|
75
77
|
SUBAGENT_MAX_ROUNDS_LIMIT
|
|
76
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-YCDF6FNR.js";
|
|
77
79
|
import {
|
|
78
80
|
getCurrentSessionKey,
|
|
79
81
|
getExecutionConfigDir,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/tools/types.ts
|
|
4
|
+
function isFileWriteTool(name) {
|
|
5
|
+
return name === "write_file" || name === "edit_file" || name === "notebook_edit";
|
|
6
|
+
}
|
|
7
|
+
function getDangerLevel(toolName, args) {
|
|
8
|
+
if (toolName.startsWith("mcp__")) {
|
|
9
|
+
const rawName = toolName.split("__").pop() ?? "";
|
|
10
|
+
const normalized = rawName.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
11
|
+
if (/^(read|get|list|search|find|query|fetch|status|describe|inspect|show|lookup)(?:_|$)/.test(normalized)) {
|
|
12
|
+
return "safe";
|
|
13
|
+
}
|
|
14
|
+
return "write";
|
|
15
|
+
}
|
|
16
|
+
if (toolName === "bash") {
|
|
17
|
+
const cmd = String(args["command"] ?? "");
|
|
18
|
+
if (/\bgit\s+(?:clean\b|reset\s+--hard\b|push\b[^\n]*(?:--force\b|\s-f\b))/i.test(cmd)) return "destructive";
|
|
19
|
+
if (/\brm\s+[^\n]*(?:-\w*[rRfF]\w*|--recursive|--force)\b/.test(cmd)) return "destructive";
|
|
20
|
+
if (/\brm\s+\S/.test(cmd)) return "destructive";
|
|
21
|
+
if (/\brmdir\b|\bmkfs\b|\bdd\s+if=|\bshred\b|\bfdisk\b|\bparted\b/.test(cmd)) return "destructive";
|
|
22
|
+
if (/(?:^|[;&|(\n]\s*)format(?:\.com)?\s+[A-Za-z]:/im.test(cmd)) return "destructive";
|
|
23
|
+
if (/\bshutdown\b|\breboot\b|\bhalt\b|\bpoweroff\b/.test(cmd)) return "destructive";
|
|
24
|
+
if (/\bkill\s+-9\b|\bkillall\b/.test(cmd)) return "destructive";
|
|
25
|
+
if (/\bRemove-Item\b|\bri\s+\S/i.test(cmd)) return "destructive";
|
|
26
|
+
if (/\brd\s+\/s\b|\brmdir\s+\/s\b/i.test(cmd)) return "destructive";
|
|
27
|
+
if (/\bdel\s+\S/.test(cmd)) return "destructive";
|
|
28
|
+
if (/\bShutdown(-Computer)?\b|\bRestart-Computer\b/i.test(cmd)) return "destructive";
|
|
29
|
+
if (/(?:^|[\s|;&])>>?\s*\S/.test(cmd)) return "write";
|
|
30
|
+
if (/\btee\b|\bcp\b|\bmv\b|\bln\s+-s/.test(cmd)) return "write";
|
|
31
|
+
if (/\bchmod\b|\bchown\b/.test(cmd)) return "write";
|
|
32
|
+
if (/\bSet-Content\b|\bOut-File\b|\bAdd-Content\b|\bCopy-Item\b|\bMove-Item\b|\bSet-ItemProperty\b|\bNew-ItemProperty\b/i.test(cmd)) return "write";
|
|
33
|
+
if (/\b(python3?|node|deno|bun|perl|ruby|php|bash|sh|zsh|pwsh|powershell)(\.exe)?\b[^\n]*?\s-(?:Command|EncodedCommand|c|e|p|r)\b/i.test(cmd)) return "write";
|
|
34
|
+
if (/\bcmd(\.exe)?\s+\/[ck]\b/i.test(cmd)) return "write";
|
|
35
|
+
if (!/[;&|`$<>\n\r(){}]/.test(cmd) && (/^(?:pwd|ls|cat|head|tail|wc|Get-ChildItem|Get-Location|Get-Content)(?:\s+[\w ./\\:*?=,@'"-]+)?\s*$/i.test(cmd.trim()) || /^echo(?:\s+[\w .,'"-]+)?\s*$/.test(cmd.trim()) || /^(?:node|python3?)\s+(?:-v|--version)\s*$/.test(cmd.trim()) || /^git\s+(?:status|log)(?:\s+(?:--short|--porcelain|--oneline|-\d+))*\s*$/.test(cmd.trim()))) return "safe";
|
|
36
|
+
return "write";
|
|
37
|
+
}
|
|
38
|
+
if (toolName === "run_tests") return "write";
|
|
39
|
+
if (toolName === "write_file") return "write";
|
|
40
|
+
if (toolName === "edit_file") return "write";
|
|
41
|
+
if (toolName === "save_last_response") return "write";
|
|
42
|
+
if (toolName === "run_interactive") {
|
|
43
|
+
const exe = String(args["executable"] ?? "").toLowerCase();
|
|
44
|
+
if (/\b(rm|rmdir|del|format|mkfs|Remove-Item)\b/i.test(exe)) return "destructive";
|
|
45
|
+
if (/\b(bash|sh|zsh|cmd|powershell|pwsh|python|node|ruby|perl)\b/i.test(exe)) return "write";
|
|
46
|
+
return "write";
|
|
47
|
+
}
|
|
48
|
+
if (toolName === "task_create" || toolName === "task_stop") return "write";
|
|
49
|
+
if (toolName === "task_list") return "safe";
|
|
50
|
+
if (toolName === "git_commit") return "write";
|
|
51
|
+
if (toolName === "git_status" || toolName === "git_diff" || toolName === "git_log") return "safe";
|
|
52
|
+
if (toolName === "notebook_edit") return "write";
|
|
53
|
+
if (toolName === "read_file" || toolName === "list_dir" || toolName === "grep_files" || toolName === "glob_files" || toolName === "web_fetch" || toolName === "save_memory" || toolName === "ask_user" || toolName === "write_todos" || toolName === "google_search" || toolName === "spawn_agent") return "safe";
|
|
54
|
+
return "write";
|
|
55
|
+
}
|
|
56
|
+
function schemaToJsonSchema(schema) {
|
|
57
|
+
const result = {
|
|
58
|
+
type: schema.type,
|
|
59
|
+
description: schema.description
|
|
60
|
+
};
|
|
61
|
+
if (schema.enum) result["enum"] = schema.enum;
|
|
62
|
+
if (schema.items) result["items"] = schemaToJsonSchema(schema.items);
|
|
63
|
+
if (schema.properties) {
|
|
64
|
+
result["properties"] = Object.fromEntries(
|
|
65
|
+
Object.entries(schema.properties).map(([k, v]) => [k, schemaToJsonSchema(v)])
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
isFileWriteTool,
|
|
73
|
+
getDangerLevel,
|
|
74
|
+
schemaToJsonSchema
|
|
75
|
+
};
|
|
@@ -3,16 +3,17 @@ import {
|
|
|
3
3
|
CI_COMMENT_MARKER,
|
|
4
4
|
countSeverity,
|
|
5
5
|
runCi
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-MJSK6ZYR.js";
|
|
7
|
+
import "./chunk-IJNDIOOQ.js";
|
|
8
8
|
import "./chunk-HLWUDRBO.js";
|
|
9
9
|
import "./chunk-6YZEZFX5.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-QFF2PTI3.js";
|
|
11
|
+
import "./chunk-CM5C7ZSM.js";
|
|
12
|
+
import "./chunk-W4P2KJZN.js";
|
|
13
|
+
import "./chunk-C6GA7H5D.js";
|
|
13
14
|
import "./chunk-TU3L3PW7.js";
|
|
14
15
|
import "./chunk-BMLQPSHP.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-YCDF6FNR.js";
|
|
16
17
|
export {
|
|
17
18
|
CI_COMMENT_MARKER,
|
|
18
19
|
countSeverity,
|