pi-advisor-flow 0.13.1 → 0.13.2-dev.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 +4 -0
- package/dist/index.js +14 -7
- package/extensions/index.ts +6 -0
- package/package.json +9 -9
- package/scripts/check-bun-version.mjs +9 -0
- package/src/attachments.ts +36 -0
- package/src/child-session.ts +1 -0
- package/src/commands/activation-preparation.ts +12 -0
- package/src/commands/activation.ts +43 -0
- package/src/commands/advisor-tools.ts +3 -0
- package/src/commands/lifecycle.ts +15 -0
- package/src/commands/manual-command.ts +19 -0
- package/src/commands/manual-consultation.ts +20 -0
- package/src/commands/manual-progress.ts +13 -0
- package/src/commands/model-commands.ts +4 -0
- package/src/commands/model-options.ts +18 -0
- package/src/commands/model-picker.ts +16 -0
- package/src/commands/outcome-stats.ts +9 -0
- package/src/commands/registration.ts +1 -0
- package/src/commands/renderers.ts +14 -0
- package/src/commands/runtime.ts +5 -0
- package/src/commands/settings-commands.ts +18 -0
- package/src/commands/settings-persistence.ts +2 -0
- package/src/commands.ts +1 -0
- package/src/config/args.ts +7 -0
- package/src/config/defaults.ts +1 -0
- package/src/config/schema.ts +1 -0
- package/src/config/state.ts +64 -1
- package/src/config/storage.ts +37 -0
- package/src/config/types.ts +9 -0
- package/src/config/validation.ts +7 -0
- package/src/config.ts +6 -0
- package/src/content-utils.ts +5 -0
- package/src/conversation.ts +39 -0
- package/src/follow-up.ts +8 -0
- package/src/git.ts +8 -0
- package/src/herdr-block.ts +7 -0
- package/src/herdr-shared.ts +23 -0
- package/src/herdr.ts +18 -0
- package/src/image-attachments.ts +24 -0
- package/src/image-validation.ts +58 -0
- package/src/images.ts +24 -0
- package/src/jev/base-url.ts +14 -0
- package/src/jev/client.ts +49 -0
- package/src/jev/decisions-client.ts +14 -0
- package/src/jev/decisions-response.ts +38 -0
- package/src/jev/endpoint-key-store.ts +18 -0
- package/src/jev/key-store.ts +28 -0
- package/src/jev/ledger.ts +30 -12
- package/src/jev/openai-key-store.ts +17 -0
- package/src/jev/questions.ts +15 -0
- package/src/jev/state.ts +5 -0
- package/src/jev/transport.ts +35 -0
- package/src/model-stream.ts +32 -0
- package/src/outcome-stats.ts +16 -0
- package/src/outcomes.ts +31 -0
- package/src/pi-settings.ts +9 -0
- package/src/preferences.ts +26 -0
- package/src/redaction.ts +8 -0
- package/src/scout-context.ts +17 -0
- package/src/scout-curation.ts +12 -0
- package/src/scout-groups.ts +47 -0
- package/src/scout-protocol.ts +17 -0
- package/src/scout-reconstruct.ts +12 -0
- package/src/scout.ts +47 -0
- package/src/session-context.ts +11 -0
- package/src/session-state.ts +73 -13
- package/src/tool-result-cap.ts +11 -0
- package/src/tools/consult-context.ts +24 -0
- package/src/tools/consultation.ts +43 -0
- package/src/tools/gate-policy.ts +18 -0
- package/src/tools/gate-protocol.ts +22 -0
- package/src/tools/jev-filter.ts +26 -0
- package/src/tools/jev-turn-gate.ts +17 -0
- package/src/tools/loop-gate.ts +25 -0
- package/src/tools/model-access.ts +12 -0
- package/src/tools/outage-notifier.ts +4 -0
- package/src/tools/prompts.ts +17 -0
- package/src/tools/register-ask-advisor.ts +44 -0
- package/src/tools/register-lifecycle.ts +32 -0
- package/src/tools/register-outcome.ts +7 -0
- package/src/tools/register-renderers.ts +14 -0
- package/src/tools/registration.ts +3 -0
- package/src/tools/render-advisor-result.ts +44 -0
- package/src/tools/render-common.ts +10 -0
- package/src/tools/scout-status.ts +34 -0
- package/src/tools/session.ts +3 -0
- package/src/tools.ts +8 -0
- package/src/ui/jev-filter-submenu.ts +21 -0
- package/src/ui/jev-provider-submenu-view.ts +22 -0
- package/src/ui/jev-provider-submenu.ts +81 -0
- package/src/ui/jev-setup-support.ts +26 -0
- package/src/ui/manual-dialog-render.ts +20 -0
- package/src/ui/manual-dialog.ts +38 -0
- package/src/ui/masked-input.ts +2 -0
- package/src/ui/searchable-model-list.ts +28 -0
- package/src/ui/settings-formatting.ts +26 -0
- package/src/ui/settings-items.ts +11 -0
- package/src/ui/settings-list-adapter.ts +13 -0
- package/src/ui/settings-mutations.ts +60 -0
- package/src/ui/settings-selector.ts +30 -0
- package/src/ui/text-setting-submenu.ts +9 -0
- package/src/ui-guard.ts +1 -0
- package/src/ui.ts +3 -0
- package/src/usage.ts +31 -0
package/src/ui/manual-dialog.ts
CHANGED
|
@@ -74,6 +74,7 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
74
74
|
selectedText: (text) => options.theme.fg("accent", text),
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
|
+
|
|
77
78
|
this.editor = new Editor(options.tui, editorTheme);
|
|
78
79
|
this.editor.setText(options.initialMessage ?? "");
|
|
79
80
|
this.editor.onChange = () => options.tui.requestRender();
|
|
@@ -93,23 +94,31 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
93
94
|
if (this.state.completed) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
97
|
+
|
|
96
98
|
if (this.isCancel(keyData)) {
|
|
97
99
|
this.cancel();
|
|
100
|
+
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
103
|
+
|
|
100
104
|
if (isShiftTab(keyData)) {
|
|
101
105
|
this.changeFocus(-1);
|
|
106
|
+
|
|
102
107
|
return;
|
|
103
108
|
}
|
|
109
|
+
|
|
104
110
|
if (this.isTab(keyData)) {
|
|
105
111
|
this.changeFocus(1);
|
|
112
|
+
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
115
|
+
|
|
108
116
|
const handlers: Record<ManualAdvisorFocus, (keyData: string) => void> = {
|
|
109
117
|
actions: (key) => this.handleActionInput(key),
|
|
110
118
|
editor: (key) => this.handleEditorInput(key),
|
|
111
119
|
git: (key) => this.handleGitInput(key),
|
|
112
120
|
};
|
|
121
|
+
|
|
113
122
|
handlers[this.focusTarget](keyData);
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -118,6 +127,7 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
118
127
|
const innerWidth = Math.max(0, renderWidth - 2);
|
|
119
128
|
const horizontalPadding = renderWidth >= 4 ? 1 : 0;
|
|
120
129
|
const contentWidth = Math.max(0, innerWidth - horizontalPadding * 2);
|
|
130
|
+
|
|
121
131
|
return renderManualAdvisorDialog({
|
|
122
132
|
actionIndex: this.actionIndex,
|
|
123
133
|
editorLines: this.editor.render(Math.max(1, contentWidth)),
|
|
@@ -137,6 +147,7 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
137
147
|
// edge of the message, a directional key also moves to the adjacent
|
|
138
148
|
// form control so the Git selector is reachable without Tab.
|
|
139
149
|
let direction: -1 | 1 | undefined;
|
|
150
|
+
|
|
140
151
|
if (this.matches(keyData, "tui.editor.cursorDown", Key.down)) {
|
|
141
152
|
direction = 1;
|
|
142
153
|
} else if (this.matches(keyData, "tui.editor.cursorUp", Key.up)) {
|
|
@@ -145,21 +156,26 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
145
156
|
|
|
146
157
|
const beforeCursor =
|
|
147
158
|
direction === undefined ? undefined : this.editor.getCursor();
|
|
159
|
+
|
|
148
160
|
const beforeText =
|
|
149
161
|
direction === undefined ? undefined : this.editor.getText();
|
|
162
|
+
|
|
150
163
|
this.editor.handleInput(keyData);
|
|
151
164
|
|
|
152
165
|
if (direction !== undefined) {
|
|
153
166
|
const afterCursor = this.editor.getCursor();
|
|
167
|
+
|
|
154
168
|
if (
|
|
155
169
|
beforeCursor?.line === afterCursor.line &&
|
|
156
170
|
beforeCursor.col === afterCursor.col &&
|
|
157
171
|
beforeText === this.editor.getText()
|
|
158
172
|
) {
|
|
159
173
|
this.changeFocus(direction);
|
|
174
|
+
|
|
160
175
|
return;
|
|
161
176
|
}
|
|
162
177
|
}
|
|
178
|
+
|
|
163
179
|
this.options.tui.requestRender();
|
|
164
180
|
}
|
|
165
181
|
|
|
@@ -171,50 +187,66 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
171
187
|
const up =
|
|
172
188
|
this.matches(keyData, "tui.select.up", Key.up) ||
|
|
173
189
|
this.matches(keyData, "tui.editor.cursorUp", Key.up);
|
|
190
|
+
|
|
174
191
|
const down =
|
|
175
192
|
this.matches(keyData, "tui.select.down", Key.down) ||
|
|
176
193
|
this.matches(keyData, "tui.editor.cursorDown", Key.down);
|
|
194
|
+
|
|
177
195
|
if (up) {
|
|
178
196
|
if (this.gitIndex === 0) {
|
|
179
197
|
this.changeFocus(-1);
|
|
180
198
|
} else {
|
|
181
199
|
this.moveGit(-1);
|
|
182
200
|
}
|
|
201
|
+
|
|
183
202
|
return;
|
|
184
203
|
}
|
|
204
|
+
|
|
185
205
|
if (down) {
|
|
186
206
|
if (this.gitIndex === this.gitLevels.length - 1) {
|
|
187
207
|
this.changeFocus(1);
|
|
188
208
|
} else {
|
|
189
209
|
this.moveGit(1);
|
|
190
210
|
}
|
|
211
|
+
|
|
191
212
|
return;
|
|
192
213
|
}
|
|
214
|
+
|
|
193
215
|
if (matchesKey(keyData, Key.space)) {
|
|
194
216
|
this.moveGit(1);
|
|
217
|
+
|
|
195
218
|
return;
|
|
196
219
|
}
|
|
220
|
+
|
|
197
221
|
if (this.matches(keyData, "tui.input.submit", Key.enter)) {
|
|
198
222
|
this.changeFocus(1);
|
|
223
|
+
|
|
199
224
|
return;
|
|
200
225
|
}
|
|
226
|
+
|
|
201
227
|
this.options.tui.requestRender();
|
|
202
228
|
}
|
|
203
229
|
|
|
204
230
|
private handleActionInput(keyData: string): void {
|
|
205
231
|
if (this.matches(keyData, "tui.editor.cursorUp", Key.up)) {
|
|
206
232
|
this.changeFocus(-1);
|
|
233
|
+
|
|
207
234
|
return;
|
|
208
235
|
}
|
|
236
|
+
|
|
209
237
|
if (this.matches(keyData, "tui.editor.cursorDown", Key.down)) {
|
|
210
238
|
this.changeFocus(1);
|
|
239
|
+
|
|
211
240
|
return;
|
|
212
241
|
}
|
|
242
|
+
|
|
213
243
|
if (matchesKey(keyData, Key.left) || matchesKey(keyData, Key.right)) {
|
|
214
244
|
this.actionIndex = this.actionIndex === 0 ? 1 : 0;
|
|
215
245
|
this.options.tui.requestRender();
|
|
246
|
+
|
|
216
247
|
return;
|
|
217
248
|
}
|
|
249
|
+
|
|
218
250
|
if (
|
|
219
251
|
this.matches(keyData, "tui.input.submit", Key.enter) ||
|
|
220
252
|
matchesKey(keyData, Key.space)
|
|
@@ -242,6 +274,7 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
242
274
|
(this.gitIndex + direction + this.gitLevels.length) %
|
|
243
275
|
this.gitLevels.length;
|
|
244
276
|
}
|
|
277
|
+
|
|
245
278
|
this.options.tui.requestRender();
|
|
246
279
|
}
|
|
247
280
|
|
|
@@ -278,13 +311,17 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
278
311
|
if (this.state.completed || this.state.submitting) {
|
|
279
312
|
return;
|
|
280
313
|
}
|
|
314
|
+
|
|
281
315
|
this.state.submitting = true;
|
|
316
|
+
|
|
282
317
|
const request: ManualAdvisorRequest = {
|
|
283
318
|
gitContext: this.gitLevels[this.gitIndex] ?? "off",
|
|
284
319
|
};
|
|
320
|
+
|
|
285
321
|
if (message) {
|
|
286
322
|
request.message = message;
|
|
287
323
|
}
|
|
324
|
+
|
|
288
325
|
try {
|
|
289
326
|
this.options.onSubmit(request);
|
|
290
327
|
this.state.completed = true;
|
|
@@ -297,6 +334,7 @@ export class ManualAdvisorDialog implements Component, Focusable {
|
|
|
297
334
|
if (this.state.completed) {
|
|
298
335
|
return;
|
|
299
336
|
}
|
|
337
|
+
|
|
300
338
|
this.state.completed = true;
|
|
301
339
|
this.options.onCancel();
|
|
302
340
|
}
|
package/src/ui/masked-input.ts
CHANGED
|
@@ -53,10 +53,12 @@ export class MaskedInput implements Component, Focusable {
|
|
|
53
53
|
// SAFETY: compatibility-only read of Input's private cursor; Input does not expose it.
|
|
54
54
|
const { cursor } = this.input as InputWithCursor;
|
|
55
55
|
const masked = `${"•".repeat(Math.min(cursor, value.length))}█${"•".repeat(Math.max(0, value.length - cursor))}`;
|
|
56
|
+
|
|
56
57
|
const placeholder =
|
|
57
58
|
value.length === 0 && this.options.placeholder
|
|
58
59
|
? this.options.placeholder
|
|
59
60
|
: masked;
|
|
61
|
+
|
|
60
62
|
return [truncateToWidth(placeholder, Math.max(1, width))];
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -57,6 +57,7 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
57
57
|
? requestedCurrentOption
|
|
58
58
|
: undefined;
|
|
59
59
|
let allOptions: string[];
|
|
60
|
+
|
|
60
61
|
if (this.multiSelect) {
|
|
61
62
|
allOptions = [...new Set(options.allOptions)].toSorted((left, right) =>
|
|
62
63
|
left.localeCompare(right)
|
|
@@ -69,7 +70,9 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
69
70
|
} else {
|
|
70
71
|
allOptions = [...options.allOptions];
|
|
71
72
|
}
|
|
73
|
+
|
|
72
74
|
this.allOptions = allOptions;
|
|
75
|
+
|
|
73
76
|
if (this.multiSelect) {
|
|
74
77
|
for (const value of options.currentOptions) {
|
|
75
78
|
if (this.allOptions.includes(value)) {
|
|
@@ -77,6 +80,7 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
|
|
80
84
|
this.theme = options.theme;
|
|
81
85
|
this.keybindings = options.keybindings;
|
|
82
86
|
this.onSelect = options.onSelect;
|
|
@@ -109,6 +113,7 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
109
113
|
|
|
110
114
|
const maxVisible = 10;
|
|
111
115
|
const total = this.filteredOptions.length;
|
|
116
|
+
|
|
112
117
|
if (total === 0) {
|
|
113
118
|
lines.push(` ${this.theme.fg("muted", "No matching models found.")}`);
|
|
114
119
|
} else {
|
|
@@ -119,10 +124,13 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
119
124
|
total - maxVisible
|
|
120
125
|
)
|
|
121
126
|
);
|
|
127
|
+
|
|
122
128
|
const endIndex = Math.min(startIndex + maxVisible, total);
|
|
129
|
+
|
|
123
130
|
for (let i = startIndex; i < endIndex; i += 1) {
|
|
124
131
|
lines.push(this.renderOption(this.filteredOptions[i], i));
|
|
125
132
|
}
|
|
133
|
+
|
|
126
134
|
if (total > maxVisible) {
|
|
127
135
|
lines.push(
|
|
128
136
|
` ${this.theme.fg(
|
|
@@ -132,25 +140,32 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
132
140
|
);
|
|
133
141
|
}
|
|
134
142
|
}
|
|
143
|
+
|
|
135
144
|
lines.push(
|
|
136
145
|
"",
|
|
137
146
|
` ${this.theme.fg("dim", this.interactionHint())}`,
|
|
138
147
|
this.theme.fg("border", "─".repeat(width))
|
|
139
148
|
);
|
|
149
|
+
|
|
140
150
|
return lines.map((line) => truncateToWidth(line, width));
|
|
141
151
|
}
|
|
142
152
|
|
|
143
153
|
handleInput(keyData: string): void {
|
|
144
154
|
if (this.matchesAction(keyData, "tui.select.up", "\u001B[A")) {
|
|
145
155
|
this.moveSelection(-1);
|
|
156
|
+
|
|
146
157
|
return;
|
|
147
158
|
}
|
|
159
|
+
|
|
148
160
|
if (this.matchesAction(keyData, "tui.select.down", "\u001B[B")) {
|
|
149
161
|
this.moveSelection(1);
|
|
162
|
+
|
|
150
163
|
return;
|
|
151
164
|
}
|
|
165
|
+
|
|
152
166
|
if (this.multiSelect && keyData === " ") {
|
|
153
167
|
const item = this.filteredOptions[this.selectedIndex];
|
|
168
|
+
|
|
154
169
|
if (item) {
|
|
155
170
|
if (this.selected.has(item)) {
|
|
156
171
|
this.selected.delete(item);
|
|
@@ -158,9 +173,12 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
158
173
|
this.selected.add(item);
|
|
159
174
|
}
|
|
160
175
|
}
|
|
176
|
+
|
|
161
177
|
this.tui.requestRender();
|
|
178
|
+
|
|
162
179
|
return;
|
|
163
180
|
}
|
|
181
|
+
|
|
164
182
|
if (
|
|
165
183
|
this.matchesAction(keyData, "tui.select.confirm", "\n") ||
|
|
166
184
|
keyData === "\r"
|
|
@@ -171,16 +189,21 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
171
189
|
);
|
|
172
190
|
} else {
|
|
173
191
|
const selectedOption = this.filteredOptions[this.selectedIndex];
|
|
192
|
+
|
|
174
193
|
if (selectedOption !== undefined) {
|
|
175
194
|
this.onSelect([selectedOption]);
|
|
176
195
|
}
|
|
177
196
|
}
|
|
197
|
+
|
|
178
198
|
return;
|
|
179
199
|
}
|
|
200
|
+
|
|
180
201
|
if (this.matchesAction(keyData, "tui.select.cancel", "\u001B")) {
|
|
181
202
|
this.onCancel();
|
|
203
|
+
|
|
182
204
|
return;
|
|
183
205
|
}
|
|
206
|
+
|
|
184
207
|
this.searchInput.handleInput(keyData);
|
|
185
208
|
this.selectedIndex = 0;
|
|
186
209
|
this.tui.requestRender();
|
|
@@ -194,14 +217,17 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
194
217
|
|
|
195
218
|
private renderOption(item: string, index: number): string {
|
|
196
219
|
let tick = " ";
|
|
220
|
+
|
|
197
221
|
if (
|
|
198
222
|
this.multiSelect ? this.selected.has(item) : item === this.currentOption
|
|
199
223
|
) {
|
|
200
224
|
tick = "✓ ";
|
|
201
225
|
}
|
|
226
|
+
|
|
202
227
|
if (index === this.selectedIndex) {
|
|
203
228
|
return ` ${this.theme.fg("accent", `→ ${tick}${item}`)}`;
|
|
204
229
|
}
|
|
230
|
+
|
|
205
231
|
return ` ${this.theme.fg("text", `${tick}${item}`)}`;
|
|
206
232
|
}
|
|
207
233
|
|
|
@@ -217,6 +243,7 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
217
243
|
if (this.filteredOptions.length > 0) {
|
|
218
244
|
const lastIndex = this.filteredOptions.length - 1;
|
|
219
245
|
const nextIndex = this.selectedIndex + direction;
|
|
246
|
+
|
|
220
247
|
if (nextIndex < 0) {
|
|
221
248
|
this.selectedIndex = lastIndex;
|
|
222
249
|
} else if (nextIndex > lastIndex) {
|
|
@@ -225,6 +252,7 @@ export class SearchableModelList implements Component, Focusable {
|
|
|
225
252
|
this.selectedIndex = nextIndex;
|
|
226
253
|
}
|
|
227
254
|
}
|
|
255
|
+
|
|
228
256
|
this.tui.requestRender();
|
|
229
257
|
}
|
|
230
258
|
}
|
|
@@ -5,6 +5,7 @@ import type { ContextPreset } from "./types.ts";
|
|
|
5
5
|
|
|
6
6
|
export const TOGGLE_VALUES = ["On", "Off"];
|
|
7
7
|
export const SIMPLE_MODE_GRADIENT_INTERVAL_MS = 100;
|
|
8
|
+
|
|
8
9
|
// Purple steps with a moving light highlight, retained from the original UI.
|
|
9
10
|
const SIMPLE_MODE_GRADIENT_COLORS = [
|
|
10
11
|
[125, 79, 205],
|
|
@@ -21,18 +22,23 @@ export const withCurrentValue = (current: string, values: string[]) =>
|
|
|
21
22
|
|
|
22
23
|
export const numericValues = (current: number, values: number[]) => {
|
|
23
24
|
const all = values.includes(current) ? values : [...values, current];
|
|
25
|
+
|
|
24
26
|
return all.toSorted((a, b) => a - b).map(String);
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export const maxCallValues = (current: string) => {
|
|
28
30
|
const values = ["0", "1", "2", "3", "5", "10", "25", "50", "∞"];
|
|
31
|
+
|
|
29
32
|
if (values.includes(current)) {
|
|
30
33
|
return values;
|
|
31
34
|
}
|
|
35
|
+
|
|
32
36
|
const numeric = Number(current);
|
|
37
|
+
|
|
33
38
|
const insertionIndex = values.findIndex(
|
|
34
39
|
(value) => value !== "∞" && Number(value) > numeric
|
|
35
40
|
);
|
|
41
|
+
|
|
36
42
|
return insertionIndex === -1
|
|
37
43
|
? [...values.slice(0, -1), current, "∞"]
|
|
38
44
|
: [
|
|
@@ -59,6 +65,7 @@ const closestPresetIndex = (
|
|
|
59
65
|
contextMaxChars: number
|
|
60
66
|
): number => {
|
|
61
67
|
let closestIndex = 0;
|
|
68
|
+
|
|
62
69
|
for (let index = 0; index < presets.length; index += 1) {
|
|
63
70
|
if (
|
|
64
71
|
Math.abs(presets[index].value - contextMaxChars) <
|
|
@@ -67,6 +74,7 @@ const closestPresetIndex = (
|
|
|
67
74
|
closestIndex = index;
|
|
68
75
|
}
|
|
69
76
|
}
|
|
77
|
+
|
|
70
78
|
return closestIndex;
|
|
71
79
|
};
|
|
72
80
|
|
|
@@ -77,30 +85,39 @@ export const contextDescription = (
|
|
|
77
85
|
const exactIndex = presets.findIndex(
|
|
78
86
|
(preset) => preset.value === contextMaxChars
|
|
79
87
|
);
|
|
88
|
+
|
|
80
89
|
const selectedIndex =
|
|
81
90
|
exactIndex === -1
|
|
82
91
|
? closestPresetIndex(presets, contextMaxChars)
|
|
83
92
|
: exactIndex;
|
|
93
|
+
|
|
84
94
|
const selectedPreset = presets[selectedIndex];
|
|
95
|
+
|
|
85
96
|
const isFullContext =
|
|
86
97
|
selectedPreset?.value === Number.MAX_SAFE_INTEGER ||
|
|
87
98
|
selectedPreset?.label.toUpperCase() === "FULL" ||
|
|
88
99
|
selectedPreset?.label.toUpperCase() === "ALL";
|
|
100
|
+
|
|
89
101
|
const progress = isFullContext
|
|
90
102
|
? 1
|
|
91
103
|
: selectedIndex / Math.max(1, presets.length - 1);
|
|
104
|
+
|
|
92
105
|
const meterWidth = 20;
|
|
93
106
|
const marker = Math.round(progress * meterWidth);
|
|
107
|
+
|
|
94
108
|
const meter = Array.from({ length: meterWidth + 1 }, (_, index) => {
|
|
95
109
|
if (index === marker) {
|
|
96
110
|
return "●";
|
|
97
111
|
}
|
|
112
|
+
|
|
98
113
|
return index < marker ? "━" : "─";
|
|
99
114
|
}).join("");
|
|
115
|
+
|
|
100
116
|
const label = currentContextLabel(presets, contextMaxChars);
|
|
101
117
|
const labelWidth = visibleWidth(label);
|
|
102
118
|
const meterPrefix = "none ";
|
|
103
119
|
const markerColumn = meterPrefix.length + marker;
|
|
120
|
+
|
|
104
121
|
const labelStart = Math.max(
|
|
105
122
|
0,
|
|
106
123
|
Math.min(
|
|
@@ -108,9 +125,12 @@ export const contextDescription = (
|
|
|
108
125
|
markerColumn - Math.floor((labelWidth - 1) / 2)
|
|
109
126
|
)
|
|
110
127
|
);
|
|
128
|
+
|
|
111
129
|
const markerLabel = `${" ".repeat(labelStart)}${label}`;
|
|
130
|
+
|
|
112
131
|
const description =
|
|
113
132
|
exactIndex === -1 ? "Custom context limit." : selectedPreset?.description;
|
|
133
|
+
|
|
114
134
|
return `${description ?? "Custom context limit."}\n${meterPrefix}${meter} full\n${markerLabel}`;
|
|
115
135
|
};
|
|
116
136
|
|
|
@@ -121,21 +141,27 @@ export const rainbowGradient = (text: string, startedAt: number): string => {
|
|
|
121
141
|
const frame = Math.floor(
|
|
122
142
|
(Date.now() - startedAt) / SIMPLE_MODE_GRADIENT_INTERVAL_MS
|
|
123
143
|
);
|
|
144
|
+
|
|
124
145
|
const shinePosition = frame % (text.length * 2);
|
|
146
|
+
|
|
125
147
|
return [...text]
|
|
126
148
|
.map((character, index) => {
|
|
127
149
|
const [baseRed, baseGreen, baseBlue] =
|
|
128
150
|
SIMPLE_MODE_GRADIENT_COLORS[index % SIMPLE_MODE_GRADIENT_COLORS.length];
|
|
151
|
+
|
|
129
152
|
const distance = Math.abs(index - shinePosition);
|
|
130
153
|
let brightness = 0;
|
|
154
|
+
|
|
131
155
|
if (distance === 0) {
|
|
132
156
|
brightness = 0.7;
|
|
133
157
|
} else if (distance === 1) {
|
|
134
158
|
brightness = 0.35;
|
|
135
159
|
}
|
|
160
|
+
|
|
136
161
|
const red = Math.round(baseRed + (255 - baseRed) * brightness);
|
|
137
162
|
const green = Math.round(baseGreen + (255 - baseGreen) * brightness);
|
|
138
163
|
const blue = Math.round(baseBlue + (255 - baseBlue) * brightness);
|
|
164
|
+
|
|
139
165
|
return `\u001B[38;2;${red};${green};${blue}m${character}`;
|
|
140
166
|
})
|
|
141
167
|
.join("")
|
package/src/ui/settings-items.ts
CHANGED
|
@@ -71,6 +71,7 @@ const toggle = (
|
|
|
71
71
|
|
|
72
72
|
const scoutTimeoutItem = (settings: AdvisorSettings): SettingItem => {
|
|
73
73
|
const timeoutMs = settings.scoutTimeoutMs ?? DEFAULT_SCOUT_TIMEOUT_MS;
|
|
74
|
+
|
|
74
75
|
return {
|
|
75
76
|
currentValue: String(timeoutMs),
|
|
76
77
|
description:
|
|
@@ -86,15 +87,19 @@ const scoutTimeoutItem = (settings: AdvisorSettings): SettingItem => {
|
|
|
86
87
|
|
|
87
88
|
const jevProviderLabel = (settings: AdvisorSettings): string => {
|
|
88
89
|
const transport = settings.jevTransport ?? DEFAULT_JEV_TRANSPORT;
|
|
90
|
+
|
|
89
91
|
if (transport === "auto") {
|
|
90
92
|
return "Auto (TypeSafe → OpenRouter)";
|
|
91
93
|
}
|
|
94
|
+
|
|
92
95
|
if (transport === "typesafe-compatible") {
|
|
93
96
|
const baseUrl = settings.jevBaseUrl ?? "no Base URL";
|
|
97
|
+
|
|
94
98
|
return settings.jevKeyProvider
|
|
95
99
|
? `System One–compatible (${baseUrl}; Pi login "${settings.jevKeyProvider}")`
|
|
96
100
|
: `System One–compatible (${baseUrl})`;
|
|
97
101
|
}
|
|
102
|
+
|
|
98
103
|
return providerName(transport);
|
|
99
104
|
};
|
|
100
105
|
|
|
@@ -374,6 +379,7 @@ export const createSettingsItems = ({
|
|
|
374
379
|
},
|
|
375
380
|
fallbackModel,
|
|
376
381
|
];
|
|
382
|
+
|
|
377
383
|
if (settings.simpleMode) {
|
|
378
384
|
items.push(
|
|
379
385
|
modelWhitelist,
|
|
@@ -385,6 +391,7 @@ export const createSettingsItems = ({
|
|
|
385
391
|
true
|
|
386
392
|
)
|
|
387
393
|
);
|
|
394
|
+
|
|
388
395
|
return items;
|
|
389
396
|
}
|
|
390
397
|
|
|
@@ -607,17 +614,20 @@ export const createSettingsItems = ({
|
|
|
607
614
|
onCancel: done,
|
|
608
615
|
onSubmit: (value) => {
|
|
609
616
|
let parsed: unknown;
|
|
617
|
+
|
|
610
618
|
try {
|
|
611
619
|
parsed = JSON.parse(value || "{}");
|
|
612
620
|
} catch {
|
|
613
621
|
return { error: "Enter a valid JSON object." };
|
|
614
622
|
}
|
|
623
|
+
|
|
615
624
|
if (!isValidAdvisorToolPolicies(parsed)) {
|
|
616
625
|
return {
|
|
617
626
|
error:
|
|
618
627
|
"Use non-empty tool names with full, summary, or exclude values.",
|
|
619
628
|
};
|
|
620
629
|
}
|
|
630
|
+
|
|
621
631
|
return { value: JSON.stringify(parsed) };
|
|
622
632
|
},
|
|
623
633
|
theme,
|
|
@@ -656,5 +666,6 @@ export const createSettingsItems = ({
|
|
|
656
666
|
afterJevSetup
|
|
657
667
|
)
|
|
658
668
|
);
|
|
669
|
+
|
|
659
670
|
return items;
|
|
660
671
|
};
|
|
@@ -48,6 +48,7 @@ export class SettingsListAdapter {
|
|
|
48
48
|
const fields = this.privateFields();
|
|
49
49
|
// SAFETY: a SettingsList submenu component is registered only when focusable.
|
|
50
50
|
const submenu = fields.submenuComponent as Focusable | undefined;
|
|
51
|
+
|
|
51
52
|
if (submenu) {
|
|
52
53
|
submenu.focused = value;
|
|
53
54
|
}
|
|
@@ -55,6 +56,7 @@ export class SettingsListAdapter {
|
|
|
55
56
|
|
|
56
57
|
setSelectedId(items: SettingItem[], selectedId: string): void {
|
|
57
58
|
const selectedIndex = items.findIndex((item) => item.id === selectedId);
|
|
59
|
+
|
|
58
60
|
if (selectedIndex !== -1) {
|
|
59
61
|
this.privateFields().selectedIndex = selectedIndex;
|
|
60
62
|
}
|
|
@@ -65,37 +67,48 @@ export class SettingsListAdapter {
|
|
|
65
67
|
onChange: (id: string, value: string) => void
|
|
66
68
|
): boolean {
|
|
67
69
|
let direction = 0;
|
|
70
|
+
|
|
68
71
|
if (matchesKey(keyData, Key.left) || keyData === "\u001B[D") {
|
|
69
72
|
direction = -1;
|
|
70
73
|
} else if (matchesKey(keyData, Key.right) || keyData === "\u001B[C") {
|
|
71
74
|
direction = 1;
|
|
72
75
|
}
|
|
76
|
+
|
|
73
77
|
if (direction === 0) {
|
|
74
78
|
return false;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
const fields = this.privateFields();
|
|
82
|
+
|
|
78
83
|
if (fields.submenuComponent || fields.searchInput?.getValue()) {
|
|
79
84
|
return false;
|
|
80
85
|
}
|
|
86
|
+
|
|
81
87
|
const item = fields.filteredItems[fields.selectedIndex];
|
|
88
|
+
|
|
82
89
|
if (!item?.values?.length) {
|
|
83
90
|
return false;
|
|
84
91
|
}
|
|
92
|
+
|
|
85
93
|
const currentIndex = item.values.indexOf(item.currentValue);
|
|
86
94
|
let nextIndex: number;
|
|
95
|
+
|
|
87
96
|
if (currentIndex === -1) {
|
|
88
97
|
nextIndex = direction > 0 ? 0 : item.values.length - 1;
|
|
89
98
|
} else {
|
|
90
99
|
nextIndex =
|
|
91
100
|
(currentIndex + direction + item.values.length) % item.values.length;
|
|
92
101
|
}
|
|
102
|
+
|
|
93
103
|
const nextValue = item.values[nextIndex];
|
|
104
|
+
|
|
94
105
|
if (nextValue === undefined) {
|
|
95
106
|
return false;
|
|
96
107
|
}
|
|
108
|
+
|
|
97
109
|
item.currentValue = nextValue;
|
|
98
110
|
onChange(item.id, nextValue);
|
|
111
|
+
|
|
99
112
|
return true;
|
|
100
113
|
}
|
|
101
114
|
|