ceulen 0.17.0 → 0.19.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 (117) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/extensions/modules/a2a/lib/client.ts +2 -1
  3. package/extensions/modules/advisor/commands/advisor.ts +22 -12
  4. package/extensions/modules/advisor/test/module.test.ts +26 -0
  5. package/extensions/modules/plan/index.ts +64 -0
  6. package/extensions/modules/plan/lib/plan-tools.ts +11 -0
  7. package/extensions/modules/plan/lib/shell-gate.ts +168 -14
  8. package/extensions/modules/plan/test/module.test.ts +125 -1
  9. package/extensions/modules/plan/test/shell-gate.test.ts +53 -1
  10. package/extensions/modules/steering/index.ts +25 -6
  11. package/extensions/modules/steering/test/anchor-regressions.test.ts +38 -0
  12. package/package.json +3 -3
  13. package/scripts/validate-themes.mjs +31 -3
  14. package/themes/alabaster.json +2 -17
  15. package/themes/amethyst.json +2 -19
  16. package/themes/anthracite.json +2 -22
  17. package/themes/basalt.json +3 -31
  18. package/themes/birch.json +2 -19
  19. package/themes/catppuccin-mocha.json +1 -7
  20. package/themes/dark-abyss.json +2 -17
  21. package/themes/dark-arctic.json +2 -23
  22. package/themes/dark-aurora.json +2 -18
  23. package/themes/dark-catppuccin.json +2 -25
  24. package/themes/dark-cavern.json +2 -18
  25. package/themes/dark-celestial.json +2 -18
  26. package/themes/dark-copper.json +2 -18
  27. package/themes/dark-cosmos.json +2 -17
  28. package/themes/dark-cyberpunk.json +2 -21
  29. package/themes/dark-dracula.json +2 -20
  30. package/themes/dark-eclipse.json +2 -18
  31. package/themes/dark-ember.json +2 -18
  32. package/themes/dark-equinox.json +2 -17
  33. package/themes/dark-forest.json +2 -21
  34. package/themes/dark-github.json +2 -24
  35. package/themes/dark-gruvbox.json +2 -30
  36. package/themes/dark-lavender.json +2 -18
  37. package/themes/dark-lunar.json +2 -17
  38. package/themes/dark-midnight.json +2 -18
  39. package/themes/dark-monochrome.json +2 -19
  40. package/themes/dark-monokai.json +2 -21
  41. package/themes/dark-nebula.json +2 -18
  42. package/themes/dark-neon-noir.json +2 -21
  43. package/themes/dark-nord.json +2 -21
  44. package/themes/dark-ocean.json +2 -22
  45. package/themes/dark-one.json +2 -21
  46. package/themes/dark-poimandres.json +4 -41
  47. package/themes/dark-rainforest.json +2 -17
  48. package/themes/dark-reef.json +2 -18
  49. package/themes/dark-retro.json +2 -18
  50. package/themes/dark-rose-pine.json +3 -21
  51. package/themes/dark-sakura.json +2 -18
  52. package/themes/dark-slate.json +2 -18
  53. package/themes/dark-solarized.json +2 -23
  54. package/themes/dark-solstice.json +2 -17
  55. package/themes/dark-starfall.json +2 -17
  56. package/themes/dark-sunset.json +2 -23
  57. package/themes/dark-swamp.json +2 -18
  58. package/themes/dark-synthwave.json +2 -25
  59. package/themes/dark-taiga.json +2 -17
  60. package/themes/dark-terminal.json +2 -18
  61. package/themes/dark-tokyo-night.json +2 -23
  62. package/themes/dark-tundra.json +2 -18
  63. package/themes/dark-twilight.json +2 -17
  64. package/themes/dark-volcanic.json +2 -17
  65. package/themes/dark.json +2 -6
  66. package/themes/graphite.json +2 -21
  67. package/themes/light-arctic.json +2 -27
  68. package/themes/light-aurora-day.json +2 -18
  69. package/themes/light-canyon.json +2 -17
  70. package/themes/light-catppuccin.json +3 -24
  71. package/themes/light-cirrus.json +2 -18
  72. package/themes/light-coral.json +2 -18
  73. package/themes/light-cyberpunk.json +2 -19
  74. package/themes/light-dawn.json +2 -17
  75. package/themes/light-dunes.json +2 -17
  76. package/themes/light-eucalyptus.json +2 -18
  77. package/themes/light-forest.json +3 -24
  78. package/themes/light-frost.json +2 -18
  79. package/themes/light-github.json +3 -39
  80. package/themes/light-glacier.json +2 -17
  81. package/themes/light-gruvbox.json +3 -30
  82. package/themes/light-haze.json +2 -18
  83. package/themes/light-honeycomb.json +2 -18
  84. package/themes/light-lagoon.json +2 -17
  85. package/themes/light-lavender.json +2 -18
  86. package/themes/light-meadow.json +2 -17
  87. package/themes/light-mint.json +2 -18
  88. package/themes/light-monochrome.json +2 -21
  89. package/themes/light-ocean.json +2 -20
  90. package/themes/light-one.json +2 -20
  91. package/themes/light-opal.json +2 -18
  92. package/themes/light-orchard.json +2 -18
  93. package/themes/light-paper.json +2 -18
  94. package/themes/light-poimandres.json +4 -41
  95. package/themes/light-prism.json +2 -19
  96. package/themes/light-retro.json +3 -21
  97. package/themes/light-sand.json +2 -18
  98. package/themes/light-savanna.json +2 -17
  99. package/themes/light-solarized.json +2 -22
  100. package/themes/light-soleil.json +2 -18
  101. package/themes/light-sunset.json +2 -22
  102. package/themes/light-synthwave.json +2 -22
  103. package/themes/light-tokyo-night.json +3 -28
  104. package/themes/light-wetland.json +2 -17
  105. package/themes/light-zenith.json +2 -18
  106. package/themes/light.json +2 -6
  107. package/themes/limestone.json +2 -19
  108. package/themes/mahogany.json +2 -19
  109. package/themes/marble.json +2 -19
  110. package/themes/mirage.json +2 -6
  111. package/themes/obsidian.json +2 -19
  112. package/themes/onyx.json +2 -17
  113. package/themes/pearl.json +2 -21
  114. package/themes/porcelain.json +2 -17
  115. package/themes/quartz.json +2 -19
  116. package/themes/sandstone.json +2 -20
  117. package/themes/titanium.json +2 -17
