@anhlp/alp-cli 0.0.1-beta.6 → 0.0.1-beta.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.
@@ -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 = (platform = process.platform, env = process.env) => platform === "win32" ? path.win32.join(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;
173
192
  }
174
- retryBusy(() => fs.renameSync(target, old), sleep);
193
+ let previous;
175
194
  try {
176
- retryBusy(() => fs.renameSync(staged, target), sleep);
195
+ previous = fs.readlinkSync(current);
196
+ } catch {
197
+ }
198
+ if (previous !== void 0) retryBusy(() => fs.unlinkSync(current));
199
+ try {
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,24 @@ 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
+ const running = await deps.daemon().catch(() => void 0);
310
312
  try {
311
- nodeFs.accessSync(dir, nodeFs.constants.W_OK);
313
+ nodeFs.accessSync(app, nodeFs.constants.W_OK);
312
314
  } catch {
313
- throw new Error(`${dir} is not writable; run alp update with the permissions that installed ${target}`);
315
+ throw new Error(`${app} is not writable; run alp update with the permissions that installed ALP there`);
314
316
  }
317
+ const target = path.join(app, asset.version);
315
318
  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})?`)) {
319
+ 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`);
320
+ if (!await deps.confirm(`Install ALP ${asset.version} in ${target} and switch to it (from ${deps.version})?`)) {
318
321
  deps.log("Not updated.");
319
322
  return 1;
320
323
  }
321
324
  }
322
325
  const work = nodeFs.mkdtempSync(path.join(os.tmpdir(), "alp-update-"));
