@firstpick/pi-package-webui 0.10.1 → 0.10.2
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/DEVELOPMENT.md +13 -19
- package/README.md +3 -3
- package/TECHNICAL.md +2 -2
- package/bin/pi-webui.mjs +21 -56
- package/index.ts +1 -256
- package/package.json +1 -1
- package/tests/guided-git-activation-static.test.mjs +8 -1
- package/tests/guided-git-fallback-runtime.test.mjs +46 -21
- package/tests/guided-git-fallback-ui-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +3 -2
- package/tests/resource-tui-extension.test.mjs +4 -18
- package/lib/tui-model-profile-selector.mjs +0 -183
- package/lib/tui-resource-selector.mjs +0 -173
- package/tests/tui-model-profile-selector.test.mjs +0 -102
- package/tests/tui-resource-selector.test.mjs +0 -74
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
-
import { TuiModelProfileSelectorComponent } from "../lib/tui-model-profile-selector.mjs";
|
|
4
|
-
|
|
5
|
-
const theme = {
|
|
6
|
-
fg: (_color, text) => text,
|
|
7
|
-
bold: (text) => text,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
function createSelector(config) {
|
|
11
|
-
const selected = [];
|
|
12
|
-
let cancelled = 0;
|
|
13
|
-
const selector = new TuiModelProfileSelectorComponent(
|
|
14
|
-
{
|
|
15
|
-
title: "Tools Model Profile",
|
|
16
|
-
subtitle: "Choose a profile to edit. This does not switch the active model.",
|
|
17
|
-
configuredModelKeys: [],
|
|
18
|
-
...config,
|
|
19
|
-
},
|
|
20
|
-
theme,
|
|
21
|
-
{
|
|
22
|
-
onSelect: (model) => selected.push(model),
|
|
23
|
-
onCancel: () => cancelled++,
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
return { selector, selected, cancelled: () => cancelled };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
33
|
-
provider: index % 2 === 0 ? "alpha" : "beta",
|
|
34
|
-
id: `model-${String(index).padStart(2, "0")}`,
|
|
35
|
-
name: `Model ${index}`,
|
|
36
|
-
}));
|
|
37
|
-
const active = models[12];
|
|
38
|
-
const { selector, selected } = createSelector({
|
|
39
|
-
models,
|
|
40
|
-
activeModelKey: `${active.provider}\0${active.id}`,
|
|
41
|
-
configuredModelKeys: [`${active.provider}\0${active.id}`],
|
|
42
|
-
});
|
|
43
|
-
const rendered = selector.render(120).join("\n");
|
|
44
|
-
assert.match(rendered, /model-12 \[alpha\] \[active\] \[profile\]/, "the picker should open around the active model and mark configured profiles");
|
|
45
|
-
assert.match(rendered, /Model Name: Model 12 · Profile: configured/);
|
|
46
|
-
|
|
47
|
-
selector.handleInput("\x1b[B");
|
|
48
|
-
selector.handleInput("\r");
|
|
49
|
-
assert.equal(selected[0], models[13], "selection should return the exact model object rather than decoding its label");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
54
|
-
provider: "alpha",
|
|
55
|
-
id: `model-${String(index).padStart(2, "0")}`,
|
|
56
|
-
name: `Model ${index}`,
|
|
57
|
-
}));
|
|
58
|
-
const active = models[12];
|
|
59
|
-
const { selector, selected } = createSelector({ models, activeModelKey: `${active.provider}\0${active.id}` });
|
|
60
|
-
for (const character of "model-00") selector.handleInput(character);
|
|
61
|
-
selector.handleInput("\r");
|
|
62
|
-
assert.equal(selected[0], models[0], "a narrowing search should select its first match instead of retaining a stale list index");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
const models = [
|
|
67
|
-
{ provider: "alpha", id: "shared-a", name: "Shared Model" },
|
|
68
|
-
{ provider: "beta", id: "shared-b", name: "Shared Model" },
|
|
69
|
-
{ provider: "gamma", id: "other", name: "Other" },
|
|
70
|
-
];
|
|
71
|
-
const { selector, selected } = createSelector({ models, activeModelKey: "" });
|
|
72
|
-
for (const character of "beta") selector.handleInput(character);
|
|
73
|
-
assert.equal(selector.getSearchInput().getValue(), "beta");
|
|
74
|
-
assert.doesNotMatch(selector.render(100).join("\n"), /\[alpha\]/);
|
|
75
|
-
selector.handleInput("\r");
|
|
76
|
-
assert.equal(selected[0], models[1], "provider search should disambiguate models with the same display name");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
const { selector, cancelled } = createSelector({
|
|
81
|
-
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
82
|
-
activeModelKey: "",
|
|
83
|
-
});
|
|
84
|
-
for (const character of "missing") selector.handleInput(character);
|
|
85
|
-
assert.match(selector.render(100).join("\n"), /No matching models/);
|
|
86
|
-
selector.handleInput("\x03");
|
|
87
|
-
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear search before cancelling");
|
|
88
|
-
assert.equal(cancelled(), 0);
|
|
89
|
-
selector.handleInput("\x03");
|
|
90
|
-
assert.equal(cancelled(), 1);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
const { selector, cancelled } = createSelector({
|
|
95
|
-
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
96
|
-
activeModelKey: "",
|
|
97
|
-
});
|
|
98
|
-
selector.handleInput("\x1b");
|
|
99
|
-
assert.equal(cancelled(), 1, "Escape should cancel model profile selection");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
console.log("tui-model-profile-selector.test.mjs passed");
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
-
import { TuiResourceSelectorComponent } from "../lib/tui-resource-selector.mjs";
|
|
4
|
-
|
|
5
|
-
const theme = {
|
|
6
|
-
fg: (_color, text) => text,
|
|
7
|
-
bold: (text) => text,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
function createSelector(enabledResourceNames = ["alpha", "gamma"]) {
|
|
11
|
-
const saved = [];
|
|
12
|
-
let cancelled = 0;
|
|
13
|
-
const selector = new TuiResourceSelectorComponent(
|
|
14
|
-
{
|
|
15
|
-
title: "Tools Configuration",
|
|
16
|
-
subtitle: "Session only. Changes apply only after Ctrl+S.",
|
|
17
|
-
resources: ["alpha", "beta", "gamma"],
|
|
18
|
-
enabledResourceNames,
|
|
19
|
-
},
|
|
20
|
-
theme,
|
|
21
|
-
{
|
|
22
|
-
onSave: (selection) => saved.push(selection),
|
|
23
|
-
onCancel: () => cancelled++,
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
return { selector, saved, cancelled: () => cancelled };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
const { selector, saved } = createSelector();
|
|
33
|
-
selector.handleInput("\x1b[B");
|
|
34
|
-
selector.handleInput("\r");
|
|
35
|
-
assert.match(selector.render(100).join("\n"), /3\/3 enabled.*\(unsaved\)/);
|
|
36
|
-
selector.handleInput("\x13");
|
|
37
|
-
assert.deepEqual(saved, [["alpha", "beta", "gamma"]], "Ctrl+S should save the current explicit selection");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
const { selector, saved } = createSelector();
|
|
42
|
-
selector.handleInput("b");
|
|
43
|
-
selector.handleInput("e");
|
|
44
|
-
assert.equal(selector.getSearchInput().getValue(), "be");
|
|
45
|
-
assert.doesNotMatch(selector.render(100).join("\n"), /alpha/);
|
|
46
|
-
|
|
47
|
-
selector.handleInput("\x18");
|
|
48
|
-
selector.handleInput("\x13");
|
|
49
|
-
assert.deepEqual(saved.at(-1), ["alpha", "gamma"], "Ctrl+X should clear only resources matching the active search");
|
|
50
|
-
|
|
51
|
-
selector.handleInput("\x01");
|
|
52
|
-
selector.handleInput("\x13");
|
|
53
|
-
assert.deepEqual(saved.at(-1), ["alpha", "beta", "gamma"], "Ctrl+A should enable only resources matching the active search");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
const { selector, cancelled } = createSelector();
|
|
58
|
-
selector.handleInput("z");
|
|
59
|
-
selector.handleInput("z");
|
|
60
|
-
assert.match(selector.render(100).join("\n"), /No matching resources/);
|
|
61
|
-
selector.handleInput("\x03");
|
|
62
|
-
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear a non-empty search before cancelling");
|
|
63
|
-
assert.equal(cancelled(), 0);
|
|
64
|
-
selector.handleInput("\x03");
|
|
65
|
-
assert.equal(cancelled(), 1, "Ctrl+C on an empty search should cancel");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
const { selector, cancelled } = createSelector();
|
|
70
|
-
selector.handleInput("\x1b");
|
|
71
|
-
assert.equal(cancelled(), 1, "Escape should cancel without saving");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log("tui-resource-selector.test.mjs passed");
|