borgmcp 3.3.0 → 3.5.0

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 (94) hide show
  1. package/README.md +30 -5
  2. package/dist/agent-integration-health.d.ts +9 -5
  3. package/dist/agent-integration-health.d.ts.map +1 -1
  4. package/dist/agent-integration-health.js +104 -5
  5. package/dist/agent-integration-health.js.map +1 -1
  6. package/dist/backends/{launch-all-windows.d.ts → launch-all-terminals.d.ts} +5 -3
  7. package/dist/backends/launch-all-terminals.d.ts.map +1 -0
  8. package/dist/backends/{launch-all-windows.js → launch-all-terminals.js} +26 -12
  9. package/dist/backends/launch-all-terminals.js.map +1 -0
  10. package/dist/bare-launch-menu.d.ts +53 -16
  11. package/dist/bare-launch-menu.d.ts.map +1 -1
  12. package/dist/bare-launch-menu.js +95 -4
  13. package/dist/bare-launch-menu.js.map +1 -1
  14. package/dist/claude.d.ts +6 -0
  15. package/dist/claude.d.ts.map +1 -1
  16. package/dist/claude.js +84 -8
  17. package/dist/claude.js.map +1 -1
  18. package/dist/cli-help.d.ts +2 -0
  19. package/dist/cli-help.d.ts.map +1 -1
  20. package/dist/cli-help.js +31 -2
  21. package/dist/cli-help.js.map +1 -1
  22. package/dist/config-utils.d.ts +12 -6
  23. package/dist/config-utils.d.ts.map +1 -1
  24. package/dist/config-utils.js +31 -8
  25. package/dist/config-utils.js.map +1 -1
  26. package/dist/cubes.d.ts +17 -0
  27. package/dist/cubes.d.ts.map +1 -1
  28. package/dist/cubes.js +87 -1
  29. package/dist/cubes.js.map +1 -1
  30. package/dist/ensure-mcp-config.d.ts.map +1 -1
  31. package/dist/ensure-mcp-config.js +5 -2
  32. package/dist/ensure-mcp-config.js.map +1 -1
  33. package/dist/launch-all-cmd.d.ts.map +1 -1
  34. package/dist/launch-all-cmd.js +20 -10
  35. package/dist/launch-all-cmd.js.map +1 -1
  36. package/dist/log-audit-core.d.ts +7 -0
  37. package/dist/log-audit-core.d.ts.map +1 -0
  38. package/dist/log-audit-core.js +80 -0
  39. package/dist/log-audit-core.js.map +1 -0
  40. package/dist/log-audit.d.ts +3 -3
  41. package/dist/log-audit.js +7 -110
  42. package/dist/log-audit.js.map +1 -1
  43. package/dist/opencode-drone.d.ts.map +1 -1
  44. package/dist/opencode-drone.js +6 -1
  45. package/dist/opencode-drone.js.map +1 -1
  46. package/dist/opencode-plugin.d.ts +47 -7
  47. package/dist/opencode-plugin.d.ts.map +1 -1
  48. package/dist/opencode-plugin.js +187 -23
  49. package/dist/opencode-plugin.js.map +1 -1
  50. package/dist/parse-launch-all-args.d.ts +1 -1
  51. package/dist/parse-launch-all-args.d.ts.map +1 -1
  52. package/dist/parse-launch-all-args.js +3 -3
  53. package/dist/parse-launch-all-args.js.map +1 -1
  54. package/dist/regen-format.js +1 -1
  55. package/dist/regen-format.js.map +1 -1
  56. package/dist/resolved-cli-config.d.ts +1 -0
  57. package/dist/resolved-cli-config.d.ts.map +1 -1
  58. package/dist/resolved-cli-config.js +1 -0
  59. package/dist/resolved-cli-config.js.map +1 -1
  60. package/dist/seat-commands.d.ts +58 -0
  61. package/dist/seat-commands.d.ts.map +1 -0
  62. package/dist/seat-commands.js +240 -0
  63. package/dist/seat-commands.js.map +1 -0
  64. package/dist/seats.d.ts +8 -0
  65. package/dist/seats.d.ts.map +1 -1
  66. package/dist/seats.js +14 -0
  67. package/dist/seats.js.map +1 -1
  68. package/dist/unknown-subcommand.d.ts +1 -1
  69. package/dist/unknown-subcommand.d.ts.map +1 -1
  70. package/dist/unknown-subcommand.js +2 -0
  71. package/dist/unknown-subcommand.js.map +1 -1
  72. package/docs/LOCAL_SERVER.md +17 -4
  73. package/package.json +1 -1
  74. package/src/agent-integration-health.ts +121 -6
  75. package/src/backends/{launch-all-windows.ts → launch-all-terminals.ts} +33 -15
  76. package/src/bare-launch-menu.ts +141 -18
  77. package/src/claude.ts +128 -7
  78. package/src/cli-help.ts +37 -2
  79. package/src/config-utils.ts +33 -8
  80. package/src/cubes.ts +118 -1
  81. package/src/ensure-mcp-config.ts +5 -2
  82. package/src/launch-all-cmd.ts +24 -11
  83. package/src/log-audit-core.ts +81 -0
  84. package/src/log-audit.ts +6 -117
  85. package/src/opencode-drone.ts +6 -1
  86. package/src/opencode-plugin.ts +216 -22
  87. package/src/parse-launch-all-args.ts +4 -4
  88. package/src/regen-format.ts +1 -1
  89. package/src/resolved-cli-config.ts +2 -0
  90. package/src/seat-commands.ts +322 -0
  91. package/src/seats.ts +15 -0
  92. package/src/unknown-subcommand.ts +2 -0
  93. package/dist/backends/launch-all-windows.d.ts.map +0 -1
  94. package/dist/backends/launch-all-windows.js.map +0 -1
