ceulen 0.10.1 → 0.11.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 +56 -0
- package/README.md +56 -1
- package/extensions/lib/plan-bridge.ts +18 -0
- package/extensions/lib/registry.ts +14 -0
- package/extensions/modules/a2a/index.ts +4 -2
- package/extensions/modules/attachments/configPanel.ts +91 -0
- package/extensions/modules/attachments/index.ts +274 -0
- package/extensions/modules/attachments/lib/clipboard-files.ts +80 -0
- package/extensions/modules/attachments/lib/pastes.ts +45 -0
- package/extensions/modules/attachments/lib/paths.ts +74 -0
- package/extensions/modules/attachments/lib/registry.ts +70 -0
- package/extensions/modules/attachments/lib/settings.ts +99 -0
- package/extensions/modules/attachments/lib/tray.ts +74 -0
- package/extensions/modules/attachments/test/configPanel.test.ts +122 -0
- package/extensions/modules/attachments/test/index.test.ts +870 -0
- package/extensions/modules/attachments/test/module.test.ts +53 -0
- package/extensions/modules/composer/test/module.test.ts +2 -2
- package/extensions/modules/config/index.ts +3 -0
- package/extensions/modules/config/test/renderTools.test.ts +1 -1
- package/extensions/modules/cron/configPanel.ts +103 -0
- package/extensions/modules/cron/index.ts +638 -0
- package/extensions/modules/cron/lib/jobs.ts +201 -0
- package/extensions/modules/cron/lib/schedule.ts +161 -0
- package/extensions/modules/cron/test/cwd-repro.test.ts +98 -0
- package/extensions/modules/cron/test/index.test.ts +859 -0
- package/extensions/modules/cron/test/schedule.test.ts +93 -0
- package/extensions/modules/munin/index.ts +3 -1
- package/extensions/modules/permission/index.ts +567 -0
- package/extensions/modules/permission/test/permission.test.ts +789 -0
- package/extensions/modules/plan/index.ts +5 -0
- package/extensions/modules/repair/index.ts +134 -3
- package/extensions/modules/repair/test/freshness.test.ts +169 -0
- package/extensions/modules/subagent/index.ts +38 -5
- package/extensions/modules/subagent/lib/runner.ts +348 -12
- package/extensions/modules/subagent/test/worktree.test.ts +230 -0
- package/extensions/modules/usage/index.ts +193 -71
- package/extensions/modules/usage/test/context.test.ts +160 -120
- package/extensions/modules/web/index.ts +3 -1
- package/extensions/modules/web/test/a11y.test.ts +1 -1
- package/package.json +2 -2
- package/skills/cron/SKILL.md +58 -0
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import {
|
|
4
|
+
buildCtxLegend,
|
|
4
5
|
computeContextBreakdown,
|
|
5
6
|
shortSource,
|
|
6
7
|
formatCtxTokens,
|
|
7
8
|
formatCtxPercent,
|
|
8
|
-
|
|
9
|
+
planCtxCells,
|
|
10
|
+
CTX_GRID_COLS,
|
|
11
|
+
CTX_GRID_ROWS,
|
|
9
12
|
renderContextPanel,
|
|
10
13
|
resolveReserveTokens,
|
|
11
14
|
type ContextBreakdownInput,
|
|
12
15
|
} from "../index.ts";
|
|
13
16
|
|
|
17
|
+
/** OMP messages glyph (⛃) — kept here so the assertion reads cleanly. */
|
|
18
|
+
const WAFFLE_MESSAGES_GLYPH = "⛃";
|
|
19
|
+
|
|
14
20
|
/** Fixture ctx with a structured system-prompt system message + tools. */
|
|
15
21
|
function fixtureCtx(overrides: Partial<ContextBreakdownInput["ctx"]> = {}): ContextBreakdownInput["ctx"] {
|
|
16
22
|
const systemSections: Record<string, string | null> = {
|
|
@@ -66,30 +72,66 @@ test("formatCtxPercent slivers and normal cases", () => {
|
|
|
66
72
|
assert.equal(formatCtxPercent(500, 0), "?");
|
|
67
73
|
});
|
|
68
74
|
|
|
69
|
-
test("
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
assert.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
assert.
|
|
75
|
+
test("planCtxCells paints OMP's 20x10 grid with per-category colors", () => {
|
|
76
|
+
const b = computeContextBreakdown(fixtureInput());
|
|
77
|
+
const cells = planCtxCells(b.categories, b.contextWindow);
|
|
78
|
+
assert.equal(cells.length, CTX_GRID_COLS * CTX_GRID_ROWS, "exactly 200 cells");
|
|
79
|
+
// Category color map (OMP's): prompt accent, tools warning, context
|
|
80
|
+
// customMessageLabel, skills success, messages userMessageText, free dim,
|
|
81
|
+
// buffer warning.
|
|
82
|
+
const byColor = new Map<string, number>();
|
|
83
|
+
for (const c of cells) byColor.set(c.color, (byColor.get(c.color) ?? 0) + 1);
|
|
84
|
+
assert.ok((byColor.get("accent") ?? 0) >= 1, "system prompt painted accent");
|
|
85
|
+
assert.ok((byColor.get("warning") ?? 0) >= 2, "tools + buffer painted warning");
|
|
86
|
+
assert.ok((byColor.get("success") ?? 0) >= 1, "skills painted success");
|
|
87
|
+
assert.ok((byColor.get("userMessageText") ?? 0) >= 1, "messages painted userMessageText");
|
|
88
|
+
assert.ok((byColor.get("customMessageLabel") ?? 0) >= 1, "system context painted customMessageLabel");
|
|
89
|
+
assert.ok((byColor.get("dim") ?? 0) > 100, "most of a 2.5%-used window is free (dim)");
|
|
90
|
+
// Glyphs follow the map: buffer hatches the tail, free fills the rest.
|
|
91
|
+
assert.equal(cells.at(-1)!.glyph, "⛝", "autocompact buffer is the final slice");
|
|
92
|
+
assert.ok(cells.some((c) => c.color === "dim" && c.glyph === "⛶"), "free cells render ⛶ dim");
|
|
80
93
|
});
|
|
81
94
|
|
|
82
|
-
test("
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
test("planCtxCells allocation: min one cell, exact fill, disabled compaction has no buffer", () => {
|
|
96
|
+
// A tiny nonzero category keeps one visible cell; zero categories get none.
|
|
97
|
+
const tiny = planCtxCells(
|
|
98
|
+
[
|
|
99
|
+
{ label: "Skills", tokens: 10 },
|
|
100
|
+
{ label: "Messages", tokens: 0 },
|
|
101
|
+
{ label: "Free space", tokens: 99990 },
|
|
102
|
+
],
|
|
103
|
+
100000,
|
|
104
|
+
);
|
|
105
|
+
assert.equal(tiny.filter((c) => c.color === "success").length, 1, "tiny nonzero slice keeps one cell");
|
|
106
|
+
assert.equal(tiny.filter((c) => c.color === "userMessageText").length, 0, "zero slice renders no cells");
|
|
107
|
+
assert.equal(tiny.length, 200);
|
|
108
|
+
|
|
109
|
+
// Disabled compaction: no buffer category → no hatch cells anywhere.
|
|
110
|
+
const b = computeContextBreakdown(fixtureInput({ settings: { compaction: { enabled: false } } }));
|
|
111
|
+
const noBuffer = planCtxCells(b.categories, b.contextWindow);
|
|
112
|
+
assert.ok(noBuffer.every((c) => c.glyph !== "⛝"), "no buffer cells when compaction is off");
|
|
113
|
+
|
|
91
114
|
// Unknown window → all free.
|
|
92
|
-
|
|
115
|
+
const unknown = planCtxCells([{ label: "Skills", tokens: 5 }], 0);
|
|
116
|
+
assert.ok(unknown.every((c) => c.glyph === "⛶" && c.color === "dim"));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("planCtxCells overflow trims largest-first and still fills the canvas", () => {
|
|
120
|
+
// Categories summing far beyond the window: trim keeps every slice ≥1 cell
|
|
121
|
+
// and the grid exactly full (no phantom overflow rows).
|
|
122
|
+
const cells = planCtxCells(
|
|
123
|
+
[
|
|
124
|
+
{ label: "System prompt", tokens: 5000 },
|
|
125
|
+
{ label: "System tools", tokens: 5000 },
|
|
126
|
+
{ label: "Messages", tokens: 5000 },
|
|
127
|
+
{ label: "Free space", tokens: 5000 },
|
|
128
|
+
],
|
|
129
|
+
4000,
|
|
130
|
+
);
|
|
131
|
+
assert.equal(cells.length, 200);
|
|
132
|
+
const counts = new Map<string, number>();
|
|
133
|
+
for (const c of cells) counts.set(c.color, (counts.get(c.color) ?? 0) + 1);
|
|
134
|
+
assert.ok((counts.get("accent") ?? 0) >= 1 && (counts.get("warning") ?? 0) >= 1 && (counts.get("userMessageText") ?? 0) >= 1, "each filled category keeps ≥1 cell after trim");
|
|
93
135
|
});
|
|
94
136
|
|
|
95
137
|
test("resolveReserveTokens mirrors pi's resolution order", () => {
|
|
@@ -187,24 +229,39 @@ test("computeContextBreakdown tolerates a throwing projection and missing usage"
|
|
|
187
229
|
assert.equal(b.freeSpace, Math.max(0, 200000 - (10000 + b.tools.total) - 16384));
|
|
188
230
|
});
|
|
189
231
|
|
|
190
|
-
test("renderContextPanel
|
|
232
|
+
test("renderContextPanel lays the legend beside a 20x10 grid (OMP geometry)", () => {
|
|
233
|
+
const b = computeContextBreakdown(fixtureInput({ model: { provider: "zai", id: "glm-5.3", name: "GLM-5.3", maxTokens: 8192, contextWindow: 200000 } }));
|
|
234
|
+
const lines = renderContextPanel(b);
|
|
235
|
+
assert.equal(lines[0], "Context Usage");
|
|
236
|
+
// Grid body: 10 rows of 20 space-joined cells, gutter, legend text.
|
|
237
|
+
const gridRows = lines.filter((l) => l.split(" ").length >= 20 && /^⛁|^⛶/.test(l));
|
|
238
|
+
assert.equal(gridRows.length, CTX_GRID_ROWS, "ten grid rows");
|
|
239
|
+
const first = lines.find((l) => l.includes("GLM-5.3")) ?? lines[3];
|
|
240
|
+
const gridPart = first.split(" ")[0];
|
|
241
|
+
assert.equal(gridPart.split(" ").filter(Boolean).length, CTX_GRID_COLS, "20 cells per row");
|
|
242
|
+
// Legend header rows ride beside the grid.
|
|
243
|
+
assert.ok(lines.some((l) => l.includes("GLM-5.3") && l.includes("200K context")), lines.join("\n"));
|
|
244
|
+
assert.ok(lines.some((l) => l.includes("[200K]")), "bracketed model id row");
|
|
245
|
+
assert.ok(lines.some((l) => l.includes("5.0K/200K tokens (2.5%)")), lines.join("\n"));
|
|
246
|
+
assert.ok(lines.some((l) => l.includes("Estimated usage by category")));
|
|
247
|
+
// Category legend lines: glyph + label + tokens + pct, one per category.
|
|
248
|
+
assert.ok(lines.some((l) => l.includes("⛁ System prompt:")), lines.join("\n"));
|
|
249
|
+
assert.ok(lines.some((l) => l.includes("⛁ System tools:")));
|
|
250
|
+
assert.ok(lines.some((l) => l.includes("⛁ System context:")));
|
|
251
|
+
assert.ok(lines.some((l) => l.includes("⛁ Skills:")));
|
|
252
|
+
assert.ok(lines.some((l) => l.includes("⛃ Messages:")));
|
|
253
|
+
assert.ok(lines.some((l) => l.includes("⛶ Free space:")));
|
|
254
|
+
assert.ok(lines.some((l) => l.includes("⛝ Autocompact buffer:")));
|
|
255
|
+
// Gutter alignment: legend lines start after the 39-char grid + 3-space gutter.
|
|
256
|
+
const cat = lines.find((l) => l.includes("⛁ System prompt:"))!;
|
|
257
|
+
assert.ok(/^[⛁⛶⛝ ]+ ⛁ System prompt:/.test(cat), cat);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("renderContextPanel fires recommendations above thresholds", () => {
|
|
191
261
|
// Tiny-ish window so the 516-token tool fixture crosses the 40% recommendation threshold.
|
|
192
262
|
const b = computeContextBreakdown(fixtureInput({ ctx: fixtureCtx(), model: { maxTokens: 8192, contextWindow: 1200 } }));
|
|
193
263
|
const lines = renderContextPanel(b);
|
|
194
|
-
assert.equal(lines[0], "Context Usage");
|
|
195
|
-
// Header: 4 waffle rows (10 cells each) with model info on the right.
|
|
196
|
-
const gridRows = lines.slice(2, 6);
|
|
197
|
-
assert.ok(gridRows.every((l) => /^[⛁⛶⛝]{10}/.test(l)), gridRows.join("|"));
|
|
198
264
|
assert.ok(lines.some((l) => l.includes("5.0K/1.2K tokens (416.7%)")), lines.join("\n"));
|
|
199
|
-
// Disjoint, glyph-prefixed category block (core prompt excludes context + skills).
|
|
200
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ System prompt:")), lines.join("\n"));
|
|
201
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ System tools:")));
|
|
202
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ System context:")));
|
|
203
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ Skills:")));
|
|
204
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ Messages:")));
|
|
205
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛶ Free space:")));
|
|
206
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛝ Autocompact buffer:")));
|
|
207
|
-
// Detail lists.
|
|
208
265
|
assert.ok(lines.some((l) => l.includes("pi-web:")), lines.join("\n"));
|
|
209
266
|
assert.ok(!lines.some((l) => l.includes("@bacnh85/")), "package labels are shortened");
|
|
210
267
|
assert.ok(lines.some((l) => l.includes("project_context: 2.0K")));
|
|
@@ -226,56 +283,32 @@ test("renderContextPanel fires memory + skills recommendations above thresholds"
|
|
|
226
283
|
assert.ok(lines.some((l) => l.includes("disable-model-invocation")));
|
|
227
284
|
});
|
|
228
285
|
|
|
229
|
-
test("
|
|
230
|
-
const {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
assert.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// TUI: panel posted as a displayable transcript message carrying the lines.
|
|
258
|
-
await handler!("", mkCtx("tui"));
|
|
259
|
-
assert.equal(sent.length, 1);
|
|
260
|
-
assert.equal(sent[0].customType, "ceulen-usage-context");
|
|
261
|
-
assert.equal(sent[0].display, true, "message is displayed in the transcript");
|
|
262
|
-
const lines = sent[0].details?.lines ?? [];
|
|
263
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛁ System prompt:")), lines.join("\n"));
|
|
264
|
-
assert.ok(lines.some((l) => l.startsWith(" ⛶ Free space:")));
|
|
265
|
-
|
|
266
|
-
// Renderer: colors the glyph, keeps the body plain, and clamps to width.
|
|
267
|
-
const comp = renderers["ceulen-usage-context"]!({ details: { lines: [" ⛁ System prompt: 1K tokens (1.0%)"] } }, {}, { fg: (c: string, s: string) => `<${c}>${s}</>` });
|
|
268
|
-
const out = comp!.render(200);
|
|
269
|
-
assert.ok(out[0].includes("<accent>⛁</>"), out[0]);
|
|
270
|
-
assert.ok(out[0].includes("System prompt: 1K tokens"), out[0]);
|
|
271
|
-
// Width clamp applies to the source line (before ANSI codes are added).
|
|
272
|
-
const narrow = comp!.render(10);
|
|
273
|
-
assert.ok(narrow[0].includes("⛁"), "glyph survives the clamp");
|
|
274
|
-
assert.ok(!narrow[0].includes("System prompt"), "body beyond the width is dropped");
|
|
275
|
-
|
|
276
|
-
// Plain-text content always rides along as the renderer-less fallback.
|
|
277
|
-
assert.ok(sent[0].content.includes("Context Usage"), "content carries a plain-text fallback");
|
|
278
|
-
assert.ok(sent[0].content.includes("⛁ System prompt:"), sent[0].content);
|
|
286
|
+
test("buildCtxLegend mirrors OMP's run structure and colors", () => {
|
|
287
|
+
const b = computeContextBreakdown(fixtureInput({ model: { provider: "zai", id: "glm-5.3-flash", name: "GLM-5.3 Flash", maxTokens: 8192, contextWindow: 1_000_000 } }));
|
|
288
|
+
const legend = buildCtxLegend(b);
|
|
289
|
+
// Line 1: model name strong + window dim. Line 2: bare id[window] muted.
|
|
290
|
+
assert.deepEqual(legend[0], [
|
|
291
|
+
{ t: "GLM-5.3 Flash", s: "strong" },
|
|
292
|
+
{ t: " (1m context)", s: "dim" },
|
|
293
|
+
]);
|
|
294
|
+
assert.deepEqual(legend[1], [{ t: "glm-5.3-flash[1m]", s: "muted" }]);
|
|
295
|
+
// Line 3: used strong, window dim, pct muted.
|
|
296
|
+
assert.deepEqual(legend[2], [
|
|
297
|
+
{ t: "5.0K", s: "strong" },
|
|
298
|
+
{ t: "/1m tokens", s: "dim" },
|
|
299
|
+
{ t: " (0.5%)", s: "muted" },
|
|
300
|
+
]);
|
|
301
|
+
assert.deepEqual(legend[3], []);
|
|
302
|
+
assert.deepEqual(legend[4], [{ t: "Estimated usage by category", s: "muted" }]);
|
|
303
|
+
// Category lines: colored glyph, strong tokens, dim pct.
|
|
304
|
+
const prompt = legend.find((l) => l.some((p) => p.t === " System prompt: "))!;
|
|
305
|
+
assert.equal(prompt[0].s, "accent");
|
|
306
|
+
assert.ok(prompt.some((p) => p.s === "strong"), "token count is bold");
|
|
307
|
+
const msgs = legend.find((l) => l.some((p) => p.t.includes("Messages")) && l.some((p) => p.t === WAFFLE_MESSAGES_GLYPH));
|
|
308
|
+
assert.equal(msgs?.[0].s, "userMessageText");
|
|
309
|
+
// No model → no header rows, legend still renders.
|
|
310
|
+
const bare = buildCtxLegend({ ...b, modelName: undefined, modelLabel: undefined });
|
|
311
|
+
assert.ok(bare[0].some((p) => p.t.includes("tokens")), "first line is the totals without a model");
|
|
279
312
|
});
|
|
280
313
|
|
|
281
314
|
test("categories are disjoint, reconcile with usage, and partition the window", () => {
|
|
@@ -313,17 +346,18 @@ test("Messages is a residual so no row exceeds the headline total", () => {
|
|
|
313
346
|
assert.equal(over.categories.reduce((a, c) => a + c.tokens, 0), 200000);
|
|
314
347
|
});
|
|
315
348
|
|
|
316
|
-
test("/context handler posts
|
|
349
|
+
test("/context handler posts v2 grid+legend; renderer paints live theme; legacy lines still render", async () => {
|
|
317
350
|
const { default: extension } = await import("../index.ts");
|
|
318
351
|
const commands: Record<string, { handler: (args: string, ctx: unknown) => Promise<void> }> = {};
|
|
319
352
|
const renderers: Record<string, (m: unknown, o: unknown, t: unknown) => { render(w: number): string[] } | undefined> = {};
|
|
320
|
-
|
|
353
|
+
type SentMsg = { customType: string; content: string; display?: boolean; details?: { grid?: unknown[][]; legend?: unknown[][]; lines?: string[] } };
|
|
354
|
+
const sent: SentMsg[] = [];
|
|
321
355
|
const fakePi = {
|
|
322
356
|
on: () => {},
|
|
323
357
|
registerCommand: (name: string, def: { handler: (args: string, ctx: unknown) => Promise<void> }) => { commands[name] = def; },
|
|
324
358
|
registerTool: () => {},
|
|
325
359
|
registerMessageRenderer: (type: string, renderer: never) => { renderers[type] = renderer; },
|
|
326
|
-
sendMessage: (msg:
|
|
360
|
+
sendMessage: (msg: SentMsg) => { sent.push(msg); },
|
|
327
361
|
getAllTools: () => (fixtureCtx() as never as { getAllTools(): unknown[] }).getAllTools(),
|
|
328
362
|
getActiveTools: () => ["read", "web_search"],
|
|
329
363
|
};
|
|
@@ -332,50 +366,56 @@ test("/context handler posts a transcript message; renderer tints glyphs", async
|
|
|
332
366
|
assert.ok(handler, "/context registered");
|
|
333
367
|
assert.ok(renderers["ceulen-usage-context"], "transcript renderer registered");
|
|
334
368
|
|
|
335
|
-
const mkCtx = (
|
|
336
|
-
mode,
|
|
337
|
-
model: { maxTokens: 8192, contextWindow: 200000 },
|
|
369
|
+
const mkCtx = () => ({
|
|
370
|
+
mode: "tui",
|
|
371
|
+
model: { provider: "zai", id: "glm-5.3", name: "GLM-5.3", maxTokens: 8192, contextWindow: 200000 },
|
|
338
372
|
getContextUsage: () => ({ tokens: 5000, contextWindow: 200000, percent: 2.5 }),
|
|
339
373
|
getSystemPrompt: () => "x".repeat(40000),
|
|
340
374
|
sessionManager: { buildSessionProjection: () => ({ messages: [] }) },
|
|
341
375
|
ui: { notify: () => {}, theme: { fg: (_c: string, s: string) => s } },
|
|
342
376
|
});
|
|
343
377
|
|
|
344
|
-
// TUI: panel posted as a displayable transcript message carrying
|
|
345
|
-
await handler!("", mkCtx(
|
|
378
|
+
// TUI: panel posted as a displayable transcript message carrying v2 details.
|
|
379
|
+
await handler!("", mkCtx());
|
|
346
380
|
assert.equal(sent.length, 1);
|
|
347
381
|
assert.equal(sent[0].customType, "ceulen-usage-context");
|
|
348
382
|
assert.equal(sent[0].display, true, "message is displayed in the transcript");
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
assert.ok(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const out = comp!.render(200);
|
|
356
|
-
assert.ok(out[0].includes("<accent>⛁</>"), out[0]);
|
|
357
|
-
assert.ok(out[0].includes("System prompt: 1K tokens"), out[0]);
|
|
358
|
-
// Width clamp applies to the source line (before ANSI codes are added).
|
|
359
|
-
const narrow = comp!.render(10);
|
|
360
|
-
assert.ok(narrow[0].includes("⛁"), "glyph survives the clamp");
|
|
361
|
-
assert.ok(!narrow[0].includes("System prompt"), "body beyond the width is dropped");
|
|
362
|
-
|
|
383
|
+
const grid = sent[0].details?.grid as Array<Array<{ glyph: string; color: string }>> | undefined;
|
|
384
|
+
const legend = sent[0].details?.legend as Array<Array<{ t: string; s?: string }>> | undefined;
|
|
385
|
+
assert.ok(Array.isArray(grid) && grid.length === CTX_GRID_ROWS, "details.grid is 10 rows");
|
|
386
|
+
assert.ok(grid!.every((row) => row.length === CTX_GRID_COLS), "every row has 20 cells");
|
|
387
|
+
assert.ok(Array.isArray(legend) && legend.length >= 8, "details.legend carries the full legend");
|
|
388
|
+
assert.ok(legend![0].some((p) => p.t === "GLM-5.3" && p.s === "strong"), "legend header is styled");
|
|
363
389
|
// Plain-text content always rides along as the renderer-less fallback.
|
|
364
390
|
assert.ok(sent[0].content.includes("Context Usage"), "content carries a plain-text fallback");
|
|
365
391
|
assert.ok(sent[0].content.includes("⛁ System prompt:"), sent[0].content);
|
|
366
|
-
});
|
|
367
392
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
assert.
|
|
375
|
-
|
|
376
|
-
assert.
|
|
377
|
-
|
|
378
|
-
assert.
|
|
393
|
+
// v2 renderer: paints cell colors + legend runs from the live theme, clamps.
|
|
394
|
+
// Real ANSI wrappers (like pi's theme) so visible-width assertions exercise the actual measure.
|
|
395
|
+
const theme = { fg: (c: string, s: string) => `\u001b[38;5;${c.length}m${s}\u001b[0m`, bold: (s: string) => `\u001b[1m${s}\u001b[0m` };
|
|
396
|
+
const comp = renderers["ceulen-usage-context"]!({ details: { grid, legend } }, {}, theme);
|
|
397
|
+
const out = comp!.render(400);
|
|
398
|
+
assert.ok(out[0].includes("\u001b[38;5;6m⛁"), `grid cell painted: ${out[0].slice(0, 80)}`);
|
|
399
|
+
assert.ok(out[0].includes("\u001b[1mGLM-5.3\u001b[0m"), "legend header bolded");
|
|
400
|
+
assert.ok(out.some((l) => l.includes("\u001b[38;5;3m⛶")), "free cells dim");
|
|
401
|
+
assert.ok(out.some((l) => l.includes("\u001b[38;5;7m⛝")), "buffer cells warning");
|
|
402
|
+
const cat = out.find((l) => l.includes("System prompt:"))!;
|
|
403
|
+
assert.ok(cat.includes("\u001b[38;5;6m⛁"), "legend glyph painted with its category color");
|
|
404
|
+
// Narrow width: clamp applies (display clamp, not data loss).
|
|
405
|
+
const narrow = comp!.render(30);
|
|
406
|
+
const visible = (l: string) => [...l.replace(/\u001b\[[0-9;]*m/g, "")].length;
|
|
407
|
+
assert.ok(narrow.every((l) => visible(l) <= 30), "rows clamp to the visible width");
|
|
408
|
+
// Regression: escape-code inflation once shredded the grid to ~7 cells at any width.
|
|
409
|
+
assert.ok(visible(out[0]) >= 50, "grid + legend header fit at width 400");
|
|
410
|
+
|
|
411
|
+
// Legacy details.lines (old transcripts) keep the glyph-tint path.
|
|
412
|
+
const legacy = renderers["ceulen-usage-context"]!({ details: { lines: [" ⛁ System prompt: 1K tokens (1.0%)"] } }, {}, theme);
|
|
413
|
+
const legacyOut = legacy!.render(200);
|
|
414
|
+
assert.ok(legacyOut[0].includes("\u001b[38;5;6m⛁"), legacyOut[0]);
|
|
415
|
+
assert.ok(legacyOut[0].includes("System prompt: 1K tokens"), legacyOut[0]);
|
|
416
|
+
const legacyNarrow = legacy!.render(10);
|
|
417
|
+
assert.ok(legacyNarrow[0].includes("⛁"), "glyph survives the clamp");
|
|
418
|
+
assert.ok(!legacyNarrow[0].includes("System prompt"), "body beyond the width is dropped");
|
|
379
419
|
});
|
|
380
420
|
|
|
381
421
|
test("shortSource reduces local paths and scoped specs to a short label", () => {
|
|
@@ -166,7 +166,9 @@ export default function piWebExtension(pi: ExtensionAPI) {
|
|
|
166
166
|
// package.json `pi.skills` manifest — so the kill-switch gates it too:
|
|
167
167
|
// disabled module ⇒ factory never runs ⇒ no web skill registered.
|
|
168
168
|
pi.on("resources_discover", () => ({
|
|
169
|
-
|
|
169
|
+
// skillsRoot() is already a native absolute path (fileURLToPath) — no
|
|
170
|
+
// realpath needed; a throw here would kill the whole module load.
|
|
171
|
+
skillPaths: [path.join(skillsRoot(), "web")],
|
|
170
172
|
}));
|
|
171
173
|
|
|
172
174
|
// Per-tool kill-switch (ceulen.disabledTools): listed tools register
|
|
@@ -105,7 +105,7 @@ describe("axeSource", () => {
|
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
describe("runner expression (via fake CDP server)", () => {
|
|
108
|
+
describe("runner expression (via fake CDP server)", { skip: process.platform === "linux" && !process.env.CHROME_PATH && "CI runners have no Chrome — launchCdp always spawns a real browser (the wsFactory only fakes the WS protocol)" }, () => {
|
|
109
109
|
it("bootstraps axe then runs it, returning the normalized report", async () => {
|
|
110
110
|
const evals: string[] = [];
|
|
111
111
|
const ws = new FakeWs();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ceulen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"homepage": "https://github.com/ceulen-dev/ceulen#readme",
|
|
41
41
|
"bugs": "https://github.com/ceulen-dev/ceulen/issues",
|
|
42
42
|
"scripts": {
|
|
43
|
-
"test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/lib/registry.test.ts extensions/lib/skill-path.test.ts extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/todo/test/*.test.ts extensions/modules/web/test/*.test.ts extensions/modules/rules/test/*.test.ts extensions/modules/a2a/test/*.test.ts extensions/modules/gh/test/*.test.ts",
|
|
43
|
+
"test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/lib/registry.test.ts extensions/lib/skill-path.test.ts extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/todo/test/*.test.ts extensions/modules/web/test/*.test.ts extensions/modules/rules/test/*.test.ts extensions/modules/a2a/test/*.test.ts extensions/modules/gh/test/*.test.ts extensions/modules/attachments/test/*.test.ts extensions/modules/cron/test/*.test.ts extensions/modules/permission/test/*.test.ts",
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"pi": {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cron
|
|
3
|
+
description: Use when the user wants scheduled, recurring, or periodic tasks in Pi — cron jobs, reminders, jobs at a specific time ("every morning at 9", "weekly monday", "in 30 minutes"), or automation that should run without being asked each time.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cron — scheduled jobs
|
|
7
|
+
|
|
8
|
+
Jobs fire a prompt **into the live session** while pi is running. Past-due jobs
|
|
9
|
+
catch up once on the next tick (~30s). Storage: `<agentDir>/cron/jobs.json`.
|
|
10
|
+
|
|
11
|
+
## Creating jobs
|
|
12
|
+
|
|
13
|
+
1. Convert the user's natural language to a **5-field cron expression**.
|
|
14
|
+
2. Verify it with `cron action:"test" schedule:"..."` — check the next 5 fire times.
|
|
15
|
+
3. Add it: `cron action:"add" name:"<short-name>" schedule:"..." prompt:"..."`.
|
|
16
|
+
|
|
17
|
+
Cheatsheet: `minute hour day-of-month month day-of-week`
|
|
18
|
+
|
|
19
|
+
- `0 9 * * mon` — Mondays 09:00
|
|
20
|
+
- `*/30 * * * *` — every 30 minutes
|
|
21
|
+
- `0 9 1 * *` — first of the month, 09:00
|
|
22
|
+
- `30 8 * * 1-5` — weekdays 08:30
|
|
23
|
+
|
|
24
|
+
Names: letters/digits/`_`/`.`/`-`, max 64 chars. Cap: 20 jobs.
|
|
25
|
+
|
|
26
|
+
## Job prompts
|
|
27
|
+
|
|
28
|
+
The prompt becomes a **standalone turn** — no conversation context. Write it
|
|
29
|
+
self-contained and short: what to do, where, and what to report. Bad: `"check
|
|
30
|
+
it again"`; good: `"Run npm test in this repo and summarize failures"`.
|
|
31
|
+
|
|
32
|
+
**Loop guard:** for 30s after a fire, `add`, `remove`, `run`, `enable`, and
|
|
33
|
+
`disable` are refused. A fired turn running longer than 30s can still mutate —
|
|
34
|
+
never write job prompts that schedule further jobs.
|
|
35
|
+
|
|
36
|
+
**Working directory:** unpinned jobs deliver only into a session whose cwd
|
|
37
|
+
matches the job's `cwd`; a foreign-cwd session marks the fire
|
|
38
|
+
`[FAIL: cwd mismatch …]`. Pin `model`/`thinking` for cross-cwd reliability
|
|
39
|
+
(pinned jobs run headless in `job.cwd`).
|
|
40
|
+
|
|
41
|
+
## Managing
|
|
42
|
+
|
|
43
|
+
- `cron action:"list"` — name, schedule, next/last fire, enabled.
|
|
44
|
+
- `cron action:"run" name:"..."` — manual fire (result arrives as a follow-up turn).
|
|
45
|
+
- `cron action:"disable" name:"..."` — pause a job (schedule kept; skipped by ticks and export).
|
|
46
|
+
- `cron action:"enable" name:"..."` — resume; the next fire is recomputed from now (no surprise catch-up fire).
|
|
47
|
+
- `cron action:"add" ... enabled:false` — create the job already disabled.
|
|
48
|
+
- `cron action:"remove" name:"..."`.
|
|
49
|
+
- `cron action:"export"` — crontab lines for 24/7 coverage while pi is closed;
|
|
50
|
+
hand the block to the user to install (`crontab -l | cat - cron.txt | crontab -`).
|
|
51
|
+
Exported lines run headless `pi -p --no-session` and log under `<agentDir>/cron/logs/`.
|
|
52
|
+
|
|
53
|
+
## Config
|
|
54
|
+
|
|
55
|
+
`settings.json` → `"cron": { "enabled": true, "tickMs": 30000 }` (global kill
|
|
56
|
+
switch + tick interval). `timeoutMs` caps headless (pinned) child runs
|
|
57
|
+
(SIGTERM at the cap, SIGKILL after a 5s grace; clamped 1min–24h, default
|
|
58
|
+
10min) — raise it for long pinned jobs.
|