@anhlp/alp-cli 0.0.0-beta.2 → 0.0.1-beta.3

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/backup.js CHANGED
@@ -7,7 +7,7 @@ import { acquireDaemonLock, alpHome, assertPrivateDirectory, daemonPaths, lockAl
7
7
  import { daemonHeld, holdDaemon, releaseHold } from "@anhlp/alp-client/supervise";
8
8
  import { start, stop } from "./daemon.js";
9
9
  import { UsageError } from "./usage.js";
10
- var VERSION = true ? "0.0.0-beta.2" : "dev";
10
+ var VERSION = true ? "0.0.1-beta.3" : "dev";
11
11
  var BY = `alp ${VERSION}`;
12
12
  var size = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${bytes} B`;
13
13
  var stamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.0-beta.2",
2
+ "version": "0.0.1-beta.3",
3
3
  "entries": {
4
4
  "packages/cli/dist/alpd.js": {
5
5
  "inputs": [
package/dist/cli.js CHANGED
@@ -15,8 +15,12 @@ import { backupCommand, restoreCommand } from "./backup.js";
15
15
  var commands = { setup: (args2) => setup(args2, alpHome()), init: (args2) => project("init", args2), upgrade: (args2) => project("upgrade", args2), update: (args2) => project("upgrade", args2), daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: (args2) => libraryCommand("agents", args2), skills: (args2) => libraryCommand("skills", args2), mcp: (args2) => ["add", "rm", "mv", "cp", "test", "show", "edit"].includes(args2[0]) ? editCommand("mcp", args2) : libraryCommand("mcp", args2), hooks: (args2) => libraryCommand("hooks", args2), providers: (args2) => libraryCommand("providers", args2), provider: (args2) => editCommand("providers", args2), teams: teamsCommand, trust: trustCommand, agent: (args2) => editCommand("agents", args2), team: (args2) => editCommand("teams", args2), skill: (args2) => editCommand("skills", args2), hook: (args2) => editCommand("hooks", args2), verify, recall, pause, resume, language, interrupt, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand };
16
16
  var [command, ...args] = process.argv.slice(2);
17
17
  try {
18
- if (!Object.hasOwn(commands, command)) throw new UsageError();
19
- await commands[command](args);
18
+ if (command === "--version") {
19
+ console.log(true ? "0.0.1-beta.3" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version);
20
+ } else {
21
+ if (!Object.hasOwn(commands, command)) throw new UsageError();
22
+ await commands[command](args);
23
+ }
20
24
  } catch (error) {
21
25
  if (error instanceof UsageError || error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") console.error(USAGE);
22
26
  else console.error(`alp: ${scrubText(error?.message ?? error)}`);
package/dist/daemon.js CHANGED
@@ -3,7 +3,7 @@ import { access } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { installedProgram, installService, serviceFor, uninstallService } from "@anhlp/alp-client/service";
5
5
  import { holdDaemon, startDaemon } from "@anhlp/alp-client/supervise";
6
- import { alpHome, connect, lockAlive, readLock } from "@anhlp/alp-client/index";
6
+ import { alpHome, connect, lockAlive, readLock, withDaemonLifecycle } from "@anhlp/alp-client/index";
7
7
  import { scrubText } from "@anhlp/alp-core/log";
8
8
  import { UsageError } from "./usage.js";
9
9
  import { DAEMON_ENTRY } from "./paths.js";
@@ -52,8 +52,12 @@ async function daemon([action, ...rest]) {
52
52
  const lock = await readLock(alpHome());
53
53
  console.log(`alpd ${lock.version} running (pid ${lock.pid}) on ${socket}`);
54
54
  } else if (action === "stop") {
55
- const stopped = await stop();
56
55
  await holdDaemon(alpHome());
56
+ const stopped = await withDaemonLifecycle(alpHome(), "stop", async () => {
57
+ const stopped2 = await stop();
58
+ await holdDaemon(alpHome());
59
+ return stopped2;
60
+ });
57
61
  console.log(stopped ? `alpd stopped; it stays stopped until alp daemon start, a prompt in Paseo, or ${await installed() ? "the next login" : "Paseo starting again"}` : "alpd is not running");
58
62
  } else if (action === "restart") {
59
63
  const client = await running().catch(() => void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-cli",
3
- "version": "0.0.0-beta.2",
3
+ "version": "0.0.1-beta.3",
4
4
  "type": "module",
5
5
  "description": "ALP cli module",
6
6
  "files": [
@@ -126,9 +126,9 @@
126
126
  "node": ">=22.12"
127
127
  },
128
128
  "dependencies": {
129
- "@anhlp/alp-core": "0.0.0-beta.2",
130
- "@anhlp/alp-client": "0.0.0-beta.2",
131
- "@anhlp/alp-protocol": "0.0.0-beta.2",
129
+ "@anhlp/alp-core": "0.0.1-beta.3",
130
+ "@anhlp/alp-client": "0.0.1-beta.3",
131
+ "@anhlp/alp-protocol": "0.0.1-beta.3",
132
132
  "smol-toml": "1.9.0",
133
133
  "@agentclientprotocol/sdk": "1.7.0",
134
134
  "@anthropic-ai/claude-agent-sdk": "^0.3.292"
package/src/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
2
3
  import { setup } from '@anhlp/alp-client/setup';
3
4
  import { alpHome } from '@anhlp/alp-client/index';
4
5
  import { scrubText } from '@anhlp/alp-core/log';
@@ -14,8 +15,14 @@ import { backupCommand, restoreCommand } from './backup.js';
14
15
  const commands = { setup: args => setup(args, alpHome()), init: args => project('init', args), upgrade: args => project('upgrade', args), update: args => project('upgrade', args), daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: args => libraryCommand('agents', args), skills: args => libraryCommand('skills', args), mcp: args => ['add', 'rm', 'mv', 'cp', 'test', 'show', 'edit'].includes(args[0]) ? editCommand('mcp', args) : libraryCommand('mcp', args), hooks: args => libraryCommand('hooks', args), providers: args => libraryCommand('providers', args), provider: args => editCommand('providers', args), teams: teamsCommand, trust: trustCommand, agent: args => editCommand('agents', args), team: args => editCommand('teams', args), skill: args => editCommand('skills', args), hook: args => editCommand('hooks', args), verify, recall, pause, resume, language, interrupt, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand };
15
16
  const [command, ...args] = process.argv.slice(2);
16
17
  try {
17
- if (!Object.hasOwn(commands, command)) throw new UsageError();
18
- await commands[command](args);
18
+ if (command === '--version') {
19
+ // Published builds inject their package version; source execution reads the same metadata.
20
+ /* global __ALP_VERSION__ */
21
+ console.log(typeof __ALP_VERSION__ === 'string' ? __ALP_VERSION__ : JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version);
22
+ } else {
23
+ if (!Object.hasOwn(commands, command)) throw new UsageError();
24
+ await commands[command](args);
25
+ }
19
26
  } catch (error) {
20
27
  if (error instanceof UsageError || error?.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') console.error(USAGE);
21
28
  else console.error(`alp: ${scrubText(error?.message ?? error)}`);
package/src/daemon.js CHANGED
@@ -2,7 +2,7 @@ import { access } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { installedProgram, installService, serviceFor, uninstallService } from '@anhlp/alp-client/service';
4
4
  import { holdDaemon, startDaemon } from '@anhlp/alp-client/supervise';
5
- import { alpHome, connect, lockAlive, readLock } from '@anhlp/alp-client/index';
5
+ import { alpHome, connect, lockAlive, readLock, withDaemonLifecycle } from '@anhlp/alp-client/index';
6
6
  import { scrubText } from '@anhlp/alp-core/log';
7
7
  import { UsageError } from './usage.js';
8
8
  import { DAEMON_ENTRY } from './paths.js';
@@ -66,9 +66,14 @@ async function daemon([action, ...rest]) {
66
66
  const lock = await readLock(alpHome());
67
67
  console.log(`alpd ${lock.version} running (pid ${lock.pid}) on ${socket}`);
68
68
  } else if (action === 'stop') {
69
- const stopped = await stop();
70
- // On purpose: the Paseo plugin leaves it stopped until something asks for it.
69
+ // Publish intent before waiting for a launch, then drain that launch before
70
+ // reading its lock. No detached child can arrive after this stop resolves.
71
71
  await holdDaemon(alpHome());
72
+ const stopped = await withDaemonLifecycle(alpHome(), 'stop', async () => {
73
+ const stopped = await stop();
74
+ await holdDaemon(alpHome());
75
+ return stopped;
76
+ });
72
77
  console.log(stopped ? `alpd stopped; it stays stopped until alp daemon start, a prompt in Paseo, or ${await installed() ? 'the next login' : 'Paseo starting again'}` : 'alpd is not running');
73
78
  } else if (action === 'restart') {
74
79
  const client = await running().catch(() => undefined);