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,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi core settings contribution to the central /config panel.
|
|
3
|
+
*
|
|
4
|
+
* Rows are backed by pi's OWN public `SettingsManager` (exported from the
|
|
5
|
+
* package root): typed getters return effective values (global ⊕ project),
|
|
6
|
+
* typed setters persist to the GLOBAL settings.json with pi's own layering,
|
|
7
|
+
* locking and atomic-write logic, and `flush()` drains the write queue before
|
|
8
|
+
* the panel reports success. Only settings WITH a typed setter are surfaced —
|
|
9
|
+
* fields like `externalEditor`, `sessionDir`, `defaultTools` or
|
|
10
|
+
* `branchSummary.*` remain config-file-only rather than duplicate
|
|
11
|
+
* SettingsManager's persistence by hand.
|
|
12
|
+
*
|
|
13
|
+
* Tab/section names follow OMP's settings taxonomy (Appearance, Model,
|
|
14
|
+
* Interaction, Context, Shell, …) so ceulen modules and pi core settings read
|
|
15
|
+
* as one system; tabs with no settable rows are omitted.
|
|
16
|
+
*
|
|
17
|
+
* Everything a row writes needs /reload (or a new session) to be picked up by
|
|
18
|
+
* the running process — pi's live SettingsManager is a different instance, and
|
|
19
|
+
* even the Model row only persists the DEFAULT (new sessions): a live model
|
|
20
|
+
* switch requires the session's own setModel() (agent-session.js), which the
|
|
21
|
+
* public extension API doesn't expose. The ONE exception is the Theme row when
|
|
22
|
+
* the /config command supplies a PiMenuLookup: it previews/commits through
|
|
23
|
+
* ctx.ui.setTheme, which applies to the running session immediately.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
27
|
+
import { row, type PanelGroup, type PanelMenuOption } from "../../lib/panel.js";
|
|
28
|
+
|
|
29
|
+
/** pi's thinking levels (core/defaults.ts THINKING_LEVEL_OPTIONS). */
|
|
30
|
+
const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
31
|
+
|
|
32
|
+
/** pi's transports (pi-ai types). */
|
|
33
|
+
const TRANSPORTS = ["auto", "sse", "websocket", "websocket-cached"] as const;
|
|
34
|
+
const TUI_MODES = ["regular", "fullscreen"] as const;
|
|
35
|
+
const FULLSCREEN_EXIT = ["transcript", "resume-hint"] as const;
|
|
36
|
+
const FULLSCREEN_SCROLLBAR = ["hidden", "auto", "always"] as const;
|
|
37
|
+
const MERMAID_MODES = ["off", "final", "streaming"] as const;
|
|
38
|
+
const CACHE_WARMING = ["streaming", "off", "idle"] as const;
|
|
39
|
+
const STEERING_MODES = ["one-at-a-time", "all"] as const;
|
|
40
|
+
const DOUBLE_ESCAPE = ["tree", "fork", "none"] as const;
|
|
41
|
+
const TREE_FILTERS = ["default", "no-tools", "user-only", "labeled-only", "all"] as const;
|
|
42
|
+
const PROJECT_TRUST = ["ask", "always", "never"] as const;
|
|
43
|
+
const OUTPUT_PADS = ["1", "0"] as const;
|
|
44
|
+
|
|
45
|
+
/** One declarative row spec over the manager (order defines render order). */
|
|
46
|
+
interface PiRowSpec {
|
|
47
|
+
key: string;
|
|
48
|
+
tab: string;
|
|
49
|
+
section: string;
|
|
50
|
+
label: string;
|
|
51
|
+
kind: "toggle" | "string" | "number";
|
|
52
|
+
value: unknown;
|
|
53
|
+
values?: readonly string[];
|
|
54
|
+
menu?: () => PanelMenuOption[];
|
|
55
|
+
preview?: (value: string) => void;
|
|
56
|
+
previewCancel?: () => void;
|
|
57
|
+
defaultValue?: unknown;
|
|
58
|
+
description: string;
|
|
59
|
+
warning?: string;
|
|
60
|
+
set(v: unknown): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const str = (v: unknown): string => (v === undefined || v === null ? "" : String(v));
|
|
64
|
+
const joinedList = (v: unknown): string => (Array.isArray(v) ? v.join(" ") : "");
|
|
65
|
+
const splitList = (v: unknown): string[] | undefined => {
|
|
66
|
+
const parts = str(v).trim().split(/[\s,]+/).filter(Boolean);
|
|
67
|
+
return parts.length > 0 ? parts : undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Wrap a numeric setter: the panel's number rows pass the raw typed text
|
|
71
|
+
* through (`kindValue` returns the string when it does not parse), and some
|
|
72
|
+
* SettingsManager setters THROW on non-finite input — a throw here would
|
|
73
|
+
* escape the panel's input handler. Ignore unparseable values (the row keeps
|
|
74
|
+
* its previous value). */
|
|
75
|
+
const num = (fn: (n: number) => void) => (v: unknown): void => {
|
|
76
|
+
const n = Number(v);
|
|
77
|
+
if (Number.isFinite(n)) fn(n);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Runtime lookups the /config command supplies from its ExtensionContext —
|
|
81
|
+
* the only panel data that does NOT come from a SettingsManager. Absent in
|
|
82
|
+
* tests and headless `show` paths, in which case the affected rows stay plain
|
|
83
|
+
* text rows. */
|
|
84
|
+
export interface PiMenuLookup {
|
|
85
|
+
/** Available theme names (ctx.ui.getAllThemes). */
|
|
86
|
+
themes?(): string[];
|
|
87
|
+
/** Apply a theme LIVE without persisting (ctx.ui.setTheme with a Theme
|
|
88
|
+
* instance — settings.json stays untouched while browsing). Captures the
|
|
89
|
+
* theme that was live so `restoreTheme` can undo the preview. */
|
|
90
|
+
previewTheme?(name: string): void;
|
|
91
|
+
/** Undo the last theme preview (restore the captured instance). */
|
|
92
|
+
restoreTheme?(): void;
|
|
93
|
+
/** Apply a theme LIVE and persist it (ctx.ui.setTheme with the name). */
|
|
94
|
+
applyTheme?(name: string): void;
|
|
95
|
+
/** Model catalog entries for the Default model row (ctx.modelRegistry
|
|
96
|
+
* .getAvailable), rendered as `provider/id`. */
|
|
97
|
+
models?(): { provider: string; id: string; description?: string }[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The Default model row value: `provider/id` (either half alone renders as
|
|
101
|
+
* itself so a half-configured pair stays visible). */
|
|
102
|
+
const modelValue = (m: SettingsManager): string => {
|
|
103
|
+
const p = str(m.getDefaultProvider());
|
|
104
|
+
const id = str(m.getDefaultModel());
|
|
105
|
+
return p && id ? `${p}/${id}` : (id || p);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** Split a `provider/id` menu value; undefined for malformed input (the
|
|
109
|
+
* setter then keeps the previous value instead of writing garbage). */
|
|
110
|
+
const splitModel = (v: unknown): { provider: string; id: string } | undefined => {
|
|
111
|
+
const s = str(v);
|
|
112
|
+
const at = s.indexOf("/");
|
|
113
|
+
if (at <= 0 || at === s.length - 1) return undefined;
|
|
114
|
+
return { provider: s.slice(0, at), id: s.slice(at + 1) };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** Every pi-core setting the panel surfaces, mapped into OMP's tabs. */
|
|
118
|
+
function piRowSpecs(m: SettingsManager, lookup?: PiMenuLookup): PiRowSpec[] {
|
|
119
|
+
return [
|
|
120
|
+
// ── Appearance ────────────────────────────────────────────────────────
|
|
121
|
+
{
|
|
122
|
+
key: "pi.theme", tab: "Appearance", section: "Theme", label: "Theme",
|
|
123
|
+
kind: "string", value: str(m.getThemeSetting()),
|
|
124
|
+
description: lookup
|
|
125
|
+
? "Color theme for the session. Browse themes with ↑/↓ to preview live; Enter selects."
|
|
126
|
+
: "Name of the color theme (see /theme). Applies after /reload.",
|
|
127
|
+
...(lookup?.themes
|
|
128
|
+
? {
|
|
129
|
+
// Lazy: theme lists are read at open time (and may be empty —
|
|
130
|
+
// openMenu then falls back to the inline editor).
|
|
131
|
+
menu: () => {
|
|
132
|
+
const names = lookup.themes?.() ?? [];
|
|
133
|
+
const cur = str(m.getThemeSetting());
|
|
134
|
+
const all = cur && !names.includes(cur) ? [cur, ...names] : names;
|
|
135
|
+
return all.map((n) => ({ value: n, label: n }));
|
|
136
|
+
},
|
|
137
|
+
preview: (v: string) => lookup.previewTheme?.(v),
|
|
138
|
+
// Esc: undo the live preview (OMP's onPreviewCancel) — the lookup
|
|
139
|
+
// captured the pre-browse theme on the first preview.
|
|
140
|
+
previewCancel: () => lookup.restoreTheme?.(),
|
|
141
|
+
// Commit: persist through the panel's own manager (flushed on
|
|
142
|
+
// save) AND live-apply + persist via ctx.ui — the preview hook is
|
|
143
|
+
// not fired on commit (kernel contract), so the row's set owns
|
|
144
|
+
// the live apply.
|
|
145
|
+
set: (v: unknown) => {
|
|
146
|
+
m.setTheme(str(v));
|
|
147
|
+
lookup.applyTheme?.(str(v));
|
|
148
|
+
},
|
|
149
|
+
}
|
|
150
|
+
: { set: (v: unknown) => m.setTheme(str(v)) }),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
key: "pi.markdown.mermaid", tab: "Appearance", section: "Display", label: "Mermaid diagrams",
|
|
154
|
+
kind: "string", value: m.getMermaidRenderingMode(), values: MERMAID_MODES, defaultValue: "streaming",
|
|
155
|
+
description: "How mermaid diagrams in responses are rendered.",
|
|
156
|
+
set: (v) => m.setMermaidRenderingMode(str(v) as never),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
key: "pi.terminal.showTerminalProgress", tab: "Appearance", section: "Display", label: "Terminal progress",
|
|
160
|
+
kind: "toggle", value: m.getShowTerminalProgress(), defaultValue: false,
|
|
161
|
+
description: "Report progress to the terminal's native progress protocol.",
|
|
162
|
+
set: (v) => m.setShowTerminalProgress(Boolean(v)),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
key: "pi.terminal.clearOnShrink", tab: "Appearance", section: "Display", label: "Clear on shrink",
|
|
166
|
+
kind: "toggle", value: m.getClearOnShrink(), defaultValue: false,
|
|
167
|
+
description: "Clear stale lines when the terminal shrinks. PI_CLEAR_ON_SHRINK env overrides.",
|
|
168
|
+
set: (v) => m.setClearOnShrink(Boolean(v)),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: "pi.showHardwareCursor", tab: "Appearance", section: "Editor", label: "Show hardware cursor",
|
|
172
|
+
kind: "toggle", value: m.getShowHardwareCursor(), defaultValue: false,
|
|
173
|
+
description: "Show the terminal's real cursor in the editor. PI_HARDWARE_CURSOR env overrides.",
|
|
174
|
+
set: (v) => m.setShowHardwareCursor(Boolean(v)),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
key: "pi.editorPaddingX", tab: "Appearance", section: "Editor", label: "Editor padding",
|
|
178
|
+
kind: "number", value: m.getEditorPaddingX(), defaultValue: 0,
|
|
179
|
+
description: "Horizontal editor padding in columns (0–3).",
|
|
180
|
+
set: num((n) => m.setEditorPaddingX(n)),
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "pi.outputPad", tab: "Appearance", section: "Editor", label: "Output padding",
|
|
184
|
+
kind: "string", value: String(m.getOutputPad()), values: OUTPUT_PADS, defaultValue: "1",
|
|
185
|
+
description: "Add a blank line between output blocks.",
|
|
186
|
+
set: (v) => m.setOutputPad(Number(v) === 0 ? 0 : 1),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
key: "pi.autocompleteMaxVisible", tab: "Appearance", section: "Editor", label: "Autocomplete max items",
|
|
190
|
+
kind: "number", value: m.getAutocompleteMaxVisible(), defaultValue: 5,
|
|
191
|
+
description: "Most completion rows shown at once (3–20).",
|
|
192
|
+
set: num((n) => m.setAutocompleteMaxVisible(n)),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "pi.tuiMode", tab: "Appearance", section: "Fullscreen", label: "TUI mode",
|
|
196
|
+
kind: "string", value: m.getTuiMode(), values: TUI_MODES, defaultValue: "regular",
|
|
197
|
+
description: "Regular scrolling transcript or the alternate-screen fullscreen UI.",
|
|
198
|
+
set: (v) => m.setTuiMode(str(v) as never),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "pi.fullscreenExitOutput", tab: "Appearance", section: "Fullscreen", label: "Fullscreen exit output",
|
|
202
|
+
kind: "string", value: m.getFullscreenExitOutput(), values: FULLSCREEN_EXIT, defaultValue: "transcript",
|
|
203
|
+
description: "What the alternate screen leaves behind on exit.",
|
|
204
|
+
set: (v) => m.setFullscreenExitOutput(str(v) as never),
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
key: "pi.fullscreenScrollbar", tab: "Appearance", section: "Fullscreen", label: "Fullscreen scrollbar",
|
|
208
|
+
kind: "string", value: m.getFullscreenScrollbar(), values: FULLSCREEN_SCROLLBAR, defaultValue: "auto",
|
|
209
|
+
description: "Scrollbar visibility in fullscreen mode.",
|
|
210
|
+
set: (v) => m.setFullscreenScrollbar(str(v) as never),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: "pi.fullscreenCopyOnSelect", tab: "Appearance", section: "Fullscreen", label: "Copy on select",
|
|
214
|
+
kind: "toggle", value: m.getFullscreenCopyOnSelect(), defaultValue: true,
|
|
215
|
+
description: "Copy selected text in fullscreen mode automatically.",
|
|
216
|
+
set: (v) => m.setFullscreenCopyOnSelect(Boolean(v)),
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: "pi.terminal.showImages", tab: "Appearance", section: "Images", label: "Show images",
|
|
220
|
+
kind: "toggle", value: m.getShowImages(), defaultValue: true,
|
|
221
|
+
description: "Render images inline in the terminal.",
|
|
222
|
+
set: (v) => m.setShowImages(Boolean(v)),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
key: "pi.terminal.imageWidthCells", tab: "Appearance", section: "Images", label: "Image width",
|
|
226
|
+
kind: "number", value: m.getImageWidthCells(), defaultValue: 60,
|
|
227
|
+
description: "Preferred inline-image width in terminal cells.",
|
|
228
|
+
set: num((n) => m.setImageWidthCells(n)),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
key: "pi.images.autoResize", tab: "Appearance", section: "Images", label: "Auto-resize images",
|
|
232
|
+
kind: "toggle", value: m.getImageAutoResize(), defaultValue: true,
|
|
233
|
+
description: "Shrink oversized images to the terminal width.",
|
|
234
|
+
set: (v) => m.setImageAutoResize(Boolean(v)),
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
key: "pi.images.blockImages", tab: "Appearance", section: "Images", label: "Block images",
|
|
238
|
+
kind: "toggle", value: m.getBlockImages(), defaultValue: false,
|
|
239
|
+
description: "Refuse to send images to the model.",
|
|
240
|
+
set: (v) => m.setBlockImages(Boolean(v)),
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
// ── Model ─────────────────────────────────────────────────────────────
|
|
244
|
+
{
|
|
245
|
+
key: "pi.defaultModel", tab: "Model", section: "Default model", label: "Default model",
|
|
246
|
+
kind: "string", value: modelValue(m),
|
|
247
|
+
description: lookup?.models
|
|
248
|
+
? "Model for NEW sessions as provider/id (applies after /reload). Enter opens the catalogue picker."
|
|
249
|
+
: "Model id used for new sessions (see /model, which sets provider + id together).",
|
|
250
|
+
...(lookup?.models
|
|
251
|
+
? {
|
|
252
|
+
// Lazy: the catalogue is read at open time (it can refresh).
|
|
253
|
+
menu: () =>
|
|
254
|
+
(lookup.models?.() ?? []).map((e) => ({
|
|
255
|
+
value: `${e.provider}/${e.id}`,
|
|
256
|
+
label: `${e.provider}/${e.id}`,
|
|
257
|
+
...(e.description ? { description: e.description } : {}),
|
|
258
|
+
})),
|
|
259
|
+
set: (v: unknown) => {
|
|
260
|
+
const split = splitModel(v);
|
|
261
|
+
if (!split) return;
|
|
262
|
+
m.setDefaultModelAndProvider(split.provider, split.id);
|
|
263
|
+
},
|
|
264
|
+
}
|
|
265
|
+
: { set: (v: unknown) => m.setDefaultModel(str(v)) }),
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
key: "pi.defaultProvider", tab: "Model", section: "Default model", label: "Default provider",
|
|
269
|
+
kind: "string", value: str(m.getDefaultProvider()),
|
|
270
|
+
description: "Provider id paired with the default model.",
|
|
271
|
+
set: (v) => m.setDefaultProvider(str(v)),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
key: "pi.enabledModels", tab: "Model", section: "Default model", label: "Enabled models",
|
|
275
|
+
kind: "string", value: joinedList(m.getEnabledModels()),
|
|
276
|
+
description: "Space-separated model patterns to scope the session (empty = all models).",
|
|
277
|
+
set: (v) => m.setEnabledModels(splitList(v)),
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "pi.defaultThinkingLevel", tab: "Model", section: "Thinking", label: "Default thinking level",
|
|
281
|
+
kind: "string", value: str(m.getDefaultThinkingLevel() ?? "medium"), values: THINKING_LEVELS, defaultValue: "medium",
|
|
282
|
+
description: "Thinking level for new sessions.",
|
|
283
|
+
set: (v) => m.setDefaultThinkingLevel(str(v) as never),
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
key: "pi.hideThinkingBlock", tab: "Model", section: "Thinking", label: "Hide thinking",
|
|
287
|
+
kind: "toggle", value: m.getHideThinkingBlock(), defaultValue: false,
|
|
288
|
+
description: "Collapse thinking blocks in the transcript.",
|
|
289
|
+
set: (v) => m.setHideThinkingBlock(Boolean(v)),
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
key: "pi.transport", tab: "Model", section: "Network", label: "Transport",
|
|
293
|
+
kind: "string", value: m.getTransport(), values: TRANSPORTS, defaultValue: "auto",
|
|
294
|
+
description: "Streaming transport for provider requests.",
|
|
295
|
+
set: (v) => m.setTransport(str(v) as never),
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
key: "pi.httpIdleTimeoutMs", tab: "Model", section: "Network", label: "HTTP idle timeout",
|
|
299
|
+
kind: "number", value: m.getHttpIdleTimeoutMs(), defaultValue: 300000,
|
|
300
|
+
description: "Drop idle provider connections after this many ms.",
|
|
301
|
+
set: num((n) => m.setHttpIdleTimeoutMs(Math.max(0, n))),
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
key: "pi.retry.enabled", tab: "Model", section: "Retry & Fallback", label: "Retry on failure",
|
|
305
|
+
kind: "toggle", value: m.getRetryEnabled(), defaultValue: true,
|
|
306
|
+
description: "Retry failed provider requests.",
|
|
307
|
+
set: (v) => m.setRetryEnabled(Boolean(v)),
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
key: "pi.cacheWarming", tab: "Model", section: "Efficiency", label: "Cache warming",
|
|
311
|
+
kind: "string", value: m.getCacheWarmingMode(), values: CACHE_WARMING, defaultValue: "streaming",
|
|
312
|
+
description: "Warm the prompt cache during streaming or idle time (costs tokens).",
|
|
313
|
+
set: (v) => m.setCacheWarmingMode(str(v) as never),
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: "pi.showCacheMissNotices", tab: "Model", section: "Efficiency", label: "Cache miss notices",
|
|
317
|
+
kind: "toggle", value: m.getShowCacheMissNotices(), defaultValue: false,
|
|
318
|
+
description: "Show a notice when the prompt cache is missed.",
|
|
319
|
+
set: (v) => m.setShowCacheMissNotices(Boolean(v)),
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "pi.warnings.anthropicExtraUsage", tab: "Model", section: "Warnings", label: "Anthropic extra usage",
|
|
323
|
+
kind: "toggle", value: Boolean(m.getWarnings().anthropicExtraUsage), defaultValue: false,
|
|
324
|
+
description: "Warn when requests bill against extra usage.",
|
|
325
|
+
set: (v) => m.setWarnings({ ...m.getWarnings(), anthropicExtraUsage: Boolean(v) }),
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
// ── Interaction ───────────────────────────────────────────────────────
|
|
329
|
+
{
|
|
330
|
+
key: "pi.steeringMode", tab: "Interaction", section: "Input", label: "Steering mode",
|
|
331
|
+
kind: "string", value: m.getSteeringMode(), values: STEERING_MODES, defaultValue: "one-at-a-time",
|
|
332
|
+
description: "Queue one message at a time or all of them while the agent runs.",
|
|
333
|
+
set: (v) => m.setSteeringMode(str(v) as never),
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
key: "pi.followUpMode", tab: "Interaction", section: "Input", label: "Follow-up mode",
|
|
337
|
+
kind: "string", value: m.getFollowUpMode(), values: STEERING_MODES, defaultValue: "one-at-a-time",
|
|
338
|
+
description: "How follow-up messages queue after a run finishes.",
|
|
339
|
+
set: (v) => m.setFollowUpMode(str(v) as never),
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
key: "pi.doubleEscapeAction", tab: "Interaction", section: "Input", label: "Double-escape action",
|
|
343
|
+
kind: "string", value: m.getDoubleEscapeAction(), values: DOUBLE_ESCAPE, defaultValue: "tree",
|
|
344
|
+
description: "What double-Esc opens: session tree, fork picker, or nothing.",
|
|
345
|
+
set: (v) => m.setDoubleEscapeAction(str(v) as never),
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
key: "pi.treeFilterMode", tab: "Interaction", section: "Input", label: "Tree filter mode",
|
|
349
|
+
kind: "string", value: m.getTreeFilterMode(), values: TREE_FILTERS, defaultValue: "default",
|
|
350
|
+
description: "Default filter for the session tree view.",
|
|
351
|
+
set: (v) => m.setTreeFilterMode(str(v) as never),
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
key: "pi.quietStartup", tab: "Interaction", section: "Startup & Notices", label: "Quiet startup",
|
|
355
|
+
kind: "toggle", value: m.getQuietStartup(), defaultValue: false,
|
|
356
|
+
description: "Skip the startup banner.",
|
|
357
|
+
set: (v) => m.setQuietStartup(Boolean(v)),
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
key: "pi.collapseChangelog", tab: "Interaction", section: "Startup & Notices", label: "Collapse changelog",
|
|
361
|
+
kind: "toggle", value: m.getCollapseChangelog(), defaultValue: false,
|
|
362
|
+
description: "Show the changelog collapsed after an update.",
|
|
363
|
+
set: (v) => m.setCollapseChangelog(Boolean(v)),
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
key: "pi.enableSkillCommands", tab: "Interaction", section: "Startup & Notices", label: "Skill commands",
|
|
367
|
+
kind: "toggle", value: m.getEnableSkillCommands(), defaultValue: true,
|
|
368
|
+
description: "Expose skills as slash commands.",
|
|
369
|
+
set: (v) => m.setEnableSkillCommands(Boolean(v)),
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
key: "pi.defaultProjectTrust", tab: "Interaction", section: "Trust & Telemetry", label: "Default project trust",
|
|
373
|
+
kind: "string", value: m.getDefaultProjectTrust(), values: PROJECT_TRUST, defaultValue: "ask",
|
|
374
|
+
description: "Whether new projects are trusted without asking.",
|
|
375
|
+
warning: "Trusting projects automatically lets their extensions and .env files run.",
|
|
376
|
+
set: (v) => m.setDefaultProjectTrust(str(v) as never),
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
key: "pi.enableInstallTelemetry", tab: "Interaction", section: "Trust & Telemetry", label: "Install telemetry",
|
|
380
|
+
kind: "toggle", value: m.getEnableInstallTelemetry(), defaultValue: true,
|
|
381
|
+
description: "Send anonymous install/update counts.",
|
|
382
|
+
set: (v) => m.setEnableInstallTelemetry(Boolean(v)),
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
key: "pi.enableAnalytics", tab: "Interaction", section: "Trust & Telemetry", label: "Analytics",
|
|
386
|
+
kind: "toggle", value: m.getEnableAnalytics(), defaultValue: false,
|
|
387
|
+
description: "Opt in to anonymous usage analytics (generates a tracking id on first enable).",
|
|
388
|
+
set: (v) => m.setEnableAnalytics(Boolean(v)),
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
// ── Context ───────────────────────────────────────────────────────────
|
|
392
|
+
{
|
|
393
|
+
key: "pi.compaction.enabled", tab: "Context", section: "Compaction", label: "Auto-compact",
|
|
394
|
+
kind: "toggle", value: m.getCompactionEnabled(), defaultValue: true,
|
|
395
|
+
description: "Compact the conversation automatically when it approaches the context limit.",
|
|
396
|
+
set: (v) => m.setCompactionEnabled(Boolean(v)),
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
// ── Shell ─────────────────────────────────────────────────────────────
|
|
400
|
+
{
|
|
401
|
+
key: "pi.shellPath", tab: "Shell", section: "Bash", label: "Shell path",
|
|
402
|
+
kind: "string", value: str(m.getShellPath()),
|
|
403
|
+
description: "Shell binary used for bash tool calls (empty = system default).",
|
|
404
|
+
set: (v) => m.setShellPath(str(v) || undefined),
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
key: "pi.shellCommandPrefix", tab: "Shell", section: "Bash", label: "Command prefix",
|
|
408
|
+
kind: "string", value: str(m.getShellCommandPrefix()),
|
|
409
|
+
description: "Prefix prepended to every bash command (e.g. an env setup snippet).",
|
|
410
|
+
set: (v) => m.setShellCommandPrefix(str(v) || undefined),
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
key: "pi.npmCommand", tab: "Shell", section: "Bash", label: "npm command",
|
|
414
|
+
kind: "string", value: joinedList(m.getNpmCommand()),
|
|
415
|
+
description: "Space-separated npm command override (e.g. a registry mirror wrapper).",
|
|
416
|
+
set: (v) => m.setNpmCommand(splitList(v)),
|
|
417
|
+
},
|
|
418
|
+
];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Build the pi-settings sections, grouped by (tab, section) in spec order.
|
|
422
|
+
* `lookup` (from the /config command's ctx) upgrades the Theme and Default
|
|
423
|
+
* model rows into live selection submenus; without it they stay text rows. */
|
|
424
|
+
export function buildPiSettingsGroups(m: SettingsManager, lookup?: PiMenuLookup): PanelGroup[] {
|
|
425
|
+
const groups: PanelGroup[] = [];
|
|
426
|
+
const byKey = new Map<string, PanelGroup>();
|
|
427
|
+
for (const spec of piRowSpecs(m, lookup)) {
|
|
428
|
+
const gkey = `${spec.tab}\u0000${spec.section}`;
|
|
429
|
+
let group = byKey.get(gkey);
|
|
430
|
+
if (!group) {
|
|
431
|
+
group = { key: `pi-${spec.tab}-${spec.section}`, label: spec.section, tab: spec.tab, rows: [] };
|
|
432
|
+
const icon = PI_TAB_ICONS[spec.tab];
|
|
433
|
+
if (icon) group.icon = icon;
|
|
434
|
+
byKey.set(gkey, group);
|
|
435
|
+
groups.push(group);
|
|
436
|
+
}
|
|
437
|
+
group.rows.push(
|
|
438
|
+
row(spec.key, spec.label, spec.kind, spec.value, (v) => spec.set(v), {
|
|
439
|
+
values: spec.values,
|
|
440
|
+
menu: spec.menu,
|
|
441
|
+
preview: spec.preview,
|
|
442
|
+
previewCancel: spec.previewCancel,
|
|
443
|
+
defaultValue: spec.defaultValue,
|
|
444
|
+
description: spec.description,
|
|
445
|
+
warning: spec.warning,
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
return groups;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** OMP tab order — the assembly order for the whole panel. */
|
|
453
|
+
export const PI_TAB_ORDER = ["Appearance", "Model", "Interaction", "Context", "Memory", "Files", "Shell", "Tools", "Tasks", "Providers", "Plugins"] as const;
|
|
454
|
+
|
|
455
|
+
/** Tab-chip icons for the pi-owned tabs (ceulen sections bring their own). */
|
|
456
|
+
const PI_TAB_ICONS: Record<string, string> = {
|
|
457
|
+
Appearance: "🎨",
|
|
458
|
+
Model: "🤖",
|
|
459
|
+
Interaction: "⌨️",
|
|
460
|
+
Context: "🧠",
|
|
461
|
+
Shell: "🖥️",
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
/** True when a row key belongs to the pi-settings contribution. */
|
|
465
|
+
export function isPiKey(key: string): boolean {
|
|
466
|
+
return key.startsWith("pi.");
|
|
467
|
+
}
|