@@ -0,0 +1,322 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, realpathSync } from 'node:fs';
3
+ import {
4
+ getProjectCliPreferenceForPath,
5
+ readAllProjectIdentities,
6
+ withLaunchSeatExpectationEnv,
7
+ type ActiveCube,
8
+ type BorgCli,
9
+ type LaunchSeatExpectation,
10
+ } from './cubes.js';
11
+ import { resolveBorgPath } from './launch-all-command.js';
12
+ import { getActiveSeatForWorktree, readAllBoundSeats, seatRef, type SeatRecord } from './seats.js';
13
+
14
+ export type LocalSeatState = 'active' | 'pending';
15
+
16
+ export interface LocalSeatRow {
17
+ droneLabel: string;
18
+ droneId: string;
19
+ cubeName: string;
20
+ cubeId: string;
21
+ worktree: string;
22
+ canonicalWorktree: string | null;
23
+ credentialRef: string;
24
+ cli: BorgCli | null;
25
+ state: LocalSeatState;
26
+ }
27
+
28
+ export interface SeatCommandDeps {
29
+ readAllProjectIdentities: () => Promise<Array<{ projectPath: string; cube: ActiveCube }>>;
30
+ readAllBoundSeats: () => Promise<Array<{ worktree: string; record: SeatRecord }>>;
31
+ getActiveSeatForWorktree: (worktree: string) => Promise<SeatRecord | null>;
32
+ getProjectCliPreference: (worktree: string) => Promise<BorgCli | null>;
33
+ pathExists: (path: string) => boolean;
34
+ realpath: (path: string) => string;
35
+ /** Run this same borg executable with no args from the selected worktree,
36
+ * carrying only the expected durable identity for child-side verification. */
37
+ launchBareBorg: (worktree: string, expectation: LaunchSeatExpectation) => Promise<number>;
38
+ stdout: (line: string) => void;
39
+ stderr: (line: string) => void;
40
+ }
41
+
42
+ export type ParsedSeatsArgs = { ok: true } | { ok: false; error: string };
43
+
44
+ export function parseSeatsArgs(args: readonly string[]): ParsedSeatsArgs {
45
+ return args.length === 0
46
+ ? { ok: true }
47
+ : { ok: false, error: 'takes no arguments' };
48
+ }
49
+
50
+ export type ParsedLaunchSeatArgs =
51
+ | { ok: true; target: string; cube?: string }
52
+ | { ok: false; error: string };
53
+
54
+ export function parseLaunchSeatArgs(args: readonly string[]): ParsedLaunchSeatArgs {
55
+ let target: string | undefined;
56
+ let cube: string | undefined;
57
+
58
+ for (let i = 0; i < args.length; i++) {
59
+ const arg = args[i];
60
+ if (arg === '--cube') {
61
+ const next = args[i + 1];
62
+ if (!next || next.startsWith('-')) {
63
+ return { ok: false, error: '--cube requires a cube name' };
64
+ }
65
+ cube = next;
66
+ i += 1;
67
+ continue;
68
+ }
69
+ if (arg.startsWith('--cube=')) {
70
+ const value = arg.slice('--cube='.length);
71
+ if (!value) return { ok: false, error: '--cube requires a cube name' };
72
+ cube = value;
73
+ continue;
74
+ }
75
+ if (arg.startsWith('-')) return { ok: false, error: `unknown option: ${arg}` };
76
+ if (target !== undefined) {
77
+ return { ok: false, error: 'accepts exactly one drone label or id prefix' };
78
+ }
79
+ target = arg;
80
+ }
81
+
82
+ if (!target) return { ok: false, error: 'requires a drone label or id prefix' };
83
+ return { ok: true, target, ...(cube ? { cube } : {}) };
84
+ }
85
+
86
+ function safeRealpath(deps: SeatCommandDeps, path: string): string | null {
87
+ try {
88
+ return deps.realpath(path);
89
+ } catch {
90
+ return null;
91
+ }
92
+ }
93
+
94
+ function seatKey(cubeId: string, droneId: string): string {
95
+ return `${cubeId}\0${droneId}`;
96
+ }
97
+
98
+ export async function readLocalSeatRows(deps: SeatCommandDeps): Promise<LocalSeatRow[]> {
99
+ const [identities, boundSeats] = await Promise.all([
100
+ deps.readAllProjectIdentities(),
101
+ deps.readAllBoundSeats(),
102
+ ]);
103
+ const identityBySeat = new Map(
104
+ identities.map((entry) => [seatKey(entry.cube.cubeId, entry.cube.droneId), entry]),
105
+ );
106
+ const identityByRealpath = new Map<string, { projectPath: string; cube: ActiveCube }>();
107
+ for (const entry of identities) {
108
+ const canonical = safeRealpath(deps, entry.projectPath);
109
+ if (canonical) identityByRealpath.set(canonical, entry);
110
+ }
111
+
112
+ const rows = await Promise.all(boundSeats.map(async ({ worktree, record }) => {
113
+ const exists = deps.pathExists(worktree);
114
+ const canonicalWorktree = exists ? safeRealpath(deps, worktree) : null;
115
+ const identity = (record.droneId ? identityBySeat.get(seatKey(record.cubeId, record.droneId)) : undefined)
116
+ ?? (canonicalWorktree ? identityByRealpath.get(canonicalWorktree) : undefined);
117
+ const cube = identity?.cube;
118
+ const launchPath = identity?.projectPath ?? worktree;
119
+ const launchCanonical = deps.pathExists(launchPath) ? safeRealpath(deps, launchPath) : null;
120
+ return {
121
+ droneLabel: cube?.droneLabel ?? record.droneLabel ?? '<unknown>',
122
+ droneId: cube?.droneId ?? record.droneId ?? '',
123
+ cubeName: cube?.name ?? record.name ?? '<unknown>',
124
+ cubeId: cube?.cubeId ?? record.cubeId,
125
+ worktree: launchPath,
126
+ canonicalWorktree: launchCanonical,
127
+ credentialRef: seatRef(record),
128
+ cli: await deps.getProjectCliPreference(launchPath),
129
+ state: record.state,
130
+ };
131
+ }));
132
+
133
+ return rows.sort((a, b) =>
134
+ a.droneLabel.localeCompare(b.droneLabel)
135
+ || a.cubeName.localeCompare(b.cubeName)
136
+ || a.worktree.localeCompare(b.worktree)
137
+ );
138
+ }
139
+
140
+ function oneLine(value: string): string {
141
+ return value.replace(/[\r\n\t]/g, ' ');
142
+ }
143
+
144
+ export function formatLocalSeatRows(rows: readonly LocalSeatRow[]): string {
145
+ if (rows.length === 0) {
146
+ return 'No drone seats are registered on this machine. Run `borg assimilate` in a project repository to create one.\n';
147
+ }
148
+ const headings = ['DRONE', 'CUBE', 'STATE', 'CLI', 'WORKTREE'];
149
+ const values = rows.map((row) => [
150
+ oneLine(row.droneLabel),
151
+ oneLine(row.cubeName),
152
+ row.state,
153
+ row.cli ?? '-',
154
+ oneLine(row.worktree),
155
+ ]);
156
+ const widths = headings.slice(0, -1).map((heading, index) =>
157
+ Math.max(heading.length, ...values.map((row) => row[index].length))
158
+ );
159
+ const render = (row: string[]) =>
160
+ row.slice(0, -1).map((value, index) => value.padEnd(widths[index] + 2)).join('') + row[row.length - 1];
161
+ return `${render(headings)}\n${values.map(render).join('\n')}\n`;
162
+ }
163
+
164
+ function formatAmbiguousMatches(rows: readonly LocalSeatRow[]): string {
165
+ const labels = rows.map((row) => row.droneLabel);
166
+ const cubes = rows.map((row) => row.cubeName);
167
+ const labelWidth = Math.max(...labels.map((label) => label.length));
168
+ const cubeWidth = Math.max(...cubes.map((cube) => cube.length));
169
+ return rows.map((row) =>
170
+ ` ${row.droneLabel.padEnd(labelWidth + 2)}${row.cubeName.padEnd(cubeWidth + 2)}id:${row.droneId.slice(0, 8)}`
171
+ ).join('\n');
172
+ }
173
+
174
+ export async function runSeats(deps: SeatCommandDeps): Promise<number> {
175
+ try {
176
+ deps.stdout(formatLocalSeatRows(await readLocalSeatRows(deps)));
177
+ return 0;
178
+ } catch (error) {
179
+ deps.stderr(`borg seats: could not read the local registry: ${error instanceof Error ? error.message : String(error)}\n`);
180
+ return 1;
181
+ }
182
+ }
183
+
184
+ export async function runLaunchSeat(
185
+ args: { target: string; cube?: string },
186
+ deps: SeatCommandDeps,
187
+ ): Promise<number> {
188
+ let rows: LocalSeatRow[];
189
+ try {
190
+ rows = await readLocalSeatRows(deps);
191
+ } catch (error) {
192
+ deps.stderr(`borg launch: could not read the local registry: ${error instanceof Error ? error.message : String(error)}\n`);
193
+ return 1;
194
+ }
195
+
196
+ if (args.cube) {
197
+ const cubeIds = new Set(rows.filter((row) => row.cubeName === args.cube).map((row) => row.cubeId));
198
+ if (cubeIds.size === 0) {
199
+ deps.stderr(
200
+ `borg launch: no cube named '${args.cube}' is registered on this machine. ` +
201
+ `Run \`borg seats\` to list this machine's cubes and drones.\n`,
202
+ );
203
+ return 1;
204
+ }
205
+ rows = rows.filter((row) => cubeIds.has(row.cubeId));
206
+ }
207
+
208
+ const labelMatches = rows.filter((row) => row.droneLabel === args.target);
209
+ const matches = labelMatches.length > 0
210
+ ? labelMatches
211
+ : rows.filter((row) => row.droneId.toLowerCase().startsWith(args.target.toLowerCase()));
212
+ if (matches.length === 0) {
213
+ if (rows.length === 0) {
214
+ deps.stderr(
215
+ `borg launch: drone '${args.target}' is not in this machine's seat registry. ` +
216
+ `The registry is local to each machine and lists only drones assimilated here. ` +
217
+ `Run \`borg seats\` on the machine where the drone was created.\n`,
218
+ );
219
+ } else if (args.cube) {
220
+ deps.stderr(
221
+ `borg launch: no drone matches '${args.target}' in cube '${args.cube}'. ` +
222
+ `Run \`borg seats\` to list the drones you can launch.\n`,
223
+ );
224
+ } else {
225
+ deps.stderr(
226
+ `borg launch: no drone matches '${args.target}' on this machine. ` +
227
+ `Run \`borg seats\` to list the drones you can launch.\n`,
228
+ );
229
+ }
230
+ return 1;
231
+ }
232
+ if (matches.length > 1) {
233
+ deps.stderr(
234
+ `borg launch: '${args.target}' matches ${matches.length} drones:\n` +
235
+ `${formatAmbiguousMatches(matches)}\n` +
236
+ `Add --cube <name>, or use the drone id prefix: borg launch ${matches[0].droneId.slice(0, 8)}.\n`,
237
+ );
238
+ return 1;
239
+ }
240
+
241
+ const selected = matches[0];
242
+ if (!selected.canonicalWorktree) {
243
+ deps.stderr(
244
+ `borg launch: drone '${selected.droneLabel}' is registered at ${selected.worktree}, but that directory does not exist. ` +
245
+ `Restore the directory, or run \`borg cleanup\` to review orphaned worktrees.\n`,
246
+ );
247
+ return 1;
248
+ }
249
+ if (selected.state !== 'active') {
250
+ deps.stderr(
251
+ `borg launch: drone '${selected.droneLabel}' has a pending seat (shown as \`pending\` in \`borg seats\`) — ` +
252
+ `its assimilation did not complete, so launching now would start an unattached session. ` +
253
+ `To complete the seat, run \`borg assimilate\` in ${selected.worktree}, then run ` +
254
+ `\`borg launch ${selected.droneLabel}\` again.\n`,
255
+ );
256
+ return 1;
257
+ }
258
+
259
+ let preferred: SeatRecord | null;
260
+ try {
261
+ preferred = await deps.getActiveSeatForWorktree(selected.canonicalWorktree);
262
+ } catch {
263
+ preferred = null;
264
+ }
265
+ if (!preferred) {
266
+ deps.stderr(
267
+ `borg launch: did not launch '${selected.droneLabel}' — its seat registration changed before the launch could start. ` +
268
+ `Run \`borg seats\` to see the current state, then try again.\n`,
269
+ );
270
+ return 1;
271
+ }
272
+ if (
273
+ seatRef(preferred) !== selected.credentialRef ||
274
+ preferred.cubeId !== selected.cubeId ||
275
+ preferred.droneId !== selected.droneId
276
+ ) {
277
+ deps.stderr(
278
+ `borg launch: did not launch '${selected.droneLabel}' — the worktree at ${selected.worktree} would resume ` +
279
+ `'${preferred.droneLabel}' (cube '${preferred.name}') instead. To resume '${preferred.droneLabel}', run \`borg\` ` +
280
+ `in that worktree. To review this machine's seats, run \`borg seats\`.\n`,
281
+ );
282
+ return 1;
283
+ }
284
+
285
+ const expectation: LaunchSeatExpectation = {
286
+ credentialRef: selected.credentialRef,
287
+ cubeId: selected.cubeId,
288
+ droneId: selected.droneId,
289
+ worktree: selected.canonicalWorktree,
290
+ droneLabel: selected.droneLabel,
291
+ };
292
+
293
+ try {
294
+ return await deps.launchBareBorg(selected.canonicalWorktree, expectation);
295
+ } catch (error) {
296
+ deps.stderr(`borg launch: failed to start borg in ${selected.canonicalWorktree}: ${error instanceof Error ? error.message : String(error)}\n`);
297
+ return 1;
298
+ }
299
+ }
300
+
301
+ export function buildDefaultSeatCommandDeps(): SeatCommandDeps {
302
+ return {
303
+ readAllProjectIdentities,
304
+ readAllBoundSeats,
305
+ getActiveSeatForWorktree,
306
+ getProjectCliPreference: getProjectCliPreferenceForPath,
307
+ pathExists: existsSync,
308
+ realpath: realpathSync,
309
+ launchBareBorg: (worktree, expectation) => new Promise((resolve, reject) => {
310
+ const child = spawn(resolveBorgPath(), [], {
311
+ cwd: worktree,
312
+ stdio: 'inherit',
313
+ shell: false,
314
+ env: withLaunchSeatExpectationEnv(process.env, expectation),
315
+ });
316
+ child.once('error', reject);
317
+ child.once('exit', (code, signal) => resolve(signal ? 1 : code ?? 1));
318
+ }),
319
+ stdout: (line) => process.stdout.write(line),
320
+ stderr: (line) => process.stderr.write(line),
321
+ };
322
+ }
package/src/seats.ts CHANGED
@@ -675,6 +675,21 @@ export async function readAllActiveSeats(): Promise<Array<{ worktree: string; re
675
675
  return out;
676
676
  }
