ceulen 0.13.0 → 0.15.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/CHANGELOG.md +66 -0
- package/README.md +5 -3
- package/extensions/index.ts +33 -1
- package/extensions/lib/registry.ts +31 -52
- package/extensions/modules/a2a/index.ts +0 -9
- package/extensions/modules/a2a/lib/config.ts +15 -1
- package/extensions/modules/a2a/test/config.test.ts +27 -0
- package/extensions/modules/a2a/test/extension.test.ts +1 -19
- package/extensions/modules/advisor/commands/advisor.ts +3 -9
- package/extensions/modules/advisor/test/configPanel.test.ts +1 -1
- package/extensions/modules/advisor/test/module.test.ts +0 -11
- package/extensions/modules/classifier/index.ts +0 -3
- package/extensions/modules/composer/test/module.test.ts +0 -22
- package/extensions/modules/config/defaultTools.ts +5 -3
- package/extensions/modules/config/index.ts +18 -204
- package/extensions/modules/config/test/defaultTools.test.ts +3 -4
- package/extensions/modules/config/test/panel.test.ts +9 -72
- package/extensions/modules/fff/index.ts +19 -8
- package/extensions/modules/fff/test/index.test.ts +31 -4
- package/extensions/modules/gh/configPanel.ts +9 -6
- package/extensions/modules/gh/index.ts +0 -3
- package/extensions/modules/gh/test/gh.test.ts +61 -0
- package/extensions/modules/jfind/index.ts +10 -4
- package/extensions/modules/jfind/lib/cascade.ts +15 -1
- package/extensions/modules/jfind/lib/lexical.ts +18 -6
- package/extensions/modules/jfind/lib/tree.ts +34 -4
- package/extensions/modules/jfind/test/cascade.test.ts +56 -1
- package/extensions/modules/munin/index.ts +5 -7
- package/extensions/modules/notify/index.ts +0 -3
- package/extensions/modules/plan/index.ts +1 -7
- package/extensions/modules/repair/configPanel.ts +11 -8
- package/extensions/modules/repair/index.ts +58 -33
- package/extensions/modules/repair/lib/auto-bg.ts +45 -2
- package/extensions/modules/repair/lib/auto-generated.ts +14 -4
- package/extensions/modules/repair/lib/read-archive.ts +14 -0
- package/extensions/modules/repair/lib/read-sqlite.ts +10 -4
- package/extensions/modules/repair/lib/settings.ts +19 -8
- package/extensions/modules/repair/test/auto-bg.test.ts +66 -0
- package/extensions/modules/repair/test/hardening.test.ts +214 -0
- package/extensions/modules/repair/test/settings.test.ts +52 -13
- package/extensions/modules/rules/index.ts +0 -4
- package/extensions/modules/rules/lib/rules.ts +1 -1
- package/extensions/modules/rules/test/module.test.ts +2 -29
- package/extensions/modules/serena/index.ts +1 -6
- package/extensions/modules/serena/lib/guidance.ts +9 -5
- package/extensions/modules/sg/index.ts +0 -5
- package/extensions/modules/shells/index.ts +31 -16
- package/extensions/modules/shells/lib/sessions.ts +76 -8
- package/extensions/modules/shells/test/output.test.ts +130 -0
- package/extensions/modules/shells/test/sessions.test.ts +127 -5
- package/extensions/modules/steering/lib/think.ts +0 -2
- package/extensions/modules/steering/test/think.test.ts +1 -5
- package/extensions/modules/todo/index.ts +0 -2
- package/extensions/modules/usage/index.ts +19 -9
- package/extensions/modules/usage/test/context.test.ts +18 -7
- package/extensions/modules/ux/index.ts +1 -5
- package/extensions/modules/ux/test/extension.test.ts +0 -5
- package/extensions/modules/web/index.ts +0 -9
- package/extensions/modules/web/lib/pdf.ts +4 -2
- package/extensions/modules/web/test/extension.test.ts +8 -18
- package/extensions/modules/web/test/pdf.test.ts +84 -0
- package/package.json +1 -1
- package/extensions/lib/tools.ts +0 -47
- package/extensions/modules/config/test/renderTools.test.ts +0 -71
- package/extensions/modules/config/test/tools.test.ts +0 -146
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
14
14
|
import { Type } from "typebox";
|
|
15
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
16
15
|
import { ghAvailable, realGh } from "./lib/gh-cli.js";
|
|
17
16
|
import { executeOp } from "./lib/ops.js";
|
|
18
17
|
|
|
@@ -40,7 +39,6 @@ export default function ghModule(pi: ExtensionAPI): void {
|
|
|
40
39
|
// stays registered in the loader) so installing gh + /reload activates it.
|
|
41
40
|
if (!ghAvailable()) return;
|
|
42
41
|
|
|
43
|
-
const disabled = readDisabledTools();
|
|
44
42
|
pi.registerTool({
|
|
45
43
|
name: "github",
|
|
46
44
|
label: "GitHub",
|
|
@@ -81,6 +79,5 @@ export default function ghModule(pi: ExtensionAPI): void {
|
|
|
81
79
|
return { content: [{ type: "text", text: err instanceof Error ? err.message : String(err) }], isError: true, details: undefined };
|
|
82
80
|
}
|
|
83
81
|
},
|
|
84
|
-
defaultActive: !disabled.has("github"),
|
|
85
82
|
});
|
|
86
83
|
}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
6
|
import { describe, it } from "node:test";
|
|
7
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
7
10
|
import {
|
|
8
11
|
formatGhFailure,
|
|
9
12
|
ghAvailable,
|
|
@@ -278,3 +281,61 @@ describe("dispatcher + availability", () => {
|
|
|
278
281
|
);
|
|
279
282
|
});
|
|
280
283
|
});
|
|
284
|
+
|
|
285
|
+
describe("/config row (run_watch budget)", () => {
|
|
286
|
+
// Round-trip: the row setter mutates a SHARED { value } object (the
|
|
287
|
+
// todo-module pattern) so the save path persists what was edited — a
|
|
288
|
+
// by-value parameter made the setting silently unwritable (round-3 P2).
|
|
289
|
+
it("row.set writes through to the working copy; garbage input keeps it", async () => {
|
|
290
|
+
const { buildGhGroups } = await import("../configPanel.ts");
|
|
291
|
+
const working = { value: 600 };
|
|
292
|
+
const row0 = buildGhGroups(working)[0]!.rows[0]!;
|
|
293
|
+
assert.equal(row0.key, "gh.runWatchTimeoutSecs");
|
|
294
|
+
assert.equal(row0.value, 600);
|
|
295
|
+
|
|
296
|
+
row0.set("900");
|
|
297
|
+
assert.equal(working.value, 900);
|
|
298
|
+
row0.set(1200);
|
|
299
|
+
assert.equal(working.value, 1200);
|
|
300
|
+
|
|
301
|
+
// NaN guard: a garbage inline edit leaves the working value untouched
|
|
302
|
+
// (a NaN would JSON-serialize to null and silently reset the setting).
|
|
303
|
+
row0.set("garbage");
|
|
304
|
+
assert.equal(working.value, 1200);
|
|
305
|
+
// Floor: sub-10 values clamp to 10.
|
|
306
|
+
row0.set(5);
|
|
307
|
+
assert.equal(working.value, 10);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("save() persists the edited working value and notifies; no owned key = no-op", async () => {
|
|
311
|
+
const { ghConfig } = await import("../configPanel.ts");
|
|
312
|
+
const home = process.env.PI_CODING_AGENT_DIR;
|
|
313
|
+
const dir = mkdtempSync(join(tmpdir(), "gh-config-"));
|
|
314
|
+
process.env.PI_CODING_AGENT_DIR = dir;
|
|
315
|
+
try {
|
|
316
|
+
const cfg = ghConfig({} as never);
|
|
317
|
+
// Drive the row the panel drives it: build groups, edit, save.
|
|
318
|
+
const row0 = cfg.groups()[0]!.rows[0]!;
|
|
319
|
+
row0.set("900");
|
|
320
|
+
|
|
321
|
+
const notes: string[] = [];
|
|
322
|
+
await cfg.save(new Set(["gh.runWatchTimeoutSecs"]), {
|
|
323
|
+
ui: { notify: (m: string) => notes.push(m) },
|
|
324
|
+
} as never);
|
|
325
|
+
const persisted = JSON.parse(readFileSync(join(dir, "settings.json"), "utf8"));
|
|
326
|
+
assert.equal(persisted.gh.runWatchTimeoutSecs, 900);
|
|
327
|
+
assert.match(notes[0] ?? "", /runWatchTimeoutSecs=900/);
|
|
328
|
+
|
|
329
|
+
// No owned edited key → no write.
|
|
330
|
+
await cfg.save(new Set(["other.key"]), {
|
|
331
|
+
ui: { notify: (m: string) => notes.push(m) },
|
|
332
|
+
} as never);
|
|
333
|
+
assert.equal(JSON.parse(readFileSync(join(dir, "settings.json"), "utf8")).gh.runWatchTimeoutSecs, 900);
|
|
334
|
+
assert.equal(notes.length, 1);
|
|
335
|
+
} finally {
|
|
336
|
+
if (home === undefined) delete process.env.PI_CODING_AGENT_DIR;
|
|
337
|
+
else process.env.PI_CODING_AGENT_DIR = home;
|
|
338
|
+
rmSync(dir, { recursive: true, force: true });
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
@@ -6,7 +6,6 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
6
6
|
import { existsSync, statSync } from "node:fs";
|
|
7
7
|
import { resolve as resolvePath } from "node:path";
|
|
8
8
|
import { Type } from "typebox";
|
|
9
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
10
9
|
import { formatBytes } from "./lib/format.js";
|
|
11
10
|
import { runCascade, FIND_TIMEOUT_MS, type CascadeResult } from "./lib/cascade.js";
|
|
12
11
|
import { createJudge } from "./lib/judge.js";
|
|
@@ -20,15 +19,14 @@ function formatBytesCeulen(bytes: number): string {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export default function jfindModule(pi: ExtensionAPI): void {
|
|
23
|
-
const disabled = readDisabledTools();
|
|
24
22
|
pi.registerTool({
|
|
25
23
|
name: "jfind",
|
|
26
24
|
label: "Semantic Find",
|
|
27
|
-
defaultActive: !disabled.has("jfind"),
|
|
28
25
|
description:
|
|
29
26
|
"Semantic code find: describe a BEHAVIOR (\"where do we parse CLI flags\", \"retry with backoff around provider calls\") and get the files and line ranges that implement it, strongest first. " +
|
|
30
27
|
"A lexical keyword scan ranks candidates, then a System One judge (the router's classifier models) ranks filenames, passage sketches, and full passages in three waves. " +
|
|
31
|
-
"Use when grep/ffgrep can't phrase the search as a literal pattern; needs a classifier model to be configured (router catalog). Slower than grep (a few seconds of judging)."
|
|
28
|
+
"Use when grep/ffgrep can't phrase the search as a literal pattern; needs a classifier model to be configured (router catalog). Slower than grep (a few seconds of judging). " +
|
|
29
|
+
"The `path` scope accepts a directory OR a single file (a deny-listed/binary/secret/empty file is refused with a reason).",
|
|
32
30
|
promptSnippet: "Semantic find: locate code by describing what it does",
|
|
33
31
|
promptGuidelines: [
|
|
34
32
|
"Describe the behavior, not the keywords: jfind judges passages semantically.",
|
|
@@ -81,6 +79,14 @@ export default function jfindModule(pi: ExtensionAPI): void {
|
|
|
81
79
|
}
|
|
82
80
|
throw err;
|
|
83
81
|
}
|
|
82
|
+
// A single-file scope that lists zero eligible files used to fall through
|
|
83
|
+
// to a silent "no hits" — surface the eligibility refusal instead.
|
|
84
|
+
if (result.stats.listed === 0 && scopeInput.length > 0 && statSync(root).isFile()) {
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: "text", text: `not searchable: ${scopeInput} (deny-listed, binary, secret, or empty by jfind's eligibility rules)` }],
|
|
87
|
+
details: { query },
|
|
88
|
+
};
|
|
89
|
+
}
|
|
84
90
|
const { stats, threshold, keywords } = result;
|
|
85
91
|
const scope = scopeInput.length > 0 ? ` in ${scopeInput}` : "";
|
|
86
92
|
const out: string[] = [];
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// budgets, and constants.
|
|
7
7
|
|
|
8
8
|
import { basename } from "node:path";
|
|
9
|
+
import { statSync } from "node:fs";
|
|
9
10
|
import {
|
|
10
11
|
fileScore,
|
|
11
12
|
grepIndex,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
type SketchCard,
|
|
25
26
|
} from "./questions.js";
|
|
26
27
|
import {
|
|
28
|
+
eligibleFile,
|
|
27
29
|
listFiles,
|
|
28
30
|
mergeHeat,
|
|
29
31
|
plainContent,
|
|
@@ -197,7 +199,7 @@ class Cascade {
|
|
|
197
199
|
const keywords = deriveKeywords(query, this.#options.extraKeywords);
|
|
198
200
|
|
|
199
201
|
onProgress?.("lexical scan");
|
|
200
|
-
const entries =
|
|
202
|
+
const entries = scopeFiles(root);
|
|
201
203
|
const fileMap = new Map(entries.map((e) => [e.rel, e.path]));
|
|
202
204
|
const index: GrepIndex = await grepIndex(root, keywords, { files: fileMap, signal });
|
|
203
205
|
this.stats.listed = entries.length;
|
|
@@ -369,6 +371,18 @@ class Cascade {
|
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
|
|
374
|
+
/** The lexical/judging cascade runs over a file LIST; a single-file `path`
|
|
375
|
+
* scope used to list zero files and report "no hits" silently. Wrap it as a
|
|
376
|
+
* one-entry walk so the documented scope works. Exported for tests. */
|
|
377
|
+
export function scopeFiles(root: string): FileEntry[] {
|
|
378
|
+
const st = statSync(root);
|
|
379
|
+
if (!st.isDirectory()) {
|
|
380
|
+
const rel = basename(root);
|
|
381
|
+
return eligibleFile(rel, st.size, rel.startsWith(".")) ? [{ path: root, rel, size: st.size }] : [];
|
|
382
|
+
}
|
|
383
|
+
return listFiles(root);
|
|
384
|
+
}
|
|
385
|
+
|
|
372
386
|
/** One cascade search. Judge failures degrade coverage and land in
|
|
373
387
|
* `stats.failures` — never thrown. */
|
|
374
388
|
export function runCascade(options: CascadeOptions): Promise<CascadeResult> {
|
|
@@ -157,16 +157,21 @@ export interface GrepIndexOptions {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const SCAN_LIMIT_DEFAULT = 512 * 1024;
|
|
160
|
+
/** ponytail: hard read cap per file — a multi-GB log must not buffer whole.
|
|
161
|
+
* The scan only needs counts, not completeness. */
|
|
162
|
+
const SCAN_READ_CAP = 2 * 1024 * 1024;
|
|
160
163
|
|
|
161
164
|
/**
|
|
162
165
|
* Count keyword occurrences (case-insensitive) per file by scanning each
|
|
163
|
-
* eligible file's first `scanLimitBytes
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
+
* eligible file's first `scanLimitBytes`, read as a BOUNDED prefix (open +
|
|
167
|
+
* read at most SCAN_READ_CAP bytes; a multi-GB log never buffers whole).
|
|
168
|
+
* ponytail: plain read + regex over matching lines (no native grep) — the
|
|
169
|
+
* cascade's ranking only needs counts, and the walk is already
|
|
170
|
+
* eligibility-bounded. Exported for tests.
|
|
166
171
|
*/
|
|
167
172
|
export async function grepIndex(rootAbs: string, rawKeywords: readonly string[], options: GrepIndexOptions): Promise<GrepIndex> {
|
|
168
173
|
void rootAbs;
|
|
169
|
-
const {
|
|
174
|
+
const { open } = await import("node:fs/promises");
|
|
170
175
|
const keywordsLower = rawKeywords.map((k) => k.toLowerCase()).filter((k) => k.length > 0);
|
|
171
176
|
const index: GrepIndex = { keywords: keywordsLower, perFileKw: new Map(), filesScanned: 0 };
|
|
172
177
|
if (keywordsLower.length === 0) return index;
|
|
@@ -176,8 +181,15 @@ export async function grepIndex(rootAbs: string, rawKeywords: readonly string[],
|
|
|
176
181
|
index.filesScanned++;
|
|
177
182
|
let text: string;
|
|
178
183
|
try {
|
|
179
|
-
const
|
|
180
|
-
|
|
184
|
+
const cap = Math.min(options.scanLimitBytes ?? SCAN_LIMIT_DEFAULT, SCAN_READ_CAP);
|
|
185
|
+
const fh = await open(abs, "r");
|
|
186
|
+
try {
|
|
187
|
+
const buf = Buffer.alloc(cap);
|
|
188
|
+
const { bytesRead } = await fh.read(buf, 0, cap, 0);
|
|
189
|
+
text = buf.subarray(0, bytesRead).toString("utf8");
|
|
190
|
+
} finally {
|
|
191
|
+
await fh.close();
|
|
192
|
+
}
|
|
181
193
|
} catch {
|
|
182
194
|
continue; // unreadable — just unranked
|
|
183
195
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { lines, clipBytes, countOccurrences } from "./lexical.js";
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
|
-
import { readdirSync,
|
|
8
|
+
import { closeSync, openSync, readdirSync, readSync, statSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
|
|
11
11
|
// ── eligibility deny-lists (tree.ts, verbatim) ──────────────────────────────
|
|
@@ -327,13 +327,33 @@ export interface ReadText {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
const BINARY_PROBE_BYTES = 8192;
|
|
330
|
+
/** ponytail: open + read at most this many bytes — a multi-GB file must not
|
|
331
|
+
* buffer whole before the maxBytes slice (the binary probe sits inside it). */
|
|
332
|
+
const READ_OPEN_CAP = 4 * 1024 * 1024;
|
|
330
333
|
|
|
331
|
-
/** Read up to `maxBytes` of a text file; rejects binaries and blank files.
|
|
334
|
+
/** Read up to `maxBytes` of a text file; rejects binaries and blank files.
|
|
335
|
+
* The underlying read is capped at READ_OPEN_CAP bytes regardless of maxBytes
|
|
336
|
+
* (beyond-cap callers already ask for ≤ READ_LIMIT, so only the OOM case
|
|
337
|
+
* changes); a short read at the cap flags `truncated`. */
|
|
332
338
|
export function readTextFile(absPath: string, maxBytes: number): ReadText {
|
|
333
|
-
|
|
339
|
+
const want = Math.min(maxBytes, READ_OPEN_CAP);
|
|
340
|
+
const fd = openSync(absPath, "r");
|
|
341
|
+
let buf: Buffer;
|
|
342
|
+
let total = 0;
|
|
343
|
+
try {
|
|
344
|
+
buf = Buffer.alloc(want);
|
|
345
|
+
while (total < want) {
|
|
346
|
+
const n = readSync(fd, buf, total, want - total, total);
|
|
347
|
+
if (n === 0) break;
|
|
348
|
+
total += n;
|
|
349
|
+
}
|
|
350
|
+
buf = buf.subarray(0, total);
|
|
351
|
+
} finally {
|
|
352
|
+
closeSync(fd);
|
|
353
|
+
}
|
|
334
354
|
const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
|
|
335
355
|
if (probe.includes(0)) throw new Error("binary");
|
|
336
|
-
const truncated =
|
|
356
|
+
const truncated = total >= want && (maxBytes > want || readSizeExceeds(absPath, want));
|
|
337
357
|
if (truncated) {
|
|
338
358
|
buf = buf.subarray(0, maxBytes);
|
|
339
359
|
const newline = buf.lastIndexOf(0x0a);
|
|
@@ -344,6 +364,16 @@ export function readTextFile(absPath: string, maxBytes: number): ReadText {
|
|
|
344
364
|
return { text, truncated };
|
|
345
365
|
}
|
|
346
366
|
|
|
367
|
+
/** Size check for the exact-cap edge (read filled `want` — is there more?).
|
|
368
|
+
* Only consulted when maxBytes === the read cap. */
|
|
369
|
+
function readSizeExceeds(absPath: string, cap: number): boolean {
|
|
370
|
+
try {
|
|
371
|
+
return statSync(absPath).size > cap;
|
|
372
|
+
} catch {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
347
377
|
/**
|
|
348
378
|
* Union the judged-positive spans; never bridge an unjudged gap. A merged
|
|
349
379
|
* span keeps the max probability. Strongest first, then earliest.
|
|
@@ -14,12 +14,13 @@ import {
|
|
|
14
14
|
mergeHeat,
|
|
15
15
|
plainContent,
|
|
16
16
|
rankedHeat,
|
|
17
|
+
readTextFile,
|
|
17
18
|
selectWindows,
|
|
18
19
|
sketch,
|
|
19
20
|
windows,
|
|
20
21
|
} from "../lib/tree.js";
|
|
21
22
|
import { entryKey, passageKey, nameBatch, sketchBatch, passageBatch, type Judge, type Request } from "../lib/questions.js";
|
|
22
|
-
import { runCascade, type CascadeOptions } from "../lib/cascade.js";
|
|
23
|
+
import { runCascade, scopeFiles, type CascadeOptions } from "../lib/cascade.js";
|
|
23
24
|
|
|
24
25
|
const dir = mkdtempSync(path.join(tmpdir(), "ceulen-jfind-"));
|
|
25
26
|
after(() => rmSync(dir, { recursive: true, force: true }));
|
|
@@ -302,4 +303,58 @@ describe("cascade", () => {
|
|
|
302
303
|
/aborted/,
|
|
303
304
|
);
|
|
304
305
|
});
|
|
306
|
+
|
|
307
|
+
it("a SINGLE-FILE path scope judges that file (B10 — was a silent no-hits)", async () => {
|
|
308
|
+
const judge = fakeJudge("src/spawn.ts");
|
|
309
|
+
const result = await runCascade({
|
|
310
|
+
root: path.join(proj, "src", "spawn.ts"),
|
|
311
|
+
query: "spawn a child process",
|
|
312
|
+
extraKeywords: [],
|
|
313
|
+
judge,
|
|
314
|
+
});
|
|
315
|
+
assert.equal(result.stats.listed, 1, "the file itself is the one entry");
|
|
316
|
+
assert.ok(result.hits.length >= 1, `hits: ${JSON.stringify(result.hits)}`);
|
|
317
|
+
assert.equal(result.hits[0]!.rel, "spawn.ts");
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("an ineligible single-file scope lists zero files", () => {
|
|
321
|
+
writeFileSync(path.join(proj, "logo.png"), "not text");
|
|
322
|
+
assert.deepEqual(scopeFiles(path.join(proj, "logo.png")), []);
|
|
323
|
+
const one = scopeFiles(path.join(proj, "src", "spawn.ts"));
|
|
324
|
+
assert.equal(one.length, 1);
|
|
325
|
+
assert.equal(one[0]!.rel, "spawn.ts");
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it("grepIndex reads a BOUNDED prefix, not the whole file (B11)", async () => {
|
|
329
|
+
// 3 MB file: needle within the 2 MB SCAN_READ_CAP, and one beyond it when
|
|
330
|
+
// the caller raises scanLimitBytes above the cap.
|
|
331
|
+
const big = path.join(dir, "scan-big.log");
|
|
332
|
+
const head = Buffer.from("spawn early\n");
|
|
333
|
+
const filler = Buffer.alloc(1024 * 1024, 0x78); // 'x'
|
|
334
|
+
writeFileSync(big, Buffer.concat([head, filler, Buffer.from("spawn late\n")]));
|
|
335
|
+
const files = new Map([["scan-big.log", big]]);
|
|
336
|
+
// scanLimitBytes 3 MB > the 2 MB read cap: the cap wins, the 2 MB+ hit is NOT counted.
|
|
337
|
+
const capped = await grepIndex(dir, ["spawn"], { files, scanLimitBytes: 3 * 1024 * 1024 });
|
|
338
|
+
const counts = capped.perFileKw.get("scan-big.log");
|
|
339
|
+
assert.ok(counts, "within-cap hit counted");
|
|
340
|
+
assert.ok(counts![0]! >= 1, "the early spawn counted");
|
|
341
|
+
assert.equal(capped.filesScanned, 1);
|
|
342
|
+
// Default 512 KB scan limit on the same file: works, no whole-file read.
|
|
343
|
+
const small = await grepIndex(dir, ["spawn"], { files });
|
|
344
|
+
assert.ok(small.perFileKw.get("scan-big.log")![0]! >= 1);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("readTextFile caps its read even when maxBytes is huge (B11)", () => {
|
|
348
|
+
const big = path.join(dir, "read-big.txt");
|
|
349
|
+
writeFileSync(big, Buffer.concat([Buffer.from("head\n"), Buffer.alloc(5 * 1024 * 1024, 0x61)]));
|
|
350
|
+
// maxBytes far above the 4 MB READ_OPEN_CAP: the read is capped and flagged truncated.
|
|
351
|
+
const huge = readTextFile(big, 8 * 1024 * 1024);
|
|
352
|
+
assert.equal(huge.truncated, true, "beyond-cap read flags truncation");
|
|
353
|
+
assert.ok(Buffer.byteLength(huge.text) <= 4 * 1024 * 1024, "text stays within the open cap");
|
|
354
|
+
assert.match(huge.text, /^head\n/);
|
|
355
|
+
// Normal path unchanged: 1 KB slice of the same file.
|
|
356
|
+
const sliced = readTextFile(big, 1024);
|
|
357
|
+
assert.equal(sliced.truncated, true);
|
|
358
|
+
assert.ok(Buffer.byteLength(sliced.text) <= 1024 + 8, "slice ends on a line boundary");
|
|
359
|
+
});
|
|
305
360
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Ported from @bacnh85/pi-munin 0.5.12 extensions/index.ts (SDK vendored to
|
|
4
4
|
// lib/sdk.ts; dotenv dropped — ceulen's bundle env.ts ingests trusted .env).
|
|
5
|
-
// Registers the 8 munin_* tools (
|
|
5
|
+
// Registers the 8 munin_* tools (all deferred — tool_search loads them),
|
|
6
6
|
// /munin-status, the Munin Memory Protocol injection (only when configured),
|
|
7
7
|
// the tool_result error sanitizer, and the munin skill (resources_discover).
|
|
8
8
|
// Config lives at PROJECT level (.pi/settings.json `munin` section) — see
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
type Remediation,
|
|
36
36
|
} from "./lib/helpers.js";
|
|
37
37
|
import { withRetry } from "./lib/retry.js";
|
|
38
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
39
38
|
import { skillsRoot } from "../../lib/skill-path.js";
|
|
40
39
|
|
|
41
40
|
// Shared schemas — per-call overrides (params win over env/settings).
|
|
@@ -69,7 +68,9 @@ const MUNIN_PROTOCOL_HEADER = `## Munin Memory Protocol
|
|
|
69
68
|
|
|
70
69
|
Use Munin to recover and preserve verified project knowledge, not as a task log.
|
|
71
70
|
If Munin is unavailable, state that briefly when it matters and continue from
|
|
72
|
-
repository evidence.
|
|
71
|
+
repository evidence. The munin_* tools are deferred: if none are declared yet,
|
|
72
|
+
load them with one tool_search call for "munin" (they stay declared for the
|
|
73
|
+
rest of the session).
|
|
73
74
|
|
|
74
75
|
### Before acting
|
|
75
76
|
|
|
@@ -576,11 +577,8 @@ export default function muninExtension(pi: ExtensionAPI) {
|
|
|
576
577
|
skillPaths: [path.join(skillsRoot(), "munin")],
|
|
577
578
|
}));
|
|
578
579
|
|
|
579
|
-
// Per-tool kill-switch (ceulen.disabledTools): listed tools register
|
|
580
|
-
// inactive — /config re-activates them live via setActiveTools.
|
|
581
|
-
const disabled = readDisabledTools();
|
|
582
580
|
for (const tool of makeTools()) {
|
|
583
|
-
pi.registerTool(
|
|
581
|
+
pi.registerTool(tool as AnyTool);
|
|
584
582
|
}
|
|
585
583
|
|
|
586
584
|
pi.registerCommand("munin-status", {
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { Type } from "typebox";
|
|
8
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
9
8
|
import { notify } from "./lib/notify.js";
|
|
10
9
|
|
|
11
10
|
export default function notifyModule(pi: ExtensionAPI): void {
|
|
12
|
-
const disabled = readDisabledTools();
|
|
13
11
|
pi.registerTool({
|
|
14
12
|
name: "notify",
|
|
15
13
|
label: "Notify",
|
|
@@ -28,6 +26,5 @@ export default function notifyModule(pi: ExtensionAPI): void {
|
|
|
28
26
|
if (r.note) text += `\n${r.note}`;
|
|
29
27
|
return { content: [{ type: "text", text }], details: { via: r.via } };
|
|
30
28
|
},
|
|
31
|
-
defaultActive: !disabled.has("notify"),
|
|
32
29
|
});
|
|
33
30
|
}
|
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
type ThinkingLevel,
|
|
53
53
|
} from "./lib/settings.js";
|
|
54
54
|
import { getPlanRegistry, planConfig, setPlanBridge, setPlanRegistry, type PlanBridge } from "./configPanel.js";
|
|
55
|
-
import { readDisabledTools } from "../../lib/tools.js";
|
|
56
55
|
// Sandbox semantics live in ONE place: the subagent module resolves agent
|
|
57
56
|
// frontmatter (user + project + bundled). discoverAgents is a pure fs loader,
|
|
58
57
|
// independent of whether the subagent module itself is enabled.
|
|
@@ -165,10 +164,7 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
165
164
|
let planReadyForReview = false;
|
|
166
165
|
let applyingStoredModel = false;
|
|
167
166
|
let writePlanInProgress = false;
|
|
168
|
-
|
|
169
|
-
* be silently undone by entering plan mode. */
|
|
170
|
-
const planToolsAvailable = (): string[] =>
|
|
171
|
-
[PLAN_TOOL, ASK_USER_QUESTION_TOOL].filter((t) => !readDisabledTools().has(t));
|
|
167
|
+
const planToolsAvailable = (): string[] => [PLAN_TOOL, ASK_USER_QUESTION_TOOL];
|
|
172
168
|
|
|
173
169
|
// ── State / settings ────────────────────────────────────────
|
|
174
170
|
|
|
@@ -594,7 +590,6 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
594
590
|
`Use ${PLAN_TOOL} in plan mode after exploration. No edit/write until the plan is approved.`,
|
|
595
591
|
`Don't call ${PLAN_TOOL} while blocking questions remain; use ${ASK_USER_QUESTION_TOOL} first.`,
|
|
596
592
|
],
|
|
597
|
-
defaultActive: !readDisabledTools().has(PLAN_TOOL),
|
|
598
593
|
parameters: Type.Object({
|
|
599
594
|
title: Type.Optional(Type.String({ description: "Short plan title. Optional: derived from the first '# Heading' in content when omitted." })),
|
|
600
595
|
content: Type.String({ description: "Markdown plan content" }),
|
|
@@ -617,7 +612,6 @@ export default function planModule(pi: ExtensionAPI): void {
|
|
|
617
612
|
"Provide a recommended option when one choice is clearly preferable.",
|
|
618
613
|
`Never issue multiple ${ASK_USER_QUESTION_TOOL} calls in the same turn — ask one question, await the answer, then decide.`,
|
|
619
614
|
],
|
|
620
|
-
defaultActive: !readDisabledTools().has(ASK_USER_QUESTION_TOOL),
|
|
621
615
|
parameters: Type.Object({
|
|
622
616
|
question: Type.String({ description: "Question to ask the user" }),
|
|
623
617
|
options: Type.Array(
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// repair's /config contribution — Tools tab, Repair section.
|
|
2
2
|
//
|
|
3
|
-
// The working copy
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
3
|
+
// The working copy mirrors the GLOBAL settings.json `repair` section (the
|
|
4
|
+
// file this panel writes); readRepairSettings() without a cwd is exactly the
|
|
5
|
+
// global layer. The trusted-project layer stays visible: the save notify
|
|
6
|
+
// discloses when a project file shadows the global save (projectShadow), the
|
|
7
|
+
// same contract as the other global-writing panels (advisor, subagent, a2a).
|
|
8
|
+
// The three tool-call-time toggles apply to the next turn (settings are read
|
|
9
|
+
// per tool call); the two bash keys bind at module load, hence the "next
|
|
10
|
+
// session" warning. The config module AUTO-prepends the Enable row and
|
|
11
|
+
// appends the per-tool toggle rows (apply_patch / str_replace_editor from the
|
|
12
|
+
// registry entry) — none of those are declared here.
|
|
10
13
|
|
|
11
14
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
12
15
|
import { row, type PanelGroup } from "../../lib/panel.js";
|
|
@@ -95,7 +98,7 @@ export function repairConfig(_pi: ExtensionAPI): ModuleConfig {
|
|
|
95
98
|
notes.push("The bash description + auto-background mechanics bind at session start — that change applies to the next session.");
|
|
96
99
|
}
|
|
97
100
|
const shadowed = projectShadow(ctx.cwd, ctx.isProjectTrusted?.() === true);
|
|
98
|
-
if (shadowed) notes.push(`This project's .pi/settings.json sets "repair" — the project layer overrides this save.`);
|
|
101
|
+
if (shadowed) notes.push(`This project's .pi/settings.json sets "repair" — the project layer overrides this save (project values stay authoritative at runtime).`);
|
|
99
102
|
ctx.ui.notify(notes.join(" "), shadowed ? "warning" : "info");
|
|
100
103
|
},
|
|
101
104
|
};
|