@conveno/cli 0.2.0-rc.7 → 0.2.0-rc.8
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/dist/{acp-9pRRszwU.js → acp-YHhVx0Ya.js} +3 -3
- package/dist/{agy-relay-C-nqvieJ.js → agy-relay-BS2NeFlh.js} +2 -2
- package/dist/{args-C7Agak9f.js → args-CGL-AmNd.js} +89 -49
- package/dist/bin.js +2 -2
- package/dist/daemon.js +20 -7
- package/dist/{daemonError-DNAKEyRT.js → daemonError-DJ-P55nH.js} +1 -1
- package/dist/{dist-DOGlDbRb.js → dist-B1EVHdIM.js} +1 -1
- package/dist/{dist-D9Gu-mQm.js → dist-B6Sm0MRT.js} +1 -1
- package/dist/{dist-D2hMvcZu.js → dist-BBdba94T.js} +10 -7
- package/dist/{dist-DOKVrSIw.js → dist-BlWWt5gx.js} +3 -3
- package/dist/{dist-iFaY42Bs.js → dist-C6cMQ00I.js} +1 -1
- package/dist/{dist-Dd31Fg0h.js → dist-CcoTmwrf.js} +1 -1
- package/dist/{dist-ftx5RNCp.js → dist-WTkKRM39.js} +1 -1
- package/dist/{hook-CQeSn-w4.js → hook-DxjJDCjz.js} +3 -0
- package/dist/hook-entry-CrpZz5QW.js +1 -0
- package/dist/{hook-entry-BXmSN--S.js → hook-entry-pHJioNgN.js} +12 -8
- package/dist/{main-seh-HPZO.js → main-DrzHsV5y.js} +61 -382
- package/dist/{pick-DoyocW55.js → pick-Bi1yJDh6.js} +1 -1
- package/dist/run-C32oP2c_.js +5550 -0
- package/dist/{runtime-Bnjh9BQ8.js → runtime-Db_YT5Xg.js} +9 -9
- package/dist/{doctor-BYa-MApu.js → uninstall-D9rW_j7H.js} +381 -22
- package/dist/{watch-Dr2RdyGo.js → watch-BrTWYf3Y.js} +4 -4
- package/package.json +19 -16
- package/dist/hook-entry-CgiSN-Oj.js +0 -1
- package/dist/run-B-WfNtCX.js +0 -4507
|
@@ -1,191 +1,16 @@
|
|
|
1
|
-
import { Ct as realSpawnDeps, Lt as spawnSession, M as dataPaths, Mt as runLaunchFile, Xt as CLI_KINDS, d as SPAWN_TABLE, f as SpawnError, u as SPAWN_CLIS } from "./dist-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as daemonProblem } from "./daemonError-DNAKEyRT.js";
|
|
7
|
-
import { a as fail, c as plural, d as warnBlock, l as seconds, n as cmd, o as localStamp, r as columns, s as plainError, t as closest, u as tilde } from "./fmt-C2SsP5Y0.js";
|
|
1
|
+
import { Ct as realSpawnDeps, Lt as spawnSession, M as dataPaths, Mt as runLaunchFile, Xt as CLI_KINDS, d as SPAWN_TABLE, f as SpawnError, u as SPAWN_CLIS } from "./dist-BBdba94T.js";
|
|
2
|
+
import { b as runLogin, c as runInit, g as runDaemon, h as runRelay, i as runDoctor, l as runSetup, m as runDevices, t as runUninstall, x as runLogout, y as runAccount } from "./uninstall-D9rW_j7H.js";
|
|
3
|
+
import { a as parseFlags, i as commandHelp, n as COMMANDS, r as COMMAND_NAMES, t as ALL_COMMAND_NAMES } from "./args-CGL-AmNd.js";
|
|
4
|
+
import { t as daemonProblem } from "./daemonError-DJ-P55nH.js";
|
|
5
|
+
import { chmod, mkdir, writeFile } from "node:fs/promises";
|
|
8
6
|
import { join, resolve } from "node:path";
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
7
|
+
import { a as fail, c as plural, d as warnBlock, n as cmd, r as columns, s as plainError, t as closest, u as tilde } from "./fmt-C2SsP5Y0.js";
|
|
8
|
+
import { t as runHook } from "./hook-DxjJDCjz.js";
|
|
9
|
+
import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
|
|
10
|
+
import { t as findSession } from "./pick-Bi1yJDh6.js";
|
|
11
11
|
import { readFileSync } from "node:fs";
|
|
12
|
-
// src/daemon.ts
|
|
13
|
-
async function lockPid(ctx) {
|
|
14
|
-
try {
|
|
15
|
-
const raw = await readFile(dataPaths(ctx.platform, ctx.dataDir).lock, "utf8");
|
|
16
|
-
const pid = JSON.parse(raw).pid;
|
|
17
|
-
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
18
|
-
} catch {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
23
|
-
/** Does something on the socket answer the Conveno handshake? */
|
|
24
|
-
async function reachable(ctx) {
|
|
25
|
-
try {
|
|
26
|
-
await (await ctx.connect(connectOpts(ctx, false))).close().catch(() => void 0);
|
|
27
|
-
return true;
|
|
28
|
-
} catch {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const lockExists = (ctx) => access(dataPaths(ctx.platform, ctx.dataDir).lock).then(() => true, () => false);
|
|
33
|
-
/** Poll until `done()` holds or `ms` pass. Returns whether it held. */
|
|
34
|
-
async function waitFor(done, ms) {
|
|
35
|
-
const deadline = Date.now() + ms;
|
|
36
|
-
for (;;) {
|
|
37
|
-
if (await done()) return true;
|
|
38
|
-
if (Date.now() >= deadline) return false;
|
|
39
|
-
await sleep(50);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const norm = (text) => text.replaceAll("\\", "/").toLowerCase();
|
|
43
|
-
/**
|
|
44
|
-
* Does this command line belong to the Conveno daemon? It must run the daemon's entry script: the
|
|
45
|
-
* one this install resolved, any installed `@conveno/cli`'s `daemon.js`, or the `bin.js` of the
|
|
46
|
-
* `@conveno/daemon` package that releases before 0.1.1 started.
|
|
47
|
-
*/
|
|
48
|
-
function isConvenoDaemonCommand(commandLine, daemonEntry) {
|
|
49
|
-
const line = norm(commandLine);
|
|
50
|
-
if (daemonEntry !== void 0 && line.includes(norm(daemonEntry))) return true;
|
|
51
|
-
return /@conveno\/cli\/(?:[^ ]+\/)?daemon\.js|@conveno\/daemon\/(?:[^ ]+\/)?bin\.js/.test(line);
|
|
52
|
-
}
|
|
53
|
-
const STOP_FIX = (t) => `then run ${cmd(t, "conveno daemon status")}`;
|
|
54
|
-
/**
|
|
55
|
-
* `conveno daemon stop`. The normal path asks the daemon to shut itself down over the control
|
|
56
|
-
* channel (`daemon.shutdown`), the way Docker and pm2 do. That needs no signal and no external
|
|
57
|
-
* tool, so it works for a normal user in a Windows SSH session. Only when the daemon does not answer,
|
|
58
|
-
* and its lock pid is verified to be the daemon, is the process ended directly.
|
|
59
|
-
*/
|
|
60
|
-
async function stopDaemon(ctx) {
|
|
61
|
-
const t = ctx.theme;
|
|
62
|
-
const lock = dataPaths(ctx.platform, ctx.dataDir).lock;
|
|
63
|
-
const pid = await lockPid(ctx);
|
|
64
|
-
const named = pid === null ? "" : ` (pid ${pid})`;
|
|
65
|
-
let client;
|
|
66
|
-
try {
|
|
67
|
-
client = await ctx.connect(connectOpts(ctx, false));
|
|
68
|
-
} catch {
|
|
69
|
-
client = void 0;
|
|
70
|
-
}
|
|
71
|
-
if (client) {
|
|
72
|
-
try {
|
|
73
|
-
await client["daemon.shutdown"]({});
|
|
74
|
-
} catch (e) {
|
|
75
|
-
await client.close().catch(() => void 0);
|
|
76
|
-
return fail(ctx, {
|
|
77
|
-
what: `The background service${named} did not accept the stop request`,
|
|
78
|
-
detail: [plainError(e)],
|
|
79
|
-
fix: `${pid === null ? "Stop the process that owns the daemon socket yourself" : `Stop pid ${pid} yourself`}, ${STOP_FIX(t)}.`,
|
|
80
|
-
exit: 1,
|
|
81
|
-
ref: "e_daemon_stop"
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
await client.close().catch(() => void 0);
|
|
85
|
-
if (!await waitFor(async () => !await reachable(ctx) && !await lockExists(ctx) && (pid === null || !ctx.isAlive(pid)), ctx.stopTimeoutMs)) return fail(ctx, {
|
|
86
|
-
what: `The background service${named} is still running after ${Math.round(ctx.stopTimeoutMs / 1e3)}s`,
|
|
87
|
-
detail: ["It accepted the stop request, but its process, socket or lock file is still there."],
|
|
88
|
-
fix: `${pid === null ? "Stop the process that owns the daemon socket yourself" : `Stop pid ${pid} yourself`}, ${STOP_FIX(t)}.`,
|
|
89
|
-
exit: 1,
|
|
90
|
-
ref: "e_daemon_stop"
|
|
91
|
-
});
|
|
92
|
-
ctx.out(`${t.status("ok")} Stopped the daemon${named}.\n`);
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
if (pid === null) {
|
|
96
|
-
ctx.out(`${t.status("info")} Conveno's background service is not running. Nothing to stop.\n`);
|
|
97
|
-
return 0;
|
|
98
|
-
}
|
|
99
|
-
const stale = async () => {
|
|
100
|
-
await rm(lock, { force: true }).catch(() => void 0);
|
|
101
|
-
ctx.out(`${t.status("info")} Nothing answered as the Conveno daemon, so no process was stopped. Removed the stale lock file (it named pid ${pid}).\n`);
|
|
102
|
-
return 0;
|
|
103
|
-
};
|
|
104
|
-
if (!ctx.isAlive(pid)) return stale();
|
|
105
|
-
const commandLine = await ctx.commandLineOf(pid);
|
|
106
|
-
if (commandLine === null) return fail(ctx, {
|
|
107
|
-
what: `The background service did not answer, and pid ${pid} could not be checked`,
|
|
108
|
-
detail: ["Conveno could not read that process's command line, so it cannot tell whether it is the daemon. It stopped nothing."],
|
|
109
|
-
fix: `If pid ${pid} is the Conveno daemon, end it yourself (Task Manager on Windows, \`kill ${pid}\` elsewhere), ${STOP_FIX(t)}.`,
|
|
110
|
-
exit: 1,
|
|
111
|
-
ref: "e_daemon_lock"
|
|
112
|
-
});
|
|
113
|
-
if (!isConvenoDaemonCommand(commandLine, ctx.daemonEntry)) return stale();
|
|
114
|
-
try {
|
|
115
|
-
ctx.kill(pid);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
return fail(ctx, {
|
|
118
|
-
what: `Could not stop the daemon (pid ${pid})`,
|
|
119
|
-
detail: [plainError(e)],
|
|
120
|
-
fix: `Stop that process yourself, ${STOP_FIX(t)}.`,
|
|
121
|
-
exit: 1,
|
|
122
|
-
ref: "e_daemon_stop"
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
if (!await waitFor(() => !ctx.isAlive(pid), ctx.stopTimeoutMs)) return fail(ctx, {
|
|
126
|
-
what: `The background service (pid ${pid}) is still running after ${Math.round(ctx.stopTimeoutMs / 1e3)}s`,
|
|
127
|
-
detail: ["It did not answer, was ended, and has not exited."],
|
|
128
|
-
fix: `Stop that process yourself, ${STOP_FIX(t)}.`,
|
|
129
|
-
exit: 1,
|
|
130
|
-
ref: "e_daemon_stop"
|
|
131
|
-
});
|
|
132
|
-
await rm(lock, { force: true }).catch(() => void 0);
|
|
133
|
-
ctx.out(`${t.status("ok")} Stopped the daemon (pid ${pid}). It was not answering, so it was ended directly.\n`);
|
|
134
|
-
return 0;
|
|
135
|
-
}
|
|
136
|
-
const SUBCOMMANDS = [
|
|
137
|
-
"start",
|
|
138
|
-
"stop",
|
|
139
|
-
"status"
|
|
140
|
-
];
|
|
141
|
-
async function runDaemon(ctx, argv) {
|
|
142
|
-
const t = ctx.theme;
|
|
143
|
-
const sub = argv[0];
|
|
144
|
-
if (sub === "start") {
|
|
145
|
-
try {
|
|
146
|
-
await (await ctx.connect(connectOpts(ctx, true))).close().catch(() => void 0);
|
|
147
|
-
} catch (e) {
|
|
148
|
-
const problem = daemonProblem(t, e);
|
|
149
|
-
return fail(ctx, {
|
|
150
|
-
what: "The Conveno daemon did not start",
|
|
151
|
-
detail: [problem.why],
|
|
152
|
-
fix: problem.notRunning ? `Run ${cmd(t, "conveno doctor")} to check the install, then try again.` : problem.fix,
|
|
153
|
-
exit: 1,
|
|
154
|
-
ref: "e_daemon_start"
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
const pid = await lockPid(ctx);
|
|
158
|
-
ctx.out(`${t.status("ok")} Daemon running${pid ? `, pid ${pid}` : ""}.\n`);
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
if (sub === "status") {
|
|
162
|
-
const pid = await lockPid(ctx);
|
|
163
|
-
try {
|
|
164
|
-
await (await ctx.connect(connectOpts(ctx, false))).close().catch(() => void 0);
|
|
165
|
-
ctx.out(`${t.status("ok")} daemon running${pid ? `, pid ${pid}` : ""}\n`);
|
|
166
|
-
return 0;
|
|
167
|
-
} catch (e) {
|
|
168
|
-
const problem = daemonProblem(t, e);
|
|
169
|
-
if (problem.notRunning) ctx.out(`${t.glyph("offline")} daemon not running\n`);
|
|
170
|
-
else {
|
|
171
|
-
ctx.out(`${t.status("error")} daemon cannot be reached\n`);
|
|
172
|
-
ctx.err(warnBlock(t, "Conveno's background service cannot be reached.", problem.fix, problem.why));
|
|
173
|
-
}
|
|
174
|
-
return 1;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (sub === "stop") return stopDaemon(ctx);
|
|
178
|
-
const suggestion = sub ? closest(sub, SUBCOMMANDS) : void 0;
|
|
179
|
-
return fail(ctx, {
|
|
180
|
-
what: sub ? `Unknown daemon command "${sub}"` : "conveno daemon needs a command",
|
|
181
|
-
fix: `Run ${cmd(t, "conveno daemon start")}, ${cmd(t, "conveno daemon stop")} or ${cmd(t, "conveno daemon status")}.`,
|
|
182
|
-
...suggestion ? { didYouMean: `Did you mean ${suggestion}?` } : {},
|
|
183
|
-
exit: 2,
|
|
184
|
-
ref: "e_usage"
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
12
|
// src/version.ts
|
|
188
|
-
const VERSION = "0.2.0-rc.
|
|
13
|
+
const VERSION = "0.2.0-rc.8";
|
|
189
14
|
// src/errorLog.ts
|
|
190
15
|
/** The message of an unexpected error, as it is. Not the softened text `plainError` gives. */
|
|
191
16
|
function rawMessage(e) {
|
|
@@ -564,49 +389,27 @@ async function runSpawnRun(ctx, argv) {
|
|
|
564
389
|
}
|
|
565
390
|
}
|
|
566
391
|
// src/status.ts
|
|
567
|
-
const CLI_SHORT = {
|
|
568
|
-
claude: "cl",
|
|
569
|
-
codex: "cx",
|
|
570
|
-
opencode: "oc",
|
|
571
|
-
antigravity: "ag",
|
|
572
|
-
cursor: "cu",
|
|
573
|
-
copilot: "cp",
|
|
574
|
-
grok: "gk"
|
|
575
|
-
};
|
|
576
|
-
const pad2 = (n) => String(n).padStart(2, "0");
|
|
577
|
-
/** Local `HH:MM:SS`, with the date in front when it is not today. */
|
|
578
|
-
function stamp(iso, now) {
|
|
579
|
-
const d = new Date(iso);
|
|
580
|
-
const time = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
581
|
-
const day = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
582
|
-
return day === `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}` ? time : `${day} ${time}`;
|
|
583
|
-
}
|
|
584
|
-
function tierText(theme, tier) {
|
|
585
|
-
switch (tier) {
|
|
586
|
-
case "live": return theme.paint("entry", "live");
|
|
587
|
-
case "next_turn": return "next turn";
|
|
588
|
-
case "acp": return "ACP";
|
|
589
|
-
case "inbox": return theme.paint("quiet", "inbox");
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
392
|
function stateCell(theme, s) {
|
|
593
393
|
if (s.isOrchestrator) return {
|
|
594
394
|
glyph: theme.status("orchestrator"),
|
|
595
|
-
word: s.status
|
|
395
|
+
word: s.status === "busy" ? "working" : "idle"
|
|
596
396
|
};
|
|
597
397
|
if (s.status === "busy") return {
|
|
598
398
|
glyph: theme.glyph("busy"),
|
|
599
|
-
word: "
|
|
399
|
+
word: "working"
|
|
600
400
|
};
|
|
601
401
|
return {
|
|
602
402
|
glyph: theme.status("idle"),
|
|
603
403
|
word: "idle"
|
|
604
404
|
};
|
|
605
405
|
}
|
|
606
|
-
/** Sessions grouped by
|
|
406
|
+
/** Sessions grouped by project folder, the way brand/components/terminal.md lays them out. */
|
|
607
407
|
function renderSessions(ctx, sessions) {
|
|
608
408
|
const t = ctx.theme;
|
|
609
|
-
const
|
|
409
|
+
const q = (w) => t.paint("quiet", w);
|
|
410
|
+
const toolName = (cli) => ctx.adapters.find((a) => a.cli === cli)?.displayName ?? cli;
|
|
411
|
+
const waiting = sessions.some((s) => (s.unreadCount ?? 0) > 0);
|
|
412
|
+
const doing = sessions.some((s) => s.statusText);
|
|
610
413
|
const groups = /* @__PURE__ */ new Map();
|
|
611
414
|
const keyOf = (s) => s.remote ? `${s.repo?.root ?? s.cwd}\u0000${s.deviceName ?? ""}` : s.repo?.root ?? s.cwd;
|
|
612
415
|
for (const s of sessions) {
|
|
@@ -616,31 +419,27 @@ function renderSessions(ctx, sessions) {
|
|
|
616
419
|
const blocks = [];
|
|
617
420
|
for (const key of [...groups.keys()].sort()) {
|
|
618
421
|
const list = (groups.get(key) ?? []).sort((a, b) => a.name.localeCompare(b.name));
|
|
619
|
-
const q = (w) => t.paint("quiet", w);
|
|
620
422
|
const head = [
|
|
621
423
|
` ${q("SESSION")}`,
|
|
622
|
-
q("
|
|
623
|
-
q("TIER"),
|
|
424
|
+
q("AI TOOL"),
|
|
624
425
|
q("STATE"),
|
|
625
|
-
q("
|
|
626
|
-
q("
|
|
426
|
+
...waiting ? [q("WAITING")] : [],
|
|
427
|
+
...doing ? [q("WORKING ON")] : []
|
|
627
428
|
];
|
|
628
429
|
const rows = list.map((s) => {
|
|
629
430
|
const st = stateCell(t, s);
|
|
431
|
+
const tags = [...s.isOrchestrator ? [t.paint("entry", "lead")] : [], ...s.spawned || s.spawnedBy ? [q("spawned")] : []];
|
|
630
432
|
return [
|
|
631
|
-
`${st.glyph} ${t.bold(s.name)}`,
|
|
632
|
-
|
|
633
|
-
tierText(t, s.deliveryTier),
|
|
433
|
+
`${st.glyph} ${t.bold(s.name)}${tags.length > 0 ? ` ${tags.join(" ")}` : ""}`,
|
|
434
|
+
toolName(s.cli),
|
|
634
435
|
st.word,
|
|
635
|
-
s.unreadCount ? String(s.unreadCount) : q("
|
|
636
|
-
|
|
637
|
-
...s.isOrchestrator ? [t.paint("entry", "lead")] : [],
|
|
638
|
-
...s.spawned || s.spawnedBy ? [t.paint("quiet", "spawned")] : []
|
|
436
|
+
...waiting ? [s.unreadCount ? String(s.unreadCount) : q("none")] : [],
|
|
437
|
+
...doing ? [s.statusText ?? ""] : []
|
|
639
438
|
];
|
|
640
439
|
});
|
|
641
440
|
const [headLine, ...rowLines] = columns([head, ...rows]);
|
|
642
441
|
const [path, device] = key.split("\0");
|
|
643
|
-
const title = device === void 0 ? t.bold(tilde(key, ctx.home)) : `${t.bold(path ?? "")} ${
|
|
442
|
+
const title = device === void 0 ? t.bold(tilde(key, ctx.home)) : `${t.bold(path ?? "")} ${q(`on ${device || "another device"}`)}`;
|
|
644
443
|
blocks.push([
|
|
645
444
|
` ${title}`,
|
|
646
445
|
` ${headLine}`,
|
|
@@ -651,17 +450,17 @@ function renderSessions(ctx, sessions) {
|
|
|
651
450
|
}
|
|
652
451
|
/** The relay part of the status header line. */
|
|
653
452
|
function relaySummary(r) {
|
|
654
|
-
if (!r) return "off
|
|
453
|
+
if (!r) return "off";
|
|
655
454
|
switch (r.state) {
|
|
656
455
|
case "connected": {
|
|
657
456
|
const online = r.peers.filter((p) => p.online).length;
|
|
658
|
-
return `connected
|
|
457
|
+
return `connected, ${plural(online, "other device")} online`;
|
|
659
458
|
}
|
|
660
459
|
case "connecting": return "connecting";
|
|
661
|
-
case "disconnected": return "
|
|
662
|
-
case "revoked": return "off
|
|
663
|
-
case "unpaired": return "off
|
|
664
|
-
default: return "off
|
|
460
|
+
case "disconnected": return "not connected, trying again";
|
|
461
|
+
case "revoked": return "off, this device was removed";
|
|
462
|
+
case "unpaired": return "off, no paired devices";
|
|
463
|
+
default: return "off";
|
|
665
464
|
}
|
|
666
465
|
}
|
|
667
466
|
async function runStatus(ctx, argv = []) {
|
|
@@ -676,173 +475,52 @@ async function runStatus(ctx, argv = []) {
|
|
|
676
475
|
client = await ctx.connect(connectOpts(ctx, false));
|
|
677
476
|
} catch (e) {
|
|
678
477
|
const problem = daemonProblem(t, e);
|
|
679
|
-
ctx.err(problem.notRunning ? warnBlock(t, "Conveno
|
|
478
|
+
ctx.err(problem.notRunning ? warnBlock(t, "Conveno is not running right now.", `Open one of your AI tools and it starts by itself. If you have not connected your AI tools yet, run ${cmd(t, "conveno setup")}.`, "Sessions are listed by Conveno's background service, and it is not running.") : warnBlock(t, "Conveno's background service cannot be reached.", problem.fix, problem.why));
|
|
680
479
|
return 0;
|
|
681
480
|
}
|
|
682
481
|
try {
|
|
683
482
|
const sessions = (await client["session.list"]({})).sessions;
|
|
684
|
-
const
|
|
483
|
+
const projects = new Set(sessions.map((s) => s.repo?.root ?? s.cwd)).size;
|
|
685
484
|
const relay = await (async () => client["relay.status"]({}))().catch(() => void 0);
|
|
686
|
-
ctx.out(
|
|
485
|
+
ctx.out(`${t.status("ok")} Conveno is running. ${plural(sessions.length, "session")} online.\n`);
|
|
486
|
+
if (relay && [
|
|
487
|
+
"connected",
|
|
488
|
+
"connecting",
|
|
489
|
+
"disconnected"
|
|
490
|
+
].includes(relay.state)) ctx.out(` Your other devices: ${relaySummary(relay)}\n`);
|
|
687
491
|
if (sessions.length === 0) {
|
|
688
|
-
ctx.out(`\nNo sessions yet. Open
|
|
492
|
+
ctx.out(`\nNo sessions yet. Open an AI tool you have connected with ${cmd(t, "conveno setup")} and it appears here.\n`);
|
|
689
493
|
return 0;
|
|
690
494
|
}
|
|
691
495
|
ctx.out(`\n${renderSessions(ctx, sessions)}\n\n`);
|
|
692
|
-
ctx.out(`${plural(sessions.length, "session")} in ${plural(
|
|
496
|
+
ctx.out(`${plural(sessions.length, "session")} in ${plural(projects, "project")}\n`);
|
|
693
497
|
return 0;
|
|
694
498
|
} finally {
|
|
695
499
|
await client.close().catch(() => void 0);
|
|
696
500
|
}
|
|
697
501
|
}
|
|
698
|
-
// src/uninstall.ts
|
|
699
|
-
const NOTE = {
|
|
700
|
-
restore: "restored byte for byte",
|
|
701
|
-
remove: "removed, it did not exist before",
|
|
702
|
-
edit: "edited since init, so only Conveno's entries are removed",
|
|
703
|
-
gone: "already gone, left as it is"
|
|
704
|
-
};
|
|
705
|
-
/**
|
|
706
|
-
* The files as init found them, from the backups: their text, or null when they did not exist. A
|
|
707
|
-
* backup that cannot be read leaves its file out, and the adapter then treats what it finds as
|
|
708
|
-
* Conveno's own.
|
|
709
|
-
*/
|
|
710
|
-
async function baselineOf(dir, entries) {
|
|
711
|
-
const out = /* @__PURE__ */ new Map();
|
|
712
|
-
for (const e of entries) if (e.backup === null) out.set(e.path, null);
|
|
713
|
-
else try {
|
|
714
|
-
out.set(e.path, await readFile(join(dir, e.backup), "utf8"));
|
|
715
|
-
} catch {}
|
|
716
|
-
return out;
|
|
717
|
-
}
|
|
718
|
-
/** Remove Conveno's own entries from files that changed since init, through each adapter. */
|
|
719
|
-
async function removeOwnEntries(ctx, dir, entries) {
|
|
720
|
-
if (entries.length === 0) return {
|
|
721
|
-
edited: [],
|
|
722
|
-
failures: []
|
|
723
|
-
};
|
|
724
|
-
const clis = new Set(entries.map((e) => e.cli));
|
|
725
|
-
const found = (await detectAll(ctx)).filter((f) => clis.has(f.adapter.cli));
|
|
726
|
-
const { items, failures } = await collectPlans(ctx, found, "uninstallPlan", await baselineOf(dir, entries));
|
|
727
|
-
const wanted = new Set(entries.map((e) => e.path));
|
|
728
|
-
const mine = items.filter((i) => wanted.has(i.change.path));
|
|
729
|
-
if (mine.length > 0) await applyChanges(ctx, mine, { markRestored: true });
|
|
730
|
-
return {
|
|
731
|
-
edited: mine.map((i) => i.change.path),
|
|
732
|
-
failures
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
async function restoreAll(ctx, manifests) {
|
|
736
|
-
const restored = [];
|
|
737
|
-
const edited = [];
|
|
738
|
-
const untouched = [];
|
|
739
|
-
for (const found of manifests) {
|
|
740
|
-
const needEdit = [];
|
|
741
|
-
for (const entry of found.manifest.entries) {
|
|
742
|
-
const action = await restoreEntry(found.dir, entry);
|
|
743
|
-
if (action === "edit") needEdit.push(entry);
|
|
744
|
-
else if (action === "gone") untouched.push(entry.path);
|
|
745
|
-
else restored.push(entry.path);
|
|
746
|
-
}
|
|
747
|
-
const r = await removeOwnEntries(ctx, found.dir, needEdit);
|
|
748
|
-
if (r.failures.length > 0) {
|
|
749
|
-
reportFailures(ctx, r.failures, "conveno uninstall");
|
|
750
|
-
throw new Error("A config file could not be read, so it was left as it is.");
|
|
751
|
-
}
|
|
752
|
-
edited.push(...r.edited);
|
|
753
|
-
for (const e of needEdit) if (!r.edited.includes(e.path)) untouched.push(e.path);
|
|
754
|
-
await markRestored(ctx, found);
|
|
755
|
-
}
|
|
756
|
-
return {
|
|
757
|
-
restored,
|
|
758
|
-
edited,
|
|
759
|
-
untouched
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
async function runUninstall(ctx, argv) {
|
|
763
|
-
const t = ctx.theme;
|
|
764
|
-
const started = ctx.now();
|
|
765
|
-
const spec = COMMANDS.find((c) => c.name === "uninstall");
|
|
766
|
-
if (!spec) return 2;
|
|
767
|
-
const parsed = parseFlags(ctx, spec, argv);
|
|
768
|
-
if (typeof parsed === "number") return parsed;
|
|
769
|
-
const yes = parsed.values.yes === true;
|
|
770
|
-
const manifests = await listManifests(ctx).catch(() => []);
|
|
771
|
-
if (manifests.length > 0) {
|
|
772
|
-
const rows = await previewRestore(manifests);
|
|
773
|
-
const made = manifests.map((m) => localStamp(m.manifest.createdAt));
|
|
774
|
-
ctx.out(`${t.bold(`Conveno will undo ${plural(manifests.length, "install")}`)}, made ${made.join(", ")} (local time).\n\n`);
|
|
775
|
-
ctx.out(`${columns(rows.map((r) => [` ${tilde(r.entry.path, ctx.home)}`, t.paint("quiet", NOTE[r.action])])).join("\n")}\n\n`);
|
|
776
|
-
if (!yes) {
|
|
777
|
-
if (!ctx.interactive) return fail(ctx, {
|
|
778
|
-
what: "Needs a terminal to confirm",
|
|
779
|
-
detail: ["No files were changed."],
|
|
780
|
-
fix: `Run ${cmd(t, "conveno uninstall --yes")} to undo the changes listed above.`,
|
|
781
|
-
exit: 2,
|
|
782
|
-
ref: "e_no_tty"
|
|
783
|
-
});
|
|
784
|
-
if (!await ctx.confirm("Undo these changes?", false)) {
|
|
785
|
-
ctx.out(`${t.status("info")} Nothing was changed.\n`);
|
|
786
|
-
return 0;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
let result;
|
|
790
|
-
try {
|
|
791
|
-
result = await restoreAll(ctx, manifests);
|
|
792
|
-
} catch (e) {
|
|
793
|
-
if (e instanceof StaleError) return staleFailure(ctx, e, "conveno uninstall");
|
|
794
|
-
return fail(ctx, {
|
|
795
|
-
what: "Could not restore a file",
|
|
796
|
-
detail: [plainError(e), `The backups are still in ${tilde(manifests[0]?.dir ?? ctx.dataDir, ctx.home)} and the other backup folders next to it.`],
|
|
797
|
-
fix: "Fix the problem above, then run conveno uninstall again.",
|
|
798
|
-
exit: 1,
|
|
799
|
-
ref: "e_restore"
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
ctx.out(`${t.status("ok")} ${t.bold("Done.")} ${seconds(started, ctx.now())}\n`);
|
|
803
|
-
ctx.out(` Restored ${plural(result.restored.length, "file")} to how init found them.\n`);
|
|
804
|
-
if (result.edited.length > 0) ctx.out(` Edited, not restored, because they changed since init: ${result.edited.map((p) => tilde(p, ctx.home)).join(", ")}. Only Conveno's entries were removed.\n`);
|
|
805
|
-
ctx.out(" Restart open sessions to drop Conveno.\n");
|
|
806
|
-
return 0;
|
|
807
|
-
}
|
|
808
|
-
const found = await detectAll(ctx);
|
|
809
|
-
const { items, failures } = await collectPlans(ctx, found, "uninstallPlan");
|
|
810
|
-
if (failures.length > 0) {
|
|
811
|
-
reportFailures(ctx, failures, "conveno uninstall");
|
|
812
|
-
return 1;
|
|
813
|
-
}
|
|
814
|
-
if (items.length === 0) {
|
|
815
|
-
ctx.out(`${t.status("ok")} Nothing to remove. No Conveno entries were found in any supported CLI.\n`);
|
|
816
|
-
return 0;
|
|
817
|
-
}
|
|
818
|
-
ctx.out(`${t.status("info")} No install backup found, so Conveno will remove only its own entries.\n\n`);
|
|
819
|
-
const result = await confirmAndApply(ctx, items, {
|
|
820
|
-
yes,
|
|
821
|
-
verb: "Remove",
|
|
822
|
-
rerun: "conveno uninstall",
|
|
823
|
-
markRestored: true
|
|
824
|
-
});
|
|
825
|
-
if ("exit" in result) return result.exit;
|
|
826
|
-
ctx.out(`${t.status("ok")} ${t.bold("Done.")} ${seconds(started, ctx.now())}\n`);
|
|
827
|
-
ctx.out(" Removed the Conveno entries. Restart open sessions to drop Conveno.\n");
|
|
828
|
-
return 0;
|
|
829
|
-
}
|
|
830
502
|
// src/main.ts
|
|
831
503
|
const DESCRIPTION = "Conveno lets AI coding sessions on one machine find each other and exchange messages.";
|
|
832
504
|
function helpText(ctx) {
|
|
833
505
|
const t = ctx.theme;
|
|
834
|
-
const
|
|
835
|
-
const
|
|
506
|
+
const label = (usage) => usage.replace(/^conveno /, "").split(/\s+[[|]/)[0]?.trim() ?? usage;
|
|
507
|
+
const rows = [
|
|
508
|
+
["conveno", "Open the Conveno app"],
|
|
509
|
+
...COMMANDS.filter((c) => !c.hidden).map((c) => [label(c.usage), c.summary]),
|
|
510
|
+
["--help", "Show this help"],
|
|
511
|
+
["--version", "Show the version"]
|
|
512
|
+
];
|
|
513
|
+
const width = Math.max(...rows.map(([u]) => u.length)) + 2;
|
|
836
514
|
const row = (c, d) => ` ${t.bold(c.padEnd(width))}${d}`;
|
|
837
515
|
return [
|
|
838
516
|
DESCRIPTION,
|
|
839
517
|
"",
|
|
840
|
-
"Usage: conveno
|
|
518
|
+
"Usage: conveno [command]",
|
|
841
519
|
"",
|
|
842
520
|
...rows.map(([u, d]) => row(u, d)),
|
|
843
|
-
row("--version", "Print the version"),
|
|
844
521
|
"",
|
|
845
|
-
`Run ${cmd(t, "conveno
|
|
522
|
+
`New here? Run ${cmd(t, "conveno setup")} to connect your AI tools.`,
|
|
523
|
+
`Run ${cmd(t, "conveno <command> --help")} for more about one command.`,
|
|
846
524
|
`conveno ${t.paint("info", VERSION)}`,
|
|
847
525
|
""
|
|
848
526
|
].join("\n");
|
|
@@ -857,7 +535,7 @@ async function runMcp(ctx, argv) {
|
|
|
857
535
|
if (!cli || !CLI_KINDS.includes(cli)) return fail(ctx, {
|
|
858
536
|
what: "conveno mcp needs a CLI name",
|
|
859
537
|
detail: [`Got ${cli ? `"${cli}"` : "none"}. Known: ${CLI_KINDS.join(", ")}.`],
|
|
860
|
-
fix: `Run ${cmd(t, "conveno mcp --cli claude")}, or let ${cmd(t, "conveno
|
|
538
|
+
fix: `Run ${cmd(t, "conveno mcp --cli claude")}, or let ${cmd(t, "conveno setup")} write the config.`,
|
|
861
539
|
exit: 2,
|
|
862
540
|
ref: "e_usage"
|
|
863
541
|
});
|
|
@@ -886,6 +564,7 @@ async function dispatch(name, rest, ctx) {
|
|
|
886
564
|
return 0;
|
|
887
565
|
}
|
|
888
566
|
switch (command) {
|
|
567
|
+
case "setup": return runSetup(ctx, rest);
|
|
889
568
|
case "init": return runInit(ctx, rest);
|
|
890
569
|
case "uninstall": return runUninstall(ctx, rest);
|
|
891
570
|
case "status": return runStatus(ctx, rest);
|
|
@@ -893,11 +572,11 @@ async function dispatch(name, rest, ctx) {
|
|
|
893
572
|
case "rename": return runRename(ctx, rest);
|
|
894
573
|
case "lead": return runLead(ctx, rest);
|
|
895
574
|
case "spawn": return runSpawn(ctx, rest);
|
|
896
|
-
case "acp-host": return (await import("./acp-
|
|
897
|
-
case "stop": return (await import("./acp-
|
|
575
|
+
case "acp-host": return (await import("./acp-YHhVx0Ya.js")).runAcpHostCmd(ctx, rest);
|
|
576
|
+
case "stop": return (await import("./acp-YHhVx0Ya.js")).runStop(ctx, rest);
|
|
898
577
|
case "spawn-run": return runSpawnRun(ctx, rest);
|
|
899
|
-
case "agy-relay": return (await import("./agy-relay-
|
|
900
|
-
case "watch": return (await import("./watch-
|
|
578
|
+
case "agy-relay": return (await import("./agy-relay-BS2NeFlh.js")).runAgyRelay(ctx, rest);
|
|
579
|
+
case "watch": return (await import("./watch-BrTWYf3Y.js")).runWatch(ctx, rest);
|
|
901
580
|
case "devices": return runDevices(ctx, rest);
|
|
902
581
|
case "relay": return runRelay(ctx, rest);
|
|
903
582
|
case "doctor": return runDoctor(ctx, rest);
|
|
@@ -908,7 +587,7 @@ async function dispatch(name, rest, ctx) {
|
|
|
908
587
|
case "mcp": return runMcp(ctx, rest);
|
|
909
588
|
case "hook": return runHook(ctx, rest);
|
|
910
589
|
default: {
|
|
911
|
-
const suggestion = closest(command,
|
|
590
|
+
const suggestion = closest(command, ALL_COMMAND_NAMES);
|
|
912
591
|
return fail(ctx, {
|
|
913
592
|
what: `Unknown command "${command}"`,
|
|
914
593
|
detail: [`conveno ${VERSION} has: ${COMMAND_NAMES.join(", ")}.`],
|
|
@@ -936,7 +615,7 @@ function opensApp(env, tty = {
|
|
|
936
615
|
async function main(argv, ctx) {
|
|
937
616
|
const [command, ...rest] = argv;
|
|
938
617
|
if (command === void 0 && opensApp(ctx.env)) try {
|
|
939
|
-
return await (await import("./run-
|
|
618
|
+
return await (await import("./run-C32oP2c_.js")).runTui(ctx);
|
|
940
619
|
} catch (e) {
|
|
941
620
|
ctx.err(`The app could not start (${rawMessage(e)}). Showing the help instead.\n`);
|
|
942
621
|
ctx.out(helpText(ctx));
|