@wrongstack/tools 0.319.1 → 1.0.0
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 +8 -8
- 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 +6 -6
- 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 +55 -55
- package/dist/{chunk-RJZQWEMS.js → chunk-24T5XIJU.js} +3 -2
- package/dist/{chunk-DTQ75VBC.js → chunk-2CTZW6JQ.js} +2 -2
- package/dist/chunk-37QKUQ2Z.js +171 -0
- package/dist/{chunk-LOBRWKCR.js → chunk-3D5DJWOE.js} +3 -3
- package/dist/{chunk-YOKD4GWJ.js → chunk-4ERMPDHV.js} +14 -8
- package/dist/{chunk-5EUJF3WC.js → chunk-4WPBS45A.js} +4 -5
- package/dist/{chunk-42BHI7TN.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-IYKXK356.js → chunk-6GOZTS6F.js} +4 -4
- package/dist/{chunk-OG2BEUBY.js → chunk-7HL23T3T.js} +73 -16
- package/dist/{chunk-HFXSNKCV.js → chunk-7JJFC6CT.js} +1 -1
- package/dist/{chunk-TTZOK6IY.js → chunk-7N5U2RAU.js} +2 -2
- package/dist/{chunk-QBV725YG.js → chunk-7ODZTPCU.js} +2 -2
- package/dist/{chunk-OTINMOKK.js → chunk-AB2CAUOP.js} +66 -55
- package/dist/{chunk-6AAOT4PW.js → chunk-AQ5YBURX.js} +16 -4
- package/dist/{chunk-JDPQOR7C.js → chunk-ASEXQRA7.js} +19 -19
- package/dist/{chunk-FRN7TIAA.js → chunk-B3MGJBFI.js} +1 -1
- package/dist/{chunk-IWS56OY7.js → chunk-CGXTR34H.js} +63 -4
- package/dist/{chunk-IU4DV2PA.js → chunk-CHEK3ASV.js} +6 -3
- package/dist/{chunk-GOIZNNOA.js → chunk-DJYLI7EW.js} +1 -1
- package/dist/{chunk-CFLJFDYV.js → chunk-DK4J2WMH.js} +14 -11
- package/dist/{chunk-ZHH3BEWU.js → chunk-DRRY6SCM.js} +49 -22
- package/dist/{chunk-BK732J7I.js → chunk-FBUP524S.js} +4 -4
- package/dist/{chunk-WHIIIREL.js → chunk-FVM3O4JQ.js} +7 -3
- package/dist/chunk-FYDBUVQD.js +244 -0
- package/dist/{chunk-UDVKRX5R.js → chunk-GDDXX27P.js} +50 -50
- package/dist/{chunk-O44IMQCN.js → chunk-GKSG5CPH.js} +6 -6
- package/dist/{chunk-3PVYQFRQ.js → chunk-HDYUBRMF.js} +5 -3
- package/dist/{chunk-ELRRTWNP.js → chunk-IXIS7RSG.js} +2 -2
- package/dist/{chunk-X5FOFGXX.js → chunk-IYH4OHBP.js} +6 -6
- package/dist/{chunk-MNP3GE7H.js → chunk-JDOO4P6Z.js} +21 -16
- package/dist/{chunk-BSJSNVGA.js → chunk-KDEXUQY7.js} +24 -11
- package/dist/{chunk-V43EQ6VR.js → chunk-KE7A76VC.js} +3 -2
- package/dist/{chunk-2OXHS3KZ.js → chunk-KLJZ4WV4.js} +4 -3
- package/dist/{chunk-3M7LLN7W.js → chunk-LQSOU63Z.js} +12 -11
- package/dist/{chunk-DC4KMPJO.js → chunk-M6UV67BH.js} +2 -2
- package/dist/{chunk-C2DQKVLO.js → chunk-MJSJWXBF.js} +1 -1
- package/dist/{chunk-RNWUCZ2U.js → chunk-MK2JK35J.js} +29 -12
- package/dist/{chunk-FQZOHLG3.js → chunk-MSOAX3GC.js} +3 -2
- package/dist/{chunk-KY4PXYSO.js → chunk-N3K2SFEI.js} +534 -494
- package/dist/{chunk-EADULOZV.js → chunk-NJX2RXKJ.js} +50 -7
- package/dist/{chunk-AKHYMB4V.js → chunk-NN2SNP2R.js} +6 -6
- package/dist/{chunk-CMOUCKGC.js → chunk-NU2IZ72J.js} +6 -6
- package/dist/{chunk-RLMX75EM.js → chunk-O6BY43ZB.js} +29 -8
- package/dist/{chunk-NKNOBUBU.js → chunk-PVCB7RUZ.js} +2 -2
- package/dist/{chunk-UQQS3VNT.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-2VSZC6QM.js → chunk-SCMRM6NL.js} +6 -4
- package/dist/{chunk-W2CECGTG.js → chunk-SMARDKAC.js} +1 -1
- package/dist/{chunk-45JPRMC2.js → chunk-SOR7OCYP.js} +7 -3
- package/dist/{chunk-ATSKPZUK.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-IIF5HIVF.js → chunk-VVZPQPTY.js} +2 -2
- package/dist/{chunk-VD2LV5WO.js → chunk-VZGPASGD.js} +37 -12
- package/dist/{chunk-64VIJPFV.js → chunk-WEEVSWQB.js} +17 -6
- package/dist/chunk-XXRMF2BC.js +186 -0
- package/dist/{chunk-RTZWBNTY.js → chunk-YEISRT4S.js} +7 -12
- package/dist/{chunk-Q5JPPCZC.js → chunk-YJTXRH5Y.js} +3 -2
- package/dist/{chunk-GMZYW52L.js → chunk-YULVUTK5.js} +6 -3
- package/dist/{chunk-NWZ6XGBJ.js → chunk-ZBMANLYH.js} +5 -3
- package/dist/{chunk-DP6CXMJZ.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 +12 -12
- package/dist/codebase-index/parser-worker-script.js +3 -3
- 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 +451 -394
- package/dist/codebase-index/worker.js +5 -5
- 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 +2 -2
- 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 +9 -9
- package/dist/exec.d.ts +2 -3
- package/dist/exec.js +6 -6
- package/dist/fetch.d.ts +4 -3
- package/dist/fetch.js +1 -1
- package/dist/format.d.ts +17 -45
- package/dist/format.js +14 -10
- package/dist/git.d.ts +3 -3
- package/dist/git.js +1 -1
- package/dist/glob.d.ts +2 -3
- package/dist/glob.js +3 -3
- package/dist/{go-parser-IKHW67WE.js → go-parser-D7ELWQ7F.js} +2 -2
- package/dist/grep.d.ts +7 -5
- package/dist/grep.js +4 -4
- package/dist/index.d.ts +54 -45
- package/dist/index.js +122 -63
- package/dist/install.d.ts +7 -55
- package/dist/install.js +8 -8
- package/dist/{json-parser-2EOVP5MR.js → json-parser-34DHYCPW.js} +1 -18
- 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 +6 -6
- package/dist/languages/tool.d.ts +3 -4
- package/dist/legacy-bridge-YXANP5QB.js +18 -0
- package/dist/lint.d.ts +5 -4
- package/dist/lint.js +8 -8
- 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 +11 -0
- package/dist/next-steps.js +10 -132
- package/dist/outdated.d.ts +5 -29
- package/dist/outdated.js +4 -4
- package/dist/pack.js +56 -56
- package/dist/{parser-dispatch-QGC4HSP5.js → parser-dispatch-BDVCJXTV.js} +4 -4
- package/dist/patch.d.ts +2 -3
- package/dist/patch.js +8 -8
- 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/{py-parser-RFWG2HYI.js → py-parser-QC6MR4GB.js} +3 -3
- package/dist/read.d.ts +5 -5
- package/dist/read.js +8 -8
- package/dist/replace.d.ts +2 -3
- package/dist/replace.js +10 -10
- 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 +8 -8
- 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 +57 -57
- 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 +8 -8
- package/dist/win32.js +1 -1
- package/dist/write.d.ts +2 -3
- package/dist/write.js +9 -9
- package/package.json +5 -5
- package/dist/legacy-bridge-3T7SR4SK.js +0 -18
- package/dist/spawn-background.d.ts +0 -80
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
e2ePlanTool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RV7BVTDG.js";
|
|
4
4
|
import {
|
|
5
5
|
codebaseAstReplaceTool,
|
|
6
6
|
codebaseImpactAnalysisTool,
|
|
@@ -14,135 +14,135 @@ import {
|
|
|
14
14
|
codebaseStatsTool,
|
|
15
15
|
codebaseTargetedTestTool,
|
|
16
16
|
deadCodeScanTool
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YEISRT4S.js";
|
|
18
18
|
import {
|
|
19
19
|
planTool
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5KS24LTS.js";
|
|
21
21
|
import {
|
|
22
22
|
taskTool
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-LQSOU63Z.js";
|
|
24
24
|
import {
|
|
25
25
|
toolSearchTool
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-24T5XIJU.js";
|
|
27
27
|
import {
|
|
28
28
|
toolUseTool
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-B3MGJBFI.js";
|
|
30
30
|
import {
|
|
31
31
|
batchToolUseTool
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-VBF2YXUW.js";
|
|
33
33
|
import {
|
|
34
34
|
toolHelpTool
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-7ODZTPCU.js";
|
|
36
36
|
import {
|
|
37
37
|
designTool
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-IXIS7RSG.js";
|
|
39
39
|
import {
|
|
40
40
|
testTool
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-QA6IASYX.js";
|
|
42
42
|
import {
|
|
43
43
|
installTool
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-O6BY43ZB.js";
|
|
45
45
|
import {
|
|
46
46
|
auditTool
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-WEEVSWQB.js";
|
|
48
48
|
import {
|
|
49
49
|
outdatedTool
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-6GOZTS6F.js";
|
|
51
51
|
import {
|
|
52
52
|
logsTool
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-VU3QBYL4.js";
|
|
54
54
|
import {
|
|
55
55
|
documentTool
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-CHEK3ASV.js";
|
|
57
57
|
import {
|
|
58
58
|
scaffoldTool
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-KLJZ4WV4.js";
|
|
60
60
|
import {
|
|
61
61
|
gitTool
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-AQ5YBURX.js";
|
|
63
63
|
import {
|
|
64
64
|
patchTool
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-CGXTR34H.js";
|
|
66
66
|
import {
|
|
67
67
|
jsonTool
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-VZGPASGD.js";
|
|
69
69
|
import {
|
|
70
70
|
diffTool
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-7HL23T3T.js";
|
|
72
72
|
import {
|
|
73
73
|
treeTool
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-JDOO4P6Z.js";
|
|
75
75
|
import {
|
|
76
76
|
lintTool
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-3D5DJWOE.js";
|
|
78
78
|
import {
|
|
79
79
|
formatTool
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-NJX2RXKJ.js";
|
|
81
81
|
import {
|
|
82
82
|
typecheckTool
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-4WPBS45A.js";
|
|
84
84
|
import {
|
|
85
85
|
languageInfoTool,
|
|
86
86
|
languagePackageTool,
|
|
87
87
|
languageTool
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-7N5U2RAU.js";
|
|
89
89
|
import {
|
|
90
90
|
replaceTool
|
|
91
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-IYH4OHBP.js";
|
|
92
92
|
import {
|
|
93
93
|
globTool
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-ASEXQRA7.js";
|
|
95
95
|
import {
|
|
96
96
|
grepTool
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-4ERMPDHV.js";
|
|
98
98
|
import {
|
|
99
99
|
bashTool,
|
|
100
100
|
checkAndBlockKillCommand,
|
|
101
101
|
diagnoseBashism,
|
|
102
102
|
shellArgs
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-NN2SNP2R.js";
|
|
104
104
|
import {
|
|
105
105
|
detectDanger,
|
|
106
106
|
execTool
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-KDEXUQY7.js";
|
|
108
108
|
import {
|
|
109
109
|
buildChildEnv
|
|
110
110
|
} from "./chunk-BTSFTGIL.js";
|
|
111
111
|
import {
|
|
112
112
|
createOutputSpool,
|
|
113
113
|
spoolNote
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-SCMRM6NL.js";
|
|
115
115
|
import {
|
|
116
116
|
getProcessRegistry,
|
|
117
117
|
redactCommand
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-HDYUBRMF.js";
|
|
119
119
|
import {
|
|
120
120
|
fetchTool
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-MJSJWXBF.js";
|
|
122
122
|
import {
|
|
123
123
|
searchTool
|
|
124
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-62OAECEQ.js";
|
|
125
125
|
import {
|
|
126
126
|
todoTool
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-FBUP524S.js";
|
|
128
128
|
import {
|
|
129
129
|
kanbanTool
|
|
130
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-SMARDKAC.js";
|
|
131
131
|
import {
|
|
132
132
|
browserTools
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-SOR7OCYP.js";
|
|
134
134
|
import {
|
|
135
135
|
readTool
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-MK2JK35J.js";
|
|
137
137
|
import {
|
|
138
138
|
writeTool
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-GKSG5CPH.js";
|
|
140
140
|
import {
|
|
141
141
|
editTool
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-DK4J2WMH.js";
|
|
143
143
|
import {
|
|
144
144
|
resolvePowerShell
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-KE7A76VC.js";
|
|
146
146
|
import {
|
|
147
147
|
normalizeCommandOutput,
|
|
148
148
|
safeResolveProjectPath,
|
|
@@ -204,12 +204,13 @@ var clarifyTool = {
|
|
|
204
204
|
const hostAsk = ctx.askUserChoices;
|
|
205
205
|
if (typeof hostAsk === "function") {
|
|
206
206
|
const res = await hostAsk(input.question, options, input.isMultiSelect);
|
|
207
|
+
const selected = Array.isArray(res?.selected) ? res.selected : [];
|
|
207
208
|
return {
|
|
208
209
|
status: "answered",
|
|
209
210
|
question: input.question,
|
|
210
|
-
selectedOptions:
|
|
211
|
-
customResponse: res
|
|
212
|
-
decisionSummary: `User selected: ${
|
|
211
|
+
selectedOptions: selected,
|
|
212
|
+
customResponse: res?.custom,
|
|
213
|
+
decisionSummary: `User selected: ${selected.join(", ")}${res?.custom ? ` (Custom: ${res.custom})` : ""}`
|
|
213
214
|
};
|
|
214
215
|
}
|
|
215
216
|
const defaultChoice = input.recommendedOption ?? options[0] ?? "Default";
|
|
@@ -746,13 +747,15 @@ ${hint}` : "") + cautionText;
|
|
|
746
747
|
outcome: timedOut ? `timed out (exit ${c.code})` : `exit ${c.code}`,
|
|
747
748
|
risk: "shell"
|
|
748
749
|
});
|
|
750
|
+
const isAborted = callerSignal.aborted;
|
|
749
751
|
yield {
|
|
750
752
|
type: "final",
|
|
751
753
|
output: {
|
|
752
754
|
output: finalResultText,
|
|
753
|
-
exit_code: timedOut ?
|
|
754
|
-
timed_out: timedOut,
|
|
755
|
-
pid
|
|
755
|
+
exit_code: timedOut || isAborted ? 124 : c.code,
|
|
756
|
+
timed_out: timedOut || isAborted,
|
|
757
|
+
pid: pid ?? null,
|
|
758
|
+
...timedOut ? { error: "Command timed out" } : isAborted ? { error: "Command aborted by user or signal" } : {}
|
|
756
759
|
}
|
|
757
760
|
};
|
|
758
761
|
return;
|
|
@@ -765,6 +768,7 @@ ${hint}` : "") + cautionText;
|
|
|
765
768
|
}
|
|
766
769
|
} finally {
|
|
767
770
|
for (const t of timers) clearTimeout(t);
|
|
771
|
+
callerSignal.removeEventListener("abort", onAbort);
|
|
768
772
|
}
|
|
769
773
|
}
|
|
770
774
|
};
|
|
@@ -1034,8 +1038,13 @@ var setWorkingDirTool = {
|
|
|
1034
1038
|
}
|
|
1035
1039
|
if (!isDirectory) {
|
|
1036
1040
|
try {
|
|
1037
|
-
|
|
1041
|
+
if (typeof previous === "string") {
|
|
1042
|
+
ctx.setWorkingDir(previous);
|
|
1043
|
+
} else {
|
|
1044
|
+
ctx.workingDir = previous;
|
|
1045
|
+
}
|
|
1038
1046
|
} catch {
|
|
1047
|
+
ctx.workingDir = previous;
|
|
1039
1048
|
}
|
|
1040
1049
|
return {
|
|
1041
1050
|
current: ctx.workingDir,
|
|
@@ -1078,7 +1087,7 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
|
|
|
1078
1087
|
"codebase-stats": "Report codebase-index health, indexed file and symbol counts, languages, and freshness. Use it before relying on indexed discovery results.",
|
|
1079
1088
|
"codebase-search": "Search indexed symbols, signatures, and documentation with optional language, kind, path, or LSP-kind filters. Use it for semantic discovery before broad text search.",
|
|
1080
1089
|
"codebase-skeleton": "Extract a compact structural skeleton from a source file or directory, preserving declarations while omitting implementation detail. Use it to understand unfamiliar code quickly.",
|
|
1081
|
-
"codebase-repo-map": "Generate a
|
|
1090
|
+
"codebase-repo-map": "Generate a reference-weighted, token-budgeted Repository Map of the codebase within ~1200 tokens by default. Use at the beginning of complex tasks or when navigating unfamiliar repositories to get a bird-eye view of the architecture.",
|
|
1082
1091
|
"codebase-impact-analysis": "Find likely callers, dependents, related tests, and change risk for a named symbol. Use it before changing a public or widely used declaration.",
|
|
1083
1092
|
"codebase-targeted-test": "Discover and run tests that cover a specified symbol, source file, or explicit test files. Use it for focused regression validation after a change.",
|
|
1084
1093
|
"security-ast-scan": "Statically scan source code for supported security patterns and return findings with locations. Use it as a focused code check, not as a substitute for a full security assessment.",
|
|
@@ -1100,8 +1109,8 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
|
|
|
1100
1109
|
task: "Manage structured task records, dependencies, ownership, and promotion into actionable session work. Use it to organize bounded work before delegation or execution.",
|
|
1101
1110
|
git: "Inspect or run scoped Git operations in the project, including status, diff, history, branches, and commits. Review the target and working tree before mutating operations.",
|
|
1102
1111
|
patch: "Apply a unified diff to project files with patch-style context checking. Use it for a reviewed multi-file change when exact patch content is available.",
|
|
1103
|
-
json: "Read, query, validate, or
|
|
1104
|
-
diff: "
|
|
1112
|
+
json: "Read, query, validate, or merge JSON/JSON5/YAML files while preserving valid structure (read-only \u2014 does not write). Use it instead of raw text edits when reading or querying structured data.",
|
|
1113
|
+
diff: "Show file content with line numbers, staged/working-tree diffs via git, or commit/branch diffs. A safer and more structured alternative to raw `git diff` via shell.",
|
|
1105
1114
|
tree: "Render a bounded directory tree with depth, file, hidden-file, and ignore controls. Use it for repository orientation without reading every file.",
|
|
1106
1115
|
lint: "Run the project\u2019s configured linter for a target path or working directory and return diagnostics. Use it after code edits to catch style and static-analysis issues.",
|
|
1107
1116
|
format: "Run the project\u2019s configured formatter on selected files or directories. Use it after editing code, while reviewing the resulting diff for unintended formatting scope.",
|
|
@@ -1114,9 +1123,9 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
|
|
|
1114
1123
|
audit: "Run the package manager\u2019s dependency vulnerability audit and summarize actionable findings. Use it to assess known dependency advisories, not source-code vulnerabilities.",
|
|
1115
1124
|
outdated: "List outdated project dependencies and available versions without changing manifests or lockfiles. Use it to plan dependency maintenance.",
|
|
1116
1125
|
logs: "Read or tail configured local, container, or process logs with bounded output. Use it to investigate a known runtime failure or service behavior.",
|
|
1117
|
-
document: "
|
|
1118
|
-
scaffold: "Preview or generate files from a built-in or custom scaffold template. Use dry_run first to inspect paths and content before creating project files.",
|
|
1119
|
-
design: "
|
|
1126
|
+
document: "List undocumented symbols as read-only candidates; this deprecated preview stub does not generate docstrings or write files. Use the auto-doc plugin when it is enabled.",
|
|
1127
|
+
scaffold: "Preview or generate files from a built-in or custom scaffold template. Writes files to disk unless dry_run is set. Use dry_run first to inspect paths and content before creating project files.",
|
|
1128
|
+
design: "Choose, preview, or materialize a UI design kit (e.g. minimal-clarity, neo-brutalist) for the active stack. Lists available kits, previews tokens, or writes a design-token source file to the project.",
|
|
1120
1129
|
tool_search: "Discover registered tools by name, description, tag, permission, or mutating status. Use it to find a lazy capability before calling it through tool-use.",
|
|
1121
1130
|
tool_use: "Invoke a registered tool by name with its input object, including a tool discovered lazily. Use it only after confirming the target tool\u2019s schema and side effects.",
|
|
1122
1131
|
batch_tool_use: "Invoke several independent registered tools as a batch and return each result. Use it for parallel read-only discovery; avoid batching dependent or destructive operations.",
|
|
@@ -1266,9 +1275,11 @@ var builtinTools = rawBuiltinTools.map((tool) => {
|
|
|
1266
1275
|
export {
|
|
1267
1276
|
clarifyTool,
|
|
1268
1277
|
PWSH_TOOL_DESCRIPTION,
|
|
1278
|
+
PWSH_TOOL_USAGE_HINT,
|
|
1269
1279
|
pwshTool,
|
|
1270
1280
|
analyzeSecurityAndPerformance,
|
|
1271
1281
|
securityAstScanTool,
|
|
1282
|
+
setWorkingDirTool,
|
|
1272
1283
|
BUILTIN_TOOL_DESCRIPTIONS,
|
|
1273
1284
|
OPTIONAL_TOOLS,
|
|
1274
1285
|
OFF_ONLY_TOOLS,
|
|
@@ -1277,4 +1288,4 @@ export {
|
|
|
1277
1288
|
TIER3_TOOLS,
|
|
1278
1289
|
builtinTools
|
|
1279
1290
|
};
|
|
1280
|
-
//# sourceMappingURL=chunk-
|
|
1291
|
+
//# sourceMappingURL=chunk-AB2CAUOP.js.map
|
|
@@ -103,6 +103,12 @@ var gitTool = {
|
|
|
103
103
|
field: "command"
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
+
if (input.limit !== void 0 && (typeof input.limit !== "number" || !Number.isFinite(input.limit) || input.limit <= 0)) {
|
|
107
|
+
throw new ToolValidationError({
|
|
108
|
+
message: "git: limit must be a positive integer",
|
|
109
|
+
field: "limit"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
106
112
|
if (input.command === "commit" && !input.message) {
|
|
107
113
|
return {
|
|
108
114
|
command: "commit",
|
|
@@ -214,7 +220,8 @@ function findGitDir(cwd, projectRoot) {
|
|
|
214
220
|
function buildArgs(input) {
|
|
215
221
|
const rawLimit = typeof input.limit === "number" && Number.isFinite(input.limit) && input.limit > 0 ? Math.floor(input.limit) : 20;
|
|
216
222
|
const limit = Math.max(1, rawLimit);
|
|
217
|
-
const
|
|
223
|
+
const rawFiles = input.files ? (Array.isArray(input.files) ? input.files : input.files.split(",")).filter((s) => typeof s === "string").map((s) => s.trim().replace(/\\/g, "/")).filter(Boolean) : [];
|
|
224
|
+
const files = [...new Set(rawFiles)];
|
|
218
225
|
switch (input.command) {
|
|
219
226
|
case "status":
|
|
220
227
|
return ["status", ...files.length ? ["--", ...files] : []];
|
|
@@ -247,9 +254,14 @@ function buildArgs(input) {
|
|
|
247
254
|
case "stash":
|
|
248
255
|
return input.message ? ["stash", "push", "-m", input.message] : ["stash", "push"];
|
|
249
256
|
case "push":
|
|
250
|
-
return [
|
|
257
|
+
return [
|
|
258
|
+
"push",
|
|
259
|
+
...input.dry_run ? ["--dry-run"] : [],
|
|
260
|
+
...input.force ? ["--force"] : [],
|
|
261
|
+
...input.branch ? ["origin", input.branch] : []
|
|
262
|
+
];
|
|
251
263
|
case "pull":
|
|
252
|
-
return ["pull"];
|
|
264
|
+
return ["pull", ...input.branch ? ["origin", input.branch] : []];
|
|
253
265
|
case "fetch":
|
|
254
266
|
return ["fetch", ...input.branch ? [input.branch] : ["--all"]];
|
|
255
267
|
case "reset":
|
|
@@ -361,4 +373,4 @@ function runGit(args, cwd, signal) {
|
|
|
361
373
|
export {
|
|
362
374
|
gitTool
|
|
363
375
|
};
|
|
364
|
-
//# sourceMappingURL=chunk-
|
|
376
|
+
//# sourceMappingURL=chunk-AQ5YBURX.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mapWithConcurrency
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZBMANLYH.js";
|
|
4
4
|
import {
|
|
5
5
|
loadGitignoreMatcher
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2CTZW6JQ.js";
|
|
7
7
|
import {
|
|
8
8
|
assertRealInsideRoot,
|
|
9
9
|
safeResolveReal
|
|
@@ -71,18 +71,28 @@ var globTool = {
|
|
|
71
71
|
const visitedRealDirs = /* @__PURE__ */ new Set();
|
|
72
72
|
let truncated = false;
|
|
73
73
|
const pushResult = async (full) => {
|
|
74
|
-
if (signal?.aborted
|
|
74
|
+
if (signal?.aborted) {
|
|
75
75
|
truncated = true;
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
79
|
const st = await fs.stat(full);
|
|
80
|
-
if (
|
|
80
|
+
if (signal?.aborted) {
|
|
81
81
|
truncated = true;
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
results.
|
|
85
|
-
|
|
84
|
+
if (results.length < limit) {
|
|
85
|
+
results.push({ rel: full, mtime: st.mtimeMs });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
truncated = true;
|
|
89
|
+
let oldestIndex = 0;
|
|
90
|
+
for (let i = 1; i < results.length; i++) {
|
|
91
|
+
if (results[i].mtime < results[oldestIndex].mtime) oldestIndex = i;
|
|
92
|
+
}
|
|
93
|
+
if (st.mtimeMs > results[oldestIndex].mtime) {
|
|
94
|
+
results[oldestIndex] = { rel: full, mtime: st.mtimeMs };
|
|
95
|
+
}
|
|
86
96
|
} catch {
|
|
87
97
|
}
|
|
88
98
|
};
|
|
@@ -94,10 +104,6 @@ var globTool = {
|
|
|
94
104
|
const realDir = await fs.realpath(dir).catch(() => dir);
|
|
95
105
|
if (visitedRealDirs.has(realDir)) return;
|
|
96
106
|
visitedRealDirs.add(realDir);
|
|
97
|
-
if (results.length >= limit) {
|
|
98
|
-
truncated = true;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
107
|
let entries;
|
|
102
108
|
try {
|
|
103
109
|
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
@@ -138,16 +144,10 @@ var globTool = {
|
|
|
138
144
|
} catch {
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
|
-
if (
|
|
147
|
+
if (signal?.aborted) return;
|
|
142
148
|
}
|
|
143
149
|
await mapWithConcurrency(matchedFiles, WALK_CONCURRENCY, pushResult);
|
|
144
|
-
|
|
145
|
-
const remainingSubdirs = truncated ? [] : subdirs;
|
|
146
|
-
await mapWithConcurrency(
|
|
147
|
-
remainingSubdirs,
|
|
148
|
-
WALK_CONCURRENCY,
|
|
149
|
-
({ full, rel }) => walk(full, rel)
|
|
150
|
-
);
|
|
150
|
+
await mapWithConcurrency(subdirs, WALK_CONCURRENCY, ({ full, rel }) => walk(full, rel));
|
|
151
151
|
};
|
|
152
152
|
await walk(base, "");
|
|
153
153
|
results.sort((a, b) => b.mtime - a.mtime);
|
|
@@ -158,4 +158,4 @@ var globTool = {
|
|
|
158
158
|
export {
|
|
159
159
|
globTool
|
|
160
160
|
};
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-ASEXQRA7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
enqueueReindex
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZTCJCYLN.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveRealInsideRoot,
|
|
6
6
|
safeResolveReal,
|
|
@@ -42,6 +42,21 @@ var patchTool = {
|
|
|
42
42
|
},
|
|
43
43
|
required: ["patch"]
|
|
44
44
|
},
|
|
45
|
+
// VULN-001 Phase 2: the permission layer's input-key heuristic cannot see
|
|
46
|
+
// destinations encoded in the diff body, so the confirm prompt keyed on
|
|
47
|
+
// `directory` (".") while the patch wrote elsewhere. Declares the stripped
|
|
48
|
+
// relative destinations; execute()'s realpath containment above remains
|
|
49
|
+
// the authority on whether they are allowed.
|
|
50
|
+
writeTargets(input) {
|
|
51
|
+
if (!input?.patch || typeof input.patch !== "string" || !input.patch.trim()) return [];
|
|
52
|
+
const strip = typeof input.strip === "number" && Number.isFinite(input.strip) && input.strip >= 0 ? Math.floor(input.strip) : 1;
|
|
53
|
+
const out = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const target of extractDiffTargets(input.patch)) {
|
|
55
|
+
const stripped = stripPathComponents(target.raw, strip);
|
|
56
|
+
if (stripped) out.add(stripped);
|
|
57
|
+
}
|
|
58
|
+
return [...out];
|
|
59
|
+
},
|
|
45
60
|
async execute(input, ctx, opts) {
|
|
46
61
|
if (!input?.patch || typeof input.patch !== "string" || !input.patch.trim()) {
|
|
47
62
|
throw new ToolValidationError({
|
|
@@ -51,6 +66,12 @@ var patchTool = {
|
|
|
51
66
|
}
|
|
52
67
|
const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
|
|
53
68
|
signal.throwIfAborted();
|
|
69
|
+
if (input.strip !== void 0 && (typeof input.strip !== "number" || !Number.isFinite(input.strip) || input.strip < 0)) {
|
|
70
|
+
throw new ToolValidationError({
|
|
71
|
+
message: "patch: strip must be a non-negative integer",
|
|
72
|
+
field: "strip"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
54
75
|
const strip = typeof input.strip === "number" && Number.isFinite(input.strip) && input.strip >= 0 ? Math.floor(input.strip) : 1;
|
|
55
76
|
const dryRun = input.dry_run ?? false;
|
|
56
77
|
const refuse = (message) => ({
|
|
@@ -68,6 +89,11 @@ var patchTool = {
|
|
|
68
89
|
}
|
|
69
90
|
const realRoot = await fs.realpath(ctx.projectRoot).catch(() => path.resolve(ctx.projectRoot));
|
|
70
91
|
const targets = extractDiffTargets(input.patch);
|
|
92
|
+
if (targets.length === 0) {
|
|
93
|
+
return refuse(
|
|
94
|
+
"patch refused: no file target could be parsed from the patch (fail-closed containment \u2014 refusing an unparseable diff)"
|
|
95
|
+
);
|
|
96
|
+
}
|
|
71
97
|
const resolvedTargets = [];
|
|
72
98
|
for (const t of targets) {
|
|
73
99
|
const stripped = stripPathComponents(t.raw, strip);
|
|
@@ -88,6 +114,11 @@ var patchTool = {
|
|
|
88
114
|
}
|
|
89
115
|
resolvedTargets.push({ raw: t.raw, deleted: t.deleted, abs: real });
|
|
90
116
|
}
|
|
117
|
+
if (resolvedTargets.length === 0) {
|
|
118
|
+
return refuse(
|
|
119
|
+
"patch refused: no file target could be resolved from the patch (fail-closed containment \u2014 target paths stripped to empty)"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
91
122
|
const beforeContents = /* @__PURE__ */ new Map();
|
|
92
123
|
const beforeExisted = /* @__PURE__ */ new Set();
|
|
93
124
|
if (!dryRun) {
|
|
@@ -160,7 +191,11 @@ var patchTool = {
|
|
|
160
191
|
message: `patch failed: ${result.stderr || result.stdout}${partial}`
|
|
161
192
|
};
|
|
162
193
|
}
|
|
163
|
-
const wouldPatch =
|
|
194
|
+
const wouldPatch = result.engine === "git" ? [
|
|
195
|
+
...new Set(
|
|
196
|
+
resolvedTargets.map((target) => path.relative(dir, target.abs) || target.abs)
|
|
197
|
+
)
|
|
198
|
+
] : extractPatchedFiles(result.stdout);
|
|
164
199
|
return {
|
|
165
200
|
applied: wouldPatch.length,
|
|
166
201
|
rejected: 1,
|
|
@@ -233,6 +268,31 @@ function extractDiffTargets(patch) {
|
|
|
233
268
|
if (oldLinesLeft <= 0 && newLinesLeft <= 0) inHunk = false;
|
|
234
269
|
continue;
|
|
235
270
|
}
|
|
271
|
+
if (line.startsWith("diff --git ")) {
|
|
272
|
+
const rest = line.slice("diff --git ".length);
|
|
273
|
+
if (rest.startsWith('"')) {
|
|
274
|
+
const quoted = /^"((?:[^"\\]|\\.)*)"\s+"((?:[^"\\]|\\.)*)"$/.exec(rest);
|
|
275
|
+
if (quoted) {
|
|
276
|
+
for (const half of [quoted[1], quoted[2]]) {
|
|
277
|
+
const p = clean(half);
|
|
278
|
+
if (p) out.push({ raw: p, deleted: false });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
const bIdx = rest.lastIndexOf(" b/");
|
|
283
|
+
if (rest.startsWith("a/") && bIdx !== -1) {
|
|
284
|
+
out.push({ raw: rest.slice(0, bIdx), deleted: false });
|
|
285
|
+
out.push({ raw: rest.slice(bIdx + 1), deleted: false });
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const extended = /^(?:rename|copy) (?:from|to) (.+)$/.exec(line);
|
|
291
|
+
if (extended) {
|
|
292
|
+
const p = clean(extended[1]);
|
|
293
|
+
if (p && p !== "/dev/null") out.push({ raw: p, deleted: false });
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
236
296
|
const oldMatch = /^---\s+([^\t\r\n]+)/.exec(line);
|
|
237
297
|
if (oldMatch) {
|
|
238
298
|
lastOld = clean(oldMatch[1]);
|
|
@@ -269,7 +329,6 @@ function runPatch(args, cwd, signal, fallback) {
|
|
|
269
329
|
if (!result.unavailable) return { ...result, engine: "patch" };
|
|
270
330
|
const gitArgs = [
|
|
271
331
|
"apply",
|
|
272
|
-
"--unsafe-paths",
|
|
273
332
|
`-p${fallback.strip}`,
|
|
274
333
|
"--verbose",
|
|
275
334
|
...fallback.dryRun ? ["--check"] : [],
|
|
@@ -336,4 +395,4 @@ function extractPatchedFiles(output) {
|
|
|
336
395
|
export {
|
|
337
396
|
patchTool
|
|
338
397
|
};
|
|
339
|
-
//# sourceMappingURL=chunk-
|
|
398
|
+
//# sourceMappingURL=chunk-CGXTR34H.js.map
|
|
@@ -29,7 +29,10 @@ var documentTool = {
|
|
|
29
29
|
description: "Specific file path to document"
|
|
30
30
|
},
|
|
31
31
|
files: {
|
|
32
|
-
|
|
32
|
+
oneOf: [
|
|
33
|
+
{ type: "string" },
|
|
34
|
+
{ type: "array", items: { type: "string" } }
|
|
35
|
+
],
|
|
33
36
|
description: "File(s) to process: single path, comma-separated list, or glob"
|
|
34
37
|
},
|
|
35
38
|
style: {
|
|
@@ -111,7 +114,7 @@ async function resolveFiles(filesInput, cwd, ctx) {
|
|
|
111
114
|
} catch {
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
|
-
return resolved;
|
|
117
|
+
return [...new Set(resolved)];
|
|
115
118
|
}
|
|
116
119
|
function processFile(content, absPath, _style, _overwrite, target) {
|
|
117
120
|
const results = [];
|
|
@@ -177,4 +180,4 @@ function processFile(content, absPath, _style, _overwrite, target) {
|
|
|
177
180
|
export {
|
|
178
181
|
documentTool
|
|
179
182
|
};
|
|
180
|
-
//# sourceMappingURL=chunk-
|
|
183
|
+
//# sourceMappingURL=chunk-CHEK3ASV.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkSyntax
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MSOAX3GC.js";
|
|
4
4
|
import {
|
|
5
5
|
enqueueReindex
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZTCJCYLN.js";
|
|
7
7
|
import {
|
|
8
8
|
safeResolveReal,
|
|
9
9
|
sha256hex,
|
|
@@ -39,6 +39,9 @@ var FUZZY_MIN_SIMILARITY = 0.9;
|
|
|
39
39
|
var FUZZY_AMBIGUITY_MARGIN = 0.05;
|
|
40
40
|
var FUZZY_MAX_INTERIOR_CHARS = 2e3;
|
|
41
41
|
function findLadderMatches(fileLf, oldLf) {
|
|
42
|
+
if (typeof fileLf !== "string" || typeof oldLf !== "string" || oldLf.length === 0) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
42
45
|
const exact = [];
|
|
43
46
|
let idx = fileLf.indexOf(oldLf);
|
|
44
47
|
let currentLine = 1;
|
|
@@ -137,6 +140,10 @@ function fuzzyScan(fileLines, needleLines, offsets, includeTrailingNewline = fal
|
|
|
137
140
|
if (fileTrimmed[i + n - 1] !== lastNeedle) continue;
|
|
138
141
|
const windowInterior = fileTrimmed.slice(i + 1, i + n - 1).join("\n");
|
|
139
142
|
if (windowInterior.length > FUZZY_MAX_INTERIOR_CHARS) continue;
|
|
143
|
+
const maxLen = Math.max(needleInterior.length, windowInterior.length);
|
|
144
|
+
if (maxLen > 0 && Math.abs(needleInterior.length - windowInterior.length) / maxLen > 1 - FUZZY_MIN_SIMILARITY) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
140
147
|
const score = similarity(needleInterior, windowInterior);
|
|
141
148
|
if (score >= FUZZY_MIN_SIMILARITY) {
|
|
142
149
|
candidates.push({
|
|
@@ -163,10 +170,6 @@ function similarity(a, b) {
|
|
|
163
170
|
if (a === b) return 1;
|
|
164
171
|
const max = Math.max(a.length, b.length);
|
|
165
172
|
if (max === 0) return 1;
|
|
166
|
-
const lenDiff = Math.abs(a.length - b.length);
|
|
167
|
-
if (lenDiff / max > 1 - FUZZY_MIN_SIMILARITY) {
|
|
168
|
-
return 1 - lenDiff / max;
|
|
169
|
-
}
|
|
170
173
|
return 1 - levenshtein(a, b) / max;
|
|
171
174
|
}
|
|
172
175
|
function levenshtein(a, b) {
|
|
@@ -359,7 +362,7 @@ var editTool = {
|
|
|
359
362
|
field: "path"
|
|
360
363
|
});
|
|
361
364
|
}
|
|
362
|
-
const autoRead = !ctx.hasRead(absPath);
|
|
365
|
+
const autoRead = ctx.hasRead ? !ctx.hasRead(absPath) : false;
|
|
363
366
|
const original = await fs.readFile(absPath, "utf8");
|
|
364
367
|
const updated = await fs.stat(absPath);
|
|
365
368
|
const mtimeTolerance = process.platform === "win32" ? 2e3 : 1;
|
|
@@ -374,7 +377,7 @@ var editTool = {
|
|
|
374
377
|
});
|
|
375
378
|
}
|
|
376
379
|
} else {
|
|
377
|
-
const lastReadMtime = ctx.lastReadMtime(absPath);
|
|
380
|
+
const lastReadMtime = ctx.lastReadMtime?.(absPath);
|
|
378
381
|
if (lastReadMtime !== void 0 && updated.mtimeMs > lastReadMtime + mtimeTolerance) {
|
|
379
382
|
throw new ToolValidationError({
|
|
380
383
|
message: `edit: file "${input.path}" was modified externally. Re-read it first.`,
|
|
@@ -399,7 +402,7 @@ var editTool = {
|
|
|
399
402
|
if (!fileLf.includes(oldLf)) {
|
|
400
403
|
throw noMatchError(input.path, fileLf, oldLf);
|
|
401
404
|
}
|
|
402
|
-
if (autoRead) ctx.recordRead(absPath, updated.mtimeMs, "user", originalHash);
|
|
405
|
+
if (autoRead) ctx.recordRead?.(absPath, updated.mtimeMs, "user", originalHash);
|
|
403
406
|
return {
|
|
404
407
|
path: absPath,
|
|
405
408
|
replacements: 0,
|
|
@@ -470,7 +473,7 @@ var editTool = {
|
|
|
470
473
|
} catch {
|
|
471
474
|
}
|
|
472
475
|
const written = await fs.stat(absPath);
|
|
473
|
-
ctx.recordRead(absPath, written.mtimeMs, "write", sha256hex(newFile));
|
|
476
|
+
ctx.recordRead?.(absPath, written.mtimeMs, "write", sha256hex(newFile));
|
|
474
477
|
ctx.session?.recordFileChange?.({
|
|
475
478
|
path: absPath,
|
|
476
479
|
action: "modified",
|
|
@@ -515,4 +518,4 @@ Compare this against your old_string and retry with the file's actual text.` : "
|
|
|
515
518
|
export {
|
|
516
519
|
editTool
|
|
517
520
|
};
|
|
518
|
-
//# sourceMappingURL=chunk-
|
|
521
|
+
//# sourceMappingURL=chunk-DK4J2WMH.js.map
|