@anhlp/alp-cli 0.0.1-beta.6 → 0.0.1-beta.7

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.1-beta.6" : "dev";
10
+ var VERSION = true ? "0.0.1-beta.7" : "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.1-beta.6",
2
+ "version": "0.0.1-beta.7",
3
3
  "entries": {
4
4
  "packages/cli/dist/alpd.js": {
5
5
  "inputs": [
package/dist/cli.js CHANGED
@@ -15,11 +15,11 @@ import { webCommand, acpCommand } from "./interfaces.js";
15
15
  import { backupCommand, restoreCommand } from "./backup.js";
16
16
  import { terminalCommand } from "./terminal.js";
17
17
  import { bridgeCommand } from "./roles.js";
18
- import { cleanupOldExecutable, selfUpdate } from "./self-update.js";
19
- import { executablePath, packagedInfo } from "@anhlp/alp-core/packaged";
18
+ import { selfUpdate } from "./self-update.js";
19
+ import { bundleInfo } from "@anhlp/alp-core/packaged";
20
20
  import { connect, lockAlive, readLock } from "@anhlp/alp-client/index";
21
21
  function alpVersion() {
22
- return packagedInfo()?.version ?? (true ? "0.0.1-beta.6" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version);
22
+ return true ? "0.0.1-beta.7" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
23
23
  }
24
24
  async function runningDaemon() {
25
25
  const lock = await readLock(alpHome());
@@ -36,13 +36,9 @@ async function runningDaemon() {
36
36
  }
37
37
  }
38
38
  async function updateCommand(args2) {
39
- const code = await selfUpdate(args2, { packaged: packagedInfo() !== void 0, version: alpVersion(), daemon: runningDaemon });
39
+ const code = await selfUpdate(args2, { bundle: bundleInfo(), version: alpVersion(), daemon: runningDaemon });
40
40
  if (code) process.exitCode = code;
41
41
  }
42
- {
43
- const executable = executablePath();
44
- if (executable) cleanupOldExecutable(executable);
45
- }
46
42
  var commands = { schedule: scheduleCommand, setup: (args2) => setup(args2, alpHome()), init: (args2) => project("init", args2), "update-template": (args2) => project("upgrade", args2), upgrade: (args2) => project("upgrade", args2), update: updateCommand, 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, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
47
43
  var [command, ...args] = process.argv.slice(2);
48
44
  try {
@@ -8,7 +8,7 @@ import { alpHome, connect, daemonPaths, discoverIntegration, startIntegration }
8
8
  import { UsageError } from "./usage.js";
9
9
  import { built, start, running } from "./daemon.js";
10
10
  import { DAEMON_ENTRY, distributionEntry } from "./paths.js";
11
- import { entryCommand, packagedInfo } from "@anhlp/alp-core/packaged";
11
+ import { entryCommand } from "@anhlp/alp-core/packaged";
12
12
  import { runRole } from "./roles.js";
13
13
  import { alpWebEntry, alpWebScript, isWebClaimed, isWebReady, refusal, stopPreRenamePaseo, stopWebService, webOwner } from "./web-service.js";
14
14
  var PASEO = "paseo";
@@ -224,10 +224,9 @@ ${pairing.url}`);
224
224
  async function acpCommand(args) {
225
225
  if (args.length) throw new UsageError();
226
226
  await built();
227
- const acp = packagedInfo()?.roles?.acp;
228
227
  const { runAcp } = (
229
228
  /** @type {{ runAcp: (options: { daemonEntry: string }) => Promise<void> }} */
230
- acp ? await acp() : await import(distributionEntry("acp.js").href)
229
+ await import(distributionEntry("acp.js").href)
231
230
  );
232
231
  await runAcp({ daemonEntry: DAEMON_ENTRY });
233
232
  }
package/dist/paths.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** Locate artifacts in either the independently shipped CLI or the legacy root build. */
2
2
  export function distributionEntry(name: any): URL;
3
- /** What starts alpd: alpd.js under Node, or the ALP executable itself (`alp daemon run`). */
3
+ /** What starts alpd: alpd.js under Node (named through app/current in the ALP bundle). */
4
4
  export const DAEMON_ENTRY: string;
package/dist/roles.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The role subcommands (t-1e02): `alp daemon run`, `alp web serve` and `alp bridge acp|antigravity`
3
- * run alpd, alp-web and the MCP bridges in this process. The ALP executable starts its own roles
4
- * this way, since it cannot run a script path; under Node they import the same scripts that
5
- * `node alpd.js` and `node alp-web.js` run.
3
+ * run alpd, alp-web and the MCP bridges in this process: they import the same scripts that
4
+ * `node alpd.js` and `node alp-web.js` run. Services and MCP entries written by the single-file
5
+ * executable of 0.0.1-beta.5/6 still name them.
6
6
  *
7
7
  * The role's module reads its options from process.argv as when run directly, so argv is rewritten
8
8
  * to `[runtime, entry, ...args]` before the module loads.
package/dist/roles.js CHANGED
@@ -1,12 +1,10 @@
1
1
  // packages/cli/src/roles.js
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { runBridge } from "@anhlp/alp-core/bridges";
4
- import { packagedInfo } from "@anhlp/alp-core/packaged";
5
4
  import { UsageError } from "./usage.js";
6
5
  async function runRole(role, file, args) {
7
6
  process.argv = [process.argv[0], file, ...args];
8
- const load = packagedInfo()?.roles?.[role];
9
- return load ? load() : import(pathToFileURL(file).href);
7
+ return import(pathToFileURL(file).href);
10
8
  }
11
9
  function bridgeCommand(args) {
12
10
  if (args.length !== 1 || !["acp", "antigravity"].includes(args[0])) throw new UsageError();
@@ -58,55 +58,53 @@ export function verifyProvenance(file: string, { repo, env, run, find }: {
58
58
  }): "unavailable" | "verified";
59
59
  /**
60
60
  * Runs `action`, again after a pause while Windows reports the file busy: a virus scanner holds an
61
- * executable it just saw run (the staged file's --version) for a moment. About 6 s in all.
61
+ * executable it just saw run (the staged bundle's --version) for a moment. About 6 s in all.
62
62
  * @template T @param {() => T} action @param {(ms: number) => void} [sleep]
63
63
  */
64
64
  export function retryBusy<T>(action: () => T, sleep?: (ms: number) => void, attempts?: number): T;
65
+ /** What to say outside the ALP bundle (an npm install). @param {string[]} positionals */
66
+ export function npmMessage(positionals?: string[]): string;
67
+ /** The bundle's own Node and CLI: run without its launcher, so Windows needs no shell for alp.cmd. @param {string} root @param {string} platform */
68
+ export function bundleCommand(root: string, platform?: string): {
69
+ command: string;
70
+ args: string[];
71
+ };
65
72
  /**
66
- * Puts `staged` in place of `target`. Unix: rename over the running file. Windows: the running
67
- * alp.exe cannot be overwritten but can be renamed, so it becomes alp.old.exe (deleted on the next
68
- * start) and the new file takes its name; a failure puts the old one back.
69
- * @param {string} staged @param {string} target @param {{ platform?: string, fs?: Pick<typeof nodeFs, 'renameSync' | 'rmSync' | 'existsSync'>, unique?: () => string, sleep?: (ms: number) => void }} [options]
73
+ * Points `<app>/current` at `<app>/<version>`. Unix: a relative symlink renamed over the old one, in
74
+ * one step. Windows: the junction is replaced (removed, then made again; put back on failure).
75
+ * @param {string} app @param {string} version @param {{ platform?: string, fs?: typeof nodeFs, unique?: () => string }} [options]
70
76
  */
71
- export function replaceExecutable(staged: string, target: string, { platform, fs, unique, sleep }?: {
77
+ export function switchCurrent(app: string, version: string, { platform, fs, unique }?: {
72
78
  platform?: string;
73
- fs?: Pick<typeof nodeFs, "renameSync" | "rmSync" | "existsSync">;
79
+ fs?: typeof nodeFs;
74
80
  unique?: () => string;
75
- sleep?: (ms: number) => void;
76
- }): {
77
- old: undefined;
78
- } | {
79
- old: string;
80
- };
81
- /** Deletes the alp.old.exe (and alp.old.<hex>.exe) a Windows update left behind; called on every packaged start. @param {string} target @param {{ platform?: string, fs?: Pick<typeof nodeFs, 'rmSync' | 'readdirSync'> }} [options] */
82
- export function cleanupOldExecutable(target: string, { platform, fs }?: {
83
- platform?: string;
84
- fs?: Pick<typeof nodeFs, "rmSync" | "readdirSync">;
85
- }): boolean;
81
+ }): void;
86
82
  /**
87
- * Whether the executable is the one npm installed for @anhlp/alp (t-cd7f): it lives in a platform
88
- * package, node_modules/@anhlp/alp-<os>-<arch>/bin/. npm owns that file; updating it in place would
89
- * leave npm's records behind, so npm updates it. @param {string} execPath
83
+ * Removes what earlier updates left in `<app>`: versions other than `keep`, and staging directories.
84
+ * A failure (a file still in use on Windows) leaves that entry for the next update. keepAside keeps
85
+ * the copies earlier reinstalls moved aside, which a running alpd may still run from.
86
+ * @param {string} app @param {string[]} keep
90
87
  */
91
- export function isNpmExecutable(execPath: string): boolean;
92
- /** What to say outside the executable (an npm install). @param {string[]} positionals */
93
- export function npmMessage(positionals?: string[]): string;
88
+ export function pruneVersions(app: string, keep: string[], fs?: typeof nodeFs, { keepAside }?: {
89
+ keepAside?: boolean | undefined;
90
+ }): string[];
94
91
  /**
95
92
  * @typedef {{
96
- * packaged: boolean, version: string, execPath: string, env: NodeJS.ProcessEnv, platform: string, arch: string,
93
+ * bundle: import('@anhlp/alp-core/packaged').BundleInfo | undefined, version: string, env: NodeJS.ProcessEnv, platform: string, arch: string,
97
94
  * log: (line: string) => void, warn: (line: string) => void, interactive: boolean,
98
95
  * fetchBytes: (url: string) => Promise<Uint8Array>, confirm: (question: string) => Promise<boolean>,
99
96
  * provenance: (file: string, repo: string) => string, extract: typeof extract,
100
- * daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (binary: string) => number,
101
- * runVersion: (binary: string) => string,
97
+ * daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (root: string) => number,
98
+ * runVersion: (root: string) => string,
102
99
  * }} UpdateDeps
103
100
  */
104
101
  /** @param {string[]} args @param {Partial<UpdateDeps>} [overrides] @returns {Promise<number>} the exit code */
105
102
  export function selfUpdate(args: string[], overrides?: Partial<UpdateDeps>): Promise<number>;
106
103
  /**
107
- * `alp update` (t-1e02 P3): replaces the ALP executable with a release from GitHub Releases, after
108
- * checking the archive against the release's SHA256SUMS and, when `gh` is installed, its build
109
- * provenance. The project template upgrade that `alp update` used to run is `alp update-template`.
104
+ * `alp update` (t-1807): installs a release of the ALP bundle from GitHub Releases beside the running
105
+ * one (<app>/<version>, see @anhlp/alp-core/packaged) and points <app>/current at it, after checking
106
+ * the archive against the release's SHA256SUMS and, when `gh` is installed, its build provenance.
107
+ * The project template upgrade that `alp update` used to run is `alp update-template`.
110
108
  *
111
109
  * Everything that touches the network, the filesystem or child processes comes in through `deps`
112
110
  * so the tests can drive each step.
@@ -114,16 +112,15 @@ export function selfUpdate(args: string[], overrides?: Partial<UpdateDeps>): Pro
114
112
  export const DEFAULT_REPO: "phucanh08/alp";
115
113
  export const SIGNER_WORKFLOW: ".github/workflows/release-binaries.yml";
116
114
  export const NPM_PACKAGE: "@anhlp/alp";
117
- export const UPDATE_USAGE: "Usage: alp update [--check] [--yes] [--version X] [--base-url URL]\nReplaces this ALP executable with the latest release (or release X) from GitHub Releases, after checking\nit against SHA256SUMS and, when gh is installed, its build provenance. --check only reports.\nALP_UPDATE_BASE_URL (as --base-url, an https:// or file:// mirror) and ALP_INSTALL_REPO (owner/name) override the source.\nThe project template upgrade is `alp update-template [directory]`.";
115
+ export const UPDATE_USAGE: "Usage: alp update [--check] [--yes] [--version X] [--base-url URL]\nInstalls the latest ALP release (or release X) from GitHub Releases beside this one and switches to it, after checking\nit against SHA256SUMS and, when gh is installed, its build provenance. --check only reports.\nALP_UPDATE_BASE_URL (as --base-url, an https:// or file:// mirror) and ALP_INSTALL_REPO (owner/name) override the source.\nThe project template upgrade is `alp update-template [directory]`.";
118
116
  export function archiveExtension(platform: string): ".zip" | ".tar.gz";
119
117
  export function sha256(bytes: Uint8Array): string;
120
- /** The largest file alp update downloads: the executable is about 100 MB. */
118
+ /** The largest file alp update downloads: an archive of the bundle is about 70 MB. */
121
119
  export const MAX_DOWNLOAD: number;
122
- export function oldPath(target: string, platform?: string): string;
120
+ export function notInstalledMessage(root: string): string;
123
121
  export type UpdateDeps = {
124
- packaged: boolean;
122
+ bundle: import("@anhlp/alp-core/packaged").BundleInfo | undefined;
125
123
  version: string;
126
- execPath: string;
127
124
  env: NodeJS.ProcessEnv;
128
125
  platform: string;
129
126
  arch: string;
@@ -138,14 +135,14 @@ export type UpdateDeps = {
138
135
  version: string;
139
136
  sessions?: number;
140
137
  } | undefined>;
141
- restartDaemon: (binary: string) => number;
142
- runVersion: (binary: string) => string;
138
+ restartDaemon: (root: string) => number;
139
+ runVersion: (root: string) => string;
143
140
  };
144
141
  import { spawnSync } from 'node:child_process';
145
142
  /** Whether a program is on PATH. @param {string} name */
146
143
  declare function which(name: string): string | undefined;
147
144
  import * as nodeFs from 'node:fs';
148
- /** Extracts the archive and returns the executable inside it. @param {string} archive @param {string} directory @param {{ name: string }} asset @param {string} platform */
145
+ /** Extracts the archive into `directory` and returns the bundle inside it. @param {string} archive @param {string} directory @param {{ name: string }} asset @param {string} platform */
149
146
  declare function extract(archive: string, directory: string, asset: {
150
147
  name: string;
151
148
  }, platform: string, run?: typeof spawnSync): string;
@@ -7,21 +7,21 @@ import path from "node:path";
7
7
  import { createInterface } from "node:readline/promises";
8
8
  import { fileURLToPath, pathToFileURL } from "node:url";
9
9
  import { parseArgs } from "node:util";
10
- import { executablePath } from "@anhlp/alp-core/packaged";
10
+ import { bundleInfo, samePath } from "@anhlp/alp-core/packaged";
11
11
  var DEFAULT_REPO = "phucanh08/alp";
12
12
  var SIGNER_WORKFLOW = ".github/workflows/release-binaries.yml";
13
13
  var NPM_PACKAGE = "@anhlp/alp";
14
- var TEMPLATE_HINT = "did you mean `alp update-template`? (`alp update` now updates the ALP executable; the project template upgrade is `alp update-template [directory]`)";
14
+ var TEMPLATE_HINT = "did you mean `alp update-template`? (`alp update` now updates ALP itself; the project template upgrade is `alp update-template [directory]`)";
15
15
  var OPTIONS = { check: { type: "boolean" }, yes: { type: "boolean", short: "y" }, version: { type: "string" }, "base-url": { type: "string" }, help: { type: "boolean", short: "h" } };
16
16
  var UPDATE_USAGE = `Usage: alp update [--check] [--yes] [--version X] [--base-url URL]
17
- Replaces this ALP executable with the latest release (or release X) from GitHub Releases, after checking
17
+ Installs the latest ALP release (or release X) from GitHub Releases beside this one and switches to it, after checking
18
18
  it against SHA256SUMS and, when gh is installed, its build provenance. --check only reports.
19
19
  ALP_UPDATE_BASE_URL (as --base-url, an https:// or file:// mirror) and ALP_INSTALL_REPO (owner/name) override the source.
20
20
  The project template upgrade is \`alp update-template [directory]\`.`;
21
21
  function releasePlatform(platform = process.platform, arch = process.arch) {
22
22
  const osName = { darwin: "darwin", linux: "linux", win32: "windows" }[platform];
23
23
  const archName = { x64: "x64", arm64: "arm64" }[arch];
24
- if (!osName || !archName || osName === "windows" && archName !== "x64") throw new Error(`ALP publishes no executable for ${platform}-${arch}`);
24
+ if (!osName || !archName || osName === "windows" && archName !== "x64") throw new Error(`ALP publishes no build for ${platform}-${arch}`);
25
25
  return `${osName}-${archName}`;
26
26
  }
27
27
  var archiveExtension = (platform) => platform.startsWith("windows-") ? ".zip" : ".tar.gz";
@@ -39,7 +39,7 @@ function parseSums(text) {
39
39
  function selectAsset(sumsText, platform, version) {
40
40
  const suffix = `-${platform}${archiveExtension(platform)}`;
41
41
  const matches = parseSums(sumsText).filter(({ name }) => name.endsWith(suffix) && /^alp-[0-9]/.test(name) && (!version || name === `alp-${version}${suffix}`));
42
- if (matches.length === 0) throw new Error(`This release has no ALP executable for ${platform}${version ? ` at version ${version}` : ""}`);
42
+ if (matches.length === 0) throw new Error(`This release has no ALP build for ${platform}${version ? ` at version ${version}` : ""}`);
43
43
  if (matches.length > 1) throw new Error(`SHA256SUMS lists more than one ${platform} archive: ${matches.map((m) => m.name).join(", ")}`);
44
44
  const [match] = matches;
45
45
  if (/[^0-9A-Za-z.+_-]/.test(match.name)) throw new Error(`Unexpected archive name in SHA256SUMS: ${match.name}`);
@@ -137,11 +137,7 @@ function verifyProvenance(file, { repo, env = process.env, run = spawnSync, find
137
137
  }
138
138
  return "verified";
139
139
  }
140
- var oldPath = (target, platform = process.platform) => {
141
- const p = platform === "win32" ? path.win32 : path;
142
- return p.join(p.dirname(target), `${p.basename(target, p.extname(target))}.old${p.extname(target) || ".exe"}`);
143
- };
144
- var TRANSIENT = /* @__PURE__ */ new Set(["EBUSY", "EPERM", "EACCES"]);
140
+ var TRANSIENT = /* @__PURE__ */ new Set(["EBUSY", "EPERM", "EACCES", "ENOTEMPTY"]);
145
141
  var pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
146
142
  function retryBusy(action, sleep = pause, attempts = 25) {
147
143
  for (let attempt = 1; ; attempt++) {
@@ -153,81 +149,82 @@ function retryBusy(action, sleep = pause, attempts = 25) {
153
149
  }
154
150
  }
155
151
  }
156
- function replaceExecutable(staged, target, { platform = process.platform, fs = nodeFs, unique = () => randomBytes(4).toString("hex"), sleep = pause } = {}) {
152
+ function npmMessage(positionals = []) {
153
+ const lines = [];
154
+ if (positionals.length) lines.push(`alp: ${TEMPLATE_HINT}`);
155
+ lines.push(`This alp was installed with npm; update it with npm:
156
+ npm install -g ${NPM_PACKAGE}@beta
157
+ Then restart alpd when no sessions are running: alp daemon restart
158
+ (The project template upgrade is \`alp update-template [directory]\`.)`);
159
+ return lines.join("\n");
160
+ }
161
+ var notInstalledMessage = (root) => `alp: ${root} is not an installed ALP (no app/current points at it); install the release with install.sh (Windows: install.ps1), which alp update can then keep up to date:
162
+ curl -fsSL https://github.com/${DEFAULT_REPO}/releases/latest/download/install.sh | sh`;
163
+ var systemTar = () => process.platform === "win32" ? path.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe") : "tar";
164
+ function extract(archive, directory, asset, platform, run = spawnSync) {
165
+ const windows = platform.startsWith("windows-");
166
+ const result = run(systemTar(), [windows ? "-xf" : "-xzf", archive, "-C", directory], { encoding: "utf8", windowsHide: true });
167
+ if (result.status !== 0) throw new Error(`Could not extract ${asset.name}: ${(result.stderr || result.error?.message || "").trim()}`);
168
+ const root = path.join(directory, asset.name.slice(0, -archiveExtension(platform).length));
169
+ if (!nodeFs.existsSync(path.join(root, "alp-bundle.json"))) throw new Error(`${asset.name} does not contain an ALP bundle (${path.basename(root)}/alp-bundle.json)`);
170
+ return root;
171
+ }
172
+ function bundleCommand(root, platform = process.platform) {
173
+ const node = platform === "win32" ? path.join(root, "node", "node.exe") : path.join(root, "node", "bin", "node");
174
+ return { command: node, args: [path.join(root, "lib", "node_modules", "@anhlp", "alp-cli", "dist", "cli.js")] };
175
+ }
176
+ function switchCurrent(app, version, { platform = process.platform, fs = nodeFs, unique = () => randomBytes(6).toString("hex") } = {}) {
177
+ const p = platform === "win32" ? path.win32 : path;
178
+ const current = p.join(app, "current");
157
179
  if (platform !== "win32") {
158
- fs.renameSync(staged, target);
159
- return { old: void 0 };
160
- }
161
- const old = oldPath(target, platform);
162
- if (fs.existsSync(old)) {
180
+ const link = p.join(app, `.current-${unique()}`);
181
+ fs.symlinkSync(version, link);
163
182
  try {
164
- fs.rmSync(old, { force: true });
165
- } catch {
166
- const aside = old.replace(/\.exe$/i, `.${unique()}.exe`);
183
+ fs.renameSync(link, current);
184
+ } catch (error) {
167
185
  try {
168
- fs.renameSync(old, aside);
169
- } catch (error) {
170
- throw new Error(`${old} is in use and could not be moved (${error.code ?? error.message}); stop the ALP processes started from it (alp daemon stop) and run alp update again`);
186
+ fs.unlinkSync(link);
187
+ } catch {
171
188
  }
189
+ throw error;
172
190
  }
191
+ return;
192
+ }
193
+ let previous;
194
+ try {
195
+ previous = fs.readlinkSync(current);
196
+ } catch {
173
197
  }
174
- retryBusy(() => fs.renameSync(target, old), sleep);
198
+ if (previous !== void 0) retryBusy(() => fs.unlinkSync(current));
175
199
  try {
176
- retryBusy(() => fs.renameSync(staged, target), sleep);
200
+ fs.symlinkSync(p.join(app, version), current, "junction");
177
201
  } catch (error) {
178
- try {
179
- retryBusy(() => fs.renameSync(old, target), sleep);
180
- } catch (restore) {
181
- throw new Error(`Could not put the new executable at ${target} (${error.code ?? error.message}), and could not move the previous one back (${restore.code ?? restore.message}): rename ${old} to ${target} yourself`);
202
+ if (previous !== void 0) try {
203
+ fs.symlinkSync(previous, current, "junction");
204
+ } catch {
182
205
  }
183
206
  throw error;
184
207
  }
185
- return { old };
186
208
  }
187
- function cleanupOldExecutable(target, { platform = process.platform, fs = nodeFs } = {}) {
188
- if (platform !== "win32") return false;
189
- const old = path.win32.basename(oldPath(target, platform));
190
- const stem = old.slice(0, -".exe".length).toLowerCase();
209
+ function pruneVersions(app, keep, fs = nodeFs, { keepAside = false } = {}) {
191
210
  let names;
192
211
  try {
193
- names = fs.readdirSync(path.win32.dirname(target));
212
+ names = fs.readdirSync(app);
194
213
  } catch {
195
- return false;
214
+ return [];
196
215
  }
197
- let removed = false;
216
+ const removed = [];
198
217
  for (const name of names) {
199
- const lower = name.toLowerCase();
200
- if (lower !== `${stem}.exe` && !(lower.startsWith(`${stem}.`) && /^[0-9a-f]+\.exe$/.test(lower.slice(stem.length + 1)))) continue;
218
+ if (name === "current" || keep.includes(name) || keepAside && name.startsWith(".alp-old-")) continue;
219
+ if (!/^[0-9][0-9A-Za-z.+-]*$/.test(name) && !/^\.alp-(update|old)-[0-9A-Za-z]+$/.test(name) && !/^\.current-[0-9a-f]+$/.test(name)) continue;
201
220
  try {
202
- fs.rmSync(path.win32.join(path.win32.dirname(target), name), { force: true });
203
- removed = true;
221
+ fs.rmSync(path.join(app, name), { recursive: true, force: true });
222
+ removed.push(name);
204
223
  } catch {
205
224
  }
206
225
  }
207
226
  return removed;
208
227
  }
209
- function isNpmExecutable(execPath) {
210
- return /[\\/]node_modules[\\/]@anhlp[\\/]alp-(?:darwin|linux|win32)-(?:arm64|x64)[\\/]bin[\\/]alp(?:\.exe)?$/i.test(execPath ?? "");
211
- }
212
- function npmMessage(positionals = []) {
213
- const lines = [];
214
- if (positionals.length) lines.push(`alp: ${TEMPLATE_HINT}`);
215
- lines.push(`This alp was installed with npm; update it with npm:
216
- npm install -g ${NPM_PACKAGE}@beta
217
- Then restart alpd when no sessions are running: alp daemon restart
218
- (The project template upgrade is \`alp update-template [directory]\`.)`);
219
- return lines.join("\n");
220
- }
221
- function extract(archive, directory, asset, platform, run = spawnSync) {
222
- const windows = platform.startsWith("windows-");
223
- const tar = process.platform === "win32" ? path.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe") : "tar";
224
- const result = run(tar, [windows ? "-xf" : "-xzf", archive, "-C", directory], { encoding: "utf8", windowsHide: true });
225
- if (result.status !== 0) throw new Error(`Could not extract ${asset.name}: ${(result.stderr || result.error?.message || "").trim()}`);
226
- const name = asset.name.slice(0, -archiveExtension(platform).length);
227
- const binary = path.join(directory, name, windows ? "alp.exe" : "alp");
228
- if (!nodeFs.existsSync(binary)) throw new Error(`${asset.name} does not contain ${name}/${windows ? "alp.exe" : "alp"}`);
229
- return binary;
230
- }
231
228
  async function confirm(question) {
232
229
  const rl = createInterface({ input: process.stdin, output: process.stdout });
233
230
  try {
@@ -238,9 +235,8 @@ async function confirm(question) {
238
235
  }
239
236
  async function selfUpdate(args, overrides = {}) {
240
237
  const deps = {
241
- packaged: false,
238
+ bundle: bundleInfo(),
242
239
  version: "0.0.0",
243
- execPath: executablePath() ?? "",
244
240
  env: process.env,
245
241
  platform: process.platform,
246
242
  arch: process.arch,
@@ -252,24 +248,31 @@ async function selfUpdate(args, overrides = {}) {
252
248
  extract,
253
249
  provenance: (file, repo2) => verifyProvenance(file, { repo: repo2 }),
254
250
  daemon: async () => void 0,
255
- restartDaemon: (binary) => spawnSync(binary, ["daemon", "restart"], { stdio: "inherit", windowsHide: true }).status ?? 1,
256
- runVersion: (binary) => spawnSync(binary, ["--version"], { encoding: "utf8", windowsHide: true, timeout: 6e4 }).stdout?.trim() ?? "",
251
+ restartDaemon: (root) => {
252
+ const run = bundleCommand(root);
253
+ return spawnSync(run.command, [...run.args, "daemon", "restart"], { stdio: "inherit", windowsHide: true }).status ?? 1;
254
+ },
255
+ runVersion: (root) => {
256
+ const run = bundleCommand(root);
257
+ return spawnSync(run.command, [...run.args, "--version"], { encoding: "utf8", windowsHide: true, timeout: 6e4 }).stdout?.trim() ?? "";
258
+ },
257
259
  ...overrides
258
260
  };
261
+ const { bundle } = deps;
259
262
  let parsed;
260
263
  try {
261
264
  parsed = parseArgs({ args, allowPositionals: true, options: OPTIONS, strict: true });
262
265
  } catch (error) {
263
266
  deps.warn(`alp: ${error.message}`);
264
267
  deps.warn(`alp: ${TEMPLATE_HINT}`);
265
- return deps.packaged ? 1 : 0;
268
+ return bundle ? 1 : 0;
266
269
  }
267
270
  const { values, positionals } = parsed;
268
271
  if (values.help) {
269
272
  deps.log(UPDATE_USAGE);
270
273
  return 0;
271
274
  }
272
- if (!deps.packaged || isNpmExecutable(deps.execPath)) {
275
+ if (!bundle) {
273
276
  deps.log(npmMessage(positionals));
274
277
  return 0;
275
278
  }
@@ -277,6 +280,10 @@ async function selfUpdate(args, overrides = {}) {
277
280
  deps.warn(`alp: ${TEMPLATE_HINT}`);
278
281
  return 1;
279
282
  }
283
+ if (!bundle.current) {
284
+ deps.warn(notInstalledMessage(bundle.root));
285
+ return 1;
286
+ }
280
287
  const wanted = values.version?.replace(/^v/, "");
281
288
  if (wanted !== void 0 && !/^[0-9][0-9A-Za-z.+-]*$/.test(wanted)) throw new Error(`Invalid version: ${values.version}`);
282
289
  const repo = deps.env.ALP_INSTALL_REPO || DEFAULT_REPO;
@@ -300,27 +307,25 @@ async function selfUpdate(args, overrides = {}) {
300
307
  deps.log(`alp ${deps.version} is newer than the latest release ${asset.version}; nothing to do (pass --version ${asset.version} to go back)`);
301
308
  return 0;
302
309
  }
303
- let target;
304
- try {
305
- target = nodeFs.realpathSync(deps.execPath);
306
- } catch {
307
- target = deps.execPath;
308
- }
309
- const dir = path.dirname(target);
310
+ const { app, current } = bundle;
311
+ if (deps.platform === "win32" && asset.version === path.basename(bundle.root)) throw new Error(`ALP ${asset.version} is the version running now; Windows cannot replace it in place. Close ALP (alp daemon stop) and rerun install.ps1 to repair it`);
312
+ const running = await deps.daemon().catch(() => void 0);
310
313
  try {
311
- nodeFs.accessSync(dir, nodeFs.constants.W_OK);
314
+ nodeFs.accessSync(app, nodeFs.constants.W_OK);
312
315
  } catch {
313
- throw new Error(`${dir} is not writable; run alp update with the permissions that installed ${target}`);
316
+ throw new Error(`${app} is not writable; run alp update with the permissions that installed ALP there`);
314
317
  }
318
+ const target = path.join(app, asset.version);
315
319
  if (!values.yes) {
316
- if (!deps.interactive) throw new Error(`alp update would replace ${target} (${deps.version} \u2192 ${asset.version}); pass --yes to do it without a terminal`);
317
- if (!await deps.confirm(`Replace ${target} (${deps.version} \u2192 ${asset.version})?`)) {
320
+ if (!deps.interactive) throw new Error(`alp update would install ${target} and switch ${current} to it (${deps.version} \u2192 ${asset.version}); pass --yes to do it without a terminal`);
321
+ if (!await deps.confirm(`Install ALP ${asset.version} in ${target} and switch to it (from ${deps.version})?`)) {
318
322
  deps.log("Not updated.");
319
323
  return 1;
320
324
  }
321
325
  }
322
326
  const work = nodeFs.mkdtempSync(path.join(os.tmpdir(), "alp-update-"));
323
- let staged;
327
+ const staging = path.join(app, `.alp-update-${randomBytes(6).toString("hex")}`);
328
+ let aside;
324
329
  try {
325
330
  deps.log(`Downloading ${asset.name} from ${base}`);
326
331
  const bytes = await deps.fetchBytes(`${base}/${asset.name}`);
@@ -331,19 +336,23 @@ async function selfUpdate(args, overrides = {}) {
331
336
  const provenance = deps.provenance(archive, repo);
332
337
  if (provenance === "verified") deps.log(`Provenance verified by gh attestation (${repo}, refs/heads/main, release-binaries.yml)`);
333
338
  else deps.warn("alp: warning: gh is not available, so only the SHA256SUMS checksum was verified, not the build provenance (install gh to verify it)");
334
- const unpacked = path.join(work, "x");
335
- nodeFs.mkdirSync(unpacked);
336
- const binary = deps.extract(archive, unpacked, asset, platform);
337
- staged = path.join(dir, `.alp.update.${randomBytes(6).toString("hex")}${deps.platform === "win32" ? ".exe" : ""}`);
338
- nodeFs.copyFileSync(binary, staged);
339
- if (deps.platform !== "win32") nodeFs.chmodSync(staged, 493);
340
- const reported = deps.runVersion(staged);
341
- if (reported !== asset.version) throw new Error(`The downloaded executable reports version ${JSON.stringify(reported)}, not ${asset.version}; nothing was replaced`);
342
- replaceExecutable(staged, target, { platform: deps.platform });
343
- staged = void 0;
339
+ nodeFs.mkdirSync(staging);
340
+ const unpacked = deps.extract(archive, staging, asset, platform);
341
+ const manifest = JSON.parse(nodeFs.readFileSync(path.join(unpacked, "alp-bundle.json"), "utf8"));
342
+ if (manifest.version !== asset.version || manifest.platform && manifest.platform !== platform) throw new Error(`${asset.name} holds ALP ${manifest.version} for ${manifest.platform}, not ${asset.version} for ${platform}; nothing was changed`);
343
+ const reported = deps.runVersion(unpacked);
344
+ if (reported !== asset.version) throw new Error(`The downloaded ALP reports version ${JSON.stringify(reported)}, not ${asset.version}; nothing was changed`);
345
+ if (nodeFs.existsSync(target)) {
346
+ if (samePath(target, bundle.root) || running?.version === asset.version) {
347
+ aside = `.alp-old-${randomBytes(6).toString("hex")}`;
348
+ retryBusy(() => nodeFs.renameSync(target, path.join(app, aside)));
349
+ } else nodeFs.rmSync(target, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
350
+ }
351
+ retryBusy(() => nodeFs.renameSync(unpacked, target));
352
+ switchCurrent(app, asset.version, { platform: deps.platform });
344
353
  } finally {
345
- if (staged) try {
346
- nodeFs.rmSync(staged, { force: true, maxRetries: 10, retryDelay: 100 });
354
+ try {
355
+ nodeFs.rmSync(staging, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
347
356
  } catch {
348
357
  }
349
358
  try {
@@ -351,8 +360,8 @@ async function selfUpdate(args, overrides = {}) {
351
360
  } catch {
352
361
  }
353
362
  }
354
- deps.log(`Updated ${target}: ${deps.version} \u2192 ${asset.version}`);
355
- const running = await deps.daemon().catch(() => void 0);
363
+ pruneVersions(app, [asset.version, path.basename(bundle.root), ...running?.version ? [running.version] : [], ...aside ? [aside] : []], nodeFs, { keepAside: Boolean(running) });
364
+ deps.log(`Updated ALP ${deps.version} \u2192 ${asset.version} (${current} \u2192 ${target})`);
356
365
  if (running && running.version !== asset.version) {
357
366
  const sessions = running.sessions;
358
367
  const known = Number.isSafeInteger(sessions);
@@ -371,20 +380,20 @@ export {
371
380
  UPDATE_USAGE,
372
381
  allowedHop,
373
382
  archiveExtension,
374
- cleanupOldExecutable,
383
+ bundleCommand,
375
384
  compareVersions,
376
385
  fetchBytes,
377
- isNpmExecutable,
386
+ notInstalledMessage,
378
387
  npmMessage,
379
- oldPath,
380
388
  parseSums,
389
+ pruneVersions,
381
390
  releaseBaseUrl,
382
391
  releasePlatform,
383
- replaceExecutable,
384
392
  retryBusy,
385
393
  selectAsset,
386
394
  selfUpdate,
387
395
  sha256,
396
+ switchCurrent,
388
397
  verifyChecksum,
389
398
  verifyProvenance
390
399
  };
package/dist/usage.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export const USAGE: "Usage:\n alp <init|update-template> [directory] create a project, or upgrade an older project's ALP template (upgrade is an alias)\n alp update [--check] [--yes] [--version X] update the ALP executable from GitHub Releases (checksum and provenance checked)\n alp --version\n alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]\n [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]\n [--claude-oracle M] [--codex-oracle M] write Ph\u1EDF/Cafe's agent profiles to .alp/settings.json\n alp daemon <start|stop|restart>\n alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready\n alp daemon <install|uninstall> run alpd as a login service that restarts after a crash\n alp daemon run [--detach] [--service] run alpd in this process (what services and the ALP executable start)\n alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio\n alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address\n alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)\n alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)\n alp web rotate give alp web a new token: open pages lose access; prints the new address\n alp web pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off\n alp terminal <allow [--paseo] --yes|deny [--paseo]|status> [--json] remote terminals (a shell as you on this host; a workspace is not a sandbox), off by default\n alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to\n alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file\n alp backup verify <file> [--json] | alp backup list [--json]\n alp restore <file> [--home-only] [--dry-run] [--stop] [--replace-newer] [--json] checks the whole backup first; keeps what it replaces\n alpd must be stopped for both; --stop stops it and starts it again after\n alp run [--agent A] [--team pho|cafe|ID] [--model M] [--mode read-only|workspace-write|full-access] [--thinking T] [--project DIR] [--json] <prompt>\n alp schedule create --session ID --at ISO_WITH_OFFSET --prompt TEXT [--project DIR] [--json]\n alp schedule list [--status pending|delivered|failed|cancelled] [--project DIR] [--json]\n alp schedule <show|cancel> ID [--project DIR] [--json] one-shot wake; timer gates only unblock tasks\n alp ps [--all]\n alp top [session] [--once]\n alp attach <session> [--json]\n alp send <session> [--prompt] [--json] <text>\n child default: user mail; --prompt: explicit new prompt to a live root or child\n alp questions [--json]\n alp answer <question> <text> | alp answer <question> --dismiss [--reason R]\n alp log <session> [--json]\n alp board [--project DIR] [--json]\n alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries\n alp providers [--json] ACP and Antigravity providers in your library\n alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules\n alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]\n [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]\n alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...\n [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]\n [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]\n alp skill new <name> [--project [DIR]] [--from S] [--file FILE]\n alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)\n alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]\n alp provider add <id> --command C [--arg A]... [--env K=V]... [--label L] [-d text] [--models a,b] an ACP agent; use id antigravity for native agy\n alp provider edit antigravity --read-only-mode instructions|reject legacy, no effect: agy enforces every mode itself\n alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]\n alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider\n without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed\n alp trust [--project DIR] | --revoke [--project DIR] | --list [--json] whether the project's hooks may run\n alp permissions [--project DIR] [--json] each agent's permission profile\n alp permissions check <agent> \"<command>\" what that agent's profile says about a command\n alp tasks [ready] [--all] [--status S] [--label L] [--project DIR] [--json]\n alp tasks gates [--json] open gates; checks GitHub ones\n alp tasks compact [--days 30] [--dry-run]\n alp tasks export [-o file.jsonl] as beads JSONL\n alp tasks import [file.jsonl] [--dry-run] beads JSONL; default .beads/issues.jsonl\n alp formula list | show <name> | pour <name> [--var k=v]... [--parent ID] [--dry-run]\n alp task add <title> [-d text] [-p 0-4] [-t task|bug|feature|chore|epic] [--parent ID] [--after ID]... [-l label]... [--path P]... [--from ID]\n alp task show <id> [--json]\n alp task report <epic> [--json] what an epic came to: tasks, time, rework, verification\n alp task edit <id> [--title T] [-d text] [-p N] [-t type] [-l label]... [--path P]... [-m note]\n alp task close <id> [--reason done|wontfix|duplicate|superseded] [-m summary] [--unverified \"why\"]\n alp verify [--project DIR] [--task ID] [--json] run the project's verify commands; --task records the result\n alp task reopen <id> [-m note]\n alp task dep <add|rm> <id> [--after ID]... [--parent ID] [--related ID]...\n alp task gate add <id> --human \"question\" [--option answer]... | --timer +2h|ISO | --pr N|owner/repo#N | --run N|owner/repo#N\n alp task gate clear <id> <gate> [--choice answer] [-m note] approve; main is told by mail\n alp task gate reject <id> <gate> [-m reason] the gate stays open; main is told by mail\n alp task gate rm <id> <gate> [-m note]\n alp pause [codex|claude] [--now] [-m reason] | alp pause status hold delegation; --now parks running assignments\n alp resume [codex|claude] lift a pause; parked assignments continue\n alp models [--refresh] [--json] the models alpd offers now, from each provider (cached; refreshed every 6 h)\n alp language [name | --reset] the language agents and ALP write to you in; default Vietnamese\n alp recall <assignment|task> [--project DIR] [--json] <question> ask a finished assignment about its work\n alp interrupt <session>\n alp compact <session>";
1
+ export const USAGE: "Usage:\n alp <init|update-template> [directory] create a project, or upgrade an older project's ALP template (upgrade is an alias)\n alp update [--check] [--yes] [--version X] update ALP from GitHub Releases (checksum and provenance checked)\n alp --version\n alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]\n [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]\n [--claude-oracle M] [--codex-oracle M] write Ph\u1EDF/Cafe's agent profiles to .alp/settings.json\n alp daemon <start|stop|restart>\n alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready\n alp daemon <install|uninstall> run alpd as a login service that restarts after a crash\n alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)\n alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio\n alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address\n alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)\n alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)\n alp web rotate give alp web a new token: open pages lose access; prints the new address\n alp web pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off\n alp terminal <allow [--paseo] --yes|deny [--paseo]|status> [--json] remote terminals (a shell as you on this host; a workspace is not a sandbox), off by default\n alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to\n alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file\n alp backup verify <file> [--json] | alp backup list [--json]\n alp restore <file> [--home-only] [--dry-run] [--stop] [--replace-newer] [--json] checks the whole backup first; keeps what it replaces\n alpd must be stopped for both; --stop stops it and starts it again after\n alp run [--agent A] [--team pho|cafe|ID] [--model M] [--mode read-only|workspace-write|full-access] [--thinking T] [--project DIR] [--json] <prompt>\n alp schedule create --session ID --at ISO_WITH_OFFSET --prompt TEXT [--project DIR] [--json]\n alp schedule list [--status pending|delivered|failed|cancelled] [--project DIR] [--json]\n alp schedule <show|cancel> ID [--project DIR] [--json] one-shot wake; timer gates only unblock tasks\n alp ps [--all]\n alp top [session] [--once]\n alp attach <session> [--json]\n alp send <session> [--prompt] [--json] <text>\n child default: user mail; --prompt: explicit new prompt to a live root or child\n alp questions [--json]\n alp answer <question> <text> | alp answer <question> --dismiss [--reason R]\n alp log <session> [--json]\n alp board [--project DIR] [--json]\n alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries\n alp providers [--json] ACP and Antigravity providers in your library\n alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules\n alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]\n [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]\n alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...\n [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]\n [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]\n alp skill new <name> [--project [DIR]] [--from S] [--file FILE]\n alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)\n alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]\n alp provider add <id> --command C [--arg A]... [--env K=V]... [--label L] [-d text] [--models a,b] an ACP agent; use id antigravity for native agy\n alp provider edit antigravity --read-only-mode instructions|reject legacy, no effect: agy enforces every mode itself\n alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]\n alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider\n without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed\n alp trust [--project DIR] | --revoke [--project DIR] | --list [--json] whether the project's hooks may run\n alp permissions [--project DIR] [--json] each agent's permission profile\n alp permissions check <agent> \"<command>\" what that agent's profile says about a command\n alp tasks [ready] [--all] [--status S] [--label L] [--project DIR] [--json]\n alp tasks gates [--json] open gates; checks GitHub ones\n alp tasks compact [--days 30] [--dry-run]\n alp tasks export [-o file.jsonl] as beads JSONL\n alp tasks import [file.jsonl] [--dry-run] beads JSONL; default .beads/issues.jsonl\n alp formula list | show <name> | pour <name> [--var k=v]... [--parent ID] [--dry-run]\n alp task add <title> [-d text] [-p 0-4] [-t task|bug|feature|chore|epic] [--parent ID] [--after ID]... [-l label]... [--path P]... [--from ID]\n alp task show <id> [--json]\n alp task report <epic> [--json] what an epic came to: tasks, time, rework, verification\n alp task edit <id> [--title T] [-d text] [-p N] [-t type] [-l label]... [--path P]... [-m note]\n alp task close <id> [--reason done|wontfix|duplicate|superseded] [-m summary] [--unverified \"why\"]\n alp verify [--project DIR] [--task ID] [--json] run the project's verify commands; --task records the result\n alp task reopen <id> [-m note]\n alp task dep <add|rm> <id> [--after ID]... [--parent ID] [--related ID]...\n alp task gate add <id> --human \"question\" [--option answer]... | --timer +2h|ISO | --pr N|owner/repo#N | --run N|owner/repo#N\n alp task gate clear <id> <gate> [--choice answer] [-m note] approve; main is told by mail\n alp task gate reject <id> <gate> [-m reason] the gate stays open; main is told by mail\n alp task gate rm <id> <gate> [-m note]\n alp pause [codex|claude] [--now] [-m reason] | alp pause status hold delegation; --now parks running assignments\n alp resume [codex|claude] lift a pause; parked assignments continue\n alp models [--refresh] [--json] the models alpd offers now, from each provider (cached; refreshed every 6 h)\n alp language [name | --reset] the language agents and ALP write to you in; default Vietnamese\n alp recall <assignment|task> [--project DIR] [--json] <question> ask a finished assignment about its work\n alp interrupt <session>\n alp compact <session>";
2
2
  export class UsageError extends Error {
3
3
  }