@anhlp/alp-client 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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ See [docs/alp/client-sdk.md](../../docs/alp/client-sdk.md) for the transport con
22
22
  request lifecycle, the old-to-new API table and what still waits on the protocol (Task 06) and
23
23
  the gateway (Task 08).
24
24
 
25
- `startIntegration({ name, entry, home, args })` (or `startIntegration(name)`; `name` defaults to `web`) discovers an optional integration's descriptor and starts it detached with `--service` and then `args`, so the entry writes its own log; discovery and the selected `ALP_HOME` are pinned by tests. `name` is a single lowercase path segment (`assertIntegrationName`). With `entry`, that script runs with the current Node and no descriptor, environment or PATH discovery happens; a missing entry is an error even when a live owner would be reused. `web` is alp-web, the service of the ALP CLI (`alp web`): it is never discovered, so it needs its `entry`, and `"web": { "enabled": false }` in the home's settings refuses it and no other integration. Everything once registered under `web` (`integrations/web.json`, the `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its rename; `discoverIntegration('paseo')` reads `ALP_PASEO_INTEGRATION`, then `ALP_WEB_INTEGRATION` for one release, then `ALP_INTEGRATION_ENTRY`. Errors name the integration, the entry and its log under `<home>/logs/integrations`. Either way a live owner of `integrations/<name>.lock` is reused, and the call resolves once that lock is ready and `<home>/<name>.json` names the same pid. Restarting is non-destructive: a daemon left running by an older install is reported as older than the current CLI and is never killed in place.
25
+ `startIntegration({ name, entry, home, args })` (or `startIntegration(name)`; `name` defaults to `web`) discovers an optional integration's descriptor and starts it detached with `--service` and then `args`, so the entry writes its own log; discovery and the selected `ALP_HOME` are pinned by tests. `name` is a single lowercase path segment (`assertIntegrationName`). With `entry`, that script runs with the current Node and no descriptor, environment or PATH discovery happens; a missing entry is an error even when a live owner would be reused. `web` is alp-dashboard, the service of the ALP CLI (`alp dashboard`): it is never discovered, so it needs its `entry`, and `"dashboard": { "enabled": false }` in the home's settings refuses it and no other integration. Everything once registered under `web` (`integrations/web.json`, the `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its rename; `discoverIntegration('paseo')` reads `ALP_PASEO_INTEGRATION`, then `ALP_WEB_INTEGRATION` for one release, then `ALP_INTEGRATION_ENTRY`. Errors name the integration, the entry and its log under `<home>/logs/integrations`. Either way a live owner of `integrations/<name>.lock` is reused, and the call resolves once that lock is ready and `<home>/<name>.json` names the same pid. Restarting is non-destructive: a daemon left running by an older install is reported as older than the current CLI and is never killed in place.
26
26
 
27
27
  Build: `npm run build --workspace=@anhlp/alp-client`. Test: `npm run test --workspace=@anhlp/alp-client`.
28
28
 
@@ -5,7 +5,7 @@
5
5
  * it also opens a session in `cwd`, as Paseo does, to read the models and modes the agent
6
6
  * offers (ALPD §65); an agent that offers none leaves them out.
7
7
  * @param {{ command: string, args?: string[], env?: Record<string, string>, label?: string, id?: string }} provider
8
- * @param {{ cwd?: string, timeoutMs?: number, discover?: boolean }} [options]
8
+ * @param {{ cwd?: string, timeoutMs?: number, discover?: boolean, signal?: AbortSignal }} [options]
9
9
  * @returns {Promise<{ protocolVersion: number, agent?: { name?: string, title?: string, version?: string }, loadSession: boolean, mcpHttp: boolean, authMethods: string[],
10
10
  * models?: Array<{ id: string, label: string, description?: string }>, currentModel?: string, modes?: Array<{ id: string, label: string, description?: string }>, currentMode?: string }>}
11
11
  */
@@ -15,10 +15,11 @@ export function probeAcp(provider: {
15
15
  env?: Record<string, string>;
16
16
  label?: string;
17
17
  id?: string;
18
- }, { cwd, timeoutMs, discover }?: {
18
+ }, { cwd, timeoutMs, discover, signal }?: {
19
19
  cwd?: string;
20
20
  timeoutMs?: number;
21
21
  discover?: boolean;
22
+ signal?: AbortSignal;
22
23
  }): Promise<{
23
24
  protocolVersion: number;
24
25
  agent?: {
package/dist/acp-probe.js CHANGED
@@ -1,7 +1,14 @@
1
1
  // packages/client/src/acp-probe.js
2
2
  import { stdioSession } from "./mcp-probe.js";
3
- async function probeAcp(provider, { cwd, timeoutMs = 2e4, discover = false } = {}) {
3
+ async function probeAcp(provider, { cwd, timeoutMs = 2e4, discover = false, signal } = {}) {
4
+ signal?.throwIfAborted();
4
5
  const session = stdioSession({ command: provider.command, args: provider.args ?? [], env: provider.env ?? {} }, cwd, timeoutMs);
6
+ let closing;
7
+ const abort = () => {
8
+ closing ??= session.close();
9
+ };
10
+ signal?.addEventListener("abort", abort, { once: true });
11
+ if (signal?.aborted) abort();
5
12
  try {
6
13
  const result = await session.request("initialize", {
7
14
  protocolVersion: 1,
@@ -29,7 +36,9 @@ async function probeAcp(provider, { cwd, timeoutMs = 2e4, discover = false } = {
29
36
  authMethods: (result.authMethods ?? []).map((method) => method?.name ?? method?.id).filter(Boolean)
30
37
  };
31
38
  } finally {
32
- await session.close();
39
+ signal?.removeEventListener("abort", abort);
40
+ await (closing ?? session.close());
41
+ signal?.throwIfAborted();
33
42
  }
34
43
  }
35
44
  export {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Probes Antigravity CLI for version, status and available models.
3
- * @param {{ command?: string, args?: string[], env?: Record<string, string>, label?: string, id?: string}} [provider] readOnlyMode, if set, is a legacy setting with no effect: agy enforces read-only itself.
3
+ * @param {{ command?: string, args?: string[], env?: Record<string, string>, label?: string, id?: string}} [provider]
4
4
  * @param {{ cwd?: string, timeoutMs?: number }} [options]
5
5
  */
6
6
  export function probeAntigravity(provider?: {
package/dist/doctor.d.ts CHANGED
@@ -10,5 +10,12 @@ export type CommandResult = { code: number; stdout: string; stderr: string };
10
10
  export type CommandRunner = (command: string, args: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number }) => Promise<CommandResult>;
11
11
  export const runCommand: CommandRunner;
12
12
  export function diagnose(options?: { home?: string; project?: string; env?: NodeJS.ProcessEnv; run?: CommandRunner; sandbox?: boolean; daemonEntry?: string; timeoutMs?: number }): Promise<DoctorCheck[]>;
13
- export function diskCheck(home: string, options?: { run?: CommandRunner; env?: NodeJS.ProcessEnv; free?: number; tempDirs?: string[] }): Promise<DoctorCheck>;
13
+ export type LeftoverState = 'clean-pushed' | 'dirty' | 'local-only' | 'unpushed' | 'in-use' | 'unknown';
14
+ export type Leftover = { path: string; state: LeftoverState; reason?: string; command?: string };
15
+ export const LEFTOVER_STATES: Record<LeftoverState, string>;
16
+ /** An absolute path of ASCII letters, digits, space and . _ - / \ : in single quotes, for sh or PowerShell; undefined for any other path. */
17
+ export function shellQuote(text: string, platform?: NodeJS.Platform): string | undefined;
18
+ /** A path as alp doctor prints it in a comment line: escaped injectively, on one line. */
19
+ export function printable(text: unknown): string;
20
+ export function diskCheck(home: string, options?: { run?: CommandRunner; env?: NodeJS.ProcessEnv; free?: number; tempDirs?: string[]; cwd?: string; classifyMs?: number; recentMs?: number; platform?: NodeJS.Platform }): Promise<DoctorCheck & { leftovers?: Leftover[] }>;
14
21
  export function repair(checks: DoctorCheck[]): Promise<Array<{ id: string; result: string }>>;
package/dist/doctor.js CHANGED
@@ -9,6 +9,7 @@ import { installedProgram, serviceFor } from "./service.js";
9
9
  import { jsonObject, agentSources, resolveAgent } from "@anhlp/alp-core/resolver";
10
10
  import { loadHooks } from "@anhlp/alp-core/hooks";
11
11
  import { isTrusted } from "@anhlp/alp-core/trust";
12
+ import { validateSkill } from "@anhlp/alp-core/skill-validate";
12
13
  import { listProviders } from "@anhlp/alp-core/providers";
13
14
  import { settingsWarnings, validateSettings, validateUserSettings } from "@anhlp/alp-core/validation";
14
15
  import { readLogTail, scrubText } from "@anhlp/alp-core/log";
@@ -78,7 +79,7 @@ async function serviceCheck(home, env) {
78
79
  const program2 = service && await installedProgram(service);
79
80
  if (!program2) return void 0;
80
81
  const missing = [];
81
- for (const file of program2) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
82
+ for (const file of program2.filter((arg) => path.isAbsolute(arg))) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
82
83
  return missing.length ? { id: "service", status: "fail", summary: `the ${service.kind} service ${service.name} runs files that are gone; run alp daemon install again`, details: missing } : { id: "service", status: "ok", summary: `${service.kind} runs alpd as ${service.name}` };
83
84
  }
84
85
  var seconds = (ms) => `${Math.round(ms / 1e3)} s`;
@@ -408,6 +409,29 @@ async function providersCheck(home, env) {
408
409
  ]
409
410
  };
410
411
  }
412
+ async function skillFormatCheck(home) {
413
+ const directory = path.join(home, "skills");
414
+ const entries2 = await readdir(directory, { withFileTypes: true }).catch(() => []);
415
+ const failed = [];
416
+ const warned = [];
417
+ let checked = 0;
418
+ for (const entry of entries2) {
419
+ if (!entry.isDirectory() && !entry.isSymbolicLink() || !/^[\w.-]+$/.test(entry.name) || entry.name.startsWith(".")) continue;
420
+ if (!await lstat(path.join(directory, entry.name, "SKILL.md")).then(() => true, () => false)) continue;
421
+ checked++;
422
+ try {
423
+ const report = await validateSkill(path.join(directory, entry.name));
424
+ if (!report.ok) failed.push(`${entry.name}: ${report.errors.map((finding) => finding.message).join("; ")}`);
425
+ else if (report.warnings.length) warned.push(`${entry.name}: ${report.warnings.map((finding) => finding.code).join(", ")}`);
426
+ } catch (error) {
427
+ failed.push(`${entry.name}: could not be checked: ${error.message}`);
428
+ }
429
+ }
430
+ if (!checked) return void 0;
431
+ if (failed.length) return { id: "skill-format", status: "fail", summary: `${failed.length} library skill${failed.length > 1 ? "s have" : " has"} an unsafe link or an unreadable file (alp skill check <name> explains)`, details: [...failed, ...warned] };
432
+ if (warned.length) return { id: "skill-format", status: "warn", summary: `${warned.length} library skill${warned.length > 1 ? "s do" : " does"} not fully meet the skill format; they still load (alp skill check <name> explains)`, details: warned };
433
+ return { id: "skill-format", status: "ok", summary: `the library's skills meet the skill format (${directory})` };
434
+ }
411
435
  async function librarySkillsCheck(home) {
412
436
  const file = path.join(home, "role-skills.json");
413
437
  let roles;
@@ -580,7 +604,137 @@ async function entries(directory, prefix = "") {
580
604
  const names = await readdir(directory).catch(() => []);
581
605
  return names.filter((name) => name.startsWith(prefix)).map((name) => path.join(directory, name));
582
606
  }
583
- async function diskCheck(home, { run = runCommand, env = process.env, free, tempDirs = [.../* @__PURE__ */ new Set([os.tmpdir(), ...process.platform === "win32" ? [] : ["/tmp"]])] } = {}) {
607
+ var QUOTABLE = /^[A-Za-z0-9._\-/\\: ]+$/;
608
+ function shellQuote(text, platform = process.platform) {
609
+ const value = String(text);
610
+ const absolute = platform === "win32" ? path.win32.isAbsolute(value) : path.posix.isAbsolute(value);
611
+ return absolute && QUOTABLE.test(value) ? `'${value}'` : void 0;
612
+ }
613
+ var printable = (text) => String(text).replace(new RegExp("\\\\|[\\p{C}\\p{Zl}\\p{Zp}]|(?! )\\p{Zs}", "gu"), (char) => char === "\\" ? "\\\\" : `\\u{${char.codePointAt(0).toString(16)}}`);
614
+ var UNQUOTABLE = "no command: its path holds characters other than ASCII letters, digits, space and . _ - / \\ :, which a pasted command might not carry safely; check it and remove it by hand";
615
+ var LEFTOVER_STATES = {
616
+ "clean-pushed": "clean and pushed (no changes, no untracked or ignored files, and every commit and, for a clone, every ref on a remote it last fetched; remove by hand with the command shown, given only for a plain ASCII path)",
617
+ dirty: "dirty (uncommitted changes or untracked files, or a merge or rebase in progress; keep)",
618
+ "local-only": "local-only data (ignored files such as .env, local config, node_modules or build output, which exist only here; keep)",
619
+ unpushed: "unpushed (commits, or for a clone tags, branches or other refs, that no remote-tracking ref mirrors; keep)",
620
+ "in-use": "in use (a running assignment, a retained result, this shell, or changed in the last day; keep)",
621
+ unknown: "unknown (not a git checkout of its own, or git could not tell; check by hand)"
622
+ };
623
+ async function ownedPaths(home) {
624
+ const owned = /* @__PURE__ */ new Set();
625
+ const read = async (file) => JSON.parse(await readFile(file, "utf8"));
626
+ const live = await read(path.join(home, "state", "live.json")).catch(() => []);
627
+ for (const entry of Array.isArray(live) ? live : []) if (typeof entry?.worktree?.path === "string") owned.add(realpathOr(entry.worktree.path));
628
+ const ledger = await read(path.join(home, "state", "assignment-results.json")).catch(() => void 0);
629
+ for (const entry of Array.isArray(ledger?.results) ? ledger.results : []) {
630
+ if (entry?.handled) continue;
631
+ for (const where of [entry?.worktree, entry?.checkout]) if (typeof where === "string") owned.add(realpathOr(where));
632
+ }
633
+ return owned;
634
+ }
635
+ var NOT_CHECKED = "not checked: alp doctor ran out of time; run it again, or check by hand";
636
+ var OutOfTime = class extends Error {
637
+ };
638
+ async function classifyLeftover(directory, { run, env, owned, here, recentMs, deadline, platform }) {
639
+ const real = realpathOr(directory);
640
+ const inside = (outer, inner) => inner === outer || inner.startsWith(outer.endsWith(path.sep) ? outer : outer + path.sep);
641
+ if ([...owned].some((owner) => inside(real, owner) || inside(owner, real)) || inside(real, here)) return { path: directory, state: "in-use" };
642
+ const git = async (args) => {
643
+ const left = deadline - Date.now();
644
+ if (left <= 0) throw new OutOfTime();
645
+ const result = await run("git", ["-C", directory, ...args], { env, timeoutMs: Math.min(1e4, left) });
646
+ if (Date.now() >= deadline) throw new OutOfTime();
647
+ return result;
648
+ };
649
+ const unknown = (reason) => ({ path: directory, state: "unknown", reason });
650
+ if (!await lstat(path.join(directory, ".git")).then(() => true, () => false)) return unknown("not a git checkout");
651
+ const where = await git(["rev-parse", "--show-toplevel", "--absolute-git-dir", "--git-common-dir"]);
652
+ if (where.code !== 0) return unknown("not a git checkout");
653
+ const [top, gitDir, common] = where.stdout.trim().split("\n");
654
+ if (!top || !gitDir || !common || realpathOr(top) !== real) return unknown("not the top of a git checkout");
655
+ const commonDir = realpathOr(path.resolve(top, common));
656
+ const status = await git(["-c", "status.showUntrackedFiles=all", "status", "--porcelain=v1", "-z", "--untracked-files=all", "--ignored=matching"]);
657
+ if (status.code !== 0) return unknown("git status failed");
658
+ const rows = status.stdout.split("\0").filter(Boolean);
659
+ if (rows.some((row) => !row.startsWith("!! "))) return { path: directory, state: "dirty" };
660
+ const ignored = rows.map((row) => row.slice(3));
661
+ if (ignored.length) return { path: directory, state: "local-only", reason: `ignored files: ${ignored.slice(0, 3).join(", ")}${ignored.length > 3 ? `, \u2026 ${ignored.length - 3} more` : ""}` };
662
+ const index = await git(["ls-files", "-z", "-v", "--stage"]);
663
+ if (index.code !== 0) return unknown("git could not list its index");
664
+ const tracked = index.stdout.split("\0").filter(Boolean);
665
+ if (tracked.some((row) => row[0] === "S" || /[a-z]/.test(row[0]))) return unknown("some files are marked assume-unchanged or skip-worktree, which git status does not check");
666
+ if (tracked.some((row) => row.slice(2).startsWith("160000 "))) return unknown("it has submodules, whose own changes and commits this check does not read");
667
+ for (const name of ["MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD", "rebase-merge", "rebase-apply"]) {
668
+ if (await lstat(path.join(gitDir, name)).then(() => true, () => false)) return { path: directory, state: "dirty" };
669
+ }
670
+ const touched = Math.max(...await Promise.all([directory, path.join(gitDir, "index"), path.join(gitDir, "HEAD")].map((file) => lstat(file).then((info) => info.mtimeMs, () => 0))));
671
+ if (Date.now() - touched < recentMs) return { path: directory, state: "in-use", reason: "changed in the last day" };
672
+ const linked = realpathOr(gitDir) !== commonDir;
673
+ const ahead = await git(["rev-list", "-n", "1", ...linked ? ["HEAD"] : ["HEAD", "--all"], "--not", "--remotes"]);
674
+ if (ahead.code !== 0) return unknown("git could not compare HEAD with the remotes");
675
+ if (ahead.stdout.trim()) return { path: directory, state: "unpushed" };
676
+ if (!linked) {
677
+ const refs = await git(["for-each-ref", "--format=%(objectname) %(refname)"]);
678
+ if (refs.code !== 0) return unknown("git could not list its refs");
679
+ const all = refs.stdout.split("\n").filter(Boolean).map((line) => {
680
+ const at = line.indexOf(" ");
681
+ return [line.slice(at + 1), line.slice(0, at)];
682
+ });
683
+ const remotes = await git(["remote"]);
684
+ if (remotes.code !== 0) return unknown("git could not list its remotes");
685
+ const remoteNames = remotes.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
686
+ const mirrors = new Map(all.filter(([name]) => name.startsWith("refs/remotes/")));
687
+ const mirrored = ([name, object]) => {
688
+ const branch = name.startsWith("refs/heads/");
689
+ const rest = branch ? name.slice("refs/heads/".length) : name.slice("refs/".length);
690
+ return remoteNames.some((remote) => {
691
+ const target = mirrors.get(`refs/remotes/${remote}/${rest}`);
692
+ return target !== void 0 && (branch || target === object);
693
+ });
694
+ };
695
+ const local = all.filter((entry) => !entry[0].startsWith("refs/remotes/") && !mirrored(entry));
696
+ if (local.length) return { path: directory, state: "unpushed", reason: `local refs no remote-tracking ref mirrors: ${local.slice(0, 3).map(([name]) => name).join(", ")}${local.length > 3 ? `, \u2026 ${local.length - 3} more` : ""}` };
697
+ }
698
+ const list = await git(["worktree", "list", "--porcelain"]);
699
+ if (list.code !== 0) return unknown("git could not list its worktrees");
700
+ if (!linked) {
701
+ if ((list.stdout.match(/^worktree /gm) ?? []).length > 1) return { path: directory, state: "in-use", reason: "other worktrees use its repository" };
702
+ const quoted2 = shellQuote(directory, platform);
703
+ if (quoted2 === void 0) return { path: directory, state: "clean-pushed", reason: UNQUOTABLE };
704
+ return { path: directory, state: "clean-pushed", command: platform === "win32" ? `Remove-Item -LiteralPath ${quoted2} -Recurse -Force` : `rm -rf ${quoted2}` };
705
+ }
706
+ const main = list.stdout.match(/^worktree (.*)$/m)?.[1];
707
+ if (!main) return unknown("git could not name its main worktree");
708
+ const [quotedMain, quoted] = [shellQuote(main, platform), shellQuote(directory, platform)];
709
+ if (quotedMain === void 0 || quoted === void 0) return { path: directory, state: "clean-pushed", reason: UNQUOTABLE };
710
+ return { path: directory, state: "clean-pushed", command: `git -C ${quotedMain} worktree remove ${quoted}` };
711
+ }
712
+ async function classifyLeftovers(paths, { budgetMs, ...options }) {
713
+ const results = paths.map((directory) => ({ path: directory, state: "unknown", reason: NOT_CHECKED }));
714
+ const deadline = Date.now() + budgetMs;
715
+ let next = 0, done = false;
716
+ const worker = async () => {
717
+ while (!done && next < paths.length && Date.now() < deadline) {
718
+ const index = next++;
719
+ try {
720
+ const result = await classifyLeftover(paths[index], { ...options, deadline });
721
+ if (!done && Date.now() < deadline) results[index] = result;
722
+ } catch (error) {
723
+ if (!(error instanceof OutOfTime)) results[index] = { path: paths[index], state: "unknown", reason: `could not check: ${error?.message ?? error}` };
724
+ }
725
+ }
726
+ };
727
+ let timer;
728
+ const expired = new Promise((resolve) => {
729
+ timer = setTimeout(resolve, Math.max(0, budgetMs));
730
+ });
731
+ await Promise.race([Promise.all(Array.from({ length: Math.min(8, paths.length) }, worker)), expired]);
732
+ clearTimeout(timer);
733
+ done = true;
734
+ return results;
735
+ }
736
+ var SHOWN_COMMANDS = 20;
737
+ async function diskCheck(home, { run = runCommand, env = process.env, free, tempDirs = [.../* @__PURE__ */ new Set([os.tmpdir(), ...process.platform === "win32" ? [] : ["/tmp"]])], cwd = process.cwd(), classifyMs = 1e4, recentMs = 24 * 60 * 60 * 1e3, platform = process.platform } = {}) {
584
738
  let bytes = free;
585
739
  if (bytes === void 0) {
586
740
  try {
@@ -605,17 +759,27 @@ async function diskCheck(home, { run = runCommand, env = process.env, free, temp
605
759
  const total = result.stdout.split("\n").reduce((sum, line) => sum + (Number(line.split(/\s+/)[0]) || 0), 0);
606
760
  return total * 1024;
607
761
  }
608
- const details = [];
609
- for (const [label, paths] of [[`${path.join(home, "worktrees")}`, worktrees], [`${tempDirs.map((directory) => path.join(directory, "alp-*")).join(", ")}`, temp]]) {
610
- if (!paths.length) continue;
611
- const used = await size(paths);
612
- details.push(`${paths.length} left in ${label}${used === void 0 ? "" : `, ${formatSize(used)}`}`);
613
- }
614
- const hint = details.length ? "ALP deletes none of these: some may belong to running assignments or hold uncommitted work. Remove those you no longer need (git worktree remove, or rm -rf)." : void 0;
762
+ const gitEnv = { ...Object.fromEntries(Object.entries(env).filter(([name]) => !/^GIT_(DIR|WORK_TREE|INDEX_FILE|COMMON_DIR|OBJECT_DIRECTORY|NAMESPACE|CEILING_DIRECTORIES)$/.test(name))), GIT_OPTIONAL_LOCKS: "0" };
763
+ const groups = [[`${path.join(home, "worktrees")}`, worktrees], [`${tempDirs.map((directory) => path.join(directory, "alp-*")).join(", ")}`, temp]].filter(([, paths]) => paths.length);
764
+ const [sizes, leftovers] = await Promise.all([
765
+ Promise.all(groups.map(([, paths]) => size(paths))),
766
+ ownedPaths(home).then((owned) => classifyLeftovers([.../* @__PURE__ */ new Set([...worktrees, ...temp])], { run, env: gitEnv, owned, here: realpathOr(cwd), budgetMs: classifyMs, recentMs, platform }))
767
+ ]);
768
+ const details = groups.map(([label, paths], index) => `${paths.length} left in ${label}${sizes[index] === void 0 ? "" : `, ${formatSize(sizes[index])}`}`);
769
+ for (const [state, meaning] of Object.entries(LEFTOVER_STATES)) {
770
+ const count = leftovers.filter((entry) => entry.state === state).length;
771
+ if (count) details.push(`${count} ${meaning}`);
772
+ }
773
+ const unchecked = leftovers.filter((entry) => entry.reason === NOT_CHECKED).length;
774
+ if (unchecked) details.push(` ${unchecked} of the unknown were not checked within ${classifyMs < 1e3 ? `${classifyMs} ms` : `${Math.round(classifyMs / 1e3)} s`}`);
775
+ const commands = leftovers.filter((entry) => entry.state === "clean-pushed").map((entry) => entry.command ?? `# remove by hand after checking (no safe command): ${printable(entry.path)}`);
776
+ for (const command of commands.slice(0, SHOWN_COMMANDS)) details.push(` ${command}`);
777
+ if (commands.length > SHOWN_COMMANDS) details.push(` \u2026 ${commands.length - SHOWN_COMMANDS} more; alp doctor --json lists every one`);
778
+ const hint = details.length ? "ALP deletes none of these, and --fix does not either. Only a clean and pushed leftover gets a command, for you to run by hand, and only when its path is plain ASCII; inspect the others before removing anything." : void 0;
615
779
  const where = bytes === void 0 ? "free space unknown" : `${formatSize(bytes)} free`;
616
780
  const status = bytes !== void 0 && bytes < 2 * GIB ? "warn" : "ok";
617
781
  const summary = bytes !== void 0 && bytes < 2 * GIB ? `${where} where ALP_HOME lives; when the disk is full, alpd pauses all work until space returns` : `${where} where ALP_HOME lives`;
618
- return { id: "disk", status, summary, ...details.length ? { details } : {}, ...hint ? { hint } : {} };
782
+ return { id: "disk", status, summary, ...details.length ? { details } : {}, ...hint ? { hint } : {}, ...leftovers.length ? { leftovers } : {} };
619
783
  }
620
784
  function realpathOr(file) {
621
785
  try {
@@ -650,6 +814,8 @@ async function diagnose({ home, project, env = process.env, run = runCommand, sa
650
814
  checks.push(await userSettingsCheck(home));
651
815
  const skills = await librarySkillsCheck(home);
652
816
  if (skills) checks.push(skills);
817
+ const skillFormat = await skillFormatCheck(home);
818
+ if (skillFormat) checks.push(skillFormat);
653
819
  const providers = await providersCheck(home, env);
654
820
  if (providers) checks.push(providers);
655
821
  const live = await liveCheck(home, running);
@@ -674,8 +840,11 @@ async function repair(checks) {
674
840
  return done;
675
841
  }
676
842
  export {
843
+ LEFTOVER_STATES,
677
844
  diagnose,
678
845
  diskCheck,
846
+ printable,
679
847
  repair,
680
- runCommand
848
+ runCommand,
849
+ shellQuote
681
850
  };
package/dist/index.d.ts CHANGED
@@ -14,12 +14,14 @@ export function assertPrivateSocket(socketPath: any): Promise<import("fs").Stats
14
14
  /**
15
15
  * Finds alpd.js for a client that cannot locate it beside itself, such as the Paseo
16
16
  * plugin, which Paseo re-bundles: the first existing candidate, then where alpd last
17
- * recorded itself ($ALP_HOME/alpd.json), then the ALP CLI (`alp`) on PATH.
17
+ * recorded itself ($ALP_HOME/alpd.json), then the ALP CLI (`alp`) on PATH and in the usual install
18
+ * directories (`binDirectories`; a test passes [] so the caller's own install is not found).
18
19
  */
19
- export function findDaemonEntry({ home, env, candidates }?: {
20
+ export function findDaemonEntry({ home, env, candidates, binDirectories }?: {
20
21
  home?: string | undefined;
21
22
  env?: NodeJS.ProcessEnv | undefined;
22
23
  candidates?: (string | undefined)[] | undefined;
24
+ binDirectories?: string[] | undefined;
23
25
  }): Promise<any>;
24
26
  /**
25
27
  * Integration names are single lowercase path segments: they name `<home>/integrations/<name>.lock`,
@@ -128,6 +130,12 @@ export function withDaemonLifecycle(home: any, action: any, run: any, { joinStar
128
130
  joinStart?: boolean | undefined;
129
131
  signal?: AbortSignal | undefined;
130
132
  }): Promise<any>;
133
+ /**
134
+ * The time a start of alpd waits for it to become ready, in ms: ALP_DAEMON_START_TIMEOUT_MS when it
135
+ * is a positive whole number of at most one hour, else DAEMON_START_TIMEOUT_MS.
136
+ * @param {NodeJS.ProcessEnv} [env]
137
+ */
138
+ export function daemonStartTimeoutMs(env?: NodeJS.ProcessEnv): number;
131
139
  /**
132
140
  * Returns the socket of a ready daemon, starting one when none runs.
133
141
  * `entry` is the daemon script; it is started through its own detaching launcher so the
@@ -145,24 +153,28 @@ export function ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleL
145
153
  /**
146
154
  * The entry of integration `name`: an environment override, a descriptor under the home or a
147
155
  * distribution root, or an `alp-<name>-integration` binary. Discovery never returns an entry for
148
- * `web`: that name belongs to alp-web, which ships with the CLI and is started with its explicit
149
- * entry. Everything once registered under `web` (the descriptor `integrations/web.json`, the
156
+ * `dashboard`: that is alp dashboard's service, which ships with the CLI and is started with its
157
+ * explicit entry; nor for `web`, its name before the rename (t-81b0.5). Everything once registered
158
+ * under `web` (the descriptor `integrations/web.json`, the
150
159
  * `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its
151
160
  * rename to `paseo`, which must never run under the web lock. `ALP_WEB_INTEGRATION` is read for
152
161
  * `paseo` only, after `ALP_PASEO_INTEGRATION`, for one release (like the alp-web-integration alias).
153
162
  * @param {string} [name]
154
- * @param {{ home?: string }} [options]
163
+ * @param {{ home?: string, env?: NodeJS.ProcessEnv, binDirectories?: string[], roots?: string[] }} [options]
155
164
  */
156
165
  export function discoverIntegration(name?: string, options?: {
157
166
  home?: string;
167
+ env?: NodeJS.ProcessEnv;
168
+ binDirectories?: string[];
169
+ roots?: string[];
158
170
  }): Promise<string | undefined>;
159
171
  export function integrationAlive(lock: any): boolean;
160
172
  /**
161
- * Starts integration `name` (default `web`) detached with `--service` (then `args`) unless its lock
173
+ * Starts integration `name` (default `dashboard`) detached with `--service` (then `args`) unless its lock
162
174
  * already names a live owner, then waits until its ready lock and `<home>/<name>.json` name the same
163
175
  * pid. `entry` names the script to run with this Node and skips descriptor, environment and PATH
164
- * discovery; `web` (alp-web) is never discovered, so it needs its entry. `"web": { "enabled": false }`
165
- * in the home's settings.json refuses `web` only.
176
+ * discovery; `dashboard` is never discovered, so it needs its entry. `"dashboard": { "enabled": false }`
177
+ * in the home's settings.json (or `web.enabled`, its key before the rename) refuses `dashboard` only.
166
178
  * @param {string | { name?: string, entry?: string, home?: string, args?: string[] }} [nameOrOptions]
167
179
  */
168
180
  export function startIntegration(nameOrOptions?: string | {
@@ -197,6 +209,8 @@ export class AlpClient extends AlpRpcClient {
197
209
  /** @type {import('@anhlp/alp-protocol').TerminalLimits | undefined} */
198
210
  terminalLimits: import("@anhlp/alp-protocol").TerminalLimits | undefined;
199
211
  }
212
+ /** How long a start waits for alpd to be ready by default: generous, as a loaded host can take a while. */
213
+ export const DAEMON_START_TIMEOUT_MS: 60000;
200
214
  import { AlpRpcClient } from './rpc/client.js';
201
215
  export { PROTOCOL_VERSION, MAX_FRAME, AlpRpcError, encodeFrame } from "@anhlp/alp-protocol";
202
216
  export { connectWebSocket, createWebSocketTransport, redactUrl, CLOSE_CODE } from "./websocket.js";