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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/THIRD-PARTY-NOTICES.txt +1 -1
  2. package/dist/acp/main.js +1 -1
  3. package/dist/acp.js +7586 -2258
  4. package/dist/{alp-web → alp-dashboard}/THIRD-PARTY-NOTICES.txt +1 -1
  5. package/dist/{alp-web/assets/TerminalPanel-BeMws9CP.js → alp-dashboard/assets/TerminalPanel-BSjqIfNr.js} +1 -1
  6. package/dist/{alp-web/assets/index-Dl7motn1.js → alp-dashboard/assets/index-CZFfSOIE.js} +35 -35
  7. package/dist/{alp-web → alp-dashboard}/index.html +1 -1
  8. package/dist/{alp-web.js → alp-dashboard.js} +491 -323
  9. package/dist/alpd.js +11807 -5372
  10. package/dist/backup.js +1 -1
  11. package/dist/build-manifest.json +24 -6
  12. package/dist/cli.js +7 -4
  13. package/dist/daemon.d.ts +2 -2
  14. package/dist/daemon.js +8 -8
  15. package/dist/dashboard-migrate.d.ts +31 -0
  16. package/dist/dashboard-migrate.js +127 -0
  17. package/dist/dashboard-service.d.ts +69 -0
  18. package/dist/{web-service.js → dashboard-service.js} +30 -32
  19. package/dist/desktop.d.ts +56 -0
  20. package/dist/desktop.js +91 -0
  21. package/dist/interfaces.d.ts +2 -2
  22. package/dist/interfaces.js +134 -42
  23. package/dist/library.d.ts +16 -2
  24. package/dist/library.js +114 -7
  25. package/dist/paths.d.ts +6 -1
  26. package/dist/paths.js +4 -2
  27. package/dist/projects.js +2 -1
  28. package/dist/roles.d.ts +5 -5
  29. package/dist/self-update.d.ts +4 -2
  30. package/dist/self-update.js +29 -6
  31. package/dist/sessions.d.ts +0 -1
  32. package/dist/usage.d.ts +1 -1
  33. package/dist/usage.js +13 -6
  34. package/package.json +6 -6
  35. package/src/cli.js +8 -3
  36. package/src/daemon.js +10 -9
  37. package/src/dashboard-migrate.js +152 -0
  38. package/src/{web-service.js → dashboard-service.js} +54 -48
  39. package/src/desktop.js +122 -0
  40. package/src/interfaces.js +171 -58
  41. package/src/library.js +108 -9
  42. package/src/paths.js +9 -3
  43. package/src/projects.js +3 -1
  44. package/src/roles.js +4 -4
  45. package/src/self-update.js +45 -8
  46. package/src/sessions.js +0 -2
  47. package/src/usage.js +13 -6
  48. package/dist/web-service.d.ts +0 -56
  49. /package/dist/{alp-web → alp-dashboard}/alp-boundary.json +0 -0
  50. /package/dist/{alp-web → alp-dashboard}/apple-touch-icon.png +0 -0
  51. /package/dist/{alp-web → alp-dashboard}/assets/TerminalPanel-DLuoa74B.css +0 -0
  52. /package/dist/{alp-web → alp-dashboard}/assets/highlighter-BnicKQ_d.js +0 -0
  53. /package/dist/{alp-web → alp-dashboard}/assets/index-DwqDSiIi.css +0 -0
  54. /package/dist/{alp-web → alp-dashboard}/favicon-attention.svg +0 -0
  55. /package/dist/{alp-web → alp-dashboard}/favicon-running.svg +0 -0
  56. /package/dist/{alp-web → alp-dashboard}/favicon.svg +0 -0
@@ -6,7 +6,7 @@ import path from 'node:path';
6
6
  import { createInterface } from 'node:readline/promises';
7
7
  import { fileURLToPath, pathToFileURL } from 'node:url';
8
8
  import { parseArgs } from 'node:util';
9
- import { bundleInfo, samePath } from '@anhlp/alp-core/packaged';
9
+ import { bundleInfo, NATIVE_DAEMON, samePath } from '@anhlp/alp-core/packaged';
10
10
 
