@openacp/cli 0.3.2 → 0.4.2

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/{autostart-N4HIL6C3.js → autostart-DZ3MHHMM.js} +3 -3
  3. package/dist/{chunk-LVSQQRCF.js → chunk-2SY7Y2VB.js} +3 -3
  4. package/dist/{chunk-7W5SOJPD.js → chunk-3QACY5E3.js} +2 -2
  5. package/dist/{chunk-CA6FXPLH.js → chunk-BLVZFCKN.js} +4 -4
  6. package/dist/chunk-KSIQZC3J.js +98 -0
  7. package/dist/chunk-KSIQZC3J.js.map +1 -0
  8. package/dist/{chunk-JOSJGZGF.js → chunk-LYKCQTH5.js} +1 -9
  9. package/dist/{chunk-JOSJGZGF.js.map → chunk-LYKCQTH5.js.map} +1 -1
  10. package/dist/{chunk-5E6ZXCNN.js → chunk-MRKYJ422.js} +2 -2
  11. package/dist/{chunk-RBDPCHGD.js → chunk-V3BA2MJ6.js} +2 -2
  12. package/dist/{chunk-YXMRR2E3.js → chunk-WF5XDN4D.js} +65 -40
  13. package/dist/chunk-WF5XDN4D.js.map +1 -0
  14. package/dist/{chunk-NS2L445T.js → chunk-WHKLPZGK.js} +4 -4
  15. package/dist/{chunk-66PHSLNS.js → chunk-WXPN5UOT.js} +599 -323
  16. package/dist/chunk-WXPN5UOT.js.map +1 -0
  17. package/dist/cli.js +258 -316
  18. package/dist/cli.js.map +1 -1
  19. package/dist/{config-2CBRLF3R.js → config-J5YQOMDU.js} +3 -3
  20. package/dist/config-editor-IXL4BFG3.js +11 -0
  21. package/dist/{daemon-UXC7PB4P.js → daemon-SLGQGRKO.js} +4 -4
  22. package/dist/index.d.ts +184 -71
  23. package/dist/index.js +18 -10
  24. package/dist/install-cloudflared-ILUXKLAC.js +8 -0
  25. package/dist/{main-P3OUOY7X.js → main-5QGMP7VG.js} +53 -17
  26. package/dist/main-5QGMP7VG.js.map +1 -0
  27. package/dist/{setup-UKWBLJIT.js → setup-JQZBPXWS.js} +4 -4
  28. package/dist/{tunnel-service-4GISQZNP.js → tunnel-service-DASSH7OA.js} +3 -3
  29. package/dist/version-VC5CPXBX.js +15 -0
  30. package/dist/version-VC5CPXBX.js.map +1 -0
  31. package/package.json +1 -1
  32. package/dist/chunk-66PHSLNS.js.map +0 -1
  33. package/dist/chunk-YXMRR2E3.js.map +0 -1
  34. package/dist/config-editor-UN56HQCW.js +0 -11
  35. package/dist/install-cloudflared-LMM7MFQX.js +0 -8
  36. package/dist/main-P3OUOY7X.js.map +0 -1
  37. /package/dist/{autostart-N4HIL6C3.js.map → autostart-DZ3MHHMM.js.map} +0 -0
  38. /package/dist/{chunk-LVSQQRCF.js.map → chunk-2SY7Y2VB.js.map} +0 -0
  39. /package/dist/{chunk-7W5SOJPD.js.map → chunk-3QACY5E3.js.map} +0 -0
  40. /package/dist/{chunk-CA6FXPLH.js.map → chunk-BLVZFCKN.js.map} +0 -0
  41. /package/dist/{chunk-5E6ZXCNN.js.map → chunk-MRKYJ422.js.map} +0 -0
  42. /package/dist/{chunk-RBDPCHGD.js.map → chunk-V3BA2MJ6.js.map} +0 -0
  43. /package/dist/{chunk-NS2L445T.js.map → chunk-WHKLPZGK.js.map} +0 -0
  44. /package/dist/{config-2CBRLF3R.js.map → config-J5YQOMDU.js.map} +0 -0
  45. /package/dist/{config-editor-UN56HQCW.js.map → config-editor-IXL4BFG3.js.map} +0 -0
  46. /package/dist/{daemon-UXC7PB4P.js.map → daemon-SLGQGRKO.js.map} +0 -0
  47. /package/dist/{install-cloudflared-LMM7MFQX.js.map → install-cloudflared-ILUXKLAC.js.map} +0 -0
  48. /package/dist/{setup-UKWBLJIT.js.map → setup-JQZBPXWS.js.map} +0 -0
  49. /package/dist/{tunnel-service-4GISQZNP.js.map → tunnel-service-DASSH7OA.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -3,11 +3,16 @@ import {
3
3
  installPlugin,
4
4
  listPlugins,
5
5
  uninstallPlugin
6
- } from "./chunk-LVSQQRCF.js";
7
- import "./chunk-YXMRR2E3.js";
6
+ } from "./chunk-2SY7Y2VB.js";
8
7
  import {
9
- __require
10
- } from "./chunk-JOSJGZGF.js";
8
+ checkAndPromptUpdate,
9
+ compareVersions,
10
+ getCurrentVersion,
11
+ getLatestVersion,
12
+ runUpdate
13
+ } from "./chunk-KSIQZC3J.js";
14
+ import "./chunk-WF5XDN4D.js";
15
+ import "./chunk-LYKCQTH5.js";
11
16
 
