@mdsohail99/opencode-agent-teams 2.0.0 → 2.1.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.
package/bin/menu.mjs DELETED
@@ -1,582 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { createInterface } from "node:readline"
4
- import { cp, mkdir, readFile, writeFile, rm, readdir } from "node:fs/promises"
5
- import { existsSync } from "node:fs"
6
- import { join, dirname } from "node:path"
7
- import { fileURLToPath } from "node:url"
8
- import { spawnSync } from "node:child_process"
9
- import { uninstall, revert, status, deleteBackup } from "./uninstall.mjs"
10
- import { killRelayProcesses, killOrphanedServeProcesses, rmRetry } from "./lib/relay-process.mjs"
11
- import { mergeSubagentDepth } from "./lib/merge-subagent-depth.mjs"
12
- import { mergeSlashCommands } from "./lib/merge-commands.mjs"
13
- import { mergeSchema } from "./lib/merge-schema.mjs"
14
- import { mergeEnvFlags } from "./lib/merge-env-flags.mjs"
15
- import { resolveConfigRoot } from "./lib/config-root.mjs"
16
- import { removeRuntimeStateDirs } from "./lib/runtime-state.mjs"
17
- import { parkPlugin, removeParkedPlugin } from "./lib/plugin-park.mjs"
18
-
19
- // --- ANSI colors ---
20
- const c = {
21
- reset: "\x1b[0m",
22
- bold: "\x1b[1m",
23
- dim: "\x1b[2m",
24
- red: "\x1b[31m",
25
- green: "\x1b[32m",
26
- yellow: "\x1b[33m",
27
- blue: "\x1b[34m",
28
- magenta: "\x1b[35m",
29
- cyan: "\x1b[36m",
30
- white: "\x1b[37m",
31
- bgBlue: "\x1b[44m",
32
- bgGreen: "\x1b[42m",
33
- bgRed: "\x1b[41m",
34
- }
35
-
36
- const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..")
37
-
38
- const argv = process.argv.slice(2)
39
- const configDirIndex = argv.indexOf("--config-dir")
40
- if (configDirIndex !== -1 && argv[configDirIndex + 1]) {
41
- process.env.OPENCODE_CONFIG_DIR = argv[configDirIndex + 1]
42
- }
43
-
44
- // Config dir is the SAME for both modes (~/.config/opencode); the mode only
45
- // decides plugin placement (parked in plugins-disabled/ for agents-only,
46
- // active in plugins/ for full). On launch we auto-detect an existing
47
- // installation; once the user picks a mode (install/reinstall), the root is
48
- // re-targeted to that mode's dir.
49
- let configRoot = resolveConfigRoot()
50
-
51
- function targetConfigRoot(mode) {
52
- configRoot = resolveConfigRoot(mode)
53
- }
54
-
55
- const MANAGED_DIRS = ["agents", "plugins", "relay"]
56
- // Legacy scrub: `<configRoot>/.relay-token` is deprecated — no current runtime
57
- // code reads it (relay + plugin use per-port tokens under LOCALAPPDATA). Kept
58
- // for historical compatibility / world-readable secret; runtime dirs are
59
- // scrubbed separately via removeRuntimeStateDirs() in cleanManaged().
60
- const MANAGED_FILES = [".relay-token"]
61
- const VERSION_FILE = () => join(configRoot, ".installed-version")
62
- const BACKUP_ROOT = () => join(configRoot, ".backups")
63
-
64
- // --- Helpers ---
65
-
66
- async function getCurrentVersion() {
67
- if (!existsSync(VERSION_FILE())) return null
68
- return (await readFile(VERSION_FILE(), "utf-8")).trim()
69
- }
70
-
71
- async function listBackups() {
72
- if (!existsSync(BACKUP_ROOT())) return []
73
- const entries = await readdir(BACKUP_ROOT())
74
- const backups = []
75
- for (const name of entries) {
76
- const dir = join(BACKUP_ROOT(), name)
77
- let version = "unknown"
78
- // New backups use .backup-version, old ones use .installed-version
79
- for (const vf of [".backup-version", ".installed-version"]) {
80
- try {
81
- version = (await readFile(join(dir, vf), "utf-8")).trim()
82
- break
83
- } catch {}
84
- }
85
- backups.push({ name, dir, version })
86
- }
87
- return backups.sort((a, b) => b.name.localeCompare(a.name))
88
- }
89
-
90
- function clearScreen() {
91
- process.stdout.write("\x1b[2J\x1b[H")
92
- }
93
-
94
- function printHeader() {
95
- console.log("")
96
- console.log(`${c.bold}${c.cyan} ╔═══════════════════════════════════════════╗${c.reset}`)
97
- console.log(`${c.bold}${c.cyan} ║ ${c.white}Agent-Teams Orchestration${c.cyan} ║${c.reset}`)
98
- console.log(`${c.bold}${c.cyan} ╚═══════════════════════════════════════════╝${c.reset}`)
99
- console.log("")
100
- }
101
-
102
- function printBox(lines) {
103
- const maxLen = Math.max(...lines.map((l) => l.replace(/\x1b\[[0-9;]*m/g, "").length))
104
- console.log(`${c.dim} ┌${"─".repeat(maxLen + 2)}┐${c.reset}`)
105
- for (const line of lines) {
106
- const plainLen = line.replace(/\x1b\[[0-9;]*m/g, "").length
107
- const pad = " ".repeat(maxLen - plainLen)
108
- console.log(`${c.dim} │${c.reset} ${line}${pad} ${c.dim}│${c.reset}`)
109
- }
110
- console.log(`${c.dim} └${"─".repeat(maxLen + 2)}┘${c.reset}`)
111
- }
112
-
113
- function prompt(rl, question) {
114
- return new Promise((resolve) => {
115
- rl.question(question, (answer) => resolve(answer.trim()))
116
- })
117
- }
118
-
119
- function promptChoice(rl, question, options) {
120
- return new Promise((resolve) => {
121
- console.log("")
122
- for (let i = 0; i < options.length; i++) {
123
- console.log(` ${c.cyan}${i + 1}${c.reset} ${options[i].label}`)
124
- }
125
- console.log("")
126
- rl.question(` ${c.dim}Choose [1-${options.length}]${c.reset}: `, (answer) => {
127
- const idx = parseInt(answer, 10) - 1
128
- if (idx >= 0 && idx < options.length) {
129
- resolve(options[idx])
130
- } else {
131
- resolve(null)
132
- }
133
- })
134
- })
135
- }
136
-
137
- // --- Install logic ---
138
-
139
- const EXCLUDE_DIRS = new Set(["node_modules", ".backups", ".git"])
140
- const EXCLUDE_FILES = new Set([".relay-token", "bun.lock", "package-lock.json"])
141
-
142
- async function copyTree(source, target) {
143
- await mkdir(target, { recursive: true })
144
- await cp(source, target, { recursive: true, force: true })
145
- }
146
-
147
- async function copyTreeExcluded(source, target, excludeDirs, excludeFiles) {
148
- await mkdir(target, { recursive: true })
149
- const entries = await readdir(source, { withFileTypes: true })
150
- for (const entry of entries) {
151
- const srcPath = join(source, entry.name)
152
- const dstPath = join(target, entry.name)
153
- if (entry.isDirectory()) {
154
- if (!excludeDirs.has(entry.name)) {
155
- await copyTreeExcluded(srcPath, dstPath, excludeDirs, excludeFiles)
156
- }
157
- } else {
158
- if (!excludeFiles.has(entry.name)) {
159
- await cp(srcPath, dstPath, { force: true })
160
- }
161
- }
162
- }
163
- }
164
-
165
- async function backupExisting() {
166
- if (!existsSync(VERSION_FILE()) && !existsSync(join(configRoot, "agents"))) return null
167
-
168
- const prevVersion = existsSync(VERSION_FILE())
169
- ? (await readFile(VERSION_FILE(), "utf-8")).trim()
170
- : "pre-install"
171
- const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19)
172
- const backupDir = join(BACKUP_ROOT(), `${prevVersion}-${timestamp}`)
173
-
174
- console.log(` ${c.dim}Backing up config directory...${c.reset}`)
175
- await copyTreeExcluded(configRoot, backupDir, EXCLUDE_DIRS, EXCLUDE_FILES)
176
- await writeFile(join(backupDir, ".backup-version"), prevVersion, "utf-8")
177
- return { version: prevVersion, dir: backupDir }
178
- }
179
-
180
- async function getInstalledMode() {
181
- const modeFile = join(configRoot, ".installed-mode")
182
- if (existsSync(modeFile)) {
183
- return (await readFile(modeFile, "utf-8")).trim() === "agents" ? "agents" : "full"
184
- }
185
- return "full"
186
- }
187
-
188
- async function cleanManaged(mode) {
189
- console.log(" Stopping any running Agent-Teams relay...")
190
- await killRelayProcesses()
191
-
192
- // Reap orphaned auxiliary `opencode serve` processes (parent already dead)
193
- // so their old in-memory plugin can't respawn relays/state dirs after the
194
- // cleanup. Only opencode.exe processes with a `serve` argument whose parent
195
- // PID no longer exists are killed.
196
- await killOrphanedServeProcesses()
197
-
198
- // Scrub RUNTIME token/state dirs from previous runs
199
- // (%LOCALAPPDATA%\opencode\agent-teams\<port> — the live shared-secret the
200
- // plugin reads). Only plugin-owned per-port dirs (token/token.tmp/relay.log/
201
- // server.log + WAL/checkpoint state files) are removed, never user files that happen
202
- // to sit under the state root.
203
- const runtime = await removeRuntimeStateDirs()
204
- if (runtime.removed > 0) {
205
- console.log(` Removed ${runtime.removed} stale runtime token/log dir(s) under ${runtime.root}`)
206
- }
207
- if (runtime.skipped > 0) {
208
- console.warn(` Skipped ${runtime.skipped} dir(s) under ${runtime.root}: contain non-plugin files (kept)`)
209
- }
210
-
211
- if (mode === "agents") {
212
- // Surgical: remove only agent-teams artifacts, never other user plugins.
213
- for (const dir of ["agents", "relay"]) {
214
- const target = join(configRoot, dir)
215
- if (existsSync(target)) await rmRetry(target)
216
- }
217
- // Park (not delete) our plugin: moving it into plugins-disabled/ takes it
218
- // out of autodiscovery (`{plugin,plugins}/*.{ts,js}`) so the native fork's
219
- // compiled-in next_agent/agents_status run collision-free; a later `full`
220
- // install restores it.
221
- if (parkPlugin(configRoot)) {
222
- console.log(` ${c.dim}Parked plugin into plugins-disabled/ (native-fork mode).${c.reset}`)
223
- }
224
- const token = join(configRoot, ".relay-token") // legacy scrub; runtime tokens live under LOCALAPPDATA
225
- if (existsSync(token)) await rmRetry(token)
226
- } else {
227
- for (const dir of MANAGED_DIRS) {
228
- const target = join(configRoot, dir)
229
- if (existsSync(target)) await rmRetry(target)
230
- }
231
- for (const file of MANAGED_FILES) {
232
- const target = join(configRoot, file)
233
- if (existsSync(target)) await rmRetry(target)
234
- }
235
- // Full mode re-activates the plugin: drop any parked copy from an earlier
236
- // agents-only install in this same config root.
237
- await removeParkedPlugin(configRoot)
238
- }
239
- }
240
-
241
- async function installFiles(mode) {
242
- await copyTree(join(packageRoot, "agents", "orchestrators"), join(configRoot, "agents"))
243
- await copyTree(join(packageRoot, "agents", "specialists"), join(configRoot, "agents"))
244
- if (mode === "agents") {
245
- // Fork-correct Agent-Teams: on the native fork (no relay) the orchestrator
246
- // must use Task(background=true)/next_agent/agents_status, not running_agents.
247
- // Overwrite the relay-based orchestrator with the fork variant.
248
- const forkAgent = join(packageRoot, "agents", "orchestrators-fork", "orchestrator-agent-teams.md")
249
- if (existsSync(forkAgent)) {
250
- await cp(forkAgent, join(configRoot, "agents", "orchestrator-agent-teams.md"), { force: true })
251
- console.log(` ${c.dim}Fork mode: installed native Agent-Teams orchestrator.${c.reset}`)
252
- }
253
- } else {
254
- // Full (stock) mode: restore the relay-based orchestrator OVER any fork
255
- // variant left by an earlier agents-only install in this same config root
256
- // (the copyTree above already overwrites; this makes the restore explicit).
257
- const originalAgent = join(packageRoot, "agents", "orchestrators", "orchestrator-agent-teams.md")
258
- if (existsSync(originalAgent)) {
259
- await cp(originalAgent, join(configRoot, "agents", "orchestrator-agent-teams.md"), { force: true })
260
- console.log(` ${c.dim}Full mode: installed relay-based Agent-Teams orchestrator.${c.reset}`)
261
- }
262
- }
263
- if (mode === "full") {
264
- await copyTree(join(packageRoot, "plugins"), join(configRoot, "plugins"))
265
- await copyTree(join(packageRoot, "relay"), join(configRoot, "relay"))
266
- }
267
- }
268
-
269
- async function writeModeMarker(mode) {
270
- await writeFile(join(configRoot, ".installed-mode"), mode, "utf-8")
271
- }
272
-
273
- async function promptMode(rl) {
274
- const options = [
275
- {
276
- label: `${c.bold}Full${c.reset} — agents + plugin + relay (stock opencode)`,
277
- value: "full",
278
- },
279
- {
280
- label: `${c.bold}Agents-only${c.reset} — curated agents + AGENTS.md only (native fork)`,
281
- value: "agents",
282
- },
283
- ]
284
- const choice = await promptChoice(rl, " Select install mode:", options)
285
- return choice?.value ?? "full"
286
- }
287
-
288
- async function pruneBackups() {
289
- if (!existsSync(BACKUP_ROOT())) return
290
- const entries = await readdir(BACKUP_ROOT())
291
- if (entries.length <= 5) return
292
- const sorted = entries.sort()
293
- for (const name of sorted.slice(0, sorted.length - 5)) {
294
- await rm(join(BACKUP_ROOT(), name), { recursive: true, force: true })
295
- }
296
- }
297
-
298
- async function mergePluginDependency() {
299
- const packagePath = join(configRoot, "package.json")
300
- let config = {}
301
- if (existsSync(packagePath)) {
302
- try {
303
- config = JSON.parse(await readFile(packagePath, "utf8"))
304
- } catch {
305
- throw new Error(`Cannot parse ${packagePath}; fix it before installing.`)
306
- }
307
- }
308
- config.dependencies = { ...(config.dependencies || {}), "@opencode-ai/plugin": "1.2.27" }
309
- await writeFile(packagePath, `${JSON.stringify(config, null, 2)}\n`, "utf8")
310
-
311
- const npmCmd = process.env.ComSpec || "cmd.exe"
312
- const npmArgs = process.platform === "win32"
313
- ? ["/d", "/s", "/c", "npm", "install", "--ignore-scripts", "--no-audit", "--no-fund", "--save-exact"]
314
- : ["install", "--ignore-scripts", "--no-audit", "--no-fund", "--save-exact"]
315
- const npmBin = process.platform === "win32" ? npmCmd : "npm"
316
- const result = spawnSync(npmBin, npmArgs, {
317
- cwd: configRoot,
318
- stdio: "inherit",
319
- })
320
- if (result.error) throw result.error
321
- if (result.status !== 0) process.exit(result.status || 1)
322
- }
323
-
324
- async function mergeAgentsMd() {
325
- const target = join(configRoot, "AGENTS.md")
326
- const AGENTS_MD = join(packageRoot, "AGENTS.md")
327
- const marker = "<!-- agent-teams-orchestration:start -->"
328
-
329
- let packageContent = ""
330
- try {
331
- packageContent = await readFile(AGENTS_MD, "utf-8")
332
- } catch {
333
- return
334
- }
335
-
336
- if (!existsSync(target)) {
337
- await writeFile(target, packageContent, "utf-8")
338
- console.log(` ${c.green}✓${c.reset} Created AGENTS.md`)
339
- return
340
- }
341
-
342
- const existing = await readFile(target, "utf-8")
343
- if (existing.includes(marker)) {
344
- console.log(` ${c.dim} AGENTS.md already contains orchestration rules, skipping${c.reset}`)
345
- return
346
- }
347
-
348
- await writeFile(target, existing + "\n\n" + packageContent + "\n", "utf-8")
349
- console.log(` ${c.green}✓${c.reset} Appended orchestration rules to existing AGENTS.md`)
350
- }
351
-
352
- async function doInstall(rl) {
353
- const pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"))
354
- const NEW_VERSION = pkg.version
355
- const currentVersion = await getCurrentVersion()
356
-
357
- if (currentVersion) {
358
- printBox([
359
- `${c.yellow}Current version:${c.reset} v${currentVersion}`,
360
- `${c.yellow}New version:${c.reset} v${NEW_VERSION}`,
361
- ])
362
- console.log("")
363
-
364
- if (currentVersion === NEW_VERSION) {
365
- console.log(` ${c.yellow}Already up to date.${c.reset}`)
366
- const answer = await prompt(rl, ` Reinstall anyway? [y/N] `)
367
- if (answer.toLowerCase() !== "y") return
368
- } else {
369
- const answer = await prompt(rl, ` Upgrade from v${currentVersion} to v${NEW_VERSION}? [Y/n] `)
370
- if (answer.toLowerCase() === "n") return
371
- }
372
-
373
- // Backup
374
- console.log(`\n ${c.dim}Backing up current installation...${c.reset}`)
375
- const backup = await backupExisting()
376
- if (backup) {
377
- console.log(` ${c.green}✓${c.reset} Backed up v${backup.version} to ${backup.dir}`)
378
- }
379
- } else {
380
- console.log(` Installing Agent-Teams v${NEW_VERSION} fresh.\n`)
381
- }
382
-
383
- const mode = await promptMode(rl)
384
- targetConfigRoot(mode)
385
-
386
- // Clean + Install
387
- console.log(` ${c.dim}Cleaning old files...${c.reset}`)
388
- await cleanManaged(mode)
389
-
390
- console.log(` ${c.dim}Copying ${mode === "agents" ? "agents" : "agents, plugins, relay"}...${c.reset}`)
391
- await installFiles(mode)
392
-
393
- await writeFile(VERSION_FILE(), NEW_VERSION, "utf-8")
394
- await writeModeMarker(mode)
395
-
396
- console.log(` ${c.dim}Merging AGENTS.md rules...${c.reset}`)
397
- await mergeAgentsMd()
398
-
399
- console.log(` ${c.dim}Ensuring subagent_depth & max_concurrent_agents in global config (mode: ${mode})...${c.reset}`)
400
- await mergeSubagentDepth(configRoot, console.log, mode)
401
- await mergeSlashCommands(configRoot, console.log, mode)
402
- await mergeSchema(configRoot, console.log, mode)
403
- await mergeEnvFlags(console.log, mode)
404
-
405
- if (mode === "full") {
406
- console.log(` ${c.dim}Installing npm dependencies...${c.reset}`)
407
- await mergePluginDependency()
408
- }
409
-
410
- await pruneBackups()
411
-
412
- console.log("")
413
- printBox([
414
- `${c.green}${c.bold}✓ Installed Agent-Teams v${NEW_VERSION}${c.reset}`,
415
- `${c.dim}Mode: ${mode === "agents" ? "agents-only" : "full"}${c.reset}`,
416
- ])
417
- console.log(`\n ${c.bold}Restart opencode${c.reset} to load the new agents${mode === "full" ? " and plugin" : ""}.\n`)
418
- }
419
-
420
- // --- Main TUI ---
421
-
422
- async function main() {
423
- clearScreen()
424
- printHeader()
425
-
426
- const rl = createInterface({ input: process.stdin, output: process.stdout })
427
-
428
- try {
429
- const currentVersion = await getCurrentVersion()
430
- const installedMode = await getInstalledMode()
431
- const backups = await listBackups()
432
- const pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"))
433
-
434
- // Status line
435
- if (currentVersion) {
436
- console.log(
437
- ` ${c.green}●${c.reset} Installed: ${c.bold}v${currentVersion}${c.reset}${currentVersion === pkg.version ? "" : ` ${c.dim}(new: v${pkg.version})${c.reset}`} ${c.dim}—${c.reset} Mode: ${c.bold}${installedMode === "agents" ? "agents-only" : "full"}${c.reset} ${c.dim}—${c.reset} Backups: ${backups.length}`,
438
- )
439
- } else {
440
- console.log(` ${c.red}●${c.reset} Not installed ${c.dim}— available: v${pkg.version}${c.reset}`)
441
- }
442
- console.log(` ${c.dim}Config: ${configRoot}${c.reset}`)
443
- console.log("")
444
-
445
- const options = [
446
- {
447
- label: currentVersion ? `${c.bold}Upgrade${c.reset} (backup + install latest)` : `${c.bold}Install${c.reset} (fresh setup)`,
448
- value: "install",
449
- },
450
- ...(currentVersion
451
- ? [
452
- {
453
- label: `${c.bold}Reinstall${c.reset} (same version, no backup)`,
454
- value: "reinstall",
455
- },
456
- ]
457
- : []),
458
- ...(backups.length > 0
459
- ? [
460
- {
461
- label: `${c.bold}Revert${c.reset} (restore a previous version)`,
462
- value: "revert",
463
- },
464
- {
465
- label: `${c.bold}Clean Backups${c.reset} (delete old backup files)`,
466
- value: "clean-backups",
467
- },
468
- ]
469
- : []),
470
- ...(currentVersion
471
- ? [
472
- {
473
- label: `${c.bold}Uninstall${c.reset} (remove Agent-Teams)`,
474
- value: "uninstall",
475
- },
476
- ]
477
- : []),
478
- {
479
- label: `${c.bold}Status${c.reset} (show version and backups)`,
480
- value: "status",
481
- },
482
- {
483
- label: `${c.dim}Exit${c.reset}`,
484
- value: "exit",
485
- },
486
- ]
487
-
488
- const choice = await promptChoice(rl, "", options)
489
-
490
- if (!choice || choice.value === "exit") {
491
- console.log(`\n ${c.dim}Bye!${c.reset}\n`)
492
- return
493
- }
494
-
495
- console.log("")
496
-
497
- switch (choice.value) {
498
- case "install":
499
- await doInstall(rl)
500
- break
501
-
502
- case "reinstall": {
503
- // Reinstall without backup
504
- const pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"))
505
- console.log(` ${c.dim}Reinstalling v${pkg.version}...${c.reset}\n`)
506
- const mode = await promptMode(rl)
507
- targetConfigRoot(mode)
508
- await cleanManaged(mode)
509
- await installFiles(mode)
510
- await writeFile(VERSION_FILE(), pkg.version, "utf-8")
511
- await writeModeMarker(mode)
512
- await mergeAgentsMd()
513
- await mergeSubagentDepth(configRoot, console.log, mode)
514
- await mergeSlashCommands(configRoot, console.log, mode)
515
- await mergeSchema(configRoot, console.log, mode)
516
- if (mode === "full") await mergePluginDependency()
517
- console.log("")
518
- printBox([`${c.green}${c.bold}✓ Reinstalled v${pkg.version}${c.reset}`, `${c.dim}Mode: ${mode === "agents" ? "agents-only" : "full"}${c.reset}`])
519
- console.log(`\n ${c.bold}Restart opencode${c.reset} to load the agents${mode === "full" ? " and plugin" : ""}.\n`)
520
- break
521
- }
522
-
523
- case "revert": {
524
- if (backups.length === 1) {
525
- await revert(backups[0].name)
526
- } else {
527
- const revertOptions = backups.map((b) => ({
528
- label: `v${b.version} (${b.name})`,
529
- value: b.name,
530
- }))
531
- revertOptions.push({ label: `${c.dim}Cancel${c.reset}`, value: null })
532
-
533
- const target = await promptChoice(rl, " Select backup to restore:", revertOptions)
534
- if (target && target.value) {
535
- await revert(target.value)
536
- } else {
537
- console.log(`\n ${c.dim}Cancelled.${c.reset}\n`)
538
- }
539
- }
540
- break
541
- }
542
-
543
- case "clean-backups": {
544
- const cleanOptions = backups.map((b) => ({
545
- label: `Delete v${b.version} (${b.name})`,
546
- value: b.name,
547
- }))
548
- cleanOptions.push({ label: `${c.red}Delete ALL backups${c.reset}`, value: "all" })
549
- cleanOptions.push({ label: `${c.dim}Cancel${c.reset}`, value: null })
550
-
551
- const choice = await promptChoice(rl, " Select backup to delete:", cleanOptions)
552
- if (choice && choice.value) {
553
- await deleteBackup(choice.value)
554
- } else {
555
- console.log(`\n ${c.dim}Cancelled.${c.reset}\n`)
556
- }
557
- break
558
- }
559
-
560
- case "uninstall": {
561
- const answer = await prompt(rl, ` ${c.red}Remove Agent-Teams completely?${c.reset} [y/N] `)
562
- if (answer.toLowerCase() === "y") {
563
- await uninstall()
564
- } else {
565
- console.log(`\n ${c.dim}Cancelled.${c.reset}\n`)
566
- }
567
- break
568
- }
569
-
570
- case "status":
571
- await status()
572
- break
573
- }
574
- } finally {
575
- rl.close()
576
- }
577
- }
578
-
579
- main().catch((e) => {
580
- console.error(`\n ${c.red}Error:${c.reset} ${e?.message ?? e}\n`)
581
- process.exit(1)
582
- })