ceulen 0.9.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.
- package/CHANGELOG.md +79 -0
- package/extensions/lib/registry.ts +8 -2
- package/extensions/lib/skill-path.test.ts +35 -0
- package/extensions/lib/skill-path.ts +22 -0
- package/extensions/modules/a2a/index.ts +2 -2
- package/extensions/modules/a2a/lib/config.ts +1 -1
- package/extensions/modules/a2a/lib/registry.ts +1 -1
- package/extensions/modules/composer/index.ts +19 -1
- package/extensions/modules/composer/lib/footer.ts +7 -7
- package/extensions/modules/composer/lib/shapes.ts +237 -112
- package/extensions/modules/composer/test/editor.test.ts +3 -3
- package/extensions/modules/composer/test/footer.test.ts +1 -1
- package/extensions/modules/composer/test/module.test.ts +8 -7
- package/extensions/modules/composer/test/screen.test.ts +10 -9
- package/extensions/modules/composer/test/shapes.test.ts +83 -61
- package/extensions/modules/config/index.ts +1 -0
- package/extensions/modules/config/test/renderTools.test.ts +1 -1
- package/extensions/modules/gh/configPanel.ts +82 -0
- package/extensions/modules/gh/index.ts +86 -0
- package/extensions/modules/gh/lib/gh-cli.ts +337 -0
- package/extensions/modules/gh/lib/ops.ts +771 -0
- package/extensions/modules/gh/test/gh.test.ts +280 -0
- package/extensions/modules/munin/index.ts +2 -2
- package/extensions/modules/plan/lib/plan-tools.ts +8 -0
- package/extensions/modules/ponytail/index.ts +2 -2
- package/extensions/modules/repair/index.ts +138 -0
- package/extensions/modules/repair/lib/guards.ts +1 -1
- package/extensions/modules/repair/lib/read-selector.ts +242 -0
- package/extensions/modules/repair/lib/settings.ts +1 -1
- package/extensions/modules/repair/test/read-selector.test.ts +198 -0
- package/extensions/modules/router/lib/provider.ts +13 -9
- package/extensions/modules/steering/configPanel.ts +8 -0
- package/extensions/modules/steering/index.ts +6 -0
- package/extensions/modules/steering/lib/settings.ts +6 -2
- package/extensions/modules/steering/lib/think.ts +66 -0
- package/extensions/modules/steering/test/harness.ts +5 -0
- package/extensions/modules/steering/test/settings.test.ts +2 -0
- package/extensions/modules/steering/test/think.test.ts +77 -0
- package/extensions/modules/subagent/lib/runner.ts +4 -2
- package/extensions/modules/ux/index.ts +2 -2
- package/extensions/modules/web/index.ts +39 -3
- package/extensions/modules/web/lib/a11y.ts +252 -0
- package/extensions/modules/web/lib/chrome.ts +1 -1
- package/extensions/modules/web/test/a11y.test.ts +218 -0
- package/extensions/modules/web/test/extension.test.ts +2 -2
- package/extensions/modules/web/test/hook.test.ts +2 -2
- package/extensions/modules/web/vendor/axe/LICENSE +362 -0
- package/extensions/modules/web/vendor/axe/LICENSE-3RD-PARTY.txt +66 -0
- package/extensions/modules/web/vendor/axe/README.md +19 -0
- package/extensions/modules/web/vendor/axe/axe.min.js +12 -0
- package/package.json +2 -2
- package/skills/web/SKILL.md +1 -0
|
@@ -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
|
|
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
|
|
128
|
-
const narrow = compose(editor("band")).lines.find(
|
|
129
|
-
assert.ok(narrow.includes("π
|
|
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.
|
|
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(
|
|
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.
|
|
140
|
+
assert.ok(wideBand.includes("12%") && wideBand.includes("─1M"), wideBand); // gauge-embedded labels
|
|
141
141
|
|
|
142
|
-
const
|
|
143
|
-
assert.ok(
|
|
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
|
-
|
|
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.
|
|
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
|
|
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.
|
|
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]!.
|
|
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,
|
|
195
|
-
const s = statusSegments({ model: "M",
|
|
196
|
-
assert.equal(plain(s.left), "π
|
|
197
|
-
assert.equal(plain(s.right), "
|
|
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), "π
|
|
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), "π
|
|
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), "π
|
|
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), "⟳
|
|
263
|
+
assert.equal(plain(statusSegments({ model: "M" }, th, "⟳").left), "⟳ > ⬢ M");
|
|
240
264
|
});
|
|
241
265
|
|
|
242
|
-
it("model segment:
|
|
243
|
-
|
|
244
|
-
assert.equal(plain(statusSegments({ model: "
|
|
245
|
-
|
|
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, "π
|
|
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), "π
|
|
268
|
-
assert.equal(plain(statusSegments({ model: "M", stats: "" }, th).left), "π
|
|
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
|
|
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
|
-
|
|
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(
|
|
300
|
+
assert.equal(seg({ pct: 75, window: 200_000 }), "π · ◫ 75.0%/200K");
|
|
281
301
|
assert.equal(seen.warn, 1);
|
|
282
|
-
assert.equal(
|
|
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(
|
|
286
|
-
assert.equal(
|
|
287
|
-
//
|
|
288
|
-
assert.equal(
|
|
289
|
-
assert.equal(
|
|
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("
|
|
302
|
-
assert.equal(
|
|
303
|
-
assert.equal(
|
|
304
|
-
assert.equal(
|
|
305
|
-
assert.equal(
|
|
306
|
-
assert.equal(
|
|
307
|
-
assert.equal(
|
|
308
|
-
assert.equal(
|
|
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
|
-
|
|
316
|
-
//
|
|
317
|
-
assert.ok(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("
|
|
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
|
-
|
|
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
|
|
333
|
-
assert.ok(plain(line).indexOf("⟧") < plain(line).indexOf("42
|
|
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
|
|
337
|
-
assert.equal(plain(statusSegments({ branch: "main" }, th).left), "π
|
|
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
|
-
//
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
statusSegments({ branch: "main", git: { staged:
|
|
344
|
-
assert.
|
|
345
|
-
|
|
346
|
-
|
|
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", () => {
|
|
@@ -258,6 +258,7 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
258
258
|
repair: { section: "Repair", icon: "🔧" },
|
|
259
259
|
fff: { section: "FFF search" },
|
|
260
260
|
web: { section: "Web", icon: "🌍" },
|
|
261
|
+
gh: { section: "GitHub", icon: "🐙" },
|
|
261
262
|
a2a: { section: "A2A", icon: "📡" },
|
|
262
263
|
rtk: { section: "RTK" },
|
|
263
264
|
config: { section: "Ceulen config", icon: "🧩" },
|
|
@@ -34,7 +34,7 @@ function toolGroups(): PanelGroup[] {
|
|
|
34
34
|
describe("render smoke — ported modules' /config sections", () => {
|
|
35
35
|
it("renders Enable + per-tool rows inside the boxed frame with zero overflow", () => {
|
|
36
36
|
const groups = toolGroups();
|
|
37
|
-
assert.equal(groups.length,
|
|
37
|
+
assert.equal(groups.length, 15, "serena + fff + ux + munin + classifier + advisor + subagent + repair + plan + todo + web + rules + a2a + gh + steering·think (rtk has no tools)");
|
|
38
38
|
const m = new ConfigPanelModel(groups, theme, "Settings");
|
|
39
39
|
m.getHeight = () => 40;
|
|
40
40
|
for (const w of [110, 100, 80, 60]) {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// gh module's /config contribution — Tools tab, GitHub section.
|
|
2
|
+
//
|
|
3
|
+
// One row: the run_watch budget. The module itself needs no settings (the gh
|
|
4
|
+
// binary + the user's gh auth own everything else). Saving writes the GLOBAL
|
|
5
|
+
// settings.json `gh` section; ops read it per call, so a save applies live.
|
|
6
|
+
|
|
7
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
9
|
+
import os from "node:os";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { row, type PanelGroup } from "../../lib/panel.js";
|
|
12
|
+
import type { ModuleConfig } from "../../lib/registry.js";
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_RUN_WATCH_TIMEOUT_SECS = 600;
|
|
15
|
+
|
|
16
|
+
function agentDir(): string {
|
|
17
|
+
return process.env.PI_CODING_AGENT_DIR || path.join(os.homedir(), ".pi", "agent");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function readRunWatchTimeoutSecs(): number {
|
|
21
|
+
for (const file of [path.join(agentDir(), "settings.json")]) {
|
|
22
|
+
try {
|
|
23
|
+
if (!existsSync(file)) continue;
|
|
24
|
+
const section = JSON.parse(readFileSync(file, "utf8"))?.gh;
|
|
25
|
+
const v = section?.runWatchTimeoutSecs;
|
|
26
|
+
if (typeof v === "number" && Number.isFinite(v) && v > 0) return Math.floor(v);
|
|
27
|
+
} catch {
|
|
28
|
+
// corrupt layer → default
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return DEFAULT_RUN_WATCH_TIMEOUT_SECS;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function writeRunWatchTimeoutSecs(secs: number): string {
|
|
35
|
+
const file = path.join(agentDir(), "settings.json");
|
|
36
|
+
let settings: Record<string, unknown> = {};
|
|
37
|
+
if (existsSync(file)) {
|
|
38
|
+
try {
|
|
39
|
+
settings = JSON.parse(readFileSync(file, "utf8")) as Record<string, unknown>;
|
|
40
|
+
} catch {
|
|
41
|
+
throw new Error(`${file} is not valid JSON — fix or remove it before saving.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
settings.gh = { ...(settings.gh as object | undefined ?? {}), runWatchTimeoutSecs: secs };
|
|
45
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
46
|
+
const tmp = file + ".tmp";
|
|
47
|
+
writeFileSync(tmp, JSON.stringify(settings, null, 2) + "\n", { mode: 0o600 });
|
|
48
|
+
renameSync(tmp, file);
|
|
49
|
+
return file;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function buildGhGroups(runWatchTimeoutSecs: number): PanelGroup[] {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
key: "gh",
|
|
56
|
+
label: "GitHub",
|
|
57
|
+
tab: "Tools",
|
|
58
|
+
icon: "🐙",
|
|
59
|
+
rows: [
|
|
60
|
+
row("gh.runWatchTimeoutSecs", "run_watch budget", "number", runWatchTimeoutSecs, (v) => {
|
|
61
|
+
runWatchTimeoutSecs = Math.max(10, Math.floor(Number(v)));
|
|
62
|
+
}, {
|
|
63
|
+
defaultValue: DEFAULT_RUN_WATCH_TIMEOUT_SECS,
|
|
64
|
+
description: "Seconds run_watch keeps polling a workflow run before reporting in-progress (capped at gh's 5-min command deadline).",
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** gh's ModuleConfig for the central /config panel. */
|
|
72
|
+
export function ghConfig(_pi: ExtensionAPI): ModuleConfig {
|
|
73
|
+
let working = readRunWatchTimeoutSecs();
|
|
74
|
+
return {
|
|
75
|
+
groups: () => buildGhGroups(working),
|
|
76
|
+
save: async (edited, ctx: ExtensionContext) => {
|
|
77
|
+
if (![...edited].some((k) => k.startsWith("gh."))) return;
|
|
78
|
+
const file = writeRunWatchTimeoutSecs(working);
|
|
79
|
+
ctx.ui.notify(`Saved gh.runWatchTimeoutSecs=${working} to ${file} (applies to the next run_watch call).`, "info");
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// gh module — one `github` tool over the `gh` CLI (zero npm deps).
|
|
2
|
+
//
|
|
3
|
+
// Ported from oh-my-pi's github tool (tools/gh*.ts + utils/github.ts), scoped
|
|
4
|
+
// to READ-ONLY ops: repo_view, file_read, pr_view, pr_diff, the five search
|
|
5
|
+
// flavors, run_watch. Mutating flows (pr_create/checkout/push) are deferred —
|
|
6
|
+
// bash `gh` covers them, and a read-only tool lets plan mode auto-allow it
|
|
7
|
+
// (plan-tools.ts READ_ONLY_TOOLS).
|
|
8
|
+
//
|
|
9
|
+
// Registration is fail-open on a missing `gh` binary: the module loads, the
|
|
10
|
+
// Enable row stays reachable, but no tool registers (OMP's createIf pattern)
|
|
11
|
+
// until gh is installed.
|
|
12
|
+
|
|
13
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
14
|
+
import { Type } from "typebox";
|
|
15
|
+
import { readDisabledTools } from "../../lib/tools.js";
|
|
16
|
+
import { ghAvailable, realGh } from "./lib/gh-cli.js";
|
|
17
|
+
import { executeOp } from "./lib/ops.js";
|
|
18
|
+
|
|
19
|
+
const OP_ENUM = [
|
|
20
|
+
"repo_view", "file_read", "pr_view", "pr_diff",
|
|
21
|
+
"search_issues", "search_prs", "search_code", "search_commits", "search_repos",
|
|
22
|
+
"run_watch",
|
|
23
|
+
] as const;
|
|
24
|
+
|
|
25
|
+
const DESCRIPTION = [
|
|
26
|
+
"Interact with GitHub via the `gh` CLI — repositories, files, pull requests, issues, and Actions.",
|
|
27
|
+
"Read-only operations:",
|
|
28
|
+
"- repo_view: repository metadata (default branch, stars, language, topics).",
|
|
29
|
+
"- file_read: a repository file's contents (text; binary → notice with URL) at an optional branch/ref.",
|
|
30
|
+
"- pr_view: PR metadata, body, files, reviews.",
|
|
31
|
+
"- pr_diff: a PR's unified diff.",
|
|
32
|
+
"- search_issues / search_prs / search_code / search_commits / search_repos: GitHub search with repo/org/user scoping and since/until date filters.",
|
|
33
|
+
"- run_watch: poll a workflow run until it completes; on failure, tails each failed job's logs (`tail` lines per job). Blocks up to ~5 min.",
|
|
34
|
+
"",
|
|
35
|
+
"Prefer these over bash `gh` invocations: repo/ref normalization handles `[host/]owner/repo` and URLs, prompts can never hang, output is capped and structured.",
|
|
36
|
+
].join("\n");
|
|
37
|
+
|
|
38
|
+
export default function ghModule(pi: ExtensionAPI): void {
|
|
39
|
+
// No `gh` binary → no tool; /config's Enable row still renders (the module
|
|
40
|
+
// stays registered in the loader) so installing gh + /reload activates it.
|
|
41
|
+
if (!ghAvailable()) return;
|
|
42
|
+
|
|
43
|
+
const disabled = readDisabledTools();
|
|
44
|
+
pi.registerTool({
|
|
45
|
+
name: "github",
|
|
46
|
+
label: "GitHub",
|
|
47
|
+
description: DESCRIPTION,
|
|
48
|
+
promptSnippet: "Interact with GitHub repos, files, PRs, issues, Actions via gh",
|
|
49
|
+
promptGuidelines: [
|
|
50
|
+
"Prefer search_code over web search for code in known GitHub repos; scope with repo:/org:/user: or the repo param.",
|
|
51
|
+
"run_watch blocks until the run finishes — pass `run` plus `tail` to bound log lines.",
|
|
52
|
+
"Read-only surface: create/push/checkout flows go through bash `gh` explicitly.",
|
|
53
|
+
],
|
|
54
|
+
parameters: Type.Object({
|
|
55
|
+
op: Type.Union(OP_ENUM.map((o) => Type.Literal(o)), { description: "github operation" }),
|
|
56
|
+
repo: Type.Optional(Type.String({ description: "[host/]owner/repo (or full URL where noted); defaults to the cwd checkout." })),
|
|
57
|
+
branch: Type.Optional(Type.String({ description: "branch / ref (file_read, repo_view)." })),
|
|
58
|
+
path: Type.Optional(Type.String({ description: "repository-relative file path (file_read)." })),
|
|
59
|
+
pr: Type.Optional(Type.String({ description: "pr number, url, or branch (pr_view, pr_diff)." })),
|
|
60
|
+
query: Type.Optional(Type.String({ description: "search query (search_* ops)." })),
|
|
61
|
+
since: Type.Optional(Type.String({ description: "lower-bound date filter: relative (3d, 2w) or ISO (search_*, not search_code)." })),
|
|
62
|
+
until: Type.Optional(Type.String({ description: "upper-bound date filter (search_*, not search_code)." })),
|
|
63
|
+
dateField: Type.Optional(Type.Union([Type.Literal("created"), Type.Literal("updated")], { description: "date field for since/until (default created)." })),
|
|
64
|
+
limit: Type.Optional(Type.Number({ description: "max results (search_*; default 10, max 50)." })),
|
|
65
|
+
run: Type.Optional(Type.String({ description: "actions run id or url (run_watch)." })),
|
|
66
|
+
tail: Type.Optional(Type.Number({ description: "failed-job log tail lines (run_watch; default 15, max 200)." })),
|
|
67
|
+
}),
|
|
68
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
69
|
+
const cwd = ctx?.cwd || process.cwd();
|
|
70
|
+
const p = params as Record<string, unknown>;
|
|
71
|
+
try {
|
|
72
|
+
const result = await executeOp(p.op as string, realGh, cwd, p as never, signal);
|
|
73
|
+
const content: Array<{ type: "text"; text: string } | { type: "image"; data: string; mimeType: string }> = [
|
|
74
|
+
{ type: "text", text: result.text },
|
|
75
|
+
];
|
|
76
|
+
if (result.image) {
|
|
77
|
+
content.push({ type: "image", data: result.image.data, mimeType: result.image.mimeType });
|
|
78
|
+
}
|
|
79
|
+
return { content, details: { op: p.op, repo: p.repo } };
|
|
80
|
+
} catch (err) {
|
|
81
|
+
return { content: [{ type: "text", text: err instanceof Error ? err.message : String(err) }], isError: true, details: undefined };
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
defaultActive: !disabled.has("github"),
|
|
85
|
+
});
|
|
86
|
+
}
|