@xrkseek/harness 0.5.12 → 0.5.13
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/node_modules/@vscode/ripgrep/LICENSE +13 -0
- package/node_modules/@vscode/ripgrep/README.md +33 -0
- package/node_modules/@vscode/ripgrep/lib/index.d.ts +1 -0
- package/node_modules/@vscode/ripgrep/lib/index.js +19 -0
- package/node_modules/@vscode/ripgrep/package.json +39 -0
- package/node_modules/@vscode/ripgrep-win32-x64/LICENSE +13 -0
- package/node_modules/@vscode/ripgrep-win32-x64/README.md +5 -0
- package/node_modules/@vscode/ripgrep-win32-x64/bin/rg.exe +0 -0
- package/node_modules/@vscode/ripgrep-win32-x64/package.json +19 -0
- package/node_modules/@xrkseek/exec-fs/dist/index.d.ts +7 -9
- package/node_modules/@xrkseek/exec-fs/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.js +60 -19
- package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/ripgrep.d.ts +63 -0
- package/node_modules/@xrkseek/exec-fs/dist/ripgrep.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/ripgrep.js +363 -0
- package/node_modules/@xrkseek/exec-fs/dist/ripgrep.js.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/search.d.ts +32 -3
- package/node_modules/@xrkseek/exec-fs/dist/search.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/search.js +189 -72
- package/node_modules/@xrkseek/exec-fs/dist/search.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/package.json +2 -0
- package/node_modules/@xrkseek/exec-shell/dist/index.d.ts +14 -1
- package/node_modules/@xrkseek/exec-shell/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/index.js +37 -5
- package/node_modules/@xrkseek/exec-shell/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-subprocess/dist/capture.d.ts +73 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/capture.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/capture.js +240 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/capture.js.map +1 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/index.d.ts +19 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-subprocess/dist/index.js +58 -21
- package/node_modules/@xrkseek/exec-subprocess/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +6 -7
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +14 -11
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-harness/package.json +1 -0
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/server-config/dist/home.d.ts +1 -2
- package/node_modules/@xrkseek/server-config/dist/home.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/home.js +1 -2
- package/node_modules/@xrkseek/server-config/dist/home.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.js +12 -2
- package/node_modules/@xrkseek/server-face/dist/face-schema.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts +11 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.js +32 -7
- package/node_modules/@xrkseek/server-face/dist/session-status.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +9 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/ws-send-queue.d.ts +10 -0
- package/node_modules/@xrkseek/server-face/dist/ws-send-queue.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/ws-send-queue.js +68 -3
- package/node_modules/@xrkseek/server-face/dist/ws-send-queue.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.d.ts +7 -8
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +22 -27
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts +1 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts.map +1 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js +23 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import { readdir, readFile as fsReadFile, stat as fsStat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { scheduler } from "node:timers/promises";
|
|
3
4
|
import { resolveWithinRoot } from "./paths.js";
|
|
5
|
+
/** Skip heavy / generated trees so grep/glob stay interactive on monorepos. */
|
|
6
|
+
export const FS_SEARCH_SKIP_DIR_NAMES = new Set([
|
|
7
|
+
".git",
|
|
8
|
+
"node_modules",
|
|
9
|
+
"dist",
|
|
10
|
+
"build",
|
|
11
|
+
"out",
|
|
12
|
+
"coverage",
|
|
13
|
+
".next",
|
|
14
|
+
".nuxt",
|
|
15
|
+
".turbo",
|
|
16
|
+
".cache",
|
|
17
|
+
".parcel-cache",
|
|
18
|
+
".vite",
|
|
19
|
+
"__pycache__",
|
|
20
|
+
".venv",
|
|
21
|
+
"venv",
|
|
22
|
+
"target",
|
|
23
|
+
".idea",
|
|
24
|
+
".gradle",
|
|
25
|
+
".codegraph",
|
|
26
|
+
".scratch-opus",
|
|
27
|
+
"Pods",
|
|
28
|
+
]);
|
|
29
|
+
/** Soft walk ceiling (still high enough for late-sorted paths). */
|
|
30
|
+
export const FS_SEARCH_WALK_CAP = 100_000;
|
|
31
|
+
/** Skip individual files larger than this for content grep. */
|
|
32
|
+
export const FS_GREP_MAX_FILE_BYTES = 1_000_000;
|
|
33
|
+
/** Yield the event loop this often while walking / grepping. */
|
|
34
|
+
const YIELD_EVERY = 48;
|
|
4
35
|
/** Convert a posix-ish glob to a RegExp. Supports * and ** segments. */
|
|
5
36
|
export function globToRegExp(pattern) {
|
|
6
37
|
const norm = pattern.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
@@ -44,62 +75,119 @@ export function matchGlob(relPosix, pattern) {
|
|
|
44
75
|
const rel = relPosix.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
45
76
|
return globToRegExp(pattern).test(rel);
|
|
46
77
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const abs = path.join(absDir, ent.name);
|
|
63
|
-
if (ent.isDirectory()) {
|
|
64
|
-
await walkFiles(abs, rootAbs, out, cap);
|
|
65
|
-
continue;
|
|
78
|
+
/**
|
|
79
|
+
* Depth-first walk under `absDir`. Skips junk dir basenames. Invokes `visit`
|
|
80
|
+
* for each file (posix path relative to `rootAbs`). Stop when visit returns
|
|
81
|
+
* false or `cap` files have been visited. Yields periodically so Host LLM /
|
|
82
|
+
* mux work can interleave.
|
|
83
|
+
*/
|
|
84
|
+
export async function walkFilesUnder(absDir, rootAbs, visit, cap = FS_SEARCH_WALK_CAP) {
|
|
85
|
+
let visited = 0;
|
|
86
|
+
let sinceYield = 0;
|
|
87
|
+
const walk = async (dir) => {
|
|
88
|
+
if (visited >= cap)
|
|
89
|
+
return false;
|
|
90
|
+
let entries;
|
|
91
|
+
try {
|
|
92
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
66
93
|
}
|
|
67
|
-
|
|
94
|
+
catch {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
for (const ent of entries) {
|
|
98
|
+
if (visited >= cap)
|
|
99
|
+
return false;
|
|
100
|
+
if (ent.isDirectory()) {
|
|
101
|
+
if (FS_SEARCH_SKIP_DIR_NAMES.has(ent.name))
|
|
102
|
+
continue;
|
|
103
|
+
const abs = path.join(dir, ent.name);
|
|
104
|
+
if (!(await walk(abs)))
|
|
105
|
+
return false;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (!ent.isFile())
|
|
109
|
+
continue;
|
|
110
|
+
const abs = path.join(dir, ent.name);
|
|
68
111
|
const rel = path.relative(rootAbs, abs).replace(/\\/g, "/");
|
|
69
|
-
|
|
112
|
+
visited += 1;
|
|
113
|
+
sinceYield += 1;
|
|
114
|
+
if (sinceYield >= YIELD_EVERY) {
|
|
115
|
+
sinceYield = 0;
|
|
116
|
+
await scheduler.yield();
|
|
117
|
+
}
|
|
118
|
+
const cont = await visit(rel);
|
|
119
|
+
if (cont === false)
|
|
120
|
+
return false;
|
|
70
121
|
}
|
|
71
|
-
|
|
122
|
+
return true;
|
|
123
|
+
};
|
|
124
|
+
await walk(absDir);
|
|
72
125
|
}
|
|
73
126
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* only the returned list is cut at `maxResults`.
|
|
127
|
+
* In-process glob walk (fallback when packaged ripgrep is unavailable).
|
|
128
|
+
* Matches during the walk and stops at `maxResults`.
|
|
77
129
|
*/
|
|
78
|
-
export async function
|
|
130
|
+
export async function globWalkUnderRoot(root, pattern, options) {
|
|
79
131
|
const rootAbs = path.resolve(root);
|
|
80
132
|
const maxResults = options?.maxResults ?? 200;
|
|
81
133
|
if (!pattern || typeof pattern !== "string") {
|
|
82
134
|
throw new Error("glob pattern required");
|
|
83
135
|
}
|
|
84
|
-
const all = [];
|
|
85
|
-
// Walk cap decoupled from maxResults: a 200-result request must still see
|
|
86
|
-
// every file (the old Math.max(maxResults*4, 2000) truncated the walk at
|
|
87
|
-
// 2000 entries, silently dropping later paths like README.md).
|
|
88
|
-
await walkFiles(rootAbs, rootAbs, all, 100_000);
|
|
89
136
|
const matched = [];
|
|
90
|
-
|
|
91
|
-
if (matchGlob(rel, pattern))
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
137
|
+
await walkFilesUnder(rootAbs, rootAbs, (rel) => {
|
|
138
|
+
if (!matchGlob(rel, pattern))
|
|
139
|
+
return;
|
|
140
|
+
matched.push(rel);
|
|
141
|
+
if (matched.length >= maxResults)
|
|
142
|
+
return false;
|
|
143
|
+
});
|
|
144
|
+
return matched;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Collect files under `root` matching `pattern` (posix paths relative to root).
|
|
148
|
+
* Prefers packaged ripgrep (`@vscode/ripgrep`, Codex / pi / DSH); falls back
|
|
149
|
+
* to {@link globWalkUnderRoot} when the binary is missing. Set `XRK_FS_SEARCH=js`
|
|
150
|
+
* to force the walk.
|
|
151
|
+
*/
|
|
152
|
+
export async function globUnderRoot(root, pattern, options) {
|
|
153
|
+
if (!pattern || typeof pattern !== "string") {
|
|
154
|
+
throw new Error("glob pattern required");
|
|
155
|
+
}
|
|
156
|
+
const { preferJsSearch, RipgrepUnavailableError, globWithRipgrep } = await import("./ripgrep.js");
|
|
157
|
+
if (!preferJsSearch()) {
|
|
158
|
+
try {
|
|
159
|
+
return await globWithRipgrep(root, pattern, options);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
if (!(err instanceof RipgrepUnavailableError))
|
|
163
|
+
throw err;
|
|
95
164
|
}
|
|
96
165
|
}
|
|
97
|
-
return
|
|
166
|
+
return globWalkUnderRoot(root, pattern, options);
|
|
167
|
+
}
|
|
168
|
+
/** Line scan without allocating a full `split` array (hot for large files). */
|
|
169
|
+
export function forEachLine(text, fn) {
|
|
170
|
+
let start = 0;
|
|
171
|
+
let lineNo = 1;
|
|
172
|
+
while (start <= text.length) {
|
|
173
|
+
let end = text.indexOf("\n", start);
|
|
174
|
+
if (end < 0)
|
|
175
|
+
end = text.length;
|
|
176
|
+
let line = text.slice(start, end);
|
|
177
|
+
if (line.endsWith("\r"))
|
|
178
|
+
line = line.slice(0, -1);
|
|
179
|
+
if (!fn(line, lineNo))
|
|
180
|
+
return;
|
|
181
|
+
if (end === text.length)
|
|
182
|
+
break;
|
|
183
|
+
start = end + 1;
|
|
184
|
+
lineNo += 1;
|
|
185
|
+
}
|
|
98
186
|
}
|
|
99
187
|
/**
|
|
100
|
-
*
|
|
188
|
+
* In-process content search (fallback when packaged ripgrep is unavailable).
|
|
101
189
|
*/
|
|
102
|
-
export async function
|
|
190
|
+
export async function grepWalkUnderRoot(root, pattern, options) {
|
|
103
191
|
if (!pattern || typeof pattern !== "string") {
|
|
104
192
|
throw new Error("grep pattern required");
|
|
105
193
|
}
|
|
@@ -118,56 +206,85 @@ export async function grepUnderRoot(root, pattern, options) {
|
|
|
118
206
|
const message = err instanceof Error ? err.message : String(err);
|
|
119
207
|
throw new Error(`invalid grep pattern: ${message}`, { cause: err });
|
|
120
208
|
}
|
|
121
|
-
let files = [];
|
|
122
|
-
const scopeAbs = scope === "." || scope === ""
|
|
123
|
-
? rootAbs
|
|
124
|
-
: resolveWithinRoot(rootAbs, scope);
|
|
125
|
-
const st = await fsStat(scopeAbs);
|
|
126
|
-
if (st.isFile()) {
|
|
127
|
-
const rel = path.relative(rootAbs, scopeAbs).replace(/\\/g, "/");
|
|
128
|
-
files = [rel];
|
|
129
|
-
}
|
|
130
|
-
else if (st.isDirectory()) {
|
|
131
|
-
const gathered = [];
|
|
132
|
-
// Walk cap decoupled from maxResults: same truncation fix as globUnderRoot.
|
|
133
|
-
await walkFiles(scopeAbs, rootAbs, gathered, 100_000);
|
|
134
|
-
files = gathered;
|
|
135
|
-
}
|
|
136
|
-
if (fileGlob) {
|
|
137
|
-
files = files.filter((f) => matchGlob(f, fileGlob));
|
|
138
|
-
}
|
|
139
209
|
const hits = [];
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
|
|
210
|
+
const scanFile = async (rel) => {
|
|
211
|
+
if (fileGlob && !matchGlob(rel, fileGlob))
|
|
212
|
+
return true;
|
|
143
213
|
const abs = resolveWithinRoot(rootAbs, rel);
|
|
214
|
+
let st;
|
|
215
|
+
try {
|
|
216
|
+
st = await fsStat(abs);
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
if (!st.isFile() || st.size > FS_GREP_MAX_FILE_BYTES)
|
|
222
|
+
return true;
|
|
144
223
|
let text;
|
|
145
224
|
try {
|
|
146
225
|
const buf = await fsReadFile(abs);
|
|
147
|
-
if (buf.byteLength >
|
|
148
|
-
|
|
226
|
+
if (buf.byteLength > FS_GREP_MAX_FILE_BYTES)
|
|
227
|
+
return true;
|
|
228
|
+
// Cheap binary reject before UTF-8 decode of the whole buffer.
|
|
229
|
+
const sample = buf.subarray(0, Math.min(buf.byteLength, 8192));
|
|
230
|
+
if (sample.includes(0))
|
|
231
|
+
return true;
|
|
149
232
|
text = buf.toString("utf8");
|
|
150
233
|
}
|
|
151
234
|
catch {
|
|
152
|
-
|
|
235
|
+
return true;
|
|
153
236
|
}
|
|
154
|
-
|
|
155
|
-
continue;
|
|
156
|
-
const lines = text.split(/\r?\n/);
|
|
157
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
158
|
-
if (hits.length >= maxResults)
|
|
159
|
-
break;
|
|
160
|
-
const line = lines[i] ?? "";
|
|
237
|
+
forEachLine(text, (line, lineNo) => {
|
|
161
238
|
re.lastIndex = 0;
|
|
162
239
|
if (re.test(line)) {
|
|
163
240
|
hits.push({
|
|
164
241
|
path: rel,
|
|
165
|
-
line:
|
|
242
|
+
line: lineNo,
|
|
166
243
|
text: line.length > 400 ? `${line.slice(0, 400)}…` : line,
|
|
167
244
|
});
|
|
245
|
+
if (hits.length >= maxResults)
|
|
246
|
+
return false;
|
|
168
247
|
}
|
|
169
|
-
|
|
248
|
+
return true;
|
|
249
|
+
});
|
|
250
|
+
return hits.length < maxResults;
|
|
251
|
+
};
|
|
252
|
+
const scopeAbs = scope === "." || scope === ""
|
|
253
|
+
? rootAbs
|
|
254
|
+
: resolveWithinRoot(rootAbs, scope);
|
|
255
|
+
const st = await fsStat(scopeAbs);
|
|
256
|
+
if (st.isFile()) {
|
|
257
|
+
const rel = path.relative(rootAbs, scopeAbs).replace(/\\/g, "/");
|
|
258
|
+
await scanFile(rel);
|
|
259
|
+
return hits;
|
|
170
260
|
}
|
|
261
|
+
if (!st.isDirectory())
|
|
262
|
+
return hits;
|
|
263
|
+
await walkFilesUnder(scopeAbs, rootAbs, async (rel) => {
|
|
264
|
+
if (!(await scanFile(rel)))
|
|
265
|
+
return false;
|
|
266
|
+
});
|
|
171
267
|
return hits;
|
|
172
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Search file contents under root. Prefers packaged ripgrep (`--json`);
|
|
271
|
+
* falls back to {@link grepWalkUnderRoot} when the binary is missing.
|
|
272
|
+
* Set `XRK_FS_SEARCH=js` to force the walk.
|
|
273
|
+
*/
|
|
274
|
+
export async function grepUnderRoot(root, pattern, options) {
|
|
275
|
+
if (!pattern || typeof pattern !== "string") {
|
|
276
|
+
throw new Error("grep pattern required");
|
|
277
|
+
}
|
|
278
|
+
const { preferJsSearch, RipgrepUnavailableError, grepWithRipgrep } = await import("./ripgrep.js");
|
|
279
|
+
if (!preferJsSearch()) {
|
|
280
|
+
try {
|
|
281
|
+
return await grepWithRipgrep(root, pattern, options);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (!(err instanceof RipgrepUnavailableError))
|
|
285
|
+
throw err;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return grepWalkUnderRoot(root, pattern, options);
|
|
289
|
+
}
|
|
173
290
|
//# sourceMappingURL=search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqB/C,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACxB,GAAG,IAAI,UAAU,CAAC;gBAClB,CAAC,IAAI,CAAC,CAAC;YACT,CAAC;iBAAM,CAAC;gBACN,GAAG,IAAI,IAAI,CAAC;gBACZ,CAAC,IAAI,CAAC,CAAC;YACT,CAAC;YACD,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACd,GAAG,IAAI,OAAO,CAAC;YACf,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,EAAE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,EAAE,EAAE;QACpD,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,OAAe,EACf,OAAuB;IAEvB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,GAChE,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/B,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC;YACH,OAAO,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,CAAC,GAAG,YAAY,uBAAuB,CAAC;gBAAE,MAAM,GAAG,CAAC;QAC3D,CAAC;IACH,CAAC;IACD,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@vscode/ripgrep": "^1.18.0",
|
|
17
18
|
"@xrkseek/attachment": "workspace:*",
|
|
18
19
|
"@xrkseek/core-tools": "workspace:*",
|
|
20
|
+
"@xrkseek/exec-subprocess": "workspace:*",
|
|
19
21
|
"@xrkseek/protocol": "workspace:*"
|
|
20
22
|
},
|
|
21
23
|
"license": "MIT",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolDefinition } from "@xrkseek/core-tools";
|
|
2
|
-
import type
|
|
2
|
+
import { type SubprocessService } from "@xrkseek/exec-subprocess";
|
|
3
3
|
export { candidatePwshPaths, PWSH_ENCODING_PREAMBLE, resolvePwshPath, } from "./resolve-pwsh.js";
|
|
4
4
|
export type ShellBackend = "bash" | "cmd" | "pwsh";
|
|
5
5
|
/**
|
|
@@ -21,6 +21,13 @@ export interface ShellJobInfo {
|
|
|
21
21
|
readonly signal?: NodeJS.Signals | null;
|
|
22
22
|
readonly stdout?: string;
|
|
23
23
|
readonly stderr?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Complete-stream spill files when the in-memory 256KiB tail dropped the head
|
|
26
|
+
* (DSH OutputCollector). Omitted from Face wire JobView; surfaced in
|
|
27
|
+
* `job_output` text when truncated.
|
|
28
|
+
*/
|
|
29
|
+
readonly stdoutSpillPath?: string;
|
|
30
|
+
readonly stderrSpillPath?: string;
|
|
24
31
|
/** Managed-job producer detail (DSH JobOutcome.detail). */
|
|
25
32
|
readonly detail?: string;
|
|
26
33
|
/** Epoch ms when the job reached a terminal status; absent while live/stopping. */
|
|
@@ -155,6 +162,12 @@ export interface ShellLocalOptions {
|
|
|
155
162
|
readonly prepareArgv?: (argv: readonly string[], cwd: string | undefined, signal: AbortSignal | undefined, ctx?: {
|
|
156
163
|
readonly ownerSessionId?: string;
|
|
157
164
|
}) => Promise<readonly string[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Directory for subprocess spill files on overflow (prefer Host
|
|
167
|
+
* `{XRK_HOME}/spill` so paths stay inside `hostReadableRoots`). When set,
|
|
168
|
+
* bash jobs enable spill; omit for in-memory tail only.
|
|
169
|
+
*/
|
|
170
|
+
readonly spillDir?: string;
|
|
158
171
|
}
|
|
159
172
|
/**
|
|
160
173
|
* One AbortSignal for preparation + execution (DSH bash-local `deadline`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB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GAAG,MAAM,CAIT;AA+ED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAElD,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE;IACP,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAChC,GACL,cAAc,EAAE,CAqRlB;AAUD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACL,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAEvB,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,0eACuc,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { appendUtf8TailCap, prepareSpillBinding, StreamTailCollector, SUBPROCESS_CAPTURE_MAX_BYTES, } from "@xrkseek/exec-subprocess";
|
|
2
3
|
import { fitWithErrorHead, fitWithSuffix } from "./bytes.js";
|
|
3
4
|
import { presentBashCall, presentBashResult } from "./present.js";
|
|
4
5
|
import { PWSH_ENCODING_PREAMBLE, resolvePwshPath, } from "./resolve-pwsh.js";
|
|
@@ -95,6 +96,8 @@ export function createLocalShell(options) {
|
|
|
95
96
|
const backend = options.backend ?? defaultBackend();
|
|
96
97
|
const pwshPath = resolvePwshPath(options.pwshPath);
|
|
97
98
|
const defaultCwd = options.defaultCwd?.trim() || undefined;
|
|
99
|
+
const spillDir = options.spillDir?.trim() || undefined;
|
|
100
|
+
const spillOpts = spillDir !== undefined ? prepareSpillBinding({ spillDir }) : undefined;
|
|
98
101
|
const maxJobs = options.maxJobs ?? 64;
|
|
99
102
|
const maxConcurrent = options.maxConcurrentJobs ?? DEFAULT_MAX_CONCURRENT_JOBS;
|
|
100
103
|
if (!Number.isSafeInteger(maxConcurrent) || maxConcurrent < 1) {
|
|
@@ -139,6 +142,14 @@ export function createLocalShell(options) {
|
|
|
139
142
|
throw new Error(`background job limit reached (limit: ${maxConcurrent}); use job_kill to stop an unneeded job, wait for it to finish, then retry`);
|
|
140
143
|
}
|
|
141
144
|
}
|
|
145
|
+
function dropJob(id) {
|
|
146
|
+
const job = jobs.get(id);
|
|
147
|
+
if (job === undefined)
|
|
148
|
+
return;
|
|
149
|
+
StreamTailCollector.unlinkSpill(job.info.stdoutSpillPath);
|
|
150
|
+
StreamTailCollector.unlinkSpill(job.info.stderrSpillPath);
|
|
151
|
+
jobs.delete(id);
|
|
152
|
+
}
|
|
142
153
|
function pruneSettled() {
|
|
143
154
|
const settled = [...jobs.entries()]
|
|
144
155
|
.filter(([, job]) => isTerminalStatus(job.info.status))
|
|
@@ -148,7 +159,7 @@ export function createLocalShell(options) {
|
|
|
148
159
|
const oldest = settled.shift();
|
|
149
160
|
if (oldest === undefined)
|
|
150
161
|
break;
|
|
151
|
-
|
|
162
|
+
dropJob(oldest[0]);
|
|
152
163
|
}
|
|
153
164
|
}
|
|
154
165
|
function pruneIfNeeded() {
|
|
@@ -159,7 +170,7 @@ export function createLocalShell(options) {
|
|
|
159
170
|
for (const [id] of finished) {
|
|
160
171
|
if (jobs.size <= maxJobs)
|
|
161
172
|
break;
|
|
162
|
-
|
|
173
|
+
dropJob(id);
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
function markReported(job) {
|
|
@@ -202,7 +213,10 @@ export function createLocalShell(options) {
|
|
|
202
213
|
if (!job || isTerminalStatus(job.info.status))
|
|
203
214
|
return;
|
|
204
215
|
const prev = job.info[channel] ?? "";
|
|
205
|
-
job.info = {
|
|
216
|
+
job.info = {
|
|
217
|
+
...job.info,
|
|
218
|
+
[channel]: appendUtf8TailCap(prev, chunk, SUBPROCESS_CAPTURE_MAX_BYTES),
|
|
219
|
+
};
|
|
206
220
|
scheduleOutputNotify();
|
|
207
221
|
}
|
|
208
222
|
function track(command, handle, ownerSessionId, id) {
|
|
@@ -235,6 +249,12 @@ export function createLocalShell(options) {
|
|
|
235
249
|
: {}),
|
|
236
250
|
stdout: r.stdout,
|
|
237
251
|
stderr: r.stderr,
|
|
252
|
+
...(r.stdoutSpillPath !== undefined
|
|
253
|
+
? { stdoutSpillPath: r.stdoutSpillPath }
|
|
254
|
+
: {}),
|
|
255
|
+
...(r.stderrSpillPath !== undefined
|
|
256
|
+
? { stderrSpillPath: r.stderrSpillPath }
|
|
257
|
+
: {}),
|
|
238
258
|
finishedAt: Date.now(),
|
|
239
259
|
});
|
|
240
260
|
})
|
|
@@ -278,6 +298,8 @@ export function createLocalShell(options) {
|
|
|
278
298
|
...(spawnCwd ? { cwd: spawnCwd } : {}),
|
|
279
299
|
// Remaining budget lives on `deadline` — do not restart timeoutMs.
|
|
280
300
|
...(deadline ? { signal: deadline } : {}),
|
|
301
|
+
// Opt-in spill under `{XRK_HOME}/spill` (readable); default off elsewhere.
|
|
302
|
+
...(spillOpts !== undefined ? { spill: spillOpts } : { spill: false }),
|
|
281
303
|
onStdout: (chunk) => {
|
|
282
304
|
appendLiveOutput(id, "stdout", chunk);
|
|
283
305
|
},
|
|
@@ -413,6 +435,13 @@ export function createLocalShell(options) {
|
|
|
413
435
|
}
|
|
414
436
|
if (body.length === 0)
|
|
415
437
|
body = "(no output)";
|
|
438
|
+
const spills = [
|
|
439
|
+
job.info.stdoutSpillPath,
|
|
440
|
+
job.info.stderrSpillPath,
|
|
441
|
+
].filter((p) => typeof p === "string" && p.length > 0);
|
|
442
|
+
if (spills.length > 0) {
|
|
443
|
+
body += `\n[some output was dropped from memory; full output: ${spills.join(", ")}]`;
|
|
444
|
+
}
|
|
416
445
|
return body;
|
|
417
446
|
},
|
|
418
447
|
waitJob(id, timeoutMs, signal) {
|
|
@@ -531,7 +560,8 @@ export function createLocalShell(options) {
|
|
|
531
560
|
}
|
|
532
561
|
}
|
|
533
562
|
await Promise.all(all.map((j) => j.settled));
|
|
534
|
-
jobs.
|
|
563
|
+
for (const id of [...jobs.keys()])
|
|
564
|
+
dropJob(id);
|
|
535
565
|
notifyChanged();
|
|
536
566
|
},
|
|
537
567
|
};
|
|
@@ -851,7 +881,9 @@ export function createBashTools(shell, options = {}) {
|
|
|
851
881
|
},
|
|
852
882
|
{
|
|
853
883
|
name: "job_output",
|
|
854
|
-
description: "Read a background job. Stream jobs return only output since the previous read.
|
|
884
|
+
description: "Read a background job. Stream jobs return only output since the previous read. " +
|
|
885
|
+
"Every response ends with `[status: ...]`. Reads are non-blocking unless `wait: true`. " +
|
|
886
|
+
"If the body notes a spill file under product home, use read_file on that absolute path for the full log.",
|
|
855
887
|
parameters: {
|
|
856
888
|
type: "object",
|
|
857
889
|
properties: {
|