677
677
 
678
+ /** All valid worktree-bound registry entries, including a PENDING seat whose
679
+ * interrupted finalize preserved its worktree for a later resume. Read-only:
680
+ * pending records remain non-hydratable and getActiveSeatForWorktree stays
681
+ * active-only. */
682
+ export async function readAllBoundSeats(): Promise<Array<{ worktree: string; record: SeatRecord }>> {
683
+ const store = await readStore();
684
+ const out: Array<{ worktree: string; record: SeatRecord }> = [];
685
+ for (const [ref, record] of Object.entries(store.seats)) {
686
+ if (typeof record.worktree === 'string' && seatRef(record) === ref) {
687
+ out.push({ worktree: record.worktree, record });
688
+ }
689
+ }
690
+ return out;
691
+ }
692
+
678
693
  // ─── Reset / scrub / metadata (all single-commit) ────────────────────────────
679
694
 
680
695
  export type ResetSeatOutcome =
@@ -21,6 +21,8 @@ export const KNOWN_SUBCOMMANDS = [
21
21
  'recover-enrollment',
22
22
  'spawn',
23
23
  'cleanup',
24
+ 'seats',
25
+ 'launch',
24
26
  'launch-all',
25
27
  'server',
26
28
  ] as const;
@@ -1 +0,0 @@
1
- {"version":3,"file":"launch-all-windows.d.ts","sourceRoot":"","sources":["../../src/backends/launch-all-windows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,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