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,346 @@
1
+ /**
2
+ * The Lua API, described once. `tmux-ide lua api`, `tmux-ide lua describe`
3
+ * and the generated docs read this table, and a test checks that the host's
4
+ * `ide` table has exactly these entries, so the three cannot drift apart.
5
+ */
6
+ import { PLUGIN_API_VERSION } from "./protocol.ts";
7
+
8
+ export type ApiStability = "stable" | "experimental";
9
+
10
+ export interface ApiEntry {
11
+ /** Dotted Lua name, e.g. `ide.log.info`. */
12
+ readonly name: string;
13
+ readonly kind: "function" | "value" | "global";
14
+ /** Lua-style signature, e.g. `ide.log.info(message, fields?)`. */
15
+ readonly signature: string;
16
+ readonly summary: string;
17
+ readonly details?: string;
18
+ readonly errors?: readonly string[];
19
+ readonly example?: string;
20
+ readonly since: string;
21
+ readonly stability: ApiStability;
22
+ }
23
+
24
+ const v1 = { since: "1.0", stability: "stable" } as const;
25
+
26
+ const LOG_DETAILS =
27
+ "Writes one line to `~/.tmux-ide/logs/plugins.log` and the daemon's `plugins` log channel, " +
28
+ "tagged with the plugin's name. `fields` is a table encoded as JSON. Each plugin may log " +
29
+ "100 lines per second; extra lines are dropped and counted.";
30
+
31
+ export const API_ENTRIES: readonly ApiEntry[] = Object.freeze([
32
+ {
33
+ name: "ide.api",
34
+ kind: "value",
35
+ signature: "ide.api",
36
+ summary: `The Lua API version this tmux-ide provides, currently "${PLUGIN_API_VERSION}".`,
37
+ details:
38
+ "Minor versions only add. A plugin declares the versions it works with in its manifest's `api` field.",
39
+ ...v1,
40
+ },
41
+ {
42
+ name: "ide.version",
43
+ kind: "value",
44
+ signature: "ide.version",
45
+ summary: "The tmux-ide version running the script.",
46
+ ...v1,
47
+ },
48
+ {
49
+ name: "ide.plugin.name",
50
+ kind: "value",
51
+ signature: "ide.plugin.name",
52
+ summary:
53
+ 'The running plugin\'s name; "init" for ~/.tmux-ide/init.lua, "run" for `tmux-ide lua run`.',
54
+ ...v1,
55
+ },
56
+ {
57
+ name: "ide.settings",
58
+ kind: "value",
59
+ signature: "ide.settings",
60
+ summary: "The plugin's settings: the defaults declared in its manifest.",
61
+ ...v1,
62
+ },
63
+ {
64
+ name: "ide.has",
65
+ kind: "function",
66
+ signature: "ide.has(feature) -> boolean",
67
+ summary:
68
+ "Whether this tmux-ide provides an API feature, so a plugin can degrade without raising its `api` range.",
69
+ details:
70
+ "Features in 1.0: log, include, require, actions, exec, panes, timers, json, store, notify.",
71
+ example: 'if ide.has("include") then ide.include("keys.lua") end',
72
+ ...v1,
73
+ },
74
+ {
75
+ name: "ide.log.debug",
76
+ kind: "function",
77
+ signature: "ide.log.debug(message, fields?)",
78
+ summary: "Log a debug line.",
79
+ details: LOG_DETAILS,
80
+ ...v1,
81
+ },
82
+ {
83
+ name: "ide.log.info",
84
+ kind: "function",
85
+ signature: "ide.log.info(message, fields?)",
86
+ summary: "Log an info line.",
87
+ details: LOG_DETAILS,
88
+ example: 'ide.log.info("loaded", { tasks = 3 })',
89
+ ...v1,
90
+ },
91
+ {
92
+ name: "ide.log.warn",
93
+ kind: "function",
94
+ signature: "ide.log.warn(message, fields?)",
95
+ summary: "Log a warning.",
96
+ details: LOG_DETAILS,
97
+ ...v1,
98
+ },
99
+ {
100
+ name: "ide.log.error",
101
+ kind: "function",
102
+ signature: "ide.log.error(message, fields?)",
103
+ summary: "Log an error.",
104
+ details: LOG_DETAILS,
105
+ ...v1,
106
+ },
107
+ {
108
+ name: "ide.include",
109
+ kind: "function",
110
+ signature: "ide.include(file) -> ...",
111
+ summary: "Run another .lua file and return what it returns.",
112
+ details:
113
+ "`init.lua` includes from `~/.tmux-ide/` and `~/.tmux-ide/lua/`; a plugin includes from its own " +
114
+ "directory. Names must be relative and may not leave those directories. Files over 1 MiB are refused.",
115
+ errors: ["E_INVALID", "E_NOT_FOUND", "E_DENIED"],
116
+ example: 'ide.include("keys.lua")',
117
+ ...v1,
118
+ },
119
+ {
120
+ name: "ide.action.register",
121
+ kind: "function",
122
+ signature:
123
+ "ide.action.register{ id, title, run, category?, description?, dangerous?, params? }",
124
+ summary:
125
+ "Offer a named action in the command palette and to `tmux-ide action run plugin.<plugin>.<id>`.",
126
+ details:
127
+ "`run(ctx, args)` runs when the action is invoked; `ctx` has `source` (palette, cli, key…) and, " +
128
+ "when known, `session`, `window` and `pane`. Each param is `{ name, type, label?, description?, " +
129
+ "optional?, pattern?, choices?, default? }`, where type is string, text, number, boolean or choice, " +
130
+ "`pattern` is a Lua pattern, and `choices` and `default` may be functions of `ctx`. Arguments are " +
131
+ "checked before `run` is called. `dangerous = true` makes every caller confirm first. Registering " +
132
+ "an id again replaces it. At most 200 actions per plugin, 32 params per action.",
133
+ errors: ["E_INVALID"],
134
+ example:
135
+ 'ide.action.register{ id = "hello", title = "Say hello", params = { { name = "who" } }, ' +
136
+ 'run = function(ctx, args) ide.log.info("hello " .. args.who) end }',
137
+ ...v1,
138
+ },
139
+ {
140
+ name: "ide.action.unregister",
141
+ kind: "function",
142
+ signature: "ide.action.unregister(id) -> boolean",
143
+ summary: "Remove an action this plugin registered; false if there was none.",
144
+ ...v1,
145
+ },
146
+ {
147
+ name: "ide.exec",
148
+ kind: "function",
149
+ signature:
150
+ "ide.exec{ cmd, args?, cwd?, env?, stdin?, timeout_ms?, context?, shell? } -> { code, signal, stdout, stderr, timed_out, truncated }",
151
+ summary: "Run a program the manifest lists under capabilities.exec, and wait for it.",
152
+ details:
153
+ "`cmd` is a program name looked up on PATH; `args` are passed as they are, with no shell. " +
154
+ "`shell = true` runs `cmd` as a /bin/sh command line and needs capabilities.shell. " +
155
+ '`context` is a tmux pane id like "%3": the program gets that pane\'s cwd, TMUX and ' +
156
+ "TMUX_PANE, and needs capabilities `panes.send`. `cmd` is looked up on the daemon's PATH; " +
157
+ "`env` may set only LANG, LC_*, TZ, TERM, colour variables, COLUMNS, LINES and PLUGIN_*. " +
158
+ "A program can usually do anything your account can; the OS sandbox only keeps it from " +
159
+ "writing tmux-ide's state (but ~/.tmux-ide/plugin-data/<plugin>), reading the daemon's " +
160
+ "credentials and, without `panes.send`, reaching your tmux server. On Linux it is off unless the daemon has TMUX_IDE_PLUGIN_EXEC_LINUX=1 (untested). " +
161
+ "It is killed with everything it started after `timeout_ms` (default and most: the " +
162
+ "callback's 30 s wall clock), or when the plugin fails or unloads, and keeps at most " +
163
+ "1 MiB of each output. Output is redacted.",
164
+ errors: ["E_DENIED", "E_INVALID", "E_NOT_FOUND", "E_UNAVAILABLE"],
165
+ example:
166
+ 'local r = ide.exec{ cmd = "git", args = { "status", "--short" }, context = ctx.pane }',
167
+ ...v1,
168
+ },
169
+ {
170
+ name: "ide.panes",
171
+ kind: "function",
172
+ signature: "ide.panes{ session?, workspace? } -> { pane… }",
173
+ summary: "The panes tmux-ide manages, as pane objects.",
174
+ details:
175
+ "A pane has `id`, `workspace`, `session` and `title`, and methods `read()`, " +
176
+ '`send(text, { enter = true })`, `split{ dir = "right"|"down", title? }`, `zoom(on?)`, ' +
177
+ "`focus()`, `rename(name)`, `kill()`, `rename_window(name)` and `kill_window()`. They go " +
178
+ "through the same daemon actions and automation API as the app and the CLI. `send` needs " +
179
+ "capabilities `panes.send`.",
180
+ example: 'for _, pane in ipairs(ide.panes{ session = "demo" }) do print(pane.title) end',
181
+ ...v1,
182
+ },
183
+ {
184
+ name: "ide.session",
185
+ kind: "function",
186
+ signature: "ide.session(workspace) -> { rename(name), kill() }",
187
+ summary: "A workspace's tmux session, to rename or kill.",
188
+ ...v1,
189
+ },
190
+ {
191
+ name: "ide.worktree.list",
192
+ kind: "function",
193
+ signature:
194
+ "ide.worktree.list{ session } -> { repo, worktrees = { { path, branch, primary, session, running, status }… } }",
195
+ summary: "The git worktrees of a session's repository, with their sessions.",
196
+ details:
197
+ "Needs capabilities `worktree`. `session` is a tmux session name (usually `ctx.session`); " +
198
+ "the daemon runs tmux-ide's own worktree code for that session's repository.",
199
+ errors: ["E_DENIED", "E_INVALID", "E_NOT_FOUND", "E_FAILED"],
200
+ example: "local tasks = ide.worktree.list{ session = ctx.session }",
201
+ ...v1,
202
+ },
203
+ {
204
+ name: "ide.worktree.create",
205
+ kind: "function",
206
+ signature: "ide.worktree.create{ session, branch, from? } -> { branch, path, session }",
207
+ summary: "Add a worktree on a new branch (or an existing one) and open a plain session in it.",
208
+ details:
209
+ "Needs capabilities `worktree`. `branch` and `from` must be plain git names: letters, " +
210
+ "digits and `. _ / -`, not starting with `-` or `.`.",
211
+ errors: ["E_DENIED", "E_INVALID", "E_NOT_FOUND", "E_FAILED"],
212
+ example: 'ide.worktree.create{ session = ctx.session, branch = "fix-login" }',
213
+ ...v1,
214
+ },
215
+ {
216
+ name: "ide.worktree.open",
217
+ kind: "function",
218
+ signature: "ide.worktree.open{ session, branch } -> { branch, path, session, created }",
219
+ summary: "Open (or start) the session of an existing worktree.",
220
+ details:
221
+ "Needs capabilities `worktree`. Sessions it starts are plain: the worktree's own tmux-ide " +
222
+ "layout, whose commands come from that branch, never runs from a plugin, and git runs " +
223
+ "with hooks off.",
224
+ errors: ["E_DENIED", "E_INVALID", "E_NOT_FOUND", "E_FAILED"],
225
+ ...v1,
226
+ },
227
+ {
228
+ name: "ide.worktree.remove",
229
+ kind: "function",
230
+ signature: "ide.worktree.remove{ session, branch } -> { branch, path, sessionKilled, removed }",
231
+ summary: "Close a worktree's session and remove the worktree; refused if it has changes.",
232
+ details:
233
+ "Needs capabilities `worktree`. Never forces: a worktree with changes is refused. Mark " +
234
+ "actions that call it `dangerous = true`, so a person confirms them.",
235
+ errors: ["E_DENIED", "E_INVALID", "E_NOT_FOUND", "E_FAILED"],
236
+ ...v1,
237
+ },
238
+ {
239
+ name: "ide.notify",
240
+ kind: "function",
241
+ signature: "ide.notify(text, { level? })",
242
+ summary: "Show a short message (200 characters) in every attached client's status line.",
243
+ ...v1,
244
+ },
245
+ {
246
+ name: "ide.json.encode",
247
+ kind: "function",
248
+ signature: "ide.json.encode(value) -> string",
249
+ summary: "Encode a Lua value as JSON. Tables that contain themselves are refused.",
250
+ ...v1,
251
+ },
252
+ {
253
+ name: "ide.json.decode",
254
+ kind: "function",
255
+ signature: "ide.json.decode(text) -> value",
256
+ summary: "Decode JSON text. null becomes nil.",
257
+ errors: ["E_INVALID"],
258
+ ...v1,
259
+ },
260
+ {
261
+ name: "ide.store.get",
262
+ kind: "function",
263
+ signature: "ide.store.get(key) -> value | nil",
264
+ summary: "Read a value this plugin stored.",
265
+ details: "Each plugin has its own store, kept across restarts: at most 1000 keys and 1 MiB.",
266
+ ...v1,
267
+ },
268
+ {
269
+ name: "ide.store.set",
270
+ kind: "function",
271
+ signature: "ide.store.set(key, value)",
272
+ summary: "Store a JSON-able value under `key`; nil deletes it.",
273
+ errors: ["E_INVALID", "E_LIMIT"],
274
+ ...v1,
275
+ },
276
+ {
277
+ name: "ide.store.delete",
278
+ kind: "function",
279
+ signature: "ide.store.delete(key)",
280
+ summary: "Delete a stored value.",
281
+ ...v1,
282
+ },
283
+ {
284
+ name: "ide.store.keys",
285
+ kind: "function",
286
+ signature: "ide.store.keys() -> { key… }",
287
+ summary: "The stored keys, sorted.",
288
+ ...v1,
289
+ },
290
+ {
291
+ name: "ide.timer.after",
292
+ kind: "function",
293
+ signature: "ide.timer.after(ms, fn) -> { id, cancel() }",
294
+ summary: "Call `fn` once after `ms` milliseconds, under the callback budget.",
295
+ details:
296
+ "At most 64 timers per plugin. Unloading or reloading the plugin cancels them. After a " +
297
+ "timer callback that took t ms, the plugin's next timer waits at least max(t, 10 ms).",
298
+ ...v1,
299
+ },
300
+ {
301
+ name: "ide.timer.every",
302
+ kind: "function",
303
+ signature: "ide.timer.every(ms, fn) -> { id, cancel() }",
304
+ summary: "Call `fn` every `ms` milliseconds (at least 250).",
305
+ ...v1,
306
+ },
307
+ {
308
+ name: "require",
309
+ kind: "global",
310
+ signature: "require(module) -> value",
311
+ summary: "Load a module once and cache it: `a.b` reads `a/b.lua` or `a/b/init.lua`.",
312
+ details:
313
+ "A plugin searches only its own directory, which its consent covers; `init.lua` searches `~/.tmux-ide/lua/`.",
314
+ errors: ["E_INVALID", "E_NOT_FOUND", "E_DENIED"],
315
+ ...v1,
316
+ },
317
+ {
318
+ name: "print",
319
+ kind: "global",
320
+ signature: "print(...)",
321
+ summary: "Same as ide.log.info with the arguments joined by tabs.",
322
+ ...v1,
323
+ },
324
+ {
325
+ name: "load",
326
+ kind: "global",
327
+ signature: "load(source, name?, mode?, env?) -> function | nil, error",
328
+ summary: "Compile Lua source text. Bytecode and reader functions are refused.",
329
+ ...v1,
330
+ },
331
+ ] satisfies ApiEntry[]);
332
+
333
+ /** The `ide.*` names the host must bind (globals are checked separately). */
334
+ export function ideTableNames(): string[] {
335
+ return API_ENTRIES.filter((entry) => entry.name.startsWith("ide.")).map((entry) => entry.name);
336
+ }
337
+
338
+ export function findApiEntry(name: string): ApiEntry | undefined {
339
+ return API_ENTRIES.find((entry) => entry.name === name);
340
+ }
341
+
342
+ /** Close matches for an unknown name, for "did you mean" hints. */
343
+ export function suggestApiEntries(name: string): ApiEntry[] {
344
+ const needle = name.toLowerCase();
345
+ return API_ENTRIES.filter((entry) => entry.name.toLowerCase().includes(needle)).slice(0, 5);
346
+ }