pi-web-ui 0.118.0 → 0.120.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.
Files changed (195) hide show
  1. package/CHANGELOG.md +143 -1
  2. package/bin/hub-upgrade.mjs +33 -15
  3. package/bin/lib/atomic-file.mjs +90 -0
  4. package/dist/server/agent-service-daemon.js +44 -10
  5. package/dist/server/agent-service.js +930 -166
  6. package/dist/server/approval-default-rules.js +4 -4
  7. package/dist/server/ask-user-question-tool.js +3 -40
  8. package/dist/server/atomic-file.js +130 -5
  9. package/dist/server/background-executors.js +235 -0
  10. package/dist/server/bash-timeout.js +47 -0
  11. package/dist/server/bash-tool.js +72 -5
  12. package/dist/server/bg-servers.js +19 -13
  13. package/dist/server/browser-page-tool.js +38 -29
  14. package/dist/server/browser-script-tool.js +119 -0
  15. package/dist/server/canvas/canvas-agent-tool.js +46 -35
  16. package/dist/server/canvas/canvas-dispatch.js +12 -1
  17. package/dist/server/claim-files-tool.js +6 -7
  18. package/dist/server/client-state.js +457 -41
  19. package/dist/server/communicate-tool.js +59 -77
  20. package/dist/server/compact-context-tool.js +4 -13
  21. package/dist/server/conversation-communication.js +23 -1
  22. package/dist/server/conversation-read-tool.js +14 -23
  23. package/dist/server/conversation-rows.js +17 -0
  24. package/dist/server/conversation-tool-names.js +2 -2
  25. package/dist/server/conversation-tool.js +23 -15
  26. package/dist/server/conversation-touches.js +1 -1
  27. package/dist/server/delegate-mode.js +0 -1
  28. package/dist/server/delegate-task.js +18 -39
  29. package/dist/server/device-center/approval-summary.js +0 -1
  30. package/dist/server/device-center/bot-execution.js +0 -1
  31. package/dist/server/device-center/group-router-runtime.js +2 -0
  32. package/dist/server/device-center/hub-upgrade.js +5 -10
  33. package/dist/server/device-center/task-progress.js +2 -2
  34. package/dist/server/dispatch-domain-handlers.js +97 -24
  35. package/dist/server/dispatch-plugin-handlers.js +10 -0
  36. package/dist/server/dsh/dsh-agent-service.js +21 -19
  37. package/dist/server/durable/durable-agent-service.js +1 -1
  38. package/dist/server/edit-tool.js +293 -0
  39. package/dist/server/engine-catalog.js +8 -2
  40. package/dist/server/engine-cli.js +29 -7
  41. package/dist/server/engine-probe.js +11 -6
  42. package/dist/server/eval-tool.js +5 -19
  43. package/dist/server/files-service.js +41 -19
  44. package/dist/server/fs-copy.js +93 -0
  45. package/dist/server/goal-review-gate.js +2 -3
  46. package/dist/server/index.js +92 -3
  47. package/dist/server/job-runner.js +345 -0
  48. package/dist/server/lsp-tool.js +10 -28
  49. package/dist/server/marker-service.js +42 -30
  50. package/dist/server/mcp-agent-tool.js +22 -47
  51. package/dist/server/model-session.js +16 -0
  52. package/dist/server/native-cli-session-hooks.js +3 -2
  53. package/dist/server/native-cli-session.js +27 -2
  54. package/dist/server/patch-tool.js +2 -8
  55. package/dist/server/phone-tool.js +167 -0
  56. package/dist/server/plan-mode.js +7 -4
  57. package/dist/server/plan-update-tool.js +5 -8
  58. package/dist/server/plugin-api-catalog.js +13 -1
  59. package/dist/server/plugin-bundled.js +35 -28
  60. package/dist/server/plugin-catalog.js +6 -0
  61. package/dist/server/plugin-delivery.js +358 -0
  62. package/dist/server/plugin-inbox.js +152 -0
  63. package/dist/server/plugin-installer.js +15 -0
  64. package/dist/server/plugin-ledger.js +183 -0
  65. package/dist/server/plugin-manifest-validate.js +19 -0
  66. package/dist/server/plugin-materialize.js +161 -0
  67. package/dist/server/plugin-paths.js +60 -0
  68. package/dist/server/plugin-removal.js +16 -3
  69. package/dist/server/plugin-schedule.js +8 -7
  70. package/dist/server/plugin-secrets.js +7 -3
  71. package/dist/server/plugin-updater.js +2 -4
  72. package/dist/server/plugins.js +205 -48
  73. package/dist/server/present-files-tool.js +7 -13
  74. package/dist/server/preset-fields.js +23 -12
  75. package/dist/server/preset-share.js +1 -1
  76. package/dist/server/process-utils.js +11 -0
  77. package/dist/server/project-scripts.js +38 -0
  78. package/dist/server/prompt-composer.js +40 -21
  79. package/dist/server/protocol-version.js +1 -1
  80. package/dist/server/question-params.js +98 -0
  81. package/dist/server/quick-ask-settings.js +0 -1
  82. package/dist/server/quick-ask.js +3 -0
  83. package/dist/server/read-tool.js +10 -17
  84. package/dist/server/remote-ssh-service.js +40 -1
  85. package/dist/server/sandbox-runtime-gate.js +1 -1
  86. package/dist/server/sandbox-service.js +0 -1
  87. package/dist/server/sandbox-tool.js +25 -34
  88. package/dist/server/schedule-agent-tool.js +9 -19
  89. package/dist/server/scm-commitmsg.js +2 -1
  90. package/dist/server/serialize.js +8 -0
  91. package/dist/server/session-list-index.js +246 -0
  92. package/dist/server/session-list-scan.js +5 -0
  93. package/dist/server/session-parser.js +16 -0
  94. package/dist/server/settings-service.js +49 -19
  95. package/dist/server/skill-tool.js +4 -6
  96. package/dist/server/subagent-budget.js +68 -0
  97. package/dist/server/subagent-evidence.js +297 -0
  98. package/dist/server/subagent-helpers.js +12 -0
  99. package/dist/server/subagent-ledger.js +401 -0
  100. package/dist/server/subagent-notify.js +6 -2
  101. package/dist/server/subagent-security-gate.js +2 -3
  102. package/dist/server/subagent-settle.js +71 -0
  103. package/dist/server/subagents.js +566 -211
  104. package/dist/server/tabs.js +8 -1
  105. package/dist/server/terminals.js +34 -28
  106. package/dist/server/tool-approval.js +15 -1
  107. package/dist/server/tool-guards.js +0 -91
  108. package/dist/server/tool-manager.js +127 -47
  109. package/dist/server/tool-overrides.js +8 -1
  110. package/dist/server/tool-prompt-overrides.js +3 -6
  111. package/dist/server/tool-prompts.js +60 -17
  112. package/dist/server/universal/driver-base.js +2 -0
  113. package/dist/server/universal/drivers/claude-code.js +210 -211
  114. package/dist/server/universal/drivers/codex.js +29 -24
  115. package/dist/server/universal/engine-mcp.js +107 -0
  116. package/dist/server/universal/universal-attachments.js +77 -1
  117. package/dist/server/universal/universal-service.js +1 -1
  118. package/dist/server/universal/universal-session.js +106 -69
  119. package/dist/server/vision-bridge.js +2 -0
  120. package/dist/server/workspace-handle.js +119 -17
  121. package/dist/server/workspace-queue.js +37 -0
  122. package/dist/server/worktree-tool.js +13 -20
  123. package/docs/README.md +40 -36
  124. package/docs/architecture-plugins.md +64 -35
  125. package/docs/device-center.md +1 -1
  126. package/package.json +16 -4
  127. package/plugin-sdk/index.d.ts +102 -0
  128. package/plugins/catalog.json +23 -51
  129. package/themes/bases/flow-base.css +8 -17
  130. package/themes/dark-teal.css +0 -3
  131. package/web/dist/.build-assets.json +1 -1
  132. package/web/dist/assets/BgTasksModal-BdOJ19Hj.js +1 -0
  133. package/web/dist/assets/BgTasksModal-SAH2XCkY.js +1 -0
  134. package/web/dist/assets/{CanvasStudio-CAWcs9tm.js → CanvasStudio-BB_Iq7pl.js} +3 -3
  135. package/web/dist/assets/CanvasStudio-DU6O3N4u.js +1579 -0
  136. package/web/dist/assets/DeviceCenter-By1zVTSY.js +3 -0
  137. package/web/dist/assets/DeviceCenter-Cnm0Tjrx.js +3 -0
  138. package/web/dist/assets/DeviceExecutionSettings-qJzbI0Cf.js +1 -0
  139. package/web/dist/assets/{DeviceGroups-C_fZMNeK.js → DeviceGroups-DPrQxW6B.js} +1 -1
  140. package/web/dist/assets/DeviceGroups-DoucyUjI.js +1 -0
  141. package/web/dist/assets/{Dropdown-CTgVLUbp.js → Dropdown-kj_NIj6e.js} +1 -1
  142. package/web/dist/assets/FilePreview-Bub8Y9uq.js +2 -0
  143. package/web/dist/assets/FilePreview-CC76Z6an.js +2 -0
  144. package/web/dist/assets/GlobalSearchModal-01nkgw4X.js +1 -0
  145. package/web/dist/assets/GlobalSearchModal-CiT6wBmR.js +1 -0
  146. package/web/dist/assets/GroupConversation-1-lsPO1f.js +61 -0
  147. package/web/dist/assets/GroupConversation-HeiyW_O_.js +61 -0
  148. package/web/dist/assets/{GroupWorkItems-BIvZtr10.js → GroupWorkItems-BYJv2XFj.js} +1 -1
  149. package/web/dist/assets/{HintTip-Da6qc566.js → HintTip-DFhoclDw.js} +1 -1
  150. package/web/dist/assets/ModelConfigModal-D2Ro-jUZ.js +2 -0
  151. package/web/dist/assets/ModelConfigModal-DPc9R1pq.js +2 -0
  152. package/web/dist/assets/{NativeCliPanel-CU1rZmyu.js → NativeCliPanel-B108d697.js} +3 -3
  153. package/web/dist/assets/NativeCliPanel-DupvGwQM.js +5 -0
  154. package/web/dist/assets/{PiSetupModal-DZKY5Wiw.js → PiSetupModal-D0HitBfd.js} +1 -1
  155. package/web/dist/assets/ProviderOAuthControls-BLKUEDde.js +1 -0
  156. package/web/dist/assets/SCMPanel-DDbWrUHR.js +2 -0
  157. package/web/dist/assets/SCMPanel-DluNcd2-.js +2 -0
  158. package/web/dist/assets/SettingsModal-Cy5lRC97.css +1 -0
  159. package/web/dist/assets/SettingsModal-DQu18366.js +33 -0
  160. package/web/dist/assets/SettingsModal-Dm_haPme.js +33 -0
  161. package/web/dist/assets/{TermXterm-Bt5WKAxP.js → TermXterm-SYc-MUk2.js} +2 -2
  162. package/web/dist/assets/TerminalPanel-CgA_lhVT.js +1 -0
  163. package/web/dist/assets/TerminalPanel-vdSIOPjD.js +1 -0
  164. package/web/dist/assets/TuiOverlayModal-Cy1jYYIw.js +1 -0
  165. package/web/dist/assets/TuiOverlayModal-kXY_4hV8.js +1 -0
  166. package/web/dist/assets/app-globals-CBEscsYP.js +129 -0
  167. package/web/dist/assets/{canvas-client-WkhM55mR.js → canvas-client-Clsypfs6.js} +1 -1
  168. package/web/dist/assets/{desktop-B8NZ3KW-.js → desktop-C6D9a8HZ.js} +1 -1
  169. package/web/dist/assets/index-BD29OL9L.js +404 -0
  170. package/web/dist/assets/index-BlCxbqqr.js +404 -0
  171. package/web/dist/assets/index-DB55rbKC.css +1 -0
  172. package/web/dist/assets/plugin-host-VWBcq-LQ.js +1 -0
  173. package/web/dist/assets/remote-ssh-client-C2eab5Kw.js +1 -0
  174. package/web/dist/assets/theme-CpQk_Agp.js +1 -0
  175. package/web/dist/index.html +10 -10
  176. package/web/dist/sw.js +1 -1
  177. package/dist/server/edit-soft-tool.js +0 -297
  178. package/web/dist/assets/BgTasksModal-D-x7kA63.js +0 -1
  179. package/web/dist/assets/DeviceCenter-Dc0whRcu.js +0 -3
  180. package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +0 -1
  181. package/web/dist/assets/FilePreview-C6W0PvaK.js +0 -2
  182. package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +0 -1
  183. package/web/dist/assets/GroupConversation-C81YjF2C.js +0 -61
  184. package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +0 -2
  185. package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +0 -1
  186. package/web/dist/assets/SCMPanel-CuEgzAlO.js +0 -2
  187. package/web/dist/assets/SettingsModal-Cdu5h29p.js +0 -33
  188. package/web/dist/assets/TerminalPanel-BCIBV8se.js +0 -1
  189. package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +0 -1
  190. package/web/dist/assets/app-globals-CZjFtI4F.js +0 -129
  191. package/web/dist/assets/index-CQc3VrWa.css +0 -1
  192. package/web/dist/assets/index-D_AGu4Zv.js +0 -404
  193. package/web/dist/assets/plugin-host-uqZGpvCs.js +0 -1
  194. package/web/dist/assets/remote-ssh-client-Cdf-cTUe.js +0 -1
  195. package/web/dist/assets/theme-DGL7hLUs.js +0 -1