323
- let staged;
326
+ const staging = path.join(app, `.alp-update-${randomBytes(6).toString("hex")}`);
327
+ let aside;
324
328
  try {
325
329
  deps.log(`Downloading ${asset.name} from ${base}`);
326
330
  const bytes = await deps.fetchBytes(`${base}/${asset.name}`);
@@ -331,19 +335,40 @@ async function selfUpdate(args, overrides = {}) {
331
335
  const provenance = deps.provenance(archive, repo);
332
336
  if (provenance === "verified") deps.log(`Provenance verified by gh attestation (${repo}, refs/heads/main, release-binaries.yml)`);
333
337
  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;
338
+ nodeFs.mkdirSync(staging);
339
+ const unpacked = deps.extract(archive, staging, asset, platform);
340
+ const manifest = JSON.parse(nodeFs.readFileSync(path.join(unpacked, "alp-bundle.json"), "utf8"));
341
+ 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`);
342
+ const reported = deps.runVersion(unpacked);
343
+ if (reported !== asset.version) throw new Error(`The downloaded ALP reports version ${JSON.stringify(reported)}, not ${asset.version}; nothing was changed`);
344
+ if (nodeFs.existsSync(target)) {
345
+ if (samePath(target, bundle.root) || running?.version === asset.version) {
346
+ const moved = `.alp-old-${randomBytes(6).toString("hex")}`;
347
+ try {
348
+ retryBusy(() => nodeFs.renameSync(target, path.join(app, moved)));
349
+ } catch (error) {
350
+ throw new Error(`Could not move ${target} aside to reinstall ALP ${asset.version}: ${error.message}. Something holds that directory: a process whose working directory is inside it, or a file handle opened without delete sharing. Stop alpd (alp daemon stop), leave that directory in any shell, and run alp update again`, { cause: error });
351
+ }
352
+ aside = moved;
353
+ } else nodeFs.rmSync(target, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
354
+ }
355
+ try {
356
+ retryBusy(() => nodeFs.renameSync(unpacked, target));
357
+ } catch (error) {
358
+ if (aside && !nodeFs.existsSync(target)) {
359
+ try {
360
+ nodeFs.renameSync(path.join(app, aside), target);
361
+ aside = void 0;
362
+ } catch {
363
+ throw new Error(`${error.message}; the running ALP ${asset.version} is in ${path.join(app, aside)}: move it back to ${target}`, { cause: error });
364
+ }
365
+ }
366
+ throw error;
367
+ }
368
+ switchCurrent(app, asset.version, { platform: deps.platform });
344
369
  } finally {
345
- if (staged) try {
346
- nodeFs.rmSync(staged, { force: true, maxRetries: 10, retryDelay: 100 });
370
+ try {
371
+ nodeFs.rmSync(staging, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
347
372
  } catch {
348
373
  }
349
374
  try {
@@ -351,8 +376,8 @@ async function selfUpdate(args, overrides = {}) {
351
376
  } catch {
352
377
  }
353
378
  }
354
- deps.log(`Updated ${target}: ${deps.version} \u2192 ${asset.version}`);
355
- const running = await deps.daemon().catch(() => void 0);
379
+ pruneVersions(app, [asset.version, path.basename(bundle.root), ...running?.version ? [running.version] : [], ...aside ? [aside] : []], nodeFs, { keepAside: Boolean(running) });
380
+ deps.log(`Updated ALP ${deps.version} \u2192 ${asset.version} (${current} \u2192 ${target})`);
356
381
  if (running && running.version !== asset.version) {
357
382
  const sessions = running.sessions;
358
383
  const known = Number.isSafeInteger(sessions);
@@ -371,20 +396,21 @@ export {
371
396
  UPDATE_USAGE,
372
397
  allowedHop,
373
398
  archiveExtension,
374
- cleanupOldExecutable,
399
+ bundleCommand,
375
400
  compareVersions,
376
401
  fetchBytes,
377
- isNpmExecutable,
402
+ notInstalledMessage,
378
403
  npmMessage,
379
- oldPath,
380
404
  parseSums,
405
+ pruneVersions,
381
406
  releaseBaseUrl,
382
407
  releasePlatform,
383
- replaceExecutable,
384
408
  retryBusy,
385
409
  selectAsset,
386
410
  selfUpdate,
387
411
  sha256,
412
+ switchCurrent,
413
+ systemTar,
388
414
  verifyChecksum,
389
415
  verifyProvenance
390
416
  };
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 (keeps profiles written by hand; names other teams and the keys to edit)\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 skills --retired [--json] skills alp_skill_retire moved to ~/.alp/retired-skills\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 packs [--project DIR] [--json] optional skill packs ALP ships (backend, frontend, architecture, ...)\n alp pack install <id> [--project [DIR]] [--assign] [--json] copy a pack's skills, agents and teams; existing entries are kept\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|edit> <name> [--project [DIR]] [--from S] [--file FILE]\n alp skill check [name|DIR] [--project [DIR]] [--strict] [--json] validate skills (format, references, links); exit 1 on errors\n alp skill restore <name> [--from DIR] [--roles a,b | --no-roles] bring back a retired skill; --roles needed if it was retired without retired.json\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 <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
  }
package/dist/usage.js CHANGED
@@ -1,15 +1,16 @@
1
1
  // packages/cli/src/usage.js
2
2
  var USAGE = `Usage:
3
3
  alp <init|update-template> [directory] create a project, or upgrade an older project's ALP template (upgrade is an alias)
4
- alp update [--check] [--yes] [--version X] update the ALP executable from GitHub Releases (checksum and provenance checked)
4
+ alp update [--check] [--yes] [--version X] update ALP from GitHub Releases (checksum and provenance checked)
5
5
  alp --version
6
6
  alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]
7
7
  [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]
8
8
  [--claude-oracle M] [--codex-oracle M] write Ph\u1EDF/Cafe's agent profiles to .alp/settings.json
9
+ (keeps profiles written by hand; names other teams and the keys to edit)
9
10
  alp daemon <start|stop|restart>
10
11
  alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready
11
12
  alp daemon <install|uninstall> run alpd as a login service that restarts after a crash
12
- alp daemon run [--detach] [--service] run alpd in this process (what services and the ALP executable start)
13
+ alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)
13
14
  alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio
14
15
  alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address
15
16
  alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)
@@ -36,18 +37,22 @@ var USAGE = `Usage:
36
37
  alp log <session> [--json]
37
38
  alp board [--project DIR] [--json]
38
39
  alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries
40
+ alp skills --retired [--json] skills alp_skill_retire moved to ~/.alp/retired-skills
39
41
  alp providers [--json] ACP and Antigravity providers in your library
40
42
  alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules
43
+ alp packs [--project DIR] [--json] optional skill packs ALP ships (backend, frontend, architecture, ...)
44
+ alp pack install <id> [--project [DIR]] [--assign] [--json] copy a pack's skills, agents and teams; existing entries are kept
41
45
  alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]
42
46
  [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]
43
47
  alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...
44
48
  [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]
45
49
  [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]
46
- alp skill new <name> [--project [DIR]] [--from S] [--file FILE]
50
+ alp skill <new|edit> <name> [--project [DIR]] [--from S] [--file FILE]
51
+ alp skill check [name|DIR] [--project [DIR]] [--strict] [--json] validate skills (format, references, links); exit 1 on errors
52
+ alp skill restore <name> [--from DIR] [--roles a,b | --no-roles] bring back a retired skill; --roles needed if it was retired without retired.json
47
53
  alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)
48
54
  alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]
49
55
  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
50
- alp provider edit antigravity --read-only-mode instructions|reject legacy, no effect: agy enforces every mode itself
51
56
  alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]
52
57
  alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider
53
58
  without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed
@@ -8,12 +8,12 @@ import { fileURLToPath } from "node:url";
8
8
  import { promisify } from "node:util";
9
9
  import { bootTime, isSameBoot, readLock } from "@anhlp/alp-client/index";
10
10
  import { distributionEntry } from "./paths.js";
11
- import { isPackaged, selfEntry } from "@anhlp/alp-core/packaged";
11
+ import { selfEntry } from "@anhlp/alp-core/packaged";
12
12
  var execFileAsync = promisify(execFile);
13
13
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14
14
  function alpWebScript() {
15
15
  const entry = fileURLToPath(distributionEntry("alp-web.js"));
16
- if (!isPackaged() && !existsSync(entry)) throw new Error(`alp web is not built: ${entry} is missing. Build the CLI (npm run build in the ALP checkout) or reinstall ALP.`);
16
+ if (!existsSync(entry)) throw new Error(`alp web is not built: ${entry} is missing. Build the CLI (npm run build in the ALP checkout) or reinstall ALP.`);
17
17
  return entry;
18
18
  }
19
19
  var alpWebEntry = () => selfEntry(alpWebScript());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-cli",
3
- "version": "0.0.1-beta.6",
3
+ "version": "0.0.1-beta.8",
4
4
  "type": "module",
5
5
  "description": "ALP cli module",
6
6
  "files": [
@@ -127,9 +127,9 @@
127
127
  "node": ">=22.12"
128
128
  },
129
129
  "dependencies": {
130
- "@anhlp/alp-core": "0.0.1-beta.6",
131
- "@anhlp/alp-client": "0.0.1-beta.6",
132
- "@anhlp/alp-protocol": "0.0.1-beta.6",
130
+ "@anhlp/alp-core": "0.0.1-beta.8",
131
+ "@anhlp/alp-client": "0.0.1-beta.8",
132
+ "@anhlp/alp-protocol": "0.0.1-beta.8",
133
133
  "smol-toml": "1.9.0",
134
134
  "@agentclientprotocol/sdk": "1.7.0",
135
135
  "@anthropic-ai/claude-agent-sdk": "^0.3.292"
@@ -161,6 +161,6 @@
161
161
  "node-pty": "1.2.0-beta.15"
162
162
  },
163
163
  "devDependencies": {
164
- "@anhlp/alp-gateway": "0.0.1-beta.6"
164
+ "@anhlp/alp-gateway": "0.0.1-beta.8"
165
165
  }
166
166
  }
package/src/cli.js CHANGED
@@ -3,25 +3,26 @@ import { readFileSync } from 'node:fs';
3
3
  import { setup } from '@anhlp/alp-client/setup';
4
4
  import { alpHome } from '@anhlp/alp-client/index';
5
5
  import { scrubText } from '@anhlp/alp-core/log';
6
+ import { catalogModels, useLiveModels } from '@anhlp/alp-core/models';
6
7
  import { USAGE, UsageError } from './usage.js';
7
8
  import { project, permissionsCommand, trustCommand, language, verify, doctor } from './projects.js';
8
9
  import { daemon } from './daemon.js';
9
10
  import { run, ps, attach, send, questions, answer, top, log, board, models, pause, resume, recall, interrupt, compact } from './sessions.js';
10
- import { libraryCommand, editCommand, teamsCommand } from './library.js';
11
+ import { libraryCommand, editCommand, teamsCommand, packsCommand, packCommand } from './library.js';
11
12
  import { scheduleCommand } from './schedules.js';
12
13
  import { tasksCommand, formulaCommand, taskCommand } from './tasks.js';
13
14
  import { webCommand, acpCommand } from './interfaces.js';
14
15
  import { backupCommand, restoreCommand } from './backup.js';
15
16
  import { terminalCommand } from './terminal.js';
16
17
  import { bridgeCommand } from './roles.js';
17
- import { cleanupOldExecutable, selfUpdate } from './self-update.js';
18
- import { executablePath, packagedInfo } from '@anhlp/alp-core/packaged';
18
+ import { selfUpdate } from './self-update.js';
19
+ import { bundleInfo } from '@anhlp/alp-core/packaged';
19
20
  import { connect, lockAlive, readLock } from '@anhlp/alp-client/index';
20
21
 
21
- /** The version of this alp: the executable's, the build's, or the package's. */
22
+ /** The version of this alp: the build's, or the package's. */
22
23
  function alpVersion() {
23
24
  /* global __ALP_VERSION__ */
24
- return packagedInfo()?.version ?? (typeof __ALP_VERSION__ === 'string' ? __ALP_VERSION__ : JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version);
25
+ return (typeof __ALP_VERSION__ === 'string' ? __ALP_VERSION__ : JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version);
25
26
  }
26
27
 
27
28
  /** The running alpd's version and live sessions, if one runs for this ALP_HOME. */
@@ -40,16 +41,13 @@ async function runningDaemon() {
40
41
  }
41
42
  }
42
43
 
43
- /** alp update: the executable's self-update (t-1e02 P3); the template upgrade is alp update-template. */
44
+ /** alp update: the bundle's self-update (t-1807); the template upgrade is alp update-template. */
44
45
  async function updateCommand(args) {
45
- const code = await selfUpdate(args, { packaged: packagedInfo() !== undefined, version: alpVersion(), daemon: runningDaemon });
46
+ const code = await selfUpdate(args, { bundle: bundleInfo(), version: alpVersion(), daemon: runningDaemon });
46
47
  if (code) process.exitCode = code;
47
48
  }
48
49
 
49
- // A Windows update leaves the previous alp.exe as alp.old.exe: it can only go once that process ended.
50
- { const executable = executablePath(); if (executable) cleanupOldExecutable(executable); }
51
-
52
- const commands = { schedule: scheduleCommand, setup: args => setup(args, alpHome()), init: args => project('init', args), 'update-template': args => project('upgrade', args), upgrade: args => project('upgrade', args), update: updateCommand, 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, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
50
+ const commands = { schedule: scheduleCommand, setup: args => setup(args, alpHome()), init: args => project('init', args), 'update-template': args => project('upgrade', args), upgrade: args => project('upgrade', args), update: updateCommand, 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, packs: packsCommand, pack: packCommand, 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, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
53
51
  const [command, ...args] = process.argv.slice(2);
54
52
  try {
55
53
  if (command === '--version') {
@@ -57,6 +55,9 @@ try {
57
55
  console.log(alpVersion());
58
56
  } else {
59
57
  if (!Object.hasOwn(commands, command)) throw new UsageError();
58
+ // Effort checks read the catalog alpd last cached, the rows alpd itself checks with (t-086c), so
59
+ // the CLI and alpd agree on a model only live rows list (t-b3cd #8). No provider is asked.
60
+ if (command !== 'setup') useLiveModels(catalogModels(alpHome()));
60
61
  await commands[command](args);
61
62
  }
62
63
  } catch (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, withDaemonLifecycle } from '@anhlp/alp-client/index';
5
+ import { alpHome, connect, daemonStartTimeoutMs, 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';
@@ -16,9 +16,9 @@ async function built() {
16
16
  }
17
17
  }
18
18
 
19
- /** Waits until an alpd for this home is ready; returns its socket. */
19
+ /** Waits until an alpd for this home is ready; returns its socket. Default wait: ALP_DAEMON_START_TIMEOUT_MS, else 60 s. */
20
20
 
21
- async function ready(timeoutMs = 15_000) {
21
+ async function ready(timeoutMs = daemonStartTimeoutMs()) {
22
22
  const deadline = Date.now() + timeoutMs;
23
23
  while (Date.now() < deadline) {
24
24
  const lock = await readLock(alpHome());
package/src/interfaces.js CHANGED
@@ -7,7 +7,8 @@ import { alpHome, connect, daemonPaths, discoverIntegration, startIntegration }
7
7
  import { UsageError } from './usage.js';
8
8
  import { built, start, running } from './daemon.js';
9
9
  import { DAEMON_ENTRY, distributionEntry } from './paths.js';
10
- import { entryCommand, packagedInfo } from '@anhlp/alp-core/packaged';
10
+ import { entryCommand } from '@anhlp/alp-core/packaged';
11
+ import { isAgentProcess } from '@anhlp/alp-core/tasks';
11
12
  import { runRole } from './roles.js';
12
13
  import { alpWebEntry, alpWebScript, isWebClaimed, isWebReady, refusal, stopPreRenamePaseo, stopWebService, webOwner } from './web-service.js';
13
14
 
@@ -186,6 +187,9 @@ async function serveWeb(home, entry) {
186
187
  }
187
188
 
188
189
  async function webCommand(args) {
190
+ // alp web prints, rotates and pairs with the user's own secrets (t-1c59): a process an ALP agent
191
+ // started is refused before anything is read, stopped or printed.
192
+ if (isAgentProcess()) throw new Error('alp web is the user\'s: it prints and rotates the user\'s credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set)');
189
193
  if (args[0] === 'pair') return pairCommand(args.slice(1));
190
194
  if (args[0] === 'rotate') return rotateCommand(args.slice(1));
191
195
  // alp-web itself in this process; its own options (--service, --rotate, --project DIR) follow.
@@ -287,8 +291,7 @@ async function pairCommand(args) {
287
291
  async function acpCommand(args) {
288
292
  if (args.length) throw new UsageError();
289
293
  await built();
290
- const acp = packagedInfo()?.roles?.acp;
291
- const { runAcp } = /** @type {{ runAcp: (options: { daemonEntry: string }) => Promise<void> }} */ (acp ? await acp() : await import(distributionEntry('acp.js').href));
294
+ const { runAcp } = /** @type {{ runAcp: (options: { daemonEntry: string }) => Promise<void> }} */ (await import(distributionEntry('acp.js').href));
292
295
  await runAcp({ daemonEntry: DAEMON_ENTRY });
293
296
  }
294
297