ceulen 0.1.0 → 0.5.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 +150 -0
- package/README.md +103 -14
- package/extensions/index.ts +113 -0
- package/extensions/lib/env.ts +75 -0
- package/extensions/lib/panel.ts +1720 -0
- package/extensions/lib/registry.ts +182 -0
- package/extensions/modules/composer/index.ts +128 -0
- package/extensions/modules/composer/lib/settings.ts +55 -0
- package/extensions/modules/composer/lib/shapes.ts +436 -0
- package/extensions/modules/composer/test/editor.test.ts +138 -0
- package/extensions/modules/composer/test/module.test.ts +218 -0
- package/extensions/modules/composer/test/screen.test.ts +195 -0
- package/extensions/modules/composer/test/shapes.test.ts +175 -0
- package/extensions/modules/config/index.ts +298 -0
- package/extensions/modules/config/piSettings.ts +467 -0
- package/extensions/modules/config/plugins.ts +290 -0
- package/extensions/modules/config/test/kernel.test.ts +523 -0
- package/extensions/modules/config/test/kernelV4.test.ts +196 -0
- package/extensions/modules/config/test/menu.test.ts +226 -0
- package/extensions/modules/config/test/panel.test.ts +395 -0
- package/extensions/modules/config/test/piSettings.test.ts +185 -0
- package/extensions/modules/config/test/plugins.test.ts +181 -0
- package/extensions/modules/config/test/preview-block.test.ts +88 -0
- package/extensions/modules/ponytail/UPSTREAM +26 -0
- package/extensions/modules/ponytail/index.ts +336 -0
- package/extensions/modules/ponytail/lib/config.ts +149 -0
- package/extensions/modules/ponytail/lib/instructions.ts +98 -0
- package/extensions/modules/ponytail/lib/subagent.ts +31 -0
- package/extensions/modules/ponytail/test/extension.test.ts +422 -0
- package/extensions/modules/ponytail/test/helpers.test.ts +163 -0
- package/extensions/modules/ponytail/test/subagent.test.ts +33 -0
- package/extensions/modules/router/commands/commands.ts +99 -0
- package/extensions/modules/router/configPanel.ts +89 -0
- package/extensions/modules/router/index.ts +75 -0
- package/extensions/modules/router/lib/client.ts +390 -0
- package/extensions/modules/router/lib/config.ts +142 -0
- package/extensions/modules/router/lib/migrate.ts +92 -0
- package/extensions/modules/router/lib/provider.ts +138 -0
- package/extensions/modules/router/lib/refresh.ts +19 -0
- package/extensions/modules/router/test/guard.test.ts +77 -0
- package/extensions/modules/router/test/unit.test.ts +1126 -0
- package/extensions/modules/usage/index.ts +1975 -0
- package/extensions/modules/usage/test/context.test.ts +387 -0
- package/extensions/modules/usage/test/env-gating.test.ts +113 -0
- package/extensions/modules/usage/test/opencode-go-usage.test.ts +139 -0
- package/extensions/modules/usage/test/parsers.test.ts +244 -0
- package/extensions/modules/usage/test/stale-ctx-regression.test.ts +294 -0
- package/extensions/modules/usage/test/zai-anthropic-adapter.test.ts +40 -0
- package/package.json +15 -3
- package/skills/ponytail/SKILL.md +124 -0
- package/skills/ponytail-audit/SKILL.md +41 -0
- package/skills/ponytail-debt/SKILL.md +44 -0
- package/skills/ponytail-gain/SKILL.md +51 -0
- package/skills/ponytail-help/SKILL.md +73 -0
- package/skills/ponytail-review/SKILL.md +57 -0
- package/extensions/index.js +0 -42
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel v4 tests — OMP-parity chrome: boxed frame, pinned sidebar width,
|
|
3
|
+
* in-pane underlined headings beside the sidebar, tab-derived footer hints,
|
|
4
|
+
* changed/selected colors, responsive sidebar hide, tab-bar compaction.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it } from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
10
|
+
import { ConfigPanelModel, row, type PanelGroup } from "../../../lib/panel.js";
|
|
11
|
+
|
|
12
|
+
const ANSI = {
|
|
13
|
+
accent: "\x1b[36m",
|
|
14
|
+
warning: "\x1b[33m",
|
|
15
|
+
dim: "\x1b[2m",
|
|
16
|
+
muted: "\x1b[90m",
|
|
17
|
+
success: "\x1b[32m",
|
|
18
|
+
border: "\x1b[34m",
|
|
19
|
+
text: "",
|
|
20
|
+
reset: "\x1b[0m",
|
|
21
|
+
} as const;
|
|
22
|
+
const theme = {
|
|
23
|
+
fg: (token: string, text: string) => `${ANSI[token as keyof typeof ANSI] ?? ""}${text}${ANSI.reset}`,
|
|
24
|
+
bold: (text: string) => text,
|
|
25
|
+
underline: (text: string) => text,
|
|
26
|
+
};
|
|
27
|
+
// eslint-disable-next-line no-control-regex
|
|
28
|
+
const plain = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
29
|
+
|
|
30
|
+
/** Two tabs, each with sections; Provider's first section label is long
|
|
31
|
+
* enough to pin the sidebar width for BOTH tabs. */
|
|
32
|
+
function sectioned(): PanelGroup[] {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
key: "a1", label: "Very Long Section", tab: "Appearance", icon: "🎨",
|
|
36
|
+
rows: [row("a.one", "One", "toggle", true, () => {}, { defaultValue: true })],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "a2", label: "Short", tab: "Appearance",
|
|
40
|
+
rows: [row("a.two", "Two", "toggle", true, () => {}, { defaultValue: true })],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "p1", label: "Router", tab: "Providers", icon: "🌐",
|
|
44
|
+
rows: [row("p.one", "Endpoint", "string", "http://x", () => {}, { defaultValue: "" })],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const model = (g: PanelGroup[] = sectioned(), height = 40) => {
|
|
50
|
+
const m = new ConfigPanelModel(g, theme, "Settings");
|
|
51
|
+
m.getHeight = () => height;
|
|
52
|
+
return m;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
describe("kernel v4 — boxed frame", () => {
|
|
56
|
+
it("draws rounded corners, tee dividers and boxed content rows", () => {
|
|
57
|
+
const out = model().render(100).map(plain);
|
|
58
|
+
assert.ok(out[0]!.startsWith("╭") && out[0]!.endsWith("╮"), "rounded top");
|
|
59
|
+
assert.ok(out.at(-1)!.startsWith("╰") && out.at(-1)!.endsWith("╯"), "rounded bottom");
|
|
60
|
+
const dividers = out.filter((l) => l.startsWith("├"));
|
|
61
|
+
assert.equal(dividers.length, 2, "two tee dividers (tab row, description)");
|
|
62
|
+
assert.ok(dividers.every((l) => l.endsWith("┤")), "dividers end in tees");
|
|
63
|
+
for (const line of out.slice(1, -1)) {
|
|
64
|
+
if (line.startsWith("├")) continue;
|
|
65
|
+
assert.ok(line.startsWith("│") && line.endsWith("│"), `boxed row: ${JSON.stringify(line)}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("never exceeds the width at any size", () => {
|
|
70
|
+
for (const w of [100, 80, 61, 60, 40, 21]) {
|
|
71
|
+
for (const line of model().render(w)) {
|
|
72
|
+
assert.ok(visibleWidth(line) <= w, `line wider than ${w}: ${JSON.stringify(line)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("kernel v4 — pinned sidebar", () => {
|
|
79
|
+
it("keeps the divider column identical across tabs", () => {
|
|
80
|
+
const m = model();
|
|
81
|
+
const colOf = (line: string) => line.indexOf("│ ", line.indexOf("│ ") + 1);
|
|
82
|
+
const wide = m.render(100).map(plain);
|
|
83
|
+
const before = wide.find((l) => l.includes("│ ") && l.includes("Very Long Section"))!;
|
|
84
|
+
m.handleInput("\u001b[C"); // switch to Providers
|
|
85
|
+
const after = m.render(100).map(plain);
|
|
86
|
+
const providersRow = after.find((l) => l.includes("Router") && l.includes("│"))!;
|
|
87
|
+
assert.ok(before && providersRow, "both tabs render a rail");
|
|
88
|
+
assert.equal(colOf(before), colOf(providersRow), "sidebar column pinned across tabs");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("hides below a 60-column rows pane and shows in-pane headings instead", () => {
|
|
92
|
+
const wide = model().render(100).map(plain);
|
|
93
|
+
assert.ok(wide.some((l) => l.includes("│ ") && l.includes("Very Long Section")), "sidebar wide");
|
|
94
|
+
const narrow = model().render(61).map(plain);
|
|
95
|
+
assert.ok(narrow.some((l) => l.includes("Very Long Section")), "heading still present");
|
|
96
|
+
// No sidebar rail inside the lines (borders sit at the edges).
|
|
97
|
+
assert.ok(!narrow.some((l) => l.includes("│ ") && l.trimStart().startsWith("│") && l.indexOf("│ ", 2) > 0), "no sidebar rail at 61 cols");
|
|
98
|
+
assert.ok(!narrow.some((l) => l.includes("Very Long Section │")), "no sidebar column");
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("kernel v4 — headings & colors", () => {
|
|
103
|
+
it("renders in-pane section headings even WITH the sidebar (OMP shows both)", () => {
|
|
104
|
+
const out = model().render(100).map(plain);
|
|
105
|
+
// One line carries BOTH the sidebar entry and the in-pane heading:
|
|
106
|
+
// `Very Long Section │ Very Long Section`.
|
|
107
|
+
const both = out.find((l) => (l.match(/Very Long Section/g) ?? []).length === 2);
|
|
108
|
+
assert.ok(both, `sidebar entry + in-pane heading share a line: ${JSON.stringify(out.slice(2, 5))}`);
|
|
109
|
+
// Sections are separated by in-pane headings in document order.
|
|
110
|
+
const order = out.filter((l) => l.includes("Very Long Section") || l.includes("Short"));
|
|
111
|
+
assert.ok(order.length >= 3, "heading + rows for both sections");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("changed beats selected on the VALUE; selected wins the LABEL", () => {
|
|
115
|
+
const g: PanelGroup[] = [{
|
|
116
|
+
key: "x", label: "X",
|
|
117
|
+
rows: [
|
|
118
|
+
row("x.a", "Changed", "string", "now", () => {}, { defaultValue: "before" }),
|
|
119
|
+
row("x.b", "Unchanged", "string", "same", () => {}, { defaultValue: "same" }),
|
|
120
|
+
],
|
|
121
|
+
}];
|
|
122
|
+
const m = model(g);
|
|
123
|
+
const out = m.render(100);
|
|
124
|
+
// Row 0 selected + changed: label accent, value warning.
|
|
125
|
+
const r0 = out.find((l) => l.includes("Changed"))!;
|
|
126
|
+
assert.ok(r0.includes(`${ANSI.accent}Changed`), "selected label accent");
|
|
127
|
+
assert.ok(r0.includes(`${ANSI.warning}now`), "changed value warning");
|
|
128
|
+
// Row 1 unselected + unchanged: plain label, muted value.
|
|
129
|
+
const r1 = out.find((l) => l.includes("Unchanged"))!;
|
|
130
|
+
assert.ok(!r1.includes(`${ANSI.warning}Unchanged`), "unchanged label not warning");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("changed (unselected) also colors the LABEL — OMP's theme fn", () => {
|
|
134
|
+
const g: PanelGroup[] = [{
|
|
135
|
+
key: "x", label: "X",
|
|
136
|
+
rows: [
|
|
137
|
+
row("x.a", "Stable", "string", "same", () => {}, { defaultValue: "same" }),
|
|
138
|
+
row("x.b", "Moved", "string", "now", () => {}, { defaultValue: "before" }),
|
|
139
|
+
],
|
|
140
|
+
}];
|
|
141
|
+
const m = model(g);
|
|
142
|
+
m.handleInput("\u001b[B"); // select "Moved" — no; we want it unselected, so move back
|
|
143
|
+
m.handleInput("\u001b[A");
|
|
144
|
+
const out = m.render(100);
|
|
145
|
+
const r = out.find((l) => l.includes("Moved"))!;
|
|
146
|
+
assert.ok(r.includes(`${ANSI.warning}Moved`), "changed label warning-styled");
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("kernel v4 — tab-derived footer hints", () => {
|
|
151
|
+
it("all-toggle tabs say 'toggle', mixed tabs say 'change'", () => {
|
|
152
|
+
const togglesOnly: PanelGroup[] = [{
|
|
153
|
+
key: "t", label: "T",
|
|
154
|
+
rows: [row("t.a", "A", "toggle", true, () => {})],
|
|
155
|
+
}];
|
|
156
|
+
assert.ok(plain(model(togglesOnly).render(100).at(-2)!).includes("Enter toggle"));
|
|
157
|
+
|
|
158
|
+
const mixed: PanelGroup[] = [{
|
|
159
|
+
key: "t", label: "T",
|
|
160
|
+
rows: [row("t.a", "A", "toggle", true, () => {}), row("t.b", "B", "string", "x", () => {})],
|
|
161
|
+
}];
|
|
162
|
+
assert.ok(plain(model(mixed).render(100).at(-2)!).includes("Enter change"));
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("info-only tabs drop the Enter pair; single-section tabs drop the section jump", () => {
|
|
166
|
+
const infoOnly: PanelGroup[] = [{
|
|
167
|
+
key: "i", label: "I",
|
|
168
|
+
rows: [row("i.a", "Note", "info", "v", () => {})],
|
|
169
|
+
}];
|
|
170
|
+
const hint = plain(model(infoOnly).render(100).at(-2)!);
|
|
171
|
+
assert.ok(!hint.includes("Enter"), `no Enter pair: ${hint}`);
|
|
172
|
+
assert.ok(!hint.includes("section"), "single section → no section jump");
|
|
173
|
+
|
|
174
|
+
const multi = sectioned();
|
|
175
|
+
assert.ok(plain(model(multi).render(100).at(-2)!).includes("section"), "2+ sections → section jump");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe("kernel v4 — tab bar compaction", () => {
|
|
180
|
+
it("keeps the ACTIVE tab's full label while collapsing inactive tabs to icons", () => {
|
|
181
|
+
const g: PanelGroup[] = [
|
|
182
|
+
{ key: "a", label: "Appearance", icon: "🎨", rows: [row("a.x", "X", "toggle", true, () => {})] },
|
|
183
|
+
{ key: "m", label: "Model", icon: "🤖", rows: [row("m.x", "Y", "toggle", true, () => {})] },
|
|
184
|
+
{ key: "i", label: "Interaction", icon: "⌨️", rows: [row("i.x", "Z", "toggle", true, () => {})] },
|
|
185
|
+
{ key: "p", label: "Providers", icon: "🌐", rows: [row("p.x", "W", "toggle", true, () => {})] },
|
|
186
|
+
];
|
|
187
|
+
const m = model(g);
|
|
188
|
+
m.getHeight = () => 24;
|
|
189
|
+
// Narrow enough that not every full label fits.
|
|
190
|
+
const out = m.render(46).map(plain);
|
|
191
|
+
const bar = out.find((l) => l.includes("Appearance"))!;
|
|
192
|
+
assert.ok(bar, "active tab label visible");
|
|
193
|
+
assert.ok(bar.includes("Appearance"), "active keeps its label");
|
|
194
|
+
assert.ok(!bar.includes("Interaction"), "far inactive tabs collapsed to icons");
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel v5 — selection submenu (OMP's select submenu): Enter on a
|
|
3
|
+
* `values`/`menu` row opens an option list with live preview, type-to-filter,
|
|
4
|
+
* Enter commit and Esc-back-with-restore.
|
|
5
|
+
*
|
|
6
|
+
* Positive-identity assertions throughout: every navigation step asserts the
|
|
7
|
+
* row/option it actually landed on (the recurring vacuous-navigation failure
|
|
8
|
+
* mode: a clamped loop that exhausts without ever matching).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it } from "node:test";
|
|
12
|
+
import assert from "node:assert/strict";
|
|
13
|
+
import { ConfigPanelModel, row, type PanelGroup, type PanelRow } from "../../../lib/panel.js";
|
|
14
|
+
|
|
15
|
+
const theme = null;
|
|
16
|
+
const plain = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
17
|
+
|
|
18
|
+
function panel(rows: PanelRow[], title = "T"): ConfigPanelModel {
|
|
19
|
+
const g: PanelGroup[] = [{ key: "s", label: "Section", rows }];
|
|
20
|
+
const m = new ConfigPanelModel(g, theme, title);
|
|
21
|
+
m.getHeight = () => 40;
|
|
22
|
+
return m;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const body = (m: ConfigPanelModel) => m.render(100).slice(3, -13).map(plain).join("\n");
|
|
26
|
+
|
|
27
|
+
describe("kernel v5 — selection submenu", () => {
|
|
28
|
+
it("Enter opens a menu on the current value; ↑/↓ navigate the real options", () => {
|
|
29
|
+
const m = panel([
|
|
30
|
+
row("mode", "Default mode", "string", "lite", () => {}, {
|
|
31
|
+
values: ["off", "lite", "full", "ultra"],
|
|
32
|
+
description: "Intensity for new sessions.",
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
35
|
+
m.handleInput("\r");
|
|
36
|
+
assert.ok(m.menuOpen, "menu open");
|
|
37
|
+
assert.deepEqual(m.menuOptions.map((o) => o.value), ["off", "lite", "full", "ultra"]);
|
|
38
|
+
assert.equal(m.menuIndex, 1, "cursor starts on the current value (lite)");
|
|
39
|
+
m.handleInput("\u001b[B");
|
|
40
|
+
assert.equal(m.menuIndex, 2);
|
|
41
|
+
assert.equal(m.menuOptions[m.menuIndex]!.value, "full", "landed on full");
|
|
42
|
+
m.handleInput("\u001b[A");
|
|
43
|
+
assert.equal(m.menuOptions[m.menuIndex]!.value, "lite", "landed back on lite");
|
|
44
|
+
// Clamps at the ends (OMP SelectList), no wrap.
|
|
45
|
+
m.handleInput("\u001b[A");
|
|
46
|
+
m.handleInput("\u001b[A");
|
|
47
|
+
assert.equal(m.menuOptions[m.menuIndex]!.value, "off", "clamped at the first option");
|
|
48
|
+
for (let i = 0; i < 10; i++) m.handleInput("\u001b[B");
|
|
49
|
+
assert.equal(m.menuOptions[m.menuIndex]!.value, "ultra", "clamped at the last option");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("renders the option list with the cursor, (current) mark and filter line", () => {
|
|
53
|
+
const m = panel([
|
|
54
|
+
row("theme", "Theme", "string", "dark", () => {}, {
|
|
55
|
+
values: ["dark", "light", "nord"],
|
|
56
|
+
description: "Color theme.",
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
m.handleInput("\r");
|
|
60
|
+
const text = body(m);
|
|
61
|
+
for (const v of ["dark", "light", "nord"]) assert.ok(text.includes(v), `option ${v} renders`);
|
|
62
|
+
assert.ok(text.includes("(current)"), "current value marked");
|
|
63
|
+
assert.ok(text.includes("Type to search"), "empty-query hint shown");
|
|
64
|
+
assert.ok(text.includes("›"), "cursor marker");
|
|
65
|
+
assert.ok(plain(m.render(100).at(-2)!).includes("Enter select"), "footer swaps to menu hints");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("keeps the row description in the fixed description area while the menu is open", () => {
|
|
69
|
+
const m = panel([
|
|
70
|
+
row("theme", "Theme", "string", "dark", () => {}, {
|
|
71
|
+
values: ["dark", "light"],
|
|
72
|
+
description: "Theme used when the terminal has a dark background.",
|
|
73
|
+
}),
|
|
74
|
+
]);
|
|
75
|
+
m.handleInput("\r");
|
|
76
|
+
const full = m.render(100).map(plain).join("\n");
|
|
77
|
+
assert.ok(
|
|
78
|
+
full.includes("Theme used when the terminal has a dark background."),
|
|
79
|
+
"row description still rendered below the menu",
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("Enter commits: set + dirty + editedKeys; Esc cancels without dirty", () => {
|
|
84
|
+
const cfg = { mode: "full" };
|
|
85
|
+
const m = panel([
|
|
86
|
+
row("mode", "Default mode", "string", cfg.mode, (v) => { cfg.mode = String(v); }, {
|
|
87
|
+
values: ["off", "lite", "full", "ultra"],
|
|
88
|
+
}),
|
|
89
|
+
]);
|
|
90
|
+
m.handleInput("\r");
|
|
91
|
+
m.handleInput("\u001b[B"); // ultra
|
|
92
|
+
m.handleInput("\r");
|
|
93
|
+
assert.equal(cfg.mode, "ultra", "committed value");
|
|
94
|
+
assert.ok(m.dirty);
|
|
95
|
+
assert.ok(m.editedKeys.has("mode"));
|
|
96
|
+
assert.equal(m.menuOpen, false);
|
|
97
|
+
|
|
98
|
+
// Re-open on the committed value, pick the same one → no extra write.
|
|
99
|
+
const m2 = panel([
|
|
100
|
+
row("mode", "Default mode", "string", cfg.mode, () => { throw new Error("must not set same value"); }, {
|
|
101
|
+
values: ["off", "lite", "full", "ultra"],
|
|
102
|
+
}),
|
|
103
|
+
]);
|
|
104
|
+
m2.handleInput("\r");
|
|
105
|
+
assert.equal(m2.menuIndex, 3, "cursor on ultra");
|
|
106
|
+
m2.handleInput("\r");
|
|
107
|
+
assert.equal(m2.dirty, false, "same-value pick writes nothing");
|
|
108
|
+
|
|
109
|
+
// Esc cancels: value untouched, not dirty.
|
|
110
|
+
const m3 = panel([
|
|
111
|
+
row("mode", "Default mode", "string", "full", () => { throw new Error("must not set on cancel"); }, {
|
|
112
|
+
values: ["off", "lite", "full", "ultra"],
|
|
113
|
+
}),
|
|
114
|
+
]);
|
|
115
|
+
m3.handleInput("\r");
|
|
116
|
+
m3.handleInput("\u001b[B");
|
|
117
|
+
m3.handleInput("\u001b");
|
|
118
|
+
assert.equal(m3.menuOpen, false);
|
|
119
|
+
assert.equal(m3.dirty, false, "cancel never dirties");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("preview fires on every highlighted option; Esc fires previewCancel once", () => {
|
|
123
|
+
const seen: string[] = [];
|
|
124
|
+
let cancels = 0;
|
|
125
|
+
const m = panel([
|
|
126
|
+
row("theme", "Theme", "string", "dark", () => {}, {
|
|
127
|
+
values: ["dark", "light", "nord"],
|
|
128
|
+
preview: (v) => seen.push(v),
|
|
129
|
+
previewCancel: () => { cancels++; },
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
m.handleInput("\r");
|
|
133
|
+
assert.deepEqual(seen, [], "opening does not preview (no move yet)");
|
|
134
|
+
m.handleInput("\u001b[B"); // light
|
|
135
|
+
m.handleInput("\u001b[B"); // nord
|
|
136
|
+
assert.deepEqual(seen, ["light", "nord"], "preview follows the highlight");
|
|
137
|
+
m.handleInput("\u001b");
|
|
138
|
+
assert.equal(cancels, 1, "Esc fires previewCancel once (row owns the restore)");
|
|
139
|
+
assert.deepEqual(seen, ["light", "nord"], "preview is not re-fired for the original value");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("type-to-filter narrows the options; ⌫ edits; Esc clears then backs out", () => {
|
|
143
|
+
const m = panel([
|
|
144
|
+
row("theme", "Theme", "string", "limestone", () => {}, {
|
|
145
|
+
values: ["limestone", "marble", "obsidian", "quartz", "sandstone"],
|
|
146
|
+
}),
|
|
147
|
+
]);
|
|
148
|
+
m.handleInput("\r");
|
|
149
|
+
assert.equal(m.menuIndex, 0, "current value at index 0");
|
|
150
|
+
m.handleInput("s"); // limestone, obsidian, sandstone
|
|
151
|
+
assert.deepEqual(m.menuOptions.map((o) => o.value), ["limestone", "obsidian", "sandstone"]);
|
|
152
|
+
m.handleInput("a"); // sandstone only
|
|
153
|
+
assert.deepEqual(m.menuOptions.map((o) => o.value), ["sandstone"], "narrowed positively");
|
|
154
|
+
m.handleInput("\u007f"); // ⌫ → "s"
|
|
155
|
+
assert.deepEqual(m.menuOptions.map((o) => o.value), ["limestone", "obsidian", "sandstone"]);
|
|
156
|
+
m.handleInput("\u001b"); // clear query, menu stays
|
|
157
|
+
assert.ok(m.menuOpen, "first Esc cleared the query");
|
|
158
|
+
assert.equal(m.menuOptions.length, 5, "full list back");
|
|
159
|
+
m.handleInput("\u001b"); // back out
|
|
160
|
+
assert.equal(m.menuOpen, false, "second Esc left the menu");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("menu claims every key while open — Tab does not switch tabs beneath it", () => {
|
|
164
|
+
const groupsIn: PanelGroup[] = [
|
|
165
|
+
{ key: "a", label: "A", tab: "A", rows: [row("a.x", "X", "string", "one", () => {}, { values: ["one", "two"] })] },
|
|
166
|
+
{ key: "b", label: "B", tab: "B", rows: [row("b.y", "Y", "toggle", true, () => {})] },
|
|
167
|
+
];
|
|
168
|
+
const m = new ConfigPanelModel(groupsIn, theme, "T");
|
|
169
|
+
m.handleInput("\r");
|
|
170
|
+
assert.ok(m.menuOpen);
|
|
171
|
+
assert.equal(m.activeTab, 0);
|
|
172
|
+
m.handleInput("\t");
|
|
173
|
+
assert.equal(m.activeTab, 0, "Tab swallowed by the menu");
|
|
174
|
+
assert.ok(m.menuOpen, "menu still open");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("dynamic menu() options render as labels with per-option descriptions", () => {
|
|
178
|
+
const m = panel([
|
|
179
|
+
row("model", "Default model", "string", "zai/glm-5", () => {}, {
|
|
180
|
+
menu: () => [
|
|
181
|
+
{ value: "zai/glm-5", label: "zai/glm-5", description: "GLM-5" },
|
|
182
|
+
{ value: "openai/gpt-5", label: "openai/gpt-5", description: "GPT-5" },
|
|
183
|
+
],
|
|
184
|
+
}),
|
|
185
|
+
]);
|
|
186
|
+
m.handleInput("\r");
|
|
187
|
+
assert.deepEqual(m.menuOptions.map((o) => o.value), ["zai/glm-5", "openai/gpt-5"]);
|
|
188
|
+
assert.equal(m.menuIndex, 0, "cursor on the current value");
|
|
189
|
+
const text = body(m);
|
|
190
|
+
assert.ok(text.includes("zai/glm-5 — GLM-5"), "per-option description renders");
|
|
191
|
+
assert.ok(text.includes("openai/gpt-5 — GPT-5"), "second option description renders");
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("an empty menu() falls back to the inline editor (string rows)", () => {
|
|
195
|
+
const m = panel([row("query", "Query", "string", "abc", () => {}, { menu: () => [] })]);
|
|
196
|
+
m.handleInput("\r");
|
|
197
|
+
assert.equal(m.menuOpen, false, "no menu for an empty provider");
|
|
198
|
+
assert.ok(m.render(100).some((l) => plain(l).includes("abc")), "inline editor took over");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("menu window follows the cursor through a long list (positive identity)", () => {
|
|
202
|
+
const values = Array.from({ length: 60 }, (_, i) => `opt-${String(i).padStart(2, "0")}`);
|
|
203
|
+
const m = panel([row("k", "Long", "string", "opt-00", () => {}, { values })]);
|
|
204
|
+
m.handleInput("\r");
|
|
205
|
+
for (let i = 0; i < 25; i++) m.handleInput("\u001b[B");
|
|
206
|
+
assert.equal(m.menuOptions[m.menuIndex]!.value, "opt-25", "cursor advanced 25 steps");
|
|
207
|
+
const text = body(m);
|
|
208
|
+
assert.ok(text.includes("opt-25"), "cursor row visible");
|
|
209
|
+
assert.ok(!text.includes("opt-00"), "window scrolled past the first option");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("commit closes the menu and re-renders the rows pane with the new value", () => {
|
|
213
|
+
const m = panel([
|
|
214
|
+
row("mode", "Default mode", "string", "lite", () => {}, {
|
|
215
|
+
values: ["off", "lite", "full"],
|
|
216
|
+
description: "Intensity for new sessions.",
|
|
217
|
+
}),
|
|
218
|
+
]);
|
|
219
|
+
m.handleInput("\r");
|
|
220
|
+
m.handleInput("\u001b[B"); // full
|
|
221
|
+
m.handleInput("\r");
|
|
222
|
+
const text = m.render(100).map(plain).join("\n");
|
|
223
|
+
assert.ok(text.includes("Default mode") && text.includes("full"), "rows pane back with committed value");
|
|
224
|
+
assert.ok(!text.includes("Type to search"), "menu chrome gone");
|
|
225
|
+
});
|
|
226
|
+
});
|