@@ -0,0 +1,293 @@
1
+ import { constants } from "node:fs";
2
+ import { access, readFile, writeFile } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { isAbsolute, join, resolve as nodeResolve } from "node:path";
5
+ import { createEditToolDefinition, generateDiffString, generateUnifiedPatch, withFileMutationQueue, } from "@earendil-works/pi-coding-agent";
6
+ import { pick } from "./i18n.js";
7
+ import { createRemoteSdkOperations } from "./remote-ssh-service.js";
8
+ import { EDIT_DESCRIPTION, EDIT_PARAMETERS, EDIT_PROMPT_GUIDELINES, EDIT_PROMPT_SNIPPET } from "./tool-prompts.js";
9
+ function isSingleEditInput(value) {
10
+ if (!value || typeof value !== "object" || Array.isArray(value))
11
+ return false;
12
+ const e = value;
13
+ return typeof e.oldText === "string" && typeof e.newText === "string";
14
+ }
15
+ /** Tolerates the argument shapes models emit for edit calls (edits as JSON string / single object / legacy flat pair). */
16
+ export function prepareEditArguments(input) {
17
+ if (!input || typeof input !== "object")
18
+ return input;
19
+ const args = input;
20
+ if (typeof args.edits === "string") {
21
+ try {
22
+ const parsed = JSON.parse(args.edits);
23
+ if (Array.isArray(parsed))
24
+ args.edits = parsed;
25
+ else if (isSingleEditInput(parsed))
26
+ args.edits = [parsed];
27
+ }
28
+ catch { }
29
+ }
30
+ else if (isSingleEditInput(args.edits)) {
31
+ args.edits = [args.edits];
32
+ }
33
+ const legacy = args;
34
+ if (typeof legacy.oldText === "string" && typeof legacy.newText === "string") {
35
+ const edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];
36
+ edits.push({ oldText: legacy.oldText, newText: legacy.newText });
37
+ const { oldText: _o, newText: _n, ...rest } = legacy;
38
+ return { ...rest, edits };
39
+ }
40
+ return args;
41
+ }
42
+ function splitBom(content) {
43
+ return content.startsWith("\uFEFF") ? { bom: "\uFEFF", text: content.slice(1) } : { bom: "", text: content };
44
+ }
45
+ function detectLineEnding(content) {
46
+ const crlfIdx = content.indexOf("\r\n");
47
+ const lfIdx = content.indexOf("\n");
48
+ if (lfIdx === -1)
49
+ return "\n";
50
+ if (crlfIdx === -1)
51
+ return "\n";
52
+ return crlfIdx < lfIdx ? "\r\n" : "\n";
53
+ }
54
+ function normalizeToLF(text) {
55
+ return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
56
+ }
57
+ function restoreLineEndings(text, ending) {
58
+ return ending === "\r\n" ? text.replace(/\n/g, "\r\n") : text;
59
+ }
60
+ const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
61
+ function normalizeShellPath(p) {
62
+ if (!p.startsWith("/") || p.startsWith("//") || p.includes("\\"))
63
+ return p;
64
+ const m = p.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);
65
+ if (!m)
66
+ return p;
67
+ return `${m[1].toUpperCase()}:\\${(m[2] ?? "").replaceAll("/", "\\")}`;
68
+ }
69
+ function resolveToCwd(filePath, cwd) {
70
+ let p = filePath.replace(UNICODE_SPACES, " ");
71
+ if (p.startsWith("@"))
72
+ p = p.slice(1);
73
+ if (process.platform === "win32")
74
+ p = normalizeShellPath(p);
75
+ const home = homedir();
76
+ if (p === "~")
77
+ return home;
78
+ if (p.startsWith("~/"))
79
+ return join(home, p.slice(2));
80
+ return isAbsolute(p) ? nodeResolve(p) : nodeResolve(cwd, p);
81
+ }
82
+ function splitLineUnits(text) {
83
+ const units = [];
84
+ const re = /[^\n]*\n|[^\n]+/g;
85
+ let offset = 0;
86
+ let m;
87
+ while ((m = re.exec(text)) !== null) {
88
+ const chunk = m[0];
89
+ const newline = chunk.endsWith("\n") ? "\n" : "";
90
+ const raw = newline ? chunk.slice(0, -1) : chunk;
91
+ units.push({ raw, newline, start: offset, end: offset + chunk.length, core: raw.trim() });
92
+ offset += chunk.length;
93
+ }
94
+ return units;
95
+ }
96
+ export function oldTextCores(oldTextLF) {
97
+ const parts = oldTextLF.split("\n");
98
+ if (parts.length > 0 && parts[parts.length - 1] === "")
99
+ parts.pop();
100
+ return parts.map((p) => p.trim());
101
+ }
102
+ export function fragmentLineEnds(cores, units) {
103
+ const isMidLineFragment = (core) => {
104
+ if (core === "")
105
+ return false;
106
+ if (units.some((u) => u.core === core))
107
+ return false;
108
+ return units.some((u) => {
109
+ const idx = u.raw.indexOf(core);
110
+ return idx > 0 && idx + core.length < u.raw.length;
111
+ });
112
+ };
113
+ const ends = [];
114
+ if (cores.length > 0 && isMidLineFragment(cores[0]))
115
+ ends.push(0);
116
+ if (cores.length > 1 && isMidLineFragment(cores[cores.length - 1]))
117
+ ends.push(1);
118
+ return ends;
119
+ }
120
+ export function isMisalignedMultilineFragment(content, start, oldTextLF) {
121
+ if (!oldTextLF.includes("\n"))
122
+ return false;
123
+ const end = start + oldTextLF.length;
124
+ const startsAtLineStart = start === 0 || content[start - 1] === "\n";
125
+ const endsAtLineBoundary = end === content.length || content[end] === "\n" || content[end - 1] === "\n";
126
+ return !(startsAtLineStart && endsAtLineBoundary);
127
+ }
128
+ class EditMatchError extends Error {
129
+ constructor(message) {
130
+ super(message);
131
+ }
132
+ }
133
+ function locateSoftReplacement(normalizedContent, oldTextLF, newTextLF, path, editIndex, lang) {
134
+ if (oldTextLF.length === 0) {
135
+ throw new EditMatchError(pick(lang, `edits[${editIndex}].oldText 在 ${path} 中不能为空。`, `edits[${editIndex}].oldText must not be empty in ${path}.`, "edit.oldtext.empty", { editIndex, path }));
136
+ }
137
+ const exactIdx = normalizedContent.indexOf(oldTextLF);
138
+ const exactMisaligned = exactIdx !== -1 && isMisalignedMultilineFragment(normalizedContent, exactIdx, oldTextLF);
139
+ if (exactIdx !== -1 && !exactMisaligned) {
140
+ const occurrences = normalizedContent.split(oldTextLF).length - 1;
141
+ if (occurrences > 1) {
142
+ throw new EditMatchError(pick(lang, `在 ${path} 中找到 ${occurrences} 处 edits[${editIndex}].oldText。每个 oldText 必须唯一,请提供更多上下文。`, `Found ${occurrences} occurrences of edits[${editIndex}].oldText in ${path}. Each oldText must be unique. Please provide more context to make it unique.`, "edit.exact.not.unique", { path, occurrences, editIndex }));
143
+ }
144
+ return { start: exactIdx, end: exactIdx + oldTextLF.length, insertText: newTextLF };
145
+ }
146
+ const cores = oldTextCores(oldTextLF);
147
+ if (cores.length === 0) {
148
+ throw new EditMatchError(pick(lang, `edits[${editIndex}].oldText 在 ${path} 中实际为空。`, `edits[${editIndex}].oldText is effectively empty in ${path}.`, "edit.soft.oldtext.blank", { editIndex, path }));
149
+ }
150
+ const units = splitLineUnits(normalizedContent);
151
+ const k = cores.length;
152
+ const starts = [];
153
+ for (let i = 0; i + k <= units.length; i++) {
154
+ let ok = true;
155
+ for (let j = 0; j < k; j++) {
156
+ if (units[i + j].core !== cores[j]) {
157
+ ok = false;
158
+ break;
159
+ }
160
+ }
161
+ if (ok)
162
+ starts.push(i);
163
+ }
164
+ if (starts.length === 0) {
165
+ if (exactMisaligned || fragmentLineEnds(cores, units).length > 0) {
166
+ throw new EditMatchError(pick(lang, `在 ${path} 中找不到该文本:edits[${editIndex}].oldText 跨越多行但首/尾没有落在行边界上(首行或末行只是文件中某行的一部分),而 soft=true 按**整行**匹配。请让 oldText 的每一行都是完整行——行首缩进可以省略,但行内容必须完整。`, `Could not find the text in ${path}: edits[${editIndex}].oldText spans multiple lines but its start/end do not fall on line boundaries (its first or last line is only part of a file line), and soft=true matches whole lines. Make every line of oldText a complete line — leading indentation may be omitted, but the line content must be complete.`, "edit.soft.fragment.not.supported", { path, editIndex }));
167
+ }
168
+ throw new EditMatchError(pick(lang, `在 ${path} 中找不到该文本(精确或忽略缩进均未命中)。oldText 必须与文件的行内容一致;行首空白差异会被忽略,但实际内容必须完全相同。`, `Could not find the text (exact or indentation-insensitive) in ${path}. The oldText must match the file's line content; leading-whitespace differences are ignored, but the actual content must be identical.`, "edit.soft.match.not.found", { path }));
169
+ }
170
+ if (starts.length > 1) {
171
+ throw new EditMatchError(pick(lang, `在 ${path} 中找到 ${starts.length} 处忽略缩进的 edits[${editIndex}].oldText。文本必须唯一,请提供更多上下文。`, `Found ${starts.length} indentation-insensitive occurrences of edits[${editIndex}].oldText in ${path}. The text must be unique. Please provide more context to make it unique.`, "edit.soft.match.not.unique", { path, "starts.length": starts.length, editIndex }));
172
+ }
173
+ const li = starts[0];
174
+ const ri = li + k;
175
+ const spanStart = units[li].start;
176
+ const spanEnd = units[ri - 1].end;
177
+ const lastNewline = units[ri - 1].newline;
178
+ let insertText = newTextLF;
179
+ if (lastNewline === "\n" && !insertText.endsWith("\n"))
180
+ insertText += "\n";
181
+ return { start: spanStart, end: spanEnd, insertText };
182
+ }
183
+ /**
184
+ * Indentation-insensitive replacement used by `edit(soft: true)`. Exact substring matches still win,
185
+ * so soft never rewrites a region the built-in edit would have matched literally.
186
+ */
187
+ export function applySoftEdits(normalizedContent, edits, path, lang = "en") {
188
+ const replacements = [];
189
+ for (let i = 0; i < edits.length; i++) {
190
+ const oldTextLF = normalizeToLF(edits[i].oldText);
191
+ const newTextLF = normalizeToLF(edits[i].newText);
192
+ replacements.push(locateSoftReplacement(normalizedContent, oldTextLF, newTextLF, path, i, lang));
193
+ }
194
+ const sorted = [...replacements].sort((a, b) => a.start - b.start);
195
+ for (let i = 1; i < sorted.length; i++) {
196
+ if (sorted[i - 1].end > sorted[i].start) {
197
+ throw new EditMatchError(pick(lang, `在 ${path} 中的 edits 重叠。请合并为一个 edit 或定位到不相交的区域。`, `edits overlap in ${path}. Merge them into one edit or target disjoint regions.`, "edit.edits.overlap", { path }));
198
+ }
199
+ }
200
+ let result = normalizedContent;
201
+ for (let i = sorted.length - 1; i >= 0; i--) {
202
+ const r = sorted[i];
203
+ result = result.slice(0, r.start) + r.insertText + result.slice(r.end);
204
+ }
205
+ if (result === normalizedContent) {
206
+ throw new EditMatchError(pick(lang, `${path} 没有变化。替换产生了完全相同的内容。`, `No changes made to ${path}. The replacement produced identical content.`, "edit.result.identical", { path }));
207
+ }
208
+ return { baseContent: normalizedContent, newContent: result };
209
+ }
210
+ async function performEdit(input, fallbackCwd, getLang, signal) {
211
+ const lang = getLang?.() ?? "en";
212
+ const { path, edits } = input;
213
+ if (!Array.isArray(edits) || edits.length === 0) {
214
+ throw new Error(pick(lang, "edit 输入无效:edits 必须包含至少一个替换。", "edit input is invalid. edits must contain at least one replacement.", "edit.input.no.edits"));
215
+ }
216
+ const cwd = fallbackCwd;
217
+ const absolutePath = resolveToCwd(path, cwd);
218
+ const remoteOps = createRemoteSdkOperations(cwd);
219
+ return withFileMutationQueue(absolutePath, async () => {
220
+ const throwIfAborted = () => {
221
+ if (signal?.aborted)
222
+ throw new Error(pick(lang, "操作已中止", "Operation aborted", "edit.operation.aborted"));
223
+ };
224
+ throwIfAborted();
225
+ try {
226
+ if (remoteOps) {
227
+ await remoteOps.edit.access(absolutePath);
228
+ }
229
+ else {
230
+ await access(absolutePath, constants.R_OK | constants.W_OK);
231
+ }
232
+ }
233
+ catch (error) {
234
+ throwIfAborted();
235
+ const errorMessage = error instanceof Error && "code" in error ? `Error code: ${error.code}` : String(error);
236
+ throw new Error(pick(lang, `无法编辑文件:${path}。${errorMessage}。`, `Could not edit file: ${path}. ${errorMessage}.`, "edit.file.access.failed", { path, errorMessage }));
237
+ }
238
+ throwIfAborted();
239
+ const buffer = remoteOps ? await remoteOps.edit.readFile(absolutePath) : await readFile(absolutePath);
240
+ const rawContent = buffer.toString("utf-8");
241
+ throwIfAborted();
242
+ const { bom, text: content } = splitBom(rawContent);
243
+ const originalEnding = detectLineEnding(content);
244
+ const normalizedContent = normalizeToLF(content);
245
+ const { baseContent, newContent } = applySoftEdits(normalizedContent, edits, path, lang);
246
+ throwIfAborted();
247
+ const finalContent = bom + restoreLineEndings(newContent, originalEnding);
248
+ if (remoteOps) {
249
+ await remoteOps.edit.writeFile(absolutePath, finalContent);
250
+ }
251
+ else {
252
+ await writeFile(absolutePath, finalContent, "utf-8");
253
+ }
254
+ throwIfAborted();
255
+ const diffResult = generateDiffString(baseContent, newContent);
256
+ const patch = generateUnifiedPatch(path, baseContent, newContent);
257
+ return {
258
+ content: [
259
+ {
260
+ type: "text",
261
+ text: pick(lang, `已在 ${path} 中替换 ${edits.length} 个块(soft:忽略缩进匹配)。`, `Successfully replaced ${edits.length} block(s) in ${path} (soft: indentation-insensitive).`, "edit.soft.replace.done", { path, "edits.length": edits.length }),
262
+ },
263
+ ],
264
+ details: { diff: diffResult.diff, patch, firstChangedLine: diffResult.firstChangedLine },
265
+ };
266
+ });
267
+ }
268
+ /**
269
+ * The single `edit` tool of this host: built-in exact replacement plus the `soft` parameter for
270
+ * indentation-tolerant matching. Replaces the SDK definition by name (see tool-overrides).
271
+ */
272
+ export function makeEditToolDefinition(cwd, getLang) {
273
+ const remoteOps = createRemoteSdkOperations(cwd);
274
+ const exactTool = createEditToolDefinition(cwd, remoteOps ? { operations: remoteOps.edit } : undefined);
275
+ return {
276
+ ...exactTool,
277
+ description: EDIT_DESCRIPTION,
278
+ promptSnippet: EDIT_PROMPT_SNIPPET,
279
+ promptGuidelines: [...EDIT_PROMPT_GUIDELINES],
280
+ parameters: EDIT_PARAMETERS,
281
+ prepareArguments: prepareEditArguments,
282
+ execute: async (toolCallId, input, signal, onUpdate, ctx) => {
283
+ const params = input;
284
+ if (params?.soft === true) {
285
+ const toolCwd = typeof ctx?.cwd === "string" && ctx.cwd ? ctx.cwd : cwd;
286
+ return (await performEdit(params, toolCwd, getLang, signal));
287
+ }
288
+ const exact = { ...params };
289
+ delete exact.soft;
290
+ return exactTool.execute(toolCallId, exact, signal, onUpdate, ctx);
291
+ },
292
+ };
293
+ }
@@ -3,6 +3,7 @@ export const ENGINE_CATALOG = {
3
3
  id: "pi",
4
4
  name: "Pi",
5
5
  packageName: "@earendil-works/pi-coding-agent",
6
+ cliPackageName: null,
6
7
  installCommand: "npm i -g @earendil-works/pi-coding-agent",
7
8
  cliCommand: "pi",
8
9
  cliModelArgs: "provider-model",
@@ -12,8 +13,9 @@ export const ENGINE_CATALOG = {
12
13
  id: "dsh",
13
14
  name: "DSH",
14
15
  packageName: "@deepseek-ai/dsh",
15
- installCommand: "npm i -g @deepseek-ai/dsh",
16
- cliCommand: null,
16
+ cliPackageName: "@deepseek-harness-tui/dsh-tui",
17
+ installCommand: "npm i -g @deepseek-ai/dsh @deepseek-harness-tui/dsh-tui",
18
+ cliCommand: "dsh-tui",
17
19
  cliModelArgs: null,
18
20
  cliRequiresArgs: false,
19
21
  },
@@ -21,6 +23,7 @@ export const ENGINE_CATALOG = {
21
23
  id: "claude",
22
24
  name: "Claude Code",
23
25
  packageName: "@anthropic-ai/claude-code",
26
+ cliPackageName: null,
24
27
  installCommand: "npm i -g @anthropic-ai/claude-code",
25
28
  cliCommand: "claude",
26
29
  cliModelArgs: "model",
@@ -30,6 +33,7 @@ export const ENGINE_CATALOG = {
30
33
  id: "codex",
31
34
  name: "Codex",
32
35
  packageName: "@openai/codex",
36
+ cliPackageName: null,
33
37
  installCommand: "npm i -g @openai/codex",
34
38
  cliCommand: "codex",
35
39
  cliModelArgs: "model",
@@ -39,6 +43,7 @@ export const ENGINE_CATALOG = {
39
43
  id: "agy",
40
44
  name: "Antigravity",
41
45
  packageName: null,
46
+ cliPackageName: null,
42
47
  installCommand: "https://antigravity.google/docs/getting-started?tab=cli",
43
48
  cliCommand: "agy",
44
49
  cliModelArgs: "model",
@@ -48,6 +53,7 @@ export const ENGINE_CATALOG = {
48
53
  id: "durable",
49
54
  name: "Pi Durable",
50
55
  packageName: "@earendil-works/pi-durable",
56
+ cliPackageName: null,
51
57
  installCommand: "npm i -g @earendil-works/pi-durable",
52
58
  cliCommand: null,
53
59
  cliModelArgs: null,
@@ -4,6 +4,24 @@ import { posix, resolve, win32 } from "node:path";
4
4
  import { ENGINE_CATALOG } from "./engine-catalog.js";
5
5
  import { probeGlobalPackage } from "./global-loader.js";
6
6
  import { findNativeCliExecutable } from "./native-cli-discovery.js";
7
+ /**
8
+ * npm's cmd-shim writes two Windows recoverable shapes, both anchored to `"%dp0%\<entry>" %*` so an
9
+ * extra command after the invocation still fails the parse:
10
+ * cmd-shim 8 (npm 11): endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\<entry>" %*
11
+ * cmd-shim 9 (npm 12): ... title %COMSPEC% & set PATHEXT=%PATHEXT:;.JS;=;% & "%_prog%" "%dp0%\<entry>" %*
12
+ * npm 12 writes the second form for every dependency bin, so `pi.cmd` / `claude.cmd` from a current npm are
13
+ * unparsable without tolerating the PATHEXT segment. The optional segment stays single-line (`[^&\r\n]*`) so a
14
+ * shim cannot smuggle a second line into the prefix.
15
+ */
16
+ const NPM_SHIM_NODE_TARGET = /^\s*(?:endLocal\s*&\s*goto\s+#_undefined_#\s+2>NUL\s*\|\|\s*title\s+%COMSPEC%\s*&)?\s*(?:set\s+PATHEXT=[^&\r\n]*&\s*)?(?:"%_prog%"|"%dp0%[\\/]node\.exe"|node(?:\.exe)?)\s+"%dp0%[\\/]([^"\r\n]+)"\s+%\*\s*$/im;
17
+ const NPM_SHIM_NATIVE_TARGET = /^\s*"%dp0%[\\/]([^"\r\n]+\.(?:exe|com))"\s+%\*\s*$/im;
18
+ /**
19
+ * Pure text parse of an npm `.cmd` shim. Exported so both dialects stay guarded on every OS:
20
+ * the surrounding `unwrapExecutable` branch only runs on win32, which CI does not exercise.
21
+ */
22
+ export function readNpmShimTargets(shim) {
23
+ return { nodeTarget: NPM_SHIM_NODE_TARGET.exec(shim)?.[1], nativeTarget: NPM_SHIM_NATIVE_TARGET.exec(shim)?.[1] };
24
+ }
7
25
  function unwrapExecutable(file, args, options) {
8
26
  const windows = (options.platform ?? process.platform) === "win32";
9
27
  if (!windows) {
@@ -23,12 +41,10 @@ function unwrapExecutable(file, args, options) {
23
41
  throw new Error("CLI requires an executable or an npm .cmd shim on Windows");
24
42
  if (statSync(file).size > 64 * 1024)
25
43
  throw new Error("CLI npm shim is too large");
26
- const shim = readFileSync(file, "utf8");
27
- const nodeTarget = /^\s*(?:endLocal\s*&\s*goto\s+#_undefined_#\s+2>NUL\s*\|\|\s*title\s+%COMSPEC%\s*&\s*)?(?:"%_prog%"|"%dp0%[\\/]node\.exe"|node(?:\.exe)?)\s+"%dp0%[\\/]([^"\r\n]+)"\s+%\*\s*$/im.exec(shim)?.[1];
28
- const nativeTarget = /^\s*"%dp0%[\\/]([^"\r\n]+\.(?:exe|com))"\s+%\*\s*$/im.exec(shim)?.[1];
44
+ const { nodeTarget, nativeTarget } = readNpmShimTargets(readFileSync(file, "utf8"));
29
45
  const target = nodeTarget ?? nativeTarget;
30
46
  if (!target || (nodeTarget && !/\.(?:[cm]?js)$/i.test(nodeTarget)) || /[%\x00-\x1f]/.test(target))
31
- throw new Error("Unsupported CLI .cmd shim; configure its executable directly");
47
+ throw new Error(`Unsupported CLI .cmd shim (${file}); configure its executable directly`);
32
48
  const entryPoint = win32.resolve(win32.dirname(file), target);
33
49
  if (!statSync(entryPoint).isFile())
34
50
  throw new Error("CLI npm entry point is not a file");
@@ -56,14 +72,20 @@ export function resolveEngineCliLaunch(id, options = {}) {
56
72
  const args = options.args ?? [];
57
73
  if (options.executablePath)
58
74
  return resolveCliExecutableLaunch(options.executablePath, args, { ...options, autoDetect: false });
59
- const file = findNativeCliExecutable(meta.cliCommand, { ...options, autoDetect: true });
75
+ let file = findNativeCliExecutable(meta.cliCommand, { ...options, autoDetect: true });
76
+ if (!file && id === "dsh") {
77
+ file = findNativeCliExecutable("dst", { ...options, autoDetect: true });
78
+ }
60
79
  if (file)
61
80
  return unwrapExecutable(file, args, options);
62
- const pkg = meta.packageName ? probeGlobalPackage(meta.packageName, { refresh: options.refresh }) : undefined;
81
+ const cliPackage = meta.cliPackageName ?? meta.packageName;
82
+ const pkg = cliPackage ? probeGlobalPackage(cliPackage, { refresh: options.refresh }) : undefined;
63
83
  if (pkg?.packagePath) {
64
84
  try {
65
85
  const manifest = JSON.parse(readFileSync(resolve(pkg.packagePath, "package.json"), "utf8"));
66
- const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.[meta.cliCommand];
86
+ const bin = typeof manifest.bin === "string"
87
+ ? manifest.bin
88
+ : (manifest.bin?.[meta.cliCommand] ?? (id === "dsh" ? manifest.bin?.dst : undefined));
67
89
  if (typeof bin === "string") {
68
90
  const entry = resolve(pkg.packagePath, bin);
69
91
  if (statSync(entry).isFile())
@@ -235,11 +235,13 @@ export async function uninstallEngineBackground(engineId, options) {
235
235
  }
236
236
  if (currentEntry)
237
237
  currentEntry.uninstalling = true;
238
- const pkg = meta.packageName;
238
+ const packages = [meta.packageName, meta.cliPackageName].filter((p) => Boolean(p));
239
239
  const timeoutMs = Math.max(10_000, Number(options?.timeoutMs ?? 180_000));
240
240
  const isWin = process.platform === "win32";
241
241
  const spawnCmd = isWin ? process.env.ComSpec || "cmd.exe" : "npm";
242
- const spawnArgs = isWin ? ["/d", "/s", "/c", "npm", "uninstall", "-g", pkg] : ["uninstall", "-g", pkg];
242
+ const spawnArgs = isWin
243
+ ? ["/d", "/s", "/c", "npm", "uninstall", "-g", ...packages]
244
+ : ["uninstall", "-g", ...packages];
243
245
  try {
244
246
  const child = spawn(spawnCmd, spawnArgs, {
245
247
  windowsHide: true,
@@ -286,7 +288,8 @@ export async function uninstallEngineBackground(engineId, options) {
286
288
  });
287
289
  });
288
290
  if (res.ok) {
289
- registryCache.delete(pkg);
291
+ for (const p of packages)
292
+ registryCache.delete(p);
290
293
  try {
291
294
  await probeAllEngines(true);
292
295
  }
@@ -321,11 +324,12 @@ export async function updateEngineBackground(engineId, options) {
321
324
  }
322
325
  if (currentEntry)
323
326
  currentEntry.updating = true;
324
- const pkg = meta.packageName;
327
+ const packages = [meta.packageName, meta.cliPackageName].filter((p) => Boolean(p));
325
328
  const timeoutMs = Math.max(10_000, Number(options?.timeoutMs ?? 300_000));
326
329
  const isWin = process.platform === "win32";
327
330
  const spawnCmd = isWin ? process.env.ComSpec || "cmd.exe" : "npm";
328
- const spawnArgs = isWin ? ["/d", "/s", "/c", "npm", "i", "-g", `${pkg}@latest`] : ["i", "-g", `${pkg}@latest`];
331
+ const updatePkgs = packages.map((p) => `${p}@latest`);
332
+ const spawnArgs = isWin ? ["/d", "/s", "/c", "npm", "i", "-g", ...updatePkgs] : ["i", "-g", ...updatePkgs];
329
333
  try {
330
334
  const child = spawn(spawnCmd, spawnArgs, {
331
335
  windowsHide: true,
@@ -372,7 +376,8 @@ export async function updateEngineBackground(engineId, options) {
372
376
  });
373
377
  });
374
378
  if (res.ok) {
375
- registryCache.delete(pkg);
379
+ for (const p of packages)
380
+ registryCache.delete(p);
376
381
  try {
377
382
  await probeAllEngines(true);
378
383
  }
@@ -479,25 +479,11 @@ export function makeEvalTool(opts) {
479
479
  "Variables and imported modules persist across calls within the conversation.",
480
480
  promptSnippet: "run a code snippet without creating a script file",
481
481
  parameters: Type.Object({
482
- code: Type.String({
483
- description: "The code snippet to evaluate. Top-level variables and functions persist across calls.",
484
- }),
485
- language: Type.Optional(Type.Unsafe({
486
- type: "string",
487
- enum: ["py", "js", "ts"],
488
- description: 'Target language: "py" for Python (default), "js" or "ts" for Node.js sandbox.',
489
- })),
490
- title: Type.Optional(Type.String({
491
- description: "Optional short label for this step.",
492
- })),
493
- timeout: Type.Optional(Type.Integer({
494
- minimum: 1,
495
- maximum: MAX_TIMEOUT_SECONDS,
496
- description: `Execution timeout in seconds (default: ${DEFAULT_TIMEOUT_SECONDS}, maximum: ${MAX_TIMEOUT_SECONDS}).`,
497
- })),
498
- reset: Type.Optional(Type.Boolean({
499
- description: "Whether to reset the sandbox environment before executing (clears all previous variables).",
500
- })),
482
+ code: Type.String(),
483
+ language: Type.Optional(Type.Unsafe({ type: "string", enum: ["py", "js", "ts"] })),
484
+ title: Type.Optional(Type.String()),
485
+ timeout: Type.Optional(Type.Integer({ description: "Seconds" })),
486
+ reset: Type.Optional(Type.Boolean({ description: "Clear variables before running" })),
501
487
  }),
502
488
  execute: async (_id, params) => {
503
489
  const lang = getLang();
@@ -315,10 +315,10 @@ export class FilesService {
315
315
  * with a search_files_result echoing reqId so the client's request never
316
316
  * stalls (ok:false on unexpected failure).
317
317
  */
318
- async searchFiles(query, reqId) {
318
+ async searchFiles(query, reqId, scope) {
319
319
  const activeCwd = this.host.getActiveCwd();
320
320
  if (isRemoteWorkspaceUri(activeCwd)) {
321
- await this.searchRemoteFiles(activeCwd, query, reqId);
321
+ await this.searchRemoteFiles(activeCwd, query, reqId, scope);
322
322
  return;
323
323
  }
324
324
  const { join } = await import("node:path");
@@ -329,6 +329,18 @@ export class FilesService {
329
329
  return;
330
330
  }
331
331
  const root = resolve(activeCwd);
332
+ const normScope = (scope ?? "").trim().replace(/\\/g, "/").replace(/\/+$/, "");
333
+ let walkAbs = root;
334
+ let walkRel = "";
335
+ if (normScope !== "" && normScope !== "@root") {
336
+ const scopeAbs = resolve(root, normScope);
337
+ const rawRel = relative(root, scopeAbs);
338
+ if (rawRel !== ".." && !rawRel.startsWith(`..${sep}`) && !rawRel.includes(`${sep}..`)) {
339
+ walkAbs = scopeAbs;
340
+ walkRel = rawRel.split(sep).join("/");
341
+ }
342
+ }
343
+ const inScope = (p) => walkRel === "" || p === walkRel || p.startsWith(`${walkRel}/`);
332
344
  const ignored = ignoredEntries();
333
345
  const MAX_RESULTS = 50;
334
346
  const MAX_VISITED = 20000;
@@ -350,22 +362,25 @@ export class FilesService {
350
362
  : join(home, normQuery.slice(2))
351
363
  : wireToAbs(normQuery);
352
364
  const st = await fsp.stat(targetAbs).catch(() => null);
353
- if (st) {
365
+ // 目录也要收:输入框里敲一个目录路径时,结果表要能直接打开它(`type: "dir"` 曾经不可达)。
366
+ if (st && (st.isFile() || st.isDirectory())) {
354
367
  const wp = workspacePath(root, targetAbs);
355
368
  const wirePath = wp ? wp.rel : targetAbs.split(sep).join("/");
356
- const baseName = targetAbs.split(/[\\/]/).pop() || wirePath;
357
- results.push({
358
- path: wirePath,
359
- name: baseName,
360
- type: st.isDirectory() ? "dir" : "file",
361
- });
369
+ if (inScope(wirePath)) {
370
+ const baseName = targetAbs.split(/[\\/]/).pop() || wirePath;
371
+ results.push({
372
+ path: wirePath,
373
+ name: baseName,
374
+ type: st.isDirectory() ? "dir" : "file",
375
+ });
376
+ }
362
377
  }
363
378
  }
364
379
  else {
365
380
  const directWp = workspacePath(root, normQuery);
366
381
  if (directWp) {
367
382
  const st = await fsp.stat(directWp.abs).catch(() => null);
368
- if (st) {
383
+ if (st && (st.isFile() || st.isDirectory()) && inScope(directWp.rel)) {
369
384
  const baseName = directWp.abs.split(/[\\/]/).pop() || directWp.rel;
370
385
  results.push({
371
386
  path: directWp.rel,
@@ -410,6 +425,8 @@ export class FilesService {
410
425
  }
411
426
  const childRelLower = childRel.toLowerCase();
412
427
  const nameLower = d.name.toLowerCase();
428
+ // 目录命中同样要有结果(前端按树展开后可直达),只是不能吃掉 50 条预算:
429
+ // 目录照常入列,仍然继续下潜。
413
430
  if ((nameLower.includes(q) || childRelLower.includes(q)) && !results.some((r) => r.path === childRel)) {
414
431
  results.push({
415
432
  path: childRel,
@@ -423,7 +440,7 @@ export class FilesService {
423
440
  }
424
441
  };
425
442
  try {
426
- await walk(root, "", 0);
443
+ await walk(walkAbs, walkRel, 0);
427
444
  this.host.emit({
428
445
  type: "search_files_result",
429
446
  reqId,
@@ -1556,7 +1573,7 @@ export class FilesService {
1556
1573
  this.emitListError(targetAbs, e.message || String(err), e.code);
1557
1574
  }
1558
1575
  }
1559
- async searchRemoteFiles(rawCwd, query, reqId) {
1576
+ async searchRemoteFiles(rawCwd, query, reqId, scope) {
1560
1577
  const rawQuery = query.trim();
1561
1578
  if (!rawQuery) {
1562
1579
  this.host.emit({ type: "search_files_result", reqId, ok: true, results: [] });
@@ -1570,18 +1587,22 @@ export class FilesService {
1570
1587
  try {
1571
1588
  const normQuery = rawQuery.replace(/\\/g, "/");
1572
1589
  const q = normQuery.toLowerCase();
1590
+ const normScope = (scope ?? "").trim();
1591
+ const inScope = (p) => normScope === "" || p === normScope || p.startsWith(normScope + "/");
1573
1592
  const results = [];
1574
1593
  let truncated = false;
1575
1594
  const target = this.resolveRemoteTarget(rawCwd, normQuery);
1576
- if (target) {
1595
+ if (target && inScope(target.rel)) {
1577
1596
  try {
1578
1597
  const st = await sshSvc.sftpStat(rawCwd, target.abs);
1579
- const name = posix.basename(target.abs) || target.rel;
1580
- results.push({
1581
- path: target.rel,
1582
- name,
1583
- type: st.isDirectory ? "dir" : "file",
1584
- });
1598
+ if (!st.isDirectory) {
1599
+ const name = posix.basename(target.abs) || target.rel;
1600
+ results.push({
1601
+ path: target.rel,
1602
+ name,
1603
+ type: "file",
1604
+ });
1605
+ }
1585
1606
  }
1586
1607
  catch { }
1587
1608
  }
@@ -1594,6 +1615,7 @@ export class FilesService {
1594
1615
  continue;
1595
1616
  const name = posix.basename(clean);
1596
1617
  if ((name.toLowerCase().includes(q) || clean.toLowerCase().includes(q)) &&
1618
+ inScope(clean) &&
1597
1619
  !results.some((r) => r.path === clean)) {
1598
1620
  results.push({
1599
1621
  path: clean,