12
17
  // src/cli.ts
13
18
  import { setDefaultAutoSelectFamily } from "net";
@@ -36,83 +41,7 @@ async function apiCall(port, urlPath, options) {
36
41
  return fetch(`http://127.0.0.1:${port}${urlPath}`, options);
37
42
  }
38
43
 
39
- // src/cli.ts
40
- setDefaultAutoSelectFamily(false);
41
- var NPM_PACKAGE = "@openacp/cli";
42
- var args = process.argv.slice(2);
43
- var command = args[0];
44
- function getCurrentVersion() {
45
- try {
46
- const { createRequire } = __require("module");
47
- const req = createRequire(import.meta.url);
48
- const pkg = req("../package.json");
49
- return pkg.version;
50
- } catch {
51
- return "0.0.0-dev";
52
- }
53
- }
54
- async function getLatestVersion() {
55
- try {
56
- const res = await fetch(`https://registry.npmjs.org/${NPM_PACKAGE}/latest`, {
57
- signal: AbortSignal.timeout(5e3)
58
- });
59
- if (!res.ok) return null;
60
- const data = await res.json();
61
- return data.version ?? null;
62
- } catch {
63
- return null;
64
- }
65
- }
66
- function compareVersions(current, latest) {
67
- const a = current.split(".").map(Number);
68
- const b = latest.split(".").map(Number);
69
- for (let i = 0; i < 3; i++) {
70
- if ((a[i] ?? 0) < (b[i] ?? 0)) return -1;
71
- if ((a[i] ?? 0) > (b[i] ?? 0)) return 1;
72
- }
73
- return 0;
74
- }
75
- async function runUpdate() {
76
- const { spawn } = await import("child_process");
77
- return new Promise((resolve) => {
78
- const child = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@latest`], {
79
- stdio: "inherit",
80
- shell: true
81
- });
82
- const onSignal = () => {
83
- child.kill("SIGTERM");
84
- resolve(false);
85
- };
86
- process.on("SIGINT", onSignal);
87
- process.on("SIGTERM", onSignal);
88
- child.on("close", (code) => {
89
- process.off("SIGINT", onSignal);
90
- process.off("SIGTERM", onSignal);
91
- resolve(code === 0);
92
- });
93
- });
94
- }
95
- async function checkAndPromptUpdate() {
96
- const current = getCurrentVersion();
97
- if (current === "0.0.0-dev") return;
98
- const latest = await getLatestVersion();
99
- if (!latest || compareVersions(current, latest) >= 0) return;
100
- console.log(`\x1B[33mUpdate available: v${current} \u2192 v${latest}\x1B[0m`);
101
- const { confirm } = await import("@inquirer/prompts");
102
- const yes = await confirm({
103
- message: "Update now before starting?",
104
- default: true
105
- });
106
- if (yes) {
107
- const ok = await runUpdate();
108
- if (ok) {
109
- console.log(`\x1B[32m\u2713 Updated to v${latest}. Please re-run your command.\x1B[0m`);
110
- process.exit(0);
111
- } else {
112
- console.error("\x1B[31mUpdate failed. Continuing with current version.\x1B[0m");
113
- }
114
- }
115
- }
44
+ // src/cli/commands.ts
116
45
  function printHelp() {
117
46
  console.log(`
118
47
  OpenACP - Self-hosted bridge for AI coding agents
@@ -151,279 +80,258 @@ Examples:
151
80
  openacp uninstall @openacp/adapter-discord
152
81
  `);
153
82
  }
154
- async function main() {
155
- if (command === "--help" || command === "-h") {
156
- printHelp();
157
- return;
83
+ async function cmdVersion() {
84
+ try {
85
+ const { createRequire } = await import("module");
86
+ const require2 = createRequire(import.meta.url);
87
+ const pkg = require2("../../package.json");
88
+ console.log(`openacp v${pkg.version}`);
89
+ } catch {
90
+ console.log("openacp v0.0.0-dev");
158
91
  }
159
- if (command === "--version" || command === "-v") {
160
- try {
161
- const { createRequire } = await import("module");
162
- const require2 = createRequire(import.meta.url);
163
- const pkg = require2("../package.json");
164
- console.log(`openacp v${pkg.version}`);
165
- } catch {
166
- console.log("openacp v0.0.0-dev");
167
- }
168
- return;
92
+ }
93
+ async function cmdInstall(args2) {
94
+ const pkg = args2[1];
95
+ if (!pkg) {
96
+ console.error("Usage: openacp install <package>");
97
+ process.exit(1);
169
98
  }
170
- if (command === "install") {
171
- const pkg = args[1];
172
- if (!pkg) {
173
- console.error("Usage: openacp install <package>");
174
- process.exit(1);
175
- }
176
- installPlugin(pkg);
177
- return;
99
+ installPlugin(pkg);
100
+ }
101
+ async function cmdUninstall(args2) {
102
+ const pkg = args2[1];
103
+ if (!pkg) {
104
+ console.error("Usage: openacp uninstall <package>");
105
+ process.exit(1);
178
106
  }
179
- if (command === "uninstall") {
180
- const pkg = args[1];
181
- if (!pkg) {
182
- console.error("Usage: openacp uninstall <package>");
183
- process.exit(1);
107
+ uninstallPlugin(pkg);
108
+ }
109
+ async function cmdPlugins() {
110
+ const plugins = listPlugins();
111
+ const entries = Object.entries(plugins);
112
+ if (entries.length === 0) {
113
+ console.log("No plugins installed.");
114
+ } else {
115
+ console.log("Installed plugins:");
116
+ for (const [name, version] of entries) {
117
+ console.log(` ${name}@${version}`);
184
118
  }
185
- uninstallPlugin(pkg);
186
- return;
187
119
  }
188
- if (command === "plugins") {
189
- const plugins = listPlugins();
190
- const entries = Object.entries(plugins);
191
- if (entries.length === 0) {
192
- console.log("No plugins installed.");
193
- } else {
194
- console.log("Installed plugins:");
195
- for (const [name, version] of entries) {
196
- console.log(` ${name}@${version}`);
197
- }
198
- }
199
- return;
120
+ }
121
+ async function cmdRuntime(args2) {
122
+ const subCmd = args2[1];
123
+ const port = readApiPort();
124
+ if (port === null) {
125
+ console.error("OpenACP is not running. Start with `openacp start`");
126
+ process.exit(1);
200
127
  }
201
- if (command === "runtime") {
202
- const subCmd = args[1];
203
- const port = readApiPort();
204
- if (port === null) {
205
- console.error("OpenACP is not running. Start with `openacp start`");
206
- process.exit(1);
207
- }
208
- try {
209
- if (subCmd === "new") {
210
- const agent = args[2];
211
- const workspaceIdx = args.indexOf("--workspace");
212
- const workspace = workspaceIdx !== -1 ? args[workspaceIdx + 1] : args[3];
213
- const body = {};
214
- if (agent) body.agent = agent;
215
- if (workspace) body.workspace = workspace;
216
- const res = await apiCall(port, "/api/sessions", {
217
- method: "POST",
218
- headers: { "Content-Type": "application/json" },
219
- body: JSON.stringify(body)
220
- });
221
- const data = await res.json();
222
- if (!res.ok) {
223
- console.error(`Error: ${data.error}`);
224
- process.exit(1);
225
- }
226
- console.log("Session created");
227
- console.log(` ID : ${data.sessionId}`);
228
- console.log(` Agent : ${data.agent}`);
229
- console.log(` Workspace : ${data.workspace}`);
230
- console.log(` Status : ${data.status}`);
231
- } else if (subCmd === "cancel") {
232
- const sessionId = args[2];
233
- if (!sessionId) {
234
- console.error("Usage: openacp runtime cancel <session-id>");
235
- process.exit(1);
236
- }
237
- const res = await apiCall(port, `/api/sessions/${encodeURIComponent(sessionId)}`, {
238
- method: "DELETE"
239
- });
240
- const data = await res.json();
241
- if (!res.ok) {
242
- console.error(`Error: ${data.error}`);
243
- process.exit(1);
244
- }
245
- console.log(`Session ${sessionId} cancelled`);
246
- } else if (subCmd === "status") {
247
- const res = await apiCall(port, "/api/sessions");
248
- const data = await res.json();
249
- if (data.sessions.length === 0) {
250
- console.log("No active sessions.");
251
- } else {
252
- console.log(`Active sessions: ${data.sessions.length}
253
- `);
254
- for (const s of data.sessions) {
255
- const name = s.name ? ` "${s.name}"` : "";
256
- console.log(` ${s.id} ${s.agent} ${s.status}${name}`);
257
- }
258
- }
259
- } else if (subCmd === "agents") {
260
- const res = await apiCall(port, "/api/agents");
261
- const data = await res.json();
262
- console.log("Available agents:");
263
- for (const a of data.agents) {
264
- const isDefault = a.name === data.default ? " (default)" : "";
265
- console.log(` ${a.name}${isDefault}`);
266
- }
267
- } else {
268
- console.error(`Unknown runtime command: ${subCmd || "(none)"}
269
- `);
270
- console.log("Usage:");
271
- console.log(" openacp runtime new [agent] [workspace] Create a new session");
272
- console.log(" openacp runtime cancel <id> Cancel a session");
273
- console.log(" openacp runtime status Show active sessions");
274
- console.log(" openacp runtime agents List available agents");
128
+ try {
129
+ if (subCmd === "new") {
130
+ const agent = args2[2];
131
+ const workspaceIdx = args2.indexOf("--workspace");
132
+ const workspace = workspaceIdx !== -1 ? args2[workspaceIdx + 1] : args2[3];
133
+ const body = {};
134
+ if (agent) body.agent = agent;
135
+ if (workspace) body.workspace = workspace;
136
+ const res = await apiCall(port, "/api/sessions", {
137
+ method: "POST",
138
+ headers: { "Content-Type": "application/json" },
139
+ body: JSON.stringify(body)
140
+ });
141
+ const data = await res.json();
142
+ if (!res.ok) {
143
+ console.error(`Error: ${data.error}`);
275
144
  process.exit(1);
276
145
  }
277
- } catch (err) {
278
- if (err instanceof TypeError && err.cause?.code === "ECONNREFUSED") {
279
- console.error("OpenACP is not running (stale port file)");
280
- removeStalePortFile();
146
+ console.log("Session created");
147
+ console.log(` ID : ${data.sessionId}`);
148
+ console.log(` Agent : ${data.agent}`);
149
+ console.log(` Workspace : ${data.workspace}`);
150
+ console.log(` Status : ${data.status}`);
151
+ } else if (subCmd === "cancel") {
152
+ const sessionId = args2[2];
153
+ if (!sessionId) {
154
+ console.error("Usage: openacp runtime cancel <session-id>");
281
155
  process.exit(1);
282
156
  }
283
- throw err;
284
- }
285
- return;
286
- }
287
- if (command === "start") {
288
- await checkAndPromptUpdate();
289
- const { startDaemon, getPidPath } = await import("./daemon-UXC7PB4P.js");
290
- const { ConfigManager: ConfigManager2 } = await import("./config-2CBRLF3R.js");
291
- const cm2 = new ConfigManager2();
292
- if (await cm2.exists()) {
293
- await cm2.load();
294
- const config2 = cm2.get();
295
- const result = startDaemon(getPidPath(), config2.logging.logDir);
296
- if ("error" in result) {
297
- console.error(result.error);
157
+ const res = await apiCall(port, `/api/sessions/${encodeURIComponent(sessionId)}`, {
158
+ method: "DELETE"
159
+ });
160
+ const data = await res.json();
161
+ if (!res.ok) {
162
+ console.error(`Error: ${data.error}`);
298
163
  process.exit(1);
299
164
  }
300
- console.log(`OpenACP daemon started (PID ${result.pid})`);
165
+ console.log(`Session ${sessionId} cancelled`);
166
+ } else if (subCmd === "status") {
167
+ const res = await apiCall(port, "/api/sessions");
168
+ const data = await res.json();
169
+ if (data.sessions.length === 0) {
170
+ console.log("No active sessions.");
171
+ } else {
172
+ console.log(`Active sessions: ${data.sessions.length}
173
+ `);
174
+ for (const s of data.sessions) {
175
+ const name = s.name ? ` "${s.name}"` : "";
176
+ console.log(` ${s.id} ${s.agent} ${s.status}${name}`);
177
+ }
178
+ }
179
+ } else if (subCmd === "agents") {
180
+ const res = await apiCall(port, "/api/agents");
181
+ const data = await res.json();
182
+ console.log("Available agents:");
183
+ for (const a of data.agents) {
184
+ const isDefault = a.name === data.default ? " (default)" : "";
185
+ console.log(` ${a.name}${isDefault}`);
186
+ }
301
187
  } else {
302
- console.error('No config found. Run "openacp" first to set up.');
188
+ console.error(`Unknown runtime command: ${subCmd || "(none)"}
189
+ `);
190
+ console.log("Usage:");
191
+ console.log(" openacp runtime new [agent] [workspace] Create a new session");
192
+ console.log(" openacp runtime cancel <id> Cancel a session");
193
+ console.log(" openacp runtime status Show active sessions");
194
+ console.log(" openacp runtime agents List available agents");
303
195
  process.exit(1);
304
196
  }
305
- return;
197
+ } catch (err) {
198
+ if (err instanceof TypeError && err.cause?.code === "ECONNREFUSED") {
199
+ console.error("OpenACP is not running (stale port file)");
200
+ removeStalePortFile();
201
+ process.exit(1);
202
+ }
203
+ throw err;
306
204
  }
307
- if (command === "stop") {
308
- const { stopDaemon } = await import("./daemon-UXC7PB4P.js");
309
- const result = stopDaemon();
310
- if (result.stopped) {
311
- console.log(`OpenACP daemon stopped (was PID ${result.pid})`);
312
- } else {
205
+ }
206
+ async function cmdStart() {
207
+ await checkAndPromptUpdate();
208
+ const { startDaemon, getPidPath } = await import("./daemon-SLGQGRKO.js");
209
+ const { ConfigManager } = await import("./config-J5YQOMDU.js");
210
+ const cm = new ConfigManager();
211
+ if (await cm.exists()) {
212
+ await cm.load();
213
+ const config = cm.get();
214
+ const result = startDaemon(getPidPath(), config.logging.logDir);
215
+ if ("error" in result) {
313
216
  console.error(result.error);
314
217
  process.exit(1);
315
218
  }
316
- return;
219
+ console.log(`OpenACP daemon started (PID ${result.pid})`);
220
+ } else {
221
+ console.error('No config found. Run "openacp" first to set up.');
222
+ process.exit(1);
317
223
  }
318
- if (command === "status") {
319
- const { getStatus } = await import("./daemon-UXC7PB4P.js");
320
- const status = getStatus();
321
- if (status.running) {
322
- console.log(`OpenACP is running (PID ${status.pid})`);
323
- } else {
324
- console.log("OpenACP is not running");
325
- }
326
- return;
224
+ }
225
+ async function cmdStop() {
226
+ const { stopDaemon } = await import("./daemon-SLGQGRKO.js");
227
+ const result = stopDaemon();
228
+ if (result.stopped) {
229
+ console.log(`OpenACP daemon stopped (was PID ${result.pid})`);
230
+ } else {
231
+ console.error(result.error);
232
+ process.exit(1);
327
233
  }
328
- if (command === "logs") {
329
- const { spawn } = await import("child_process");
330
- const { ConfigManager: ConfigManager2, expandHome } = await import("./config-2CBRLF3R.js");
331
- const pathMod = await import("path");
332
- const cm2 = new ConfigManager2();
333
- let logDir = "~/.openacp/logs";
334
- if (await cm2.exists()) {
335
- await cm2.load();
336
- logDir = cm2.get().logging.logDir;
337
- }
338
- const logFile = pathMod.join(expandHome(logDir), "openacp.log");
339
- const tail = spawn("tail", ["-f", "-n", "50", logFile], { stdio: "inherit" });
340
- tail.on("error", (err) => {
341
- console.error(`Cannot tail log file: ${err.message}`);
342
- process.exit(1);
343
- });
344
- return;
234
+ }
235
+ async function cmdStatus() {
236
+ const { getStatus } = await import("./daemon-SLGQGRKO.js");
237
+ const status = getStatus();
238
+ if (status.running) {
239
+ console.log(`OpenACP is running (PID ${status.pid})`);
240
+ } else {
241
+ console.log("OpenACP is not running");
345
242
  }
346
- if (command === "config") {
347
- const { runConfigEditor } = await import("./config-editor-UN56HQCW.js");
348
- const { ConfigManager: ConfigManager2 } = await import("./config-2CBRLF3R.js");
349
- const cm2 = new ConfigManager2();
350
- if (!await cm2.exists()) {
351
- console.error('No config found. Run "openacp" first to set up.');
352
- process.exit(1);
353
- }
354
- await runConfigEditor(cm2);
355
- return;
243
+ }
244
+ async function cmdLogs() {
245
+ const { spawn } = await import("child_process");
246
+ const { ConfigManager, expandHome } = await import("./config-J5YQOMDU.js");
247
+ const pathMod = await import("path");
248
+ const cm = new ConfigManager();
249
+ let logDir = "~/.openacp/logs";
250
+ if (await cm.exists()) {
251
+ await cm.load();
252
+ logDir = cm.get().logging.logDir;
356
253
  }
357
- if (command === "reset") {
358
- const { getStatus } = await import("./daemon-UXC7PB4P.js");
359
- const status = getStatus();
360
- if (status.running) {
361
- console.error("OpenACP is running. Stop it first: openacp stop");
362
- process.exit(1);
363
- }
364
- const { confirm } = await import("@inquirer/prompts");
365
- const yes = await confirm({
366
- message: "This will delete all OpenACP data (~/.openacp). You will need to set up again. Continue?",
367
- default: false
368
- });
369
- if (!yes) {
370
- console.log("Aborted.");
371
- return;
372
- }
373
- const { uninstallAutoStart } = await import("./autostart-N4HIL6C3.js");
374
- uninstallAutoStart();
375
- const fs2 = await import("fs");
376
- const os2 = await import("os");
377
- const path2 = await import("path");
378
- const openacpDir = path2.join(os2.homedir(), ".openacp");
379
- fs2.rmSync(openacpDir, { recursive: true, force: true });
380
- console.log("Reset complete. Run `openacp` to set up again.");
381
- return;
254
+ const logFile = pathMod.join(expandHome(logDir), "openacp.log");
255
+ const tail = spawn("tail", ["-f", "-n", "50", logFile], { stdio: "inherit" });
256
+ tail.on("error", (err) => {
257
+ console.error(`Cannot tail log file: ${err.message}`);
258
+ process.exit(1);
259
+ });
260
+ }
261
+ async function cmdConfig() {
262
+ const { runConfigEditor } = await import("./config-editor-IXL4BFG3.js");
263
+ const { ConfigManager } = await import("./config-J5YQOMDU.js");
264
+ const cm = new ConfigManager();
265
+ if (!await cm.exists()) {
266
+ console.error('No config found. Run "openacp" first to set up.');
267
+ process.exit(1);
382
268
  }
383
- if (command === "update") {
384
- const current = getCurrentVersion();
385
- const latest = await getLatestVersion();
386
- if (!latest) {
387
- console.error("Could not check for updates. Check your internet connection.");
388
- process.exit(1);
389
- }
390
- if (compareVersions(current, latest) >= 0) {
391
- console.log(`Already up to date (v${current})`);
392
- return;
393
- }
394
- console.log(`Update available: v${current} \u2192 v${latest}`);
395
- const ok = await runUpdate();
396
- if (ok) {
397
- console.log(`\x1B[32m\u2713 Updated to v${latest}\x1B[0m`);
398
- } else {
399
- console.error("Update failed. Try manually: npm install -g @openacp/cli@latest");
400
- process.exit(1);
401
- }
269
+ await runConfigEditor(cm);
270
+ }
271
+ async function cmdReset() {
272
+ const { getStatus } = await import("./daemon-SLGQGRKO.js");
273
+ const status = getStatus();
274
+ if (status.running) {
275
+ console.error("OpenACP is running. Stop it first: openacp stop");
276
+ process.exit(1);
277
+ }
278
+ const { confirm } = await import("@inquirer/prompts");
279
+ const yes = await confirm({
280
+ message: "This will delete all OpenACP data (~/.openacp). You will need to set up again. Continue?",
281
+ default: false
282
+ });
283
+ if (!yes) {
284
+ console.log("Aborted.");
402
285
  return;
403
286
  }
404
- if (command === "--daemon-child") {
405
- const { startServer: startServer2 } = await import("./main-P3OUOY7X.js");
406
- await startServer2();
287
+ const { uninstallAutoStart } = await import("./autostart-DZ3MHHMM.js");
288
+ uninstallAutoStart();
289
+ const fs2 = await import("fs");
290
+ const os2 = await import("os");
291
+ const path2 = await import("path");
292
+ const openacpDir = path2.join(os2.homedir(), ".openacp");
293
+ fs2.rmSync(openacpDir, { recursive: true, force: true });
294
+ console.log("Reset complete. Run `openacp` to set up again.");
295
+ }
296
+ async function cmdUpdate() {
297
+ const current = getCurrentVersion();
298
+ const latest = await getLatestVersion();
299
+ if (!latest) {
300
+ console.error("Could not check for updates. Check your internet connection.");
301
+ process.exit(1);
302
+ }
303
+ if (compareVersions(current, latest) >= 0) {
304
+ console.log(`Already up to date (v${current})`);
407
305
  return;
408
306
  }
409
- const forceForeground = command === "--foreground";
410
- if (command && !command.startsWith("-")) {
411
- console.error(`Unknown command: ${command}`);
307
+ console.log(`Update available: v${current} \u2192 v${latest}`);
308
+ const ok = await runUpdate();
309
+ if (ok) {
310
+ console.log(`\x1B[32m\u2713 Updated to v${latest}\x1B[0m`);
311
+ } else {
312
+ console.error("Update failed. Try manually: npm install -g @openacp/cli@latest");
313
+ process.exit(1);
314
+ }
315
+ }
316
+ async function cmdDefault(command2) {
317
+ const forceForeground = command2 === "--foreground";
318
+ if (command2 && !command2.startsWith("-")) {
319
+ console.error(`Unknown command: ${command2}`);
412
320
  printHelp();
413
321
  process.exit(1);
414
322
  }
415
323
  await checkAndPromptUpdate();
416
- const { ConfigManager } = await import("./config-2CBRLF3R.js");
324
+ const { ConfigManager } = await import("./config-J5YQOMDU.js");
417
325
  const cm = new ConfigManager();
418
326
  if (!await cm.exists()) {
419
- const { runSetup } = await import("./setup-UKWBLJIT.js");
327
+ const { runSetup } = await import("./setup-JQZBPXWS.js");
420
328
  const shouldStart = await runSetup(cm);
421
329
  if (!shouldStart) process.exit(0);
422
330
  }
423
331
  await cm.load();
424
332
  const config = cm.get();
425
333
  if (!forceForeground && config.runMode === "daemon") {
426
- const { startDaemon, getPidPath } = await import("./daemon-UXC7PB4P.js");
334
+ const { startDaemon, getPidPath } = await import("./daemon-SLGQGRKO.js");
427
335
  const result = startDaemon(getPidPath(), config.logging.logDir);
428
336
  if ("error" in result) {
429
337
  console.error(result.error);
@@ -432,11 +340,45 @@ async function main() {
432
340
  console.log(`OpenACP daemon started (PID ${result.pid})`);
433
341
  return;
434
342
  }
435
- const { markRunning } = await import("./daemon-UXC7PB4P.js");
343
+ const { markRunning } = await import("./daemon-SLGQGRKO.js");
436
344
  markRunning();
437
- const { startServer } = await import("./main-P3OUOY7X.js");
345
+ const { startServer } = await import("./main-5QGMP7VG.js");
438
346
  await startServer();
439
347
  }
348
+
349
+ // src/cli.ts
350
+ setDefaultAutoSelectFamily(false);
351
+ var args = process.argv.slice(2);
352
+ var command = args[0];
353
+ var commands = {
354
+ "--help": async () => printHelp(),
355
+ "-h": async () => printHelp(),
356
+ "--version": () => cmdVersion(),
357
+ "-v": () => cmdVersion(),
358
+ "install": () => cmdInstall(args),
359
+ "uninstall": () => cmdUninstall(args),
360
+ "plugins": () => cmdPlugins(),
361
+ "runtime": () => cmdRuntime(args),
362
+ "start": () => cmdStart(),
363
+ "stop": () => cmdStop(),
364
+ "status": () => cmdStatus(),
365
+ "logs": () => cmdLogs(),
366
+ "config": () => cmdConfig(),
367
+ "reset": () => cmdReset(),
368
+ "update": () => cmdUpdate(),
369
+ "--daemon-child": async () => {
370
+ const { startServer } = await import("./main-5QGMP7VG.js");
371
+ await startServer();
372
+ }
373
+ };
374
+ async function main() {
375
+ const handler = command ? commands[command] : void 0;
376
+ if (handler) {
377
+ await handler();
378
+ } else {
379
+ await cmdDefault(command);
380
+ }
381
+ }
440
382
  main().catch((err) => {
441
383
  console.error("Fatal:", err);
442
384
  process.exit(1);