tmux-ide 2.9.20 → 2.9.22
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/bin/cli.js +16998 -4283
- package/package.json +3 -2
- package/packages/contracts/src/command-catalog.ts +116 -0
- package/packages/contracts/src/commands.ts +5 -4
- package/packages/contracts/src/daemon-events.ts +2 -1
- package/packages/contracts/src/index.ts +3 -0
- package/packages/contracts/src/pane-reader.ts +121 -0
- package/packages/contracts/src/pane-stream.ts +18 -0
- package/packages/contracts/src/plain-text.ts +61 -0
- package/packages/contracts/src/visual-theme-presets.ts +58 -2
- package/packages/daemon/dist/command-center/command-catalog-routes.js +78 -0
- package/packages/daemon/dist/command-center/plugin-routes.js +84 -0
- package/packages/daemon/dist/command-center/server.js +13 -0
- package/packages/daemon/dist/command-center/tmux-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +6 -0
- package/packages/daemon/dist/doctor.js +106 -43
- package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +39 -1
- package/packages/daemon/dist/lib/headless-daemon.js +1 -0
- package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
- package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
- package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
- package/packages/daemon/dist/lib/tmux-pane-reader.js +105 -0
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +9 -0
- package/packages/daemon/dist/lib/worktree.js +18 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/open-browser.js +26 -12
- package/packages/daemon/dist/open-reader.js +84 -0
- package/packages/daemon/dist/plugins/action-catalog.js +129 -0
- package/packages/daemon/dist/plugins/action-cli.js +212 -0
- package/packages/daemon/dist/plugins/api-table.js +303 -0
- package/packages/daemon/dist/plugins/cli.js +556 -0
- package/packages/daemon/dist/plugins/consent.js +107 -0
- package/packages/daemon/dist/plugins/daemon-plugins.js +124 -0
- package/packages/daemon/dist/plugins/discovery.js +142 -0
- package/packages/daemon/dist/plugins/examples/worktree-tasks.js +115 -0
- package/packages/daemon/dist/plugins/exec-sandbox.js +202 -0
- package/packages/daemon/dist/plugins/host/actions-prelude.js +279 -0
- package/packages/daemon/dist/plugins/host/entry.js +4 -0
- package/packages/daemon/dist/plugins/host/host-api-prelude.js +232 -0
- package/packages/daemon/dist/plugins/host/lua-state.js +493 -0
- package/packages/daemon/dist/plugins/host/main.js +322 -0
- package/packages/daemon/dist/plugins/host/sandbox.js +299 -0
- package/packages/daemon/dist/plugins/host-calls.js +279 -0
- package/packages/daemon/dist/plugins/manifest.js +69 -0
- package/packages/daemon/dist/plugins/plugin-exec.js +261 -0
- package/packages/daemon/dist/plugins/plugin-log.js +54 -0
- package/packages/daemon/dist/plugins/plugin-store.js +74 -0
- package/packages/daemon/dist/plugins/protocol.js +252 -0
- package/packages/daemon/dist/plugins/safe-files.js +97 -0
- package/packages/daemon/dist/plugins/supervisor.js +790 -0
- package/packages/daemon/dist/plugins/worktree-calls.js +154 -0
- package/packages/daemon/dist/restore.js +57 -40
- package/packages/daemon/dist/terminal/mirror/session-channel.js +4 -1
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +12 -3
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +7 -2
- package/packages/daemon/dist/tmux-upgrade/cli.js +106 -0
- package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
- package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
- package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +62 -5
- package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +30 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-plugin-commands.js +152 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-plugin-form.js +251 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
- package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +14 -0
- package/packages/daemon/dist/tui/mirror/workspace/palette-list-layout.js +5 -0
- package/packages/daemon/src/command-center/command-catalog-routes.ts +116 -0
- package/packages/daemon/src/command-center/plugin-routes.ts +110 -0
- package/packages/daemon/src/command-center/server.ts +15 -0
- package/packages/daemon/src/command-center/tmux-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +6 -0
- package/packages/daemon/src/doctor.ts +118 -45
- package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +59 -0
- package/packages/daemon/src/lib/headless-daemon.ts +1 -0
- package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
- package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
- package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
- package/packages/daemon/src/lib/tmux-pane-reader.ts +144 -0
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +9 -0
- package/packages/daemon/src/lib/worktree.ts +16 -0
- package/packages/daemon/src/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/action-catalog.ts +141 -0
- package/packages/daemon/src/plugins/action-cli.ts +248 -0
- package/packages/daemon/src/plugins/api-table.ts +346 -0
- package/packages/daemon/src/plugins/cli.ts +630 -0
- package/packages/daemon/src/plugins/consent.ts +125 -0
- package/packages/daemon/src/plugins/daemon-plugins.ts +172 -0
- package/packages/daemon/src/plugins/discovery.ts +176 -0
- package/packages/daemon/src/plugins/examples/worktree-tasks.ts +120 -0
- package/packages/daemon/src/plugins/exec-sandbox.ts +264 -0
- package/packages/daemon/src/plugins/host/actions-prelude.ts +280 -0
- package/packages/daemon/src/plugins/host/entry.ts +5 -0
- package/packages/daemon/src/plugins/host/host-api-prelude.ts +233 -0
- package/packages/daemon/src/plugins/host/lua-state.ts +557 -0
- package/packages/daemon/src/plugins/host/main.ts +359 -0
- package/packages/daemon/src/plugins/host/sandbox.ts +301 -0
- package/packages/daemon/src/plugins/host-calls.ts +343 -0
- package/packages/daemon/src/plugins/manifest.ts +74 -0
- package/packages/daemon/src/plugins/plugin-exec.ts +326 -0
- package/packages/daemon/src/plugins/plugin-log.ts +63 -0
- package/packages/daemon/src/plugins/plugin-store.ts +80 -0
- package/packages/daemon/src/plugins/protocol.ts +275 -0
- package/packages/daemon/src/plugins/safe-files.ts +105 -0
- package/packages/daemon/src/plugins/supervisor.ts +954 -0
- package/packages/daemon/src/plugins/worktree-calls.ts +183 -0
- package/packages/daemon/src/restore.ts +80 -44
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +6 -1
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +15 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
- package/packages/daemon/src/tmux-upgrade/cli.ts +118 -0
- package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
- package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
- package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
- package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
- package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +90 -6
- package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
- package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +42 -2
- package/packages/daemon/src/tui/mirror/runtime/application-palette-preview.tsx +7 -1
- package/packages/daemon/src/tui/mirror/runtime/application-plugin-commands.ts +229 -0
- package/packages/daemon/src/tui/mirror/runtime/application-plugin-form.ts +312 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
- package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +44 -2
- package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
- package/packages/tmux-bridge/src/runner.ts +3 -1
|
@@ -5,15 +5,29 @@ import { createHomeAgentSelectionOwner } from "./application-home-agent-selectio
|
|
|
5
5
|
import { createApplicationHomeAgentNavigator } from "./application-home-agent-navigation.js";
|
|
6
6
|
import { applicationGenerationNavigationKey, createApplicationAgentNavigator, } from "./application-generation-starter.js";
|
|
7
7
|
import { createApplicationPaletteCommandOwner } from "./application-palette-command-owner.js";
|
|
8
|
+
import { createApplicationPluginForm, pluginPaletteContext } from "./application-plugin-form.js";
|
|
8
9
|
import { createApplicationPaneRenameOwner } from "./application-pane-rename-owner.js";
|
|
9
10
|
import { applicationPaletteCommands, applicationPaletteCommandSource, } from "./application-palette-input.js";
|
|
10
11
|
/** Observe the existing client, never open a second shell or poll for readiness. */
|
|
11
12
|
export function waitForHomeAgentSemantic(generation, expectedKey, signal) {
|
|
13
|
+
const client = generation()?.client;
|
|
14
|
+
return waitForHomeAgentGeneration(generation, expectedKey, () => Boolean(client?.getSnapshot().semantic), signal);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Waits, bounded, until the attached generation `expectedKey` lists an agent
|
|
18
|
+
* (`listed`), or until the generation changes, the bound passes or `signal`
|
|
19
|
+
* aborts (#764: Home can list an agent before the attached session does).
|
|
20
|
+
*/
|
|
21
|
+
export function waitForHomeAgentListed(generation, expectedKey, listed, signal) {
|
|
22
|
+
return waitForHomeAgentGeneration(generation, expectedKey, listed, signal);
|
|
23
|
+
}
|
|
24
|
+
/** The bound both waits share: the cold path's own 5 s. */
|
|
25
|
+
export const HOME_AGENT_WAIT_MS = 5_000;
|
|
26
|
+
function waitForHomeAgentGeneration(generation, expectedKey, satisfied, signal) {
|
|
12
27
|
const client = generation()?.client;
|
|
13
28
|
if (!client || signal.aborted)
|
|
14
29
|
return Promise.resolve(false);
|
|
15
|
-
const ready = () => applicationGenerationNavigationKey(generation()) !== expectedKey ||
|
|
16
|
-
Boolean(client.getSnapshot().semantic);
|
|
30
|
+
const ready = () => applicationGenerationNavigationKey(generation()) !== expectedKey || satisfied();
|
|
17
31
|
// A changed generation is settled, not admitted: the navigator revalidates it.
|
|
18
32
|
if (ready())
|
|
19
33
|
return Promise.resolve(true);
|
|
@@ -35,7 +49,7 @@ export function waitForHomeAgentSemantic(generation, expectedKey, signal) {
|
|
|
35
49
|
if (ready())
|
|
36
50
|
finish(true);
|
|
37
51
|
};
|
|
38
|
-
const timeout = setTimeout(() => finish(false),
|
|
52
|
+
const timeout = setTimeout(() => finish(false), HOME_AGENT_WAIT_MS);
|
|
39
53
|
signal.addEventListener("abort", abort, { once: true });
|
|
40
54
|
// subscribe may synchronously deliver its current projection.
|
|
41
55
|
for (const scope of ["semantic", "lifecycle"]) {
|
|
@@ -53,6 +67,17 @@ export function waitForHomeAgentSemantic(generation, expectedKey, signal) {
|
|
|
53
67
|
check();
|
|
54
68
|
});
|
|
55
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* While an agent opens, it owns the keyboard: other keys are ignored and Esc
|
|
72
|
+
* cancels the open (#764: the warm wait can last 5 s). True when it owns `name`.
|
|
73
|
+
*/
|
|
74
|
+
export function agentOpeningOwnsKey(name, opener) {
|
|
75
|
+
if (!opener.opening())
|
|
76
|
+
return false;
|
|
77
|
+
if (name === "escape")
|
|
78
|
+
opener.cancel();
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
56
81
|
/** Resident feature composition: observation, selection, and navigation have separate owners. */
|
|
57
82
|
export function createApplicationHomeAgentsOwner(options) {
|
|
58
83
|
const observer = options.observer ?? createApplicationHomeAgentObserver();
|
|
@@ -85,10 +110,11 @@ export function createApplicationHomeAgentsOwner(options) {
|
|
|
85
110
|
};
|
|
86
111
|
},
|
|
87
112
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(options.generation, key, signal),
|
|
113
|
+
waitForAgent: (key, listed, signal) => waitForHomeAgentListed(options.generation, key, listed, signal),
|
|
88
114
|
startGeneration: options.startGeneration,
|
|
89
115
|
// The existing pane input router is source-neutral. Session/surface intents
|
|
90
116
|
// above retain keyboard vs pointer provenance without inventing a second router.
|
|
91
|
-
selectPane: (paneId) => options.selectPane(paneId),
|
|
117
|
+
selectPane: (paneId, _source, admission) => admission ? options.selectPane(paneId, admission) : options.selectPane(paneId),
|
|
92
118
|
showTerminals: options.showTerminals,
|
|
93
119
|
setNote: options.setNote,
|
|
94
120
|
});
|
|
@@ -148,7 +174,12 @@ export function createApplicationHomeAgentsOwner(options) {
|
|
|
148
174
|
observer.dispose();
|
|
149
175
|
selection.dispose();
|
|
150
176
|
});
|
|
151
|
-
return {
|
|
177
|
+
return {
|
|
178
|
+
presentation,
|
|
179
|
+
opening,
|
|
180
|
+
cancel,
|
|
181
|
+
ownsKey: (name) => agentOpeningOwnsKey(name, { opening, cancel }),
|
|
182
|
+
};
|
|
152
183
|
}
|
|
153
184
|
/** Compose Home navigation with competing chrome intents; physical input stays in the root. */
|
|
154
185
|
export function createApplicationHomeNavigationOwner(options) {
|
|
@@ -200,7 +231,29 @@ export function createApplicationHomeNavigationOwner(options) {
|
|
|
200
231
|
setNote: options.setNote,
|
|
201
232
|
observer: options.observer,
|
|
202
233
|
});
|
|
234
|
+
// Plugin commands come from the local daemon's command catalog; a command
|
|
235
|
+
// with parameters opens a step-by-step form inside the palette.
|
|
236
|
+
const pluginCommands = options.pluginCommands;
|
|
237
|
+
let paletteOwner = null;
|
|
238
|
+
const pluginForm = pluginCommands &&
|
|
239
|
+
createApplicationPluginForm({
|
|
240
|
+
service: pluginCommands,
|
|
241
|
+
context: () => pluginPaletteContext(options.sessionOwner()?.sessionName() ?? null, options.focusedPane()),
|
|
242
|
+
query: () => paletteOwner?.query() ?? "",
|
|
243
|
+
setNote: options.setNote,
|
|
244
|
+
close: () => paletteOwner?.setOpen(false, "keyboard"),
|
|
245
|
+
stepChanged: () => paletteOwner?.resetForStep(),
|
|
246
|
+
});
|
|
203
247
|
const paletteCommands = createApplicationPaletteCommandOwner({
|
|
248
|
+
...(pluginCommands && pluginForm
|
|
249
|
+
? {
|
|
250
|
+
plugins: {
|
|
251
|
+
form: pluginForm,
|
|
252
|
+
refresh: () => void pluginCommands.refresh(),
|
|
253
|
+
watch: () => pluginCommands.watch(),
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
: {}),
|
|
204
257
|
commands: () => [
|
|
205
258
|
...(options.fleetCommands
|
|
206
259
|
? [
|
|
@@ -215,10 +268,13 @@ export function createApplicationHomeNavigationOwner(options) {
|
|
|
215
268
|
: "hide-sidebar",
|
|
216
269
|
]
|
|
217
270
|
: []),
|
|
271
|
+
...(pluginCommands?.commands() ?? []),
|
|
218
272
|
],
|
|
219
273
|
isOpen: () => Boolean(options.shell().semantic?.focus.palette.open ?? options.shell().localPaletteOpen),
|
|
220
274
|
targetKey: () => `${applicationGenerationNavigationKey(options.sessionOwner()?.snapshot() ?? null)}:${options.focusedPane()}`,
|
|
221
275
|
disabledReason: (command) => {
|
|
276
|
+
if (typeof command === "object" && command.kind === "plugin-form")
|
|
277
|
+
return command.disabledReason ?? null;
|
|
222
278
|
if (typeof command === "object" && command.fleet?.disabled)
|
|
223
279
|
return "Machine or session unavailable";
|
|
224
280
|
if (typeof command === "object" ||
|
|
@@ -262,6 +318,7 @@ export function createApplicationHomeNavigationOwner(options) {
|
|
|
262
318
|
openSession: (name, source) => options.startGeneration(name, false, source),
|
|
263
319
|
onNavigationIntent: homeAgents.cancel,
|
|
264
320
|
});
|
|
321
|
+
paletteOwner = paletteCommands;
|
|
265
322
|
const paletteCommandList = paletteCommands.commands;
|
|
266
323
|
return {
|
|
267
324
|
homeAgents: options.fleetHome ? { ...homeAgents, presentation: options.fleetHome } : homeAgents,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createApplicationPluginCommands } from "./application-plugin-commands.js";
|
|
1
2
|
import { createEffect } from "solid-js";
|
|
2
3
|
import { createApplicationHomeFleetOwner } from "./application-home-fleet.js";
|
|
3
4
|
import { createApplicationHomeNavigationOwner } from "./application-home-agents-owner.js";
|
|
@@ -33,6 +34,7 @@ export function createApplicationHomeExperience(options) {
|
|
|
33
34
|
fleetCommands: machines.paletteCommands,
|
|
34
35
|
openFleet: machines.openPalette,
|
|
35
36
|
openSessions: () => machines.showSwitcher(false),
|
|
37
|
+
pluginCommands: createApplicationPluginCommands(),
|
|
36
38
|
});
|
|
37
39
|
const tour = createLazyApplicationGuidedTour({
|
|
38
40
|
...options,
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { retainsAgentControl } from "./application-retained-agent.js";
|
|
2
2
|
import { createApplicationHomeAgentNavigator, } from "./application-home-agent-navigation.js";
|
|
3
3
|
import { applicationGenerationNavigationKey } from "./application-generation-starter.js";
|
|
4
|
-
import { waitForHomeAgentSemantic } from "./application-home-agents-owner.js";
|
|
4
|
+
import { agentOpeningOwnsKey, waitForHomeAgentListed, waitForHomeAgentSemantic, } from "./application-home-agents-owner.js";
|
|
5
5
|
/** Machine identity fences the existing exact-agent admission owner. No independent input path. */
|
|
6
6
|
export function createApplicationMachineAgentNavigator(options) {
|
|
7
7
|
let current = null;
|
|
8
8
|
let disposed = false;
|
|
9
9
|
let opening = false;
|
|
10
10
|
let request = 0;
|
|
11
|
+
const cancel = () => {
|
|
12
|
+
request++;
|
|
13
|
+
opening = false;
|
|
14
|
+
current?.cancel();
|
|
15
|
+
};
|
|
11
16
|
return {
|
|
12
17
|
open(machineId, target, source = "mouse") {
|
|
13
18
|
current?.dispose();
|
|
@@ -23,7 +28,7 @@ export function createApplicationMachineAgentNavigator(options) {
|
|
|
23
28
|
retainsAgentControl(generation(), target)) {
|
|
24
29
|
// Reserve before the next key; the terminal controller waits for a fresh
|
|
25
30
|
// coherent runtime and remains the only owner of physical input.
|
|
26
|
-
options.selectPane(target.paneId
|
|
31
|
+
options.selectPane(target.paneId);
|
|
27
32
|
options.showTerminals(source);
|
|
28
33
|
options.setNote(null);
|
|
29
34
|
opening = false;
|
|
@@ -47,8 +52,9 @@ export function createApplicationMachineAgentNavigator(options) {
|
|
|
47
52
|
};
|
|
48
53
|
},
|
|
49
54
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(generation, key, signal),
|
|
55
|
+
waitForAgent: (key, listed, signal) => waitForHomeAgentListed(generation, key, listed, signal),
|
|
50
56
|
startGeneration: (session, prepared, origin, focus, admission) => options.startGeneration(session, prepared, origin, focus, () => selected() && options.isCurrentTarget(machineId, target) && (admission?.() ?? true)),
|
|
51
|
-
selectPane: options.selectPane,
|
|
57
|
+
selectPane: (paneId, _source, admission) => admission ? options.selectPane(paneId, admission) : options.selectPane(paneId),
|
|
52
58
|
showTerminals: options.showTerminals,
|
|
53
59
|
setNote: options.setNote,
|
|
54
60
|
});
|
|
@@ -58,11 +64,9 @@ export function createApplicationMachineAgentNavigator(options) {
|
|
|
58
64
|
});
|
|
59
65
|
},
|
|
60
66
|
opening: () => opening,
|
|
61
|
-
cancel
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
current?.cancel();
|
|
65
|
-
},
|
|
67
|
+
cancel,
|
|
68
|
+
/** Esc cancels an open in progress; other keys are ignored meanwhile. */
|
|
69
|
+
ownsKey: (name) => agentOpeningOwnsKey(name, { opening: () => opening, cancel }),
|
|
66
70
|
dispose() {
|
|
67
71
|
disposed = true;
|
|
68
72
|
request++;
|
|
@@ -6,9 +6,12 @@ export function createApplicationPaletteCommandOwner(options) {
|
|
|
6
6
|
const [closeArmed, setCloseArmed] = createSignal(false);
|
|
7
7
|
const [busy, setBusy] = createSignal(false);
|
|
8
8
|
let armedTarget;
|
|
9
|
+
let stopWatch = null;
|
|
9
10
|
let openRevision = 0;
|
|
11
|
+
const baseCommands = options.commands ?? (() => applicationPaletteCommands(null));
|
|
10
12
|
const search = createApplicationPaletteSearchOwner({
|
|
11
|
-
|
|
13
|
+
// While a plugin form is open the list is the current step's entries.
|
|
14
|
+
commands: () => options.plugins?.form.active() ? options.plugins.form.entries() : baseCommands(),
|
|
12
15
|
open: options.isOpen ?? (() => false),
|
|
13
16
|
activate: (command, source) => activate(command, source),
|
|
14
17
|
close: () => setOpen(false, "keyboard"),
|
|
@@ -18,8 +21,14 @@ export function createApplicationPaletteCommandOwner(options) {
|
|
|
18
21
|
setReferencePage(undefined);
|
|
19
22
|
openRevision += 1;
|
|
20
23
|
setCloseArmed(false);
|
|
21
|
-
|
|
24
|
+
options.plugins?.form.cancel();
|
|
25
|
+
stopWatch?.();
|
|
26
|
+
stopWatch = null;
|
|
27
|
+
if (open) {
|
|
28
|
+
options.plugins?.refresh();
|
|
29
|
+
stopWatch = options.plugins?.watch?.() ?? null;
|
|
22
30
|
search.reset(options.activeSurface() === "home" ? 0 : 1);
|
|
31
|
+
}
|
|
23
32
|
void options.binding
|
|
24
33
|
.setPaletteOpen(open, options.commandSource(source, "command-palette"))
|
|
25
34
|
.catch(() => options.setNote("Commands could not be updated. Try again."));
|
|
@@ -32,6 +41,22 @@ export function createApplicationPaletteCommandOwner(options) {
|
|
|
32
41
|
setReferencePage(command === "help" ? "help" : command === "shortcuts" ? "shortcuts" : "changes");
|
|
33
42
|
return;
|
|
34
43
|
}
|
|
44
|
+
if (typeof command === "object" && command.kind === "plugin-form") {
|
|
45
|
+
if (command.disabledReason) {
|
|
46
|
+
options.setNote(command.disabledReason);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
options.plugins?.form.choose(command);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (typeof command === "object" && command.kind === "plugin-command") {
|
|
53
|
+
if (!options.plugins) {
|
|
54
|
+
options.setNote("Plugin commands are unavailable.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
options.plugins.form.start(command);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
35
60
|
if (command === "switch-session") {
|
|
36
61
|
if (!options.openSessions) {
|
|
37
62
|
options.setNote("Session switching is unavailable.");
|
|
@@ -150,6 +175,9 @@ export function createApplicationPaletteCommandOwner(options) {
|
|
|
150
175
|
};
|
|
151
176
|
return {
|
|
152
177
|
...search,
|
|
178
|
+
keyboardHint: () => options.plugins?.form.active() ? options.plugins.form.hint() : search.keyboardHint(),
|
|
179
|
+
/** Clear the search line and selection for a new form step. */
|
|
180
|
+
resetForStep: () => search.reset(0),
|
|
153
181
|
referencePage,
|
|
154
182
|
setReferencePage,
|
|
155
183
|
busy,
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin commands for the TUI palette: the plugin half of the daemon's
|
|
3
|
+
* command catalog, plus invoking a command and asking for a parameter's
|
|
4
|
+
* choices. Always the LOCAL canonical daemon, like the fleet preferences.
|
|
5
|
+
*
|
|
6
|
+
* The catalog is fetched when the palette opens, so a plugin reload shows up
|
|
7
|
+
* the next time the palette is opened.
|
|
8
|
+
*/
|
|
9
|
+
import { CommandCatalogResourceSchemaZ, CommandInvokeResultSchemaZ, CommandParamOptionsResultSchemaZ, } from "@tmux-ide/contracts";
|
|
10
|
+
import { createSignal } from "solid-js";
|
|
11
|
+
import WebSocket from "ws";
|
|
12
|
+
import { canonicalDaemonUrl, readCanonicalDaemonInfo, } from "../../../lib/canonical-daemon.js";
|
|
13
|
+
const defaultTransport = {
|
|
14
|
+
daemon: readCanonicalDaemonInfo,
|
|
15
|
+
fetch: (...args) => fetch(...args),
|
|
16
|
+
socket: (url, ownerToken) => new WebSocket(url, {
|
|
17
|
+
headers: { Authorization: `Bearer ${ownerToken}` },
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async function request(transport, method, path, body, signal) {
|
|
21
|
+
const daemon = transport.daemon();
|
|
22
|
+
if (!daemon?.authToken)
|
|
23
|
+
throw new Error("No local tmux-ide daemon is running.");
|
|
24
|
+
const response = await transport.fetch(canonicalDaemonUrl("http", daemon.bindHostname, daemon.port) + path, {
|
|
25
|
+
method,
|
|
26
|
+
redirect: "error",
|
|
27
|
+
signal,
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${daemon.authToken}`,
|
|
30
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
31
|
+
},
|
|
32
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
33
|
+
});
|
|
34
|
+
const payload = await response.json().catch(() => null);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const message = payload && typeof payload === "object" && "error" in payload
|
|
37
|
+
? String(payload.error)
|
|
38
|
+
: `The daemon answered ${response.status}.`;
|
|
39
|
+
throw new Error(message);
|
|
40
|
+
}
|
|
41
|
+
return payload;
|
|
42
|
+
}
|
|
43
|
+
export function createApplicationPluginCommands(transport = defaultTransport) {
|
|
44
|
+
const [commands, setCommands] = createSignal([]);
|
|
45
|
+
let inflight = null;
|
|
46
|
+
const refresh = async () => {
|
|
47
|
+
inflight?.abort();
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
inflight = controller;
|
|
50
|
+
try {
|
|
51
|
+
const parsed = CommandCatalogResourceSchemaZ.safeParse(await request(transport, "GET", "/api/resources/command-catalog", undefined, AbortSignal.any([controller.signal, AbortSignal.timeout(3000)])));
|
|
52
|
+
if (!parsed.success || controller.signal.aborted)
|
|
53
|
+
return;
|
|
54
|
+
setCommands(parsed.data.entries.flatMap((entry) => entry.plugin
|
|
55
|
+
? [
|
|
56
|
+
{
|
|
57
|
+
kind: "plugin-command",
|
|
58
|
+
id: entry.descriptor.id,
|
|
59
|
+
label: entry.descriptor.label,
|
|
60
|
+
category: entry.descriptor.category,
|
|
61
|
+
plugin: entry.plugin,
|
|
62
|
+
dangerous: entry.descriptor.dangerous,
|
|
63
|
+
params: entry.params,
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
: []));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// No daemon, or plugins off: the palette simply shows no plugin commands.
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
if (inflight === controller)
|
|
73
|
+
inflight = null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
commands,
|
|
78
|
+
/** Fetch the catalog again; keeps the last list if the daemon is unreachable. */
|
|
79
|
+
refresh,
|
|
80
|
+
/**
|
|
81
|
+
* Follow the daemon's command-catalog invalidations while the palette is
|
|
82
|
+
* open, so a plugin reload shows up without reopening it. Returns a stop
|
|
83
|
+
* function; does nothing without a daemon or a socket.
|
|
84
|
+
*/
|
|
85
|
+
watch() {
|
|
86
|
+
const daemon = transport.daemon();
|
|
87
|
+
if (!daemon?.authToken || !transport.socket)
|
|
88
|
+
return () => { };
|
|
89
|
+
let socket;
|
|
90
|
+
try {
|
|
91
|
+
socket = transport.socket(canonicalDaemonUrl("ws", daemon.bindHostname, daemon.port, "/ws/events?mode=semantic"), daemon.authToken);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return () => { };
|
|
95
|
+
}
|
|
96
|
+
let stopped = false;
|
|
97
|
+
socket.addEventListener("error", () => { });
|
|
98
|
+
socket.addEventListener("open", () => {
|
|
99
|
+
socket.send(JSON.stringify({
|
|
100
|
+
type: "subscribe",
|
|
101
|
+
sessions: [],
|
|
102
|
+
interests: [{ resource: "command-catalog", workspaceName: null }],
|
|
103
|
+
legacyEvents: false,
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
socket.addEventListener("message", (event) => {
|
|
107
|
+
if (stopped || (typeof event.data !== "string" && !Buffer.isBuffer(event.data)))
|
|
108
|
+
return;
|
|
109
|
+
let frame;
|
|
110
|
+
try {
|
|
111
|
+
frame = JSON.parse(String(event.data));
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (frame &&
|
|
117
|
+
typeof frame === "object" &&
|
|
118
|
+
frame.type === "resource.changed" &&
|
|
119
|
+
frame.resource === "command-catalog")
|
|
120
|
+
void refresh();
|
|
121
|
+
});
|
|
122
|
+
return () => {
|
|
123
|
+
if (stopped)
|
|
124
|
+
return;
|
|
125
|
+
stopped = true;
|
|
126
|
+
socket.close(1000, "palette closed");
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
async invoke(id, args, context, confirmed) {
|
|
130
|
+
try {
|
|
131
|
+
const parsed = CommandInvokeResultSchemaZ.safeParse(await request(transport, "POST", "/api/v2/commands/invoke", { id, args, context, ...(confirmed ? { confirmed: true } : {}) }, AbortSignal.timeout(60_000)));
|
|
132
|
+
return parsed.success
|
|
133
|
+
? parsed.data
|
|
134
|
+
: { ok: false, error: "The daemon sent an unexpected answer." };
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
return { ok: false, error: error.message };
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
async paramOptions(id, param, context) {
|
|
141
|
+
try {
|
|
142
|
+
const parsed = CommandParamOptionsResultSchemaZ.safeParse(await request(transport, "POST", "/api/v2/commands/param-options", { id, param, context }, AbortSignal.timeout(30_000)));
|
|
143
|
+
return parsed.success
|
|
144
|
+
? parsed.data
|
|
145
|
+
: { ok: false, error: "The daemon sent an unexpected answer." };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return { ok: false, error: error.message };
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The step-by-step form a plugin command with parameters opens inside the
|
|
3
|
+
* palette. Each step is one parameter: the palette's search line is the
|
|
4
|
+
* input, and its list holds the step's entries (a choice per option, or one
|
|
5
|
+
* "Use …" entry for free text). A dangerous command ends with a confirm step.
|
|
6
|
+
*
|
|
7
|
+
* Arguments are checked again by the plugin; this only collects them.
|
|
8
|
+
*/
|
|
9
|
+
import { terminalSafe, } from "@tmux-ide/contracts";
|
|
10
|
+
import { createSignal } from "solid-js";
|
|
11
|
+
const quote = (value) => (typeof value === "string" ? `“${value}”` : String(value));
|
|
12
|
+
function resultNote(label, result) {
|
|
13
|
+
if (!result.ok)
|
|
14
|
+
return `${label}: ${result.error}`;
|
|
15
|
+
if (typeof result.value === "string" && result.value.trim())
|
|
16
|
+
return `${label}: ${result.value}`;
|
|
17
|
+
return `${label}: done`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The context a palette invocation sends. The TUI's focused pane id is its
|
|
21
|
+
* own mirror id, not the tmux `%N` id plugins pass to ide.exec{context}, so
|
|
22
|
+
* only a real tmux pane id is sent as `pane`.
|
|
23
|
+
*/
|
|
24
|
+
export function pluginPaletteContext(session, focusedPane) {
|
|
25
|
+
const pane = focusedPane && /^%\d{1,9}$/u.test(focusedPane) ? focusedPane : null;
|
|
26
|
+
return {
|
|
27
|
+
source: "palette",
|
|
28
|
+
...(session ? { session } : {}),
|
|
29
|
+
...(pane ? { pane } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function createApplicationPluginForm(options) {
|
|
33
|
+
const [state, setState] = createSignal(null);
|
|
34
|
+
let generation = 0;
|
|
35
|
+
// Notes carry plugin text (labels, results, errors) to the terminal.
|
|
36
|
+
const setNote = (note) => options.setNote(note === null ? null : terminalSafe(note, 500));
|
|
37
|
+
const run = (command, args) => {
|
|
38
|
+
setState(null);
|
|
39
|
+
options.close();
|
|
40
|
+
setNote(`${command.label}…`);
|
|
41
|
+
void options.service
|
|
42
|
+
.invoke(command.id, args, options.context(), command.dangerous)
|
|
43
|
+
.then((result) => setNote(resultNote(command.label, result)));
|
|
44
|
+
};
|
|
45
|
+
const loadOptions = (current, param) => {
|
|
46
|
+
if (!param.dynamicChoices && !param.dynamicDefault)
|
|
47
|
+
return;
|
|
48
|
+
if (current.options[param.name])
|
|
49
|
+
return;
|
|
50
|
+
const marker = current.generation;
|
|
51
|
+
setState({ ...current, options: { ...current.options, [param.name]: { phase: "loading" } } });
|
|
52
|
+
void options.service
|
|
53
|
+
.paramOptions(current.command.id, param.name, options.context())
|
|
54
|
+
.then((result) => {
|
|
55
|
+
const latest = state();
|
|
56
|
+
if (!latest || latest.generation !== marker)
|
|
57
|
+
return;
|
|
58
|
+
setState({
|
|
59
|
+
...latest,
|
|
60
|
+
options: {
|
|
61
|
+
...latest.options,
|
|
62
|
+
[param.name]: result.ok
|
|
63
|
+
? {
|
|
64
|
+
phase: "ready",
|
|
65
|
+
...(result.choices ? { choices: result.choices } : {}),
|
|
66
|
+
...(result.default !== undefined ? { default: result.default } : {}),
|
|
67
|
+
}
|
|
68
|
+
: { phase: "error", error: result.error },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const enterStep = (next) => {
|
|
74
|
+
const { command } = next;
|
|
75
|
+
if (next.step >= command.params.length) {
|
|
76
|
+
// Past the last parameter: confirm a dangerous command, else run it.
|
|
77
|
+
if (command.dangerous && next.step === command.params.length) {
|
|
78
|
+
setState(next);
|
|
79
|
+
options.stepChanged();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
run(command, { ...next.values });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setState(next);
|
|
86
|
+
options.stepChanged();
|
|
87
|
+
loadOptions(next, command.params[next.step]);
|
|
88
|
+
};
|
|
89
|
+
const currentParam = (current) => current.command.params[current.step] ?? null;
|
|
90
|
+
const defaultFor = (current, param) => current.options[param.name]?.default ?? param.default;
|
|
91
|
+
const choicesFor = (current, param) => current.options[param.name]?.choices ?? param.choices ?? [];
|
|
92
|
+
const advance = (current, param, value) => {
|
|
93
|
+
const values = { ...current.values };
|
|
94
|
+
if (value === undefined)
|
|
95
|
+
delete values[param.name];
|
|
96
|
+
else
|
|
97
|
+
values[param.name] = value;
|
|
98
|
+
enterStep({ ...current, step: current.step + 1, values });
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
active: () => state() !== null,
|
|
102
|
+
/**
|
|
103
|
+
* Start a plugin command. One without parameters and not dangerous runs
|
|
104
|
+
* at once; otherwise the palette turns into its form.
|
|
105
|
+
*/
|
|
106
|
+
start(command) {
|
|
107
|
+
generation += 1;
|
|
108
|
+
if (command.params.length === 0 && !command.dangerous) {
|
|
109
|
+
run(command, {});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
enterStep({ command, step: 0, values: {}, options: {}, generation });
|
|
113
|
+
},
|
|
114
|
+
cancel() {
|
|
115
|
+
if (!state())
|
|
116
|
+
return;
|
|
117
|
+
generation += 1;
|
|
118
|
+
setState(null);
|
|
119
|
+
},
|
|
120
|
+
entries() {
|
|
121
|
+
const current = state();
|
|
122
|
+
if (!current)
|
|
123
|
+
return [];
|
|
124
|
+
const param = currentParam(current);
|
|
125
|
+
if (!param) {
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
kind: "plugin-form",
|
|
129
|
+
key: "run",
|
|
130
|
+
label: `Run ${current.command.label}`,
|
|
131
|
+
detail: "This cannot be undone",
|
|
132
|
+
},
|
|
133
|
+
{ kind: "plugin-form", key: "cancel", label: "Cancel", detail: "Do nothing" },
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
const detail = param.description ?? param.label;
|
|
137
|
+
const loaded = current.options[param.name];
|
|
138
|
+
const out = [];
|
|
139
|
+
if (loaded?.phase === "loading") {
|
|
140
|
+
out.push({
|
|
141
|
+
kind: "plugin-form",
|
|
142
|
+
key: "loading",
|
|
143
|
+
label: "Loading choices…",
|
|
144
|
+
detail,
|
|
145
|
+
disabledReason: "Still loading choices",
|
|
146
|
+
});
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
if (loaded?.phase === "error") {
|
|
150
|
+
out.push({
|
|
151
|
+
kind: "plugin-form",
|
|
152
|
+
key: "error",
|
|
153
|
+
label: loaded.error ?? "Choices are unavailable",
|
|
154
|
+
detail,
|
|
155
|
+
disabledReason: "The plugin could not list choices",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const fallback = defaultFor(current, param);
|
|
159
|
+
if (param.type === "choice") {
|
|
160
|
+
for (const choice of choicesFor(current, param)) {
|
|
161
|
+
out.push({
|
|
162
|
+
kind: "plugin-form",
|
|
163
|
+
key: `choice:${choice.value}`,
|
|
164
|
+
label: choice.value === fallback ? `${choice.label} (default)` : choice.label,
|
|
165
|
+
detail,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (param.type === "boolean") {
|
|
170
|
+
for (const value of [true, false]) {
|
|
171
|
+
out.push({
|
|
172
|
+
kind: "plugin-form",
|
|
173
|
+
key: `bool:${value}`,
|
|
174
|
+
label: `${value ? "Yes" : "No"}${fallback === value ? " (default)" : ""}`,
|
|
175
|
+
detail,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const typed = options.query();
|
|
181
|
+
out.push({
|
|
182
|
+
kind: "plugin-form",
|
|
183
|
+
key: "submit",
|
|
184
|
+
label: typed
|
|
185
|
+
? `Use ${quote(typed)}`
|
|
186
|
+
: fallback !== undefined
|
|
187
|
+
? `Use default ${quote(fallback)}`
|
|
188
|
+
: `Type the ${param.label.toLowerCase()}`,
|
|
189
|
+
detail,
|
|
190
|
+
...(!typed && fallback === undefined && param.required
|
|
191
|
+
? { disabledReason: `${param.label} is required` }
|
|
192
|
+
: {}),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (!param.required)
|
|
196
|
+
out.push({ kind: "plugin-form", key: "skip", label: "Leave empty", detail });
|
|
197
|
+
return out;
|
|
198
|
+
},
|
|
199
|
+
/** The person activated one of the current step's entries. */
|
|
200
|
+
choose(entry) {
|
|
201
|
+
const current = state();
|
|
202
|
+
if (!current)
|
|
203
|
+
return;
|
|
204
|
+
const param = currentParam(current);
|
|
205
|
+
if (!param) {
|
|
206
|
+
if (entry.key === "run")
|
|
207
|
+
run(current.command, { ...current.values });
|
|
208
|
+
else {
|
|
209
|
+
setState(null);
|
|
210
|
+
options.close();
|
|
211
|
+
setNote(`${current.command.label}: cancelled`);
|
|
212
|
+
}
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (entry.key === "skip")
|
|
216
|
+
return advance(current, param, undefined);
|
|
217
|
+
if (entry.key.startsWith("choice:"))
|
|
218
|
+
return advance(current, param, entry.key.slice(7));
|
|
219
|
+
if (entry.key.startsWith("bool:"))
|
|
220
|
+
return advance(current, param, entry.key === "bool:true");
|
|
221
|
+
if (entry.key !== "submit")
|
|
222
|
+
return;
|
|
223
|
+
const typed = options.query();
|
|
224
|
+
const raw = typed || defaultFor(current, param);
|
|
225
|
+
if (raw === undefined || raw === "") {
|
|
226
|
+
setNote(`${param.label} is required`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (param.type === "number") {
|
|
230
|
+
const number = typeof raw === "number" ? raw : Number(raw);
|
|
231
|
+
if (!Number.isFinite(number) || (typeof raw === "string" && raw.trim() === "")) {
|
|
232
|
+
setNote(`${param.label} must be a number`);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
return advance(current, param, number);
|
|
236
|
+
}
|
|
237
|
+
advance(current, param, String(raw));
|
|
238
|
+
},
|
|
239
|
+
/** Keyboard hint while the form is open. */
|
|
240
|
+
hint() {
|
|
241
|
+
const current = state();
|
|
242
|
+
if (!current)
|
|
243
|
+
return "";
|
|
244
|
+
const param = currentParam(current);
|
|
245
|
+
const total = current.command.params.length;
|
|
246
|
+
return terminalSafe(param
|
|
247
|
+
? `${current.command.label} · ${param.label} (${current.step + 1}/${total}) · Enter to choose · Esc to cancel`
|
|
248
|
+
: `${current.command.label} · confirm · Enter to choose · Esc to cancel`, 500);
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|