acryl 0.0.0 → 0.1.10
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 +5 -0
- package/lib/bin.js +5189 -0
- package/lib/bin.js.map +1 -0
- package/lib/index.js +5051 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bin.d.ts +4 -0
- package/lib/types/cli/grammar.d.ts +9 -0
- package/lib/types/cli/node-launcher.d.ts +9 -0
- package/lib/types/cli/run.d.ts +32 -0
- package/lib/types/host/direct.d.ts +18 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/markdown.d.ts +28 -0
- package/lib/types/render.d.ts +78 -0
- package/lib/types/sessionId.d.ts +12 -0
- package/lib/types/tui/CustomEditor.d.ts +51 -0
- package/lib/types/tui/Spinner.d.ts +18 -0
- package/lib/types/tui/TuiApp.d.ts +64 -0
- package/lib/types/tui/actions.d.ts +85 -0
- package/lib/types/tui/agentPresets/AgentPresetsOverlay.d.ts +19 -0
- package/lib/types/tui/agentPresets/types.d.ts +18 -0
- package/lib/types/tui/bannerText.d.ts +19 -0
- package/lib/types/tui/commands.d.ts +54 -0
- package/lib/types/tui/context/ContextOverlay.d.ts +17 -0
- package/lib/types/tui/fileIndex.d.ts +17 -0
- package/lib/types/tui/fileMention.d.ts +31 -0
- package/lib/types/tui/interaction/ApprovalOverlay.d.ts +18 -0
- package/lib/types/tui/interaction/QuestionOverlay.d.ts +26 -0
- package/lib/types/tui/interaction/types.d.ts +36 -0
- package/lib/types/tui/liveText.d.ts +60 -0
- package/lib/types/tui/logoArt.generated.d.ts +9 -0
- package/lib/types/tui/miniTextField.d.ts +20 -0
- package/lib/types/tui/modelProfile/ModelProfileOverlay.d.ts +48 -0
- package/lib/types/tui/modelProfile/types.d.ts +63 -0
- package/lib/types/tui/piTheme.d.ts +10 -0
- package/lib/types/tui/plugins/PluginsOverlay.d.ts +22 -0
- package/lib/types/tui/plugins/types.d.ts +18 -0
- package/lib/types/tui/promptAutocomplete.d.ts +29 -0
- package/lib/types/tui/statsFormat.d.ts +89 -0
- package/lib/types/tui/store.d.ts +246 -0
- package/lib/types/tui/text.d.ts +21 -0
- package/lib/types/tui/theme.d.ts +35 -0
- package/lib/types/tui/toolCards/ToolCardsOverlay.d.ts +33 -0
- package/lib/types/tui/trajectory/TrajectoryDetail.d.ts +13 -0
- package/lib/types/tui/trajectory/TrajectoryLedger.d.ts +9 -0
- package/lib/types/tui/trajectory/TrajectoryOverlay.d.ts +39 -0
- package/lib/types/tui/trajectory/detail.d.ts +10 -0
- package/lib/types/tui/trajectory/layout.d.ts +16 -0
- package/lib/types/tui/trajectory/types.d.ts +74 -0
- package/lib/types/tui-app/session.d.ts +21 -0
- package/lib/types/version.d.ts +2 -0
- package/lib/types/yly/yly-frames.generated.d.ts +18 -0
- package/lib/types/yly/yly-pet.d.ts +46 -0
- package/lib/types/yly/yly-programs.d.ts +41 -0
- package/package.json +58 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-terminal answerer for one question from `ctx.userQuestions`: the
|
|
3
|
+
* `ask_user_question` tool, or `dsh-plan-mode`'s `exit_plan_mode` review
|
|
4
|
+
* (`approveLabel` set). A cursor moves over the offered options plus a
|
|
5
|
+
* trailing "Other…" row that opens a free-text field; a request with no
|
|
6
|
+
* options starts directly in that field. Space toggles a row for a
|
|
7
|
+
* multi-select question; Enter always submits the current toggled/typed
|
|
8
|
+
* answer.
|
|
9
|
+
* @module @tomowang/dsh-tui/tui/interaction/QuestionOverlay
|
|
10
|
+
*/
|
|
11
|
+
import type { Component } from '@earendil-works/pi-tui';
|
|
12
|
+
import type { TuiActions } from '../actions.js';
|
|
13
|
+
import type { QuestionPromptState } from './types.js';
|
|
14
|
+
export declare class QuestionOverlay implements Component {
|
|
15
|
+
private readonly question;
|
|
16
|
+
private readonly actions;
|
|
17
|
+
private cursor;
|
|
18
|
+
private readonly toggled;
|
|
19
|
+
private customMode;
|
|
20
|
+
private customField;
|
|
21
|
+
constructor(question: QuestionPromptState, actions: TuiActions);
|
|
22
|
+
invalidate(): void;
|
|
23
|
+
private submit;
|
|
24
|
+
render(_width: number): string[];
|
|
25
|
+
handleInput(data: string): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain, Cordis-agnostic display shapes for the in-terminal answerers: one
|
|
3
|
+
* pending tool-approval decision from `@deepseek-ai/dsh-user-approval`'s
|
|
4
|
+
* `approval/request` waterfall, and one pending question from
|
|
5
|
+
* `@deepseek-ai/dsh-user-questions`' `ctx.userQuestions` seam (the
|
|
6
|
+
* `ask_user_question` tool and `dsh-plan-mode`'s `exit_plan_mode` review).
|
|
7
|
+
* @module @tomowang/dsh-tui/tui/interaction/types
|
|
8
|
+
*/
|
|
9
|
+
/** One pending tool-approval decision, ready to render. */
|
|
10
|
+
export interface ApprovalPromptState {
|
|
11
|
+
readonly toolName: string;
|
|
12
|
+
readonly callId: string | undefined;
|
|
13
|
+
readonly reason: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** One selectable answer offered to the user. */
|
|
16
|
+
export interface QuestionOptionRow {
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly description: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** One pending question, ready to render. */
|
|
21
|
+
export interface QuestionPromptState {
|
|
22
|
+
readonly header: string | undefined;
|
|
23
|
+
readonly question: string;
|
|
24
|
+
readonly detail: string | undefined;
|
|
25
|
+
readonly options: readonly QuestionOptionRow[];
|
|
26
|
+
readonly multiSelect: boolean;
|
|
27
|
+
/** The option label that approves a `plan-review` intent, when the question carries one. */
|
|
28
|
+
readonly approveLabel: string | undefined;
|
|
29
|
+
/** e.g. "Question 2 of 3"; `undefined` for a single-question request. */
|
|
30
|
+
readonly progress: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The overlay's answer for one question, handed back to the queue. */
|
|
33
|
+
export interface QuestionAnswer {
|
|
34
|
+
readonly selected: readonly string[];
|
|
35
|
+
readonly custom: string | undefined;
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure text builders for the small always-present live-region rows (status
|
|
3
|
+
* bar, queued-message preview, permission indicator) — the pi-tui
|
|
4
|
+
* equivalents of the old `StatusBar.tsx`/`QueuedIndicator.tsx`/
|
|
5
|
+
* `PermissionIndicator.tsx`, minus the Ink wrapper. `TuiApp` renders each of
|
|
6
|
+
* these through a `DynamicText` that calls the builder fresh every frame, so
|
|
7
|
+
* they always reflect the latest store snapshot (and, for the status bar,
|
|
8
|
+
* the spinner's current frame) without any manual `setText` bookkeeping.
|
|
9
|
+
* @module @tomowang/dsh-tui/tui/liveText
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentStatus } from '@deepseek-ai/dsh-agent';
|
|
12
|
+
import type { GoalPhase, GoalProjection } from '@deepseek-ai/dsh-goal';
|
|
13
|
+
import type { UserMessage } from '@deepseek-ai/dsh-session';
|
|
14
|
+
import type { PermissionState } from './store.js';
|
|
15
|
+
export interface StatusBarParams {
|
|
16
|
+
readonly sessionId: string;
|
|
17
|
+
readonly provider: string;
|
|
18
|
+
readonly model: string;
|
|
19
|
+
readonly status: AgentStatus;
|
|
20
|
+
readonly queuedCount: number;
|
|
21
|
+
/** Current agent preset's display label, or `undefined` without a mounted preset service. */
|
|
22
|
+
readonly presetLabel: string | undefined;
|
|
23
|
+
/** Number of events logged to `agent.session.events` so far. */
|
|
24
|
+
readonly eventCount: number;
|
|
25
|
+
/** Current animation frame, shown only while `status === 'running'`. */
|
|
26
|
+
readonly spinnerChar: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function buildStatusBarText(params: StatusBarParams): string;
|
|
29
|
+
export declare function buildQueuedText(queued: readonly UserMessage[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Persistent low-key dock row nudging the reader to upgrade once the
|
|
32
|
+
* startup registry check (`src/updateCheck.ts`) finds a newer published
|
|
33
|
+
* version; renders nothing while unchecked or already current. Unlike
|
|
34
|
+
* `notice`, this isn't cleared on the next input — it's meant to stay
|
|
35
|
+
* visible for the rest of the session, mirroring how `gh`/`npm` surface an
|
|
36
|
+
* available-update line.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildUpdateHintText(currentVersion: string, latestVersion: string | undefined): string;
|
|
39
|
+
export declare function buildPermissionText(permission: PermissionState | undefined): string;
|
|
40
|
+
/** Human label for one durable goal phase — the single source of truth shared by the `/goal` notice (`index.ts`) and this strip. */
|
|
41
|
+
export declare function goalPhaseLabel(phase: GoalPhase): string;
|
|
42
|
+
/**
|
|
43
|
+
* The goal strip docked above the composer — the terminal GoalBar. Mirrors
|
|
44
|
+
* the web portal's rendering rule exactly: loading (`undefined` — projection
|
|
45
|
+
* unit not composed), absent/cleared (`null`), and complete goals render
|
|
46
|
+
* nothing; a present goal shows a goal glyph, its phase label, and the
|
|
47
|
+
* truncated objective, with the blocker explanation appended for a blocked
|
|
48
|
+
* goal (the portal shows it as a hover tooltip, which a terminal cannot).
|
|
49
|
+
* Mutations live on the `/goal` command, not on the strip.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Terminal window/tab title: `<session title> — dsh-tui` once the optional
|
|
53
|
+
* `dsh-session-title` service has accepted one for this session, or just
|
|
54
|
+
* `dsh-tui` before that (loading) or without the service composed —
|
|
55
|
+
* mirroring the harness's own `<session title> — <configured title>` OSC 0
|
|
56
|
+
* convention. Plain text, never ANSI-colored: an OSC 0 title string is
|
|
57
|
+
* displayed verbatim by the terminal chrome, not interpreted as SGR.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildTerminalTitle(title: string | null | undefined): string;
|
|
60
|
+
export declare function buildGoalBarText(goal: GoalProjection | null | undefined): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by `node scripts/generate-logo.mjs` from
|
|
3
|
+
* `assets/deepseek-128px.png` via chafa (half-block, 16x16, rgb color
|
|
4
|
+
* space). Do not hand-edit — re-run the script after the source image
|
|
5
|
+
* changes; requires `chafa` installed locally (e.g. `brew install chafa`).
|
|
6
|
+
* @module @tomowang/dsh-tui/tui/logoArt.generated
|
|
7
|
+
*/
|
|
8
|
+
/** One entry per output row; each line carries embedded 24-bit ANSI SGR color codes. */
|
|
9
|
+
export declare const LOGO_HALF_BLOCK: readonly string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny hand-rolled single-line text buffer (value + cursor, insert/
|
|
3
|
+
* backspace/delete/left/right/home/end) shared by the handful of overlays
|
|
4
|
+
* that need one embedded field inside otherwise-custom keyboard handling
|
|
5
|
+
* (`QuestionOverlay`'s free-text answer, `TrajectoryOverlay`'s filter,
|
|
6
|
+
* `ProviderForm`'s fields, `ModelListEditor`'s add-id field) — replacing
|
|
7
|
+
* `ink-text-input` without wrestling with pi-tui's focus model, which only
|
|
8
|
+
* tracks one focused `Component` at a time and has no built-in way to
|
|
9
|
+
* delegate keystrokes to a field nested inside a larger custom overlay.
|
|
10
|
+
* @module @tomowang/dsh-tui/tui/miniTextField
|
|
11
|
+
*/
|
|
12
|
+
export interface MiniTextFieldState {
|
|
13
|
+
readonly value: string;
|
|
14
|
+
readonly cursor: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function emptyMiniTextField(value?: string): MiniTextFieldState;
|
|
17
|
+
/** Apply one keystroke, or return `undefined` if this field doesn't handle it (so the caller can fall through to its own bindings, e.g. Enter/Escape/Tab). */
|
|
18
|
+
export declare function miniTextFieldInput(state: MiniTextFieldState, data: string): MiniTextFieldState | undefined;
|
|
19
|
+
/** Render the field's text, optionally with an inverse-video cursor block at the cursor position. */
|
|
20
|
+
export declare function renderMiniTextField(state: MiniTextFieldState, cursorVisible: boolean, mask?: string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/model` overlay: provider list, add/edit form, and the form's nested
|
|
3
|
+
* model-catalog editor, as one component. The three used to be three
|
|
4
|
+
* separate Ink components (`ProviderList`/`ProviderForm`/`ModelListEditor`)
|
|
5
|
+
* switched by conditional mounting, with the form's local field state reset
|
|
6
|
+
* via a React `key={formKey}` remount trick. pi-tui has no nested-focus
|
|
7
|
+
* delegation (only one `Component` is ever focused at a time) and no
|
|
8
|
+
* remount-to-reset-state idiom, so this is one class instead: `showModels`
|
|
9
|
+
* picks which of the three views is active, and `syncFormState` reinitializes
|
|
10
|
+
* the form's local fields from the store's draft whenever `formKey` changes
|
|
11
|
+
* — the direct equivalent of the old remount, just explicit.
|
|
12
|
+
* @module @tomowang/dsh-tui/tui/modelProfile/ModelProfileOverlay
|
|
13
|
+
*/
|
|
14
|
+
import type { Component } from '@earendil-works/pi-tui';
|
|
15
|
+
import type { TuiActions } from '../actions.js';
|
|
16
|
+
import type { TuiStore } from '../store.js';
|
|
17
|
+
export declare class ModelProfileOverlay implements Component {
|
|
18
|
+
private readonly store;
|
|
19
|
+
private readonly actions;
|
|
20
|
+
private confirmDelete;
|
|
21
|
+
private formKeySeen;
|
|
22
|
+
private route;
|
|
23
|
+
private displayName;
|
|
24
|
+
private api;
|
|
25
|
+
private baseURL;
|
|
26
|
+
private apiKeyDraft;
|
|
27
|
+
private models;
|
|
28
|
+
private showModels;
|
|
29
|
+
private focused;
|
|
30
|
+
private modelDraftId;
|
|
31
|
+
private modelSelected;
|
|
32
|
+
private modelInputFocused;
|
|
33
|
+
constructor(store: TuiStore, actions: TuiActions);
|
|
34
|
+
invalidate(): void;
|
|
35
|
+
private textFields;
|
|
36
|
+
/** Reinitialize form-local state from the store's draft when `formKey` changes — the equivalent of the old `key={formKey}` remount. */
|
|
37
|
+
private syncFormState;
|
|
38
|
+
private buildDraft;
|
|
39
|
+
render(_width: number): string[];
|
|
40
|
+
private renderList;
|
|
41
|
+
private handleListInput;
|
|
42
|
+
private renderForm;
|
|
43
|
+
private handleFormInput;
|
|
44
|
+
private renderModelListEditor;
|
|
45
|
+
private addModel;
|
|
46
|
+
private handleModelListEditorInput;
|
|
47
|
+
handleInput(data: string): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data shapes for the `/model` provider-profile overlay: the read model that
|
|
3
|
+
* joins `ctx.llm`'s provider directory with `ctx.settings`' stored sections,
|
|
4
|
+
* the raw shape stored at each provider's settings path, and the mutable
|
|
5
|
+
* draft one add/edit form works with before a save round-trips it back.
|
|
6
|
+
* @module @tomowang/dsh-tui/tui/modelProfile/types
|
|
7
|
+
*/
|
|
8
|
+
/** One model entry within a provider's catalog. */
|
|
9
|
+
export interface ModelEntry {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly contextWindow?: number;
|
|
13
|
+
readonly maxTokens?: number;
|
|
14
|
+
}
|
|
15
|
+
/** One model an endpoint reported during discovery, not yet added to a draft. */
|
|
16
|
+
export interface DiscoveredModel {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly contextWindow?: number;
|
|
20
|
+
readonly maxTokens?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Raw shape stored at a provider's settings path (subset of `PiAiProviderProfile`). */
|
|
23
|
+
export interface StoredProviderProfile {
|
|
24
|
+
readonly displayName?: string;
|
|
25
|
+
readonly api?: string;
|
|
26
|
+
readonly baseURL?: string;
|
|
27
|
+
readonly apiKeyEnv?: string;
|
|
28
|
+
readonly models?: readonly ModelEntry[];
|
|
29
|
+
}
|
|
30
|
+
/** One provider route as shown in the overlay's list view. */
|
|
31
|
+
export interface ProviderRow {
|
|
32
|
+
readonly route: string;
|
|
33
|
+
readonly displayName: string;
|
|
34
|
+
readonly settingsNs: string;
|
|
35
|
+
readonly settingsPath: readonly string[];
|
|
36
|
+
/** Whether the user's settings document has an override for this route. */
|
|
37
|
+
readonly configured: boolean;
|
|
38
|
+
/** Whether the route is currently registered/live in `ctx.llm`. */
|
|
39
|
+
readonly live: boolean;
|
|
40
|
+
readonly api: string | undefined;
|
|
41
|
+
readonly baseURL: string | undefined;
|
|
42
|
+
readonly apiKeyRef: string;
|
|
43
|
+
readonly apiKeyConfigured: boolean;
|
|
44
|
+
readonly models: readonly ModelEntry[];
|
|
45
|
+
/** Settings revision this row was read at; replayed as `expectedRevision` on write. */
|
|
46
|
+
readonly revision: number | undefined;
|
|
47
|
+
}
|
|
48
|
+
/** Editable draft for the add/edit form; never carries the raw API key once saved. */
|
|
49
|
+
export interface ProviderDraft {
|
|
50
|
+
readonly route: string;
|
|
51
|
+
readonly isNew: boolean;
|
|
52
|
+
readonly settingsNs: string;
|
|
53
|
+
readonly settingsPath: readonly string[];
|
|
54
|
+
readonly displayName: string;
|
|
55
|
+
readonly api: string;
|
|
56
|
+
readonly baseURL: string;
|
|
57
|
+
readonly apiKeyRef: string;
|
|
58
|
+
readonly apiKeyConfigured: boolean;
|
|
59
|
+
/** Local-only plaintext key entered in this session; empty means "keep current". */
|
|
60
|
+
readonly apiKeyDraft: string;
|
|
61
|
+
readonly models: readonly ModelEntry[];
|
|
62
|
+
readonly revision: number | undefined;
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts this app's `theme.ts` hex-token table to the color-function shapes
|
|
3
|
+
* pi-tui's built-in components (`Editor`, `SelectList`) expect.
|
|
4
|
+
* @module @tomowang/dsh-tui/tui/piTheme
|
|
5
|
+
*/
|
|
6
|
+
import type { EditorTheme } from '@earendil-works/pi-tui';
|
|
7
|
+
import type { SelectListTheme } from '@earendil-works/pi-tui';
|
|
8
|
+
export declare const selectListTheme: SelectListTheme;
|
|
9
|
+
export declare const editorTheme: EditorTheme;
|
|
10
|
+
export declare const shellModeEditorBorderColor: (s: string) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/plugins` overlay: a scrollable, read-only list of every entry in the
|
|
3
|
+
* loader's tree, snapshotted once at open time (see `pluginRows()` in
|
|
4
|
+
* `index.ts`) rather than kept live — the tree rarely changes mid-session,
|
|
5
|
+
* and re-snapshotting on every render would fight the scroll position.
|
|
6
|
+
* @module @tomowang/dsh-tui/tui/plugins/PluginsOverlay
|
|
7
|
+
*/
|
|
8
|
+
import type { Component, TUI } from '@earendil-works/pi-tui';
|
|
9
|
+
import type { TuiActions } from '../actions.js';
|
|
10
|
+
import type { PluginRow } from './types.js';
|
|
11
|
+
export declare class PluginsOverlay implements Component {
|
|
12
|
+
private readonly tui;
|
|
13
|
+
private readonly rows;
|
|
14
|
+
private readonly actions;
|
|
15
|
+
private scrollOffset;
|
|
16
|
+
constructor(tui: TUI, rows: readonly PluginRow[], actions: TuiActions);
|
|
17
|
+
invalidate(): void;
|
|
18
|
+
private listHeight;
|
|
19
|
+
private maxOffset;
|
|
20
|
+
render(_width: number): string[];
|
|
21
|
+
handleInput(data: string): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain, Cordis-agnostic snapshot of one loader entry, joined from
|
|
3
|
+
* `ctx.loader.entries()` for the `/plugins` overlay.
|
|
4
|
+
* @module @tomowang/dsh-tui/tui/plugins/types
|
|
5
|
+
*/
|
|
6
|
+
/** One flattened loader entry, alongside its live fiber lifecycle state. */
|
|
7
|
+
export interface PluginRow {
|
|
8
|
+
/** Dotted entry id inside the loader's tree (see `EntryTree.sep`). */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** Module specifier the entry imports. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** Effective disabled state, including inherited group disables. */
|
|
13
|
+
readonly disabled: boolean;
|
|
14
|
+
/** True for a nested group entry rather than a leaf plugin. */
|
|
15
|
+
readonly group: boolean;
|
|
16
|
+
/** Fiber lifecycle state, or `undefined` while the entry has no fiber (not yet started, or disabled). */
|
|
17
|
+
readonly state: 'pending' | 'loading' | 'active' | 'failed' | 'disposed' | 'unloading' | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wires this app's own slash-command (`commands.ts`) and `@`-file-mention
|
|
3
|
+
* (`fileMention.ts`) query logic into pi-tui's `AutocompleteProvider` seam
|
|
4
|
+
* for `CustomEditor` — kept as dsh-tui's own `git ls-files`-backed file index
|
|
5
|
+
* rather than pi-tui's built-in `fd`-shelling completion, to preserve
|
|
6
|
+
* existing behavior without a new external binary dependency.
|
|
7
|
+
* @module @tomowang/dsh-tui/tui/promptAutocomplete
|
|
8
|
+
*/
|
|
9
|
+
import type { AutocompleteItem, AutocompleteProvider, AutocompleteSuggestions } from '@earendil-works/pi-tui';
|
|
10
|
+
import { matchSlashCommands } from './commands.js';
|
|
11
|
+
/** Fetch (loading it on first use) the repo-relative file list backing `@`-mention. */
|
|
12
|
+
export type GetFileCandidates = () => Promise<readonly string[]>;
|
|
13
|
+
export declare class PromptAutocompleteProvider implements AutocompleteProvider {
|
|
14
|
+
private readonly getFileCandidates;
|
|
15
|
+
readonly triggerCharacters: string[];
|
|
16
|
+
constructor(getFileCandidates: GetFileCandidates);
|
|
17
|
+
getSuggestions(lines: string[], cursorLine: number, cursorCol: number, { signal }: {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
force?: boolean;
|
|
20
|
+
}): Promise<AutocompleteSuggestions | null>;
|
|
21
|
+
applyCompletion(lines: string[], cursorLine: number, cursorCol: number, item: AutocompleteItem, _prefix: string): {
|
|
22
|
+
lines: string[];
|
|
23
|
+
cursorLine: number;
|
|
24
|
+
cursorCol: number;
|
|
25
|
+
};
|
|
26
|
+
shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Re-exported for `CustomEditor`, which also needs to check command-mode text on plain Tab (completion without submitting). */
|
|
29
|
+
export { matchSlashCommands };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure formatting for the status bar's stats line: turn/step counts, LLM/tool
|
|
3
|
+
* wall time, first-token latency, decode throughput, cache hit rate, and
|
|
4
|
+
* billed tokens. Mirrors the web portal's `StatsLine` (`ui-conversation`)
|
|
5
|
+
* field-for-field so the two surfaces read the same figures the same way;
|
|
6
|
+
* duplicated rather than imported since dsh-tui carries no web-client
|
|
7
|
+
* dependency.
|
|
8
|
+
* @module @tomowang/dsh-tui/tui/statsFormat
|
|
9
|
+
*/
|
|
10
|
+
import type { SessionStatsProjection } from '@deepseek-ai/dsh-session-stats';
|
|
11
|
+
import type { ContextBreakdownProjection, ContextPressureProjection, TokenUsageProjection } from '@deepseek-ai/dsh-token-meter';
|
|
12
|
+
/**
|
|
13
|
+
* Compact token count: 517 / 12.2K / 517K / 1.2M (one decimal under three digits).
|
|
14
|
+
* @param n - token count.
|
|
15
|
+
* @returns display string.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatTokens(n: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Compact duration: 45.2s under a minute, 2m42s from there on.
|
|
20
|
+
* @param ms - duration in milliseconds.
|
|
21
|
+
* @returns display string.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatDuration(ms: number): string;
|
|
24
|
+
/**
|
|
25
|
+
* Compact throughput: one decimal under 10 tok/s, whole above.
|
|
26
|
+
* @param tps - tokens per second.
|
|
27
|
+
* @returns display string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatTokensPerSecond(tps: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Sum the three disjoint prompt-side billing buckets.
|
|
32
|
+
* @param usage - the session's token-usage projection value.
|
|
33
|
+
* @returns billed input tokens.
|
|
34
|
+
*/
|
|
35
|
+
export declare function billedInputTokens(usage: TokenUsageProjection): number;
|
|
36
|
+
/**
|
|
37
|
+
* Cache-hit share of prompt-side input over the whole durable log.
|
|
38
|
+
* @param usage - the session's token-usage projection value.
|
|
39
|
+
* @returns rounded integer percent, or null when no input was billed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function cacheHitPercent(usage: TokenUsageProjection): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* Build the pipe-separated stats line for the status bar, e.g.
|
|
44
|
+
* `1 turns · 1 steps| LLM 4.3s| TTFT avg 1.1s · 131 tok/s| Cache hit 80%| Input 9.1K tok · Output 412 tok`.
|
|
45
|
+
* A group with no data drops out whole; an empty return means nothing to show yet.
|
|
46
|
+
* @param stats - whole-log turn/step counts and wall times, or `undefined` without the projection unit mounted.
|
|
47
|
+
* @param usage - whole-log provider token usage, or `undefined` without the projection unit mounted.
|
|
48
|
+
* @returns the joined line, or `''` when there is nothing to display.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildStatsLine(stats: SessionStatsProjection | undefined, usage: TokenUsageProjection | undefined): string;
|
|
51
|
+
/** Approximate context occupancy, mirroring the web portal's `contextOccupancy`. */
|
|
52
|
+
export interface ContextOccupancy {
|
|
53
|
+
/** Rounded percent of the context window in use, clamped to 100. */
|
|
54
|
+
readonly percent: number;
|
|
55
|
+
/** `projectedTokens` when the provider has reported usage since the last surface change, else the last raw `pressureTokens` sample. */
|
|
56
|
+
readonly usedTokens: number;
|
|
57
|
+
/** Newest recorded route capacity. */
|
|
58
|
+
readonly contextWindow: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Derive occupancy from the newest pressure sample, or `null` while either
|
|
62
|
+
* side (a usage sample, a known route capacity) hasn't arrived yet.
|
|
63
|
+
* @param pressure - the session's context-pressure projection value.
|
|
64
|
+
* @returns occupancy figures, or `null` when there is nothing to show yet.
|
|
65
|
+
*/
|
|
66
|
+
export declare function contextOccupancy(pressure: ContextPressureProjection | undefined): ContextOccupancy | null;
|
|
67
|
+
/**
|
|
68
|
+
* Build the always-on compact context-usage line, e.g. `Context 1% · ~8.1K / 1M tok`.
|
|
69
|
+
* @param pressure - the session's context-pressure projection value.
|
|
70
|
+
* @returns the display line, or `''` when there is nothing to show yet.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildContextLine(pressure: ContextPressureProjection | undefined): string;
|
|
73
|
+
/** One row of the `/context` overlay's System/Tools/Messages breakdown. */
|
|
74
|
+
export interface ContextBreakdownRow {
|
|
75
|
+
readonly label: string;
|
|
76
|
+
readonly tokens: number;
|
|
77
|
+
/** Bar-segment width in percentage points, scaled to `occupancy.percent` rather than the breakdown's own sum. */
|
|
78
|
+
readonly width: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Proportional breakdown rows for the `/context` overlay's bar. The three
|
|
82
|
+
* heuristic figures are composition only — they do not sum to
|
|
83
|
+
* `occupancy.usedTokens` — so segment widths are scaled to `occupancy.percent`
|
|
84
|
+
* rather than treated as an independent total; see `ContextBreakdownProjection`'s doc comment.
|
|
85
|
+
* @param occupancy - this session's occupancy figures, or `null` without a usage sample yet.
|
|
86
|
+
* @param breakdown - the session's context-breakdown projection value.
|
|
87
|
+
* @returns the three rows in System/Tools/Messages order, or `[]` when there is nothing to show yet.
|
|
88
|
+
*/
|
|
89
|
+
export declare function contextBreakdownRows(occupancy: ContextOccupancy | null, breakdown: ContextBreakdownProjection | undefined): readonly ContextBreakdownRow[];
|