@@ -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
  });
@@ -410,6 +422,118 @@ describe("plan mode — branch restore", () => {
410
422
  });
411
423
  });
412
424
 
425
+ describe("ask_user_question ask-loop dampener", () => {
426
+ /** ctx whose ui.select answers `answers` in order and counts dialogs shown. */
427
+ function askingCtx(h: ReturnType<typeof createFakePi>, answers: string[]) {
428
+ const shown: string[] = [];
429
+ let i = 0;
430
+ const ctx = h.ctx({
431
+ ui: {
432
+ notify: () => {},
433
+ select: async (question: string) => { shown.push(question); return answers[i++]; },
434
+ editor: async () => undefined,
435
+ setStatus: () => {},
436
+ setEditorText: () => {},
437
+ theme: { fg: (_c: string, t: string) => t },
438
+ },
439
+ });
440
+ return { ctx, shown };
441
+ }
442
+ const ask = (h: ReturnType<typeof createFakePi>, ctx: any, question: string) =>
443
+ h.tools.ask_user_question.execute(`tc-${question}`, { question, options: [{ label: "Send it" }, { label: "Stop" }] }, undefined, undefined, ctx);
444
+ const text = (r: any) => String(r?.content?.[0]?.text ?? "");
445
+
446
+ it("refuses a near-duplicate of an already-answered question", async () => {
447
+ const h = await start();
448
+ const { ctx, shown } = askingCtx(h, ["Send it"]);
449
+ const first = await ask(h, ctx, "Ready to execute the confirmed plan — dispatch the NAK diagnosis to the peer now?");
450
+ assert.equal(text(first), "User selected: Send it", "1st ask shows the dialog");
451
+ // The incident's exact drift: same intent, reworded, shrinking.
452
+ const second = await ask(h, ctx, "Execute: dispatch to peer now?");
453
+ assert.match(text(second), /Loop guard/, "reworded repeat is refused");
454
+ assert.match(text(second), /already asked this and the user answered/, "guard explains why");
455
+ assert.match(text(second), /"Send it"/, "guard hands back the earlier answer");
456
+ assert.equal(shown.length, 1, "the repeat NEVER opened a second dialog");
457
+ assert.equal(second.details.loopGuard, true, "details mark the loop guard");
458
+ });
459
+
460
+ it("genuinely different questions are NOT blocked", async () => {
461
+ const h = await start();
462
+ const { ctx, shown } = askingCtx(h, ["Send it", "Send it", "Send it"]);
463
+ await ask(h, ctx, "Which port profile should the uplink use?");
464
+ await ask(h, ctx, "Which RADIUS secret belongs on the controller?");
465
+ const third = await ask(h, ctx, "How long should the capture run stay armed?");
466
+ assert.equal(text(third), "User selected: Send it", "a distinct question still opens");
467
+ assert.equal(shown.length, 3, "all three dialogs shown");
468
+ });
469
+
470
+ it("same verb, different object is NOT a duplicate (measured at 0.67)", async () => {
471
+ const h = await start();
472
+ const { ctx } = askingCtx(h, ["Go", "Go"]);
473
+ await ask(h, ctx, "Should I restart the radius unit?");
474
+ const second = await ask(h, ctx, "Should I restart the nginx unit?");
475
+ assert.equal(text(second), "User selected: Go", "different target still asks");
476
+ });
477
+
478
+ it("an explicit answer stays reusable while the loop guard holds", async () => {
479
+ const h = await start();
480
+ const { ctx, shown } = askingCtx(h, ["Dispatch now, store memories"]);
481
+ await ask(h, ctx, "Ready to execute — dispatch the NAK diagnosis to the peer now?");
482
+ const again = await ask(h, ctx, "Execute: dispatch to peer now?");
483
+ assert.match(text(again), /Dispatch now, store memories/, "guard hands the exact earlier choice back");
484
+ assert.equal(shown.length, 1, "user is not asked twice");
485
+ });
486
+
487
+ it("the count backstop catches wording drift the similarity arm misses", async () => {
488
+ const h = await start();
489
+ // Four asks that are all DIFFERENT enough to beat the similarity arm, yet a
490
+ // loop by the only wording-independent signal: no tool call in between.
491
+ const { ctx, shown } = askingCtx(h, ["A", "B", "C", "D"]);
492
+ await ask(h, ctx, "Which port profile?");
493
+ await ask(h, ctx, "Which RADIUS secret?");
494
+ await ask(h, ctx, "How long is the capture?");
495
+ assert.equal(shown.length, 3, "three distinct questions are a legitimate flow");
496
+ const fourth = await ask(h, ctx, "Pick a colour for the dashboard?");
497
+ assert.match(text(fourth), /Loop guard/, "4th consecutive ask with no tool call is refused");
498
+ assert.match(text(fourth), /call #4 in a row/, "guard names the run length");
499
+ assert.equal(shown.length, 3, "the 4th ask never opened a dialog");
500
+ });
501
+
502
+ it("any other tool call re-arms the dampener", async () => {
503
+ const h = await start();
504
+ const { ctx, shown } = askingCtx(h, ["Send it", "Send it"]);
505
+ await ask(h, ctx, "Dispatch now?");
506
+ // The model finally does the work instead of asking again.
507
+ await h.fire("tool_call", { toolName: "bash", input: { command: "ls" } }, ctx);
508
+ const after = await ask(h, ctx, "Dispatch now?");
509
+ assert.equal(text(after), "User selected: Send it", "re-armed after another tool call");
510
+ assert.equal(shown.length, 2, "the dialog opened again");
511
+ });
512
+
513
+ it("a fresh session re-arms the dampener", async () => {
514
+ const h = await start();
515
+ const { ctx } = askingCtx(h, ["Send it"]);
516
+ await ask(h, ctx, "Dispatch now?");
517
+ await start(h); // session_start clears the run
518
+ const { ctx: ctx2, shown } = askingCtx(h, ["Send it"]);
519
+ const after = await ask(h, ctx2, "Dispatch now?");
520
+ assert.equal(text(after), "User selected: Send it", "new session asks normally");
521
+ assert.equal(shown.length, 1, "dialog shown in the new session");
522
+ });
523
+
524
+ it("cancelled asks do not count as an answer to reuse", async () => {
525
+ const h = await start();
526
+ // ctx.ui.select returning undefined = user cancelled.
527
+ const cancelledCtx = h.ctx({ ui: { notify: () => {}, select: async () => undefined, editor: async () => undefined, setStatus: () => {}, setEditorText: () => {}, theme: { fg: (_c: string, t: string) => t } } });
528
+ await ask(h, cancelledCtx, "Dispatch now?");
529
+ const { ctx, shown } = askingCtx(h, ["Send it"]);
530
+ const repeat = await ask(h, ctx, "Dispatch now?");
531
+ assert.equal(text(repeat), "User selected: Send it", "no stale answer to hand back — dialog opens");
532
+ assert.equal(shown.length, 1);
533
+ });
534
+ });
535
+
536
+
413
537
  /** Recursively collect file names under dir ([] when missing). */
414
538
  function readSyncRecursive(dir: string, prefix = ""): string[] {
415
539
  if (!existsSync(dir)) return [];
@@ -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 $(date)",
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"]);
@@ -341,12 +341,28 @@ export default function steeringModule(pi: ExtensionAPI): void {
341
341
  settings = readSteeringSettings(ctx); // read per turn — /config saves apply live
342
342
  activeFamily = family(ctx.model);
343
343
 
344
+ // pi 1.2.0 fires before_agent_start for sendMessage(..., { triggerTurn: true })
345
+ // runs too (cron fires, repair auto-bg follow-ups, subagent receipts) and
346
+ // splits the event on `messageType` — `prompt`/`images` exist only on the
347
+ // "user" variant. Older pi has no messageType and fires ONLY for user
348
+ // prompts, so "not custom" is the correct test on every supported version.
349
+ const messageType = (event as { messageType?: string }).messageType;
350
+ const isCustomRun = messageType === "custom";
351
+
344
352
  // ds-anchor bootstrap: request #1 gets the byte-identical Minimal prompt
345
353
  // and NO guidance (Super Power, selection guidance, hints all suppressed).
346
354
  // This handler is LAST in ceulen's chain, so the returned systemPrompt
347
355
  // REPLACES everything ponytail/subagent/advisor composed — deliberate, and
348
356
  // the only place this module clobbers rather than composes.
349
- if (anchorBootstrapping(ctx.model)) {
357
+ //
358
+ // A machine-initiated run must NOT consume the bootstrap: the minimal prompt
359
+ // plus bash/str_replace_editor-only tools would run a cron/background task
360
+ // under DSH minimal mode. The bootstrap stays pending for the next user turn.
361
+ if (isCustomRun && anchorTarget(ctx.model)) {
362
+ // Machine-initiated: never engage the bootstrap (trace once, then the
363
+ // normal composition path below).
364
+ anchorTracePush(`bootstrap skipped: custom-triggered run (promoted=${anchorPromoted})`);
365
+ } else if (anchorBootstrapping(ctx.model)) {
350
366
  scanAnchorEntries(ctx);
351
367
  if (!anchorPromoted) {
352
368
  anchorRunActive = true;
@@ -389,14 +405,17 @@ export default function steeringModule(pi: ExtensionAPI): void {
389
405
  // byte-identical — a per-turn source switch would invalidate the cache head.
390
406
  const selected = event.systemPromptOptions?.selectedTools;
391
407
  const activeForHint: readonly string[] = Array.isArray(selected) && selected.length > 0 ? selected : pi.getActiveTools();
392
- if (settings.firstToolHints && activeForHint.includes("bash")) {
393
- const runHint = runTaskFirstToolHint(event.prompt || "");
408
+ // Hints heuristically read the USER's task text: a custom-triggered run has
409
+ // no prompt, and hinting off a machine message would be noise.
410
+ const runPrompt = !isCustomRun && "prompt" in event ? event.prompt : "";
411
+ if (settings.firstToolHints && !isCustomRun && activeForHint.includes("bash")) {
412
+ const runHint = runTaskFirstToolHint(runPrompt);
394
413
  if (runHint) dynamicParts.push(runHint);
395
- const ghHint = githubCloneFirstToolHint(event.prompt || "");
414
+ const ghHint = githubCloneFirstToolHint(runPrompt);
396
415
  if (ghHint) dynamicParts.push(ghHint);
397
416
  }
398
- if (settings.firstToolHints && activeForHint.includes("find")) {
399
- const readHint = readUncertainPathHint(event.prompt || "");
417
+ if (settings.firstToolHints && !isCustomRun && activeForHint.includes("find")) {
418
+ const readHint = readUncertainPathHint(runPrompt);
400
419
  if (readHint) dynamicParts.push(readHint);
401
420
  }
402
421
 
@@ -90,4 +90,42 @@ describe("ds-anchor regressions", () => {
90
90
  assert.equal(out.max_completion_tokens, 256000, "budget pinned on the field the payload already carries");
91
91
  assert.equal(out.max_tokens, undefined, "conflicting max_tokens dropped");
92
92
  });
93
+
94
+ // pi 1.2.0: before_agent_start also fires for sendMessage({triggerTurn: true})
95
+ // runs (cron fires, auto-bg receipts) with messageType "custom" and NO prompt.
96
+ it("a custom-triggered run does NOT consume the bootstrap; the next user turn still gets it", () => {
97
+ const h = createFakePi();
98
+ h.setEntries([]);
99
+ h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
100
+ // cron-style custom run (no `prompt` field — pi's custom variant)
101
+ const custom = h.fire("before_agent_start", {
102
+ messageType: "custom", message: { customType: "ceulen-cron-fire", content: "job fired" },
103
+ systemPrompt: "FULL PI PROMPT", systemPromptOptions: {},
104
+ }, h.ctx("deepseek-v4-pro"));
105
+ assert.notEqual(custom?.systemPrompt, MINIMAL, "custom run must not get the minimal prompt");
106
+ const out = h.fire("before_provider_request", { payload: { tools: [{ name: "bash" }, { name: "str_replace_editor" }, { name: "edit" }] } }, h.ctx("deepseek-v4-pro"));
107
+ assert.equal(out?.tools, undefined, "custom run keeps the full tool catalog");
108
+ assert.equal(out?.max_tokens, undefined, "custom run gets no budget pin");
109
+ // the bootstrap stayed pending for the next user turn
110
+ const user = h.fire("before_agent_start", { messageType: "user", prompt: "do a task", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
111
+ assert.equal(user?.systemPrompt, MINIMAL, "the next USER turn still bootstraps");
112
+ });
113
+
114
+ it("a custom-triggered run gets no first-tool hints (no prompt to read)", () => {
115
+ const h = createFakePi(["bash", "read", "edit", "grep"]);
116
+ h.setEntries([]);
117
+ h.fire("session_start", {}, h.ctx("deepseek-v4-flash"));
118
+ const custom = h.fire("before_agent_start", {
119
+ messageType: "custom", message: { customType: "ceulen-cron-fire", content: "run the task" },
120
+ systemPrompt: "FULL", systemPromptOptions: {},
121
+ }, h.ctx("deepseek-v4-flash"));
122
+ // The static family guidance still composes; what must NOT appear is the
123
+ // prompt-derived dynamic hint (recognisable by its "Do NOT spawn a task
124
+ // agent" / task-shaped preamble). A user turn with the same text DOES add it.
125
+ const customDynamic = (custom?.systemPrompt ?? "").length;
126
+ const user = h.fire("before_agent_start", { messageType: "user", prompt: "refactor everything in the repo", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-flash"));
127
+ assert.equal(user?.systemPrompt, custom?.systemPrompt, "a custom run adds no dynamic hint");
128
+ assert.ok(String(custom?.systemPrompt ?? "").startsWith("DeepSeek V4"), "static family guidance still composes on custom runs");
129
+ assert.ok(customDynamic > "FULL".length, "static guidance present");
130
+ });
93
131
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ceulen",
3
- "version": "0.17.0",
3
+ "version": "0.19.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.2.0",
56
- "@earendil-works/pi-tui": ">=0.99.1 <1.2.0",
55
+ "@earendil-works/pi-coding-agent": ">=0.99.1 <1.3.0",
56
+ "@earendil-works/pi-tui": ">=0.99.1 <1.3.0",
57
57
  "typebox": "*"
58
58
  },
59
59
  "devDependencies": {
@@ -1,7 +1,13 @@
1
1
  // Validates every themes/*.json loads as a pi theme: name present + unique,
2
2
  // not colliding with pi's builtin names (dark/light/system are preloaded and
3
- // win dedupe), full pi-required color token set (from pi's theme-json schema),
4
- // and every value resolving to a var ref, #RRGGBB, 256-color index, or "".
3
+ // win dedupe), full pi-required color token set, every value resolving to a var
4
+ // ref, #RRGGBB, 256-color index, or "", and NO unknown keys anywhere.
5
+ //
6
+ // pi 1.2.0 (dist/modes/interactive/theme/theme-schema.js) validates themes
7
+ // loaded at startup with `additionalProperties: false` at BOTH the root and
8
+ // `colors` — an unknown key throws, the loader swallows it as a diagnostic, and
9
+ // the theme silently vanishes ("Theme not found: <name>" + system fallback).
10
+ // The ALLOWED/ROOT_KEYS gates below mirror that so `npm test` catches it here.
5
11
  // ponytail: adapted from @bacnh85/pi-themes scripts/validate-themes.mjs (MIT).
6
12
  // Usage: node scripts/validate-themes.mjs [dir] (dir defaults to ./themes)
7
13
  import { readFileSync, readdirSync } from "node:fs";
@@ -30,6 +36,21 @@ const REQUIRED = [
30
36
  "syntaxPunctuation", "thinkingOff", "thinkingMinimal", "thinkingLow",
31
37
  "thinkingMedium", "thinkingHigh", "thinkingXhigh", "bashMode",
32
38
  ];
39
+ // pi 1.2.0's full colors token set (THEME_TOKENS): REQUIRED plus the tokens
40
+ // that are optional because they carry a fallback.
41
+ // Source of truth: node_modules/@earendil-works/pi-coding-agent/dist/modes/
42
+ // interactive/theme/theme-tokens.js (not importable — the package `exports` map
43
+ // blocks deep subpaths). Re-derive on every pi minor bump:
44
+ // node -p "Object.keys(require('<pi>/dist/modes/interactive/theme/theme-tokens.js').THEME_TOKENS)"
45
+ // A token pi ADDS is not a break (an unknown key only fails when we SHIP one);
46
+ // a token pi REMOVES is — this file would then allow a key pi rejects.
47
+ const ALLOWED_COLORS = new Set([
48
+ ...REQUIRED,
49
+ "scrollbarTrack", "scrollbarThumb", "searchMatchBg", "searchMatchText", "thinkingMax",
50
+ ]);
51
+ // pi 1.2.0's root object (additionalProperties: false).
52
+ const ROOT_KEYS = new Set(["$schema", "name", "appearance", "vars", "colors", "export"]);
53
+ const EXPORT_KEYS = new Set(["pageBg", "cardBg", "infoBg"]);
33
54
  const BUILTIN = new Set(["dark", "light", "system"]);
34
55
 
35
56
  let failed = false;
@@ -63,9 +84,16 @@ for (const file of files) {
63
84
  const missing = REQUIRED.filter((k) => !(k in colors));
64
85
  if (missing.length) fail(`missing required tokens: ${missing.join(", ")}`);
65
86
 
87
+ const unknownRoot = Object.keys(theme).filter((k) => !ROOT_KEYS.has(k));
88
+ if (unknownRoot.length) fail(`unknown root keys: ${unknownRoot.join(", ")}`);
89
+ const unknownColors = Object.keys(colors).filter((k) => !ALLOWED_COLORS.has(k));
90
+ if (unknownColors.length) fail(`unknown color tokens: ${unknownColors.join(", ")}`);
91
+ const unknownExport = Object.keys(theme.export ?? {}).filter((k) => !EXPORT_KEYS.has(k));
92
+ if (unknownExport.length) fail(`unknown export keys: ${unknownExport.join(", ")}`);
93
+
66
94
  const vars = new Set(Object.keys(theme.vars ?? {}));
67
95
  const bad = [];
68
- for (const [k, v] of Object.entries({ ...vars.entries && theme.vars, ...colors })) {
96
+ for (const [k, v] of Object.entries({ ...theme.vars, ...colors })) {
69
97
  if (!isColorValue(v, vars)) bad.push(`${k}=${JSON.stringify(v)}`);
70
98
  }
71
99
  if (bad.length) fail(`unresolvable values: ${bad.join(", ")}`);
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "alabaster",
4
4
  "vars": {
5
5
  "alabaster": "#fdfcfb",
@@ -68,22 +68,7 @@
68
68
  "thinkingMedium": "#606870",
69
69
  "thinkingHigh": "#505860",
70
70
  "thinkingXhigh": "#303840",
71
- "bashMode": "#405840",
72
- "statusLineBg": "#ececf0",
73
- "statusLineSep": "#a0a0a8",
74
- "statusLineModel": "#505860",
75
- "statusLinePath": "#404850",
76
- "statusLineGitClean": "#305030",
77
- "statusLineGitDirty": "#806030",
78
- "statusLineContext": "#404860",
79
- "statusLineSpend": "#405050",
80
- "statusLineStaged": 28,
81
- "statusLineDirty": 136,
82
- "statusLineUntracked": 31,
83
- "statusLineOutput": 133,
84
- "statusLineCost": 133,
85
- "statusLineSubagents": "shadowGray",
86
- "pythonMode": "#f0c040"
71
+ "bashMode": "#405840"
87
72
  },
88
73
  "export": {
89
74
  "pageBg": "#fdfcfb",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "amethyst",
4
4
  "vars": {
5
5
  "amethyst": "#b48eff",
@@ -11,7 +11,6 @@
11
11
  "lavender": "#c8a8e9",
12
12
  "crystalFacet": "#2a2435",
13
13
  "caveDark": "#140f18",
14
- "caveDeep": "#0f0b13",
15
14
  "selectedBg": "#221b28",
16
15
  "userMsgBg": "#1a1420",
17
16
  "toolPendingBg": "#1b1624",
@@ -55,7 +54,6 @@
55
54
  "toolDiffAdded": "#8eb897",
56
55
  "toolDiffRemoved": "#d96c75",
57
56
  "toolDiffContext": "#8b7a99",
58
- "link": "violet",
59
57
  "syntaxComment": "#7a6b88",
60
58
  "syntaxKeyword": "amethyst",
61
59
  "syntaxFunction": "gold",
@@ -71,22 +69,7 @@
71
69
  "thinkingMedium": "violet",
72
70
  "thinkingHigh": "amethyst",
73
71
  "thinkingXhigh": "lavender",
74
- "bashMode": "amethyst",
75
- "statusLineBg": "caveDeep",
76
- "statusLineSep": 240,
77
- "statusLineModel": "roseQuartz",
78
- "statusLinePath": "violet",
79
- "statusLineGitClean": "#8eb897",
80
- "statusLineGitDirty": "gold",
81
- "statusLineContext": "lavender",
82
- "statusLineSpend": "deepPurple",
83
- "statusLineStaged": 141,
84
- "statusLineDirty": 179,
85
- "statusLineUntracked": 183,
86
- "statusLineOutput": 213,
87
- "statusLineCost": 213,
88
- "statusLineSubagents": "amethyst",
89
- "pythonMode": "gold"
72
+ "bashMode": "amethyst"
90
73
  },
91
74
  "export": {
92
75
  "pageBg": "caveDark",
@@ -1,17 +1,13 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "anthracite",
4
4
  "vars": {
5
- "coal": "#121419",
6
5
  "steel": "#3d4555",
7
6
  "steelLight": "#4f5566",
8
7
  "ember": "#e8734a",
9
- "emberDim": "#b5583a",
10
- "ash": "#d4d8e4",
11
8
  "ashGray": "#9ca3b5",
12
9
  "soot": "#6b7280",
13
10
  "sootDark": "#4d5561",
14
- "coalLighter": "#1a1e25",
15
11
  "success": "#7fb069",
16
12
  "error": "#d9534f",
17
13
  "warning": "#e89c4a"
@@ -52,7 +48,6 @@
52
48
  "toolDiffAdded": "success",
53
49
  "toolDiffRemoved": "error",
54
50
  "toolDiffContext": "soot",
55
- "link": "#6ba3d4",
56
51
  "syntaxComment": "#6b8099",
57
52
  "syntaxKeyword": "#7ba8d4",
58
53
  "syntaxFunction": "#e8a069",
@@ -68,22 +63,7 @@
68
63
  "thinkingMedium": "#6ba3d4",
69
64
  "thinkingHigh": "#c99a6e",
70
65
  "thinkingXhigh": "#e8b089",
71
- "bashMode": "#6ba3d4",
72
- "statusLineBg": "#0f1114",
73
- "statusLineSep": 240,
74
- "statusLineModel": "#c99a6e",
75
- "statusLinePath": "#6ba3d4",
76
- "statusLineGitClean": "#7fb069",
77
- "statusLineGitDirty": "#e89c4a",
78
- "statusLineContext": "#8791a6",
79
- "statusLineSpend": "#6ba3d4",
80
- "statusLineStaged": 107,
81
- "statusLineDirty": 179,
82
- "statusLineUntracked": 74,
83
- "statusLineOutput": 173,
84
- "statusLineCost": 173,
85
- "statusLineSubagents": "ember",
86
- "pythonMode": "#f0c040"
66
+ "bashMode": "#6ba3d4"
87
67
  },
88
68
  "export": {
89
69
  "pageBg": "#121419",
@@ -1,20 +1,7 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "basalt",
4
- "vars": {
5
- "charcoal": "#171613",
6
- "coolingLava": "#3a3530",
7
- "warmGray": "#4a433d",
8
- "pumice": "#e4e0d8",
9
- "dustyWhite": "#cac5bd",
10
- "ironOxide": "#c45a3a",
11
- "rustOrange": "#d97651",
12
- "mineralGreen": "#6a9a6a",
13
- "lichtenGreen": "#8bb88b",
14
- "obsidian": "#0f0d0b",
15
- "emberRed": "#b84a2c",
16
- "ashGray": "#5a524b"
17
- },
4
+ "vars": {},
18
5
  "colors": {
19
6
  "accent": "#c45a3a",
20
7
  "border": "#3a3530",
@@ -66,22 +53,7 @@
66
53
  "thinkingMedium": "#6a605a",
67
54
  "thinkingHigh": "#7a706a",
68
55
  "thinkingXhigh": "#8a807a",
69
- "bashMode": "#c45a3a",
70
- "statusLineBg": "#0f0d0b",
71
- "statusLineSep": "#3a3530",
72
- "statusLineModel": "#c45a3a",
73
- "statusLinePath": "#cac5bd",
74
- "statusLineGitClean": "#6a9a6a",
75
- "statusLineGitDirty": "#d97651",
76
- "statusLineContext": "#8bb88b",
77
- "statusLineSpend": "#d97651",
78
- "statusLineStaged": "#6a9a6a",
79
- "statusLineDirty": "#d97651",
80
- "statusLineUntracked": "#5a524b",
81
- "statusLineOutput": "#cac5bd",
82
- "statusLineCost": "#d97651",
83
- "statusLineSubagents": "#c45a3a",
84
- "pythonMode": "#f0c040"
56
+ "bashMode": "#c45a3a"
85
57
  },
86
58
  "export": {
87
59
  "pageBg": "#171613",
package/themes/birch.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "birch",
4
4
  "vars": {
5
- "barkCream": "#f9f7f1",
6
5
  "barkCharcoal": "#505048",
7
6
  "mossSage": "#608058",
8
7
  "barkStriation": "#c8c4b8",
@@ -11,7 +10,6 @@
11
10
  "darkMoss": "#4a603f",
12
11
  "warmGray": "#9a958a",
13
12
  "mutedSage": "#8a9d84",
14
- "deepBark": "#3a3832",
15
13
  "selectedBg": "#ede9df",
16
14
  "userMsgBg": "#f2efe7",
17
15
  "toolPendingBg": "#eef0ed",
@@ -70,22 +68,7 @@
70
68
  "thinkingMedium": "mossSage",
71
69
  "thinkingHigh": "#5a7a60",
72
70
  "thinkingXhigh": "#4a6050",
73
- "bashMode": "lightMoss",
74
- "statusLineBg": "#ebe7dc",
75
- "statusLineSep": "barkStriation",
76
- "statusLineModel": "#5a6a5a",
77
- "statusLinePath": "#4a5a60",
78
- "statusLineGitClean": "darkMoss",
79
- "statusLineGitDirty": "#9a7040",
80
- "statusLineContext": "#6a6a70",
81
- "statusLineSpend": "#4a6a6a",
82
- "statusLineStaged": 28,
83
- "statusLineDirty": 136,
84
- "statusLineUntracked": 31,
85
- "statusLineOutput": 133,
86
- "statusLineCost": 133,
87
- "statusLineSubagents": "mossSage",
88
- "pythonMode": "#f0c040"
71
+ "bashMode": "lightMoss"
89
72
  },
90
73
  "export": {
91
74
  "pageBg": "#f9f7f1",
@@ -1,10 +1,7 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
2
+ "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "pi-catppuccin-mocha",
4
4
  "vars": {
5
- "rosewater": "#F5E0DC",
6
- "flamingo": "#F2CDCD",
7
- "pink": "#F5C2E7",
8
5
  "mauve": "#CBA6F7",
9
6
  "red": "#F38BA8",
10
7
  "maroon": "#EBA0AC",
@@ -15,17 +12,14 @@
15
12
  "sky": "#89DCEB",
16
13
  "sapphire": "#74C7EC",
17
14
  "blue": "#89B4FA",
18
- "lavender": "#B4BEFE",
19
15
  "text": "#CDD6F4",
20
16
  "subtext1": "#BAC2DE",
21
17
  "subtext0": "#A6ADC8",
22
18
  "overlay2": "#9399B2",
23
19
  "overlay1": "#7F849C",
24
20
  "overlay0": "#6C7086",
25
- "surface2": "#585B70",
26
21
  "surface1": "#45475A",
27
22
  "surface0": "#313244",
28
- "base": "#1E1E2E",
29
23
  "mantle": "#181825",
30
24
  "crust": "#11111B",
31
25
  "exportInfoTint": "#242031"