@wrongstack/tools 0.320.1 → 1.0.1
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/_danger-detect.d.ts +8 -0
- package/dist/_syntax-check.d.ts +1 -2
- package/dist/audit.d.ts +4 -5
- package/dist/audit.js +6 -6
- package/dist/auto-proceed-loop-guard.d.ts +1 -1
- package/dist/auto-proceed-loop-guard.js +9 -160
- package/dist/bash-kill-guard.d.ts +2 -3
- package/dist/bash.d.ts +2 -3
- package/dist/bash.js +4 -4
- package/dist/batch-tool-use.d.ts +2 -3
- package/dist/batch-tool-use.js +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tools.d.ts +56 -45
- package/dist/builtin.js +50 -50
- package/dist/{chunk-T77XOX7E.js → chunk-24T5XIJU.js} +1 -1
- package/dist/{chunk-DTQ75VBC.js → chunk-2CTZW6JQ.js} +2 -2
- package/dist/{chunk-KWXIKGE3.js → chunk-3D5DJWOE.js} +3 -3
- package/dist/{chunk-XSSFBS5I.js → chunk-4ERMPDHV.js} +11 -6
- package/dist/{chunk-QSNVDHOZ.js → chunk-4WPBS45A.js} +4 -5
- package/dist/{chunk-4CQWNZ62.js → chunk-5ITQPCLC.js} +2 -2
- package/dist/{chunk-B4HTSV6Z.js → chunk-5KS24LTS.js} +11 -11
- package/dist/{chunk-QPNYDH5B.js → chunk-62OAECEQ.js} +29 -7
- package/dist/{chunk-DFQDJT22.js → chunk-6GOZTS6F.js} +3 -3
- package/dist/{chunk-5UFVCIUB.js → chunk-6H4ERJP7.js} +140 -24
- package/dist/{chunk-34VLZ35Z.js → chunk-7HL23T3T.js} +63 -10
- package/dist/{chunk-HFXSNKCV.js → chunk-7JJFC6CT.js} +1 -1
- package/dist/{chunk-23EX5WDO.js → chunk-7LQCT3LT.js} +3 -3
- package/dist/{chunk-NDIT3SBZ.js → chunk-7N5U2RAU.js} +2 -2
- package/dist/{chunk-QBV725YG.js → chunk-7ODZTPCU.js} +2 -2
- package/dist/{chunk-6AAOT4PW.js → chunk-AQ5YBURX.js} +16 -4
- package/dist/{chunk-ZMW6WJFT.js → chunk-ASEXQRA7.js} +3 -3
- package/dist/{chunk-FRN7TIAA.js → chunk-B3MGJBFI.js} +1 -1
- package/dist/{chunk-JLYA4X7K.js → chunk-CGXTR34H.js} +21 -6
- package/dist/{chunk-IU4DV2PA.js → chunk-CHEK3ASV.js} +6 -3
- package/dist/{chunk-GOIZNNOA.js → chunk-DJYLI7EW.js} +1 -1
- package/dist/{chunk-Z6IHMJMC.js → chunk-DK4J2WMH.js} +11 -11
- package/dist/{chunk-OYP27E3I.js → chunk-DRRY6SCM.js} +47 -20
- package/dist/{chunk-JVRLTEO7.js → chunk-E7JE3UEX.js} +2 -2
- package/dist/{chunk-BK732J7I.js → chunk-FBUP524S.js} +4 -4
- package/dist/{chunk-NYRLWDT5.js → chunk-FVM3O4JQ.js} +1 -1
- package/dist/chunk-FYDBUVQD.js +244 -0
- package/dist/{chunk-PV6HIZQD.js → chunk-GDDXX27P.js} +50 -50
- package/dist/{chunk-3GIKYHLA.js → chunk-GKSG5CPH.js} +6 -6
- package/dist/{chunk-ESLPBT5A.js → chunk-HDYUBRMF.js} +4 -3
- package/dist/{chunk-4BABEJC2.js → chunk-IAYMTTR2.js} +236 -79
- package/dist/{chunk-ELRRTWNP.js → chunk-IXIS7RSG.js} +2 -2
- package/dist/{chunk-HR67OWEP.js → chunk-IYH4OHBP.js} +5 -5
- package/dist/{chunk-W232EFEM.js → chunk-JDOO4P6Z.js} +7 -4
- package/dist/{chunk-2OXHS3KZ.js → chunk-KLJZ4WV4.js} +4 -3
- package/dist/{chunk-3M7LLN7W.js → chunk-LQSOU63Z.js} +12 -11
- package/dist/{chunk-OTPTQBYE.js → chunk-MGPR7VG3.js} +279 -265
- package/dist/{chunk-C2DQKVLO.js → chunk-MJSJWXBF.js} +1 -1
- package/dist/{chunk-NSPNFOJ7.js → chunk-MK2JK35J.js} +25 -10
- package/dist/{chunk-JSNSMG5R.js → chunk-MSOAX3GC.js} +1 -1
- package/dist/{chunk-J43O3BOX.js → chunk-N3K2SFEI.js} +532 -492
- package/dist/{chunk-J74TMK4M.js → chunk-NJX2RXKJ.js} +50 -7
- package/dist/chunk-NL2S2CXD.js +171 -0
- package/dist/{chunk-WAQASTXB.js → chunk-O6BY43ZB.js} +29 -8
- package/dist/{chunk-QGF2C7TF.js → chunk-PVCB7RUZ.js} +2 -2
- package/dist/{chunk-YTKSNTT4.js → chunk-QA6IASYX.js} +8 -8
- package/dist/{chunk-VPALDFYM.js → chunk-RV7BVTDG.js} +1 -1
- package/dist/chunk-S57CDR2H.js +288 -0
- package/dist/{chunk-W2CECGTG.js → chunk-SMARDKAC.js} +1 -1
- package/dist/{chunk-QWKSKFKZ.js → chunk-SOR7OCYP.js} +1 -1
- package/dist/{chunk-I7FBZOEP.js → chunk-T3SMFF5Q.js} +11 -5
- package/dist/{chunk-4BHUSMNL.js → chunk-UI3ZJIG3.js} +1 -1
- package/dist/{chunk-WXJY3BKV.js → chunk-VBF2YXUW.js} +2 -2
- package/dist/{chunk-FQNXYA6W.js → chunk-VU3QBYL4.js} +36 -5
- package/dist/{chunk-VD2LV5WO.js → chunk-VZGPASGD.js} +37 -12
- package/dist/{chunk-UZFY3CKD.js → chunk-WEEVSWQB.js} +17 -6
- package/dist/chunk-XXRMF2BC.js +186 -0
- package/dist/{chunk-LRDIRJJL.js → chunk-YEISRT4S.js} +5 -11
- package/dist/{chunk-Q5JPPCZC.js → chunk-YJTXRH5Y.js} +3 -2
- package/dist/{chunk-Z5Q3TXRY.js → chunk-ZTCJCYLN.js} +3 -3
- package/dist/circuit-breaker.d.ts +1 -0
- package/dist/circuit-breaker.js +1 -1
- package/dist/clarify.d.ts +1 -0
- package/dist/codebase-index/codebase-ast-replace-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +5 -4
- package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +4 -3
- package/dist/codebase-index/codebase-index-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +4 -3
- package/dist/codebase-index/codebase-repo-map-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-search-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-skeleton-tool.d.ts +2 -3
- package/dist/codebase-index/codebase-stats-tool.d.ts +9 -3
- package/dist/codebase-index/codebase-targeted-test-tool.d.ts +4 -3
- package/dist/codebase-index/index.d.ts +11 -11
- package/dist/codebase-index/index.js +8 -8
- package/dist/codebase-index/project-server-framing.d.ts +29 -0
- package/dist/codebase-index/project-server-lifecycle.d.ts +20 -0
- package/dist/codebase-index/project-server-operations.d.ts +37 -0
- package/dist/codebase-index/project-server-types.d.ts +30 -0
- package/dist/codebase-index/project-server-watcher.d.ts +25 -0
- package/dist/codebase-index/project-server.js +448 -391
- package/dist/codebase-index/worker.js +2 -2
- package/dist/codebase-index/writer-init.d.ts +13 -0
- package/dist/codebase-index/writer-maintenance.d.ts +14 -0
- package/dist/codebase-index/writer.d.ts +0 -15
- package/dist/design.d.ts +2 -2
- package/dist/design.js +1 -1
- package/dist/diff.d.ts +4 -4
- package/dist/diff.js +1 -1
- package/dist/document.d.ts +3 -4
- package/dist/document.js +1 -1
- package/dist/e2e.d.ts +1 -1
- package/dist/e2e.js +1 -1
- package/dist/edit.d.ts +3 -3
- package/dist/edit.js +6 -6
- package/dist/exec.d.ts +2 -3
- package/dist/exec.js +4 -4
- package/dist/fetch.d.ts +4 -3
- package/dist/fetch.js +1 -1
- package/dist/format.d.ts +17 -45
- package/dist/format.js +12 -8
- package/dist/git.d.ts +3 -3
- package/dist/git.js +1 -1
- package/dist/glob.d.ts +2 -3
- package/dist/glob.js +2 -2
- package/dist/grep.d.ts +7 -5
- package/dist/grep.js +3 -3
- package/dist/index.d.ts +54 -45
- package/dist/index.js +118 -59
- package/dist/install.d.ts +7 -55
- package/dist/install.js +6 -6
- package/dist/json.d.ts +3 -4
- package/dist/json.js +2 -2
- package/dist/kanban-tool-types.d.ts +1 -2
- package/dist/kanban.d.ts +3 -19
- package/dist/kanban.js +1 -1
- package/dist/languages/execute-tool.d.ts +2 -3
- package/dist/languages/index.d.ts +2 -2
- package/dist/languages/index.js +4 -4
- package/dist/languages/tool.d.ts +3 -4
- package/dist/{legacy-bridge-FOV5ODDI.js → legacy-bridge-YXANP5QB.js} +6 -6
- package/dist/lint.d.ts +5 -4
- package/dist/lint.js +6 -6
- package/dist/logs.d.ts +3 -4
- package/dist/logs.js +2 -2
- package/dist/memory.d.ts +7 -8
- package/dist/memory.js +1 -1
- package/dist/mode.d.ts +3 -4
- package/dist/mode.js +1 -1
- package/dist/next-steps-tool.d.ts +2 -3
- package/dist/next-steps.d.ts +4 -0
- package/dist/next-steps.js +9 -175
- package/dist/outdated.d.ts +5 -29
- package/dist/outdated.js +3 -3
- package/dist/pack.js +51 -51
- package/dist/patch.d.ts +2 -3
- package/dist/patch.js +5 -5
- package/dist/plan.d.ts +4 -4
- package/dist/plan.js +3 -3
- package/dist/process-registry.js +2 -2
- package/dist/ps-slash.js +4 -4
- package/dist/pwsh.d.ts +1 -0
- package/dist/read.d.ts +5 -5
- package/dist/read.js +5 -5
- package/dist/replace.d.ts +2 -3
- package/dist/replace.js +6 -6
- package/dist/scaffold.d.ts +7 -3
- package/dist/scaffold.js +3 -1
- package/dist/search.d.ts +17 -3
- package/dist/search.js +5 -1
- package/dist/set-working-dir.d.ts +2 -3
- package/dist/skill.d.ts +4 -5
- package/dist/skill.js +1 -1
- package/dist/task.d.ts +6 -6
- package/dist/task.js +3 -3
- package/dist/test.d.ts +5 -4
- package/dist/test.js +6 -6
- package/dist/todo.d.ts +8 -8
- package/dist/todo.js +2 -2
- package/dist/tool-diff.js +11 -230
- package/dist/tool-help.d.ts +2 -3
- package/dist/tool-help.js +1 -1
- package/dist/tool-search.d.ts +2 -3
- package/dist/tool-search.js +1 -1
- package/dist/tool-summary.js +5 -281
- package/dist/tool-tier.js +52 -52
- package/dist/tool-use.d.ts +2 -3
- package/dist/tool-use.js +1 -1
- package/dist/tree.d.ts +5 -3
- package/dist/tree.js +5 -1
- package/dist/typecheck.d.ts +3 -3
- package/dist/typecheck.js +6 -6
- package/dist/write.d.ts +2 -3
- package/dist/write.js +6 -6
- package/package.json +5 -5
- package/dist/spawn-background.d.ts +0 -80
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// src/tool-summary.ts
|
|
2
|
+
var FALLBACK_HEAD_FIELDS = [
|
|
3
|
+
"path",
|
|
4
|
+
"file_path",
|
|
5
|
+
"pattern",
|
|
6
|
+
"symbol",
|
|
7
|
+
"command",
|
|
8
|
+
"cmd",
|
|
9
|
+
"url",
|
|
10
|
+
"query",
|
|
11
|
+
"description",
|
|
12
|
+
"content"
|
|
13
|
+
];
|
|
14
|
+
function clip(s, n) {
|
|
15
|
+
return s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
|
|
16
|
+
}
|
|
17
|
+
function pickPath(obj) {
|
|
18
|
+
const p = obj.file_path ?? obj.path ?? obj.filepath;
|
|
19
|
+
return typeof p === "string" ? p : "";
|
|
20
|
+
}
|
|
21
|
+
function safeJson(v) {
|
|
22
|
+
try {
|
|
23
|
+
return JSON.stringify(v);
|
|
24
|
+
} catch {
|
|
25
|
+
return String(v);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function coerceInput(input) {
|
|
29
|
+
if (typeof input === "string") {
|
|
30
|
+
const s = input.trim();
|
|
31
|
+
if (s.startsWith("{") || s.startsWith("[")) {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(s);
|
|
34
|
+
if (parsed && typeof parsed === "object")
|
|
35
|
+
return { obj: parsed, raw: parsed };
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { obj: null, raw: input };
|
|
40
|
+
}
|
|
41
|
+
if (input && typeof input === "object")
|
|
42
|
+
return { obj: input, raw: input };
|
|
43
|
+
return { obj: null, raw: input };
|
|
44
|
+
}
|
|
45
|
+
function summarizeToolInput(toolName, input) {
|
|
46
|
+
if (input === null || input === void 0 || input === "") return "";
|
|
47
|
+
const { obj, raw } = coerceInput(input);
|
|
48
|
+
if (!obj) return clip(String(raw), 120);
|
|
49
|
+
const name = (toolName ?? "").toLowerCase();
|
|
50
|
+
if (/^todo(_?write)?$|^todos$/.test(name) || Array.isArray(obj.todos)) {
|
|
51
|
+
const todos = obj.todos ?? [];
|
|
52
|
+
if (Array.isArray(todos)) {
|
|
53
|
+
const done = todos.filter((t) => t?.status === "completed").length;
|
|
54
|
+
const wip = todos.filter((t) => t?.status === "in_progress").length;
|
|
55
|
+
const parts = [`${todos.length} todo${todos.length === 1 ? "" : "s"}`];
|
|
56
|
+
if (done > 0) parts.push(`${done} done`);
|
|
57
|
+
if (wip > 0) parts.push(`${wip} in-progress`);
|
|
58
|
+
return parts.join(" \xB7 ");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (/batch|parallel/.test(name) || Array.isArray(obj.tool_uses) || Array.isArray(obj.calls)) {
|
|
62
|
+
const list = obj.tool_uses ?? obj.calls ?? obj.batch;
|
|
63
|
+
if (Array.isArray(list)) {
|
|
64
|
+
const subNames = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const item of list) {
|
|
66
|
+
if (item && typeof item === "object" && "name" in item) {
|
|
67
|
+
subNames.add(String(item.name));
|
|
68
|
+
} else if (item && typeof item === "object" && "tool" in item) {
|
|
69
|
+
subNames.add(String(item.tool));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const preview = [...subNames].slice(0, 3).join(", ");
|
|
73
|
+
const more = subNames.size > 3 ? ` +${subNames.size - 3}` : "";
|
|
74
|
+
return `${list.length} sub-tool${list.length === 1 ? "" : "s"}${preview ? ` \xB7 ${preview}${more}` : ""}`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (name === "patch" && typeof obj.patch === "string" && obj.patch) {
|
|
78
|
+
const fileCount = (obj.patch.match(/^\+\+\+ /gm) ?? []).length;
|
|
79
|
+
if (fileCount > 0) return `patch \xB7 ${fileCount} file${fileCount === 1 ? "" : "s"}`;
|
|
80
|
+
return `patch \xB7 ${obj.patch.split("\n").length} lines`;
|
|
81
|
+
}
|
|
82
|
+
if (/^(edit|str_replace|edit_file|patch)$/.test(name)) {
|
|
83
|
+
const fp = pickPath(obj);
|
|
84
|
+
const oldS = typeof obj.old_string === "string" ? obj.old_string : "";
|
|
85
|
+
const newS = typeof obj.new_string === "string" ? obj.new_string : "";
|
|
86
|
+
const oldLines = oldS ? oldS.split("\n").length : 0;
|
|
87
|
+
const newLines = newS ? newS.split("\n").length : 0;
|
|
88
|
+
return `edit ${fp || "(file)"}${oldLines || newLines ? ` (${oldLines} \u2192 ${newLines} lines)` : ""}`;
|
|
89
|
+
}
|
|
90
|
+
if (/^(write|write_file|create_file|new_file)$/.test(name)) {
|
|
91
|
+
const fp = pickPath(obj);
|
|
92
|
+
const c = typeof obj.content === "string" ? obj.content : "";
|
|
93
|
+
const lines = c ? c.split("\n").length : 0;
|
|
94
|
+
return `write ${fp || "(file)"}${lines ? ` \xB7 ${lines} lines` : ""}`;
|
|
95
|
+
}
|
|
96
|
+
if (/^(bash|shell|sh|exec|run|run_command|run_shell|command)$/.test(name)) {
|
|
97
|
+
const cmd = obj.command ?? obj.cmd ?? obj.script;
|
|
98
|
+
if (typeof cmd === "string") return `$ ${clip(cmd, 110)}`;
|
|
99
|
+
}
|
|
100
|
+
if (/^(fetch|http|web|web_fetch|web_search|webfetch|curl|request)$/.test(name)) {
|
|
101
|
+
const url = obj.url;
|
|
102
|
+
if (typeof url === "string") {
|
|
103
|
+
const method = obj.method ?? "GET";
|
|
104
|
+
return `${method.toUpperCase()} ${clip(url, 100)}`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (/^(grep|search|ripgrep|rg)$/.test(name)) {
|
|
108
|
+
const pattern = obj.pattern;
|
|
109
|
+
const scope = obj.path ?? obj.glob ?? obj.type;
|
|
110
|
+
if (typeof pattern === "string") {
|
|
111
|
+
return scope ? `grep ${clip(pattern, 60)} in ${scope}` : `grep ${clip(pattern, 100)}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (/^(glob|find)$/.test(name)) {
|
|
115
|
+
const p = obj.pattern ?? obj.glob;
|
|
116
|
+
if (typeof p === "string") return `glob ${clip(p, 80)}`;
|
|
117
|
+
}
|
|
118
|
+
if (/^tree$/.test(name)) {
|
|
119
|
+
const p = typeof obj.path === "string" ? obj.path : "";
|
|
120
|
+
const d = typeof obj.depth === "number" ? obj.depth : null;
|
|
121
|
+
return `tree ${p || "."}${d !== null ? ` (depth ${d})` : ""}`;
|
|
122
|
+
}
|
|
123
|
+
if (/^diff$/.test(name)) {
|
|
124
|
+
const a = typeof obj.a === "string" ? obj.a : "";
|
|
125
|
+
const b = typeof obj.b === "string" ? obj.b : "";
|
|
126
|
+
if (a || b) return `diff ${a && b ? `${a}..${b}` : a || b}`;
|
|
127
|
+
const fl = [];
|
|
128
|
+
if (Array.isArray(obj.files)) {
|
|
129
|
+
for (const f of obj.files) if (typeof f === "string") fl.push(f);
|
|
130
|
+
} else if (typeof obj.files === "string") {
|
|
131
|
+
for (const part of obj.files.split(",")) {
|
|
132
|
+
const t = part.trim();
|
|
133
|
+
if (t) fl.push(t);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (fl.length === 1) return `diff ${clip(String(fl[0]), 80)}`;
|
|
137
|
+
if (fl.length > 1) return `diff ${fl.length} files`;
|
|
138
|
+
}
|
|
139
|
+
if (/^replace$/.test(name)) {
|
|
140
|
+
const pattern = typeof obj.pattern === "string" ? obj.pattern : "";
|
|
141
|
+
if (pattern) {
|
|
142
|
+
let scope = "";
|
|
143
|
+
if (typeof obj.files === "string") {
|
|
144
|
+
const parts = obj.files.split(",").map((s) => s.trim()).filter(Boolean);
|
|
145
|
+
scope = parts.length > 1 ? `${parts.length} files` : parts[0] ?? "";
|
|
146
|
+
} else if (Array.isArray(obj.files) && obj.files.length > 0) {
|
|
147
|
+
scope = obj.files.length === 1 ? String(obj.files[0]) : `${obj.files.length} files`;
|
|
148
|
+
}
|
|
149
|
+
return `replace ${clip(pattern, 60)}${scope ? ` in ${clip(scope, 50)}` : ""}`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (/^(read|read_file|cat|view)$/.test(name)) {
|
|
153
|
+
const fp = pickPath(obj);
|
|
154
|
+
const offset = obj.offset;
|
|
155
|
+
const limit = obj.limit;
|
|
156
|
+
if (fp && (typeof offset === "number" || typeof limit === "number")) {
|
|
157
|
+
const start = offset ?? 0;
|
|
158
|
+
const end = typeof limit === "number" ? start + limit : "";
|
|
159
|
+
return `read ${fp} (${start}\u2026${end})`;
|
|
160
|
+
}
|
|
161
|
+
if (fp) return `read ${fp}`;
|
|
162
|
+
}
|
|
163
|
+
for (const k of FALLBACK_HEAD_FIELDS) {
|
|
164
|
+
const v = obj[k];
|
|
165
|
+
if (typeof v === "string" && v.length > 0) {
|
|
166
|
+
return `${k}: ${clip(v, 100)}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return clip(safeJson(raw), 120);
|
|
170
|
+
}
|
|
171
|
+
var SUMMARIZE_TOOL_INPUT_BROWSER_SRC = [
|
|
172
|
+
'function __clip(s,n){ s=String(s==null?"":s); return s.length>n ? s.slice(0,n-1)+"\\u2026" : s; }',
|
|
173
|
+
"function toolInputSummary(name, rawInput){",
|
|
174
|
+
' if(rawInput==null || rawInput==="") return "";',
|
|
175
|
+
" var obj=null, raw=rawInput;",
|
|
176
|
+
' if(typeof rawInput==="string"){',
|
|
177
|
+
" var s=rawInput.trim();",
|
|
178
|
+
' if(s.charAt(0)==="{" || s.charAt(0)==="["){ try{ var pj=JSON.parse(s); if(pj && typeof pj==="object"){ obj=pj; raw=pj; } }catch(_e){} }',
|
|
179
|
+
' } else if(rawInput && typeof rawInput==="object"){ obj=rawInput; raw=rawInput; }',
|
|
180
|
+
" if(!obj) return __clip(String(raw),120);",
|
|
181
|
+
' var n=String(name==null?"":name).toLowerCase();',
|
|
182
|
+
" if(/^todo(_?write)?$|^todos$/.test(n) || Array.isArray(obj.todos)){",
|
|
183
|
+
" var todos=obj.todos||[];",
|
|
184
|
+
" if(Array.isArray(todos)){",
|
|
185
|
+
" var done=0, wip=0, ti;",
|
|
186
|
+
' for(ti=0; ti<todos.length; ti++){ var st=todos[ti]&&todos[ti].status; if(st==="completed") done++; else if(st==="in_progress") wip++; }',
|
|
187
|
+
' var tp=[todos.length+" todo"+(todos.length===1?"":"s")];',
|
|
188
|
+
' if(done>0) tp.push(done+" done"); if(wip>0) tp.push(wip+" in-progress");',
|
|
189
|
+
' return tp.join(" \\u00b7 ");',
|
|
190
|
+
" }",
|
|
191
|
+
" }",
|
|
192
|
+
" if(/batch|parallel/.test(n) || Array.isArray(obj.tool_uses) || Array.isArray(obj.calls)){",
|
|
193
|
+
" var list=obj.tool_uses||obj.calls||obj.batch;",
|
|
194
|
+
" if(Array.isArray(list)){",
|
|
195
|
+
" var names={}, ord=[], li, it, nm;",
|
|
196
|
+
' for(li=0; li<list.length; li++){ it=list[li]; if(it && typeof it==="object"){ nm=("name" in it)?it.name:(("tool" in it)?it.tool:null); if(nm!=null){ nm=String(nm); if(!names[nm]){ names[nm]=1; ord.push(nm); } } } }',
|
|
197
|
+
' var preview=ord.slice(0,3).join(", ");',
|
|
198
|
+
' var more=ord.length>3 ? " +"+(ord.length-3) : "";',
|
|
199
|
+
' return list.length+" sub-tool"+(list.length===1?"":"s")+(preview?(" \\u00b7 "+preview+more):"");',
|
|
200
|
+
" }",
|
|
201
|
+
" }",
|
|
202
|
+
" var fp;",
|
|
203
|
+
' if(n==="patch" && typeof obj.patch==="string" && obj.patch){',
|
|
204
|
+
" var pfm=obj.patch.match(/^\\+\\+\\+ /gm);",
|
|
205
|
+
" var pfc=pfm?pfm.length:0;",
|
|
206
|
+
' if(pfc>0) return "patch \\u00b7 "+pfc+" file"+(pfc===1?"":"s");',
|
|
207
|
+
' return "patch \\u00b7 "+obj.patch.split("\\n").length+" lines";',
|
|
208
|
+
" }",
|
|
209
|
+
" if(/^(edit|str_replace|edit_file|patch)$/.test(n)){",
|
|
210
|
+
" fp=(obj.file_path!=null?obj.file_path:(obj.path!=null?obj.path:obj.filepath));",
|
|
211
|
+
' var oldS=typeof obj.old_string==="string"?obj.old_string:"";',
|
|
212
|
+
' var newS=typeof obj.new_string==="string"?obj.new_string:"";',
|
|
213
|
+
' var ol=oldS?oldS.split("\\n").length:0, nl=newS?newS.split("\\n").length:0;',
|
|
214
|
+
' var efp=typeof fp==="string"?fp:"";',
|
|
215
|
+
' return "edit "+(efp||"(file)")+((ol||nl)?(" ("+ol+" \\u2192 "+nl+" lines)"):"");',
|
|
216
|
+
" }",
|
|
217
|
+
" if(/^(write|write_file|create_file|new_file)$/.test(n)){",
|
|
218
|
+
" fp=(obj.file_path!=null?obj.file_path:(obj.path!=null?obj.path:obj.filepath));",
|
|
219
|
+
' var wc=typeof obj.content==="string"?obj.content:"";',
|
|
220
|
+
' var wl=wc?wc.split("\\n").length:0;',
|
|
221
|
+
' var wfp=typeof fp==="string"?fp:"";',
|
|
222
|
+
' return "write "+(wfp||"(file)")+(wl?(" \\u00b7 "+wl+" lines"):"");',
|
|
223
|
+
" }",
|
|
224
|
+
" if(/^(bash|shell|sh|exec|run|run_command|run_shell|command)$/.test(n)){",
|
|
225
|
+
" var cmd=(obj.command!=null?obj.command:(obj.cmd!=null?obj.cmd:obj.script));",
|
|
226
|
+
' if(typeof cmd==="string") return "$ "+__clip(cmd,110);',
|
|
227
|
+
" }",
|
|
228
|
+
" if(/^(fetch|http|web|web_fetch|web_search|webfetch|curl|request)$/.test(n)){",
|
|
229
|
+
' if(typeof obj.url==="string"){ var mth=(typeof obj.method==="string"?obj.method:"GET"); return mth.toUpperCase()+" "+__clip(obj.url,100); }',
|
|
230
|
+
" }",
|
|
231
|
+
" if(/^(grep|search|ripgrep|rg)$/.test(n)){",
|
|
232
|
+
" var pat=obj.pattern, scope=(obj.path!=null?obj.path:(obj.glob!=null?obj.glob:obj.type));",
|
|
233
|
+
' if(typeof pat==="string"){ return scope ? ("grep "+__clip(pat,60)+" in "+scope) : ("grep "+__clip(pat,100)); }',
|
|
234
|
+
" }",
|
|
235
|
+
" if(/^(glob|find)$/.test(n)){",
|
|
236
|
+
" var gp=(obj.pattern!=null?obj.pattern:obj.glob);",
|
|
237
|
+
' if(typeof gp==="string") return "glob "+__clip(gp,80);',
|
|
238
|
+
" }",
|
|
239
|
+
" if(/^tree$/.test(n)){",
|
|
240
|
+
' var trp=typeof obj.path==="string"?obj.path:"";',
|
|
241
|
+
' var trd=typeof obj.depth==="number"?obj.depth:null;',
|
|
242
|
+
' return "tree "+(trp||".")+(trd!==null?(" (depth "+trd+")"):"");',
|
|
243
|
+
" }",
|
|
244
|
+
" if(/^diff$/.test(n)){",
|
|
245
|
+
' var da=typeof obj.a==="string"?obj.a:"", db=typeof obj.b==="string"?obj.b:"";',
|
|
246
|
+
' if(da||db) return "diff "+((da&&db)?(da+".."+db):(da||db));',
|
|
247
|
+
" var dfl=[], dfi, dpi;",
|
|
248
|
+
' if(Array.isArray(obj.files)){ for(dfi=0; dfi<obj.files.length; dfi++){ if(typeof obj.files[dfi]==="string") dfl.push(obj.files[dfi]); } }',
|
|
249
|
+
' else if(typeof obj.files==="string"){ var dparts=obj.files.split(","); for(dpi=0; dpi<dparts.length; dpi++){ var dt=dparts[dpi].trim(); if(dt) dfl.push(dt); } }',
|
|
250
|
+
' if(dfl.length===1) return "diff "+__clip(String(dfl[0]),80);',
|
|
251
|
+
' if(dfl.length>1) return "diff "+dfl.length+" files";',
|
|
252
|
+
" }",
|
|
253
|
+
" if(/^replace$/.test(n)){",
|
|
254
|
+
' var rpat=typeof obj.pattern==="string"?obj.pattern:"";',
|
|
255
|
+
" if(rpat){",
|
|
256
|
+
' var rscope="";',
|
|
257
|
+
' if(typeof obj.files==="string"){',
|
|
258
|
+
" var rparts=[], rsi;",
|
|
259
|
+
' var rraw=obj.files.split(",");',
|
|
260
|
+
" for(rsi=0; rsi<rraw.length; rsi++){ var rt=rraw[rsi].trim(); if(rt) rparts.push(rt); }",
|
|
261
|
+
' rscope=rparts.length>1?(rparts.length+" files"):(rparts.length===1?rparts[0]:"");',
|
|
262
|
+
" } else if(Array.isArray(obj.files) && obj.files.length>0){",
|
|
263
|
+
' rscope=obj.files.length===1?String(obj.files[0]):(obj.files.length+" files");',
|
|
264
|
+
" }",
|
|
265
|
+
' return "replace "+__clip(rpat,60)+(rscope?(" in "+__clip(rscope,50)):"");',
|
|
266
|
+
" }",
|
|
267
|
+
" }",
|
|
268
|
+
" if(/^(read|read_file|cat|view)$/.test(n)){",
|
|
269
|
+
" fp=(obj.file_path!=null?obj.file_path:(obj.path!=null?obj.path:obj.filepath));",
|
|
270
|
+
' if(typeof fp==="string" && fp){',
|
|
271
|
+
" var off=obj.offset, lim=obj.limit;",
|
|
272
|
+
' if(typeof off==="number" || typeof lim==="number"){ var start=(typeof off==="number"?off:0); var end=(typeof lim==="number"?(start+lim):""); return "read "+fp+" ("+start+"\\u2026"+end+")"; }',
|
|
273
|
+
' return "read "+fp;',
|
|
274
|
+
" }",
|
|
275
|
+
" }",
|
|
276
|
+
' var HEAD=["path","file_path","pattern","symbol","command","cmd","url","query","description","content"], hi;',
|
|
277
|
+
' for(hi=0; hi<HEAD.length; hi++){ var hv=obj[HEAD[hi]]; if(typeof hv==="string" && hv.length>0){ return HEAD[hi]+": "+__clip(hv,100); } }',
|
|
278
|
+
" var jsonStr; try{ jsonStr=JSON.stringify(raw); }catch(_e2){ jsonStr=String(raw); }",
|
|
279
|
+
" return __clip(jsonStr,120);",
|
|
280
|
+
"}"
|
|
281
|
+
].join("\n");
|
|
282
|
+
|
|
283
|
+
export {
|
|
284
|
+
FALLBACK_HEAD_FIELDS,
|
|
285
|
+
summarizeToolInput,
|
|
286
|
+
SUMMARIZE_TOOL_INPUT_BROWSER_SRC
|
|
287
|
+
};
|
|
288
|
+
//# sourceMappingURL=chunk-S57CDR2H.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
executeLanguagePlan,
|
|
3
3
|
executePackagePlan,
|
|
4
4
|
planLanguageOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7N5U2RAU.js";
|
|
6
6
|
|
|
7
7
|
// src/languages/legacy-bridge.ts
|
|
8
8
|
import * as fs from "node:fs/promises";
|
|
@@ -21,7 +21,11 @@ async function detectNonJsEcosystem(cwd, projectRoot) {
|
|
|
21
21
|
try {
|
|
22
22
|
let dir = path.resolve(cwd);
|
|
23
23
|
const root = path.resolve(projectRoot);
|
|
24
|
-
|
|
24
|
+
const isInsideOrSame = (d, r) => {
|
|
25
|
+
const rel = path.relative(r, d);
|
|
26
|
+
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
27
|
+
};
|
|
28
|
+
for (let depth = 0; depth <= 4 && isInsideOrSame(dir, root); depth++) {
|
|
25
29
|
for (const marker of NON_JS_MARKERS) {
|
|
26
30
|
try {
|
|
27
31
|
const s = await fs.stat(path.join(dir, marker.filename));
|
|
@@ -38,8 +42,10 @@ async function detectNonJsEcosystem(cwd, projectRoot) {
|
|
|
38
42
|
}
|
|
39
43
|
} catch {
|
|
40
44
|
}
|
|
41
|
-
if (dir ===
|
|
42
|
-
|
|
45
|
+
if (path.relative(root, dir) === "") break;
|
|
46
|
+
const parent = path.dirname(dir);
|
|
47
|
+
if (parent === dir) break;
|
|
48
|
+
dir = parent;
|
|
43
49
|
}
|
|
44
50
|
} catch {
|
|
45
51
|
}
|
|
@@ -98,4 +104,4 @@ export {
|
|
|
98
104
|
tryLegacyCodeOperation,
|
|
99
105
|
tryLegacyPackageOperation
|
|
100
106
|
};
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-T3SMFF5Q.js.map
|
|
@@ -80,7 +80,7 @@ var batchToolUseTool = {
|
|
|
80
80
|
if (input.calls.length > MAX_BATCH_CALLS) {
|
|
81
81
|
throw new Error(`batch_tool_use: calls must contain at most ${MAX_BATCH_CALLS} items`);
|
|
82
82
|
}
|
|
83
|
-
const governedExecute = ctx.meta[GOVERNED_TOOL_EXECUTOR_META_KEY];
|
|
83
|
+
const governedExecute = ctx.meta?.[GOVERNED_TOOL_EXECUTOR_META_KEY];
|
|
84
84
|
if (typeof governedExecute !== "function") {
|
|
85
85
|
return {
|
|
86
86
|
results: input.calls.map((call) => ({
|
|
@@ -200,4 +200,4 @@ async function executeSingle(call, ctx, governedExecute) {
|
|
|
200
200
|
export {
|
|
201
201
|
batchToolUseTool
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
203
|
+
//# sourceMappingURL=chunk-VBF2YXUW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compileUserRegex
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YJTXRH5Y.js";
|
|
4
4
|
import {
|
|
5
5
|
safeResolveReal
|
|
6
6
|
} from "./chunk-ZUFHAHTE.js";
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
// src/logs.ts
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
10
|
import { StringDecoder } from "node:string_decoder";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
11
|
+
import * as fs from "node:fs/promises";
|
|
12
|
+
import { buildChildEnv, toErrorMessage } from "@wrongstack/core/utils";
|
|
13
|
+
import { FsError, ToolValidationError } from "@wrongstack/core/types";
|
|
13
14
|
var logsTool = {
|
|
14
15
|
name: "logs",
|
|
15
16
|
category: "Logs",
|
|
@@ -86,7 +87,37 @@ var logsTool = {
|
|
|
86
87
|
return await dockerLogs(input.service, lines, filterRe, cwd, signal, input.since);
|
|
87
88
|
}
|
|
88
89
|
if (input.path) {
|
|
89
|
-
|
|
90
|
+
const resolved = await safeResolveReal(input.path, ctx);
|
|
91
|
+
let stat2;
|
|
92
|
+
try {
|
|
93
|
+
stat2 = await fs.stat(resolved);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const code = err.code;
|
|
96
|
+
if (code === "ENOENT") {
|
|
97
|
+
throw new FsError({
|
|
98
|
+
message: `logs: file not found "${input.path}"`,
|
|
99
|
+
code: "FS_READ_FAILED",
|
|
100
|
+
path: resolved,
|
|
101
|
+
context: { errno: "ENOENT" }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
throw new FsError({
|
|
105
|
+
message: `logs: failed to stat "${input.path}": ${toErrorMessage(err)}`,
|
|
106
|
+
code: "FS_READ_FAILED",
|
|
107
|
+
path: resolved,
|
|
108
|
+
context: { errno: code },
|
|
109
|
+
cause: err
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (!stat2.isFile()) {
|
|
113
|
+
throw new FsError({
|
|
114
|
+
message: `logs: "${input.path}" is not a regular file`,
|
|
115
|
+
code: "FS_READ_FAILED",
|
|
116
|
+
path: resolved,
|
|
117
|
+
context: { reason: "not-a-regular-file" }
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return await fileLogs(resolved, lines, filterRe);
|
|
90
121
|
}
|
|
91
122
|
return {
|
|
92
123
|
source: "none",
|
|
@@ -268,4 +299,4 @@ function parseLine(line) {
|
|
|
268
299
|
export {
|
|
269
300
|
logsTool
|
|
270
301
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
302
|
+
//# sourceMappingURL=chunk-VU3QBYL4.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
capSubject,
|
|
3
3
|
compileUserRegex
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YJTXRH5Y.js";
|
|
5
5
|
import {
|
|
6
6
|
safeResolveReal
|
|
7
7
|
} from "./chunk-ZUFHAHTE.js";
|
|
@@ -39,7 +39,7 @@ async function readJsonFileBounded(filePath, ctx) {
|
|
|
39
39
|
var jsonTool = {
|
|
40
40
|
name: "json",
|
|
41
41
|
category: "Data",
|
|
42
|
-
description: "Parse, pretty-print, query, validate, transform, and merge JSON/JSON5/YAML. Use `action` to select the operation: parse (default), query, validate, transform, or merge.",
|
|
42
|
+
description: "Parse, pretty-print, query, validate, transform, and merge JSON/JSON5/YAML (read-only \u2014 does not write files). Use `action` to select the operation: parse (default), query, validate, transform, or merge.",
|
|
43
43
|
usageHint: 'VERY USEFUL FOR DATA INSPECTION:\n\n- `action: "parse"` (default): read/pretty-print/convert JSON, JSON5, or YAML from `file` or `data`.\n- `action: "query"`: JMESPath-like query (`a.b[0].c`, `items[*].name`, filters, functions).\n- `action: "validate"`: validate data against a JSON Schema (`schema` param).\n- `action: "transform"`: chain multiple JMESPath transforms (`transforms` param).\n- `action: "merge"`: deep merge `base` and `patch` objects (`conflictResolution` param).\nPrefer this over raw `read` + manual parsing when dealing with configuration or data files.',
|
|
44
44
|
permission: "auto",
|
|
45
45
|
mutating: false,
|
|
@@ -444,20 +444,35 @@ function jmespathSearch(data, query) {
|
|
|
444
444
|
if (rest === void 0) return val;
|
|
445
445
|
return jmespathSearch(val, rest);
|
|
446
446
|
}
|
|
447
|
-
const
|
|
447
|
+
const propIdxMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(\d+)\](?:\.?(.*))?$/);
|
|
448
|
+
if (propIdxMatch) {
|
|
449
|
+
const key = propIdxMatch[1];
|
|
450
|
+
if (key === "__proto__" || key === "prototype" || key === "constructor") {
|
|
451
|
+
return void 0;
|
|
452
|
+
}
|
|
453
|
+
const idx = Number.parseInt(propIdxMatch[2], 10);
|
|
454
|
+
const rest = propIdxMatch[3] ? propIdxMatch[3] : void 0;
|
|
455
|
+
const arr = data?.[key];
|
|
456
|
+
if (!Array.isArray(arr)) return void 0;
|
|
457
|
+
const val = arr[idx];
|
|
458
|
+
if (rest === void 0) return val;
|
|
459
|
+
return jmespathSearch(val, rest);
|
|
460
|
+
}
|
|
461
|
+
const arrMatch = query.match(/^\[(\d+)\](?:\.?(.*))?$/);
|
|
448
462
|
if (arrMatch) {
|
|
449
463
|
const idx = Number.parseInt(arrMatch[1], 10);
|
|
450
|
-
const rest = arrMatch[2];
|
|
464
|
+
const rest = arrMatch[2] ? arrMatch[2] : void 0;
|
|
451
465
|
const arr = data;
|
|
452
466
|
const val = arr?.[idx];
|
|
453
467
|
if (rest === void 0) return val;
|
|
454
468
|
return jmespathSearch(val, rest);
|
|
455
469
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return data;
|
|
470
|
+
const wildcardMatch = query.match(/^\[\*\](?:\.(.+))?$/);
|
|
471
|
+
if (wildcardMatch) {
|
|
472
|
+
if (!Array.isArray(data)) return [];
|
|
473
|
+
const rest = wildcardMatch[1];
|
|
474
|
+
if (rest === void 0) return data;
|
|
475
|
+
return data.map((item) => jmespathSearch(item, rest));
|
|
461
476
|
}
|
|
462
477
|
const multiMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\*\](?:\.(.+))?$/);
|
|
463
478
|
if (multiMatch) {
|
|
@@ -469,14 +484,24 @@ function jmespathSearch(data, query) {
|
|
|
469
484
|
return arr.map((item) => jmespathSearch(item, rest));
|
|
470
485
|
}
|
|
471
486
|
const filterMatch = query.match(
|
|
472
|
-
/^\[
|
|
487
|
+
/^\[\??([a-zA-Z_][a-zA-Z0-9_]*)(==|!=|<|>|<=|>=)(`[^`]+`|'[^']*')\](?:\.(.+))?$/
|
|
473
488
|
);
|
|
474
489
|
if (filterMatch) {
|
|
475
490
|
const field = filterMatch[1];
|
|
476
491
|
const op = filterMatch[2];
|
|
477
492
|
const rawVal = filterMatch[3];
|
|
478
493
|
const rest = filterMatch[4];
|
|
479
|
-
|
|
494
|
+
let cmpVal;
|
|
495
|
+
if (rawVal.startsWith("'") && rawVal.endsWith("'")) {
|
|
496
|
+
cmpVal = rawVal.slice(1, -1);
|
|
497
|
+
} else {
|
|
498
|
+
const inner = rawVal.slice(1, -1);
|
|
499
|
+
try {
|
|
500
|
+
cmpVal = JSON.parse(inner);
|
|
501
|
+
} catch {
|
|
502
|
+
cmpVal = inner;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
480
505
|
const arr = data;
|
|
481
506
|
if (!Array.isArray(arr)) return [];
|
|
482
507
|
const filtered = arr.filter((item) => {
|
|
@@ -676,4 +701,4 @@ ${toYaml(v, indent + 1)}`;
|
|
|
676
701
|
export {
|
|
677
702
|
jsonTool
|
|
678
703
|
};
|
|
679
|
-
//# sourceMappingURL=chunk-
|
|
704
|
+
//# sourceMappingURL=chunk-VZGPASGD.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
tryLegacyPackageOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T3SMFF5Q.js";
|
|
4
4
|
import {
|
|
5
5
|
spawnStream
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DRRY6SCM.js";
|
|
7
7
|
import {
|
|
8
8
|
COMMAND_OUTPUT_MAX_BYTES,
|
|
9
9
|
detectPackageManager,
|
|
@@ -117,7 +117,8 @@ var auditTool = {
|
|
|
117
117
|
type: "final",
|
|
118
118
|
output: parseAuditOutput(result.stdout, result.exitCode, {
|
|
119
119
|
level: input.level,
|
|
120
|
-
spawnTruncated: result.truncated
|
|
120
|
+
spawnTruncated: result.truncated,
|
|
121
|
+
rawError: result.stderr || result.error || ""
|
|
121
122
|
})
|
|
122
123
|
};
|
|
123
124
|
}
|
|
@@ -129,7 +130,7 @@ function parseAuditOutput(json, exitCode, opts = {}) {
|
|
|
129
130
|
vulnerabilities: [],
|
|
130
131
|
total: 0,
|
|
131
132
|
summary: exitCode === 0 ? "No vulnerabilities found" : "Audit failed",
|
|
132
|
-
output: "",
|
|
133
|
+
output: normalizeCommandOutput(opts.rawError || ""),
|
|
133
134
|
truncated: false
|
|
134
135
|
};
|
|
135
136
|
}
|
|
@@ -143,7 +144,17 @@ function parseAuditOutput(json, exitCode, opts = {}) {
|
|
|
143
144
|
advisories = advisories.filter((a) => (SEVERITY_RANK[a.severity] ?? 0) >= minRank);
|
|
144
145
|
}
|
|
145
146
|
const total = advisories.length;
|
|
146
|
-
|
|
147
|
+
let summary;
|
|
148
|
+
if (total === 0) {
|
|
149
|
+
if (exitCode !== 0) {
|
|
150
|
+
const errObj = data.error;
|
|
151
|
+
summary = typeof errObj?.summary === "string" ? errObj.summary : typeof errObj?.code === "string" ? `Audit failed (${errObj.code})` : "Audit failed";
|
|
152
|
+
} else {
|
|
153
|
+
summary = "No vulnerabilities found";
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
summary = `Found ${total} vulnerabilities: ${advisories.filter((a) => a.severity === "critical").length} critical, ${advisories.filter((a) => a.severity === "high").length} high`;
|
|
157
|
+
}
|
|
147
158
|
return {
|
|
148
159
|
exit_code: exitCode,
|
|
149
160
|
vulnerabilities: advisories,
|
|
@@ -209,4 +220,4 @@ function extractAdvisories(data) {
|
|
|
209
220
|
export {
|
|
210
221
|
auditTool
|
|
211
222
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
223
|
+
//# sourceMappingURL=chunk-WEEVSWQB.js.map
|