tmux-ide 2.9.18 → 2.9.21

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.
Files changed (97) hide show
  1. package/bin/cli.js +14703 -3882
  2. package/package.json +3 -2
  3. package/packages/contracts/src/command-catalog.ts +116 -0
  4. package/packages/contracts/src/commands.ts +5 -4
  5. package/packages/contracts/src/daemon-events.ts +2 -1
  6. package/packages/contracts/src/index.ts +2 -0
  7. package/packages/contracts/src/plain-text.ts +61 -0
  8. package/packages/daemon/dist/command-center/command-catalog-routes.js +78 -0
  9. package/packages/daemon/dist/command-center/plugin-routes.js +84 -0
  10. package/packages/daemon/dist/command-center/server.js +13 -0
  11. package/packages/daemon/dist/doctor.js +12 -5
  12. package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
  13. package/packages/daemon/dist/lib/daemon-embed.js +24 -1
  14. package/packages/daemon/dist/lib/headless-daemon.js +1 -0
  15. package/packages/daemon/dist/lib/native-split-capability.js +13 -15
  16. package/packages/daemon/dist/lib/worktree.js +18 -0
  17. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  18. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  19. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  20. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  21. package/packages/daemon/dist/plugins/action-catalog.js +129 -0
  22. package/packages/daemon/dist/plugins/action-cli.js +212 -0
  23. package/packages/daemon/dist/plugins/api-table.js +303 -0
  24. package/packages/daemon/dist/plugins/cli.js +556 -0
  25. package/packages/daemon/dist/plugins/consent.js +107 -0
  26. package/packages/daemon/dist/plugins/daemon-plugins.js +132 -0
  27. package/packages/daemon/dist/plugins/discovery.js +142 -0
  28. package/packages/daemon/dist/plugins/examples/worktree-tasks.js +115 -0
  29. package/packages/daemon/dist/plugins/exec-sandbox.js +202 -0
  30. package/packages/daemon/dist/plugins/host/actions-prelude.js +279 -0
  31. package/packages/daemon/dist/plugins/host/entry.js +4 -0
  32. package/packages/daemon/dist/plugins/host/host-api-prelude.js +232 -0
  33. package/packages/daemon/dist/plugins/host/lua-state.js +493 -0
  34. package/packages/daemon/dist/plugins/host/main.js +322 -0
  35. package/packages/daemon/dist/plugins/host/sandbox.js +299 -0
  36. package/packages/daemon/dist/plugins/host-calls.js +279 -0
  37. package/packages/daemon/dist/plugins/manifest.js +69 -0
  38. package/packages/daemon/dist/plugins/plugin-exec.js +261 -0
  39. package/packages/daemon/dist/plugins/plugin-log.js +54 -0
  40. package/packages/daemon/dist/plugins/plugin-store.js +74 -0
  41. package/packages/daemon/dist/plugins/protocol.js +252 -0
  42. package/packages/daemon/dist/plugins/safe-files.js +97 -0
  43. package/packages/daemon/dist/plugins/supervisor.js +790 -0
  44. package/packages/daemon/dist/plugins/worktree-calls.js +154 -0
  45. package/packages/daemon/dist/terminal/mirror/session-channel.js +3 -2
  46. package/packages/daemon/dist/terminal/mirror/window-split-authority.js +1 -1
  47. package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +27 -0
  48. package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
  49. package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +30 -2
  50. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-commands.js +152 -0
  51. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-form.js +251 -0
  52. package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +14 -0
  53. package/packages/daemon/dist/tui/mirror/workspace/palette-list-layout.js +5 -0
  54. package/packages/daemon/src/command-center/command-catalog-routes.ts +116 -0
  55. package/packages/daemon/src/command-center/plugin-routes.ts +110 -0
  56. package/packages/daemon/src/command-center/server.ts +15 -0
  57. package/packages/daemon/src/doctor.ts +12 -5
  58. package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
  59. package/packages/daemon/src/lib/daemon-embed.ts +42 -0
  60. package/packages/daemon/src/lib/headless-daemon.ts +1 -0
  61. package/packages/daemon/src/lib/native-split-capability.ts +12 -13
  62. package/packages/daemon/src/lib/worktree.ts +16 -0
  63. package/packages/daemon/src/plugins/action-catalog.ts +141 -0
  64. package/packages/daemon/src/plugins/action-cli.ts +248 -0
  65. package/packages/daemon/src/plugins/api-table.ts +346 -0
  66. package/packages/daemon/src/plugins/cli.ts +630 -0
  67. package/packages/daemon/src/plugins/consent.ts +125 -0
  68. package/packages/daemon/src/plugins/daemon-plugins.ts +182 -0
  69. package/packages/daemon/src/plugins/discovery.ts +176 -0
  70. package/packages/daemon/src/plugins/examples/worktree-tasks.ts +120 -0
  71. package/packages/daemon/src/plugins/exec-sandbox.ts +264 -0
  72. package/packages/daemon/src/plugins/host/actions-prelude.ts +280 -0
  73. package/packages/daemon/src/plugins/host/entry.ts +5 -0
  74. package/packages/daemon/src/plugins/host/host-api-prelude.ts +233 -0
  75. package/packages/daemon/src/plugins/host/lua-state.ts +557 -0
  76. package/packages/daemon/src/plugins/host/main.ts +359 -0
  77. package/packages/daemon/src/plugins/host/sandbox.ts +301 -0
  78. package/packages/daemon/src/plugins/host-calls.ts +343 -0
  79. package/packages/daemon/src/plugins/manifest.ts +74 -0
  80. package/packages/daemon/src/plugins/plugin-exec.ts +326 -0
  81. package/packages/daemon/src/plugins/plugin-log.ts +63 -0
  82. package/packages/daemon/src/plugins/plugin-store.ts +80 -0
  83. package/packages/daemon/src/plugins/protocol.ts +275 -0
  84. package/packages/daemon/src/plugins/safe-files.ts +105 -0
  85. package/packages/daemon/src/plugins/supervisor.ts +954 -0
  86. package/packages/daemon/src/plugins/worktree-calls.ts +183 -0
  87. package/packages/daemon/src/terminal/mirror/session-channel.ts +3 -2
  88. package/packages/daemon/src/terminal/mirror/window-split-authority.ts +3 -2
  89. package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
  90. package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +32 -0
  91. package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
  92. package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +42 -2
  93. package/packages/daemon/src/tui/mirror/runtime/application-palette-preview.tsx +7 -1
  94. package/packages/daemon/src/tui/mirror/runtime/application-plugin-commands.ts +229 -0
  95. package/packages/daemon/src/tui/mirror/runtime/application-plugin-form.ts +312 -0
  96. package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +44 -2
  97. package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
