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.
Files changed (145) hide show
  1. package/bin/cli.js +16998 -4283
  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 +3 -0
  7. package/packages/contracts/src/pane-reader.ts +121 -0
  8. package/packages/contracts/src/pane-stream.ts +18 -0
  9. package/packages/contracts/src/plain-text.ts +61 -0
  10. package/packages/contracts/src/visual-theme-presets.ts +58 -2
  11. package/packages/daemon/dist/command-center/command-catalog-routes.js +78 -0
  12. package/packages/daemon/dist/command-center/plugin-routes.js +84 -0
  13. package/packages/daemon/dist/command-center/server.js +13 -0
  14. package/packages/daemon/dist/command-center/tmux-server-reader.js +41 -0
  15. package/packages/daemon/dist/command-center/tmux-servers.js +6 -0
  16. package/packages/daemon/dist/doctor.js +106 -43
  17. package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
  18. package/packages/daemon/dist/lib/cli-command.js +13 -0
  19. package/packages/daemon/dist/lib/daemon-embed.js +39 -1
  20. package/packages/daemon/dist/lib/headless-daemon.js +1 -0
  21. package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
  22. package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
  23. package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
  24. package/packages/daemon/dist/lib/tmux-pane-reader.js +105 -0
  25. package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
  26. package/packages/daemon/dist/lib/tmux-server-owner.js +9 -0
  27. package/packages/daemon/dist/lib/worktree.js +18 -0
  28. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  29. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  30. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  31. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  32. package/packages/daemon/dist/open-browser.js +26 -12
  33. package/packages/daemon/dist/open-reader.js +84 -0
  34. package/packages/daemon/dist/plugins/action-catalog.js +129 -0
  35. package/packages/daemon/dist/plugins/action-cli.js +212 -0
  36. package/packages/daemon/dist/plugins/api-table.js +303 -0
  37. package/packages/daemon/dist/plugins/cli.js +556 -0
  38. package/packages/daemon/dist/plugins/consent.js +107 -0
  39. package/packages/daemon/dist/plugins/daemon-plugins.js +124 -0
  40. package/packages/daemon/dist/plugins/discovery.js +142 -0
  41. package/packages/daemon/dist/plugins/examples/worktree-tasks.js +115 -0
  42. package/packages/daemon/dist/plugins/exec-sandbox.js +202 -0
  43. package/packages/daemon/dist/plugins/host/actions-prelude.js +279 -0
  44. package/packages/daemon/dist/plugins/host/entry.js +4 -0
  45. package/packages/daemon/dist/plugins/host/host-api-prelude.js +232 -0
  46. package/packages/daemon/dist/plugins/host/lua-state.js +493 -0
  47. package/packages/daemon/dist/plugins/host/main.js +322 -0
  48. package/packages/daemon/dist/plugins/host/sandbox.js +299 -0
  49. package/packages/daemon/dist/plugins/host-calls.js +279 -0
  50. package/packages/daemon/dist/plugins/manifest.js +69 -0
  51. package/packages/daemon/dist/plugins/plugin-exec.js +261 -0
  52. package/packages/daemon/dist/plugins/plugin-log.js +54 -0
  53. package/packages/daemon/dist/plugins/plugin-store.js +74 -0
  54. package/packages/daemon/dist/plugins/protocol.js +252 -0
  55. package/packages/daemon/dist/plugins/safe-files.js +97 -0
  56. package/packages/daemon/dist/plugins/supervisor.js +790 -0
  57. package/packages/daemon/dist/plugins/worktree-calls.js +154 -0
  58. package/packages/daemon/dist/restore.js +57 -40
  59. package/packages/daemon/dist/terminal/mirror/session-channel.js +4 -1
  60. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +12 -3
  61. package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
  62. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +7 -2
  63. package/packages/daemon/dist/tmux-upgrade/cli.js +106 -0
  64. package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
  65. package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
  66. package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
  67. package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
  68. package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
  69. package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +62 -5
  70. package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
  71. package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
  72. package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +30 -2
  73. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-commands.js +152 -0
  74. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-form.js +251 -0
  75. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
  76. package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +14 -0
  77. package/packages/daemon/dist/tui/mirror/workspace/palette-list-layout.js +5 -0
  78. package/packages/daemon/src/command-center/command-catalog-routes.ts +116 -0
  79. package/packages/daemon/src/command-center/plugin-routes.ts +110 -0
  80. package/packages/daemon/src/command-center/server.ts +15 -0
  81. package/packages/daemon/src/command-center/tmux-server-reader.ts +62 -0
  82. package/packages/daemon/src/command-center/tmux-servers.ts +6 -0
  83. package/packages/daemon/src/doctor.ts +118 -45
  84. package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
  85. package/packages/daemon/src/lib/cli-command.ts +16 -0
  86. package/packages/daemon/src/lib/daemon-embed.ts +59 -0
  87. package/packages/daemon/src/lib/headless-daemon.ts +1 -0
  88. package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
  89. package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
  90. package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
  91. package/packages/daemon/src/lib/tmux-pane-reader.ts +144 -0
  92. package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
  93. package/packages/daemon/src/lib/tmux-server-owner.ts +9 -0
  94. package/packages/daemon/src/lib/worktree.ts +16 -0
  95. package/packages/daemon/src/open-browser.ts +59 -18
  96. package/packages/daemon/src/open-reader.ts +148 -0
  97. package/packages/daemon/src/plugins/action-catalog.ts +141 -0
  98. package/packages/daemon/src/plugins/action-cli.ts +248 -0
  99. package/packages/daemon/src/plugins/api-table.ts +346 -0
  100. package/packages/daemon/src/plugins/cli.ts +630 -0
  101. package/packages/daemon/src/plugins/consent.ts +125 -0
  102. package/packages/daemon/src/plugins/daemon-plugins.ts +172 -0
  103. package/packages/daemon/src/plugins/discovery.ts +176 -0
  104. package/packages/daemon/src/plugins/examples/worktree-tasks.ts +120 -0
  105. package/packages/daemon/src/plugins/exec-sandbox.ts +264 -0
  106. package/packages/daemon/src/plugins/host/actions-prelude.ts +280 -0
  107. package/packages/daemon/src/plugins/host/entry.ts +5 -0
  108. package/packages/daemon/src/plugins/host/host-api-prelude.ts +233 -0
  109. package/packages/daemon/src/plugins/host/lua-state.ts +557 -0
  110. package/packages/daemon/src/plugins/host/main.ts +359 -0
  111. package/packages/daemon/src/plugins/host/sandbox.ts +301 -0
  112. package/packages/daemon/src/plugins/host-calls.ts +343 -0
  113. package/packages/daemon/src/plugins/manifest.ts +74 -0
  114. package/packages/daemon/src/plugins/plugin-exec.ts +326 -0
  115. package/packages/daemon/src/plugins/plugin-log.ts +63 -0
  116. package/packages/daemon/src/plugins/plugin-store.ts +80 -0
  117. package/packages/daemon/src/plugins/protocol.ts +275 -0
  118. package/packages/daemon/src/plugins/safe-files.ts +105 -0
  119. package/packages/daemon/src/plugins/supervisor.ts +954 -0
  120. package/packages/daemon/src/plugins/worktree-calls.ts +183 -0
  121. package/packages/daemon/src/restore.ts +80 -44
  122. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  123. package/packages/daemon/src/terminal/mirror/session-channel.ts +6 -1
  124. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +15 -2
  125. package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
  126. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
  127. package/packages/daemon/src/tmux-upgrade/cli.ts +118 -0
  128. package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
  129. package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
  130. package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
  131. package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
  132. package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
  133. package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
  134. package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +90 -6
  135. package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
  136. package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
  137. package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +42 -2
  138. package/packages/daemon/src/tui/mirror/runtime/application-palette-preview.tsx +7 -1
  139. package/packages/daemon/src/tui/mirror/runtime/application-plugin-commands.ts +229 -0
  140. package/packages/daemon/src/tui/mirror/runtime/application-plugin-form.ts +312 -0
  141. package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
  142. package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
  143. package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +44 -2
  144. package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
  145. package/packages/tmux-bridge/src/runner.ts +3 -1
