@sagmans/dsh-tui 0.6.0 → 0.8.0
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/.agents/skills/dsh-tui-dogfood/SKILL.md +83 -0
- package/.agents/skills/dsh-tui-dogfood/references/home-state.md +78 -0
- package/.agents/skills/dsh-tui-dogfood/scripts/clone-links.mjs +133 -0
- package/.agents/skills/dsh-tui-dogfood/scripts/run-plugin-from-worktree.sh +417 -0
- package/.agents/skills/dsh-tui-update-models/SKILL.md +199 -0
- package/.agents/skills/dsh-tui-update-models/references/model-wiring.md +292 -0
- package/.agents/skills/dsh-tui-update-models/scripts/dump-model-catalog.mjs +314 -0
- package/README.md +154 -27
- package/lib/agent/present.d.ts.map +1 -1
- package/lib/agent/present.js +2 -1
- package/lib/agent/present.js.map +1 -1
- package/lib/cards/composition.d.ts +68 -0
- package/lib/cards/composition.d.ts.map +1 -0
- package/lib/cards/composition.js +117 -0
- package/lib/cards/composition.js.map +1 -0
- package/lib/cards/presenter.d.ts +23 -0
- package/lib/cards/presenter.d.ts.map +1 -0
- package/lib/cards/presenter.js +394 -0
- package/lib/cards/presenter.js.map +1 -0
- package/lib/cards/preview.d.ts +42 -0
- package/lib/cards/preview.d.ts.map +1 -0
- package/lib/cards/preview.js +51 -0
- package/lib/cards/preview.js.map +1 -0
- package/lib/cards.d.ts +12 -120
- package/lib/cards.d.ts.map +1 -1
- package/lib/cards.js +4 -556
- package/lib/cards.js.map +1 -1
- package/lib/compat/section.d.ts +29 -0
- package/lib/compat/section.d.ts.map +1 -0
- package/lib/compat/section.js +82 -0
- package/lib/compat/section.js.map +1 -0
- package/lib/config.d.ts +27 -2
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +61 -1
- package/lib/config.js.map +1 -1
- package/lib/contracts.d.ts +28 -0
- package/lib/contracts.d.ts.map +1 -1
- package/lib/fold-cursor.d.ts +8 -0
- package/lib/fold-cursor.d.ts.map +1 -1
- package/lib/fold-cursor.js +18 -0
- package/lib/fold-cursor.js.map +1 -1
- package/lib/gates/question-card.d.ts +77 -0
- package/lib/gates/question-card.d.ts.map +1 -0
- package/lib/gates/question-card.js +113 -0
- package/lib/gates/question-card.js.map +1 -0
- package/lib/gates/questions.d.ts +127 -0
- package/lib/gates/questions.d.ts.map +1 -0
- package/lib/gates/questions.js +418 -0
- package/lib/gates/questions.js.map +1 -0
- package/lib/gates.d.ts +1 -113
- package/lib/gates.d.ts.map +1 -1
- package/lib/gates.js +1 -484
- package/lib/gates.js.map +1 -1
- package/lib/herdr/client.d.ts +8 -0
- package/lib/herdr/client.d.ts.map +1 -1
- package/lib/herdr/client.js +13 -1
- package/lib/herdr/client.js.map +1 -1
- package/lib/herdr/constants.d.ts +18 -0
- package/lib/herdr/constants.d.ts.map +1 -1
- package/lib/herdr/constants.js +18 -0
- package/lib/herdr/constants.js.map +1 -1
- package/lib/herdr/reporter.d.ts +20 -4
- package/lib/herdr/reporter.d.ts.map +1 -1
- package/lib/herdr/reporter.js +70 -20
- package/lib/herdr/reporter.js.map +1 -1
- package/lib/herdr/state.d.ts +10 -0
- package/lib/herdr/state.d.ts.map +1 -1
- package/lib/herdr/state.js +21 -4
- package/lib/herdr/state.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +348 -2602
- package/lib/index.js.map +1 -1
- package/lib/input/action-catalog.d.ts +74 -0
- package/lib/input/action-catalog.d.ts.map +1 -0
- package/lib/input/action-catalog.js +137 -0
- package/lib/input/action-catalog.js.map +1 -0
- package/lib/input/actions.d.ts +5 -81
- package/lib/input/actions.d.ts.map +1 -1
- package/lib/input/actions.js +4 -625
- package/lib/input/actions.js.map +1 -1
- package/lib/input/completion.d.ts +1 -1
- package/lib/input/completion.d.ts.map +1 -1
- package/lib/input/completion.js +2 -1
- package/lib/input/completion.js.map +1 -1
- package/lib/input/file-index.d.ts +40 -0
- package/lib/input/file-index.d.ts.map +1 -0
- package/lib/input/file-index.js +141 -0
- package/lib/input/file-index.js.map +1 -0
- package/lib/input/file-search.d.ts +1 -38
- package/lib/input/file-search.d.ts.map +1 -1
- package/lib/input/file-search.js +1 -487
- package/lib/input/file-search.js.map +1 -1
- package/lib/input/key-press.d.ts +57 -0
- package/lib/input/key-press.d.ts.map +1 -0
- package/lib/input/key-press.js +218 -0
- package/lib/input/key-press.js.map +1 -0
- package/lib/input/keymap-conflicts.d.ts +59 -0
- package/lib/input/keymap-conflicts.d.ts.map +1 -0
- package/lib/input/keymap-conflicts.js +292 -0
- package/lib/input/keymap-conflicts.js.map +1 -0
- package/lib/input/keymap-settings.js +1 -1
- package/lib/input/keymap-settings.js.map +1 -1
- package/lib/input/keymap.d.ts.map +1 -1
- package/lib/input/keymap.js +3 -1
- package/lib/input/keymap.js.map +1 -1
- package/lib/input/workspace-files.d.ts +10 -0
- package/lib/input/workspace-files.d.ts.map +1 -0
- package/lib/input/workspace-files.js +359 -0
- package/lib/input/workspace-files.js.map +1 -0
- package/lib/install-skills.d.ts +39 -0
- package/lib/install-skills.d.ts.map +1 -0
- package/lib/install-skills.js +273 -0
- package/lib/install-skills.js.map +1 -0
- package/lib/keys-command.d.ts +2 -1
- package/lib/keys-command.d.ts.map +1 -1
- package/lib/keys-command.js +2 -1
- package/lib/keys-command.js.map +1 -1
- package/lib/model-list.d.ts +37 -0
- package/lib/model-list.d.ts.map +1 -0
- package/lib/model-list.js +60 -0
- package/lib/model-list.js.map +1 -0
- package/lib/startup.d.ts +8 -0
- package/lib/startup.d.ts.map +1 -1
- package/lib/startup.js +120 -24
- package/lib/startup.js.map +1 -1
- package/lib/subagents.d.ts +7 -3
- package/lib/subagents.d.ts.map +1 -1
- package/lib/subagents.js +28 -4
- package/lib/subagents.js.map +1 -1
- package/lib/surface/appearance-preferences.d.ts +26 -0
- package/lib/surface/appearance-preferences.d.ts.map +1 -0
- package/lib/surface/appearance-preferences.js +139 -0
- package/lib/surface/appearance-preferences.js.map +1 -0
- package/lib/surface/appearance.d.ts +87 -0
- package/lib/surface/appearance.d.ts.map +1 -0
- package/lib/surface/appearance.js +353 -0
- package/lib/surface/appearance.js.map +1 -0
- package/lib/surface/background-work.d.ts +51 -0
- package/lib/surface/background-work.d.ts.map +1 -0
- package/lib/surface/background-work.js +172 -0
- package/lib/surface/background-work.js.map +1 -0
- package/lib/surface/commands.d.ts +82 -0
- package/lib/surface/commands.d.ts.map +1 -0
- package/lib/surface/commands.js +370 -0
- package/lib/surface/commands.js.map +1 -0
- package/lib/surface/modal-input.d.ts +59 -0
- package/lib/surface/modal-input.d.ts.map +1 -0
- package/lib/surface/modal-input.js +243 -0
- package/lib/surface/modal-input.js.map +1 -0
- package/lib/surface/model-choice.d.ts +54 -0
- package/lib/surface/model-choice.d.ts.map +1 -0
- package/lib/surface/model-choice.js +325 -0
- package/lib/surface/model-choice.js.map +1 -0
- package/lib/surface/preset-choice.d.ts +78 -0
- package/lib/surface/preset-choice.d.ts.map +1 -0
- package/lib/surface/preset-choice.js +163 -0
- package/lib/surface/preset-choice.js.map +1 -0
- package/lib/surface/prompt-input.d.ts +97 -0
- package/lib/surface/prompt-input.d.ts.map +1 -0
- package/lib/surface/prompt-input.js +215 -0
- package/lib/surface/prompt-input.js.map +1 -0
- package/lib/surface/prompt-memory.d.ts +76 -0
- package/lib/surface/prompt-memory.d.ts.map +1 -0
- package/lib/surface/prompt-memory.js +167 -0
- package/lib/surface/prompt-memory.js.map +1 -0
- package/lib/surface/session-lifecycle.d.ts +120 -0
- package/lib/surface/session-lifecycle.d.ts.map +1 -0
- package/lib/surface/session-lifecycle.js +324 -0
- package/lib/surface/session-lifecycle.js.map +1 -0
- package/lib/surface/session-picker.d.ts +39 -0
- package/lib/surface/session-picker.d.ts.map +1 -0
- package/lib/surface/session-picker.js +107 -0
- package/lib/surface/session-picker.js.map +1 -0
- package/lib/surface/session-view.d.ts +86 -0
- package/lib/surface/session-view.d.ts.map +1 -0
- package/lib/surface/session-view.js +215 -0
- package/lib/surface/session-view.js.map +1 -0
- package/lib/surface/staged-turns.d.ts +81 -0
- package/lib/surface/staged-turns.d.ts.map +1 -0
- package/lib/surface/staged-turns.js +206 -0
- package/lib/surface/staged-turns.js.map +1 -0
- package/lib/surface/terminal-lifecycle.d.ts +76 -0
- package/lib/surface/terminal-lifecycle.d.ts.map +1 -0
- package/lib/surface/terminal-lifecycle.js +222 -0
- package/lib/surface/terminal-lifecycle.js.map +1 -0
- package/lib/terminal-text/scan.d.ts +44 -0
- package/lib/terminal-text/scan.d.ts.map +1 -0
- package/lib/terminal-text/scan.js +195 -0
- package/lib/terminal-text/scan.js.map +1 -0
- package/lib/terminal-text/sgr.d.ts +32 -0
- package/lib/terminal-text/sgr.d.ts.map +1 -0
- package/lib/terminal-text/sgr.js +203 -0
- package/lib/terminal-text/sgr.js.map +1 -0
- package/lib/terminal-text.d.ts +1 -1
- package/lib/terminal-text.d.ts.map +1 -1
- package/lib/terminal-text.js +2 -379
- package/lib/terminal-text.js.map +1 -1
- package/lib/theme-command.js +2 -1
- package/lib/theme-command.js.map +1 -1
- package/lib/theme-defaults.d.ts +64 -0
- package/lib/theme-defaults.d.ts.map +1 -0
- package/lib/theme-defaults.js +248 -0
- package/lib/theme-defaults.js.map +1 -0
- package/lib/theme-files.d.ts +1 -1
- package/lib/theme-files.d.ts.map +1 -1
- package/lib/theme-files.js +1 -1
- package/lib/theme-files.js.map +1 -1
- package/lib/theme-resolver.d.ts +36 -0
- package/lib/theme-resolver.d.ts.map +1 -0
- package/lib/theme-resolver.js +112 -0
- package/lib/theme-resolver.js.map +1 -0
- package/lib/theme-schema.d.ts.map +1 -1
- package/lib/theme-schema.js +3 -2
- package/lib/theme-schema.js.map +1 -1
- package/lib/theme-settings.d.ts +5 -7
- package/lib/theme-settings.d.ts.map +1 -1
- package/lib/theme-settings.js +37 -21
- package/lib/theme-settings.js.map +1 -1
- package/lib/theme-tokens.d.ts +0 -89
- package/lib/theme-tokens.d.ts.map +1 -1
- package/lib/theme-tokens.js +0 -356
- package/lib/theme-tokens.js.map +1 -1
- package/lib/theme.d.ts +1 -1
- package/lib/theme.d.ts.map +1 -1
- package/lib/theme.js +2 -1
- package/lib/theme.js.map +1 -1
- package/lib/tool-display.d.ts.map +1 -1
- package/lib/tool-display.js +2 -1
- package/lib/tool-display.js.map +1 -1
- package/lib/transcript/message-content.d.ts +21 -0
- package/lib/transcript/message-content.d.ts.map +1 -0
- package/lib/transcript/message-content.js +61 -0
- package/lib/transcript/message-content.js.map +1 -0
- package/lib/transcript/tool-calls.d.ts +106 -0
- package/lib/transcript/tool-calls.d.ts.map +1 -0
- package/lib/transcript/tool-calls.js +254 -0
- package/lib/transcript/tool-calls.js.map +1 -0
- package/lib/transcript.d.ts +14 -55
- package/lib/transcript.d.ts.map +1 -1
- package/lib/transcript.js +31 -253
- package/lib/transcript.js.map +1 -1
- package/lib/ui/dock.d.ts +14 -2
- package/lib/ui/dock.d.ts.map +1 -1
- package/lib/ui/dock.js +52 -10
- package/lib/ui/dock.js.map +1 -1
- package/lib/ui/editor.d.ts.map +1 -1
- package/lib/ui/editor.js +2 -1
- package/lib/ui/editor.js.map +1 -1
- package/lib/ui/keymap-picker.d.ts +2 -1
- package/lib/ui/keymap-picker.d.ts.map +1 -1
- package/lib/ui/keymap-picker.js +1 -0
- package/lib/ui/keymap-picker.js.map +1 -1
- package/lib/ui/view/gate-card.d.ts +21 -0
- package/lib/ui/view/gate-card.d.ts.map +1 -0
- package/lib/ui/view/gate-card.js +104 -0
- package/lib/ui/view/gate-card.js.map +1 -0
- package/lib/ui/view/tool-card.d.ts +149 -0
- package/lib/ui/view/tool-card.d.ts.map +1 -0
- package/lib/ui/view/tool-card.js +429 -0
- package/lib/ui/view/tool-card.js.map +1 -0
- package/lib/ui/view/transcript-message.d.ts +62 -0
- package/lib/ui/view/transcript-message.d.ts.map +1 -0
- package/lib/ui/view/transcript-message.js +158 -0
- package/lib/ui/view/transcript-message.js.map +1 -0
- package/lib/ui/view.d.ts +105 -223
- package/lib/ui/view.d.ts.map +1 -1
- package/lib/ui/view.js +132 -679
- package/lib/ui/view.js.map +1 -1
- package/package.json +3 -1
- package/themes/violet-orbit.yaml +7 -5
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import type { Keymap } from '../input/actions.ts';
|
|
3
|
+
import { PromptStash } from '../stash.ts';
|
|
4
|
+
import type { TuiTheme } from '../theme.ts';
|
|
5
|
+
import type { GhostBrush } from '../ui/editor.ts';
|
|
6
|
+
import type { PickerAction, PickerCard } from '../ui/picker.ts';
|
|
7
|
+
/**
|
|
8
|
+
* What a list has to answer to be driven by whoever owns the keyboard.
|
|
9
|
+
*
|
|
10
|
+
* This owner raises the lists and hands them over; the overlay they are drawn
|
|
11
|
+
* in, the vetting of a pick, and how long a list may hold the keyboard stay
|
|
12
|
+
* with the modal owner, which is why they arrive as a port.
|
|
13
|
+
*/
|
|
14
|
+
export interface MemoryPicker {
|
|
15
|
+
handleKey(data: string): PickerAction | undefined;
|
|
16
|
+
card(window?: number): PickerCard;
|
|
17
|
+
setNote(text: string | undefined): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* What the prompt's memory needs from the surface that composes it.
|
|
21
|
+
*
|
|
22
|
+
* The history switches are read at call time rather than captured: the
|
|
23
|
+
* settings document is hot-reloaded, and a copy taken here would pin this
|
|
24
|
+
* surface to the settings of the day it loaded. The theme is read through its
|
|
25
|
+
* delegate for the same reason, and the editor and the picker are ports
|
|
26
|
+
* because the widget and the keyboard lifetime are the surface's own.
|
|
27
|
+
*/
|
|
28
|
+
export interface PromptMemoryPorts {
|
|
29
|
+
readonly historyEnabled: () => boolean;
|
|
30
|
+
readonly historyGhost: () => boolean;
|
|
31
|
+
readonly historyMaxEntries: () => number;
|
|
32
|
+
readonly theme: TuiTheme;
|
|
33
|
+
readonly keymap: () => Keymap;
|
|
34
|
+
readonly notice: (message: string) => void;
|
|
35
|
+
readonly render: () => void;
|
|
36
|
+
/** The draft as written, with a pasted block expanded back to its text. */
|
|
37
|
+
readonly editorText: () => string;
|
|
38
|
+
readonly setEditorText: (text: string) => void;
|
|
39
|
+
/** Whether the prompt bar belongs to the reader rather than to a question. */
|
|
40
|
+
readonly editorAvailable: () => boolean;
|
|
41
|
+
/** The session this surface drives, which is the one its drafts belong to. */
|
|
42
|
+
readonly activeSession: () => SessionId;
|
|
43
|
+
readonly openPicker: (picker: MemoryPicker) => Promise<string | undefined>;
|
|
44
|
+
}
|
|
45
|
+
/** The prompt's memory of itself, and the operations the surface routes to it. */
|
|
46
|
+
export interface PromptMemory {
|
|
47
|
+
/** The dimmed completion the editor draws from recorded prompts. */
|
|
48
|
+
readonly ghostBrush: GhostBrush;
|
|
49
|
+
/** Reverse search over recorded prompts, seeded with whatever is in the bar. */
|
|
50
|
+
readonly openHistoryPicker: () => Promise<void>;
|
|
51
|
+
/** Record a submitted line; the setting decides whether any of it is kept. */
|
|
52
|
+
readonly record: (text: string) => void;
|
|
53
|
+
/** Show where history is kept, or forget it; the file is global to this machine. */
|
|
54
|
+
readonly runHistoryCommand: (argument: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Build the bank for the session this surface drives, and hand it back.
|
|
57
|
+
*
|
|
58
|
+
* Handed back rather than kept here alone: the surface's status count and the
|
|
59
|
+
* parked-draft commands it routes read the same instance, and both exist
|
|
60
|
+
* before a pick could reach a picker — which is why the bank cannot be built
|
|
61
|
+
* with the rest of this owner.
|
|
62
|
+
*/
|
|
63
|
+
readonly buildStash: () => PromptStash;
|
|
64
|
+
/** Follow the session just opened, so the footer counts that session's drafts. */
|
|
65
|
+
readonly sessionOpened: () => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The memory the prompt keeps of what was typed, and what it offers back.
|
|
69
|
+
*
|
|
70
|
+
* Two stores, one subject: the prompt history is global and written from every
|
|
71
|
+
* submitted line, while the stash parks a draft for the session in force. Both
|
|
72
|
+
* are read through the same editor and both answer in a list, so they share the
|
|
73
|
+
* one owner that knows what the reader is looking at.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createPromptMemory(ports: PromptMemoryPorts): PromptMemory;
|
|
76
|
+
//# sourceMappingURL=prompt-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-memory.d.ts","sourceRoot":"","sources":["../../src/surface/prompt-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAM/D;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAA;IACjD,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CACxC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAA;IACtC,QAAQ,CAAC,YAAY,EAAE,MAAM,OAAO,CAAA;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,MAAM,CAAA;IACxC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,MAAM,MAAM,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,8EAA8E;IAC9E,QAAQ,CAAC,eAAe,EAAE,MAAM,OAAO,CAAA;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,EAAE,MAAM,SAAS,CAAA;IACvC,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAC3E;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,oFAAoF;IACpF,QAAQ,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACtD;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,WAAW,CAAA;IACtC,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAA;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA0JzE"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createPromptHistory } from "../agent/prompt-history.js";
|
|
2
|
+
import { ghostSuffix } from "../input/ghost.js";
|
|
3
|
+
import { PromptStash } from "../stash.js";
|
|
4
|
+
import { resetSequence } from "../theme-resolver.js";
|
|
5
|
+
import { TUI_SETTINGS_NAMESPACE } from "../theme-settings.js";
|
|
6
|
+
import { HistoryPicker } from "../ui/history-picker.js";
|
|
7
|
+
import { confirmedClear, StashConfirmPicker, StashPicker } from "../ui/stash-picker.js";
|
|
8
|
+
/** Reverse video for the cell the cursor occupies, so a ghost keeps the cursor visible. */
|
|
9
|
+
const GHOST_CURSOR_PREFIX = '\u001b[7m';
|
|
10
|
+
/**
|
|
11
|
+
* The memory the prompt keeps of what was typed, and what it offers back.
|
|
12
|
+
*
|
|
13
|
+
* Two stores, one subject: the prompt history is global and written from every
|
|
14
|
+
* submitted line, while the stash parks a draft for the session in force. Both
|
|
15
|
+
* are read through the same editor and both answer in a list, so they share the
|
|
16
|
+
* one owner that knows what the reader is looking at.
|
|
17
|
+
*/
|
|
18
|
+
export function createPromptMemory(ports) {
|
|
19
|
+
/**
|
|
20
|
+
* The reader's prompt history: global across projects, recorded from every
|
|
21
|
+
* submitted line, and offered back as they type. Built before the bar exists
|
|
22
|
+
* so its first load cannot race the first suggestion.
|
|
23
|
+
*/
|
|
24
|
+
const promptHistory = createPromptHistory({
|
|
25
|
+
cap: () => ports.historyMaxEntries(),
|
|
26
|
+
warn: message => {
|
|
27
|
+
ports.notice(message);
|
|
28
|
+
ports.render();
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* The dimmed completion drawn from recorded prompts.
|
|
33
|
+
*
|
|
34
|
+
* Colour is the affordance: with styling off the suggestion would be
|
|
35
|
+
* unreadable text the reader could still accept, which is worse than none.
|
|
36
|
+
* The cursor cell is also reversed so the cursor stays visible on the ghost.
|
|
37
|
+
*/
|
|
38
|
+
const ghostBrush = {
|
|
39
|
+
enabled: () => ports.historyEnabled() && ports.historyGhost() && ports.theme.color && ports.theme.visible('editor.ghost'),
|
|
40
|
+
suggestion: input => ghostSuffix({ entries: promptHistory.entries(), ...input }),
|
|
41
|
+
paint: (text, cell) => {
|
|
42
|
+
const styled = ports.theme.style('editor.ghost', text);
|
|
43
|
+
return cell === 'cursor' ? GHOST_CURSOR_PREFIX + styled + resetSequence() : styled;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The bank the surface asked for, as this owner's own reference to it.
|
|
48
|
+
*
|
|
49
|
+
* Late-bound because the surface builds it where a pick can reach a picker:
|
|
50
|
+
* this reference exists before the bank does, and a session opened before
|
|
51
|
+
* then has none to follow.
|
|
52
|
+
*/
|
|
53
|
+
let stash;
|
|
54
|
+
/**
|
|
55
|
+
* Reverse search over recorded prompts, seeded with whatever is in the bar.
|
|
56
|
+
*
|
|
57
|
+
* A pick replaces the draft; a cancel leaves it exactly as it was, because the
|
|
58
|
+
* list was opened to look rather than to lose what is already typed.
|
|
59
|
+
*/
|
|
60
|
+
const openHistoryPicker = async () => {
|
|
61
|
+
if (!ports.historyEnabled()) {
|
|
62
|
+
ports.notice('prompt history is disabled in ' + TUI_SETTINGS_NAMESPACE + ' settings');
|
|
63
|
+
ports.render();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (promptHistory.entries().length === 0) {
|
|
67
|
+
const blocked = promptHistory.blockedReason();
|
|
68
|
+
ports.notice(blocked === undefined ? 'no prompt history yet' : 'prompt history is unavailable: ' + blocked);
|
|
69
|
+
ports.render();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// The expanded text is what the reader wrote; a large paste sits in the bar
|
|
73
|
+
// as a marker, and seeding with it would filter out the prompt it came from.
|
|
74
|
+
const picked = await ports.openPicker(new HistoryPicker(() => promptHistory.entries(), ports.editorText(), () => ports.keymap()));
|
|
75
|
+
if (picked === undefined)
|
|
76
|
+
return;
|
|
77
|
+
ports.setEditorText(picked);
|
|
78
|
+
ports.render();
|
|
79
|
+
};
|
|
80
|
+
/** Show where history is kept, or forget it; the file is global to this machine. */
|
|
81
|
+
const runHistoryCommand = (argument) => {
|
|
82
|
+
// The line that asked for this is recorded before the command runs, but that
|
|
83
|
+
// write rides the store's queue; waiting for it lets the count describe the
|
|
84
|
+
// file the reader has, not the state before their own line landed.
|
|
85
|
+
void promptHistory.flush().then(() => {
|
|
86
|
+
if (argument === '') {
|
|
87
|
+
const count = promptHistory.entries().length;
|
|
88
|
+
const blocked = promptHistory.blockedReason();
|
|
89
|
+
ports.notice([
|
|
90
|
+
count + (count === 1 ? ' prompt recorded' : ' prompts recorded'),
|
|
91
|
+
promptHistory.path(),
|
|
92
|
+
blocked === undefined ? undefined : 'writes disabled: ' + blocked,
|
|
93
|
+
].filter(part => part !== undefined).join(' · '));
|
|
94
|
+
ports.render();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (argument !== 'clear') {
|
|
98
|
+
ports.notice('usage: /history shows where history is kept · /history clear forgets every prompt');
|
|
99
|
+
ports.render();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// A refused write cannot remove anything, so saying "forgot 0 prompts"
|
|
103
|
+
// would describe a successful clear the file never had.
|
|
104
|
+
const blocked = promptHistory.blockedReason();
|
|
105
|
+
if (blocked !== undefined) {
|
|
106
|
+
ports.notice('prompt history is unavailable: ' + blocked);
|
|
107
|
+
ports.render();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return promptHistory.clear().then(removed => {
|
|
111
|
+
ports.notice('forgot ' + removed + (removed === 1 ? ' prompt' : ' prompts'));
|
|
112
|
+
ports.render();
|
|
113
|
+
});
|
|
114
|
+
}).catch(error => {
|
|
115
|
+
// The store keeps what the file still holds, so the reader is told the
|
|
116
|
+
// clear failed rather than being shown a count that never landed.
|
|
117
|
+
ports.notice('could not clear prompt history: ' + (error instanceof Error ? error.message : String(error)));
|
|
118
|
+
ports.render();
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* The prompt bank for the session this surface drives.
|
|
123
|
+
*
|
|
124
|
+
* The surface owns the editor, the picker, and the notices, so the bank is
|
|
125
|
+
* handed the few things it needs to reach them and nothing else: the commands
|
|
126
|
+
* stay free of terminal state and are exercised without one in the tests.
|
|
127
|
+
*/
|
|
128
|
+
const buildStash = () => {
|
|
129
|
+
stash = new PromptStash({
|
|
130
|
+
getEditorText: () => ports.editorText(),
|
|
131
|
+
setEditorText: text => ports.setEditorText(text),
|
|
132
|
+
editorIsAvailable: () => ports.editorAvailable(),
|
|
133
|
+
notice: message => ports.notice(message),
|
|
134
|
+
pick: (entries, label) => ports.openPicker(new StashPicker(entries, label, () => ports.keymap())),
|
|
135
|
+
confirm: async (count) => confirmedClear(await ports.openPicker(new StashConfirmPicker(count, () => ports.keymap()))),
|
|
136
|
+
render: () => ports.render(),
|
|
137
|
+
},
|
|
138
|
+
// The bank follows the session this surface drives, not the directory it
|
|
139
|
+
// runs in: two terminals in one checkout keep separate drafts, and a resume
|
|
140
|
+
// finds the ones it parked. Read per command so a switch retargets it.
|
|
141
|
+
{ sessionId: () => String(ports.activeSession()) });
|
|
142
|
+
return stash;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Follow the session the surface has just opened.
|
|
146
|
+
*
|
|
147
|
+
* The bank follows the session, so the footer stops counting the drafts of
|
|
148
|
+
* the session just left and the next command reads this session's file.
|
|
149
|
+
*/
|
|
150
|
+
const sessionOpened = () => {
|
|
151
|
+
void stash?.open();
|
|
152
|
+
};
|
|
153
|
+
/** Record a submitted line, when the reader has recording on at all. */
|
|
154
|
+
const record = (text) => {
|
|
155
|
+
if (ports.historyEnabled())
|
|
156
|
+
promptHistory.record(text);
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
ghostBrush,
|
|
160
|
+
openHistoryPicker,
|
|
161
|
+
record,
|
|
162
|
+
runHistoryCommand,
|
|
163
|
+
buildStash,
|
|
164
|
+
sessionOpened,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=prompt-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-memory.js","sourceRoot":"","sources":["../../src/surface/prompt-memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAA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AAE;SAC7B;QACD,yEAAyE;QACzE,4EAA4E;QAC5E,uEAAuE;QACvE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,EAAE,CACnD,CAAA;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED;;;;;OAKG;IACH,MAAM,aAAa,GAAG,GAAS,EAAE;QAC/B,KAAK,KAAK,EAAE,IAAI,EAAE,CAAA;IACpB,CAAC,CAAA;IAED,wEAAwE;IACxE,MAAM,MAAM,GAAG,CAAC,IAAY,EAAQ,EAAE;QACpC,IAAI,KAAK,CAAC,cAAc,EAAE;YAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxD,CAAC,CAAA;IAED,OAAO;QACL,UAAU;QACV,iBAAiB;QACjB,MAAM;QACN,iBAAiB;QACjB,UAAU;QACV,aAAa;KACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
4
|
+
import { type ForkEvent } from '../agent/fork.ts';
|
|
5
|
+
import { type ForkInheritance, type TuiAgent } from '../agent/host.ts';
|
|
6
|
+
import type { HerdrReporter } from '../herdr/reporter.ts';
|
|
7
|
+
/** The session this process runs, as much of it as a driven read needs. */
|
|
8
|
+
export interface LiveSession {
|
|
9
|
+
/** The events this process holds unflushed, which storage alone does not. */
|
|
10
|
+
readonly snapshotEvents?: () => readonly ForkEvent[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What the session's lifecycle owner needs from the surface that composes it.
|
|
14
|
+
*
|
|
15
|
+
* Every read is taken at call time: the session, the scrollback and the queue
|
|
16
|
+
* all move while a transition settles, and a captured copy would name the
|
|
17
|
+
* session this terminal drove before the reader moved.
|
|
18
|
+
*/
|
|
19
|
+
export interface SessionLifecyclePorts {
|
|
20
|
+
/** The session this run was launched for; another is reached only by switching. */
|
|
21
|
+
readonly initialSession: SessionId;
|
|
22
|
+
/** The route this run was launched with: the model, and the provider it names. */
|
|
23
|
+
readonly model: string | undefined;
|
|
24
|
+
readonly provider: string | undefined;
|
|
25
|
+
/** Whether this run rings for a turn that ran long enough. */
|
|
26
|
+
readonly bell: boolean;
|
|
27
|
+
/** The mode a session takes, settled before the transcript is touched. */
|
|
28
|
+
readonly presetFor: (id: SessionId, resume: boolean, fork: ForkInheritance | undefined) => Promise<string | undefined>;
|
|
29
|
+
/** Install the session's own route; the world the preset mounts reads it back. */
|
|
30
|
+
readonly installModelChoice: (agentCtx: Context) => void;
|
|
31
|
+
/** Mount the mode a new session runs into the agent's own scope. */
|
|
32
|
+
readonly mountPreset: (agentCtx: Context, preset: string) => Promise<void>;
|
|
33
|
+
/** The live session this process runs, which is the only source holding the queue. */
|
|
34
|
+
readonly liveSession: (id: SessionId) => LiveSession | undefined;
|
|
35
|
+
/** Re-arm the bar's completion against the world the new agent mounted. */
|
|
36
|
+
readonly installCompletion: () => void;
|
|
37
|
+
/** Every event of a session, which a fork cut is derived from. */
|
|
38
|
+
readonly sessionEvents: (id: SessionId) => Promise<readonly ForkEvent[]>;
|
|
39
|
+
/** Show a session without folding it; the open owns the fold that follows. */
|
|
40
|
+
readonly setViewed: (id: SessionId) => void;
|
|
41
|
+
/** The scope a folded card reads its tool through. */
|
|
42
|
+
readonly setPresentScope: (scope: Agent | undefined) => void;
|
|
43
|
+
/** Drop that scope; the outgoing agent is torn down after it. */
|
|
44
|
+
readonly clearPresentScope: () => void;
|
|
45
|
+
readonly resetTranscript: () => void;
|
|
46
|
+
readonly replay: (id: SessionId) => Promise<void>;
|
|
47
|
+
readonly fold: (id: SessionId) => Promise<number>;
|
|
48
|
+
readonly notice: (message: string) => void;
|
|
49
|
+
readonly render: () => void;
|
|
50
|
+
/** The prompt memory's per-session reset, taken when a session is really opened. */
|
|
51
|
+
readonly promptMemorySessionOpened: () => void;
|
|
52
|
+
/** The staged owner's fresh cursor for the session just opened. */
|
|
53
|
+
readonly stagedSessionOpened: (id: SessionId) => void;
|
|
54
|
+
/** The turn/end an undo may be parked waiting for. */
|
|
55
|
+
readonly turnSettled: () => void;
|
|
56
|
+
/** The parent's catalog names the child; lifecycle events carry only its id. */
|
|
57
|
+
readonly acceptCatalog: (info: unknown) => void;
|
|
58
|
+
/** Drop the roster of the session a transition lets go of. */
|
|
59
|
+
readonly resetRoster: () => void;
|
|
60
|
+
/** A job the turn started may have settled while the reader watched elsewhere. */
|
|
61
|
+
readonly refreshJobs: () => void;
|
|
62
|
+
/** The pane's agent row, which hears the driver rather than each turn. */
|
|
63
|
+
readonly herdr: HerdrReporter;
|
|
64
|
+
/** Write to the tty, but only while this surface owns it. */
|
|
65
|
+
readonly writeTerminal: (text: string) => void;
|
|
66
|
+
/** Whether the exit has begun, which mutes the bell. */
|
|
67
|
+
readonly exiting: () => boolean;
|
|
68
|
+
/** The surface's teardowns, in the order they are registered. */
|
|
69
|
+
readonly disposers: Array<() => void>;
|
|
70
|
+
}
|
|
71
|
+
/** The agent this terminal drives, and every read or operation the composer takes from it. */
|
|
72
|
+
export interface SessionLifecycle {
|
|
73
|
+
/** The session this surface drives: commands, approvals, and the bell belong to it. */
|
|
74
|
+
readonly activeSession: () => SessionId;
|
|
75
|
+
/** The agent in service, or undefined while a transition creates the next one. */
|
|
76
|
+
readonly drivingAgent: () => TuiAgent | undefined;
|
|
77
|
+
/** Whether a turn is open, which the clock, the title and the bell read. */
|
|
78
|
+
readonly turnRunning: () => boolean;
|
|
79
|
+
/** What the running-state clock reports: a turn, and when it started. */
|
|
80
|
+
readonly activity: () => {
|
|
81
|
+
readonly running: boolean;
|
|
82
|
+
readonly startedAt: number | undefined;
|
|
83
|
+
};
|
|
84
|
+
/** Whether a session was really opened, which is what an exit hint can name. */
|
|
85
|
+
readonly sessionOpened: () => boolean;
|
|
86
|
+
/** The prompts queued on the driven agent, which an interrupt would drop. */
|
|
87
|
+
readonly queuedPrompts: () => readonly string[];
|
|
88
|
+
/** Stop the clock that repaints a running turn; an exit does not wait for it. */
|
|
89
|
+
readonly stopClock: () => void;
|
|
90
|
+
/**
|
|
91
|
+
* Stop the agent in service and let go of what it projected: the handle and its
|
|
92
|
+
* projections go before the world they name is torn down, and the stop is
|
|
93
|
+
* awaited so the next agent joins a surface nothing is still writing to.
|
|
94
|
+
*/
|
|
95
|
+
readonly disposeOutgoing: () => Promise<void>;
|
|
96
|
+
/** Start the agent for a session, which is what a replacement joins. */
|
|
97
|
+
readonly openAgent: (id: SessionId, resume: boolean, fork?: ForkInheritance) => Promise<TuiAgent>;
|
|
98
|
+
/** Move the surface to another stored session without leaving the terminal. */
|
|
99
|
+
readonly switchSession: (id: SessionId) => Promise<void>;
|
|
100
|
+
/** Start a fresh session without leaving the terminal. */
|
|
101
|
+
readonly runNewCommand: (title: string) => void;
|
|
102
|
+
/** Compose this session's agent again without leaving the conversation. */
|
|
103
|
+
readonly runReloadCommand: () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Branch this conversation and continue in the branch: a real session that
|
|
106
|
+
* inherits a prefix of this one, cut at the last completed turn because half an
|
|
107
|
+
* exchange is not a state to hand a model.
|
|
108
|
+
*/
|
|
109
|
+
readonly runForkCommand: (title: string) => void;
|
|
110
|
+
/** Give this session a title. */
|
|
111
|
+
readonly runRenameCommand: (title: string) => void;
|
|
112
|
+
/** The driven half of one durable event; the caller folds the viewed half. */
|
|
113
|
+
readonly observe: (session: {
|
|
114
|
+
readonly id: SessionId;
|
|
115
|
+
}, event: ForkEvent) => void;
|
|
116
|
+
/** The listeners that follow the driver rather than each turn. */
|
|
117
|
+
readonly driverListeners: () => readonly (() => void)[];
|
|
118
|
+
}
|
|
119
|
+
export declare function createSessionLifecycle(ctx: Context, ports: SessionLifecyclePorts): SessionLifecycle;
|
|
120
|
+
//# sourceMappingURL=session-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
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