ceulen 0.18.0 → 0.20.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 +53 -0
- package/extensions/modules/config/piSettings.ts +6 -0
- package/extensions/modules/config/test/piSettings.test.ts +9 -0
- package/extensions/modules/plan/lib/plan-tools.ts +11 -0
- package/extensions/modules/plan/lib/shell-gate.ts +168 -14
- package/extensions/modules/plan/test/module.test.ts +13 -1
- package/extensions/modules/plan/test/shell-gate.test.ts +53 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.20.0 — 2026-10-16
|
|
4
|
+
|
|
5
|
+
pi 1.3.0 compatibility pass (verified by diffing the 1.2.0 and 1.3.0
|
|
6
|
+
releases surface by surface — ExtensionAPI types, root exports,
|
|
7
|
+
SettingsManager, settings schema, stock settings-selector, pi-tui,
|
|
8
|
+
agent-session tool restore): **no breaking changes**. The 1.3.0 delta is
|
|
9
|
+
additive for every ceulen-coupled surface; the resumed-session tool-restore
|
|
10
|
+
change runs before `session_start` and ceulen's append-only `tool_search`
|
|
11
|
+
re-arm composes with it; the overlay `done()` fix (#10648) removes a real
|
|
12
|
+
`/config`-overlay hazard when panels stack. Changes shipped:
|
|
13
|
+
|
|
14
|
+
- **peerDependencies** for both `@earendil-works/pi-*` packages widened
|
|
15
|
+
`>=0.99.1 <1.3.0` → `>=0.99.1 <1.4.0` (the old range excluded pi 1.3.0,
|
|
16
|
+
breaking fresh installs on the current release).
|
|
17
|
+
- **/config → Providers → Protocol** gains the `Session share destination`
|
|
18
|
+
row (`pi.sessionShareDestination`, auto/gist/radius) — stock-`/settings`
|
|
19
|
+
parity for pi 1.3.0's new `/share` destination setting (typed setter, so
|
|
20
|
+
it rides the existing SettingsManager save path).
|
|
21
|
+
- AGENTS.md inline peer range updated to match.
|
|
22
|
+
|
|
23
|
+
## 0.19.0 — 2026-10-15
|
|
24
|
+
|
|
25
|
+
Plan-mode false-block rework — mined from two weeks of session history
|
|
26
|
+
(155 sessions: 54 hard-blocked read-only commands, 28 headless confirm-blocks,
|
|
27
|
+
15 user rejects; several reproduced live during the analysis itself):
|
|
28
|
+
|
|
29
|
+
- **plan/shell-gate**: `classifyCommand`'s redirect/substitution pre-check was
|
|
30
|
+
quote-blind and substitution-hostile. Six false-positive classes fixed:
|
|
31
|
+
`<`/`>` inside quoted strings (`jq 'select(.x > "1")'`, `grep -oE "[^<]"`)
|
|
32
|
+
are data, not redirects; `$(…)`/backticks/`<(…)` classify their INNER command
|
|
33
|
+
recursively (read inner → read, unknown → confirm, write inner → write)
|
|
34
|
+
instead of blanket-hard-block; heredocs feeding an interpreter
|
|
35
|
+
(`python3 - <<'EOF'`) demote from write-block to the confirm tier; bare
|
|
36
|
+
`env` (`env | grep -i PI_`) reads instead of writing; sed's s-command flag
|
|
37
|
+
scan no longer parses file PATHS (`…/modules/plan/index.ts` faked
|
|
38
|
+
`s/modules/plan/index` with flags containing `e`), is anchored against
|
|
39
|
+
word-char/`/`-preceded `s`, and treats a substitution AS the script as
|
|
40
|
+
uninspectable → confirm. True writers (`echo x > f`, `rm`, `cat > f <<EOF`)
|
|
41
|
+
stay hard-blocked. Regression fixture table pins 29 real commands from the
|
|
42
|
+
logs.
|
|
43
|
+
- **plan/plan-tools**: `READ_ONLY_TOOLS` gains the research set —
|
|
44
|
+
`web_search`, `web_extract`, `web_map`, `web_screenshot`, `web_pdf`,
|
|
45
|
+
`tool_search`, `todo`. `web_interact`/`web_crawl`/`web_research`/
|
|
46
|
+
`web_image`/`web_chat` stay at the confirm tier (external side effects).
|
|
47
|
+
- **classifier.planGate.observe**: recommended-first configuration step (a
|
|
48
|
+
settings change, not code): observe mode logs safe/unsafe verdicts for
|
|
49
|
+
confirm-tier commands to classifier.log under `ceulen-plan-gate`; review
|
|
50
|
+
before flipping `classifier.planGate.enabled` to auto-run safe commands
|
|
51
|
+
without prompting.
|
|
52
|
+
- **test**: fix the plan handoff test flake (two `write_plan` calls in the
|
|
53
|
+
same millisecond shared a `<timestamp>-<slug>` filename; the test now
|
|
54
|
+
sleeps 2ms — the module keeps overwrite semantics).
|
|
55
|
+
|
|
3
56
|
## 0.18.0 — 2026-10-14
|
|
4
57
|
|
|
5
58
|
pi 1.2.0 compatibility + the ask_user_question confirmation loop (incident
|
|
@@ -546,6 +546,12 @@ function piRowSpecs(m: SettingsManager, lookup?: PiMenuLookup): PiRowSpec[] {
|
|
|
546
546
|
description: "Preferred transport for providers that support multiple transports.",
|
|
547
547
|
set: (v) => m.setTransport(str(v) as never),
|
|
548
548
|
},
|
|
549
|
+
{
|
|
550
|
+
key: "pi.sessionShareDestination", tab: "Providers", section: "Protocol", label: "Session share destination",
|
|
551
|
+
kind: "string", value: m.getSessionShareDestination(), values: ["auto", "gist", "radius"], defaultValue: "auto",
|
|
552
|
+
description: "Where to upload sessions with /share (auto prefers Radius when authenticated, otherwise GitHub Gist).",
|
|
553
|
+
set: (v) => m.setSessionShareDestination(str(v) as never),
|
|
554
|
+
},
|
|
549
555
|
{
|
|
550
556
|
key: "pi.httpIdleTimeoutMs", tab: "Providers", section: "Timeouts", label: "HTTP idle timeout",
|
|
551
557
|
kind: "string", value: httpTimeoutLabel(m.getHttpIdleTimeoutMs()), defaultValue: "5 min",
|
|
@@ -12,6 +12,15 @@ const rowsOf = (m: SettingsManager) => buildPiSettingsGroups(m).flatMap((g) => g
|
|
|
12
12
|
const rowAt = (m: SettingsManager, key: string) => rowsOf(m).find((r) => r.key === key)!;
|
|
13
13
|
|
|
14
14
|
describe("pi settings contribution", () => {
|
|
15
|
+
it("session share destination row round-trips auto/gist/radius", () => {
|
|
16
|
+
const m = SettingsManager.inMemory();
|
|
17
|
+
assert.equal(rowAt(m, "pi.sessionShareDestination").value, "auto");
|
|
18
|
+
for (const v of ["gist", "radius", "auto"] as const) {
|
|
19
|
+
rowAt(m, "pi.sessionShareDestination").set(v);
|
|
20
|
+
assert.equal(m.getSessionShareDestination(), v);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
15
24
|
it("builds OMP-taxonomy tabs with unique keys and sections", () => {
|
|
16
25
|
const groups = buildPiSettingsGroups(SettingsManager.inMemory());
|
|
17
26
|
const keys = groups.flatMap((g) => g.rows.map((r) => r.key));
|
|
@@ -33,6 +33,17 @@ export const READ_ONLY_TOOLS = new Set([
|
|
|
33
33
|
// Rendered-page accessibility audit — reads the page in a local headless
|
|
34
34
|
// Chrome, mutates nothing.
|
|
35
35
|
"web_a11y",
|
|
36
|
+
// Web research reads: search results, page→markdown, site URL map, page
|
|
37
|
+
// capture/PDF text. Plan mode IS research; these fetch remote content and
|
|
38
|
+
// write nothing (web_interact/web_crawl/web_research/web_image/web_chat
|
|
39
|
+
// act on external services and stay at the confirm tier).
|
|
40
|
+
"web_search", "web_extract", "web_map", "web_screenshot", "web_pdf",
|
|
41
|
+
// tool_search loads a deferred tool onto the request — no side effects; it
|
|
42
|
+
// is the only path to the deferred munin/web reads inside plan mode.
|
|
43
|
+
"tool_search",
|
|
44
|
+
// Todo phases persist session-transcript entries only (pi.appendEntry) —
|
|
45
|
+
// never the repo; OMP plans track phases while planning.
|
|
46
|
+
"todo",
|
|
36
47
|
// PDF text extraction (vendored pdf.js, in-process) — reads a local file.
|
|
37
48
|
"read_pdf",
|
|
38
49
|
// Semantic find — read-only judging over the workspace; costs model calls
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
// keep the rules byte-faithful. Local changes: exported standalone functions,
|
|
4
4
|
// no plan/file state.
|
|
5
5
|
//
|
|
6
|
+
// 2026-10-15 rework (session-history evidence: 54 hard-blocked read-only
|
|
7
|
+
// commands over 2 weeks — see .pi/plans/2026-10-15T08-50-03-167Z*.md): the
|
|
8
|
+
// redirect/substitution pre-check became quote-aware; `$(…)`/`` `…` ``/
|
|
9
|
+
// `<(…)` substitutions classify their INNER command instead of blanket-write;
|
|
10
|
+
// heredocs feeding an interpreter drop from write to the confirm tier; bare
|
|
11
|
+
// `env` (no args) reads; sed's s-command flag scan no longer parses file
|
|
12
|
+
// PATHS as `s/pattern/repl/flags`. Deliberate deviations from upstream —
|
|
13
|
+
// keep them when re-vendoring.
|
|
14
|
+
//
|
|
6
15
|
// Classifies one shell command for plan mode WITHOUT attempting to interpret
|
|
7
16
|
// arbitrary executables:
|
|
8
17
|
// read — provably no filesystem writes → auto-run
|
|
@@ -99,13 +108,48 @@ const FLOW_KEYWORD = /^(?:while|until|do|done)(?:\s+|$)/;
|
|
|
99
108
|
// sed read-only gate: `w` (file write), `e` (executes pattern space), -f
|
|
100
109
|
// (script file, uninspectable), -i (in-place) are the writers. Everything else
|
|
101
110
|
// is stdout-only.
|
|
102
|
-
|
|
111
|
+
// `s` must not follow a word char or `/` — `s/modules/plan/index` inside a
|
|
112
|
+
// PATH (`…/modules/plan/index.ts`, observed inside a substitution span) is
|
|
113
|
+
// not an s-command. Address forms (`2s/…`) missed here are backstopped by
|
|
114
|
+
// the standalone `w`-flag checks below.
|
|
115
|
+
const S_COMMAND_FLAGS = /(?<![\/\w])s([^\w\s])(?:\\.|(?!\1)[\s\S])*?\1(?:\\.|(?!\1)[\s\S])*?\1([a-z0-9]*)/gi;
|
|
116
|
+
|
|
117
|
+
/** Quoted spans of a command — sed script arguments in practice. The s-command
|
|
118
|
+
* flag scan runs over ONLY these: file path operands like
|
|
119
|
+
* `extensions/modules/plan/index.ts` must not be parsed as
|
|
120
|
+
* `s/modules/plan/index` (flags "index" contain `e` → false "not read-only",
|
|
121
|
+
* observed live: `sed -n '800,845p' …/plan/index.ts` blocked). */
|
|
122
|
+
function quotedSpans(cmd: string): string[] {
|
|
123
|
+
const spans: string[] = [];
|
|
124
|
+
let quote: "'" | '"' | null = null;
|
|
125
|
+
let cur = "";
|
|
126
|
+
for (const ch of cmd) {
|
|
127
|
+
if (quote) {
|
|
128
|
+
cur += ch;
|
|
129
|
+
if (ch === quote) {
|
|
130
|
+
spans.push(cur);
|
|
131
|
+
cur = "";
|
|
132
|
+
quote = null;
|
|
133
|
+
}
|
|
134
|
+
} else if (ch === "'" || ch === '"') {
|
|
135
|
+
quote = ch;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return spans;
|
|
139
|
+
}
|
|
103
140
|
|
|
104
141
|
function isSedReadOnly(inspection: string): boolean {
|
|
105
142
|
if (/(?:^|\s)-[a-zA-Z]*[if][a-zA-Z]*\b|--in-place\b|--file\b/i.test(inspection)) return false;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
143
|
+
// The w/e flag checks and the s-command scan apply to the SCRIPT (the
|
|
144
|
+
// quoted arguments), never to file-path operands.
|
|
145
|
+
const script = quotedSpans(inspection).join("\n") || inspection;
|
|
146
|
+
// A runtime-computed script (`sed -n "$(grep …)p"`) is uninspectable —
|
|
147
|
+
// its `w`/`e` flags are only known at execution. Same reasoning as the
|
|
148
|
+
// heredoc rule: demote to confirm, never auto-read.
|
|
149
|
+
if (/\$\(|`/.test(script)) return false;
|
|
150
|
+
if (/(?<![A-Za-z])w|w(?![A-Za-z])/i.test(script)) return false;
|
|
151
|
+
if (/(?:^|[^A-Za-z-])e(?:[\s;}]|$|['"])/i.test(script)) return false;
|
|
152
|
+
for (const m of script.matchAll(S_COMMAND_FLAGS)) {
|
|
109
153
|
if (/[ew]/i.test(m[2])) return false;
|
|
110
154
|
}
|
|
111
155
|
return true;
|
|
@@ -156,7 +200,15 @@ export function classifySegment(seg: string): CommandDisposition {
|
|
|
156
200
|
// command/type/which: only pure executable lookups are reads. POSIX `command NAME`
|
|
157
201
|
// EXECUTES NAME, so bare `command` stays a writer wrapper; only `command -v/-V` is a lookup.
|
|
158
202
|
if (/^(?:type|which)\b/i.test(inspection) || /^command\s+-[vV]\b/i.test(inspection)) return "read";
|
|
159
|
-
|
|
203
|
+
// `env` is transparent: `env` alone (or piped — each pipe stage is its own
|
|
204
|
+
// segment) PRINTS the environment; `env VAR=x cmd…` runs the remainder.
|
|
205
|
+
// Observed live: `env | grep -i "PI_"` hard-blocked as a writer.
|
|
206
|
+
if (/^env(?:\s|$)/i.test(inspection)) {
|
|
207
|
+
const rest = inspection.replace(/^env\s*/i, "").trim();
|
|
208
|
+
if (!rest) return "read";
|
|
209
|
+
return classifySegment(rest);
|
|
210
|
+
}
|
|
211
|
+
if (/^(?:(?:rm|rmdir|mv|cp|mkdir|touch|chmod|chown|ln|install|truncate|dd|mktemp|command)|sudo|nohup|time)\b/i.test(inspection)) return "write";
|
|
160
212
|
if (/^sed\b/i.test(inspection)) {
|
|
161
213
|
if (/\s(?:-i\S*|--in-place(?:=\S*)?)(?:\s|$)/i.test(inspection) || /\b(?:\d+)?w\s+/i.test(inspection) || /\/w\s/i.test(inspection) || /(?:^|[^A-Za-z-])\d+w[a-zA-Z0-9.]/i.test(inspection)) return "write";
|
|
162
214
|
return isSedReadOnly(inspection) ? "read" : "confirm";
|
|
@@ -180,21 +232,123 @@ export function classifySegment(seg: string): CommandDisposition {
|
|
|
180
232
|
return /^(?:rg|grep|find|fd|ls|pwd|cat|head|tail|wc|sort|uniq|cut|echo|printf|jq|strings|stat|file|du|tree|lsof|basename|dirname|realpath|cd|read|diff|cmp)\b/i.test(inspection) ? "read" : "confirm";
|
|
181
233
|
}
|
|
182
234
|
|
|
235
|
+
/** Executing substitutions (`$(…)`, backticks, `<(…)`, `>(…)`) OUTSIDE single
|
|
236
|
+
* quotes (single-quoted text is literal — no substitution happens). Inner
|
|
237
|
+
* commands are classified recursively; a substitution is only as safe as
|
|
238
|
+
* what it runs. Nesting handled by depth; unclosed spans read to end. */
|
|
239
|
+
function findExecutingSubstitutions(cmd: string): string[] {
|
|
240
|
+
const inners: string[] = [];
|
|
241
|
+
let quote: "'" | '"' | null = null;
|
|
242
|
+
for (let i = 0; i < cmd.length; i++) {
|
|
243
|
+
const ch = cmd[i];
|
|
244
|
+
if (quote) {
|
|
245
|
+
if (ch === quote && cmd[i - 1] !== "\\") quote = null;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (ch === "'" || ch === '"') {
|
|
249
|
+
quote = ch;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const opener = ch === "`" ? "`" : ch === "$" && cmd[i + 1] === "(" ? "$(" : (ch === "<" || ch === ">") && cmd[i + 1] === "(" ? ch + "(" : null;
|
|
253
|
+
if (!opener) continue;
|
|
254
|
+
// Walk to the matching close (paren depth, or the closing backtick),
|
|
255
|
+
// single-quote-aware inside so `'` in the payload doesn't strand us.
|
|
256
|
+
let depth = 1;
|
|
257
|
+
let j = i + opener.length;
|
|
258
|
+
let inner = "";
|
|
259
|
+
let innerQuote: "'" | '"' | null = null;
|
|
260
|
+
for (; j < cmd.length && depth > 0; j++) {
|
|
261
|
+
const c = cmd[j];
|
|
262
|
+
if (innerQuote) {
|
|
263
|
+
if (c === innerQuote && cmd[j - 1] !== "\\") innerQuote = null;
|
|
264
|
+
} else if (c === "'" || c === '"') {
|
|
265
|
+
innerQuote = c;
|
|
266
|
+
} else if (opener === "`") {
|
|
267
|
+
if (c === "`") depth = 0;
|
|
268
|
+
} else if (c === "(") depth++;
|
|
269
|
+
else if (c === ")") depth--;
|
|
270
|
+
inner += depth > 0 ? c : "";
|
|
271
|
+
}
|
|
272
|
+
inners.push(inner);
|
|
273
|
+
i = j - 1;
|
|
274
|
+
}
|
|
275
|
+
return inners;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Disposition of every executing substitution in the command, or null when
|
|
279
|
+
* there are none. read only when EVERY inner command is read. */
|
|
280
|
+
function substitutionDisposition(cmd: string): CommandDisposition | null {
|
|
281
|
+
const inners = findExecutingSubstitutions(cmd);
|
|
282
|
+
if (inners.length === 0) return null;
|
|
283
|
+
let worst: CommandDisposition = "read";
|
|
284
|
+
for (const inner of inners) {
|
|
285
|
+
const d = classifyCommand(inner);
|
|
286
|
+
if (d === "write") return "write";
|
|
287
|
+
if (d === "confirm") worst = "confirm";
|
|
288
|
+
}
|
|
289
|
+
return worst;
|
|
290
|
+
}
|
|
291
|
+
|
|
183
292
|
/** Classify a full (possibly compound) command. Any known writer wins; the
|
|
184
|
-
* whole command is read only when every segment is read
|
|
293
|
+
* whole command is read only when every segment is read, there is no
|
|
294
|
+
* file-writing redirection, and no substitution/heredoc demotes it. */
|
|
185
295
|
export function classifyCommand(cmd: string): CommandDisposition {
|
|
186
296
|
const c = cmd.trim();
|
|
187
297
|
if (!c) return "confirm";
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
298
|
+
// File-writing redirections stay a hard write — but only REAL ones:
|
|
299
|
+
// quote-aware, so `<`/`>` inside quoted strings (jq `select(.x > "1")`
|
|
300
|
+
// programs, `grep -oE "[^<]"` patterns — the two biggest live false-block
|
|
301
|
+
// classes) are data, not redirects. Discarding forms stay read-safe:
|
|
302
|
+
// n>/dev/null and fd dups (2>&1, 2>&-).
|
|
303
|
+
let quote: "'" | '"' | null = null;
|
|
304
|
+
let heredocMark = false;
|
|
305
|
+
let inputRedirect = false; // unquoted `<` file/process input — demotes read
|
|
306
|
+
for (let i = 0; i < c.length; i++) {
|
|
307
|
+
const ch = c[i];
|
|
308
|
+
if (quote) {
|
|
309
|
+
if (ch === quote && c[i - 1] !== "\\") quote = null;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (ch === "'" || ch === '"') {
|
|
313
|
+
quote = ch;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (ch === "<" || ch === ">") {
|
|
317
|
+
const run = c.slice(i).match(/^[<>]+/)?.[0] ?? "";
|
|
318
|
+
const rest = c.slice(i + run.length);
|
|
319
|
+
if (ch === ">") {
|
|
320
|
+
// Writers: `>`/`>>` to a file. Read-safe: n>/dev/null, 2>&1, 2>&-.
|
|
321
|
+
if (/^\s*\/dev\/null(?![\w.\/-])/.test(rest) || /^\s*&[\d-]/.test(rest)) {
|
|
322
|
+
i += run.length + (rest.match(/^\s*\S+/)?.[0].length ?? 0);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
return "write";
|
|
326
|
+
}
|
|
327
|
+
if (run.length >= 2) {
|
|
328
|
+
heredocMark = true; // `<<`/`<<-` heredoc marker
|
|
329
|
+
i += run.length - 1;
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
inputRedirect = true; // `<` file input or `<(…)`, `>(…)` — executes/reads, demotes
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const sub = substitutionDisposition(c);
|
|
336
|
+
if (sub === "write") return "write";
|
|
337
|
+
// `sort --output` — the one flag-form file writer checked pre-split.
|
|
338
|
+
if (/--output(?:=|\s)/i.test(c)) return "write";
|
|
339
|
+
// Strip discard redirects before segmenting: `2>&1`'s `&` is an fd dup,
|
|
340
|
+
// NOT a background separator (splitting on it yields a phantom "1"
|
|
341
|
+
// segment that classifies confirm). The write-scan above already ran.
|
|
342
|
+
const segments = splitShellSegments(c.replace(/\d*>+\s*\/dev\/null(?![\w.\/-])|\d*>&[\d-]/g, ""));
|
|
194
343
|
if (segments.length > 1) {
|
|
195
344
|
if (segments.some((seg) => classifySegment(seg) === "write")) return "write";
|
|
196
|
-
if (segments.every((seg) => classifySegment(seg) === "read"))
|
|
345
|
+
if (segments.every((seg) => classifySegment(seg) === "read")) {
|
|
346
|
+
if (sub === "confirm" || heredocMark || inputRedirect) return "confirm";
|
|
347
|
+
return "read";
|
|
348
|
+
}
|
|
197
349
|
return "confirm";
|
|
198
350
|
}
|
|
199
|
-
|
|
351
|
+
const single = classifySegment(c);
|
|
352
|
+
if (single === "read" && (sub === "confirm" || heredocMark || inputRedirect)) return "confirm";
|
|
353
|
+
return single;
|
|
200
354
|
}
|
|
@@ -109,6 +109,15 @@ describe("plan mode — tool gating", () => {
|
|
|
109
109
|
const deny = await h.fire("tool_call", { toolName: "some_mcp_tool", input: {} }, h.ctx({ cwd: REPO, ui: { ...h.ctx().ui, select: async () => undefined } }));
|
|
110
110
|
assert.equal(deny.block, true);
|
|
111
111
|
});
|
|
112
|
+
|
|
113
|
+
it("2026-10-15 rework: web reads, tool_search, and todo auto-allow in plan mode", async () => {
|
|
114
|
+
const h = await start();
|
|
115
|
+
await h.commands.plan.handler("", h.ctx({ cwd: REPO }));
|
|
116
|
+
for (const toolName of ["web_search", "web_extract", "web_map", "web_screenshot", "web_pdf", "tool_search", "todo"]) {
|
|
117
|
+
const result = await h.fire("tool_call", { toolName, input: {} }, h.ctx({ cwd: REPO }));
|
|
118
|
+
assert.equal(result, undefined, `${toolName} must auto-allow (got ${JSON.stringify(result)})`);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
112
121
|
});
|
|
113
122
|
|
|
114
123
|
describe("plan mode — classifier planGate", () => {
|
|
@@ -363,8 +372,11 @@ describe("plan mode — prompt + approval flow", () => {
|
|
|
363
372
|
assert.match(h.newSessionMessages[0].content, /Execute the approved plan/);
|
|
364
373
|
|
|
365
374
|
// Regression: re-entering plan mode after the handoff must NOT reuse the
|
|
366
|
-
// child's plan path — a new plan writes a NEW file.
|
|
375
|
+
// child's plan path — a new plan writes a NEW file. (2ms delay: two plans
|
|
376
|
+
// in the same millisecond share a `<timestamp>-<slug>` name and the test
|
|
377
|
+
// would flake on second-granularity file identity, not module logic.)
|
|
367
378
|
await h.commands.plan.handler("", h.ctx({ cwd: REPO }));
|
|
379
|
+
await new Promise((r) => setTimeout(r, 2));
|
|
368
380
|
await h.tools.write_plan.execute("tc2", { title: "Handoff", content: "v2" }, undefined, undefined, h.ctx({ cwd: REPO }));
|
|
369
381
|
assert.equal(readSyncRecursive(join(REPO, ".pi", "plans")).filter((n) => n.includes("handoff")).length, 2, "fresh plan file, not an in-place refinement");
|
|
370
382
|
});
|
|
@@ -54,7 +54,7 @@ describe("plan shell gate — writers hard-block", () => {
|
|
|
54
54
|
"git commit -m x",
|
|
55
55
|
"git checkout main",
|
|
56
56
|
"git config user.email x@y.z",
|
|
57
|
-
"echo $(
|
|
57
|
+
"echo $(rm -rf x)",
|
|
58
58
|
"echo a | xargs rm",
|
|
59
59
|
"echo a | xargs --null rm",
|
|
60
60
|
]) {
|
|
@@ -81,6 +81,58 @@ describe("plan shell gate — unknown executables confirm", () => {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
// 2026-10-15 rework (plan 2026-10-15T08-50-03-167Z): the six false-block
|
|
85
|
+
// classes mined from 2 weeks of session history. Each command below was a
|
|
86
|
+
// REAL hard-block in a live session except the regression writers.
|
|
87
|
+
describe("plan shell gate — false-block rework fixtures", () => {
|
|
88
|
+
const cases: Array<[string, "read" | "write" | "confirm"]> = [
|
|
89
|
+
// A6: sed s-command flag scan no longer parses file PATHS.
|
|
90
|
+
["sed -n '800,845p' extensions/modules/plan/index.ts", "read"],
|
|
91
|
+
["sed -n '1,12p' extensions/modules/web/index.ts", "read"],
|
|
92
|
+
// A5: bare `env` prints the environment.
|
|
93
|
+
[`env | grep -i "PI_"`, "read"],
|
|
94
|
+
["env FOO=1 grep x f", "read"],
|
|
95
|
+
["env rm -rf x", "write"],
|
|
96
|
+
// A1: quoted `<`/`>` are data, not redirects.
|
|
97
|
+
[`jq -r 'select(.timestamp > "2026-10-14") | .x' sessions.jsonl`, "read"],
|
|
98
|
+
[`grep -oE "CgroupNS[^<]{0,120}" page.html`, "read"],
|
|
99
|
+
// A2: substitution classifies its INNER command.
|
|
100
|
+
[`TOKEN=$(curl -s https://x.test/t); curl -s https://x.test/v`, "confirm"],
|
|
101
|
+
["echo $(date)", "confirm"],
|
|
102
|
+
// Substitution AS the sed script is uninspectable (its w/e flags are
|
|
103
|
+
// runtime-computed) → confirm even with a read-only inner. REAL failing
|
|
104
|
+
// command from classifier.log (advisor-flagged A5 misreport, 2026-10-15):
|
|
105
|
+
[`sed -n "$(grep -n 'function planGateAutoRun' extensions/modules/plan/index.ts | cut -d: -f1),+2p" extensions/modules/plan/index.ts`, "confirm"],
|
|
106
|
+
// A3: process substitution demotes to confirm.
|
|
107
|
+
[`comm -23 <(ls themes/*.json | sort) <(jq -r '.x' themes/a.json)`, "confirm"],
|
|
108
|
+
// A4: heredoc feeding an interpreter is confirm, not write.
|
|
109
|
+
["python3 - <<'EOF'\nprint(1)\nEOF", "confirm"],
|
|
110
|
+
// `<` file input reads a file — demote to confirm, never auto-read.
|
|
111
|
+
["wc -l < notes.md", "confirm"],
|
|
112
|
+
// True writers stay hard-blocked.
|
|
113
|
+
["echo hi > /tmp/x", "write"],
|
|
114
|
+
["rm file.txt", "write"],
|
|
115
|
+
["cat > newf.ts <<'EOF'\nx\nEOF", "write"],
|
|
116
|
+
["cat <<EOF > x.md\nhello\nEOF", "write"],
|
|
117
|
+
// Controls (regression pins from the live probe).
|
|
118
|
+
["diff pi-web/a.d.ts /Users/x/node_modules/a.d.ts", "read"],
|
|
119
|
+
["R=/rel1/dist; L=/rel2/dist; diff \"$R/types.d.ts\" \"$L/types.d.ts\" | head -5", "read"],
|
|
120
|
+
["node --import tsx -e \"console.log(1)\"", "confirm"],
|
|
121
|
+
["npm test", "confirm"],
|
|
122
|
+
["for f in ~/.pi/agent/sessions/*/*.jsonl; do jq -r '.x' \"$f\"; done", "confirm"],
|
|
123
|
+
["git log --oneline | head -3", "read"],
|
|
124
|
+
["grep -rn \"exposure\" pi-*/extensions/*.ts | head", "read"],
|
|
125
|
+
["python3 -c 'import json; print(json.load(open(\"p.json\"))[\"a\"])'", "confirm"],
|
|
126
|
+
["git diff --stat", "read"],
|
|
127
|
+
["curl -s https://example.com | grep title", "confirm"],
|
|
128
|
+
["which pi; pi --version 2>/dev/null", "confirm"],
|
|
129
|
+
["wc -l extensions/modules/plan/index.ts", "read"],
|
|
130
|
+
];
|
|
131
|
+
for (const [cmd, expected] of cases) {
|
|
132
|
+
it(`${expected}: ${cmd.split("\n")[0]}`, () => assert.equal(classifyCommand(cmd), expected, cmd));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
84
136
|
describe("plan shell gate — helpers", () => {
|
|
85
137
|
it("splitShellSegments keeps quoted separators in one segment", () => {
|
|
86
138
|
assert.deepEqual(splitShellSegments("grep 'a|b' f | head"), ["grep 'a|b' f", "head"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ceulen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Ceulen — the Pi coding agent, fully dressed: one bundle extension carrying the full toolkit with a single /ceulen config command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@earendil-works/pi-coding-agent": ">=0.99.1 <1.
|
|
56
|
-
"@earendil-works/pi-tui": ">=0.99.1 <1.
|
|
55
|
+
"@earendil-works/pi-coding-agent": ">=0.99.1 <1.4.0",
|
|
56
|
+
"@earendil-works/pi-tui": ">=0.99.1 <1.4.0",
|
|
57
57
|
"typebox": "*"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|