@linxiraos/pi-tui 1.4.11 → 1.4.13
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 +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/hotkeys-markdown.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +9 -2
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +22 -4
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
package/src/prompt/composer.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getComposerStyle } from "../components/composer/registry";
|
|
2
2
|
import { Spacer } from "../components/spacer";
|
|
3
3
|
import type { StatusLineComponent } from "../status-line/component";
|
|
4
|
-
import {
|
|
5
|
-
import { type
|
|
4
|
+
import { extensionLinkLabels } from "../render/extension-links";
|
|
5
|
+
import { LinkHints, type ViewportLink, viewportLinkTargets } from "../render/link-hints";
|
|
6
6
|
import type { StatusLineSession } from "../status-line/host";
|
|
7
|
-
import { createStartupStatusLine, type StatusLineStartupData } from "../status-line/startup";
|
|
7
|
+
import { createStartupStatusLine, type StatusLineStartupData, startupComposerState } from "../status-line/startup";
|
|
8
8
|
import { isInsideTerminalMultiplexer } from "../terminal-multiplexer";
|
|
9
9
|
import { ProcessTerminal, type Terminal } from "../terminal";
|
|
10
10
|
import {
|
|
@@ -19,13 +19,13 @@ import {
|
|
|
19
19
|
type ViewportSize,
|
|
20
20
|
} from "../tui";
|
|
21
21
|
import { wrapLiteralLine } from "../utils";
|
|
22
|
-
import type { NativeChild, NativeSurface, NativeSurfaceProvider } from "../native/node";
|
|
22
|
+
import type { DescribeContext, NativeChild, NativeSurface, NativeSurfaceProvider } from "../native/node";
|
|
23
23
|
import { sameItems } from "../native/memo";
|
|
24
24
|
import { postmortem } from "@linxiraos/pi-utils";
|
|
25
25
|
import { CustomEditor } from "./custom-editor";
|
|
26
26
|
import type { WordCompletionMethod } from "./word-completion";
|
|
27
27
|
import { type AnimationFrame, TranscriptContainer } from "../chrome/transcript-container";
|
|
28
|
-
import { WelcomeComponent } from "./welcome";
|
|
28
|
+
import { type VersionUpdate, WelcomeComponent } from "./welcome";
|
|
29
29
|
import { ensureThemeSync, getEditorTheme, theme } from "../theme/theme";
|
|
30
30
|
|
|
31
31
|
const DOUBLE_INTERRUPT_MS = 500;
|
|
@@ -66,6 +66,8 @@ export const COMPOSER_DEFAULTS: ComposerPreferences = {
|
|
|
66
66
|
/** Welcome data that can be supplied initially or patched as startup resolves it. */
|
|
67
67
|
export interface ComposerWelcomeUpdate {
|
|
68
68
|
readonly version?: string;
|
|
69
|
+
/** Background self-update activity after the version label; `null` clears it. */
|
|
70
|
+
readonly versionUpdate?: VersionUpdate | null;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -186,46 +188,12 @@ export function routeViewportClick(spans: readonly ViewportClickSpan[], index: n
|
|
|
186
188
|
return [];
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
/** An extension link label drawn on a mutable-viewport line: what a click or hint tag lands on. */
|
|
190
|
-
export interface ViewportLink {
|
|
191
|
-
readonly url: string;
|
|
192
|
-
/** Mutable-viewport line the label is drawn on. */
|
|
193
|
-
readonly row: number;
|
|
194
|
-
/** First cell of the label's part on that line. */
|
|
195
|
-
readonly start: number;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** An extension link label tagged for picking by keyboard in link-hint mode. */
|
|
199
|
-
interface ViewportLinkHint {
|
|
200
|
-
readonly tag: string;
|
|
201
|
-
readonly link: ViewportLink;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
191
|
/**
|
|
205
192
|
* Called once when link-hint mode ends; `reason` is `"crowded"` when a row held more links than
|
|
206
193
|
* their tags could fit side by side, so no tags were drawn.
|
|
207
194
|
*/
|
|
208
195
|
export type LinkHintsEnd = (reason?: "crowded") => void;
|
|
209
196
|
|
|
210
|
-
/**
|
|
211
|
-
* The extension link labels drawn on `rows`, top to bottom, a wrapped label once at its first row:
|
|
212
|
-
* a row's first label continues the previous row's last label when that has the same marker id
|
|
213
|
-
* and ends its row.
|
|
214
|
-
*/
|
|
215
|
-
function viewportLinkTargets(rows: readonly string[]): ViewportLink[] {
|
|
216
|
-
const targets: ViewportLink[] = [];
|
|
217
|
-
let previous: ExtensionLinkLabel | undefined;
|
|
218
|
-
for (let row = 0; row < rows.length; row++) {
|
|
219
|
-
const labels = extensionLinkLabels(rows[row]!);
|
|
220
|
-
for (const [index, label] of labels.entries()) {
|
|
221
|
-
if (index === 0 && previous?.endsRow && previous.id === label.id) continue;
|
|
222
|
-
targets.push({ url: label.url, row, start: label.start });
|
|
223
|
-
}
|
|
224
|
-
previous = labels.at(-1);
|
|
225
|
-
}
|
|
226
|
-
return targets;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
197
|
/**
|
|
230
198
|
* Reserved click-candidate id for the pinned HUD expander row. Checked before
|
|
231
199
|
* any registry lookup: its `@…:…` charset cannot collide with generated agent
|
|
@@ -269,6 +237,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
269
237
|
#preferences: ComposerPreferences;
|
|
270
238
|
#welcome: WelcomeComponent | undefined;
|
|
271
239
|
#version = "";
|
|
240
|
+
#versionUpdate: VersionUpdate | null = null;
|
|
272
241
|
#headerBefore: readonly Component[] = [];
|
|
273
242
|
#headerAfter: readonly Component[] = [];
|
|
274
243
|
#runtimeChildren: readonly Component[] = [];
|
|
@@ -314,12 +283,8 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
314
283
|
#lastViewportRows: readonly string[] = [];
|
|
315
284
|
/** Click-candidate id under the pointer, painted with the hover band. Id-anchored so it follows streaming rows. */
|
|
316
285
|
#hoveredClickId: string | undefined;
|
|
317
|
-
/**
|
|
318
|
-
|
|
319
|
-
* the first frame after `startLinkHints` assigns them), the letters typed so far, and what to run
|
|
320
|
-
* when the mode ends for any reason.
|
|
321
|
-
*/
|
|
322
|
-
#linkHints: { hints: ViewportLinkHint[] | undefined; typed: string; onEnd: LinkHintsEnd } | undefined;
|
|
286
|
+
/** Keyboard link-hint mode: its tags (assigned by the first frame after `startLinkHints`) and what to run when it ends. */
|
|
287
|
+
#linkHints: { hints: LinkHints; onEnd: LinkHintsEnd } | undefined;
|
|
323
288
|
/** Width of the last painted viewport, which `#lastViewportRows` was laid out for. */
|
|
324
289
|
#lastViewportWidth = 0;
|
|
325
290
|
// Hard-row prefix currently above the native viewport. The first resize
|
|
@@ -414,6 +379,8 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
414
379
|
this.#startupStatus = createStartupStatusLine(statusLine);
|
|
415
380
|
this.#statusHost.setComponent(this.#startupStatus);
|
|
416
381
|
this.#startupStatus.attachToEditor(this.editor, getComposerStyle(this.#preferences.composerShape));
|
|
382
|
+
const state = startupComposerState(statusLine);
|
|
383
|
+
this.editor.composerState = () => state;
|
|
417
384
|
}
|
|
418
385
|
// Emergency controls stay active until InteractiveMode installs configured bindings.
|
|
419
386
|
// They deliberately mirror the interactive editor's contract so a stalled startup
|
|
@@ -581,7 +548,8 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
581
548
|
const visibleHeaderRows = Math.max(0, rows - (mutable.length + drop));
|
|
582
549
|
this.#retiredHeaderStart = Math.max(0, history.rows.length - visibleHeaderRows);
|
|
583
550
|
}
|
|
584
|
-
|
|
551
|
+
const painted = this.#paintHoverBand(mutable, spans);
|
|
552
|
+
return { history, viewport: this.#linkHints?.hints.paint(painted, width) ?? painted };
|
|
585
553
|
}
|
|
586
554
|
|
|
587
555
|
/**
|
|
@@ -595,27 +563,9 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
595
563
|
#syncLinkHints(rows: readonly string[], width: number): void {
|
|
596
564
|
const state = this.#linkHints;
|
|
597
565
|
if (state === undefined) return;
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
if (hints
|
|
601
|
-
state.hints = linkHintTags(targets.length).map((tag, index) => ({ tag, link: targets[index]! }));
|
|
602
|
-
if (state.hints.length === 0) {
|
|
603
|
-
this.#endLinkHints();
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
} else {
|
|
607
|
-
const unchanged =
|
|
608
|
-
targets.length >= hints.length &&
|
|
609
|
-
hints.every(({ link }, index) => link.url === targets[index]!.url && link.start === targets[index]!.start);
|
|
610
|
-
if (!unchanged) {
|
|
611
|
-
this.#endLinkHints();
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
state.hints = hints.map(({ tag }, index) => ({ tag, link: targets[index]! }));
|
|
615
|
-
}
|
|
616
|
-
const cells = new Map<number, number>();
|
|
617
|
-
for (const { tag, link } of state.hints) cells.set(link.row, (cells.get(link.row) ?? 0) + tag.length);
|
|
618
|
-
if ([...cells.values()].some(count => count > width)) this.#endLinkHints("crowded");
|
|
566
|
+
const kept = state.hints.tagged ? state.hints.follow(rows) : state.hints.assign(rows) > 0;
|
|
567
|
+
if (!kept) this.#endLinkHints();
|
|
568
|
+
else if (state.hints.crowded(width)) this.#endLinkHints("crowded");
|
|
619
569
|
}
|
|
620
570
|
|
|
621
571
|
#endLinkHints(reason?: "crowded"): void {
|
|
@@ -625,46 +575,6 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
625
575
|
state.onEnd(reason);
|
|
626
576
|
}
|
|
627
577
|
|
|
628
|
-
/**
|
|
629
|
-
* Draw every tag the typed letters still lead to over the start of its label. Tags on one row
|
|
630
|
-
* never overlap: one that would land on an earlier tag moves right, and tags that would run past
|
|
631
|
-
* the right edge move left, so each stays readable as long as the row has room for them all.
|
|
632
|
-
*/
|
|
633
|
-
#paintLinkHints(viewport: string[], width: number): string[] {
|
|
634
|
-
const state = this.#linkHints;
|
|
635
|
-
if (state?.hints === undefined) return viewport;
|
|
636
|
-
const rows = new Map<number, { tag: string; col: number }[]>();
|
|
637
|
-
for (const { tag, link } of state.hints) {
|
|
638
|
-
if (viewport[link.row] === undefined || !tag.startsWith(state.typed)) continue;
|
|
639
|
-
let row = rows.get(link.row);
|
|
640
|
-
if (!row) rows.set(link.row, (row = []));
|
|
641
|
-
row.push({ tag, col: link.start });
|
|
642
|
-
}
|
|
643
|
-
const painted = [...viewport];
|
|
644
|
-
for (const [index, tags] of rows) {
|
|
645
|
-
tags.sort((a, b) => a.col - b.col);
|
|
646
|
-
let free = 0;
|
|
647
|
-
for (const placed of tags) {
|
|
648
|
-
placed.col = Math.max(placed.col, free);
|
|
649
|
-
free = placed.col + placed.tag.length;
|
|
650
|
-
}
|
|
651
|
-
let limit = width;
|
|
652
|
-
for (let i = tags.length - 1; i >= 0; i--) {
|
|
653
|
-
const placed = tags[i]!;
|
|
654
|
-
placed.col = Math.max(0, Math.min(placed.col, limit - placed.tag.length));
|
|
655
|
-
limit = placed.col;
|
|
656
|
-
}
|
|
657
|
-
let line = painted[index]!;
|
|
658
|
-
for (const { tag, col } of tags) {
|
|
659
|
-
// Raw SGR like the hover highlight: chalk's inverse/bold drop out when it detects no color.
|
|
660
|
-
const styled = `\x1b[1;7m${theme.fg("accent", tag)}\x1b[22;27m`;
|
|
661
|
-
line = compositeLineAt(line, styled, col, tag.length, width);
|
|
662
|
-
}
|
|
663
|
-
painted[index] = line;
|
|
664
|
-
}
|
|
665
|
-
return painted;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
578
|
/**
|
|
669
579
|
* Describe the whole surface for a TSP terminal. `main` is the flowing
|
|
670
580
|
* document: the header (welcome, extras) and every transcript block as its
|
|
@@ -674,7 +584,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
674
584
|
* row, the editor and the status line. There is no history/viewport split:
|
|
675
585
|
* retirement, resize replay and hover bands are ANSI concerns.
|
|
676
586
|
*/
|
|
677
|
-
describeSurface(): NativeSurface {
|
|
587
|
+
describeSurface(cx: DescribeContext): NativeSurface {
|
|
678
588
|
if (!this.#started || this.#stopped) return this.#nativeSurface;
|
|
679
589
|
const main: NativeChild[] = [...this.#header.children];
|
|
680
590
|
const dock: NativeChild[] = [];
|
|
@@ -688,7 +598,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
688
598
|
dock.push(...roots);
|
|
689
599
|
} else {
|
|
690
600
|
const transcript = roots[transcriptIndex] as TranscriptContainer;
|
|
691
|
-
main.push(...roots.slice(0, transcriptIndex), ...transcript.nativeBlocks());
|
|
601
|
+
main.push(...roots.slice(0, transcriptIndex), ...transcript.nativeBlocks(cx));
|
|
692
602
|
for (const root of this.#nativeTail) main.push(...root.children);
|
|
693
603
|
const tail: readonly Component[] = this.#nativeTail;
|
|
694
604
|
dock.push(...(this.#nativeDock ?? roots.slice(transcriptIndex + 1).filter(root => !tail.includes(root))));
|
|
@@ -816,7 +726,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
816
726
|
*/
|
|
817
727
|
startLinkHints(onEnd: LinkHintsEnd): void {
|
|
818
728
|
this.#endLinkHints();
|
|
819
|
-
this.#linkHints = { hints:
|
|
729
|
+
this.#linkHints = { hints: new LinkHints(), onEnd };
|
|
820
730
|
}
|
|
821
731
|
|
|
822
732
|
/** Whether link-hint mode is on. */
|
|
@@ -833,18 +743,11 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
833
743
|
const state = this.#linkHints;
|
|
834
744
|
if (state === undefined) return false;
|
|
835
745
|
// A key typed before the tags were first painted picks among the labels last drawn.
|
|
836
|
-
if (state.hints
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
const picked = matching.length === 1 && matching[0]!.tag === typed ? matching[0]!.link : undefined;
|
|
842
|
-
if (matching.length === 0 || picked !== undefined) {
|
|
843
|
-
this.#endLinkHints();
|
|
844
|
-
return picked ?? false;
|
|
845
|
-
}
|
|
846
|
-
state.typed = typed;
|
|
847
|
-
return true;
|
|
746
|
+
if (!state.hints.tagged) this.#syncLinkHints(this.#lastViewportRows, this.#lastViewportWidth);
|
|
747
|
+
if (this.#linkHints !== state) return false;
|
|
748
|
+
const result = state.hints.type(letter);
|
|
749
|
+
if (result !== true) this.#endLinkHints();
|
|
750
|
+
return result;
|
|
848
751
|
}
|
|
849
752
|
|
|
850
753
|
/** Leave link-hint mode without picking a link. */
|
|
@@ -1209,6 +1112,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
1209
1112
|
const welcome = this.#welcome;
|
|
1210
1113
|
if (!welcome) return;
|
|
1211
1114
|
if (update.version !== undefined) welcome.setVersion(this.#version);
|
|
1115
|
+
if (update.versionUpdate !== undefined) welcome.setVersionUpdate(this.#versionUpdate);
|
|
1212
1116
|
this.ui.requestRender();
|
|
1213
1117
|
}
|
|
1214
1118
|
|
|
@@ -1319,10 +1223,13 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
1319
1223
|
|
|
1320
1224
|
#applyWelcomeUpdate(update: ComposerWelcomeUpdate): void {
|
|
1321
1225
|
if (update.version !== undefined) this.#version = update.version;
|
|
1226
|
+
if (update.versionUpdate !== undefined) this.#versionUpdate = update.versionUpdate;
|
|
1322
1227
|
}
|
|
1323
1228
|
|
|
1324
1229
|
#ensureWelcome(): void {
|
|
1325
|
-
|
|
1230
|
+
if (this.#welcome) return;
|
|
1231
|
+
this.#welcome = new WelcomeComponent(this.#version);
|
|
1232
|
+
this.#welcome.setVersionUpdate(this.#versionUpdate);
|
|
1326
1233
|
}
|
|
1327
1234
|
|
|
1328
1235
|
#rebuildHeader(): void {
|
|
@@ -42,6 +42,7 @@ import { type MacOSSpellingFeatures, MacOSSpellingProvider } from "./macos-spell
|
|
|
42
42
|
import { TypingWordTracker } from "./typing-word";
|
|
43
43
|
import { hasMagicKeyword, highlightMagicKeywords, magicKeywordRanges } from "./magic-keywords";
|
|
44
44
|
import type { TspEditorDecoration, TspText } from "@linxiraos/pi-wire";
|
|
45
|
+
import { motionEffectsEnabled } from "../motion-effects";
|
|
45
46
|
import { isNativeRendering } from "../native/state";
|
|
46
47
|
import { isQueuedMessageList, parseQueueShorthand, QUEUE_LIST_MARKER_RE } from "./queue-input";
|
|
47
48
|
import { type WordCompletionMethod, WordCompletionProvider } from "./word-completion";
|
|
@@ -620,7 +621,7 @@ export class CustomEditor extends Editor {
|
|
|
620
621
|
name => this.skillFilePath(name) !== undefined,
|
|
621
622
|
register,
|
|
622
623
|
),
|
|
623
|
-
selector => this.#
|
|
624
|
+
selector => this.#mentionChipFor(selector),
|
|
624
625
|
register,
|
|
625
626
|
),
|
|
626
627
|
);
|
|
@@ -635,18 +636,20 @@ export class CustomEditor extends Editor {
|
|
|
635
636
|
*/
|
|
636
637
|
skillFilePath: (name: string) => string | undefined = () => undefined;
|
|
637
638
|
|
|
638
|
-
/**
|
|
639
|
-
|
|
639
|
+
/**
|
|
640
|
+
* Host-owned model probe: a mentionable `provider/id[:level]` selector's chip label and
|
|
641
|
+
* canonical selector, so equivalent spellings (`:hi`/`:high`, bare/`:auto`) share a chip.
|
|
642
|
+
*/
|
|
643
|
+
resolveModelMention: (selector: string) => { label: string; selector: string } | undefined = () => undefined;
|
|
640
644
|
|
|
641
645
|
/** Host-owned session probe: maps a persisted model pseudonym back to its selector. */
|
|
642
646
|
modelMentionSelector: (agent: string) => string | undefined = () => undefined;
|
|
643
647
|
|
|
644
|
-
#
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
return registered !== undefined && registered !== expansion ? undefined : label;
|
|
648
|
+
#mentionChipFor(selector: string): { label: string; selector: string } | undefined {
|
|
649
|
+
const chip = this.resolveModelMention(selector);
|
|
650
|
+
if (chip === undefined) return undefined;
|
|
651
|
+
const registered = this.atoms.get(chip.label);
|
|
652
|
+
return registered === undefined || registered === modelMentionToken(chip.selector) ? chip : undefined;
|
|
650
653
|
}
|
|
651
654
|
|
|
652
655
|
/**
|
|
@@ -700,9 +703,9 @@ export class CustomEditor extends Editor {
|
|
|
700
703
|
const start = match.index + match[1].length;
|
|
701
704
|
const end = match.index + match[0].length;
|
|
702
705
|
if (end === line.length && i === lines.length - 1) break;
|
|
703
|
-
const
|
|
704
|
-
if (
|
|
705
|
-
this.collapseToAtom(i, start, end, label, modelMentionToken(selector));
|
|
706
|
+
const chip = this.#mentionChipFor(selector);
|
|
707
|
+
if (chip === undefined) continue;
|
|
708
|
+
this.collapseToAtom(i, start, end, chip.label, modelMentionToken(chip.selector));
|
|
706
709
|
collapsed = true;
|
|
707
710
|
anyCollapsed = true;
|
|
708
711
|
break;
|
|
@@ -871,7 +874,8 @@ export class CustomEditor extends Editor {
|
|
|
871
874
|
const caret = this.getCursor();
|
|
872
875
|
this.#typing.update(this.textRevision, this.#decorationLines, caret.line, caret.col, this.focused);
|
|
873
876
|
const typing = this.#typing.word;
|
|
874
|
-
|
|
877
|
+
// With decorative motion off the keyword keeps its static highlight; the pending frame chain ends here.
|
|
878
|
+
const animated = this.focused && this.#shimmerEnabled() && motionEffectsEnabled() && hasMagicKeyword(editorText);
|
|
875
879
|
const phase = animated ? (Date.now() % CustomEditor.SHIMMER_PERIOD_MS) / CustomEditor.SHIMMER_PERIOD_MS : 0;
|
|
876
880
|
if (animated) this.#scheduleShimmerFrame();
|
|
877
881
|
let sourceSearchOffset = 0;
|
|
@@ -19,8 +19,8 @@ export interface GradientHighlightSpec {
|
|
|
19
19
|
hue: (t: number) => number;
|
|
20
20
|
/** HSL saturation percentage. Default 90. */
|
|
21
21
|
saturation?: number;
|
|
22
|
-
/** HSL lightness percentage. Default 62. */
|
|
23
|
-
lightness?: number;
|
|
22
|
+
/** Maps a normalized position `t` in [0, 1) to an HSL lightness percentage. Default: 62 everywhere. */
|
|
23
|
+
lightness?: (t: number) => number;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Build a stateless highlighter that paints each standalone match of `highlight`
|
|
@@ -24,8 +24,8 @@ export interface GradientHighlightSpec {
|
|
|
24
24
|
hue: (t: number) => number;
|
|
25
25
|
/** HSL saturation percentage. Default 90. */
|
|
26
26
|
saturation?: number;
|
|
27
|
-
/** HSL lightness percentage. Default 62. */
|
|
28
|
-
lightness?: number;
|
|
27
|
+
/** Maps a normalized position `t` in [0, 1) to an HSL lightness percentage. Default: 62 everywhere. */
|
|
28
|
+
lightness?: (t: number) => number;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -36,7 +36,7 @@ export interface GradientHighlightSpec {
|
|
|
36
36
|
* memoized per active color mode.
|
|
37
37
|
*/
|
|
38
38
|
export function createGradientHighlighter(spec: GradientHighlightSpec): KeywordHighlighter {
|
|
39
|
-
const { probe, highlight, stops, hue, saturation = 90, lightness = 62 } = spec;
|
|
39
|
+
const { probe, highlight, stops, hue, saturation = 90, lightness = () => 62 } = spec;
|
|
40
40
|
|
|
41
41
|
let cachedMode: string | undefined;
|
|
42
42
|
let cachedPalette: readonly string[] | undefined;
|
|
@@ -51,7 +51,8 @@ export function createGradientHighlighter(spec: GradientHighlightSpec): KeywordH
|
|
|
51
51
|
const format = mode === "truecolor" ? "ansi-16m" : "ansi-256";
|
|
52
52
|
const next: string[] = [];
|
|
53
53
|
for (let i = 0; i < stops; i++) {
|
|
54
|
-
|
|
54
|
+
const t = i / stops;
|
|
55
|
+
next.push(Bun.color(`hsl(${Math.round(hue(t))}, ${saturation}%, ${Math.round(lightness(t))}%)`, format) ?? "");
|
|
55
56
|
}
|
|
56
57
|
cachedMode = mode;
|
|
57
58
|
cachedPalette = next;
|
|
@@ -12,6 +12,8 @@ export interface MagicKeywordSpec {
|
|
|
12
12
|
readonly word: string;
|
|
13
13
|
/** HSL hue sweep `[from, to]` in degrees painted across the word; `to` may exceed 360 to wrap through red. */
|
|
14
14
|
readonly hue: readonly [number, number];
|
|
15
|
+
/** HSL lightness sweep `[from, to]` in percent painted alongside `hue`; omitted keeps the default lightness. */
|
|
16
|
+
readonly lightness?: readonly [number, number];
|
|
15
17
|
}
|
|
16
18
|
export interface RegisteredKeyword {
|
|
17
19
|
readonly word: string;
|
|
@@ -15,6 +15,8 @@ export interface MagicKeywordSpec {
|
|
|
15
15
|
readonly word: string;
|
|
16
16
|
/** HSL hue sweep `[from, to]` in degrees painted across the word; `to` may exceed 360 to wrap through red. */
|
|
17
17
|
readonly hue: readonly [number, number];
|
|
18
|
+
/** HSL lightness sweep `[from, to]` in percent painted alongside `hue`; omitted keeps the default lightness. */
|
|
19
|
+
readonly lightness?: readonly [number, number];
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/** Characters that bind a magic keyword into an identifier or path segment. */
|
|
@@ -79,7 +81,7 @@ export function setMagicKeywords(specs: readonly MagicKeywordSpec[]): void {
|
|
|
79
81
|
|
|
80
82
|
/** Build the painter table for a keyword spec list. */
|
|
81
83
|
function buildRegistry(specs: readonly MagicKeywordSpec[]): readonly RegisteredKeyword[] {
|
|
82
|
-
return specs.map(({ word, hue: [from, to] }) => ({
|
|
84
|
+
return specs.map(({ word, hue: [from, to], lightness }) => ({
|
|
83
85
|
word,
|
|
84
86
|
pattern: magicKeywordRegex(word, "g"),
|
|
85
87
|
highlight: createGradientHighlighter({
|
|
@@ -87,6 +89,7 @@ function buildRegistry(specs: readonly MagicKeywordSpec[]): readonly RegisteredK
|
|
|
87
89
|
highlight: magicKeywordRegex(word, "g"),
|
|
88
90
|
stops: 14,
|
|
89
91
|
hue: t => (from + t * (to - from)) % 360,
|
|
92
|
+
lightness: lightness && (t => lightness[0] + t * (lightness[1] - lightness[0])),
|
|
90
93
|
}),
|
|
91
94
|
}));
|
|
92
95
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Model } from "@linxiraos/pi-ai";
|
|
2
|
-
import
|
|
2
|
+
import { getSupportedEfforts } from "@linxiraos/pi-catalog/model-thinking";
|
|
3
|
+
import type { AutocompleteItem, ModelMentionCompletion } from "../index";
|
|
3
4
|
import type { ModelBrowserRegistry, ModelBrowserSource } from "../overlays/model-browser";
|
|
4
|
-
import {
|
|
5
|
+
import { sameItems } from "../native/memo";
|
|
6
|
+
import { modelMentionDisplayName, modelMentionName } from "./model-mention-syntax";
|
|
5
7
|
import type {
|
|
6
8
|
buildSearchAffinity as BuildSearchAffinity,
|
|
7
9
|
ModelBrowserItem,
|
|
@@ -12,9 +14,15 @@ import { theme } from "../theme/theme";
|
|
|
12
14
|
|
|
13
15
|
const MODEL_MENTION_CONTEXT_RE = /(?:^|\s)(\^[^\s]*)$/;
|
|
14
16
|
const MAX_MODEL_MENTION_SUGGESTIONS = 20;
|
|
17
|
+
const MAX_EFFORT_CANDIDATE_MODELS = 3;
|
|
15
18
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Supplies picker-ranked model candidates for the query after `^`. `availableModelIds`
|
|
21
|
+
* lists every available model's selector, in or out of the picker scope.
|
|
22
|
+
*/
|
|
23
|
+
export type ModelMentionCandidateSource = ((query: string) => ReadonlyArray<ModelBrowserItem>) & {
|
|
24
|
+
availableModelIds?: () => ReadonlySet<string>;
|
|
25
|
+
};
|
|
18
26
|
|
|
19
27
|
interface ModelBrowserModules {
|
|
20
28
|
SessionModelScopeCache: typeof SessionModelScopeCacheClass;
|
|
@@ -32,25 +40,59 @@ export function isModelMentionPrefix(prefix: string): boolean {
|
|
|
32
40
|
return prefix.startsWith("^");
|
|
33
41
|
}
|
|
34
42
|
|
|
43
|
+
function mentionRow(value: string, description: string): AutocompleteItem {
|
|
44
|
+
return { value, label: value, description, icon: theme.symbol("icon.model"), iconName: "model" };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Some provider model ids contain a colon or end in a level name (`qwen3:8b`, `glm-4.7:max`),
|
|
49
|
+
* so literal matches are listed before level rows.
|
|
50
|
+
*/
|
|
51
|
+
function mentionRows(query: string, candidates: ModelMentionCandidateSource): AutocompleteItem[] {
|
|
52
|
+
const colon = query.lastIndexOf(":");
|
|
53
|
+
if (colon > 0) {
|
|
54
|
+
const typed = query.slice(colon + 1).toLowerCase();
|
|
55
|
+
const levelRows: AutocompleteItem[] = [];
|
|
56
|
+
for (const { selector, model } of candidates(query.slice(0, colon)).slice(0, MAX_EFFORT_CANDIDATE_MODELS)) {
|
|
57
|
+
for (const effort of getSupportedEfforts(model)) {
|
|
58
|
+
if (!effort.startsWith(typed)) continue;
|
|
59
|
+
levelRows.push(
|
|
60
|
+
mentionRow(`${selector}:${effort}`, modelMentionName(modelMentionDisplayName(model), effort)),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (levelRows.length > 0) {
|
|
65
|
+
const lowered = query.toLowerCase();
|
|
66
|
+
const literalRows: AutocompleteItem[] = [];
|
|
67
|
+
for (const item of candidates(query)) {
|
|
68
|
+
if (literalRows.length === MAX_MODEL_MENTION_SUGGESTIONS) break;
|
|
69
|
+
if (item.selector.toLowerCase().includes(lowered)) {
|
|
70
|
+
literalRows.push(mentionRow(item.selector, modelMentionDisplayName(item.model)));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const literalValues = new Set(literalRows.map(row => row.value));
|
|
74
|
+
const available = candidates.availableModelIds?.();
|
|
75
|
+
return [
|
|
76
|
+
...literalRows,
|
|
77
|
+
...levelRows.filter(row => !literalValues.has(row.value) && !available?.has(row.value)),
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return candidates(query)
|
|
82
|
+
.slice(0, MAX_MODEL_MENTION_SUGGESTIONS)
|
|
83
|
+
.map(item => mentionRow(item.selector, modelMentionDisplayName(item.model)));
|
|
84
|
+
}
|
|
85
|
+
|
|
35
86
|
/** Build model mention choices for the whitespace-delimited token at the cursor. */
|
|
36
87
|
export function getModelMentionSuggestions(
|
|
37
88
|
textBeforeCursor: string,
|
|
38
89
|
candidates: ModelMentionCandidateSource | undefined,
|
|
39
|
-
):
|
|
40
|
-
if (!candidates) return
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.slice(0, MAX_MODEL_MENTION_SUGGESTIONS)
|
|
46
|
-
.map(item => ({
|
|
47
|
-
value: item.selector,
|
|
48
|
-
label: item.selector,
|
|
49
|
-
description: modelMentionDisplayName(item.model),
|
|
50
|
-
icon: theme.symbol("icon.model"),
|
|
51
|
-
iconName: "model",
|
|
52
|
-
}));
|
|
53
|
-
return items.length > 0 ? { items, prefix } : null;
|
|
90
|
+
): ModelMentionCompletion {
|
|
91
|
+
if (!candidates) return { kind: "unhandled" };
|
|
92
|
+
const prefix = textBeforeCursor.match(MODEL_MENTION_CONTEXT_RE)?.[1];
|
|
93
|
+
if (!prefix) return { kind: "unhandled" };
|
|
94
|
+
const items = mentionRows(prefix.slice(1), candidates).slice(0, MAX_MODEL_MENTION_SUGGESTIONS);
|
|
95
|
+
return items.length > 0 ? { kind: "matched", suggestions: { items, prefix } } : { kind: "no-match" };
|
|
54
96
|
}
|
|
55
97
|
|
|
56
98
|
/** Replace the live mention token with the selected canonical selector and a trailing space. */
|
|
@@ -88,7 +130,7 @@ export function createModelMentionSource(host: {
|
|
|
88
130
|
let scopeCache: SessionModelScopeCacheClass | undefined;
|
|
89
131
|
let ranker: ModelItemRankerClass | undefined;
|
|
90
132
|
let rankerProviderOrder: readonly string[] | undefined;
|
|
91
|
-
|
|
133
|
+
const rank = (query: string): ReadonlyArray<ModelBrowserItem> => {
|
|
92
134
|
const { SessionModelScopeCache, buildSearchAffinity, ModelItemRanker } = loadModelBrowser();
|
|
93
135
|
scopeCache ??= new SessionModelScopeCache(host.source, host.registry);
|
|
94
136
|
const scope = scopeCache.get(host.scopedModels());
|
|
@@ -104,4 +146,15 @@ export function createModelMentionSource(host: {
|
|
|
104
146
|
}
|
|
105
147
|
return ranker.rank(query);
|
|
106
148
|
};
|
|
149
|
+
let availableModels: readonly Model[] | undefined;
|
|
150
|
+
let availableIds: ReadonlySet<string> = new Set();
|
|
151
|
+
const availableModelIds = (): ReadonlySet<string> => {
|
|
152
|
+
const models = host.registry.getAvailable();
|
|
153
|
+
if (!sameItems(availableModels, models)) {
|
|
154
|
+
availableModels = models;
|
|
155
|
+
availableIds = new Set(models.map(model => `${model.provider}/${model.id}`));
|
|
156
|
+
}
|
|
157
|
+
return availableIds;
|
|
158
|
+
};
|
|
159
|
+
return Object.assign(rank, { availableModelIds });
|
|
107
160
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* the startup composer prepaint graph never loads the catalog or task agents.
|
|
5
5
|
*/
|
|
6
6
|
import type { Model } from "@linxiraos/pi-ai";
|
|
7
|
+
import type { Effort } from "@linxiraos/pi-catalog/effort";
|
|
7
8
|
/** Whitespace-delimited token; groups are leading delimiter and selector. Reset lastIndex before reuse. */
|
|
8
9
|
export declare const MODEL_MENTION_RE: RegExp;
|
|
9
10
|
/** Submitted mention; groups are agent pseudonym and display name. */
|
|
@@ -11,8 +12,11 @@ export declare const MODEL_MENTION_TAG_RE: RegExp;
|
|
|
11
12
|
/** A user-tagged model usable as a subagent pseudonym on the current session branch. */
|
|
12
13
|
export interface ModelMention {
|
|
13
14
|
agent: string;
|
|
15
|
+
/** Canonical selector: `provider/id`, plus `:<effort>` when the tag names one. */
|
|
14
16
|
selector: string;
|
|
15
17
|
name: string;
|
|
18
|
+
/** Initial effort from the tag's `:<level>` suffix; absent keeps the agent's default policy. */
|
|
19
|
+
thinkingLevel?: Effort;
|
|
16
20
|
}
|
|
17
21
|
/** Expand a composer atom back into its canonical model selector. */
|
|
18
22
|
export declare function modelMentionToken(selector: string): string;
|
|
@@ -20,5 +24,7 @@ export declare function modelMentionToken(selector: string): string;
|
|
|
20
24
|
export declare function modelMentionTag(mention: ModelMention): string;
|
|
21
25
|
/** Use the catalog display name, without quotes, or the id when the name is empty. */
|
|
22
26
|
export declare function modelMentionDisplayName(model: Model): string;
|
|
27
|
+
/** Display name of a mention, naming the tagged effort so tags of one model stay distinct. */
|
|
28
|
+
export declare function modelMentionName(displayName: string, thinkingLevel: Effort): string;
|
|
23
29
|
/** Restore known submitted tags to editable selectors; leave unknown agents literal. */
|
|
24
30
|
export declare function expandModelMentionTags(text: string, selectorFor: (agent: string) => string | undefined): string;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* the startup composer prepaint graph never loads the catalog or task agents.
|
|
5
5
|
*/
|
|
6
6
|
import type { Model } from "@linxiraos/pi-ai";
|
|
7
|
+
import type { Effort } from "@linxiraos/pi-catalog/effort";
|
|
7
8
|
|
|
8
9
|
/** Whitespace-delimited token; groups are leading delimiter and selector. Reset lastIndex before reuse. */
|
|
9
10
|
export const MODEL_MENTION_RE = /(^|\s)\^([^\s^]+)(?=\s|$)/g;
|
|
@@ -13,8 +14,11 @@ export const MODEL_MENTION_TAG_RE = /<model agent="(m\d+)" name="([^"]*)"\/>/g;
|
|
|
13
14
|
/** A user-tagged model usable as a subagent pseudonym on the current session branch. */
|
|
14
15
|
export interface ModelMention {
|
|
15
16
|
agent: string;
|
|
17
|
+
/** Canonical selector: `provider/id`, plus `:<effort>` when the tag names one. */
|
|
16
18
|
selector: string;
|
|
17
19
|
name: string;
|
|
20
|
+
/** Initial effort from the tag's `:<level>` suffix; absent keeps the agent's default policy. */
|
|
21
|
+
thinkingLevel?: Effort;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/** Expand a composer atom back into its canonical model selector. */
|
|
@@ -32,6 +36,11 @@ export function modelMentionDisplayName(model: Model): string {
|
|
|
32
36
|
return (model.name.trim() || model.id).replaceAll('"', "");
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
/** Display name of a mention, naming the tagged effort so tags of one model stay distinct. */
|
|
40
|
+
export function modelMentionName(displayName: string, thinkingLevel: Effort): string {
|
|
41
|
+
return `${displayName} · ${thinkingLevel}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
/** Restore known submitted tags to editable selectors; leave unknown agents literal. */
|
|
36
45
|
export function expandModelMentionTags(text: string, selectorFor: (agent: string) => string | undefined): string {
|
|
37
46
|
return text.replace(MODEL_MENTION_TAG_RE, (tag, agent: string) => {
|