@songtonyli/dsh-cli 0.1.54 → 0.1.56
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/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +17 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +60 -41
- package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +2 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +9 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +30 -12
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +3 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +3 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +53 -5
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +27 -5
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +5 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/any_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/api_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/c_sharp_features_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/compiler/plugin_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/cpp_features_pb.js +34 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/cpp_file_options_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/cpp_options_pb.js +22 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/descriptor_pb.js +49 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/duration_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/empty_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/field_mask_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/go_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/java_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/json_enumvalue_options_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/json_options_pb.js +22 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/source_context_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/struct_pb.js +11 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/timestamp_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/type_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/wrappers_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +15 -15
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +18 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +60 -41
- package/node_modules/@bufbuild/protobuf/dist/esm/create.js +2 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +10 -7
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +31 -13
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +3 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +4 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +53 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +28 -6
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +5 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/any_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/api_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/c_sharp_features_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/compiler/plugin_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/cpp_features_pb.js +33 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/cpp_file_options_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/cpp_options_pb.js +19 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/descriptor_pb.js +47 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/duration_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/empty_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/field_mask_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/go_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/java_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/json_enumvalue_options_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/json_options_pb.js +19 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/source_context_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/struct_pb.js +11 -6
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/timestamp_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/type_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/wrappers_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +15 -15
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +1 -1
- package/node_modules/@bufbuild/protobuf/package.json +236 -13
- package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-locale/lib/client.js +7 -7
- package/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/lib/client.js +61 -61
- package/node_modules/@deepseek-ai/dsh-client-ui-approval/lib/client.js +10 -10
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/lib/client.js +49 -49
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/lib/client.js +207 -207
- package/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +16 -16
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +153 -153
- package/node_modules/@deepseek-ai/dsh-client-ui-cordis/lib/client.js +74 -74
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/client.js +80 -80
- package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/lib/client.js +39 -39
- package/node_modules/@deepseek-ai/dsh-client-ui-goal/lib/client.js +16 -16
- package/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/lib/client.js +23 -23
- package/node_modules/@deepseek-ai/dsh-client-ui-jobs/lib/client.js +37 -37
- package/node_modules/@deepseek-ai/dsh-client-ui-layout/lib/client.js +9 -9
- package/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/lib/client.js +12 -12
- package/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/client.js +31 -31
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/lib/client.js +8 -8
- package/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/lib/client.js +18 -18
- package/node_modules/@deepseek-ai/dsh-client-ui-plan/lib/client.js +22 -22
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +139 -139
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/OnboardingSurface.module.css +28 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/types/OnboardingSurface.d.ts +11 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/lib/client.js +182 -182
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +128 -128
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +49 -49
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +87 -87
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/lib/client.js +41 -41
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/lib/client.js +13 -13
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-session-log/lib/client.js +5 -5
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-signin/lib/client.js +24 -24
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-subagent/lib/client.js +27 -27
- package/node_modules/@deepseek-ai/dsh-client-ui-shortcuts/lib/client.js +42 -42
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +44 -44
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-browser/lib/client.js +25 -25
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.excel.js +9 -9
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.js +70 -70
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.pdf.js +9 -9
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/lib/client.js +18 -18
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/lib/client.js +26 -26
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-terminal/lib/client.js +16 -16
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-terminal/lib/client.terminal.js +11 -11
- package/node_modules/@deepseek-ai/dsh-client-ui-skill/lib/client.js +19 -19
- package/node_modules/@deepseek-ai/dsh-client-ui-subagent/lib/client.js +37 -37
- package/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +27 -27
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/lib/client.js +99 -99
- package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/lib/client.js +197 -197
- package/node_modules/@deepseek-ai/dsh-client-ui-user-questions/lib/client.js +73 -73
- package/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/lib/client.js +26 -26
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +92 -92
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/cordis.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/lib/index.js +11 -5
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/package.json +4 -0
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-agent-team/lib/client.js +32 -32
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-voice-input/lib/client.js +24 -24
- package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/lib/types-DxezulnA.js +1324 -0
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/persistence.js +30 -0
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/projection.js +68 -0
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/transaction.js +22 -0
- package/node_modules/@deepseek-ai/dsh-session-log-export/lib/client.js +3 -3
- package/node_modules/@deepseek-ai/dsh-subprocess-local/lib/runner-launch-DGV26RBf.js +1525 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +15 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +15 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +691 -42
- package/package.json +2 -2
|
@@ -171,6 +171,241 @@ var AuthorizationDeclinedError = class extends AuthorizationError {
|
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
173
|
//#endregion
|
|
174
|
+
//#region lib/types/key-chips.js
|
|
175
|
+
/**
|
|
176
|
+
* Key chips: each key a surface names - `Ctrl+G`, `Esc`, `Shift+↑`, the
|
|
177
|
+
* reader's `q` - is drawn apart from the words around it, and on a palette
|
|
178
|
+
* with clickable keys carries a zero-width mark naming the key, so a click on
|
|
179
|
+
* its cells presses that key.
|
|
180
|
+
*
|
|
181
|
+
* The mark is an APC sequence. pi-tui measures, wraps, and truncates APC as
|
|
182
|
+
* zero columns, as it does its own cursor marker, so a chip lays out exactly
|
|
183
|
+
* as its bare label. The screens take every mark out of a frame before they
|
|
184
|
+
* write it ({@link takeKeyFrame}) and keep the columns each marked key
|
|
185
|
+
* occupies; no mark reaches the terminal.
|
|
186
|
+
*
|
|
187
|
+
* Pure: hint text in, styled text out; drawn lines in, clean lines and the
|
|
188
|
+
* cells of each key out.
|
|
189
|
+
* @module @deepseek-ai/dsh-tui-app/key-chips
|
|
190
|
+
*/
|
|
191
|
+
/** A `Ctrl` letter, or a `Shift` chord over `Tab`, `Enter`, or one or two arrows. */
|
|
192
|
+
const CHORD = String.raw`Ctrl\+[A-Z]|Shift\+(?:Tab|Enter|[↑↓←→]{1,2})`;
|
|
193
|
+
/** Keys the surfaces name by word. */
|
|
194
|
+
const NAMED = "Esc|Enter|Tab|Space|PgUp|PgDn|Home|End";
|
|
195
|
+
/** One arrow, or a pair drawn as one token such as `↑↓`. */
|
|
196
|
+
const ARROWS = "[↑↓←→]{1,2}";
|
|
197
|
+
/** The single-character keys a legend names, and the `jk` pair the reader draws as one token. */
|
|
198
|
+
const CHARACTERS = String.raw`jk|[EIqb?/@[\]]`;
|
|
199
|
+
/** A key token starts the text or follows whitespace or an opening parenthesis. */
|
|
200
|
+
const BEFORE = String.raw`(?<=^|[\s(])`;
|
|
201
|
+
/** A key token ends the text or precedes whitespace or closing punctuation. */
|
|
202
|
+
const AFTER = String.raw`(?=$|[\s,.;:)])`;
|
|
203
|
+
/** The tokens each vocabulary recognizes; global, so each search restarts at index 0 through `matchAll`. */
|
|
204
|
+
const TOKENS = {
|
|
205
|
+
legend: new RegExp(`${BEFORE}(?:${CHORD}|${NAMED}|${ARROWS}|${CHARACTERS})${AFTER}`, "gu"),
|
|
206
|
+
prose: new RegExp(`${BEFORE}(?:${CHORD}|${NAMED}|${ARROWS})${AFTER}`, "gu")
|
|
207
|
+
};
|
|
208
|
+
/** The CSI final byte of each arrow key. */
|
|
209
|
+
const ARROW_FINAL = new Map([
|
|
210
|
+
["↑", "A"],
|
|
211
|
+
["↓", "B"],
|
|
212
|
+
["→", "C"],
|
|
213
|
+
["←", "D"]
|
|
214
|
+
]);
|
|
215
|
+
/**
|
|
216
|
+
* The bytes a press of each word-named key and `Shift` word chord sends, in
|
|
217
|
+
* the legacy encoding every terminal reads, except `Shift+Enter`, which only
|
|
218
|
+
* the CSI-u form distinguishes from `Enter`.
|
|
219
|
+
*/
|
|
220
|
+
const NAMED_BYTES = new Map([
|
|
221
|
+
["Esc", "\x1B"],
|
|
222
|
+
["Enter", "\r"],
|
|
223
|
+
["Tab", " "],
|
|
224
|
+
["Space", " "],
|
|
225
|
+
["PgUp", "\x1B[5~"],
|
|
226
|
+
["PgDn", "\x1B[6~"],
|
|
227
|
+
["Home", "\x1B[H"],
|
|
228
|
+
["End", "\x1B[F"],
|
|
229
|
+
["Shift+Tab", "\x1B[Z"],
|
|
230
|
+
["Shift+Enter", "\x1B[13;2u"]
|
|
231
|
+
]);
|
|
232
|
+
/** A `Ctrl` letter chord. */
|
|
233
|
+
const CTRL_LETTER = /^Ctrl\+([A-Z])$/u;
|
|
234
|
+
/** One arrow, shifted or not. */
|
|
235
|
+
const ARROW_KEY = /^(Shift\+)?([↑↓←→])$/u;
|
|
236
|
+
/** A single-character key, which sends itself. */
|
|
237
|
+
const CHARACTER_KEY = /^[jkEIqb?/@[\]]$/u;
|
|
238
|
+
/** Offset between an uppercase letter's code and the control code `Ctrl` with it sends. */
|
|
239
|
+
const CONTROL_OFFSET = 64;
|
|
240
|
+
/**
|
|
241
|
+
* The bytes one press of a key sends.
|
|
242
|
+
* @param key - the key as a chip names it: `Ctrl+G`, `Shift+↑`, `Esc`, `q`.
|
|
243
|
+
* @returns the bytes a terminal sends for that press, or undefined for a name
|
|
244
|
+
* outside the vocabulary, which no click presses.
|
|
245
|
+
*/
|
|
246
|
+
function keyBytes(key) {
|
|
247
|
+
const named = NAMED_BYTES.get(key);
|
|
248
|
+
if (named !== void 0) return named;
|
|
249
|
+
const ctrl = CTRL_LETTER.exec(key);
|
|
250
|
+
if (ctrl !== null) return String.fromCharCode(ctrl[1].charCodeAt(0) - CONTROL_OFFSET);
|
|
251
|
+
const arrow = ARROW_KEY.exec(key);
|
|
252
|
+
if (arrow !== null) {
|
|
253
|
+
const final = ARROW_FINAL.get(arrow[2]);
|
|
254
|
+
return arrow[1] === void 0 ? `\u001b[${final}` : `\u001b[1;2${final}`;
|
|
255
|
+
}
|
|
256
|
+
return CHARACTER_KEY.test(key) ? key : void 0;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The chips one token draws as: a pair of arrows or `jk` is one chip per
|
|
260
|
+
* character, and a `Shift` chord over two arrows shifts both, so each drawn
|
|
261
|
+
* character presses the key it names.
|
|
262
|
+
* @param token - the matched token.
|
|
263
|
+
* @returns the chips in drawing order.
|
|
264
|
+
*/
|
|
265
|
+
function chipsOf(token) {
|
|
266
|
+
const pair = /^(Shift\+)?([↑↓←→])([↑↓←→])$/u.exec(token);
|
|
267
|
+
if (pair !== null) {
|
|
268
|
+
const shift = pair[1] ?? "";
|
|
269
|
+
const first = `${shift}${pair[2]}`;
|
|
270
|
+
const second = pair[3];
|
|
271
|
+
return [{
|
|
272
|
+
label: first,
|
|
273
|
+
key: first
|
|
274
|
+
}, {
|
|
275
|
+
label: second,
|
|
276
|
+
key: `${shift}${second}`
|
|
277
|
+
}];
|
|
278
|
+
}
|
|
279
|
+
if (token === "jk") return [{
|
|
280
|
+
label: "j",
|
|
281
|
+
key: "j"
|
|
282
|
+
}, {
|
|
283
|
+
label: "k",
|
|
284
|
+
key: "k"
|
|
285
|
+
}];
|
|
286
|
+
return [{
|
|
287
|
+
label: token,
|
|
288
|
+
key: token
|
|
289
|
+
}];
|
|
290
|
+
}
|
|
291
|
+
/** What opens a key mark; the screens search a drawn line for it before anything else. */
|
|
292
|
+
const MARK_PREFIX = "\x1B_dsh-key;";
|
|
293
|
+
/** What ends a key mark. */
|
|
294
|
+
const MARK_END = "\x07";
|
|
295
|
+
/** One mark: the columns its chip spans, then the key it presses. */
|
|
296
|
+
const MARK = /\u001b_dsh-key;(\d+);([^\u0007\u001b]*)\u0007/gu;
|
|
297
|
+
/**
|
|
298
|
+
* The zero-width mark that names the key under the columns after it.
|
|
299
|
+
* @param width - the columns the chip's label takes.
|
|
300
|
+
* @param key - the key the chip presses.
|
|
301
|
+
* @returns the APC sequence.
|
|
302
|
+
*/
|
|
303
|
+
function mark(width, key) {
|
|
304
|
+
return `${MARK_PREFIX}${String(width)};${key}${MARK_END}`;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* How a chip is drawn: the accent color, underlined, so a key reads apart
|
|
308
|
+
* from the words around it, and as something to click, with or without
|
|
309
|
+
* color.
|
|
310
|
+
* @param palette - the active palette.
|
|
311
|
+
* @returns the chip style.
|
|
312
|
+
*/
|
|
313
|
+
function chipStyle(palette) {
|
|
314
|
+
return (text) => palette.underline(palette.accent(text));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Draw the keys a text names as chips and every other run of it in `base`.
|
|
318
|
+
*
|
|
319
|
+
* The runs are styled apart rather than nested, so a chip neither inherits
|
|
320
|
+
* nor cancels the style of the text around it. The text keeps its visible
|
|
321
|
+
* width: the marks are zero columns wide.
|
|
322
|
+
* @param palette - the active palette; its `clickableKeys` decides whether
|
|
323
|
+
* each chip carries its key mark.
|
|
324
|
+
* @param text - the text, unstyled.
|
|
325
|
+
* @param base - the style of the runs between chips; dim by default.
|
|
326
|
+
* @param vocabulary - which key names count; `legend` by default.
|
|
327
|
+
* @returns the styled text.
|
|
328
|
+
*/
|
|
329
|
+
function paintKeys(palette, text, base = palette.dim, vocabulary = "legend") {
|
|
330
|
+
const style = chipStyle(palette);
|
|
331
|
+
let out = "";
|
|
332
|
+
let last = 0;
|
|
333
|
+
for (const match of text.matchAll(TOKENS[vocabulary])) {
|
|
334
|
+
if (match.index > last) out += base(text.slice(last, match.index));
|
|
335
|
+
for (const chip of chipsOf(match[0])) out += `${palette.clickableKeys ? mark(visibleWidth(chip.label), chip.key) : ""}${style(chip.label)}`;
|
|
336
|
+
last = match.index + match[0].length;
|
|
337
|
+
}
|
|
338
|
+
if (last < text.length) out += base(text.slice(last));
|
|
339
|
+
return out;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Take the key marks out of one drawn line.
|
|
343
|
+
* @param line - the line as a component drew it.
|
|
344
|
+
* @returns the line without marks and the cells of each key they named. A
|
|
345
|
+
* chip the width cut short spans no column past the line's end, and a mark
|
|
346
|
+
* naming a key outside the vocabulary is removed without a spot.
|
|
347
|
+
*/
|
|
348
|
+
function takeKeySpots(line) {
|
|
349
|
+
if (!line.includes(MARK_PREFIX)) return {
|
|
350
|
+
line,
|
|
351
|
+
spots: []
|
|
352
|
+
};
|
|
353
|
+
let clean = "";
|
|
354
|
+
let column = 0;
|
|
355
|
+
let last = 0;
|
|
356
|
+
const found = [];
|
|
357
|
+
for (const match of line.matchAll(MARK)) {
|
|
358
|
+
const text = line.slice(last, match.index);
|
|
359
|
+
clean += text;
|
|
360
|
+
column += visibleWidth(text);
|
|
361
|
+
const bytes = keyBytes(match[2]);
|
|
362
|
+
if (bytes !== void 0) found.push({
|
|
363
|
+
from: column,
|
|
364
|
+
to: column + Number(match[1]),
|
|
365
|
+
bytes
|
|
366
|
+
});
|
|
367
|
+
last = match.index + match[0].length;
|
|
368
|
+
}
|
|
369
|
+
clean += line.slice(last);
|
|
370
|
+
const end = visibleWidth(clean);
|
|
371
|
+
const spots = found.filter((spot) => spot.from < end).map((spot) => ({
|
|
372
|
+
...spot,
|
|
373
|
+
to: Math.min(spot.to, end)
|
|
374
|
+
}));
|
|
375
|
+
return {
|
|
376
|
+
line: clean,
|
|
377
|
+
spots
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/** A frame that draws no key. */
|
|
381
|
+
const EMPTY_KEY_FRAME = /* @__PURE__ */ new Map();
|
|
382
|
+
/**
|
|
383
|
+
* Take the key marks out of a whole frame.
|
|
384
|
+
* @param lines - the frame as the tree drew it.
|
|
385
|
+
* @returns the lines to write and the keys each one draws.
|
|
386
|
+
*/
|
|
387
|
+
function takeKeyFrame(lines) {
|
|
388
|
+
const keys = /* @__PURE__ */ new Map();
|
|
389
|
+
return {
|
|
390
|
+
lines: lines.map((line, index) => {
|
|
391
|
+
const marked = takeKeySpots(line);
|
|
392
|
+
if (marked.spots.length > 0) keys.set(index, marked.spots);
|
|
393
|
+
return marked.line;
|
|
394
|
+
}),
|
|
395
|
+
keys
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* The key drawn at one cell of a frame.
|
|
400
|
+
* @param keys - the frame's keys.
|
|
401
|
+
* @param line - the frame line or screen row.
|
|
402
|
+
* @param column - the column, counted from 0.
|
|
403
|
+
* @returns the bytes that key sends, or undefined when no chip covers the cell.
|
|
404
|
+
*/
|
|
405
|
+
function keyAt(keys, line, column) {
|
|
406
|
+
return keys.get(line)?.find((spot) => column >= spot.from && column < spot.to)?.bytes;
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
174
409
|
//#region lib/types/alt-screen.js
|
|
175
410
|
/**
|
|
176
411
|
* The terminal's alternate screen, which a surface that owns the whole
|
|
@@ -190,7 +425,8 @@ var AuthorizationDeclinedError = class extends AuthorizationError {
|
|
|
190
425
|
* belongs rather than by printing downward, so nothing here ever scrolls the
|
|
191
426
|
* terminal. Each paint writes only the rows whose text changed since the last
|
|
192
427
|
* one, wrapped in one synchronized-output pair so the terminal shows whole
|
|
193
|
-
* frames.
|
|
428
|
+
* frames. Each paint takes the key marks out of its rows first and keeps
|
|
429
|
+
* where each marked key was drawn, by screen row.
|
|
194
430
|
* @module @deepseek-ai/dsh-tui-app/alt-screen
|
|
195
431
|
*/
|
|
196
432
|
/** Switch to the alternate screen, saving the main one. */
|
|
@@ -230,6 +466,8 @@ var AlternateScreen = class {
|
|
|
230
466
|
/** The terminal width the drawn rows were written at, so a resize repaints them all. */
|
|
231
467
|
drawnWidth = 0;
|
|
232
468
|
entered = false;
|
|
469
|
+
/** The keys the last paint drew, by screen row. */
|
|
470
|
+
keys = EMPTY_KEY_FRAME;
|
|
233
471
|
/**
|
|
234
472
|
* @param terminal - the terminal whose two screens these are.
|
|
235
473
|
*/
|
|
@@ -250,32 +488,46 @@ var AlternateScreen = class {
|
|
|
250
488
|
if (this.entered) return;
|
|
251
489
|
this.entered = true;
|
|
252
490
|
this.drawn = [];
|
|
491
|
+
this.keys = EMPTY_KEY_FRAME;
|
|
253
492
|
this.drawnWidth = this.terminal.columns;
|
|
254
493
|
this.terminal.write(`${ENTER}${NO_AUTOWRAP}${HIDE_CARET}${CLEAR}`);
|
|
255
494
|
}
|
|
256
495
|
/**
|
|
257
496
|
* Draw one frame.
|
|
258
497
|
* @param lines - the frame, one entry per screen row from the top; rows the
|
|
259
|
-
* frame no longer has are cleared.
|
|
260
|
-
* is the
|
|
498
|
+
* frame no longer has are cleared. Key marks are taken out before a row is
|
|
499
|
+
* written. Nothing is written while the main screen is the one the
|
|
500
|
+
* terminal shows.
|
|
261
501
|
*/
|
|
262
502
|
paint(lines) {
|
|
263
503
|
if (!this.entered) return;
|
|
504
|
+
const marked = takeKeyFrame(lines);
|
|
505
|
+
this.keys = marked.keys;
|
|
264
506
|
if (this.terminal.columns !== this.drawnWidth) {
|
|
265
507
|
this.drawn = [];
|
|
266
508
|
this.drawnWidth = this.terminal.columns;
|
|
267
509
|
}
|
|
268
510
|
let frame = BEGIN_FRAME;
|
|
269
|
-
for (const [row, line] of lines.entries()) {
|
|
511
|
+
for (const [row, line] of marked.lines.entries()) {
|
|
270
512
|
if (this.drawn[row] === line) continue;
|
|
271
513
|
frame += `${cursorTo(row)}${CLEAR_ROW}${line}`;
|
|
272
514
|
}
|
|
273
|
-
for (let row = lines.length; row < this.drawn.length; row += 1) frame += `${cursorTo(row)}${CLEAR_ROW}`;
|
|
274
|
-
this.drawn =
|
|
515
|
+
for (let row = marked.lines.length; row < this.drawn.length; row += 1) frame += `${cursorTo(row)}${CLEAR_ROW}`;
|
|
516
|
+
this.drawn = marked.lines;
|
|
275
517
|
frame += END_FRAME;
|
|
276
518
|
this.terminal.write(frame);
|
|
277
519
|
}
|
|
278
520
|
/**
|
|
521
|
+
* The key the last paint drew at one cell.
|
|
522
|
+
* @param row - the screen row, counted from 0 at the top.
|
|
523
|
+
* @param column - the column, counted from 0.
|
|
524
|
+
* @returns the bytes that key sends, or undefined when no chip covers the
|
|
525
|
+
* cell or the main screen is the one the terminal shows.
|
|
526
|
+
*/
|
|
527
|
+
keyAt(row, column) {
|
|
528
|
+
return this.entered ? keyAt(this.keys, row, column) : void 0;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
279
531
|
* Give the terminal back, which restores the main screen exactly as it was
|
|
280
532
|
* when {@link AlternateScreen.enter} saved it.
|
|
281
533
|
*/
|
|
@@ -1505,6 +1757,16 @@ function showSetting(ctx, ns) {
|
|
|
1505
1757
|
return rows;
|
|
1506
1758
|
}
|
|
1507
1759
|
/**
|
|
1760
|
+
* One namespace's resolved value with secrets redacted.
|
|
1761
|
+
* @param ctx - plugin context carrying the optional settings service.
|
|
1762
|
+
* @param ns - the registered namespace to read.
|
|
1763
|
+
* @returns the resolved section value.
|
|
1764
|
+
* @throws {Error} when no settings service is mounted or `ns` is not registered.
|
|
1765
|
+
*/
|
|
1766
|
+
function settingValue(ctx, ns) {
|
|
1767
|
+
return requireDescriptor(requireSettings(ctx), ns).value;
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1508
1770
|
* Write one field of a namespace's user section through a path-addressed
|
|
1509
1771
|
* `set` against the revision read at call time. `rawValue` is parsed as JSON
|
|
1510
1772
|
* when it is valid JSON and stored as a string otherwise; an empty `path`
|
|
@@ -3127,7 +3389,9 @@ var TailWrappedText = class {
|
|
|
3127
3389
|
/**
|
|
3128
3390
|
* The terminal palette: one table of SGR open/close pairs behind named roles,
|
|
3129
3391
|
* so components never emit raw escape codes. A disabled palette returns text
|
|
3130
|
-
* unchanged for dumb terminals and captured output.
|
|
3392
|
+
* unchanged for dumb terminals and captured output. The palette also says
|
|
3393
|
+
* whether the keys a surface names are clickable, because it is what every
|
|
3394
|
+
* surface draws a key chip with.
|
|
3131
3395
|
* @module @deepseek-ai/dsh-tui-app/style
|
|
3132
3396
|
*/
|
|
3133
3397
|
const ESC = "\x1B[";
|
|
@@ -3155,9 +3419,10 @@ const SGR = {
|
|
|
3155
3419
|
/**
|
|
3156
3420
|
* Build the palette.
|
|
3157
3421
|
* @param enabled - whether escape sequences are emitted; false makes every role the identity.
|
|
3422
|
+
* @param clickableKeys - whether key chips carry click marks; false by default.
|
|
3158
3423
|
* @returns the palette.
|
|
3159
3424
|
*/
|
|
3160
|
-
function createPalette(enabled) {
|
|
3425
|
+
function createPalette(enabled, clickableKeys = false) {
|
|
3161
3426
|
const role = (name) => {
|
|
3162
3427
|
const [open, close] = SGR[name];
|
|
3163
3428
|
return enabled ? (text) => `${ESC}${open}m${text}${ESC}${close}m` : (text) => text;
|
|
@@ -3181,7 +3446,8 @@ function createPalette(enabled) {
|
|
|
3181
3446
|
removedBand: role("removedBand"),
|
|
3182
3447
|
addedSign: role("addedSign"),
|
|
3183
3448
|
removedSign: role("removedSign"),
|
|
3184
|
-
enabled
|
|
3449
|
+
enabled,
|
|
3450
|
+
clickableKeys
|
|
3185
3451
|
};
|
|
3186
3452
|
}
|
|
3187
3453
|
/**
|
|
@@ -3619,7 +3885,7 @@ var NoticeBlock = class {
|
|
|
3619
3885
|
text;
|
|
3620
3886
|
constructor(theme, text, tone = "dim") {
|
|
3621
3887
|
const palette = theme.palette;
|
|
3622
|
-
this.text = new Text(palette
|
|
3888
|
+
this.text = new Text(paintKeys(palette, `· ${text}`, palette[tone], "prose"), 0, 0);
|
|
3623
3889
|
}
|
|
3624
3890
|
invalidate() {
|
|
3625
3891
|
this.text.invalidate();
|
|
@@ -3747,7 +4013,8 @@ var ContextBlock = class {
|
|
|
3747
4013
|
}
|
|
3748
4014
|
const kept = (ranges[(this.options.pinnedParts ?? 0) - 1]?.to ?? 0) + this.theme.contextPreviewLines;
|
|
3749
4015
|
const cut = !this.expanded && body.length > kept;
|
|
3750
|
-
const
|
|
4016
|
+
const marker = () => wrapTextWithAnsi(paintKeys(palette, foldMarker(body.length - kept, marked ? "marked" : "transcript")), textWidth).map(indent);
|
|
4017
|
+
const shown = cut ? [...body.slice(0, kept), ...marker()] : body;
|
|
3751
4018
|
return {
|
|
3752
4019
|
lines: [...head, ...shown],
|
|
3753
4020
|
head: head.length,
|
|
@@ -4415,9 +4682,10 @@ var ToolBlock = class {
|
|
|
4415
4682
|
...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)
|
|
4416
4683
|
];
|
|
4417
4684
|
const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
|
|
4418
|
-
const shown = paintCodeRows(kept, code, this.theme.codeHighlight);
|
|
4419
|
-
const callCount = Math.min(this.call.lines.length + loading.length, shown.length);
|
|
4420
4685
|
const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
|
|
4686
|
+
const painted = paintCodeRows(kept, code, this.theme.codeHighlight);
|
|
4687
|
+
const shown = cut ? [...painted.slice(0, -1), paintKeys(palette, kept.at(-1), (text) => text)] : painted;
|
|
4688
|
+
const callCount = Math.min(this.call.lines.length + loading.length, shown.length);
|
|
4421
4689
|
const marks = [
|
|
4422
4690
|
...this.call.diff ?? new Array(this.call.lines.length).fill(void 0),
|
|
4423
4691
|
...new Array(loading.length).fill(void 0),
|
|
@@ -5624,6 +5892,60 @@ function matchEffort(reasoning, typed) {
|
|
|
5624
5892
|
return wanted === DEFAULT_ARGUMENT ? void 0 : null;
|
|
5625
5893
|
}
|
|
5626
5894
|
//#endregion
|
|
5895
|
+
//#region lib/types/search-route.js
|
|
5896
|
+
/**
|
|
5897
|
+
* Web-search routes for `/search`: DeepSeek's own endpoint, or the user's
|
|
5898
|
+
* OpenRouter DeepSeek model through OpenRouter's Anthropic-compatible
|
|
5899
|
+
* Messages API. A route is a write to the `web-search-deepseek` settings
|
|
5900
|
+
* namespace, which the provider reads at each search.
|
|
5901
|
+
* @module @deepseek-ai/dsh-tui-app/search-route
|
|
5902
|
+
*/
|
|
5903
|
+
/** Settings namespace the DeepSeek search provider registers. */
|
|
5904
|
+
const SEARCH_NAMESPACE = "web-search-deepseek";
|
|
5905
|
+
/** Anthropic-compatible Messages base of OpenRouter; the provider appends `/messages`. */
|
|
5906
|
+
const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
5907
|
+
/** Credential reference the shipped `openrouter` chat provider also resolves. */
|
|
5908
|
+
const OPENROUTER_KEY_REF = "OPENROUTER_API_KEY";
|
|
5909
|
+
/** Picker rows for `/search`. */
|
|
5910
|
+
const SEARCH_ROUTE_ITEMS = [{
|
|
5911
|
+
value: "deepseek",
|
|
5912
|
+
label: "DeepSeek",
|
|
5913
|
+
description: "DeepSeek native search with DEEPSEEK_API_KEY or the DeepSeek account (default)"
|
|
5914
|
+
}, {
|
|
5915
|
+
value: "openrouter",
|
|
5916
|
+
label: "OpenRouter DeepSeek",
|
|
5917
|
+
description: `Search through OpenRouter with ${OPENROUTER_KEY_REF} and deepseek/deepseek-v4-flash-0731`
|
|
5918
|
+
}];
|
|
5919
|
+
/**
|
|
5920
|
+
* The route the stored search settings resolve to.
|
|
5921
|
+
* @param ctx - plugin context carrying the optional settings service.
|
|
5922
|
+
* @returns `openrouter` when the resolved endpoint is OpenRouter's, otherwise `deepseek`.
|
|
5923
|
+
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
5924
|
+
*/
|
|
5925
|
+
function currentSearchRoute(ctx) {
|
|
5926
|
+
const { baseURL } = settingValue(ctx, SEARCH_NAMESPACE);
|
|
5927
|
+
return baseURL?.startsWith(OPENROUTER_BASE_URL) === true ? "openrouter" : "deepseek";
|
|
5928
|
+
}
|
|
5929
|
+
/**
|
|
5930
|
+
* Select a search route by writing the provider's settings.
|
|
5931
|
+
* @param ctx - plugin context carrying the optional settings service.
|
|
5932
|
+
* @param route - the route to select; `deepseek` clears the namespace's user overrides.
|
|
5933
|
+
* @param model - the OpenRouter model for `openrouter`; defaults to {@link OPENROUTER_SEARCH_MODEL}.
|
|
5934
|
+
* @returns a confirmation row.
|
|
5935
|
+
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
5936
|
+
*/
|
|
5937
|
+
async function applySearchRoute(ctx, route, model) {
|
|
5938
|
+
if (route === "deepseek") {
|
|
5939
|
+
await resetSetting(ctx, SEARCH_NAMESPACE);
|
|
5940
|
+
return "web search: DeepSeek";
|
|
5941
|
+
}
|
|
5942
|
+
const chosen = model ?? "deepseek/deepseek-v4-flash-0731";
|
|
5943
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "baseURL", OPENROUTER_BASE_URL);
|
|
5944
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "apiKeyEnv", OPENROUTER_KEY_REF);
|
|
5945
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "model", chosen);
|
|
5946
|
+
return `web search: OpenRouter ${chosen}`;
|
|
5947
|
+
}
|
|
5948
|
+
//#endregion
|
|
5627
5949
|
//#region lib/types/permission.js
|
|
5628
5950
|
/**
|
|
5629
5951
|
* Permission-preset rows and labels shared by `/permission` and the
|
|
@@ -5942,7 +6264,7 @@ var ViewBanner = class {
|
|
|
5942
6264
|
return [bandRow(palette, truncateToWidth(` ${[
|
|
5943
6265
|
`${palette.warning(VIEW_GLYPH)} ${palette.bold(palette.warning(this.title))}`,
|
|
5944
6266
|
[...trail, palette.bold(current)].join(palette.dim(" › ")),
|
|
5945
|
-
`${palette
|
|
6267
|
+
`${paintKeys(palette, "Ctrl+P")} ${palette.dim(`back to ${back}`)}`
|
|
5946
6268
|
].join(palette.dim(" · "))}`, width, "…"), width)];
|
|
5947
6269
|
}
|
|
5948
6270
|
};
|
|
@@ -6626,10 +6948,10 @@ function renderInspector(view, render) {
|
|
|
6626
6948
|
})];
|
|
6627
6949
|
const room = Math.max(1, width - 4);
|
|
6628
6950
|
if (view.parts.length > 1) for (const line of partsStrip(view.parts, palette, room)) lines.push(bodyLine(line, width, palette, tone, level));
|
|
6629
|
-
const body = foldRows(view.rows.flatMap((row) => wrapTextWithAnsi(row, room)), render.previewLines, (hidden) => palette
|
|
6951
|
+
const body = foldRows(view.rows.flatMap((row) => wrapTextWithAnsi(row, room)), render.previewLines, (hidden) => paintKeys(palette, foldMarker(hidden, "inspector")));
|
|
6630
6952
|
for (const row of body) lines.push(bodyLine(row, width, palette, tone, level));
|
|
6631
6953
|
lines.push(bottomRule({
|
|
6632
|
-
left: palette
|
|
6954
|
+
left: paintKeys(palette, fitLegend(HINTS.transcript, ruleRoom(width))),
|
|
6633
6955
|
width,
|
|
6634
6956
|
palette,
|
|
6635
6957
|
tone,
|
|
@@ -7886,7 +8208,7 @@ function unfocusedLine(segments, palette, width, queue) {
|
|
|
7886
8208
|
const drawn = middleFacts(facts, rest.length - facts.length, width - visibleWidth(model) - reserved);
|
|
7887
8209
|
const left = [model === "" ? "" : palette.accent(model), ...drawn].filter((token) => token !== "").join(palette.dim(SEPARATOR$2));
|
|
7888
8210
|
if (hint === "") return fitLine(left, width);
|
|
7889
|
-
return fitLine(`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(hint)))}${palette.link
|
|
8211
|
+
return fitLine(`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(hint)))}${paintKeys(palette, hint, palette.link)}`, width);
|
|
7890
8212
|
}
|
|
7891
8213
|
/**
|
|
7892
8214
|
* The first detail row of a printed segment, or the summary of a page segment.
|
|
@@ -7910,8 +8232,8 @@ function expansionBody(segment) {
|
|
|
7910
8232
|
*/
|
|
7911
8233
|
function expansionLine(segment, palette, width) {
|
|
7912
8234
|
const body = expansionBody(segment);
|
|
7913
|
-
const legend = fitLegend(HINTS.bar, width);
|
|
7914
|
-
const suffix =
|
|
8235
|
+
const legend = paintKeys(palette, fitLegend(HINTS.bar, width));
|
|
8236
|
+
const suffix = body === "" ? legend : `${palette.dim(SEPARATOR$2)}${legend}`;
|
|
7915
8237
|
const prefix = palette.dim(body);
|
|
7916
8238
|
const rest = width - visibleWidth(suffix);
|
|
7917
8239
|
if (rest < 1) return fitLine(`${prefix}${suffix}`, width);
|
|
@@ -8150,7 +8472,7 @@ var ListPrompt = class {
|
|
|
8150
8472
|
}
|
|
8151
8473
|
render(width) {
|
|
8152
8474
|
const inner = Math.max(1, width - 2);
|
|
8153
|
-
const body = this.body.flatMap((line) => wrapTextWithAnsi(this.
|
|
8475
|
+
const body = this.body.flatMap((line) => wrapTextWithAnsi(this.paintBody(line), inner).map((part) => ` ${part}`));
|
|
8154
8476
|
return [
|
|
8155
8477
|
"",
|
|
8156
8478
|
...this.heading.render(width),
|
|
@@ -8159,6 +8481,14 @@ var ListPrompt = class {
|
|
|
8159
8481
|
];
|
|
8160
8482
|
}
|
|
8161
8483
|
/**
|
|
8484
|
+
* Style one body row.
|
|
8485
|
+
* @param line - the row, unstyled.
|
|
8486
|
+
* @returns the row dim; a subclass whose rows name keys draws those as chips.
|
|
8487
|
+
*/
|
|
8488
|
+
paintBody(line) {
|
|
8489
|
+
return this.palette.dim(line);
|
|
8490
|
+
}
|
|
8491
|
+
/**
|
|
8162
8492
|
* The lines under the body rows: the select list, which a subclass may
|
|
8163
8493
|
* precede or replace.
|
|
8164
8494
|
* @param width - the terminal width.
|
|
@@ -8258,6 +8588,15 @@ var PickPrompt = class extends ListPrompt {
|
|
|
8258
8588
|
withdraw() {
|
|
8259
8589
|
this.settle(void 0);
|
|
8260
8590
|
}
|
|
8591
|
+
/**
|
|
8592
|
+
* Style one body row: a picker's rows are hints its caller wrote, so the
|
|
8593
|
+
* keys they name are drawn as chips.
|
|
8594
|
+
* @param line - the row, unstyled.
|
|
8595
|
+
* @returns the row dim, its keys as chips.
|
|
8596
|
+
*/
|
|
8597
|
+
paintBody(line) {
|
|
8598
|
+
return paintKeys(this.palette, line, this.palette.dim, "prose");
|
|
8599
|
+
}
|
|
8261
8600
|
handleInput(data) {
|
|
8262
8601
|
if (matchesKey(data, "escape") && this.query !== "") {
|
|
8263
8602
|
this.setQuery("");
|
|
@@ -8285,9 +8624,7 @@ var PickPrompt = class extends ListPrompt {
|
|
|
8285
8624
|
this.setQuery(this.query + typed);
|
|
8286
8625
|
}
|
|
8287
8626
|
listLines(width) {
|
|
8288
|
-
|
|
8289
|
-
const shown = this.query !== "" && this.visible.length === 0 ? [this.palette.dim(` no row matches "${this.query}"`)] : super.listLines(width);
|
|
8290
|
-
return [this.palette.dim(filter), ...shown];
|
|
8627
|
+
return [this.query === "" ? paintKeys(this.palette, FILTER_HINT) : this.palette.dim(`filter: ${this.query} · ${String(this.visible.length)}/${String(this.rows.length)}`), ...this.query !== "" && this.visible.length === 0 ? [this.palette.dim(` no row matches "${this.query}"`)] : super.listLines(width)];
|
|
8291
8628
|
}
|
|
8292
8629
|
};
|
|
8293
8630
|
/** Detail rows a read-only page draws at once; the rest wait behind a scroll. */
|
|
@@ -8354,7 +8691,7 @@ var DetailPrompt = class {
|
|
|
8354
8691
|
"",
|
|
8355
8692
|
...this.heading.render(width),
|
|
8356
8693
|
...wrapped.slice(this.offset, this.offset + DETAIL_MAX_VISIBLE),
|
|
8357
|
-
this.palette
|
|
8694
|
+
`${paintKeys(this.palette, DETAIL_HINT)}${position === "" ? "" : this.palette.dim(position)}`
|
|
8358
8695
|
];
|
|
8359
8696
|
}
|
|
8360
8697
|
};
|
|
@@ -8510,10 +8847,10 @@ var QuestionPrompt = class {
|
|
|
8510
8847
|
if (this.typing) {
|
|
8511
8848
|
this.input.focused = true;
|
|
8512
8849
|
lines.push(...this.input.render(width));
|
|
8513
|
-
lines.push(this.palette
|
|
8850
|
+
lines.push(paintKeys(this.palette, "Enter answers · Esc back to the options"));
|
|
8514
8851
|
} else {
|
|
8515
8852
|
lines.push(...this.list.render(width));
|
|
8516
|
-
if (this.question.multiSelect === true) lines.push(this.palette
|
|
8853
|
+
if (this.question.multiSelect === true) lines.push(paintKeys(this.palette, "Space toggles · Enter on Done confirms · Esc cancels"));
|
|
8517
8854
|
}
|
|
8518
8855
|
return lines;
|
|
8519
8856
|
}
|
|
@@ -8749,7 +9086,7 @@ function renderQueuePanel(rows, render) {
|
|
|
8749
9086
|
for (const content of followUpLines(row.text, room, glyph)) lines.push(bodyLine(content, width, palette, tone));
|
|
8750
9087
|
}
|
|
8751
9088
|
const hints = selected === void 0 ? [QUEUE_ENTRY_HINT] : HINTS.queue;
|
|
8752
|
-
lines.push(bodyLine(palette
|
|
9089
|
+
lines.push(bodyLine(paintKeys(palette, fitLegend(hints, room)), width, palette, tone));
|
|
8753
9090
|
lines.push(bottomRule({
|
|
8754
9091
|
width,
|
|
8755
9092
|
palette,
|
|
@@ -9644,7 +9981,7 @@ function frameRow(columns, row, palette, width) {
|
|
|
9644
9981
|
*/
|
|
9645
9982
|
function legendText(state, palette, room) {
|
|
9646
9983
|
if (state.column === "filter") return palette.accent(truncateToWidth(`/ ${state.query ?? ""}`, Math.max(1, room), ELLIPSIS$1));
|
|
9647
|
-
return palette
|
|
9984
|
+
return paintKeys(palette, fitLegend(READER_HINTS[state.column], room));
|
|
9648
9985
|
}
|
|
9649
9986
|
/**
|
|
9650
9987
|
* Where one entry sits in the list it belongs to, as both the top rule and
|
|
@@ -9738,6 +10075,212 @@ function readerRows(state, groups, render) {
|
|
|
9738
10075
|
];
|
|
9739
10076
|
}
|
|
9740
10077
|
//#endregion
|
|
10078
|
+
//#region lib/types/pointer.js
|
|
10079
|
+
/**
|
|
10080
|
+
* Pointer input for the terminal surface: a {@link Terminal} that turns the
|
|
10081
|
+
* terminal's mouse reports on while the application runs, answers them
|
|
10082
|
+
* before pi-tui sees any input, and presses a key by handing its bytes to the
|
|
10083
|
+
* same input callback a key press reaches.
|
|
10084
|
+
*
|
|
10085
|
+
* Mouse reports are what `mouse: true` trades for: while they are on, the
|
|
10086
|
+
* terminal sends the wheel and plain click-drag to the application instead of
|
|
10087
|
+
* scrolling its own scrollback or selecting text, which most terminals still
|
|
10088
|
+
* do with `Shift` (`Option` in iTerm2) held.
|
|
10089
|
+
*
|
|
10090
|
+
* The main screen draws into the terminal's scrollback from wherever the
|
|
10091
|
+
* shell left the cursor, so a click's screen row names no frame line by
|
|
10092
|
+
* itself. {@link PointerTerminal.locateCursor} asks the terminal where its
|
|
10093
|
+
* cursor is; the renderer knows which frame line it left the cursor on, and
|
|
10094
|
+
* the difference places every row.
|
|
10095
|
+
* @module @deepseek-ai/dsh-tui-app/pointer
|
|
10096
|
+
*/
|
|
10097
|
+
/** Report button presses and releases, encoded as SGR sequences. */
|
|
10098
|
+
const ENABLE_MOUSE = "\x1B[?1000h\x1B[?1006h";
|
|
10099
|
+
/** Stop reporting the mouse, which gives the wheel and selection back to the terminal. */
|
|
10100
|
+
const DISABLE_MOUSE = "\x1B[?1006l\x1B[?1000l";
|
|
10101
|
+
/** Device status report 6: the terminal answers with its cursor position. */
|
|
10102
|
+
const CURSOR_QUERY = "\x1B[6n";
|
|
10103
|
+
/** One SGR mouse report: button code, 1-based column and row, `M` for a press and `m` for a release. */
|
|
10104
|
+
const SGR_MOUSE = /^\u001b\[<(\d+);(\d+);(\d+)([Mm])$/u;
|
|
10105
|
+
/** A legacy X10 mouse report, which a terminal ignoring SGR mode could still send. */
|
|
10106
|
+
const X10_MOUSE = /^\u001b\[M[\s\S]{3}$/u;
|
|
10107
|
+
/** The answer to {@link CURSOR_QUERY}: 1-based row and column. */
|
|
10108
|
+
const CURSOR_REPORT = /^\u001b\[(\d+);(\d+)R$/u;
|
|
10109
|
+
/** Button code bits that mark a motion or wheel report rather than a press or release. */
|
|
10110
|
+
const NOT_A_BUTTON = 224;
|
|
10111
|
+
/** Button code of the left button, once the modifier bits are masked off. */
|
|
10112
|
+
const LEFT_BUTTON = 0;
|
|
10113
|
+
/** The button bits of a button code, without the `Shift`, `Alt`, and `Ctrl` bits. */
|
|
10114
|
+
const BUTTON_BITS = 3;
|
|
10115
|
+
/**
|
|
10116
|
+
* Parse one SGR mouse report.
|
|
10117
|
+
* @param data - one input sequence.
|
|
10118
|
+
* @returns the report, or undefined when `data` is not an SGR mouse report.
|
|
10119
|
+
*/
|
|
10120
|
+
function parsePointer(data) {
|
|
10121
|
+
const match = SGR_MOUSE.exec(data);
|
|
10122
|
+
if (match === null) return void 0;
|
|
10123
|
+
return {
|
|
10124
|
+
button: Number(match[1]),
|
|
10125
|
+
column: Number(match[2]) - 1,
|
|
10126
|
+
row: Number(match[3]) - 1,
|
|
10127
|
+
release: match[4] === "m"
|
|
10128
|
+
};
|
|
10129
|
+
}
|
|
10130
|
+
/**
|
|
10131
|
+
* Whether a report is the left button itself going down or up, rather than
|
|
10132
|
+
* motion, the wheel, or another button.
|
|
10133
|
+
* @param report - the parsed report.
|
|
10134
|
+
* @returns true for a left press or release.
|
|
10135
|
+
*/
|
|
10136
|
+
function isLeftButton(report) {
|
|
10137
|
+
return (report.button & NOT_A_BUTTON) === 0 && (report.button & BUTTON_BITS) === LEFT_BUTTON;
|
|
10138
|
+
}
|
|
10139
|
+
/**
|
|
10140
|
+
* The terminal the tree renders into, with clicks reported on top of it.
|
|
10141
|
+
*
|
|
10142
|
+
* A click is a left press and a left release on the same cell; any other
|
|
10143
|
+
* report, a wheel tick included, is consumed without effect, so no mouse
|
|
10144
|
+
* report ever reaches the editor as typed text. Every other method is the
|
|
10145
|
+
* wrapped terminal's own.
|
|
10146
|
+
*/
|
|
10147
|
+
var PointerTerminal = class {
|
|
10148
|
+
terminal;
|
|
10149
|
+
onClick;
|
|
10150
|
+
/** The callback pi-tui gave {@link PointerTerminal.start}, which a pressed key reaches. */
|
|
10151
|
+
deliver;
|
|
10152
|
+
/** Where the left button went down, until it comes up again. */
|
|
10153
|
+
pressed;
|
|
10154
|
+
/** What the next cursor report answers; set while one {@link CURSOR_QUERY} is unanswered. */
|
|
10155
|
+
located;
|
|
10156
|
+
/**
|
|
10157
|
+
* @param terminal - the terminal to report clicks on.
|
|
10158
|
+
* @param onClick - called with the cell of each click.
|
|
10159
|
+
*/
|
|
10160
|
+
constructor(terminal, onClick) {
|
|
10161
|
+
this.terminal = terminal;
|
|
10162
|
+
this.onClick = onClick;
|
|
10163
|
+
}
|
|
10164
|
+
get columns() {
|
|
10165
|
+
return this.terminal.columns;
|
|
10166
|
+
}
|
|
10167
|
+
get rows() {
|
|
10168
|
+
return this.terminal.rows;
|
|
10169
|
+
}
|
|
10170
|
+
get kittyProtocolActive() {
|
|
10171
|
+
return this.terminal.kittyProtocolActive;
|
|
10172
|
+
}
|
|
10173
|
+
/**
|
|
10174
|
+
* Start the wrapped terminal and turn mouse reports on.
|
|
10175
|
+
* @param onInput - pi-tui's input callback; every sequence that is neither a
|
|
10176
|
+
* mouse report nor an awaited cursor report reaches it unchanged.
|
|
10177
|
+
* @param onResize - pi-tui's resize callback.
|
|
10178
|
+
*/
|
|
10179
|
+
start(onInput, onResize) {
|
|
10180
|
+
this.deliver = onInput;
|
|
10181
|
+
this.terminal.start((data) => {
|
|
10182
|
+
this.receive(data);
|
|
10183
|
+
}, onResize);
|
|
10184
|
+
this.terminal.write(ENABLE_MOUSE);
|
|
10185
|
+
}
|
|
10186
|
+
/** Turn mouse reports off and stop the wrapped terminal; a pending cursor query is dropped. */
|
|
10187
|
+
stop() {
|
|
10188
|
+
this.located = void 0;
|
|
10189
|
+
this.pressed = void 0;
|
|
10190
|
+
this.terminal.write(DISABLE_MOUSE);
|
|
10191
|
+
this.terminal.stop();
|
|
10192
|
+
}
|
|
10193
|
+
/**
|
|
10194
|
+
* Press a key: its bytes reach pi-tui exactly as the terminal's own report
|
|
10195
|
+
* of that press would.
|
|
10196
|
+
* @param bytes - the key's bytes.
|
|
10197
|
+
*/
|
|
10198
|
+
press(bytes) {
|
|
10199
|
+
this.deliver?.(bytes);
|
|
10200
|
+
}
|
|
10201
|
+
/**
|
|
10202
|
+
* Ask the terminal which screen row its cursor is on.
|
|
10203
|
+
*
|
|
10204
|
+
* One query is in flight at a time: a second call while the first is
|
|
10205
|
+
* unanswered replaces the callback, so the newest click is the one the
|
|
10206
|
+
* answer places. A terminal that never answers leaves the callback unrun.
|
|
10207
|
+
* @param onRow - called with the cursor's screen row, counted from 0.
|
|
10208
|
+
*/
|
|
10209
|
+
locateCursor(onRow) {
|
|
10210
|
+
const pending = this.located !== void 0;
|
|
10211
|
+
this.located = onRow;
|
|
10212
|
+
if (!pending) this.terminal.write(CURSOR_QUERY);
|
|
10213
|
+
}
|
|
10214
|
+
/**
|
|
10215
|
+
* Answer one input sequence: a mouse report or an awaited cursor report is
|
|
10216
|
+
* this terminal's own; anything else is pi-tui's.
|
|
10217
|
+
* @param data - one input sequence.
|
|
10218
|
+
*/
|
|
10219
|
+
receive(data) {
|
|
10220
|
+
const report = parsePointer(data);
|
|
10221
|
+
if (report !== void 0) {
|
|
10222
|
+
this.onReport(report);
|
|
10223
|
+
return;
|
|
10224
|
+
}
|
|
10225
|
+
if (X10_MOUSE.test(data)) return;
|
|
10226
|
+
const located = this.located;
|
|
10227
|
+
const cursor = located === void 0 ? null : CURSOR_REPORT.exec(data);
|
|
10228
|
+
if (located !== void 0 && cursor !== null) {
|
|
10229
|
+
this.located = void 0;
|
|
10230
|
+
located(Number(cursor[1]) - 1);
|
|
10231
|
+
return;
|
|
10232
|
+
}
|
|
10233
|
+
this.deliver?.(data);
|
|
10234
|
+
}
|
|
10235
|
+
/**
|
|
10236
|
+
* Track the left button and report a click when it comes up where it went down.
|
|
10237
|
+
* @param report - one parsed mouse report.
|
|
10238
|
+
*/
|
|
10239
|
+
onReport(report) {
|
|
10240
|
+
if (!isLeftButton(report)) return;
|
|
10241
|
+
if (!report.release) {
|
|
10242
|
+
this.pressed = {
|
|
10243
|
+
column: report.column,
|
|
10244
|
+
row: report.row
|
|
10245
|
+
};
|
|
10246
|
+
return;
|
|
10247
|
+
}
|
|
10248
|
+
const pressed = this.pressed;
|
|
10249
|
+
this.pressed = void 0;
|
|
10250
|
+
if (pressed?.column === report.column && pressed.row === report.row) this.onClick(pressed);
|
|
10251
|
+
}
|
|
10252
|
+
drainInput(maxMs, idleMs) {
|
|
10253
|
+
return this.terminal.drainInput(maxMs, idleMs);
|
|
10254
|
+
}
|
|
10255
|
+
write(data) {
|
|
10256
|
+
this.terminal.write(data);
|
|
10257
|
+
}
|
|
10258
|
+
moveBy(lines) {
|
|
10259
|
+
this.terminal.moveBy(lines);
|
|
10260
|
+
}
|
|
10261
|
+
hideCursor() {
|
|
10262
|
+
this.terminal.hideCursor();
|
|
10263
|
+
}
|
|
10264
|
+
showCursor() {
|
|
10265
|
+
this.terminal.showCursor();
|
|
10266
|
+
}
|
|
10267
|
+
clearLine() {
|
|
10268
|
+
this.terminal.clearLine();
|
|
10269
|
+
}
|
|
10270
|
+
clearFromCursor() {
|
|
10271
|
+
this.terminal.clearFromCursor();
|
|
10272
|
+
}
|
|
10273
|
+
clearScreen() {
|
|
10274
|
+
this.terminal.clearScreen();
|
|
10275
|
+
}
|
|
10276
|
+
setTitle(title) {
|
|
10277
|
+
this.terminal.setTitle(title);
|
|
10278
|
+
}
|
|
10279
|
+
setProgress(active) {
|
|
10280
|
+
this.terminal.setProgress(active);
|
|
10281
|
+
}
|
|
10282
|
+
};
|
|
10283
|
+
//#endregion
|
|
9741
10284
|
//#region lib/types/reader-screen.js
|
|
9742
10285
|
/**
|
|
9743
10286
|
* The reader as the surface that owns the terminal: the pane drawn on the
|
|
@@ -10479,6 +11022,10 @@ var SyntaxHighlighter = class {
|
|
|
10479
11022
|
* side of every frame: the tree lays out in the columns that remain and each
|
|
10480
11023
|
* drawn line is moved right by that many spaces, so nothing the conversation
|
|
10481
11024
|
* or the docked chrome draws touches either edge of the terminal.
|
|
11025
|
+
*
|
|
11026
|
+
* Every frame leaves here without its key marks: the screen takes them out
|
|
11027
|
+
* of the finished frame, overlays composited, and keeps where each marked
|
|
11028
|
+
* key was drawn ({@link GuardedMainScreen.keyFrame}).
|
|
10482
11029
|
* @module @deepseek-ai/dsh-tui-app/screen
|
|
10483
11030
|
*/
|
|
10484
11031
|
/**
|
|
@@ -10552,6 +11099,8 @@ var GuardedMainScreen = class extends TuiMainScreen {
|
|
|
10552
11099
|
guard;
|
|
10553
11100
|
/** What draws instead while another surface holds the terminal; absent while this screen does. */
|
|
10554
11101
|
onSuspendedRender;
|
|
11102
|
+
/** The keys the last frame drew, by frame line. */
|
|
11103
|
+
keys = EMPTY_KEY_FRAME;
|
|
10555
11104
|
/**
|
|
10556
11105
|
* @param terminal - the terminal the tree renders into.
|
|
10557
11106
|
* @param showHardwareCursor - whether the terminal's own cursor is the caret.
|
|
@@ -10612,6 +11161,32 @@ var GuardedMainScreen = class extends TuiMainScreen {
|
|
|
10612
11161
|
}
|
|
10613
11162
|
suspended();
|
|
10614
11163
|
}
|
|
11164
|
+
/**
|
|
11165
|
+
* Where the last written frame drew its keys, and the frame line the
|
|
11166
|
+
* terminal's cursor was left on, which is what a cursor report places the
|
|
11167
|
+
* frame by.
|
|
11168
|
+
* @returns the snapshot; later frames never change it.
|
|
11169
|
+
*/
|
|
11170
|
+
keyFrame() {
|
|
11171
|
+
return {
|
|
11172
|
+
keys: this.keys,
|
|
11173
|
+
cursorLine: this.captureRenderState().hardwareCursorRow
|
|
11174
|
+
};
|
|
11175
|
+
}
|
|
11176
|
+
/**
|
|
11177
|
+
* Take every key mark out of the finished frame before pi-tui resets and
|
|
11178
|
+
* writes its lines, keeping where each key was drawn. The renderer calls
|
|
11179
|
+
* this once per frame, after the overlays are composited into it and before
|
|
11180
|
+
* it is compared with what the terminal holds, so the kept cells are the
|
|
11181
|
+
* written frame's own.
|
|
11182
|
+
* @param lines - the finished frame.
|
|
11183
|
+
* @returns the frame with pi-tui's line resets applied and no key mark left.
|
|
11184
|
+
*/
|
|
11185
|
+
applyLineResets(lines) {
|
|
11186
|
+
const marked = takeKeyFrame(lines);
|
|
11187
|
+
this.keys = marked.keys;
|
|
11188
|
+
return super.applyLineResets(marked.lines);
|
|
11189
|
+
}
|
|
10615
11190
|
/** Write the frame, unless another surface holds the terminal. */
|
|
10616
11191
|
doRender() {
|
|
10617
11192
|
if (this.onSuspendedRender !== void 0) return;
|
|
@@ -11144,8 +11719,8 @@ function renderSubagentPanel(view, render) {
|
|
|
11144
11719
|
return palette.dim(parts.join(SEPARATOR));
|
|
11145
11720
|
}
|
|
11146
11721
|
const counts = `subagents${SEPARATOR}${String(total)} listed`;
|
|
11147
|
-
const
|
|
11148
|
-
const lines = [palette.dim(
|
|
11722
|
+
const hints = focusHints(render.width - visibleWidth(counts) - visibleWidth(SEPARATOR));
|
|
11723
|
+
const lines = [`${palette.dim(`${counts}${SEPARATOR}`)}${paintKeys(palette, hints)}`];
|
|
11149
11724
|
for (const [index, row] of view.rows.entries()) lines.push(index === selected ? pulse(palette, palette.accent(row.text), render.level ?? 0) : palette.dim(row.text));
|
|
11150
11725
|
if (view.hidden > 0) lines.push(palette.dim(`+${String(view.hidden)} more${SEPARATOR}/subagents lists them all`));
|
|
11151
11726
|
if (render.failure !== void 0) lines.push(palette.dim(`listing failed: ${render.failure}`));
|
|
@@ -11338,10 +11913,10 @@ var ToastPane = class {
|
|
|
11338
11913
|
const body = truncateToWidth(this.text, field, ELLIPSIS);
|
|
11339
11914
|
const padding = " ".repeat(Math.max(0, field - visibleWidth(body)));
|
|
11340
11915
|
const lines = [
|
|
11341
|
-
`╭${rule}
|
|
11342
|
-
|
|
11343
|
-
`╰${rule}╯`
|
|
11344
|
-
]
|
|
11916
|
+
palette.dim(`╭${rule}╮`),
|
|
11917
|
+
`${palette.dim("│ ")}${paintKeys(palette, body, palette.dim, "prose")}${palette.dim(`${padding}│`)}`,
|
|
11918
|
+
palette.dim(`╰${rule}╯`)
|
|
11919
|
+
];
|
|
11345
11920
|
const age = this.settings.age();
|
|
11346
11921
|
return age === void 0 ? lines : recolorLines(lines, age, this.settings.style());
|
|
11347
11922
|
}
|
|
@@ -11367,6 +11942,8 @@ var ToastPane = class {
|
|
|
11367
11942
|
*/
|
|
11368
11943
|
/** A second Ctrl+C inside this window quits. */
|
|
11369
11944
|
const QUIT_DOUBLE_PRESS_MS = 600;
|
|
11945
|
+
/** Text drawn in the terminal's own colors, as a footer segment's detail rows are. */
|
|
11946
|
+
const plainText = (text) => text;
|
|
11370
11947
|
/** What input reports while the host is opening another session. */
|
|
11371
11948
|
const SESSION_SWITCH_WAIT = "wait for the session switch to finish";
|
|
11372
11949
|
/** What a session switch reports while a dispatched `/compact` runs. */
|
|
@@ -11598,6 +12175,11 @@ const LOCAL_COMMANDS = [
|
|
|
11598
12175
|
name: "settings",
|
|
11599
12176
|
description: "Inspect or change settings (/settings, /settings <ns>, /settings <ns> <path> <value>, /settings reset <ns>)"
|
|
11600
12177
|
},
|
|
12178
|
+
{
|
|
12179
|
+
name: "search",
|
|
12180
|
+
description: "Pick the web-search route (/search deepseek, /search openrouter [model])",
|
|
12181
|
+
hint: "<route>"
|
|
12182
|
+
},
|
|
11601
12183
|
{
|
|
11602
12184
|
name: "plugins",
|
|
11603
12185
|
description: "List the composed plugins (/plugins bundles, /plugins enable|disable <id>, /plugins add <spec>, /plugins remove <name>)"
|
|
@@ -11921,7 +12503,14 @@ var TuiApp = class {
|
|
|
11921
12503
|
contextPreviewLines: deps.contextPreviewLines,
|
|
11922
12504
|
codeHighlight: this.codeHighlight
|
|
11923
12505
|
};
|
|
11924
|
-
|
|
12506
|
+
let terminal = deps.terminal;
|
|
12507
|
+
if (palette.clickableKeys) {
|
|
12508
|
+
const pointer = new PointerTerminal(deps.terminal, (cell) => {
|
|
12509
|
+
this.onClick(pointer, cell);
|
|
12510
|
+
});
|
|
12511
|
+
terminal = pointer;
|
|
12512
|
+
}
|
|
12513
|
+
this.tui = new GuardedMainScreen(terminal, true, (viewportTop, width, frameLines) => {
|
|
11925
12514
|
return this.settleFrame(viewportTop, width, frameLines);
|
|
11926
12515
|
});
|
|
11927
12516
|
this.readerScreen = new AlternateScreen(deps.terminal);
|
|
@@ -12432,7 +13021,7 @@ var TuiApp = class {
|
|
|
12432
13021
|
const session = this.agent.session;
|
|
12433
13022
|
const title = this.deps.ctx.get("sessionTitle")?.get(session)?.title;
|
|
12434
13023
|
const name = title === void 0 ? `session ${session.id}` : `${title} ${palette.dim(`(${session.id})`)}`;
|
|
12435
|
-
const trail = this.parents.length === 0 ? palette.dim("· /help for commands") : this.asides.has(this.bound) ? `${palette.accent(`◆ ${BTW_VIEW_TITLE}`)} ${palette
|
|
13024
|
+
const trail = this.parents.length === 0 ? palette.dim("· /help for commands") : this.asides.has(this.bound) ? `${palette.accent(`◆ ${BTW_VIEW_TITLE}`)} ${paintKeys(palette, "· Ctrl+P ends it and returns")}` : `${palette.accent(`◆ subagent view ${"›".repeat(this.parents.length)}`)} ${paintKeys(palette, "· Ctrl+P returns")}`;
|
|
12436
13025
|
this.header.setText(`${palette.bold(palette.accent("dsh"))} ${palette.dim("·")} ${name} ${trail}`);
|
|
12437
13026
|
this.tui.requestRender();
|
|
12438
13027
|
}
|
|
@@ -13284,6 +13873,31 @@ var TuiApp = class {
|
|
|
13284
13873
|
return this.onAction(action, data);
|
|
13285
13874
|
}
|
|
13286
13875
|
/**
|
|
13876
|
+
* Press the key whose chip a click landed on, exactly as typing it would.
|
|
13877
|
+
*
|
|
13878
|
+
* The reader's screen is addressed by row. The main screen is drawn from
|
|
13879
|
+
* wherever the shell left the cursor, so the frame line under the click is
|
|
13880
|
+
* placed by asking the terminal where its cursor is: the renderer left it on
|
|
13881
|
+
* a known frame line, and the click is that many rows away. The keys are
|
|
13882
|
+
* read from the frame written when the click arrived, so a frame drawn
|
|
13883
|
+
* while the terminal answers cannot move the target.
|
|
13884
|
+
* @param pointer - the terminal the click was reported on, which presses the key.
|
|
13885
|
+
* @param cell - the clicked cell.
|
|
13886
|
+
*/
|
|
13887
|
+
onClick(pointer, cell) {
|
|
13888
|
+
if (this.readerScreen.active) {
|
|
13889
|
+
const key = this.readerScreen.keyAt(cell.row, cell.column);
|
|
13890
|
+
if (key !== void 0) pointer.press(key);
|
|
13891
|
+
return;
|
|
13892
|
+
}
|
|
13893
|
+
const frame = this.tui.keyFrame();
|
|
13894
|
+
pointer.locateCursor((cursorRow) => {
|
|
13895
|
+
if (this.readerScreen.active) return;
|
|
13896
|
+
const key = keyAt(frame.keys, frame.cursorLine + cell.row - cursorRow, cell.column);
|
|
13897
|
+
if (key !== void 0) pointer.press(key);
|
|
13898
|
+
});
|
|
13899
|
+
}
|
|
13900
|
+
/**
|
|
13287
13901
|
* Apply one resolved key action.
|
|
13288
13902
|
* @param action - what the key named where the keyboard is.
|
|
13289
13903
|
* @param data - the raw key bytes, which a typing action hands to the editor.
|
|
@@ -13768,7 +14382,7 @@ var TuiApp = class {
|
|
|
13768
14382
|
/* v8 ignore next -- the bar draws at least the model segment, and an absent id falls back to it */
|
|
13769
14383
|
if (segment === void 0) return;
|
|
13770
14384
|
if (segment.detail.kind === "rows") {
|
|
13771
|
-
this.showBlock(segment.detail.rows);
|
|
14385
|
+
this.showBlock(segment.detail.rows.map((row) => paintKeys(this.deps.palette, row, plainText, "prose")));
|
|
13772
14386
|
return;
|
|
13773
14387
|
}
|
|
13774
14388
|
this.navigate("/todos", () => this.browseTodos());
|
|
@@ -14224,6 +14838,9 @@ var TuiApp = class {
|
|
|
14224
14838
|
case "permission":
|
|
14225
14839
|
await this.choosePermission(argument);
|
|
14226
14840
|
return;
|
|
14841
|
+
case "search":
|
|
14842
|
+
await this.chooseSearchRoute(argument);
|
|
14843
|
+
return;
|
|
14227
14844
|
case "sessions":
|
|
14228
14845
|
case "resume":
|
|
14229
14846
|
await this.openSessionPicker();
|
|
@@ -14318,11 +14935,11 @@ var TuiApp = class {
|
|
|
14318
14935
|
*/
|
|
14319
14936
|
showHelp() {
|
|
14320
14937
|
const palette = this.deps.palette;
|
|
14321
|
-
const rows = this.completableCommands().map((command) => `/${command.name.padEnd(12)} ${palette
|
|
14938
|
+
const rows = this.completableCommands().map((command) => `/${command.name.padEnd(12)} ${paintKeys(palette, command.description, palette.dim, "prose")}`);
|
|
14322
14939
|
this.chat.addChild(new Text([
|
|
14323
14940
|
...rows,
|
|
14324
14941
|
"",
|
|
14325
|
-
...helpKeyLines().map(palette
|
|
14942
|
+
...helpKeyLines().map((line) => paintKeys(palette, line))
|
|
14326
14943
|
].join("\n"), 0, 1));
|
|
14327
14944
|
this.tui.requestRender();
|
|
14328
14945
|
}
|
|
@@ -14630,6 +15247,37 @@ var TuiApp = class {
|
|
|
14630
15247
|
this.refreshFooter();
|
|
14631
15248
|
}
|
|
14632
15249
|
/**
|
|
15250
|
+
* Choose the web-search route: an empty argument opens the picker on the
|
|
15251
|
+
* route in force, `deepseek` or `openrouter [model]` selects directly. Without a
|
|
15252
|
+
* typed model, `openrouter` searches with the model `/model` selected when that model is on the
|
|
15253
|
+
* `openrouter` provider.
|
|
15254
|
+
* @param argument - a route id with an optional OpenRouter model, or empty for the picker.
|
|
15255
|
+
*/
|
|
15256
|
+
async chooseSearchRoute(argument) {
|
|
15257
|
+
try {
|
|
15258
|
+
const [typed, model, ...extra] = argument === "" ? [] : argument.split(/\s+/u);
|
|
15259
|
+
let route;
|
|
15260
|
+
if (typed === void 0) {
|
|
15261
|
+
const picked = await this.showModal(new PickPrompt(this.deps.palette, "Web search route", [...SEARCH_ROUTE_ITEMS], { current: currentSearchRoute(this.deps.ctx) }));
|
|
15262
|
+
if (picked === void 0) return;
|
|
15263
|
+
route = picked.value;
|
|
15264
|
+
} else if (typed === "deepseek" || typed === "openrouter") route = typed;
|
|
15265
|
+
else {
|
|
15266
|
+
this.notice(`unknown search route "${typed}" (available: deepseek, openrouter)`, "error");
|
|
15267
|
+
return;
|
|
15268
|
+
}
|
|
15269
|
+
if (extra.length > 0 || model !== void 0 && route !== "openrouter") {
|
|
15270
|
+
this.notice("usage: /search deepseek | /search openrouter [model]", "error");
|
|
15271
|
+
return;
|
|
15272
|
+
}
|
|
15273
|
+
const selected = this.currentSelection();
|
|
15274
|
+
const inherited = selected.provider === "openrouter" ? selected.model : void 0;
|
|
15275
|
+
this.notice(await applySearchRoute(this.deps.ctx, route, model ?? inherited), "success");
|
|
15276
|
+
} catch (error) {
|
|
15277
|
+
this.notice(describeFailure(error), "error");
|
|
15278
|
+
}
|
|
15279
|
+
}
|
|
15280
|
+
/**
|
|
14633
15281
|
* Choose the bound session's permission preset: an empty argument opens
|
|
14634
15282
|
* the picker on the preset in force, and anything else names a catalog
|
|
14635
15283
|
* value. A pick submits `/permission <preset>` when the shared command
|
|
@@ -15665,9 +16313,9 @@ var TuiApp = class {
|
|
|
15665
16313
|
paintLoaderMessage(message) {
|
|
15666
16314
|
const palette = this.deps.palette;
|
|
15667
16315
|
const activity = this.loaderActivity;
|
|
15668
|
-
if (this.deps.reducedMotion || !message.startsWith(activity)) return palette.dim
|
|
16316
|
+
if (this.deps.reducedMotion || !message.startsWith(activity)) return paintKeys(palette, message, palette.dim, "prose");
|
|
15669
16317
|
const rest = message.slice(activity.length);
|
|
15670
|
-
return `${shimmer(palette, activity, this.deps.now())}${rest === "" ? "" : palette.dim
|
|
16318
|
+
return `${shimmer(palette, activity, this.deps.now())}${rest === "" ? "" : paintKeys(palette, rest, palette.dim, "prose")}`;
|
|
15671
16319
|
}
|
|
15672
16320
|
/**
|
|
15673
16321
|
* Draw the spinner label plus the current call's ↑send ↓receive suffix,
|
|
@@ -15891,6 +16539,7 @@ const Config = z.object({
|
|
|
15891
16539
|
streamPaceFrames: z.natural().default(8),
|
|
15892
16540
|
toolRevealFrames: z.natural().default(6),
|
|
15893
16541
|
reducedMotion: z.boolean().default(false),
|
|
16542
|
+
mouse: z.boolean().default(false),
|
|
15894
16543
|
openBrowser: z.boolean().default(true),
|
|
15895
16544
|
btwTools: z.array(z.string()).default([...BTW_TOOLS]),
|
|
15896
16545
|
btwSandboxedTools: z.array(z.string()).default([...BTW_SANDBOXED_TOOLS])
|
|
@@ -16152,7 +16801,7 @@ async function run(ctx, config, host) {
|
|
|
16152
16801
|
host: sessions,
|
|
16153
16802
|
initial,
|
|
16154
16803
|
terminal: host.createTerminal(),
|
|
16155
|
-
palette: createPalette(host.color),
|
|
16804
|
+
palette: createPalette(host.color, config.mouse),
|
|
16156
16805
|
toolPreviewLines: config.toolPreviewLines,
|
|
16157
16806
|
contextPreviewLines: config.contextPreviewLines,
|
|
16158
16807
|
focusPreviewLines: config.focusPreviewLines,
|