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.
- package/bin/cli.js +14703 -3882
- 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 +2 -0
- package/packages/contracts/src/plain-text.ts +61 -0
- 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/doctor.js +12 -5
- package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
- package/packages/daemon/dist/lib/daemon-embed.js +24 -1
- package/packages/daemon/dist/lib/headless-daemon.js +1 -0
- package/packages/daemon/dist/lib/native-split-capability.js +13 -15
- 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/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 +132 -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/terminal/mirror/session-channel.js +3 -2
- package/packages/daemon/dist/terminal/mirror/window-split-authority.js +1 -1
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
- 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/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/doctor.ts +12 -5
- package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
- package/packages/daemon/src/lib/daemon-embed.ts +42 -0
- package/packages/daemon/src/lib/headless-daemon.ts +1 -0
- package/packages/daemon/src/lib/native-split-capability.ts +12 -13
- package/packages/daemon/src/lib/worktree.ts +16 -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 +182 -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/terminal/mirror/session-channel.ts +3 -2
- package/packages/daemon/src/terminal/mirror/window-split-authority.ts +3 -2
- package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +32 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
- 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/workspace/application-command-description.ts +44 -2
- package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
|
@@ -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
|
+
`;
|