@@ -0,0 +1,312 @@
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 {
10
+ terminalSafe,
11
+ type CommandInvocationContext,
12
+ type CommandInvokeResult,
13
+ type CommandParam,
14
+ type CommandParamOptionsResult,
15
+ } from "@tmux-ide/contracts";
16
+ import { createSignal } from "solid-js";
17
+ import type {
18
+ ApplicationPluginFormPaletteCommand,
19
+ ApplicationPluginPaletteCommand,
20
+ } from "../workspace/application-command-description.ts";
21
+
22
+ type ArgValue = string | number | boolean;
23
+
24
+ interface ParamOptionsState {
25
+ readonly phase: "loading" | "ready" | "error";
26
+ readonly choices?: readonly { value: string; label: string }[];
27
+ readonly default?: ArgValue;
28
+ readonly error?: string;
29
+ }
30
+
31
+ interface FormState {
32
+ readonly command: ApplicationPluginPaletteCommand;
33
+ readonly step: number;
34
+ readonly values: Readonly<Record<string, ArgValue>>;
35
+ readonly options: Readonly<Record<string, ParamOptionsState>>;
36
+ readonly generation: number;
37
+ }
38
+
39
+ export interface PluginFormService {
40
+ invoke(
41
+ id: string,
42
+ args: Record<string, ArgValue>,
43
+ context: CommandInvocationContext,
44
+ confirmed: boolean,
45
+ ): Promise<CommandInvokeResult>;
46
+ paramOptions(
47
+ id: string,
48
+ param: string,
49
+ context: CommandInvocationContext,
50
+ ): Promise<CommandParamOptionsResult>;
51
+ }
52
+
53
+ const quote = (value: ArgValue) => (typeof value === "string" ? `“${value}”` : String(value));
54
+
55
+ function resultNote(label: string, result: CommandInvokeResult): string {
56
+ if (!result.ok) return `${label}: ${result.error}`;
57
+ if (typeof result.value === "string" && result.value.trim()) return `${label}: ${result.value}`;
58
+ return `${label}: done`;
59
+ }
60
+
61
+ /**
62
+ * The context a palette invocation sends. The TUI's focused pane id is its
63
+ * own mirror id, not the tmux `%N` id plugins pass to ide.exec{context}, so
64
+ * only a real tmux pane id is sent as `pane`.
65
+ */
66
+ export function pluginPaletteContext(
67
+ session: string | null,
68
+ focusedPane: string | null,
69
+ ): CommandInvocationContext {
70
+ const pane = focusedPane && /^%\d{1,9}$/u.test(focusedPane) ? focusedPane : null;
71
+ return {
72
+ source: "palette",
73
+ ...(session ? { session } : {}),
74
+ ...(pane ? { pane } : {}),
75
+ };
76
+ }
77
+
78
+ export function createApplicationPluginForm(options: {
79
+ readonly service: PluginFormService;
80
+ readonly context: () => CommandInvocationContext;
81
+ readonly query: () => string;
82
+ readonly setNote: (note: string | null) => void;
83
+ /** Close the palette (the form finished or was cancelled). */
84
+ readonly close: () => void;
85
+ /** A new step started: clear the search line and selection. */
86
+ readonly stepChanged: () => void;
87
+ }) {
88
+ const [state, setState] = createSignal<FormState | null>(null);
89
+ let generation = 0;
90
+ // Notes carry plugin text (labels, results, errors) to the terminal.
91
+ const setNote = (note: string | null) =>
92
+ options.setNote(note === null ? null : terminalSafe(note, 500));
93
+
94
+ const run = (command: ApplicationPluginPaletteCommand, args: Record<string, ArgValue>) => {
95
+ setState(null);
96
+ options.close();
97
+ setNote(`${command.label}…`);
98
+ void options.service
99
+ .invoke(command.id, args, options.context(), command.dangerous)
100
+ .then((result) => setNote(resultNote(command.label, result)));
101
+ };
102
+
103
+ const loadOptions = (current: FormState, param: CommandParam) => {
104
+ if (!param.dynamicChoices && !param.dynamicDefault) return;
105
+ if (current.options[param.name]) return;
106
+ const marker = current.generation;
107
+ setState({ ...current, options: { ...current.options, [param.name]: { phase: "loading" } } });
108
+ void options.service
109
+ .paramOptions(current.command.id, param.name, options.context())
110
+ .then((result) => {
111
+ const latest = state();
112
+ if (!latest || latest.generation !== marker) return;
113
+ setState({
114
+ ...latest,
115
+ options: {
116
+ ...latest.options,
117
+ [param.name]: result.ok
118
+ ? {
119
+ phase: "ready",
120
+ ...(result.choices ? { choices: result.choices } : {}),
121
+ ...(result.default !== undefined ? { default: result.default } : {}),
122
+ }
123
+ : { phase: "error", error: result.error },
124
+ },
125
+ });
126
+ });
127
+ };
128
+
129
+ const enterStep = (next: FormState) => {
130
+ const { command } = next;
131
+ if (next.step >= command.params.length) {
132
+ // Past the last parameter: confirm a dangerous command, else run it.
133
+ if (command.dangerous && next.step === command.params.length) {
134
+ setState(next);
135
+ options.stepChanged();
136
+ return;
137
+ }
138
+ run(command, { ...next.values });
139
+ return;
140
+ }
141
+ setState(next);
142
+ options.stepChanged();
143
+ loadOptions(next, command.params[next.step]!);
144
+ };
145
+
146
+ const currentParam = (current: FormState): CommandParam | null =>
147
+ current.command.params[current.step] ?? null;
148
+
149
+ const defaultFor = (current: FormState, param: CommandParam): ArgValue | undefined =>
150
+ current.options[param.name]?.default ?? param.default;
151
+
152
+ const choicesFor = (current: FormState, param: CommandParam) =>
153
+ current.options[param.name]?.choices ?? param.choices ?? [];
154
+
155
+ const advance = (current: FormState, param: CommandParam, value: ArgValue | undefined) => {
156
+ const values = { ...current.values };
157
+ if (value === undefined) delete values[param.name];
158
+ else values[param.name] = value;
159
+ enterStep({ ...current, step: current.step + 1, values });
160
+ };
161
+
162
+ return {
163
+ active: () => state() !== null,
164
+
165
+ /**
166
+ * Start a plugin command. One without parameters and not dangerous runs
167
+ * at once; otherwise the palette turns into its form.
168
+ */
169
+ start(command: ApplicationPluginPaletteCommand): void {
170
+ generation += 1;
171
+ if (command.params.length === 0 && !command.dangerous) {
172
+ run(command, {});
173
+ return;
174
+ }
175
+ enterStep({ command, step: 0, values: {}, options: {}, generation });
176
+ },
177
+
178
+ cancel(): void {
179
+ if (!state()) return;
180
+ generation += 1;
181
+ setState(null);
182
+ },
183
+
184
+ entries(): ApplicationPluginFormPaletteCommand[] {
185
+ const current = state();
186
+ if (!current) return [];
187
+ const param = currentParam(current);
188
+ if (!param) {
189
+ return [
190
+ {
191
+ kind: "plugin-form",
192
+ key: "run",
193
+ label: `Run ${current.command.label}`,
194
+ detail: "This cannot be undone",
195
+ },
196
+ { kind: "plugin-form", key: "cancel", label: "Cancel", detail: "Do nothing" },
197
+ ];
198
+ }
199
+ const detail = param.description ?? param.label;
200
+ const loaded = current.options[param.name];
201
+ const out: ApplicationPluginFormPaletteCommand[] = [];
202
+ if (loaded?.phase === "loading") {
203
+ out.push({
204
+ kind: "plugin-form",
205
+ key: "loading",
206
+ label: "Loading choices…",
207
+ detail,
208
+ disabledReason: "Still loading choices",
209
+ });
210
+ return out;
211
+ }
212
+ if (loaded?.phase === "error") {
213
+ out.push({
214
+ kind: "plugin-form",
215
+ key: "error",
216
+ label: loaded.error ?? "Choices are unavailable",
217
+ detail,
218
+ disabledReason: "The plugin could not list choices",
219
+ });
220
+ }
221
+ const fallback = defaultFor(current, param);
222
+ if (param.type === "choice") {
223
+ for (const choice of choicesFor(current, param)) {
224
+ out.push({
225
+ kind: "plugin-form",
226
+ key: `choice:${choice.value}`,
227
+ label: choice.value === fallback ? `${choice.label} (default)` : choice.label,
228
+ detail,
229
+ });
230
+ }
231
+ } else if (param.type === "boolean") {
232
+ for (const value of [true, false]) {
233
+ out.push({
234
+ kind: "plugin-form",
235
+ key: `bool:${value}`,
236
+ label: `${value ? "Yes" : "No"}${fallback === value ? " (default)" : ""}`,
237
+ detail,
238
+ });
239
+ }
240
+ } else {
241
+ const typed = options.query();
242
+ out.push({
243
+ kind: "plugin-form",
244
+ key: "submit",
245
+ label: typed
246
+ ? `Use ${quote(typed)}`
247
+ : fallback !== undefined
248
+ ? `Use default ${quote(fallback)}`
249
+ : `Type the ${param.label.toLowerCase()}`,
250
+ detail,
251
+ ...(!typed && fallback === undefined && param.required
252
+ ? { disabledReason: `${param.label} is required` }
253
+ : {}),
254
+ });
255
+ }
256
+ if (!param.required)
257
+ out.push({ kind: "plugin-form", key: "skip", label: "Leave empty", detail });
258
+ return out;
259
+ },
260
+
261
+ /** The person activated one of the current step's entries. */
262
+ choose(entry: ApplicationPluginFormPaletteCommand): void {
263
+ const current = state();
264
+ if (!current) return;
265
+ const param = currentParam(current);
266
+ if (!param) {
267
+ if (entry.key === "run") run(current.command, { ...current.values });
268
+ else {
269
+ setState(null);
270
+ options.close();
271
+ setNote(`${current.command.label}: cancelled`);
272
+ }
273
+ return;
274
+ }
275
+ if (entry.key === "skip") return advance(current, param, undefined);
276
+ if (entry.key.startsWith("choice:")) return advance(current, param, entry.key.slice(7));
277
+ if (entry.key.startsWith("bool:")) return advance(current, param, entry.key === "bool:true");
278
+ if (entry.key !== "submit") return;
279
+ const typed = options.query();
280
+ const raw: ArgValue | undefined = typed || defaultFor(current, param);
281
+ if (raw === undefined || raw === "") {
282
+ setNote(`${param.label} is required`);
283
+ return;
284
+ }
285
+ if (param.type === "number") {
286
+ const number = typeof raw === "number" ? raw : Number(raw);
287
+ if (!Number.isFinite(number) || (typeof raw === "string" && raw.trim() === "")) {
288
+ setNote(`${param.label} must be a number`);
289
+ return;
290
+ }
291
+ return advance(current, param, number);
292
+ }
293
+ advance(current, param, String(raw));
294
+ },
295
+
296
+ /** Keyboard hint while the form is open. */
297
+ hint(): string {
298
+ const current = state();
299
+ if (!current) return "";
300
+ const param = currentParam(current);
301
+ const total = current.command.params.length;
302
+ return terminalSafe(
303
+ param
304
+ ? `${current.command.label} · ${param.label} (${current.step + 1}/${total}) · Enter to choose · Esc to cancel`
305
+ : `${current.command.label} · confirm · Enter to choose · Esc to cancel`,
306
+ 500,
307
+ );
308
+ },
309
+ };
310
+ }
311
+
312
+ export type ApplicationPluginForm = ReturnType<typeof createApplicationPluginForm>;
@@ -1,5 +1,5 @@
1
1
  import { CHROME_ACTIONS } from "./application-action-descriptions.ts";
