ceulen 0.10.0 → 0.10.1

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.
@@ -119,28 +119,28 @@ describe("composed screen through the real TUI renderer", () => {
119
119
  assert.ok(compose(editor("rail")).out.includes("▎"), "rail glyph");
120
120
  });
121
121
 
122
- it("band carries the stock status on screen: icons on every segment, context right-justified", () => {
122
+ it("band carries the stock status on screen: icons on every segment, gauge with the context figure", () => {
123
123
  // At the default 60 cols the band keeps brand+model+dir and sheds the rest
124
124
  // whole; the widest capture exercises every segment at once. Line 1 (right-
125
125
  // justified, OMP placement) sits above the band when present: rate · stats
126
126
  // · usage on one row.
127
- const narrowBand = (l: string) => l.includes("π ·");
128
- const narrow = compose(editor("band")).lines.find(narrowBand)!;
129
- assert.ok(narrow.includes("π · GLM-5.3"), narrow);
127
+ const isBand = (l: string) => l.includes("π >") || l.includes("π ·");
128
+ const narrow = compose(editor("band")).lines.find(isBand)!;
129
+ assert.ok(narrow.includes("π > ⬢ GLM-5.3"), narrow);
130
130
  assert.ok(narrow.includes("📁 ~/dev/ceulen"), narrow);
131
- assert.ok(narrow.includes("12.0%/1.0M"), `context figure never clipped: ${narrow}`);
131
+ assert.ok(narrow.includes("12%") && narrow.includes("─1M"), `gauge carries the context figure: ${narrow}`);
132
132
  assert.ok(!narrow.includes("…"), "whole segments only, no half-cut segment");
133
133
 
134
134
  const wide = compose(editor("band"), 120);
135
- const wideBand = wide.lines.find((l) => l.includes("π ·"))!;
135
+ const wideBand = wide.lines.find(isBand)!;
136
136
  const usageLine = wide.lines.find((l) => l.includes("⚡ 46 tok/s"))!;
137
137
  assert.ok(usageLine.includes("↑1.9M ↓377k R69M") && usageLine.includes("R:59%"), `rate · stats · usage on line 1: ${usageLine}`);
138
138
  assert.ok(!wideBand.includes("⚡"), `line 1 sits above the band: ${wide.lines.join("\n")}`);
139
139
  assert.ok(wideBand.includes("⑂ main *3 +1 ?2"), wideBand);
140
- assert.ok(wideBand.includes("12.0%/1.0M"), wideBand); // right-justification asserted purely in shapes.test
140
+ assert.ok(wideBand.includes("12%") && wideBand.includes("─1M"), wideBand); // gauge-embedded labels
141
141
 
142
- const claude = compose(editor("claude"), 120).lines.find((l) => l.includes("GLM-5.3"))!;
143
- assert.ok(claude.includes("⑂ main") && claude.includes("12.0%/1.0M"), claude);
142
+ const claudeBar = compose(editor("claude"), 120).lines.find((l) => l.includes("GLM-5.3"))!;
143
+ assert.ok(claudeBar.includes("⑂ main") && claudeBar.includes("◫ 12.0%/1M"), claudeBar);
144
144
  });
145
145
 
146
146
  it("composes at narrow widths without eating closing chrome", () => {
@@ -203,6 +203,7 @@ describe("composed screen through the real TUI renderer", () => {
203
203
  dim: (s: string) => s,
204
204
  warn: (s: string) => s,
205
205
  error: (s: string) => s,
206
+ success: (s: string) => s,
206
207
  fill: (s: string) => s,
207
208
  inverse: (s: string) => s,
208
209
  };
@@ -11,10 +11,11 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
11
11
  import { tmpdir } from "node:os";
12
12
  import { join } from "node:path";
13
13
  import {
14
+ bottomBar,
14
15
  composeStatus,
15
16
  contentWidth,
16
17
  DEFAULT_SHAPE,
17
- formatCompact,
18
+ formatNumberTokens,
18
19
  ICONS,
19
20
  parseGitStats,
20
21
  gutterWidth,
@@ -29,6 +30,8 @@ import {
29
30
  shapeById,
30
31
  statusSegments,
31
32
  surfacePainter,
33
+ type BandData,
34
+ type ShapeCtx,
32
35
  type ShapeTheme,
33
36
  } from "../lib/shapes.ts";
34
37
 
@@ -63,6 +66,24 @@ describe("composer shape vocabulary (OMP parity)", () => {
63
66
  assert.equal(isShapeId("nope"), false);
64
67
  assert.equal(isShapeId(42), false);
65
68
  });
69
+
70
+ it("carries OMP's per-shape statusAttachment map (bottomBar + gap)", () => {
71
+ // OMP: band/box embed (no bar); claude/rule bar=left (title on the rule);
72
+ // pi/borderless/field/rail bar=full; ONLY rule/field/rail carry the gap
73
+ // spacer (borderless is bottomBarGap:false — flush under the prompt row).
74
+ const map = (id: string) => {
75
+ const s = shapeById(id);
76
+ return [s.bottomBar, s.barGap === true];
77
+ };
78
+ assert.deepEqual(map("band"), ["none", false]);
79
+ assert.deepEqual(map("box"), ["none", false]);
80
+ assert.deepEqual(map("claude"), ["left", false]);
81
+ assert.deepEqual(map("rule"), ["left", true]);
82
+ assert.deepEqual(map("pi"), ["full", false]);
83
+ assert.deepEqual(map("borderless"), ["full", false], "OMP borderless: no gap");
84
+ assert.deepEqual(map("field"), ["full", true]);
85
+ assert.deepEqual(map("rail"), ["full", true]);
86
+ });
66
87
  });
67
88
 
68
89
  describe("shape geometry", () => {
@@ -121,18 +142,18 @@ describe("chrome rendering through the shared builders", () => {
121
142
  assert.ok(box[0]!.endsWith("╮"), `box top closes at ${w}: ${box[0]}`);
122
143
  assert.ok(box[box.length - 1]!.endsWith("─╯"), `box bottom closes at ${w}: ${box[box.length - 1]}`);
123
144
  const claude = previewShape("claude", w, th, { model: "M" }).map(plain);
124
- assert.equal(claude.length, 3, `claude keeps both rules at ${w}`);
145
+ assert.ok(claude.length >= 2, `claude keeps both rules at ${w}`);
125
146
  for (const l of claude) assert.equal(visibleWidth(l), w, `claude row width at ${w}`);
126
147
  }
127
148
  });
128
149
 
129
150
  it("status-bearing shapes show the live status line; band reserves a blank row when empty", () => {
130
151
  const box = previewShape("box", 40, th, { model: "GLM-5.3", cwd: "ceulen", pct: 42 }).map(plain);
131
- assert.ok(box[0]!.includes("GLM-5.3") && box[0]!.includes("ceulen") && box[0]!.includes("42.0%"), box[0]);
152
+ assert.ok(box[0]!.includes("GLM-5.3") && box[0]!.includes("ceulen") && box[0]!.includes("42%"), box[0]);
132
153
  const bandEmpty = previewShape("band", 40, th).map(plain);
133
- assert.equal(bandEmpty[0]!.trim(), "", "band row reserved (blank) without data");
154
+ assert.ok(bandEmpty.every((l) => !l.includes("π")), "no status rows without data (the layout never shifts)");
134
155
  const bandFull = previewShape("band", 40, th, { model: "M" }).map(plain);
135
- assert.ok(bandFull[0]!.includes("╭─") && bandFull[0]!.includes("M"), bandFull[0]);
156
+ assert.ok(bandFull[0]!.trimStart().startsWith("π") && bandFull[0]!.includes("M"), bandFull[0]);
136
157
  });
137
158
 
138
159
  it("rules carry pi's scroll indicator when lines are hidden", () => {
@@ -191,12 +212,13 @@ describe("git branch read (.git/HEAD)", () => {
191
212
  });
192
213
 
193
214
  describe("status line + surface fill", () => {
194
- it("statusSegments splits OMP's stock groups: identity left, context window right", () => {
195
- const s = statusSegments({ model: "M", provider: "router", thinkingLevel: "max", cwd: "~/dev/ceulen", branch: "main", rate: 46, pct: 42.6, window: 1_000_000 }, th);
196
- assert.equal(plain(s.left), "π · (router) M (max) · 📁 ~/dev/ceulen · ⑂ main");
197
- assert.equal(plain(s.right), "42.6%/1.0M");
215
+ it("statusSegments splits OMP's stock groups: identity left, session title right", () => {
216
+ const s = statusSegments({ model: "M", thinkingLevel: "max", cwd: "~/dev/ceulen", branch: "main", rate: 46, pct: 42.6, window: 1_000_000, sessionName: "fix" }, th);
217
+ assert.equal(plain(s.left), "π > ⬢ M · max > 📁 ~/dev/ceulen > ⑂ main");
218
+ assert.equal(plain(s.right), "fix");
198
219
  // Every segment carries its icon (OMP's glyph set).
199
220
  assert.ok(plain(s.left).startsWith("π "), "brand leads the group");
221
+ assert.ok(plain(s.left).includes("⬢ M"), "model icon");
200
222
  assert.ok(plain(s.left).includes("📁 ~/dev/ceulen"), "folder icon on the dir");
201
223
  assert.ok(plain(s.left).includes("⑂ main"), "branch icon on the git segment");
202
224
  // Generation rate is NOT a band segment — it renders right-justified on
@@ -214,7 +236,7 @@ describe("status line + surface fill", () => {
214
236
  assert.ok(plain(rateLine({ stats: "↑1k ↓500" }, th, 40)).startsWith("↑1k ↓500"), "stats alone sits left");
215
237
  assert.ok(plain(rateLine({ usage: "(router) R:59%/2H3M" }, th, 40)).startsWith("(router) R:59%/2H3M"), "usage alone sits left");
216
238
  // Usage tone steps (error/warn) with the tightest window.
217
- const toneTheme: ShapeTheme = { ...th, warn: (t) => `W(${t})`, error: (t) => `E(${t})` };
239
+ const toneTheme: ShapeTheme = { ...th, warn: (t: string) => `W(${t})`, error: (t: string) => `E(${t})` };
218
240
  assert.ok(plain(rateLine({ usage: "R:9%/1M", usageTone: "error" }, toneTheme, 40)).startsWith("E(R:9%/1M)"), "error tone paints");
219
241
  // Over-budget: the LEFT group sheds whole trailing segments (usage first,
220
242
  // then stats); the rate yields only when the left group is gone.
@@ -228,26 +250,23 @@ describe("status line + surface fill", () => {
228
250
  assert.equal(plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k" }, th, 10)), "⚡ 46 tok/s", `rate is the last thing standing: ${plain(rateLine({ rate: 46, stats: "↑1.9M ↓377k" }, th, 10))}`);
229
251
  // Blanks drop out — never wrong, just shorter. The brand only leads a
230
252
  // group that exists, so an empty session keeps the band blank.
231
- assert.equal(plain(statusSegments({ model: "M" }, th).left), "π · M");
253
+ assert.equal(plain(statusSegments({ model: "M" }, th).left), "π > ⬢ M");
232
254
  assert.equal(statusSegments({}, th).left, "", "no data → no brand");
233
255
  assert.equal(statusSegments(undefined, th).left, "");
234
256
  assert.equal(statusSegments(undefined, th).right, "");
235
- assert.equal(plain(statusSegments({ model: " ", cwd: "x" }, th).left), "π · 📁 x", "blank segments skipped");
257
+ assert.equal(plain(statusSegments({ model: " ", cwd: "x" }, th).left), "π > 📁 x", "blank segments skipped");
236
258
  // Branch without a cwd still renders; detached renders as-is.
237
- assert.equal(plain(statusSegments({ branch: "detached" }, th).left), "π · ⑂ detached");
259
+ assert.equal(plain(statusSegments({ branch: "detached" }, th).left), "π > ⑂ detached");
260
+ // No session title → empty right group.
261
+ assert.equal(statusSegments({ model: "M" }, th).right, "");
238
262
  // Spinner takes the brand slot while a turn runs.
239
- assert.equal(plain(statusSegments({ model: "M" }, th, "⟳").left), "⟳ · M");
263
+ assert.equal(plain(statusSegments({ model: "M" }, th, "⟳").left), "⟳ > ⬢ M");
240
264
  });
241
265
 
242
- it("model segment: (provider) prefix skips when the name carries it; off/blank level dropped", () => {
243
- // Direct provider whose display name already starts with provider/ — no double prefix.
244
- assert.equal(plain(statusSegments({ model: "zai/glm-5.3", provider: "zai" }, th).left), "π · zai/glm-5.3");
245
- // Prefix is case-insensitive on the check, verbatim on output.
246
- assert.equal(plain(statusSegments({ model: "Zai/GLM", provider: "zai" }, th).left), "π · Zai/GLM");
247
- assert.equal(plain(statusSegments({ model: "M", provider: "zai" }, th).left), "π · (zai) M");
248
- // `off` and blank levels render nothing, not "(off)".
249
- assert.equal(plain(statusSegments({ model: "M", thinkingLevel: "off" }, th).left), "π · M");
250
- assert.equal(plain(statusSegments({ model: "M", thinkingLevel: " " }, th).left), "π · M");
266
+ it("model segment: ⬢ icon, level after OMP's dot separator; off/blank level dropped", () => {
267
+ assert.equal(plain(statusSegments({ model: "zai/glm-5.3", provider: "zai" }, th).left), "π > ⬢ zai/glm-5.3");
268
+ assert.equal(plain(statusSegments({ model: "M", thinkingLevel: "off" }, th).left), "π > ⬢ M");
269
+ assert.equal(plain(statusSegments({ model: "M", thinkingLevel: " " }, th).left), "π > ⬢ M");
251
270
  // Level without a model never renders alone.
252
271
  assert.equal(statusSegments({ thinkingLevel: "max" }, th).left, "");
253
272
  });
@@ -258,35 +277,36 @@ describe("status line + surface fill", () => {
258
277
  th,
259
278
  );
260
279
  const left = plain(s.left);
261
- assert.equal(left, "π · (router) M (high) · ⑂ main *10 +1 ?4");
280
+ assert.equal(left, "π > ⬢ M · high > ⑂ main *10 +1 ?4");
262
281
  // Supplied-but-dropped figures never leak into the band — line 1
263
282
  // (rateLine) owns rate · stats · usage.
264
283
  assert.ok(!left.includes("R:59%") && !left.includes("↑1.9M") && !left.includes("tok/s"), "usage/stats/rate stay off the band");
265
284
  // Usage-only line 1 keeps tone-stepping.
266
- assert.equal(plain(rateLine({ usage: "(r) R:59%/2H3M", usageTone: "warning" }, { ...th, warn: (t) => `W(${t})` }, 40)), "W((r) R:59%/2H3M)");
267
- assert.equal(plain(statusSegments({ model: "M", usage: " " }, th).left), "π · M");
268
- assert.equal(plain(statusSegments({ model: "M", stats: "" }, th).left), "π · M");
285
+ assert.equal(plain(rateLine({ usage: "(r) R:59%/2H3M", usageTone: "warning" }, { ...th, warn: (t: string) => `W(${t})` }, 40)), "W((r) R:59%/2H3M)");
286
+ assert.equal(plain(statusSegments({ model: "M", usage: " " }, th).left), "π > ⬢ M");
287
+ assert.equal(plain(statusSegments({ model: "M", stats: "" }, th).left), "π > ⬢ M");
269
288
  });
270
289
 
271
- it("context window color-steps like pi's footer (>70 warn, >90 error)", () => {
290
+ it("context segment: ◫ icon, OMP format, color-steps at OMP's thresholds (>50 warn, >90 error), ⟲ when auto", () => {
272
291
  const seen = { warn: 0, error: 0 };
273
292
  const stepping: ShapeTheme = {
274
293
  ...th,
275
294
  warn: (s) => (seen.warn++, s),
276
295
  error: (s) => (seen.error++, s),
277
296
  };
278
- assert.equal(plain(statusSegments({ pct: 42, window: 200_000 }, stepping).right), "42.0%/200k");
297
+ const seg = (d: BandData) => plain(bottomBar({ w: 200, hidden: 0, theme: stepping, data: d }, "full"));
298
+ assert.equal(seg({ pct: 42, window: 200_000 }), "π · ◫ 42.0%/200K");
279
299
  assert.equal(seen.warn, 0);
280
- assert.equal(plain(statusSegments({ pct: 75, window: 200_000 }, stepping).right), "75.0%/200k");
300
+ assert.equal(seg({ pct: 75, window: 200_000 }), "π · ◫ 75.0%/200K");
281
301
  assert.equal(seen.warn, 1);
282
- assert.equal(plain(statusSegments({ pct: 95, window: 200_000 }, stepping).right), "95.0%/200k");
302
+ assert.equal(seg({ pct: 95, window: 200_000 }), "π · ◫ 95.0%/200K");
283
303
  assert.equal(seen.error, 1);
284
304
  // Unknown pct with a known window shows the window alone.
285
- assert.equal(plain(statusSegments({ pct: null, window: 200_000 }, th).right), "200k/?");
286
- assert.equal(statusSegments({}, th).right, "");
287
- // pi's `(auto)` compaction marker rides the context figure (footer parity).
288
- assert.equal(plain(statusSegments({ pct: 42, window: 200_000, autoCompact: true }, th).right), "42.0%/200k (auto)");
289
- assert.equal(plain(statusSegments({ pct: 95, window: 200_000, autoCompact: true }, stepping).right), "95.0%/200k (auto)");
305
+ assert.equal(seg({ pct: null, window: 200_000 }), "π · ◫ 200K/?");
306
+ assert.equal(seg({}), "", "nothing to show → no segment");
307
+ // OMP's auto-compact icon rides the context figure.
308
+ assert.equal(seg({ pct: 42, window: 200_000, autoCompact: true }), "π · ◫ 42.0%/200K ⟲");
309
+ assert.equal(seg({ pct: 95, window: 200_000, autoCompact: true }), "π · ◫ 95.0%/200K ⟲");
290
310
  });
291
311
 
292
312
  it("composeStatus justifies the right group; the left group yields first when narrow", () => {
@@ -298,25 +318,25 @@ describe("status line + surface fill", () => {
298
318
  assert.equal(plain(composeStatus("LLLLLL", "RRRR", 5)), "RRRR", "right alone when the left cannot fit");
299
319
  });
300
320
 
301
- it("formatCompact matches pi-footer/OMP token figures", () => {
302
- assert.equal(formatCompact(0), "0");
303
- assert.equal(formatCompact(999), "999");
304
- assert.equal(formatCompact(2_500), "2.5k");
305
- assert.equal(formatCompact(200_000), "200k");
306
- assert.equal(formatCompact(1_000_000), "1.0M");
307
- assert.equal(formatCompact(12_000_000), "12M");
308
- assert.equal(formatCompact(Number.NaN), "0");
321
+ it("formatNumberTokens matches OMP's token figures", () => {
322
+ assert.equal(formatNumberTokens(0), "0");
323
+ assert.equal(formatNumberTokens(999), "999");
324
+ assert.equal(formatNumberTokens(2_500), "2.5K");
325
+ assert.equal(formatNumberTokens(200_000), "200K");
326
+ assert.equal(formatNumberTokens(1_000_000), "1M");
327
+ assert.equal(formatNumberTokens(12_000_000), "12M");
328
+ assert.equal(formatNumberTokens(Number.NaN), "0");
309
329
  });
310
330
 
311
331
  it("status chips/bands carry dir, branch and the context window", () => {
312
332
  const data = { model: "M", cwd: "~/dev/ceulen", branch: "main", pct: 42.6, window: 1_000_000 };
313
333
  const band = previewShape("band", 60, th, data).map(plain)[0]!;
314
334
  assert.ok(band.includes("📁 ~/dev/ceulen") && band.includes("⑂ main"), band);
315
- assert.ok(band.includes("42.6%/1.0M"), band);
316
- // Right group is justified to the band's right edge (before the closing cap cells).
317
- assert.ok(band.trimEnd().endsWith("42.6%/1.0M"), band);
335
+ // The gauge carries the context figure, rounded (OMP's embedded percent),
336
+ // and closes the band with the window label.
337
+ assert.ok(band.includes("43%") && band.includes("─1M"), band);
318
338
  const box = previewShape("box", 60, th, data).map(plain)[0]!;
319
- assert.ok(box.includes("📁 ~/dev/ceulen") && box.includes("42.6%/1.0M") && box.endsWith("╮"), box);
339
+ assert.ok(box.includes("📁 ~/dev/ceulen") && box.includes("43%") && box.endsWith("╮"), box);
320
340
  });
321
341
 
322
342
  it("band fills the status chip only, not the whole line (OMP's band)", () => {
@@ -326,24 +346,26 @@ describe("status line + surface fill", () => {
326
346
  const line = shapeById("band").top!(c as never)!;
327
347
  const filled = line.slice(line.indexOf("⟦") + 1, line.indexOf("⟧"));
328
348
  assert.ok(filled.includes("main"), `identity is filled: ${filled}`);
329
- assert.ok(!filled.includes("42.0%/1.0M"), `context figure stays on the bare surface: ${filled}`);
330
- // The context figure survives OUTSIDE the chip, and the line is still full width.
349
+ // The gauge (context figure) survives OUTSIDE the chip, and the line is full width.
331
350
  assert.equal(visibleWidth(line), 80, "band still spans the full width");
332
- assert.ok(plain(line).includes("42.0%/1.0M"), plain(line));
333
- assert.ok(plain(line).indexOf("⟧") < plain(line).indexOf("42.0%/1.0M"), "fill ends before the context figure");
351
+ assert.ok(plain(line).includes("42%"), plain(line));
352
+ assert.ok(plain(line).indexOf("⟧") < plain(line).indexOf("42%"), "fill ends before the gauge");
334
353
  });
335
354
 
336
- it("git segment renders OMP's indicators and goes warning when dirty", () => {
337
- assert.equal(plain(statusSegments({ branch: "main" }, th).left), "π · ⑂ main", "clean tree: branch only");
355
+ it("git segment renders OMP's indicators with per-indicator colors", () => {
356
+ assert.equal(plain(statusSegments({ branch: "main" }, th).left), "π > ⑂ main", "clean tree: branch only");
338
357
  const dirty = statusSegments({ branch: "main", git: { staged: 1, unstaged: 3, untracked: 2 } }, th).left;
339
358
  assert.ok(plain(dirty).endsWith("⑂ main *3 +1 ?2"), plain(dirty));
340
- // Dirty renders through the warning hook (OMP's statusLineGitDirty).
341
- let warned = 0;
342
- const th2: ShapeTheme = { ...th, warn: (s) => (warned++, s) };
343
- statusSegments({ branch: "main", git: { staged: 0, unstaged: 1, untracked: 0 } }, th2);
344
- assert.equal(warned, 1, "dirty tree warns");
345
- assert.equal(plain(statusSegments({ branch: "main", git: { staged: 0, unstaged: 0, untracked: 0 } }, th2).left), "π · ⑂ main");
346
- assert.equal(warned, 1, "clean tree does not warn again");
359
+ // Per-indicator colors (OMP's statusLine colors): branch warns when dirty,
360
+ // staged paints success, untracked dims.
361
+ const marks: ShapeTheme = { ...th, warn: (s) => `W<${s}>`, success: (s) => `S<${s}>`, dim: (s) => `D<${s}>` };
362
+ const marked = plain(statusSegments({ branch: "main", git: { staged: 1, unstaged: 3, untracked: 2 } }, marks).left);
363
+ assert.ok(marked.includes("W<⑂ main> W<*3>") && marked.includes("S<+1>") && marked.includes("D<?2>"), marked);
364
+ // Clean tree paints the branch plain (never warning) — OMP colors only
365
+ // the INDICATORS, not the branch itself.
366
+ const clean = statusSegments({ branch: "main", git: { staged: 0, unstaged: 0, untracked: 0 } }, marks).left;
367
+ assert.ok(!plain(clean).includes("W<") && plain(clean).includes("⑂ main"), clean);
368
+ assert.equal(plain(statusSegments({ branch: "main", git: { staged: 0, unstaged: 0, untracked: 0 } }, th).left), "π > ⑂ main", "zero counts are clean");
347
369
  });
348
370
 
349
371
  it("parseGitStats counts porcelain XY states like OMP's indicators", () => {
@@ -36,6 +36,7 @@ import {
36
36
  } from "./lib/helpers.js";
37
37
  import { withRetry } from "./lib/retry.js";
38
38
  import { readDisabledTools } from "../../lib/tools.js";
39
+ import { skillsRoot } from "../../lib/skill-path.js";
39
40
 
40
41
  // Shared schemas — per-call overrides (params win over env/settings).
41
42
  const projectParam = Type.Optional(
@@ -569,9 +570,8 @@ export default function muninExtension(pi: ExtensionAPI) {
569
570
  // dir) and is contributed through resources_discover — NOT via the
570
571
  // package.json `pi.skills` manifest — so the kill-switch gates it too:
571
572
  // disabled module ⇒ factory never runs ⇒ no munin skill registered.
572
- const skillsRoot = new URL("../../../skills/", import.meta.url).pathname;
573
573
  pi.on("resources_discover", () => ({
574
- skillPaths: [path.join(fs.realpathSync(skillsRoot), "munin")],
574
+ skillPaths: [path.join(fs.realpathSync(skillsRoot()), "munin")],
575
575
  }));
576
576
 
577
577
  // Per-tool kill-switch (ceulen.disabledTools): listed tools register
@@ -28,6 +28,7 @@ import {
28
28
  } from "./lib/config.js";
29
29
  import { row, type PanelGroup } from "../../lib/panel.js";
30
30
  import type { ModuleConfig } from "../../lib/registry.js";
31
+ import { skillsRoot } from "../../lib/skill-path.js";
31
32
  import { filterSkillBodyForMode, getPonytailInstructions } from "./lib/instructions.js";
32
33
  import { getSubagentInstructions, shouldInjectSubagentInstructions } from "./lib/subagent.js";
33
34
 
@@ -173,9 +174,8 @@ export default function ponytailExtension(pi: ExtensionAPI) {
173
174
  // registered. Only THIS module's dirs (not the skills/ root — the ux module
174
175
  // owns its own entries there; a whole-dir path would leak ux skills past the
175
176
  // ux kill-switch whenever ponytail is enabled).
176
- const skillsRoot = new URL("../../../skills/", import.meta.url).pathname;
177
177
  pi.on("resources_discover", () => ({
178
- skillPaths: ["ponytail", "ponytail-audit", "ponytail-debt", "ponytail-gain", "ponytail-help", "ponytail-review"].map((n) => path.join(skillsRoot, n)),
178
+ skillPaths: ["ponytail", "ponytail-audit", "ponytail-debt", "ponytail-gain", "ponytail-help", "ponytail-review"].map((n) => path.join(skillsRoot(), n)),
179
179
  }));
180
180
 
181
181
  let currentMode: PonytailMode = DEFAULT_MODE;
@@ -108,7 +108,7 @@ export function writeRepairSection(patch: Partial<RepairSettings>): string {
108
108
  settings.repair = repair;
109
109
  mkdirSync(path.dirname(file), { recursive: true });
110
110
  const tmp = file + ".tmp";
111
- writeFileSync(tmp, JSON.stringify(settings, null, 2) + "\n");
111
+ writeFileSync(tmp, JSON.stringify(settings, null, 2) + "\n", { mode: 0o600 });
112
112
  renameSync(tmp, file);
113
113
  return file;
114
114
  }
@@ -120,15 +120,19 @@ export function registerProvider(pi: ExtensionAPI, settings: RouterSettings): vo
120
120
  // stale persisted flags self-heal — /v1/models vision metadata lies
121
121
  // in both directions (see client.ts VISION_OVERRIDES/VISION_DOWNGRADES)
122
122
  // and old caches froze it verbatim.
123
- return stored.map((m) =>
124
- (m as { type?: string }).type === "classifier"
125
- ? m
126
- : applyReasoning(
127
- // Array.isArray guards legacy/malformed store entries (treated as text-only).
128
- { ...m, input: resolveVision(m.id, Array.isArray(m.input) && m.input.includes("image")) ? ["text", "image"] : ["text"] } as PiModel,
129
- settings.enableReasoning,
130
- ),
131
- ) as unknown as ProviderModelConfig[];
123
+ // Non-object entries (null in a hand-edited/corrupted store) are
124
+ // dropped — a null here used to throw TypeError and break startup.
125
+ return stored
126
+ .filter((m): m is NonNullable<typeof m> => m !== null && typeof m === "object")
127
+ .map((m) =>
128
+ (m as { type?: string }).type === "classifier"
129
+ ? m
130
+ : applyReasoning(
131
+ // Array.isArray guards legacy/malformed store entries (treated as text-only).
132
+ { ...m, input: resolveVision(m.id, Array.isArray(m.input) && m.input.includes("image")) ? ["text", "image"] : ["text"] } as PiModel,
133
+ settings.enableReasoning,
134
+ ),
135
+ ) as unknown as ProviderModelConfig[];
132
136
  }
133
137
 
134
138
  const cred = context.credential as { type?: string; key?: string } | undefined;
@@ -39,6 +39,7 @@ import {
39
39
  HARD_TIMEOUT_MS,
40
40
  truncateParallelOutput,
41
41
  } from "./security.ts";
42
+ import { randomUUID } from "node:crypto";
42
43
 
43
44
  // ---------------------------------------------------------------------------
44
45
  // Types
@@ -462,7 +463,7 @@ export async function applyWorktreePatch3way(
462
463
  exec?: (command: string, args: string[], options?: { cwd?: string; timeout?: number }) => Promise<{ code: number; stdout: string; stderr: string }>,
463
464
  ): Promise<{ ok: boolean; stderr: string }> {
464
465
  const run = applyChain.then(async (): Promise<{ ok: boolean; stderr: string }> => {
465
- const tmp = path.join(os.tmpdir(), `pi-subagent-apply-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}.patch`);
466
+ const tmp = path.join(os.tmpdir(), `pi-subagent-apply-${randomUUID()}.patch`);
466
467
  try {
467
468
  // git apply interprets paths relative to cwd — write the diff to a file
468
469
  // and apply at the repo root. captureWorktreeDiff trims trailing
@@ -470,7 +471,8 @@ export async function applyWorktreePatch3way(
470
471
  // restore it (CRLF-aware: trimming "...\r\n" must not downgrade the
471
472
  // final line ending to LF).
472
473
  const patchText = diff.endsWith("\n") ? diff : `${diff}${diff.includes("\r\n") ? "\r\n" : "\n"}`;
473
- await fs.writeFile(tmp, patchText, "utf8");
474
+ // wx: never follow a pre-planted symlink at this path (shared /tmp).
475
+ await fs.writeFile(tmp, patchText, { encoding: "utf8", flag: "wx" });
474
476
  const res = await runGit(repoRoot, ["apply", "--3way", tmp], exec);
475
477
  return { ok: res.ok, stderr: (res.stderr || res.stdout).trim() };
476
478
  } catch (error) {
@@ -29,6 +29,7 @@ import {
29
29
  import { getUxInstructions } from "./lib/instructions.js";
30
30
  import { row, type PanelGroup } from "../../lib/panel.js";
31
31
  import { readDisabledTools } from "../../lib/tools.js";
32
+ import { skillsRoot } from "../../lib/skill-path.js";
32
33
  import type { ModuleConfig } from "../../lib/registry.js";
33
34
 
34
35
  export const readDefaultMode = getDefaultMode;
@@ -278,9 +279,8 @@ export default function uxExtension(pi: ExtensionAPI) {
278
279
  // package.json `pi.skills` manifest — so the kill-switch gates them too:
279
280
  // disabled module ⇒ factory never runs ⇒ no ux-* skills registered. Only
280
281
  // THIS module's dirs: the shared skills/ root belongs to ponytail's handler.
281
- const skillsRoot = new URL("../../../skills/", import.meta.url).pathname;
282
282
  pi.on("resources_discover", () => ({
283
- skillPaths: ["ux-design", "ux-capture", "ux-presets", "ux-routing"].map((n) => path.join(skillsRoot, n)),
283
+ skillPaths: ["ux-design", "ux-capture", "ux-presets", "ux-routing"].map((n) => path.join(skillsRoot(), n)),
284
284
  }));
285
285
 
286
286
  let currentMode: UxMode = DEFAULT_MODE;
@@ -16,6 +16,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
16
16
  import { Type } from "typebox";
17
17
 
18
18
  import { readDisabledTools } from "../../lib/tools.js";
19
+ import { skillsRoot } from "../../lib/skill-path.js";
19
20
 
20
21
  import { formatA11ySummary, runA11yAudit } from "./lib/a11y";
21
22
 
@@ -164,9 +165,8 @@ export default function piWebExtension(pi: ExtensionAPI) {
164
165
  // dir) and is contributed through resources_discover — NOT via the
165
166
  // package.json `pi.skills` manifest — so the kill-switch gates it too:
166
167
  // disabled module ⇒ factory never runs ⇒ no web skill registered.
167
- const skillsRoot = new URL("../../../skills/", import.meta.url).pathname;
168
168
  pi.on("resources_discover", () => ({
169
- skillPaths: [path.join(fs.realpathSync(skillsRoot), "web")],
169
+ skillPaths: [path.join(fs.realpathSync(skillsRoot()), "web")],
170
170
  }));
171
171
 
172
172
  // Per-tool kill-switch (ceulen.disabledTools): listed tools register
@@ -145,7 +145,7 @@ export function buildScreenshotArgs(opts: ScreenshotArgsOpts): string[] {
145
145
  "--hide-scrollbars",
146
146
  `--window-size=${opts.width},${height}`,
147
147
  ...(opts.reducedMotion ? ["--force-prefers-reduced-motion"] : []),
148
- ...(opts.waitForSec ? [`--virtual-time-budget=${Math.round(opts.waitForSec * 1000)}`] : []),
148
+ ...(opts.waitForSec ? [`--virtual-time-budget=${Math.max(0, Math.round(opts.waitForSec * 1000))}`] : []),
149
149
  `--screenshot=${opts.outPath}`,
150
150
  opts.url,
151
151
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ceulen",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
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/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",
44
44
  "typecheck": "tsc --noEmit"
45
45
  },
46
46
  "pi": {