@@ -0,0 +1,233 @@
1
+ /**
2
+ * The rest of the `ide` API: exec, panes, sessions, timers, json, store and
3
+ * notify. Runs after SANDBOX_PRELUDE and ACTIONS_PRELUDE and reaches them
4
+ * only through `__ide_internal`. Daemon-side work goes through the private
5
+ * host functions in `__ide_internal.host` (see ../host-calls.ts).
6
+ */
7
+ export const MAX_TIMERS_PER_PLUGIN = 64;
8
+ export const MIN_REPEAT_MS = 250;
9
+
10
+ export const HOST_API_PRELUDE = String.raw`
11
+ local internal = __ide_internal
12
+ local timer_start, timer_cancel, json_decode_raw = __ide_timer_start, __ide_timer_cancel, __ide_json_decode
13
+ __ide_timer_start, __ide_timer_cancel, __ide_json_decode = nil, nil, nil
14
+
15
+ local ide, host, arm, runners = internal.ide, internal.host, internal.arm, internal.runners
16
+ local json_encode = internal.json_encode
17
+ local raw_error, raw_type, raw_pairs, raw_ipairs, raw_tostring, raw_setmetatable =
18
+ error, type, pairs, ipairs, tostring, setmetatable
19
+ local m_type = math.type
20
+ local co_running = coroutine.running
21
+ local MAX_TIMERS, MIN_REPEAT = ${MAX_TIMERS_PER_PLUGIN}, ${MIN_REPEAT_MS}
22
+
23
+ local function fail(message) raw_error("E_INVALID: " .. message, 3) end
24
+ local function call(name, ...)
25
+ local fn = host[name]
26
+ if not fn then raw_error("E_UNAVAILABLE: this tmux-ide has no " .. name, 3) end
27
+ return fn(...)
28
+ end
29
+
30
+ ----------------------------------------------------------------------- exec
31
+
32
+ ide.exec = function(spec)
33
+ if raw_type(spec) ~= "table" then fail("ide.exec expects a table like { cmd = 'git', args = {...} }") end
34
+ local request = {}
35
+ for _, key in raw_ipairs({ "cmd", "cwd", "stdin", "timeout_ms", "context", "shell" }) do
36
+ request[key] = spec[key]
37
+ end
38
+ if spec.args ~= nil then
39
+ if raw_type(spec.args) ~= "table" then fail("ide.exec args must be a list of strings") end
40
+ local args = {}
41
+ for i, value in raw_ipairs(spec.args) do args[i] = raw_tostring(value) end
42
+ request.args = args
43
+ end
44
+ if spec.env ~= nil then
45
+ if raw_type(spec.env) ~= "table" then fail("ide.exec env must be a table of strings") end
46
+ local env = {}
47
+ for key, value in raw_pairs(spec.env) do env[raw_tostring(key)] = raw_tostring(value) end
48
+ request.env = env
49
+ end
50
+ return call("_exec", request)
51
+ end
52
+
53
+ ------------------------------------------------------------------ worktree
54
+
55
+ local function worktree_call(op)
56
+ return function(spec)
57
+ if raw_type(spec) ~= "table" then
58
+ fail("ide.worktree." .. op .. " expects a table like { session = ctx.session, branch = 'fix-login' }")
59
+ end
60
+ return call("_worktree", op, { session = spec.session, branch = spec.branch, from = spec.from })
61
+ end
62
+ end
63
+
64
+ ide.worktree = {
65
+ list = worktree_call("list"),
66
+ create = worktree_call("create"),
67
+ open = worktree_call("open"),
68
+ remove = worktree_call("remove"),
69
+ }
70
+
71
+ -------------------------------------------------------------------- notify
72
+
73
+ ide.notify = function(text, opts)
74
+ local level = raw_type(opts) == "table" and opts.level or nil
75
+ return call("_notify", raw_tostring(text), level)
76
+ end
77
+
78
+ ---------------------------------------------------------------------- json
79
+
80
+ ide.json = {
81
+ encode = function(value) return json_encode(value) end,
82
+ decode = function(text)
83
+ if raw_type(text) ~= "string" then fail("ide.json.decode expects a string") end
84
+ return json_decode_raw(text)
85
+ end,
86
+ }
87
+
88
+ --------------------------------------------------------------------- store
89
+
90
+ ide.store = {
91
+ get = function(key) return call("_store_get", key) end,
92
+ set = function(key, value) return call("_store_set", key, value) end,
93
+ delete = function(key) return call("_store_set", key, nil) end,
94
+ keys = function() return call("_store_keys") end,
95
+ }
96
+
97
+ -------------------------------------------------------------------- timers
98
+
99
+ local timers = {}
100
+ local timer_count = 0
101
+ local next_timer = 0
102
+
103
+ local function cancel(id)
104
+ if timers[id] == nil then return false end
105
+ timers[id] = nil
106
+ timer_count = timer_count - 1
107
+ timer_cancel(id)
108
+ return true
109
+ end
110
+
111
+ local function start(ms, fn, repeating)
112
+ if raw_type(fn) ~= "function" then fail("timer callback must be a function") end
113
+ if raw_type(ms) ~= "number" or ms ~= ms or ms < 0 or ms > 86400000 then
114
+ fail("timer delay must be a number of milliseconds")
115
+ end
116
+ if repeating and ms < MIN_REPEAT then fail("ide.timer.every needs at least " .. MIN_REPEAT .. " ms") end
117
+ if timer_count >= MAX_TIMERS then fail("a plugin may have at most " .. MAX_TIMERS .. " timers") end
118
+ next_timer = next_timer + 1
119
+ local id = next_timer
120
+ timers[id] = { fn = fn, repeating = repeating }
121
+ timer_count = timer_count + 1
122
+ timer_start(id, math.floor(ms), repeating)
123
+ return { id = id, cancel = function() return cancel(id) end }
124
+ end
125
+
126
+ ide.timer = {
127
+ after = function(ms, fn) return start(ms, fn, false) end,
128
+ every = function(ms, fn) return start(ms, fn, true) end,
129
+ }
130
+
131
+ internal.run_timer = function(id)
132
+ runners[co_running()] = true
133
+ arm()
134
+ local timer = timers[id]
135
+ if not timer then return "[]" end
136
+ if not timer.repeating then
137
+ timers[id] = nil
138
+ timer_count = timer_count - 1
139
+ end
140
+ timer.fn()
141
+ return "[]"
142
+ end
143
+
144
+ -------------------------------------------------- panes, windows, sessions
145
+
146
+ local Pane = {}
147
+ Pane.__index = Pane
148
+
149
+ local function pane_object(raw)
150
+ local endpoint = raw.endpoint
151
+ return raw_setmetatable({
152
+ id = endpoint.semanticPaneId,
153
+ workspace = endpoint.workspaceName,
154
+ session = raw.session,
155
+ title = raw.title,
156
+ endpoint = endpoint,
157
+ }, Pane)
158
+ end
159
+
160
+ local function action(name, input) return call("_action", name, input) end
161
+
162
+ function Pane:read() return call("_pane_read", self.endpoint) end
163
+ function Pane:send(text, opts)
164
+ if raw_type(text) ~= "string" or #text == 0 then fail("pane:send expects text") end
165
+ local enter = not (raw_type(opts) == "table" and opts.enter == false)
166
+ return call("_pane_send", self.endpoint, text, enter)
167
+ end
168
+ function Pane:split(opts)
169
+ opts = opts or {}
170
+ local direction = opts.dir or "right"
171
+ if direction ~= "right" and direction ~= "down" then fail("pane:split dir must be 'right' or 'down'") end
172
+ return action("workspace.window.split", {
173
+ workspaceName = self.workspace, semanticPaneId = self.id,
174
+ direction = direction, displayTitle = opts.title,
175
+ })
176
+ end
177
+ function Pane:zoom(on)
178
+ local desired = on == nil and "toggle" or (on and "zoomed" or "unzoomed")
179
+ return action("workspace.pane.zoom.toggle", {
180
+ workspaceName = self.workspace, semanticPaneId = self.id, desired = desired,
181
+ })
182
+ end
183
+ function Pane:focus()
184
+ return action("workspace.pane.select", { workspaceName = self.workspace, semanticPaneId = self.id })
185
+ end
186
+ function Pane:rename(name)
187
+ return action("workspace.rename", {
188
+ workspaceName = self.workspace, scope = "pane", semanticPaneId = self.id, name = name,
189
+ })
190
+ end
191
+ function Pane:kill()
192
+ return action("workspace.pane.kill", { workspaceName = self.workspace, semanticPaneId = self.id })
193
+ end
194
+ function Pane:rename_window(name)
195
+ return action("workspace.rename", {
196
+ workspaceName = self.workspace, scope = "window",
197
+ target = { by = "pane", semanticPaneId = self.id }, name = name,
198
+ })
199
+ end
200
+ function Pane:kill_window()
201
+ return action("workspace.window.kill", {
202
+ workspaceName = self.workspace, target = { by = "pane", semanticPaneId = self.id },
203
+ })
204
+ end
205
+
206
+ ide.panes = function(filter)
207
+ local out = {}
208
+ for _, raw in raw_ipairs(call("_panes")) do
209
+ local pane = pane_object(raw)
210
+ if raw_type(filter) ~= "table"
211
+ or ((filter.session == nil or filter.session == pane.session)
212
+ and (filter.workspace == nil or filter.workspace == pane.workspace)) then
213
+ out[#out + 1] = pane
214
+ end
215
+ end
216
+ return out
217
+ end
218
+
219
+ ide.session = function(workspace)
220
+ if raw_type(workspace) ~= "string" or #workspace == 0 then fail("ide.session expects a workspace name") end
221
+ return {
222
+ workspace = workspace,
223
+ rename = function(_, name)
224
+ return action("workspace.rename", { workspaceName = workspace, scope = "session", name = name })
225
+ end,
226
+ kill = function() return action("workspace.session.kill", { workspaceName = workspace }) end,
227
+ }
228
+ end
229
+
230
+ for _, feature in raw_ipairs({ "exec", "panes", "timers", "json", "store", "notify" }) do
231
+ internal.features[feature] = true
232
+ end
233
+ `;