2
- import type { TmuxServerScope } from "@tmux-ide/contracts";
2
+ import { terminalSafe, type CommandParam, type TmuxServerScope } from "@tmux-ide/contracts";
3
3
  import { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.ts";
4
4
  export { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.ts";
5
5
  import { PANE_ACTION_MENU_ITEMS } from "./pane-action-menu-model.ts";
@@ -37,6 +37,30 @@ export interface ApplicationMachinePaletteCommand {
37
37
  readonly fleet: FleetPaletteTarget;
38
38
  }
39
39
 
40
+ /** A command a plugin registered, from the daemon's command catalog. */
41
+ export interface ApplicationPluginPaletteCommand {
42
+ readonly kind: "plugin-command";
43
+ readonly fleet?: undefined;
44
+ /** Catalog id, `plugin.<plugin>.<id>`. */
45
+ readonly id: string;
46
+ readonly label: string;
47
+ readonly category: string;
48
+ readonly plugin: string;
49
+ readonly dangerous: boolean;
50
+ readonly params: readonly CommandParam[];
51
+ }
52
+
53
+ /** One choice in the step-by-step form a plugin command with parameters opens. */
54
+ export interface ApplicationPluginFormPaletteCommand {
55
+ readonly kind: "plugin-form";
56
+ readonly fleet?: undefined;
57
+ /** Unique within the current form step. */
58
+ readonly key: string;
59
+ readonly label: string;
60
+ readonly detail: string;
61
+ readonly disabledReason?: string;
62
+ }
63
+
40
64
  export type ApplicationPaletteCommand =
41
65
  | "hide-sidebar"
42
66
  | "show-sidebar"
@@ -55,7 +79,9 @@ export type ApplicationPaletteCommand =
55
79
  | "close-pane"
56
80
  | ApplicationMachinePaletteCommand
57
81
  | ApplicationAgentPaletteCommand
58
- | ApplicationSessionPaletteCommand;
82
+ | ApplicationSessionPaletteCommand
83
+ | ApplicationPluginPaletteCommand
84
+ | ApplicationPluginFormPaletteCommand;
59
85
 
60
86
  export const PALETTE_REFERENCE_COMMANDS = {
61
87
  shortcuts: { label: "Keyboard shortcuts", shortcut: "Ctrl+K", key: "k", page: "shortcuts" },
@@ -93,6 +119,22 @@ export function applicationCommandDescription(command: ApplicationPaletteCommand
93
119
  };
94
120
  if (command === "shortcuts" || command === "whats-new")
95
121
  return { id: command, ...PALETTE_REFERENCE_COMMANDS[command], detail: "Help and reference" };
122
+ if (typeof command === "object" && command.kind === "plugin-command")
123
+ return {
124
+ id: JSON.stringify([command.kind, command.id]),
125
+ // Plugin text: plain text only, even if something upstream let it through.
126
+ label: terminalSafe(
127
+ command.params.length > 0 || command.dangerous ? `${command.label}…` : command.label,
128
+ 200,
129
+ ),
130
+ detail: terminalSafe(`${command.category} · ${command.plugin} plugin`, 200),
131
+ };
132
+ if (typeof command === "object" && command.kind === "plugin-form")
133
+ return {
134
+ id: JSON.stringify([command.kind, command.key]),
135
+ label: terminalSafe(command.label, 200),
136
+ detail: terminalSafe(command.detail, 500),
137
+ };
96
138
  if (typeof command === "object" && command.kind === "open-machine")
97
139
  return {
98
140
  id: JSON.stringify([
@@ -1,7 +1,11 @@
1
+ import { terminalSafe } from "@tmux-ide/contracts";
1
2
  import type { ApplicationPaletteCommand } from "./application-command-description.ts";
2
3
 
3
4
  export function paletteSection(command: ApplicationPaletteCommand): string {
4
5
  if (command === "switch-session") return "Sessions";
6
+ if (typeof command === "object" && command.kind === "plugin-command")
7
+ return terminalSafe(command.category, 80);
8
+ if (typeof command === "object" && command.kind === "plugin-form") return "Choose";
5
9
  if (typeof command === "object")
6
10
  return command.kind === "jump-agent"
7
11
  ? "Agents"