@aiwayds/dsh-tui-pi 0.1.1 → 0.4.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/README.md +175 -41
- package/lib/agent-manager.d.ts +125 -0
- package/lib/agent-manager.js +298 -0
- package/lib/agent-manager.js.map +1 -0
- package/lib/agents.d.ts +30 -0
- package/lib/agents.js +489 -0
- package/lib/agents.js.map +1 -0
- package/lib/append-system.d.ts +2 -0
- package/lib/append-system.js +1 -1
- package/lib/append-system.js.map +1 -1
- package/lib/dsh-events.d.ts +12 -0
- package/lib/editor.d.ts +58 -0
- package/lib/editor.js +92 -0
- package/lib/editor.js.map +1 -1
- package/lib/footer.d.ts +46 -0
- package/lib/footer.js +65 -0
- package/lib/footer.js.map +1 -1
- package/lib/hotkeys.d.ts +93 -0
- package/lib/hotkeys.js +305 -0
- package/lib/hotkeys.js.map +1 -0
- package/lib/index.js +342 -61
- package/lib/index.js.map +1 -1
- package/lib/keymap.d.ts +243 -0
- package/lib/keymap.js +245 -0
- package/lib/keymap.js.map +1 -0
- package/lib/live-widgets.d.ts +59 -49
- package/lib/live-widgets.js +174 -117
- package/lib/live-widgets.js.map +1 -1
- package/lib/panels.d.ts +177 -0
- package/lib/panels.js +331 -0
- package/lib/panels.js.map +1 -0
- package/lib/selectors.d.ts +12 -1
- package/lib/selectors.js +1 -1
- package/lib/selectors.js.map +1 -1
- package/lib/session.d.ts +25 -0
- package/lib/session.js +173 -12
- package/lib/session.js.map +1 -1
- package/lib/settings.d.ts +1 -2
- package/lib/subagent-policy.d.ts +88 -0
- package/lib/subagent-policy.js +189 -0
- package/lib/subagent-policy.js.map +1 -0
- package/lib/subagent-viewer.d.ts +49 -0
- package/lib/subagent-viewer.js +523 -0
- package/lib/subagent-viewer.js.map +1 -0
- package/lib/theme/index.js +4 -0
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/palette.d.ts +21 -3
- package/lib/theme/palette.js +27 -6
- package/lib/theme/palette.js.map +1 -1
- package/lib/theme-settings.d.ts +71 -9
- package/lib/theme-settings.js +145 -21
- package/lib/theme-settings.js.map +1 -1
- package/lib/tui.d.ts +23 -9
- package/lib/tui.js +110 -7
- package/lib/tui.js.map +1 -1
- package/package.json +3 -4
- package/patches/@earendil-works__pi-tui.patch +206 -2
- package/scripts/dev-install.mjs +87 -0
- package/scripts/link-dsh-closure.mjs +85 -0
- package/templates/agents/ArtyDuck.md +11 -0
- package/templates/agents/oldfox.md +33 -0
- package/templates/agents/workhorse.md +34 -0
package/lib/theme/palette.js
CHANGED
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
* fills are solid approximations of alpha tints blended over `canvas`
|
|
11
11
|
* (the terminal can't carry alpha) — same values as `blend()` below.
|
|
12
12
|
*
|
|
13
|
-
* The TUI
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* The TUI paints every rendered row with `canvas` (patched pi-tui
|
|
14
|
+
* `setCanvasBackground`, see src/tui.ts) — the app owns its background, so
|
|
15
|
+
* a theme switch recolors the whole screen and the terminal/multiplexer
|
|
16
|
+
* background never shows through. `canvasSubtle` stays the visible raised
|
|
17
|
+
* surface on top of it. DSH_TUI_TRANSPARENT=1 reverts to the old
|
|
18
|
+
* see-through canvas, where `canvas` is only the semantic base for the dark
|
|
19
|
+
* muted blends and contrast design.
|
|
16
20
|
*/
|
|
17
21
|
export const githubLight = {
|
|
18
22
|
name: 'github-light',
|
|
23
|
+
dark: false,
|
|
19
24
|
// Main canvas: near-white with a faint cool-green cast (not the harsh
|
|
20
|
-
// pure #fff); paper feel.
|
|
21
|
-
//
|
|
22
|
-
// dark muted blends and contrast design.
|
|
25
|
+
// pure #fff); paper feel. Painted on every rendered row (see the module
|
|
26
|
+
// header) — the whole screen carries it.
|
|
23
27
|
canvas: '#fcfdfc',
|
|
24
28
|
// Raised surface (message bubbles, think/tool panels, overlays, code
|
|
25
29
|
// blocks): one step darker than the canvas, clear gray-green.
|
|
@@ -83,6 +87,7 @@ function blend(base, over, alpha) {
|
|
|
83
87
|
}
|
|
84
88
|
export const githubDark = {
|
|
85
89
|
name: 'github-dark',
|
|
90
|
+
dark: true,
|
|
86
91
|
// Main canvas: deep gray-blue (the GitHub dark family).
|
|
87
92
|
canvas: '#0d1117',
|
|
88
93
|
// Raised surface (bubbles, panels, overlays): one step lighter gray-blue.
|
|
@@ -151,4 +156,20 @@ export function detectDarkPalette(env = process.env) {
|
|
|
151
156
|
// Default to dark — GitHub's terminal default and the safer contrast choice.
|
|
152
157
|
return true;
|
|
153
158
|
}
|
|
159
|
+
/** WCAG relative luminance of an RGB triple (0 = black, 1 = white). */
|
|
160
|
+
function rgbLuminance({ r, g, b }) {
|
|
161
|
+
const toLinear = (channel) => {
|
|
162
|
+
const value = channel / 255;
|
|
163
|
+
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
164
|
+
};
|
|
165
|
+
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* True when an OSC 11 background color reads as a light terminal (the same
|
|
169
|
+
* 0.5 luminance threshold pi uses for its terminal detection). Structural
|
|
170
|
+
* match for pi-tui's `RgbColor`, so the query result passes through as-is.
|
|
171
|
+
*/
|
|
172
|
+
export function rgbIsLight(rgb) {
|
|
173
|
+
return rgbLuminance(rgb) >= 0.5;
|
|
174
|
+
}
|
|
154
175
|
//# sourceMappingURL=palette.js.map
|
package/lib/theme/palette.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/theme/palette.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/theme/palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAqCH,MAAM,CAAC,MAAM,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,IAAI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,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;QACtD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,6EAA6E;IAC7E,OAAO,IAAI,CAAA;AACb,CAAC;AASD,uEAAuE;AACvE,SAAS,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAO;IACpC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAU,EAAE;QAC3C,MAAM,KAAK,GAAG,OAAO,GAAG,GAAG,CAAA;QAC3B,OAAO,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAA;IAC5E,CAAC,CAAA;IACD,OAAO,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,GAAG,CAAA;AACjC,CAAC"}
|
package/lib/theme-settings.d.ts
CHANGED
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Theme settings: persists the user's theme preference
|
|
3
|
-
*
|
|
4
|
-
* /settings browser and the /theme
|
|
5
|
-
*
|
|
2
|
+
* Theme settings: persists the user's theme preference, the think/tool panel
|
|
3
|
+
* height, and the subagent concurrency/rounds limits under the `dsh-tui`
|
|
4
|
+
* settings namespace, surfaced by the /settings browser and the /theme
|
|
5
|
+
* command. The theme and panel-height preferences are read once at TUI
|
|
6
|
+
* startup (`readThemePreference` / `readPanelHeightPreference`); the subagent
|
|
7
|
+
* limits are read live at every policy decision (`readSubagentLimits`). The
|
|
6
8
|
* namespace is marked `applies: 'live'`: a committed change (the /theme
|
|
7
9
|
* picker, the /settings browser, an external edit) is pushed through the
|
|
8
10
|
* watch hook, so the running TUI repaints without a restart.
|
|
9
11
|
*/
|
|
10
12
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
13
|
import { type SettingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
14
|
+
import { type FooterHints } from './footer.ts';
|
|
12
15
|
import { type PanelHeight } from './messages.ts';
|
|
13
16
|
import type { ThemePreference } from './theme/index.ts';
|
|
14
17
|
/** Settings namespace carrying the persisted dsh-tui preferences. */
|
|
15
18
|
export declare const THEME_SETTINGS_NAMESPACE: SettingsNamespace;
|
|
19
|
+
/** Subagent concurrency/rounds/tool knobs read by the subagent policy. */
|
|
20
|
+
export interface SubagentLimits {
|
|
21
|
+
/** Concurrent live children allowed; 0 lifts the cap (the guard stays off). */
|
|
22
|
+
maxAgents: number;
|
|
23
|
+
/** Completed turns per child before a summary request is injected; 0 disables. */
|
|
24
|
+
maxRounds: number;
|
|
25
|
+
/**
|
|
26
|
+
* Disable the native `subagent` tool for every agent in the process, so
|
|
27
|
+
* plain ad-hoc delegation goes through a registered agent definition
|
|
28
|
+
* (`~/.dsh/agents/*.md` via `use_agent`) instead. Deliberately narrow:
|
|
29
|
+
* `subagent_fork`, `workflow` and `ralph` stay available (they are not the
|
|
30
|
+
* plain one-shot spawn the TUI's user wants fenced off).
|
|
31
|
+
*/
|
|
32
|
+
disableSubagent: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default subagent limits, applied whenever the settings service, namespace,
|
|
36
|
+
* or a field cannot be read. 4 concurrent children and 50 rounds per child are
|
|
37
|
+
* the documented out-of-the-box behavior; the native `subagent` tool is
|
|
38
|
+
* disabled by default — the TUI's user delegates through registered agents
|
|
39
|
+
* (toggle it in /agents → l limits when the plain tool is needed again).
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_SUBAGENT_LIMITS: SubagentLimits;
|
|
16
42
|
/**
|
|
17
43
|
* Register the `dsh-tui` settings namespace with the settings provider.
|
|
18
44
|
*
|
|
@@ -28,12 +54,12 @@ export declare const THEME_SETTINGS_NAMESPACE: SettingsNamespace;
|
|
|
28
54
|
* startup.
|
|
29
55
|
*
|
|
30
56
|
* @param ctx - plugin context; does nothing while no settings service is mounted.
|
|
31
|
-
* @param onPreferenceChange - hot-reload sink for committed `dsh-tui` theme
|
|
32
|
-
*
|
|
33
|
-
* registered (a reloaded plugin instance, a second mount of this
|
|
34
|
-
* registration fails.
|
|
57
|
+
* @param onPreferenceChange - hot-reload sink for committed `dsh-tui` theme,
|
|
58
|
+
* panel-height and footer-hints changes; `undefined` when the namespace is
|
|
59
|
+
* already registered (a reloaded plugin instance, a second mount of this
|
|
60
|
+
* bundle) or registration fails.
|
|
35
61
|
*/
|
|
36
|
-
export declare function registerThemeSettings(ctx: Context, onPreferenceChange?: (pref: ThemePreference, panelHeight: PanelHeight) => void): void;
|
|
62
|
+
export declare function registerThemeSettings(ctx: Context, onPreferenceChange?: (pref: ThemePreference, panelHeight: PanelHeight, footerHints: FooterHints) => void): void;
|
|
37
63
|
/**
|
|
38
64
|
* Read the persisted theme preference (the startup snapshot).
|
|
39
65
|
*
|
|
@@ -50,6 +76,22 @@ export declare function readThemePreference(ctx: Context): Promise<ThemePreferen
|
|
|
50
76
|
* when the settings service is absent or the namespace/value cannot be read.
|
|
51
77
|
*/
|
|
52
78
|
export declare function readPanelHeightPreference(ctx: Context): Promise<PanelHeight>;
|
|
79
|
+
/**
|
|
80
|
+
* Read the persisted footer-hint selection (the startup snapshot).
|
|
81
|
+
*
|
|
82
|
+
* @param ctx - plugin context.
|
|
83
|
+
* @returns the resolved `dsh-tui` footerHints object, or DEFAULT_FOOTER_HINTS
|
|
84
|
+
* when the settings service is absent or the namespace/value cannot be read.
|
|
85
|
+
*/
|
|
86
|
+
export declare function readFooterHintsPreference(ctx: Context): Promise<FooterHints>;
|
|
87
|
+
/**
|
|
88
|
+
* Read the currently persisted footer-hint selection, synchronously.
|
|
89
|
+
* Unlike `readFooterHintsPreference` (the startup snapshot), this does not
|
|
90
|
+
* wait for the namespace registration - it describes whatever the settings
|
|
91
|
+
* service exposes right now, so a caller can honor a live change immediately.
|
|
92
|
+
* @returns DEFAULT_FOOTER_HINTS when the service, namespace, or value is absent.
|
|
93
|
+
*/
|
|
94
|
+
export declare function currentFooterHints(ctx: Context): FooterHints;
|
|
53
95
|
/**
|
|
54
96
|
* Read the currently persisted theme preference, synchronously.
|
|
55
97
|
* Unlike `readThemePreference` (the startup snapshot), this does not wait for
|
|
@@ -66,3 +108,23 @@ export declare function currentThemePreference(ctx: Context): ThemePreference;
|
|
|
66
108
|
* @returns undefined on success, the failure message otherwise.
|
|
67
109
|
*/
|
|
68
110
|
export declare function writeThemePreference(ctx: Context, pref: ThemePreference): Promise<string | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* Read the currently resolved subagent limits, synchronously. Unlike the
|
|
113
|
+
* startup-snapshot readers, this does not wait for the namespace registration
|
|
114
|
+
* — it describes whatever the settings service exposes right now, so every
|
|
115
|
+
* policy decision (the guard at each spawn, `onTurnCount` at each child turn)
|
|
116
|
+
* reflects the latest committed value without a watcher. Missing settings
|
|
117
|
+
* service or namespace, or a non-integer/negative field, degrades to the
|
|
118
|
+
* defaults — a settings-less deployment keeps the documented caps.
|
|
119
|
+
*/
|
|
120
|
+
export declare function readSubagentLimits(ctx: Context): SubagentLimits;
|
|
121
|
+
/**
|
|
122
|
+
* Persist one subagent policy knob (maxAgents, maxRounds, or disableSubagent)
|
|
123
|
+
* to the `dsh-tui` settings namespace. The namespace is `applies: 'live'`, so
|
|
124
|
+
* the commit hot-applies without a restart — the policy reads
|
|
125
|
+
* `readSubagentLimits` at the next decision point. Never throws: a deployment
|
|
126
|
+
* without the settings provider, or an unregistered namespace, surfaces a
|
|
127
|
+
* failure message for the caller.
|
|
128
|
+
* @returns undefined on success, the failure message otherwise.
|
|
129
|
+
*/
|
|
130
|
+
export declare function writeSubagentLimit(ctx: Context, key: 'maxAgents' | 'maxRounds' | 'disableSubagent', value: number | boolean): Promise<string | undefined>;
|
package/lib/theme-settings.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Theme settings: persists the user's theme preference
|
|
3
|
-
*
|
|
4
|
-
* /settings browser and the /theme
|
|
5
|
-
*
|
|
2
|
+
* Theme settings: persists the user's theme preference, the think/tool panel
|
|
3
|
+
* height, and the subagent concurrency/rounds limits under the `dsh-tui`
|
|
4
|
+
* settings namespace, surfaced by the /settings browser and the /theme
|
|
5
|
+
* command. The theme and panel-height preferences are read once at TUI
|
|
6
|
+
* startup (`readThemePreference` / `readPanelHeightPreference`); the subagent
|
|
7
|
+
* limits are read live at every policy decision (`readSubagentLimits`). The
|
|
6
8
|
* namespace is marked `applies: 'live'`: a committed change (the /theme
|
|
7
9
|
* picker, the /settings browser, an external edit) is pushed through the
|
|
8
10
|
* watch hook, so the running TUI repaints without a restart.
|
|
9
11
|
*/
|
|
10
12
|
import { SettingsConflictError, settingsNamespace, } from '@deepseek-ai/dsh-settings';
|
|
11
13
|
import z from '@deepseek-ai/schemastery';
|
|
14
|
+
import { DEFAULT_FOOTER_HINTS } from "./footer.js";
|
|
12
15
|
import { DEFAULT_PANEL_HEIGHT } from "./messages.js";
|
|
13
16
|
/** Settings namespace carrying the persisted dsh-tui preferences. */
|
|
14
17
|
export const THEME_SETTINGS_NAMESPACE = settingsNamespace('dsh-tui');
|
|
18
|
+
/**
|
|
19
|
+
* Default subagent limits, applied whenever the settings service, namespace,
|
|
20
|
+
* or a field cannot be read. 4 concurrent children and 50 rounds per child are
|
|
21
|
+
* the documented out-of-the-box behavior; the native `subagent` tool is
|
|
22
|
+
* disabled by default — the TUI's user delegates through registered agents
|
|
23
|
+
* (toggle it in /agents → l limits when the plain tool is needed again).
|
|
24
|
+
*/
|
|
25
|
+
export const DEFAULT_SUBAGENT_LIMITS = Object.freeze({
|
|
26
|
+
maxAgents: 4,
|
|
27
|
+
maxRounds: 50,
|
|
28
|
+
disableSubagent: true,
|
|
29
|
+
});
|
|
15
30
|
/** Schema of the `dsh-tui` settings section. */
|
|
16
31
|
const THEME_SETTINGS_SCHEMA = z.object({
|
|
17
32
|
theme: z
|
|
@@ -24,11 +39,42 @@ const THEME_SETTINGS_SCHEMA = z.object({
|
|
|
24
39
|
.description("Think/tool panel height in displayed rows ('5'/'7'/'10' — header + content lines; "
|
|
25
40
|
+ "box borders add 2 more) or 'all' to print the full content — a streaming "
|
|
26
41
|
+ 'reasoning panel shows a 200-line live tail and tool results cap at 2000 lines'),
|
|
42
|
+
// `z.natural()` is schemastery's constraint for a non-negative integer
|
|
43
|
+
// (the `z.number().int().min(0)` intent — no `.int()` chain exists here).
|
|
44
|
+
maxAgents: z
|
|
45
|
+
.natural()
|
|
46
|
+
.default(DEFAULT_SUBAGENT_LIMITS.maxAgents)
|
|
47
|
+
.description('Max concurrently running subagents (0 = unlimited)'),
|
|
48
|
+
maxRounds: z
|
|
49
|
+
.natural()
|
|
50
|
+
.default(DEFAULT_SUBAGENT_LIMITS.maxRounds)
|
|
51
|
+
.description('Max rounds per subagent before the TUI sends a summary request (0 = unlimited)'),
|
|
52
|
+
disableSubagent: z
|
|
53
|
+
.boolean()
|
|
54
|
+
.default(DEFAULT_SUBAGENT_LIMITS.disableSubagent)
|
|
55
|
+
.description('Disable the native subagent tool (delegation goes through registered '
|
|
56
|
+
+ 'agents, ~/.dsh/agents/*.md via use_agent); subagent_fork/workflow/'
|
|
57
|
+
+ 'ralph stay available'),
|
|
58
|
+
footerHints: z
|
|
59
|
+
.object({
|
|
60
|
+
send: z.boolean().default(true).description('Show "Enter: send" in the footer hint bar'),
|
|
61
|
+
stop: z.boolean().default(true).description('Show "Esc ×2: stop" in the footer hint bar'),
|
|
62
|
+
quit: z.boolean().default(true).description('Show "Ctrl+C ×2: quit" in the footer hint bar'),
|
|
63
|
+
quitEmpty: z.boolean().default(true).description('Show "Ctrl+D: quit (empty)" in the footer hint bar'),
|
|
64
|
+
subagents: z.boolean().default(true).description('Show "Ctrl+G: subagents" in the footer hint bar'),
|
|
65
|
+
history: z.boolean().default(true).description('Show "↑↓: history" in the footer hint bar'),
|
|
66
|
+
})
|
|
67
|
+
.default({ ...DEFAULT_FOOTER_HINTS })
|
|
68
|
+
.description('Footer shortcut hints to display (toggle each one on/off)'),
|
|
27
69
|
});
|
|
28
70
|
/** Composition entry below the user layer: fall back to the defaults. */
|
|
29
71
|
const THEME_SETTINGS_ENTRY = {
|
|
30
72
|
theme: 'auto',
|
|
31
73
|
panelHeight: DEFAULT_PANEL_HEIGHT,
|
|
74
|
+
maxAgents: DEFAULT_SUBAGENT_LIMITS.maxAgents,
|
|
75
|
+
maxRounds: DEFAULT_SUBAGENT_LIMITS.maxRounds,
|
|
76
|
+
disableSubagent: DEFAULT_SUBAGENT_LIMITS.disableSubagent,
|
|
77
|
+
footerHints: { ...DEFAULT_FOOTER_HINTS },
|
|
32
78
|
};
|
|
33
79
|
/**
|
|
34
80
|
* In-flight namespace registration. The registration rides the settings
|
|
@@ -52,10 +98,10 @@ let registrationPromise;
|
|
|
52
98
|
* startup.
|
|
53
99
|
*
|
|
54
100
|
* @param ctx - plugin context; does nothing while no settings service is mounted.
|
|
55
|
-
* @param onPreferenceChange - hot-reload sink for committed `dsh-tui` theme
|
|
56
|
-
*
|
|
57
|
-
* registered (a reloaded plugin instance, a second mount of this
|
|
58
|
-
* registration fails.
|
|
101
|
+
* @param onPreferenceChange - hot-reload sink for committed `dsh-tui` theme,
|
|
102
|
+
* panel-height and footer-hints changes; `undefined` when the namespace is
|
|
103
|
+
* already registered (a reloaded plugin instance, a second mount of this
|
|
104
|
+
* bundle) or registration fails.
|
|
59
105
|
*/
|
|
60
106
|
export function registerThemeSettings(ctx, onPreferenceChange) {
|
|
61
107
|
registrationPromise = new Promise(resolve => {
|
|
@@ -78,12 +124,12 @@ export function registerThemeSettings(ctx, onPreferenceChange) {
|
|
|
78
124
|
});
|
|
79
125
|
if (onPreferenceChange !== undefined) {
|
|
80
126
|
scope.watch((next) => {
|
|
81
|
-
// The resolved section is `{ theme: ..., panelHeight:
|
|
82
|
-
// narrow the unknown to the
|
|
127
|
+
// The resolved section is `{ theme: ..., panelHeight: ...,
|
|
128
|
+
// footerHints: {...} }` — narrow the unknown to the observed fields.
|
|
83
129
|
const section = next;
|
|
84
130
|
const theme = section.theme;
|
|
85
131
|
const panelHeight = section.panelHeight;
|
|
86
|
-
onPreferenceChange(theme === 'light' || theme === 'dark' ? theme : 'auto', panelHeight === '7' || panelHeight === '10' || panelHeight === 'all' ? panelHeight : DEFAULT_PANEL_HEIGHT);
|
|
132
|
+
onPreferenceChange(theme === 'light' || theme === 'dark' ? theme : 'auto', panelHeight === '7' || panelHeight === '10' || panelHeight === 'all' ? panelHeight : DEFAULT_PANEL_HEIGHT, narrowFooterHints(section.footerHints));
|
|
87
133
|
});
|
|
88
134
|
}
|
|
89
135
|
}
|
|
@@ -97,6 +143,18 @@ export function registerThemeSettings(ctx, onPreferenceChange) {
|
|
|
97
143
|
});
|
|
98
144
|
});
|
|
99
145
|
}
|
|
146
|
+
/** Validate an unknown `footerHints` value into the typed shape (defaults win). */
|
|
147
|
+
function narrowFooterHints(value) {
|
|
148
|
+
if (value === null || typeof value !== 'object')
|
|
149
|
+
return { ...DEFAULT_FOOTER_HINTS };
|
|
150
|
+
const section = value;
|
|
151
|
+
const hints = { ...DEFAULT_FOOTER_HINTS };
|
|
152
|
+
for (const key of Object.keys(DEFAULT_FOOTER_HINTS)) {
|
|
153
|
+
if (typeof section[key] === 'boolean')
|
|
154
|
+
hints[key] = section[key];
|
|
155
|
+
}
|
|
156
|
+
return hints;
|
|
157
|
+
}
|
|
100
158
|
/**
|
|
101
159
|
* The resolved `dsh-tui` section as read from the settings provider, after
|
|
102
160
|
* waiting for the in-flight registration.
|
|
@@ -126,8 +184,8 @@ async function readResolvedSection(ctx) {
|
|
|
126
184
|
if (settings === undefined)
|
|
127
185
|
return undefined;
|
|
128
186
|
// The descriptor's `value` is the whole resolved section
|
|
129
|
-
// (`{ theme: ..., panelHeight: ... }`), not the field
|
|
130
|
-
// unknown to the
|
|
187
|
+
// (`{ theme: ..., panelHeight: ..., footerHints: {...} }`), not the field
|
|
188
|
+
// itself — narrow the unknown to the three observed fields.
|
|
131
189
|
return settings
|
|
132
190
|
.describe()
|
|
133
191
|
.find((descriptor) => descriptor.ns === THEME_SETTINGS_NAMESPACE)?.value;
|
|
@@ -158,6 +216,32 @@ export async function readPanelHeightPreference(ctx) {
|
|
|
158
216
|
return height;
|
|
159
217
|
return DEFAULT_PANEL_HEIGHT;
|
|
160
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Read the persisted footer-hint selection (the startup snapshot).
|
|
221
|
+
*
|
|
222
|
+
* @param ctx - plugin context.
|
|
223
|
+
* @returns the resolved `dsh-tui` footerHints object, or DEFAULT_FOOTER_HINTS
|
|
224
|
+
* when the settings service is absent or the namespace/value cannot be read.
|
|
225
|
+
*/
|
|
226
|
+
export async function readFooterHintsPreference(ctx) {
|
|
227
|
+
return narrowFooterHints((await readResolvedSection(ctx))?.footerHints);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Read the currently persisted footer-hint selection, synchronously.
|
|
231
|
+
* Unlike `readFooterHintsPreference` (the startup snapshot), this does not
|
|
232
|
+
* wait for the namespace registration - it describes whatever the settings
|
|
233
|
+
* service exposes right now, so a caller can honor a live change immediately.
|
|
234
|
+
* @returns DEFAULT_FOOTER_HINTS when the service, namespace, or value is absent.
|
|
235
|
+
*/
|
|
236
|
+
export function currentFooterHints(ctx) {
|
|
237
|
+
const settings = ctx.get('settings');
|
|
238
|
+
if (settings === undefined)
|
|
239
|
+
return { ...DEFAULT_FOOTER_HINTS };
|
|
240
|
+
const hints = settings
|
|
241
|
+
.describe()
|
|
242
|
+
.find((descriptor) => descriptor.ns === THEME_SETTINGS_NAMESPACE)?.value?.footerHints;
|
|
243
|
+
return narrowFooterHints(hints);
|
|
244
|
+
}
|
|
161
245
|
/**
|
|
162
246
|
* Read the currently persisted theme preference, synchronously.
|
|
163
247
|
* Unlike `readThemePreference` (the startup snapshot), this does not wait for
|
|
@@ -178,14 +262,14 @@ export function currentThemePreference(ctx) {
|
|
|
178
262
|
return 'auto';
|
|
179
263
|
}
|
|
180
264
|
/**
|
|
181
|
-
* Persist one `dsh-tui` preference (theme or
|
|
182
|
-
* namespace. The namespace is `applies: 'live'`, so the
|
|
183
|
-
* through the registration's watch hook) hot-applies the
|
|
184
|
-
* running TUI. Best-effort: a deployment without a settings
|
|
185
|
-
* the failure; a failed write returns its error message for
|
|
186
|
-
* surface. A concurrent writer moving the namespace rejects
|
|
187
|
-
* `SettingsConflictError` — retried once against a fresh revision; a
|
|
188
|
-
* conflict surfaces a friendly message instead of the raw error.
|
|
265
|
+
* Persist one `dsh-tui` preference (theme, panelHeight, or a subagent limit)
|
|
266
|
+
* to the settings namespace. The namespace is `applies: 'live'`, so the
|
|
267
|
+
* commit (observed through the registration's watch hook) hot-applies the
|
|
268
|
+
* change to the running TUI. Best-effort: a deployment without a settings
|
|
269
|
+
* provider reports the failure; a failed write returns its error message for
|
|
270
|
+
* the caller to surface. A concurrent writer moving the namespace rejects
|
|
271
|
+
* with `SettingsConflictError` — retried once against a fresh revision; a
|
|
272
|
+
* second conflict surfaces a friendly message instead of the raw error.
|
|
189
273
|
* @returns undefined on success, the failure message otherwise.
|
|
190
274
|
*/
|
|
191
275
|
async function writeDshTuiPreference(ctx, key, value) {
|
|
@@ -220,4 +304,44 @@ async function writeDshTuiPreference(ctx, key, value) {
|
|
|
220
304
|
export async function writeThemePreference(ctx, pref) {
|
|
221
305
|
return writeDshTuiPreference(ctx, 'theme', pref);
|
|
222
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Read the currently resolved subagent limits, synchronously. Unlike the
|
|
309
|
+
* startup-snapshot readers, this does not wait for the namespace registration
|
|
310
|
+
* — it describes whatever the settings service exposes right now, so every
|
|
311
|
+
* policy decision (the guard at each spawn, `onTurnCount` at each child turn)
|
|
312
|
+
* reflects the latest committed value without a watcher. Missing settings
|
|
313
|
+
* service or namespace, or a non-integer/negative field, degrades to the
|
|
314
|
+
* defaults — a settings-less deployment keeps the documented caps.
|
|
315
|
+
*/
|
|
316
|
+
export function readSubagentLimits(ctx) {
|
|
317
|
+
const settings = ctx.get('settings');
|
|
318
|
+
if (settings === undefined)
|
|
319
|
+
return { ...DEFAULT_SUBAGENT_LIMITS };
|
|
320
|
+
// The descriptor's `value` is the whole resolved section
|
|
321
|
+
// (`{ theme: ..., panelHeight: ..., maxAgents: ..., maxRounds: ...,
|
|
322
|
+
// disableSubagent: ... }`) — narrow the unknown to the observed fields.
|
|
323
|
+
const section = settings
|
|
324
|
+
.describe()
|
|
325
|
+
.find((descriptor) => descriptor.ns === THEME_SETTINGS_NAMESPACE)?.value;
|
|
326
|
+
const natural = (value, fallback) => typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : fallback;
|
|
327
|
+
return {
|
|
328
|
+
maxAgents: natural(section?.maxAgents, DEFAULT_SUBAGENT_LIMITS.maxAgents),
|
|
329
|
+
maxRounds: natural(section?.maxRounds, DEFAULT_SUBAGENT_LIMITS.maxRounds),
|
|
330
|
+
disableSubagent: typeof section?.disableSubagent === 'boolean'
|
|
331
|
+
? section.disableSubagent
|
|
332
|
+
: DEFAULT_SUBAGENT_LIMITS.disableSubagent,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Persist one subagent policy knob (maxAgents, maxRounds, or disableSubagent)
|
|
337
|
+
* to the `dsh-tui` settings namespace. The namespace is `applies: 'live'`, so
|
|
338
|
+
* the commit hot-applies without a restart — the policy reads
|
|
339
|
+
* `readSubagentLimits` at the next decision point. Never throws: a deployment
|
|
340
|
+
* without the settings provider, or an unregistered namespace, surfaces a
|
|
341
|
+
* failure message for the caller.
|
|
342
|
+
* @returns undefined on success, the failure message otherwise.
|
|
343
|
+
*/
|
|
344
|
+
export async function writeSubagentLimit(ctx, key, value) {
|
|
345
|
+
return writeDshTuiPreference(ctx, key, value);
|
|
346
|
+
}
|
|
223
347
|
//# sourceMappingURL=theme-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-settings.js","sourceRoot":"","sources":["../src/theme-settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme-settings.js","sourceRoot":"","sources":["../src/theme-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAIlB,MAAM,2BAA2B,CAAA;AAClC,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAoB,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAA;AAGtE,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAsB,iBAAiB,CAAC,SAAS,CAAC,CAAA;AAkBvF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmB,MAAM,CAAC,MAAM,CAAC;IACnE,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,IAAI;CACtB,CAAC,CAAA;AAEF,gDAAgD;AAChD,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC;SACL,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAChC,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6CAA6C,CAAC;IAC7D,WAAW,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9B,OAAO,CAAC,oBAAoB,CAAC;SAC7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IACpE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,uBAAuB,EAAE,CAAA;IACjE,yDAAyD;IACzD,oEAAoE;IACpE,wEAAwE;IACxE,MAAM,OAAO,GAAG,QAAQ;SACrB,QAAQ,EAAE;SACV,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,wBAAwB,CAAC,EAAE,KAExD,CAAA;IACb,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAU,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;IACvF,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,uBAAuB,CAAC,SAAS,CAAC;QACzE,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,uBAAuB,CAAC,SAAS,CAAC;QACzE,eAAe,EAAE,OAAO,OAAO,EAAE,eAAe,KAAK,SAAS;YAC5D,CAAC,CAAC,OAAO,CAAC,eAAe;YACzB,CAAC,CAAC,uBAAuB,CAAC,eAAe;KAC5C,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAY,EACZ,GAAkD,EAClD,KAAuB;IAEvB,OAAO,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAC/C,CAAC"}
|
package/lib/tui.d.ts
CHANGED
|
@@ -20,12 +20,24 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { Container, type AutocompleteProvider, type TUI } from '@earendil-works/pi-tui';
|
|
22
22
|
import { CwdBorderEditor } from './editor.ts';
|
|
23
|
+
import { type KeyAction, type KeyBindings } from './keymap.ts';
|
|
23
24
|
import { type ThemePreference, type TuiTheme } from './theme/index.ts';
|
|
24
25
|
export interface StartTuiOptions {
|
|
25
26
|
/** Submit handler for the editor. Defaults to a local echo (smoke-test mode). */
|
|
26
27
|
onSubmit?: (text: string) => void;
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Executes an app-level key action (see keymap.ts for the pi-aligned
|
|
30
|
+
* interrupt chain: double-Esc stop, windowed Ctrl+C, empty-editor Ctrl+D
|
|
31
|
+
* quit). Absent (smoke-test mode): Ctrl+C family and Ctrl+D quit fall back
|
|
32
|
+
* to a plain exit(130); interrupt-arm/arm-stop/double are no-ops.
|
|
33
|
+
*/
|
|
34
|
+
onKeyAction?: (action: KeyAction) => void;
|
|
35
|
+
/** Whether the agent is mid-turn; feeds the Esc/Ctrl+C decision. Defaults to false. */
|
|
36
|
+
isRunning?: () => boolean;
|
|
37
|
+
/** Live running-subagent count; feeds the Ctrl+G viewer decision. Defaults to 0. */
|
|
38
|
+
getRunningAgents?: () => number;
|
|
39
|
+
/** User keybindings overrides (`~/.dsh/keybindings.json`); partial merge. */
|
|
40
|
+
keyBindings?: Partial<KeyBindings>;
|
|
29
41
|
/** Persisted theme preference; 'auto' falls back to terminal detection. */
|
|
30
42
|
themePreference?: ThemePreference;
|
|
31
43
|
}
|
|
@@ -57,13 +69,13 @@ export interface TuiHandle {
|
|
|
57
69
|
*/
|
|
58
70
|
readonly theme: TuiTheme;
|
|
59
71
|
/**
|
|
60
|
-
* Hot-swap the theme bundle: repaints the
|
|
61
|
-
* and updates every subsequent `theme` read.
|
|
62
|
-
* TranscriptRenderer's job (`setTheme`), and
|
|
63
|
-
* lines are the LiveWidgets' job
|
|
64
|
-
*
|
|
65
|
-
* everything at once. No-op when
|
|
66
|
-
* singletons).
|
|
72
|
+
* Hot-swap the theme bundle: repaints the canvas background, the editor
|
|
73
|
+
* border and the placeholder, and updates every subsequent `theme` read.
|
|
74
|
+
* Transcript repainting is the TranscriptRenderer's job (`setTheme`), and
|
|
75
|
+
* the last-request / running-agent lines are the LiveWidgets' job
|
|
76
|
+
* (`setTheme`) — both owned by the caller; call them before `applyTheme`
|
|
77
|
+
* so the one throttled render frame paints everything at once. No-op when
|
|
78
|
+
* the bundle is unchanged (themes are module singletons).
|
|
67
79
|
*/
|
|
68
80
|
applyTheme(theme: TuiTheme): void;
|
|
69
81
|
/** Autocomplete provider for the editor; re-applied across editor rebuilds. */
|
|
@@ -72,5 +84,7 @@ export interface TuiHandle {
|
|
|
72
84
|
setEditorBranchProvider(provider: () => string | undefined): void;
|
|
73
85
|
/** Live permission-preset display-name source for the editor; re-applied across editor rebuilds. */
|
|
74
86
|
setEditorPermissionProvider(provider: () => string | undefined): void;
|
|
87
|
+
/** Swap the user keybindings live (`/hotkeys` writes → apply immediately). */
|
|
88
|
+
setKeyBindings(bindings: Partial<KeyBindings>): void;
|
|
75
89
|
}
|
|
76
90
|
export declare function startTui(options?: StartTuiOptions): TuiHandle;
|