11
11
  /**
12
12
  * `alp update` (t-1807): installs a release of the ALP bundle from GitHub Releases beside the running
@@ -194,7 +194,7 @@ const pause = (/** @type {number} */ ms) => Atomics.wait(new Int32Array(new Shar
194
194
 
195
195
  /**
196
196
  * Runs `action`, again after a pause while Windows reports the file busy: a virus scanner holds an
197
- * executable it just saw run (the staged bundle's --version) for a moment. About 6 s in all.
197
+ * executable it just saw run (the staged bundle's --version) for a moment. About 8 s in all.
198
198
  * @template T @param {() => T} action @param {(ms: number) => void} [sleep]
199
199
  */
200
200
  export function retryBusy(action, sleep = pause, attempts = 25) {
@@ -217,7 +217,20 @@ export function npmMessage(positionals = []) {
217
217
  /** Why this bundle cannot update itself: it was not installed by install.sh / install.ps1. @param {string} root */
218
218
  export const 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:\n curl -fsSL https://github.com/${DEFAULT_REPO}/releases/latest/download/install.sh | sh`;
219
219
 
220
- const systemTar = () => process.platform === 'win32' ? path.join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe') : 'tar';
220
+ /**
221
+ * tar, as this platform must start it. On Windows it is the system's own bsdtar
222
+ * (%SystemRoot%\System32\tar.exe), never whatever comes first on PATH: under Git Bash that is Git's
223
+ * GNU tar, which reads a drive-letter path such as `D:\a\…\alp.zip` as a remote `host:file`
224
+ * archive and cannot read or write a zip at all. `--force-local` is not an answer: bsdtar rejects it.
225
+ *
226
+ * DUPLICATE, deliberately (t-ffe4.6): `windowsTar` in scripts/spawn-command.mjs is the same
227
+ * knowledge for the repository's own scripts. This package is published, so it cannot import from
228
+ * scripts/, and scripts/ must keep working before anything is built. Change one and change the
229
+ * other; test/integration/spawn-command.test.js asserts the two agree, and refuses any third copy.
230
+ * @param {string} platform @param {Record<string, string | undefined>} env
231
+ */
232
+ export const systemTar = (platform = process.platform, env = process.env) =>
233
+ platform === 'win32' ? path.win32.join(env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe') : 'tar';
221
234
 
222
235
  /** Extracts the archive into `directory` and returns the bundle inside it. @param {string} archive @param {string} directory @param {{ name: string }} asset @param {string} platform */
223
236
  function extract(archive, directory, asset, platform, run = spawnSync) {
@@ -291,7 +304,7 @@ async function confirm(question) {
291
304
  * fetchBytes: (url: string) => Promise<Uint8Array>, confirm: (question: string) => Promise<boolean>,
292
305
  * provenance: (file: string, repo: string) => string, extract: typeof extract,
293
306
  * daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (root: string) => number,
294
- * runVersion: (root: string) => string,
307
+ * runVersion: (root: string) => string, runDaemonVersion: (root: string) => string,
295
308
  * }} UpdateDeps
296
309
  */
297
310
 
@@ -306,6 +319,8 @@ export async function selfUpdate(args, overrides = {}) {
306
319
  daemon: async () => undefined,
307
320
  restartDaemon: root => { const run = bundleCommand(root); return spawnSync(run.command, [...run.args, 'daemon', 'restart'], { stdio: 'inherit', windowsHide: true }).status ?? 1; },
308
321
  runVersion: root => { const run = bundleCommand(root); return spawnSync(run.command, [...run.args, '--version'], { encoding: 'utf8', windowsHide: true, timeout: 60_000 }).stdout?.trim() ?? ''; },
322
+ // Without BUN_BE_BUN, which would make the native alpd the Bun CLI.
323
+ runDaemonVersion: root => spawnSync(path.join(root, 'bin', NATIVE_DAEMON), ['--version'], { encoding: 'utf8', windowsHide: true, timeout: 60_000, env: Object.fromEntries(Object.entries(process.env).filter(([name]) => name !== 'BUN_BE_BUN')) }).stdout?.trim() ?? '',
309
324
  ...overrides,
310
325
  };
311
326
  const { bundle } = deps;
@@ -344,8 +359,10 @@ export async function selfUpdate(args, overrides = {}) {
344
359
  if (order < 0 && !wanted) { deps.log(`alp ${deps.version} is newer than the latest release ${asset.version}; nothing to do (pass --version ${asset.version} to go back)`); return 0; }
345
360
 
346
361
  const { app, current } = bundle;
347
- // Windows cannot rename or delete a directory that a running node.exe (this one) comes from.
348
- 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`);
362
+ // A reinstall of the running version moves its directory aside instead of replacing it in place,
363
+ // on Windows too: Windows renames a directory that holds a running executable. Only a process
364
+ // whose working directory is inside the tree, or a handle opened without delete sharing, refuses
365
+ // the move (t-5294.7, board finding p-bcd9c956) — that failure is reported below, not predicted.
349
366
  // The version a running alpd uses keeps its files, like the one this process runs.
350
367
  const running = await deps.daemon().catch(() => undefined);
351
368
  try { nodeFs.accessSync(app, nodeFs.constants.W_OK); } catch { throw new Error(`${app} is not writable; run alp update with the permissions that installed ALP there`); }
@@ -377,12 +394,32 @@ export async function selfUpdate(args, overrides = {}) {
377
394
  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`);
378
395
  const reported = deps.runVersion(unpacked);
379
396
  if (reported !== asset.version) throw new Error(`The downloaded ALP reports version ${JSON.stringify(reported)}, not ${asset.version}; nothing was changed`);
397
+ // The native alpd (t-81b0.9) must run on this machine too: an old CPU, glibc or a quarantined file would
398
+ // otherwise leave alp without a daemon after the switch.
399
+ if (deps.env.ALP_NATIVE_DAEMON !== '0' && nodeFs.existsSync(path.join(unpacked, 'bin', NATIVE_DAEMON))) {
400
+ const native = deps.runDaemonVersion(unpacked);
401
+ if (native !== asset.version) throw new Error(`The downloaded ALP's native alpd (bin/${NATIVE_DAEMON}) reports version ${JSON.stringify(native)}, not ${asset.version}, so it cannot run here; nothing was changed. To update with alpd on the bundled Node, set ALP_NATIVE_DAEMON=0 for this update and keep it set`);
402
+ }
380
403
  if (nodeFs.existsSync(target)) {
381
404
  // A reinstall of the running version moves it aside (its processes keep their files); any other copy is stale.
382
- if (samePath(target, bundle.root) || running?.version === asset.version) { aside = `.alp-old-${randomBytes(6).toString('hex')}`; retryBusy(() => nodeFs.renameSync(target, path.join(app, aside))); }
405
+ if (samePath(target, bundle.root) || running?.version === asset.version) {
406
+ const moved = `.alp-old-${randomBytes(6).toString('hex')}`;
407
+ try { retryBusy(() => nodeFs.renameSync(target, path.join(app, moved))); } catch (error) {
408
+ // Nothing has been replaced yet. Say what really holds the directory, so nobody looks for
409
+ // a Windows rule that does not exist (t-5294.7).
410
+ 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 });
411
+ }
412
+ aside = moved;
413
+ }
383
414
  else nodeFs.rmSync(target, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
384
415
  }
385
- retryBusy(() => nodeFs.renameSync(unpacked, target));
416
+ try { retryBusy(() => nodeFs.renameSync(unpacked, target)); } catch (error) {
417
+ // The running version goes back where it was, so app/current still points at files (t-1f14).
418
+ if (aside && !nodeFs.existsSync(target)) {
419
+ try { nodeFs.renameSync(path.join(app, aside), target); aside = undefined; } catch { throw new Error(`${error.message}; the running ALP ${asset.version} is in ${path.join(app, aside)}: move it back to ${target}`, { cause: error }); }
420
+ }
421
+ throw error;
422
+ }
386
423
  switchCurrent(app, asset.version, { platform: deps.platform });
387
424
  } finally {
388
425
  // A cleanup failure must not hide why the update failed; a leftover staging directory goes with the next update.
package/src/sessions.js CHANGED
@@ -410,8 +410,6 @@ async function recall(args) {
410
410
  console.log(answer.answer);
411
411
  }
412
412
 
413
- /** alp web: opens the web app alpd serves on 127.0.0.1, with the token in the address (ALPD §61). */
414
-
415
413
  async function interrupt(args) {
416
414
  if (args.length !== 1) throw new UsageError();
417
415
  const client = await running();
package/src/usage.js CHANGED
@@ -8,16 +8,19 @@ const USAGE = `Usage:
8
8
  alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]
9
9
  [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]
10
10
  [--claude-oracle M] [--codex-oracle M] write Phở/Cafe's agent profiles to .alp/settings.json
11
+ (keeps profiles written by hand; names other teams and the keys to edit)
11
12
  alp daemon <start|stop|restart>
12
13
  alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready
13
14
  alp daemon <install|uninstall> run alpd as a login service that restarts after a crash
14
15
  alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)
15
16
  alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio
16
- alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address
17
- alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)
17
+ alp dashboard [--port N] [--host 127.0.0.1|localhost] [--no-open|--print] open ALP's dashboard in the browser (alp-dashboard, loopback only); --no-open/--print only print its address
18
+ alp dashboard --status|--stop whether alp dashboard runs (address without its token) | stop it
19
+ alp desktop open ALP's desktop app (ALP.app, else the checkout in ALP_DESKTOP_CHECKOUT)
20
+ alp dashboard serve [--service|--rotate] [--project DIR] [--port N] run alp-dashboard in this process (what alp dashboard starts)
18
21
  alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)
19
- alp web rotate give alp web a new token: open pages lose access; prints the new address
20
- 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
22
+ alp dashboard rotate give alp dashboard a new token: open pages lose access; prints the new address
23
+ alp dashboard 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
21
24
  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
22
25
  alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to
23
26
  alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file
@@ -38,18 +41,22 @@ const USAGE = `Usage:
38
41
  alp log <session> [--json]
39
42
  alp board [--project DIR] [--json]
40
43
  alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries
44
+ alp skills --retired [--json] skills alp_skill_retire moved to ~/.alp/retired-skills
41
45
  alp providers [--json] ACP and Antigravity providers in your library
42
46
  alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules
47
+ alp packs [--project DIR] [--json] optional skill packs ALP ships (backend, frontend, architecture, ...)
48
+ alp pack install <id> [--project [DIR]] [--assign] [--json] copy a pack's skills, agents and teams; existing entries are kept
43
49
  alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]
44
50
  [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]
45
51
  alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...
46
52
  [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]
47
53
  [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]
48
- alp skill new <name> [--project [DIR]] [--from S] [--file FILE]
54
+ alp skill <new|edit> <name> [--project [DIR]] [--from S] [--file FILE]
55
+ alp skill check [name|DIR] [--project [DIR]] [--strict] [--json] validate skills (format, references, links); exit 1 on errors
56
+ 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
49
57
  alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)
50
58
  alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]
51
59
  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
52
- alp provider edit antigravity --read-only-mode instructions|reject legacy, no effect: agy enforces every mode itself
53
60
  alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]
54
61
  alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider
55
62
  without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed
@@ -1,56 +0,0 @@
1
- /** The alp-web service script beside this CLI; a clear error when this CLI was built without it. */
2
- export function alpWebScript(): string;
3
- /**
4
- * The process that owns alp web's lock, if it is proven safe to stop; else why not. `kind` says
5
- * whether waiting can help: `transient` (an owner still starting has not published web.json yet),
6
- * `foreign` (proven not to be the integration: another user's, another boot's, or a reused pid) or
7
- * `unknown` (it cannot be proven either way, for example without ps or on Windows).
8
- *
9
- * The reuse proof compares the lock's creation time with the process's start from ps: when
10
- * `startedUptime` is recorded, monotonic uptime comparison prevents clock step vulnerabilities.
11
- * For legacy locks, wall-clock `startedAt` is compared.
12
- * @param {string} home
13
- * @returns {Promise<{ pid: number, app: unknown } | { reason: string, alive: boolean, kind?: 'transient' | 'foreign' | 'unknown' }>}
14
- */
15
- export function webOwner(home: string): Promise<{
16
- pid: number;
17
- app: unknown;
18
- } | {
19
- reason: string;
20
- alive: boolean;
21
- kind?: "transient" | "foreign" | "unknown";
22
- }>;
23
- /**
24
- * Stops the Paseo integration from before its rename when it still runs as integration `web` (its
25
- * web.json has no `app: 'alp-web'`), so alp-web can take the lock and web.port. Returns the pid it
26
- * stopped. A process that cannot be proven to be that integration is left alone.
27
- * @param {string} home
28
- */
29
- export function stopPreRenamePaseo(home: string): Promise<number | undefined>;
30
- /**
31
- * Stops whatever runs as integration `web` (alp-web, or the Paseo integration from before its
32
- * rename), waiting up to `timeoutMs` for a starting owner to publish what proves it. Resolves once
33
- * no live process owns the lock; refuses at once an owner that is foreign or cannot be proven.
34
- * @param {string} home @param {number} [timeoutMs]
35
- */
36
- export function stopWebService(home: string, timeoutMs?: number): Promise<number | undefined>;
37
- /** The opening of the message for a web lock held by a process alp would not stop. @param {string} home */
38
- export function refusal(home: string): string;
39
- /**
40
- * Probes whether the published web service URL is live and answering requests.
41
- * Accepts only loopback HTTP/HTTPS addresses.
42
- * @param {string | undefined} url
43
- * @param {number} [timeoutMs]
44
- */
45
- export function isWebReady(url: string | undefined, timeoutMs?: number): Promise<boolean>;
46
- /**
47
- * Whether web metadata is genuinely claimed by a live alp-web process.
48
- * If the process is proven foreign (e.g. a reused PID or from another boot) or
49
- * the URL does not answer HTTP requests, it is never claimed.
50
- * @param {any} published
51
- * @param {number | undefined} lockPid
52
- * @param {any} held
53
- * @param {number} [timeoutMs]
54
- */
55
- export function isWebClaimed(published: any, lockPid: number | undefined, held: any, timeoutMs?: number): Promise<boolean>;
56
- export function alpWebEntry(): string;
File without changes