@staix/agent-hub 0.45.0 → 0.46.1
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/CHANGELOG.md +32 -0
- package/README.md +10 -4
- package/docs/adding-an-ai-tool.md +1 -0
- package/docs/agent-notes/adapters.md +33 -4
- package/docs/agent-notes/budget.md +2 -1
- package/docs/agent-notes/daemon.md +5 -1
- package/docs/agent-notes/security-review.md +3 -2
- package/docs/agent-notes/tasks.md +3 -1
- package/docs/agent-notes/tests.md +1 -1
- package/docs/design/adapters.md +16 -0
- package/docs/design/agent-hub-architecture.md +12 -0
- package/docs/design/cli-output.md +2 -0
- package/docs/design/roadmap.md +86 -5
- package/docs/design/task-board.md +2 -2
- package/docs/dogfood.md +15 -0
- package/docs/events.md +2 -2
- package/docs/operations.md +103 -21
- package/docs/quickstart.md +15 -3
- package/docs/security.md +7 -5
- package/docs/smoke.md +1 -1
- package/docs/verification/2026-11-05-hardcoded-values-classification-rules.md +28 -0
- package/docs/verification/2026-11-22-agy-1.5.14.md +27 -0
- package/docs/verification/2026-11-22-claude-instruction-hook.md +35 -0
- package/docs/verification/2026-11-22-instructed-ipc.md +9 -0
- package/docs/verification/2026-11-22-jcode-1.0.3.md +71 -0
- package/docs/verification/2026-11-22-jcode-separate-home.md +14 -0
- package/docs/verification/2026-11-22-qwen-0283-acp.md +28 -0
- package/docs/verification/2026-11-22-qwen-0283-dual-output.md +33 -0
- package/docs/verification/2026-11-22-roadmap-r5-view-receipt.md +63 -0
- package/docs/verification/2026-11-23-0.46.0.md +44 -0
- package/docs/verification/2026-11-24-0.46.1.md +48 -0
- package/docs/verification/assets/1483-r5-detail-1440-light.png +0 -0
- package/docs/verification/assets/1483-r5-detail-390-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-1440-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-1440-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-390-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-390-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-820-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-820-light.png +0 -0
- package/docs/verified.json +23 -23
- package/package.json +3 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +6053 -5509
- package/plugins/agent-hub/server.js +1300 -1087
- package/plugins/agent-hub/skills/ahub/SKILL.md +17 -0
- package/plugins/agent-hub/skills/ahub-manage/SKILL.md +37 -0
- package/plugins/agent-hub/skills/ahub-status/SKILL.md +14 -0
- package/plugins/agent-hub/skills/ahub-use/SKILL.md +12 -0
- package/src/adapters/claude-channel.ts +2 -1
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/definitions/native-cli-claude-setup.ts +9 -1
- package/src/adapters/definitions/native-cli-doctor.ts +8 -5
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +158 -0
- package/src/adapters/definitions/native-cli-jcode-home.ts +72 -0
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +20 -0
- package/src/adapters/definitions/native-cli-skills.ts +29 -0
- package/src/cli/claude-profile-hook.ts +40 -3
- package/src/cli/console-state.ts +55 -26
- package/src/cli/console-usage.ts +5 -3
- package/src/cli/console.ts +35 -4
- package/src/cli/help.ts +15 -10
- package/src/cli/identity.ts +2 -1
- package/src/cli/instruction-hook.ts +28 -0
- package/src/cli/jcode-mcp.ts +2 -1
- package/src/cli/main.js +8 -0
- package/src/cli/main.ts +138 -18
- package/src/cli/output-standard.ts +3 -55
- package/src/cli/output.ts +8 -2
- package/src/cli/recovery-package.ts +53 -12
- package/src/cli/roadmap.ts +37 -3
- package/src/cli/setup-homes.ts +1 -0
- package/src/cli/setup.ts +1 -1
- package/src/cli/skills-install.ts +463 -0
- package/src/cli/task-output.ts +1 -1
- package/src/cli/upgrade-presentation-flags.ts +1 -1
- package/src/hub/board.ts +42 -4
- package/src/hub/budget-projection.ts +99 -0
- package/src/hub/claude-launch-proof.ts +5 -1
- package/src/hub/conductor.ts +8 -3
- package/src/hub/config-apply.ts +3 -2
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config-trust.ts +1 -1
- package/src/hub/control-client.ts +9 -2
- package/src/hub/daemon.ts +457 -26
- package/src/hub/events.ts +1 -1
- package/src/hub/execution-budget.ts +29 -8
- package/src/hub/hub-tools.ts +2 -2
- package/src/hub/inference.ts +1 -1
- package/src/hub/instances.ts +10 -1
- package/src/hub/instructed-exact.ts +95 -0
- package/src/hub/instructed-intent.ts +64 -0
- package/src/hub/instructed-ipc.ts +33 -0
- package/src/hub/instructed-runtime.ts +19 -0
- package/src/hub/instruction-receipt.ts +218 -0
- package/src/hub/manager.ts +46 -3
- package/src/hub/registry.ts +1 -1
- package/src/hub/roadmap-decompose.ts +60 -1
- package/src/hub/roadmap-sync.ts +2 -2
- package/src/hub/roadmap.ts +19 -1
- package/src/hub/routing.ts +18 -1
- package/src/hub/runtime-capture-prune.ts +2 -1
- package/src/hub/settings.ts +2 -1
- package/src/hub/tasks.ts +194 -12
- package/src/hub/ui.ts +6 -2
- package/src/hub/usage-rollup.ts +42 -2
- package/src/ui/index.html +342 -8
- package/src/ui/plugin.ts +6 -2
- package/src/ui/roadmap-model.ts +70 -0
package/src/cli/roadmap.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const ROADMAP_FORMS = {
|
|
|
10
10
|
order: "order <id> <n>", state: "state <id> <proposed|planned|active|done|dropped>",
|
|
11
11
|
unplaced: "unplaced [--repo <owner/name>] [--json]",
|
|
12
12
|
triage: "triage [--repo <owner/name>] [--list] [--json]",
|
|
13
|
-
decompose: "decompose <id> [--accept <part>] [--json]",
|
|
13
|
+
decompose: "decompose <id> [--accept <part>] [--publish [--apply --confirm <fingerprint>]] [--json]",
|
|
14
14
|
accept: "accept <suggestion>", reject: "reject <suggestion>",
|
|
15
15
|
importGithub: "import-github [--repo <owner/name>] [--apply] [--json]",
|
|
16
16
|
check: "check [--json]", sync: "sync [--apply --confirm <fingerprint>] [--json]",
|
|
@@ -51,13 +51,22 @@ function integer(value: string | undefined, zero = false): number {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function parseR3(command: string, rest: readonly string[], jsonSeen: boolean): RoadmapArgs {
|
|
54
|
-
let json = jsonSeen, list = false, apply = false, repo: string | undefined, accept: number | undefined;
|
|
54
|
+
let json = jsonSeen, list = false, apply = false, repo: string | undefined, accept: number | undefined, publish = false, confirm: string | undefined;
|
|
55
55
|
const operands: string[] = [];
|
|
56
56
|
for (let at = 0; at < rest.length; at++) {
|
|
57
57
|
const word = rest[at]!;
|
|
58
58
|
if (word === "--json") { if (json) return usage("duplicate roadmap --json flag"); json = true; continue; }
|
|
59
59
|
if (word === "--list" && command === "triage") { if (list) return usage("duplicate roadmap --list flag"); list = true; continue; }
|
|
60
60
|
if (word === "--apply" && command === "import-github") { if (apply) return usage("duplicate roadmap --apply flag"); apply = true; continue; }
|
|
61
|
+
if (word === "--publish" && command === "decompose") { if (publish) return usage("duplicate roadmap --publish flag"); publish = true; continue; }
|
|
62
|
+
if (word === "--apply" && command === "decompose") { if (apply) return usage("duplicate roadmap --apply flag"); apply = true; continue; }
|
|
63
|
+
if ((word === "--confirm" || word.startsWith("--confirm=")) && command === "decompose") {
|
|
64
|
+
if (confirm !== undefined) return usage("duplicate roadmap --confirm option");
|
|
65
|
+
const value = word === "--confirm" ? rest[++at] : word.slice("--confirm=".length);
|
|
66
|
+
if (!value || !/^[a-f0-9]{64}$/.test(value)) return usage("roadmap confirmation needs a full fingerprint");
|
|
67
|
+
confirm = value;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
61
70
|
if ((word === "--accept" || word.startsWith("--accept=")) && command === "decompose") {
|
|
62
71
|
if (accept !== undefined) return usage("duplicate roadmap --accept option");
|
|
63
72
|
const value = word === "--accept" ? rest[++at] : word.slice("--accept=".length);
|
|
@@ -75,13 +84,18 @@ function parseR3(command: string, rest: readonly string[], jsonSeen: boolean): R
|
|
|
75
84
|
operands.push(word);
|
|
76
85
|
}
|
|
77
86
|
if (json && !R3_JSON.includes(command)) return usage(`roadmap ${command} has no --json form`);
|
|
87
|
+
if (command === "decompose") {
|
|
88
|
+
if ((apply || confirm !== undefined) && !publish) return usage("roadmap decompose apply needs its --publish preview");
|
|
89
|
+
if (apply !== (confirm !== undefined)) return usage("roadmap decompose --apply needs its preview fingerprint");
|
|
90
|
+
if (publish && accept !== undefined) return usage("roadmap decompose takes --accept <part> or --publish, not both");
|
|
91
|
+
}
|
|
78
92
|
if (command === "accept" || command === "reject") {
|
|
79
93
|
if (operands.length !== 1) return usage(`roadmap ${command} needs one suggestion id`);
|
|
80
94
|
return { op: "hub_roadmap_edit", args: { op: command, suggestion: integer(operands[0]) }, json };
|
|
81
95
|
}
|
|
82
96
|
if (command === "decompose") {
|
|
83
97
|
if (operands.length !== 1) return usage("roadmap decompose needs one milestone id");
|
|
84
|
-
return { op: "hub_roadmap_decompose", args: { id: integer(operands[0]), ...(accept === undefined ? {} : { accept }) }, json };
|
|
98
|
+
return { op: "hub_roadmap_decompose", args: { id: integer(operands[0]), ...(accept === undefined ? {} : { accept }), ...(publish ? { publish: true } : {}), ...(apply ? { apply: true, confirm } : {}) }, json };
|
|
85
99
|
}
|
|
86
100
|
if (operands.length) return usage(`roadmap ${command} takes no operands`);
|
|
87
101
|
const base = repo === undefined ? {} : { repo };
|
|
@@ -204,6 +218,26 @@ export function renderRoadmap(input: unknown, width = 80): string {
|
|
|
204
218
|
if (view.truncated === true) add("More findings exist; narrow the roadmap before relying on this list.");
|
|
205
219
|
return lines.join("\n");
|
|
206
220
|
}
|
|
221
|
+
if (view.publish === true && Array.isArray(view.parts)) {
|
|
222
|
+
add(`Milestone ${count(view.milestone)} publish preview (${text(view.repo)})`);
|
|
223
|
+
for (const value of list(view.parts)) {
|
|
224
|
+
const part = row(value), issue = part.issue === null || part.issue === undefined ? null : `${text(view.repo)}#${count(part.issue)}`;
|
|
225
|
+
const action = part.action === "create" ? "a spec issue would be created"
|
|
226
|
+
: part.action === "published" ? `already published as ${issue}`
|
|
227
|
+
: part.action === "task" ? `goes straight to its held task ${count(part.task)}, so no issue`
|
|
228
|
+
: "released already, so this hold publishes nothing";
|
|
229
|
+
add(` part ${count(part.part)} (${part.intake === "spec" ? "needs its own spec issue" : "straight to a task"}): ${action}`);
|
|
230
|
+
}
|
|
231
|
+
if (!list(view.parts).length && !Number(view.skippedPrivate) && !Number(view.skippedUnknown)) add("This milestone holds no accepted part to publish.");
|
|
232
|
+
if (Number(view.skippedPrivate) > 0) add(`Private parts skipped: ${count(view.skippedPrivate)}; a private part is never published.`);
|
|
233
|
+
if (Number(view.skippedUnknown) > 0) add(`Parts with no stored text: ${count(view.skippedUnknown)}; run ahub roadmap decompose ${count(view.milestone)} to propose them again.`);
|
|
234
|
+
for (const call of list(view.calls)) if (Array.isArray(call)) add(` gh ${call.map(value => `'${String(value).replaceAll("'", "'\\''")}'`).join(" ")}`);
|
|
235
|
+
if (view.githubMilestone === null || view.githubMilestone === undefined) add("No GitHub milestone is bound to this roadmap milestone, so a created issue joins none; run ahub roadmap sync first.");
|
|
236
|
+
else add(`Each created issue joins GitHub milestone ${count(view.githubMilestone)}.`);
|
|
237
|
+
if (view.applied === true) add(`Created ${count(list(view.created).length)} issue${list(view.created).length === 1 ? "" : "s"}; the drafts stay held until ahub intake approve.`);
|
|
238
|
+
else add(`Apply this exact preview: ahub roadmap decompose ${count(view.milestone)} --publish --apply --confirm ${text(view.fingerprint)}`);
|
|
239
|
+
return lines.join("\n");
|
|
240
|
+
}
|
|
207
241
|
if (Array.isArray(view.calls) && typeof view.fingerprint === "string") {
|
|
208
242
|
add(`GitHub mirror: ${view.applied ? "applied" : "dry run"}`);
|
|
209
243
|
for (const call of view.calls) if (Array.isArray(call)) add(` gh ${call.map(value => `'${String(value).replaceAll("'", "'\\''")}'`).join(" ")}`);
|
package/src/cli/setup-homes.ts
CHANGED
|
@@ -32,6 +32,7 @@ export async function setupClaudeHomes(ports: SetupHomesPorts): Promise<void> {
|
|
|
32
32
|
}
|
|
33
33
|
for (const check of initial) if (check.next) ports.print(`${check.home.path}: ${check.next.blocked ? "setup blocked" : check.next.argv.join(" ")} (${check.next.why})`);
|
|
34
34
|
if (initial.every(check => !check.next && check.hook.state === "installed")) return;
|
|
35
|
+
if (ports.hook?.instruction && initial.some(check => check.hook.state !== "installed")) ports.print("The Claude UserPromptSubmit and Stop hooks record and close hash-only pending instruction evidence; they grant no command authority.");
|
|
35
36
|
if (!ports.yes && ports.interactive === false) throw new Error("not a terminal: nothing was changed; rerun with --yes to apply");
|
|
36
37
|
if (!ports.yes && !["y", "yes"].includes((await ports.ask("Install the hub plugin and project-neutral hook in these Claude homes? [y/N] "))?.trim().toLowerCase() ?? "")) { ports.print("Claude setup was not changed."); return; }
|
|
37
38
|
ports.current?.();
|
package/src/cli/setup.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Compatibility exports; native plugin policy belongs to its adapter definition leaf. */
|
|
2
|
-
export { PLUGIN, CLAUDE_PLUGIN_INVENTORY, parseList, pluginState, nextStep, type InstalledPlugin, type Marketplace, type PluginState, type SetupStep } from "../adapters/definitions/native-cli-claude-setup.ts";
|
|
2
|
+
export { PLUGIN, HUB_SKILL_NAMES, hubSkillsPresent, CLAUDE_PLUGIN_INVENTORY, parseList, pluginState, nextStep, type InstalledPlugin, type Marketplace, type PluginState, type SetupStep } from "../adapters/definitions/native-cli-claude-setup.ts";
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hub skills for the agent hosts other than Claude Code (#1622).
|
|
3
|
+
*
|
|
4
|
+
* The Claude plugin carries the skills itself; every other host reads its own user skill directory, so `ahub setup`
|
|
5
|
+
* writes one tree per skill there. Each tree carries an `.ahub-skill.json` marker and is replaced only while it still
|
|
6
|
+
* holds exactly the digest the hub wrote. A tree the person edited, a tree another tool installed and a link are
|
|
7
|
+
* reported and left alone; `ahub setup --undo` removes only the hub's own unmodified trees. Other skills in the same
|
|
8
|
+
* host directory are never read, written or reported.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
11
|
+
import { lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { hostSkillDir, SKILL_HOSTS, type SkillHost } from "../adapters/definitions/native-cli-skills.ts";
|
|
15
|
+
import { realPath } from "../hub/project.ts";
|
|
16
|
+
import { VERSION } from "../version.ts";
|
|
17
|
+
|
|
18
|
+
export { hostSkillDir, SKILL_HOSTS, type SkillHost };
|
|
19
|
+
|
|
20
|
+
export const SKILL_MARKER = ".ahub-skill.json";
|
|
21
|
+
export const SKILL_TOOL = "agent-hub";
|
|
22
|
+
|
|
23
|
+
const SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
24
|
+
const MAX_FILES = 256;
|
|
25
|
+
const MAX_FILE_BYTES = 1024 * 1024;
|
|
26
|
+
const MAX_TREE_BYTES = 8 * 1024 * 1024;
|
|
27
|
+
|
|
28
|
+
export class SkillsInstallError extends Error {}
|
|
29
|
+
|
|
30
|
+
interface TreeFile { path: string; bytes: Buffer }
|
|
31
|
+
interface Tree { files: TreeFile[]; digest: string }
|
|
32
|
+
interface Marker { tool: string; version: string; sha256: string }
|
|
33
|
+
interface SourceSkill { name: string; tree: Tree }
|
|
34
|
+
|
|
35
|
+
export type SkillAction =
|
|
36
|
+
| "install" | "replace" | "unchanged" // a run that writes
|
|
37
|
+
| "modified" | "foreign" | "linked" | "failed" // a tree the hub does not own or cannot read
|
|
38
|
+
| "absent" | "missing" // no host on this machine, or no tree where the host is installed
|
|
39
|
+
| "remove" | "removed"; // the undo path
|
|
40
|
+
|
|
41
|
+
export interface SkillEntry {
|
|
42
|
+
host: SkillHost;
|
|
43
|
+
/** The skill directory name; empty for a host-level entry (no host, no directory). */
|
|
44
|
+
skill: string;
|
|
45
|
+
dir: string;
|
|
46
|
+
action: SkillAction;
|
|
47
|
+
detail: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type SkillState = "installed" | "stale" | "modified" | "foreign" | "linked" | "missing" | "absent" | "failed";
|
|
51
|
+
export interface SkillHostState {
|
|
52
|
+
host: SkillHost;
|
|
53
|
+
/** The host's skills directory (the parent of the installed trees). */
|
|
54
|
+
dir: string;
|
|
55
|
+
state: SkillState;
|
|
56
|
+
detail: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SkillPaths {
|
|
60
|
+
home?: string;
|
|
61
|
+
env?: NodeJS.ProcessEnv;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function digest(files: TreeFile[]): string {
|
|
65
|
+
const hash = createHash("sha256");
|
|
66
|
+
for (const file of [...files].sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0))) {
|
|
67
|
+
hash.update(file.path);
|
|
68
|
+
hash.update("\0");
|
|
69
|
+
hash.update(createHash("sha256").update(file.bytes).digest("hex"));
|
|
70
|
+
hash.update("\n");
|
|
71
|
+
}
|
|
72
|
+
return hash.digest("hex");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function lstat(path: string): ReturnType<typeof lstatSync> | undefined {
|
|
76
|
+
try { return lstatSync(path); } catch { return undefined; }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Read one skill tree: regular files only, no link followed, bounded count and size. */
|
|
80
|
+
function readTree(dir: string): Tree {
|
|
81
|
+
let root: ReturnType<typeof lstatSync>;
|
|
82
|
+
try { root = lstatSync(dir); } catch (error) {
|
|
83
|
+
throw new SkillsInstallError(`cannot read ${dir}: ${(error as Error).message}`);
|
|
84
|
+
}
|
|
85
|
+
if (root.isSymbolicLink()) throw new SkillsInstallError(`refused a link: ${dir}`);
|
|
86
|
+
if (!root.isDirectory()) throw new SkillsInstallError(`not a directory: ${dir}`);
|
|
87
|
+
const files: TreeFile[] = [];
|
|
88
|
+
let total = 0;
|
|
89
|
+
const walk = (abs: string, rel: string): void => {
|
|
90
|
+
const stat = lstatSync(abs);
|
|
91
|
+
if (stat.isSymbolicLink()) throw new SkillsInstallError(`refused a link: ${abs}`);
|
|
92
|
+
if (stat.isDirectory()) {
|
|
93
|
+
for (const name of readdirSync(abs).sort()) {
|
|
94
|
+
if (name === SKILL_MARKER) continue;
|
|
95
|
+
walk(join(abs, name), rel ? `${rel}/${name}` : name);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!stat.isFile()) throw new SkillsInstallError(`not a regular file: ${abs}`);
|
|
100
|
+
if (stat.size > MAX_FILE_BYTES) throw new SkillsInstallError(`file too large (limit ${MAX_FILE_BYTES} bytes): ${abs}`);
|
|
101
|
+
if (files.length >= MAX_FILES) throw new SkillsInstallError(`too many files under ${dir} (limit ${MAX_FILES})`);
|
|
102
|
+
total += stat.size;
|
|
103
|
+
if (total > MAX_TREE_BYTES) throw new SkillsInstallError(`tree too large under ${dir} (limit ${MAX_TREE_BYTES} bytes)`);
|
|
104
|
+
files.push({ path: rel, bytes: readFileSync(abs) });
|
|
105
|
+
};
|
|
106
|
+
walk(dir, "");
|
|
107
|
+
return { files, digest: digest(files) };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function readSource(source: string): SourceSkill[] {
|
|
111
|
+
const root = lstat(source);
|
|
112
|
+
if (!root) throw new SkillsInstallError(`cannot read the hub skill source ${source}`);
|
|
113
|
+
if (root.isSymbolicLink() || !root.isDirectory()) throw new SkillsInstallError(`the hub skill source is not a directory: ${source}`);
|
|
114
|
+
const skills: SourceSkill[] = [];
|
|
115
|
+
for (const name of readdirSync(source).sort()) {
|
|
116
|
+
if (name.startsWith(".")) continue;
|
|
117
|
+
const abs = join(source, name);
|
|
118
|
+
const stat = lstat(abs);
|
|
119
|
+
if (!stat) throw new SkillsInstallError(`cannot read ${abs}`);
|
|
120
|
+
if (stat.isSymbolicLink()) throw new SkillsInstallError(`refused a link in the hub skill source: ${abs}`);
|
|
121
|
+
if (!stat.isDirectory()) continue;
|
|
122
|
+
if (!SKILL_NAME.test(name)) throw new SkillsInstallError(`not a usable skill name: ${name}`);
|
|
123
|
+
skills.push({ name, tree: readTree(abs) });
|
|
124
|
+
}
|
|
125
|
+
if (!skills.length) throw new SkillsInstallError(`no skills under ${source}`);
|
|
126
|
+
return skills;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function readMarker(dir: string): Marker | "missing" | "foreign" {
|
|
130
|
+
let text: string;
|
|
131
|
+
try { text = readFileSync(join(dir, SKILL_MARKER), "utf8"); } catch { return "missing"; }
|
|
132
|
+
try {
|
|
133
|
+
const value = JSON.parse(text) as Partial<Marker>;
|
|
134
|
+
if (value.tool === SKILL_TOOL && typeof value.version === "string" && typeof value.sha256 === "string") {
|
|
135
|
+
return { tool: value.tool, version: value.version, sha256: value.sha256 };
|
|
136
|
+
}
|
|
137
|
+
} catch { /* a malformed marker is not the hub's */ }
|
|
138
|
+
return "foreign";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Resolve the host's config home and skill directory without following a link in the skill trees. A symlinked config
|
|
143
|
+
* home is the host's own choice and is resolved with `realPath`; a symlinked skills directory is refused.
|
|
144
|
+
*/
|
|
145
|
+
function locate(host: SkillHost, paths: SkillPaths): { dir: string } | { action: "absent" | "failed" | "linked" | "foreign"; dir: string; detail: string } {
|
|
146
|
+
const lexical = hostSkillDir(host, paths.home ?? homedir(), paths.env ?? process.env);
|
|
147
|
+
const configHome = dirname(lexical);
|
|
148
|
+
const config = lstat(configHome);
|
|
149
|
+
if (!config) return { action: "absent", dir: lexical, detail: `host not installed: no ${configHome}` };
|
|
150
|
+
if (!config.isSymbolicLink() && !config.isDirectory()) return { action: "failed", dir: lexical, detail: `${configHome} is not a directory` };
|
|
151
|
+
let resolved: string;
|
|
152
|
+
try { resolved = realPath(configHome); } catch (error) { return { action: "failed", dir: lexical, detail: `${configHome}: ${(error as Error).message}` }; }
|
|
153
|
+
// The config home link is the host's own choice and has been resolved above; a linked skills directory is not.
|
|
154
|
+
const dir = join(resolved, "skills");
|
|
155
|
+
const stat = lstat(dir);
|
|
156
|
+
if (stat?.isSymbolicLink()) return { action: "linked", dir, detail: "the skills directory is a link; left untouched" };
|
|
157
|
+
if (stat && !stat.isDirectory()) return { action: "foreign", dir, detail: "the skills path is not a directory; left untouched" };
|
|
158
|
+
return { dir };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** What one skill tree would become, without writing anything. */
|
|
162
|
+
function inspectSkill(host: SkillHost, skill: SourceSkill, base: string): SkillEntry {
|
|
163
|
+
const dir = join(base, skill.name);
|
|
164
|
+
const entry = (action: SkillAction, detail: string): SkillEntry => ({ host, skill: skill.name, dir, action, detail });
|
|
165
|
+
const stat = lstat(dir);
|
|
166
|
+
if (!stat) return entry("install", "not installed");
|
|
167
|
+
if (stat.isSymbolicLink()) return entry("linked", "the skill directory is a link; left untouched");
|
|
168
|
+
if (!stat.isDirectory()) return entry("foreign", "not a directory; left untouched");
|
|
169
|
+
const marker = readMarker(dir);
|
|
170
|
+
if (marker === "missing") return entry("foreign", `no ${SKILL_MARKER}; left untouched`);
|
|
171
|
+
if (marker === "foreign") return entry("foreign", `${SKILL_MARKER} is not the hub's; left untouched`);
|
|
172
|
+
let installed: Tree;
|
|
173
|
+
try { installed = readTree(dir); } catch (error) { return entry("failed", (error as Error).message); }
|
|
174
|
+
if (installed.digest !== marker.sha256) return entry("modified", "edited since the hub wrote it; left untouched");
|
|
175
|
+
if (marker.version !== VERSION) return entry("replace", `stale ${marker.version} -> ${VERSION}`);
|
|
176
|
+
if (installed.digest !== skill.tree.digest) return entry("replace", "the hub's files changed at the same version");
|
|
177
|
+
return entry("unchanged", VERSION);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Plan the install for every host, from a source tree in this package. Throws when the source is unreadable. */
|
|
181
|
+
export function skillInstallPlan(source: string, paths: SkillPaths = {}): SkillEntry[] {
|
|
182
|
+
const skills = readSource(source);
|
|
183
|
+
const plan: SkillEntry[] = [];
|
|
184
|
+
for (const host of SKILL_HOSTS) {
|
|
185
|
+
const found = locate(host, paths);
|
|
186
|
+
if ("action" in found) { plan.push({ host, skill: "", dir: found.dir, action: found.action, detail: found.detail }); continue; }
|
|
187
|
+
for (const skill of skills) plan.push(inspectSkill(host, skill, found.dir));
|
|
188
|
+
}
|
|
189
|
+
return plan;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Plan the undo: only a tree the hub wrote and nobody edited is marked for removal. Other skills are not listed. */
|
|
193
|
+
export function skillUndoPlan(paths: SkillPaths = {}): SkillEntry[] {
|
|
194
|
+
const plan: SkillEntry[] = [];
|
|
195
|
+
for (const host of SKILL_HOSTS) {
|
|
196
|
+
const found = locate(host, paths);
|
|
197
|
+
if ("action" in found) { plan.push({ host, skill: "", dir: found.dir, action: found.action, detail: found.detail }); continue; }
|
|
198
|
+
const stat = lstat(found.dir);
|
|
199
|
+
if (!stat) { plan.push({ host, skill: "", dir: found.dir, action: "absent", detail: "not installed" }); continue; }
|
|
200
|
+
if (stat.isSymbolicLink()) { plan.push({ host, skill: "", dir: found.dir, action: "linked", detail: "the skill directory is a link; left untouched" }); continue; }
|
|
201
|
+
if (!stat.isDirectory()) { plan.push({ host, skill: "", dir: found.dir, action: "foreign", detail: "not a directory; left untouched" }); continue; }
|
|
202
|
+
let names: string[];
|
|
203
|
+
try { names = readdirSync(found.dir).sort(); } catch (error) { plan.push({ host, skill: "", dir: found.dir, action: "failed", detail: (error as Error).message }); continue; }
|
|
204
|
+
let seen = 0;
|
|
205
|
+
for (const name of names) {
|
|
206
|
+
if (name.startsWith(".")) continue;
|
|
207
|
+
const dir = join(found.dir, name);
|
|
208
|
+
const child = lstat(dir);
|
|
209
|
+
if (!child || child.isSymbolicLink() || !child.isDirectory()) continue;
|
|
210
|
+
const marker = readMarker(dir);
|
|
211
|
+
if (marker === "missing" || marker === "foreign") continue; // another tool's skill is not the hub's
|
|
212
|
+
seen += 1;
|
|
213
|
+
let installed: Tree;
|
|
214
|
+
try { installed = readTree(dir); } catch (error) { plan.push({ host, skill: name, dir, action: "failed", detail: (error as Error).message }); continue; }
|
|
215
|
+
if (installed.digest !== marker.sha256) { plan.push({ host, skill: name, dir, action: "modified", detail: "edited since the hub wrote it; left untouched" }); continue; }
|
|
216
|
+
plan.push({ host, skill: name, dir, action: "remove", detail: `the hub's ${marker.version} tree` });
|
|
217
|
+
}
|
|
218
|
+
if (!seen) plan.push({ host, skill: "", dir: found.dir, action: "absent", detail: "no hub skill tree" });
|
|
219
|
+
}
|
|
220
|
+
return plan;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Write one tree beside its target and rename it into place; the marker lands with the files, never before them. */
|
|
224
|
+
function writeTree(target: string, tree: Tree): void {
|
|
225
|
+
const parent = dirname(target);
|
|
226
|
+
mkdirSync(parent, { recursive: true, mode: 0o755 });
|
|
227
|
+
const temp = `${target}.ahub-tmp-${process.pid}-${randomUUID()}`;
|
|
228
|
+
let previous: string | undefined;
|
|
229
|
+
try {
|
|
230
|
+
mkdirSync(temp, { mode: 0o755 });
|
|
231
|
+
for (const file of tree.files) {
|
|
232
|
+
const dest = join(temp, ...file.path.split("/"));
|
|
233
|
+
mkdirSync(dirname(dest), { recursive: true, mode: 0o755 });
|
|
234
|
+
writeFileSync(dest, file.bytes, { flag: "wx", mode: 0o644 });
|
|
235
|
+
}
|
|
236
|
+
const marker = JSON.stringify({ tool: SKILL_TOOL, version: VERSION, sha256: tree.digest }, null, 2) + "\n";
|
|
237
|
+
writeFileSync(join(temp, SKILL_MARKER), marker, { flag: "wx", mode: 0o644 });
|
|
238
|
+
if (lstat(target)) {
|
|
239
|
+
previous = `${target}.ahub-old-${process.pid}-${randomUUID()}`;
|
|
240
|
+
renameSync(target, previous);
|
|
241
|
+
}
|
|
242
|
+
try { renameSync(temp, target); }
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (previous) {
|
|
245
|
+
try { renameSync(previous, target); } catch { /* the old tree keeps its temporary name and is named in the error */ }
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
if (previous) rmSync(previous, { recursive: true, force: true });
|
|
250
|
+
} catch (error) {
|
|
251
|
+
rmSync(temp, { recursive: true, force: true });
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** True when the directory a tree lives in became a link after the plan; writing through it would land outside. */
|
|
257
|
+
function hostDirLinked(dir: string): boolean {
|
|
258
|
+
return lstat(dirname(dir))?.isSymbolicLink() ?? false;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Apply the entries that write. A host that cannot be written is reported, never thrown, so other hosts still install. */
|
|
262
|
+
export function applySkillPlan(source: string, plan: SkillEntry[]): SkillEntry[] {
|
|
263
|
+
const skills = new Map(readSource(source).map(skill => [skill.name, skill]));
|
|
264
|
+
return plan.map(entry => {
|
|
265
|
+
if (entry.action !== "install" && entry.action !== "replace") return entry;
|
|
266
|
+
const skill = skills.get(entry.skill);
|
|
267
|
+
if (!skill) return { ...entry, action: "failed", detail: `no source for ${entry.skill}` };
|
|
268
|
+
// The plan was made before the question; a tree or a skills directory that changed while it was open is kept.
|
|
269
|
+
if (hostDirLinked(entry.dir)) return { ...entry, action: "linked", detail: "the skills directory became a link; left untouched" };
|
|
270
|
+
const fresh = inspectSkill(entry.host, skill, dirname(entry.dir));
|
|
271
|
+
if (fresh.action === "unchanged") return fresh;
|
|
272
|
+
if (fresh.action !== "install" && fresh.action !== "replace") {
|
|
273
|
+
return { ...fresh, detail: `${fresh.detail} (changed since the plan; left untouched)` };
|
|
274
|
+
}
|
|
275
|
+
try { writeTree(entry.dir, skill.tree); return { ...entry, detail: entry.action === "replace" ? entry.detail : VERSION }; }
|
|
276
|
+
catch (error) { return { ...entry, action: "failed", detail: (error as Error).message }; }
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Apply the undo. The marker and digest are checked again here, so a tree edited after the plan is not removed. */
|
|
281
|
+
export function applySkillUndo(plan: SkillEntry[]): SkillEntry[] {
|
|
282
|
+
return plan.map(entry => {
|
|
283
|
+
if (entry.action !== "remove") return entry;
|
|
284
|
+
if (hostDirLinked(entry.dir)) return { ...entry, action: "linked", detail: "the skills directory became a link; left untouched" };
|
|
285
|
+
const stat = lstat(entry.dir);
|
|
286
|
+
if (!stat || stat.isSymbolicLink() || !stat.isDirectory()) return { ...entry, action: "foreign", detail: "changed since the plan; left untouched" };
|
|
287
|
+
const marker = readMarker(entry.dir);
|
|
288
|
+
if (marker === "missing" || marker === "foreign") return { ...entry, action: "foreign", detail: "changed since the plan; left untouched" };
|
|
289
|
+
let installed: Tree;
|
|
290
|
+
try { installed = readTree(entry.dir); } catch (error) { return { ...entry, action: "failed", detail: (error as Error).message }; }
|
|
291
|
+
if (installed.digest !== marker.sha256) return { ...entry, action: "modified", detail: "edited since the plan; left untouched" };
|
|
292
|
+
try { rmSync(entry.dir, { recursive: true, force: false }); return { ...entry, action: "removed", detail: entry.detail }; }
|
|
293
|
+
catch (error) { return { ...entry, action: "failed", detail: (error as Error).message }; }
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function skillState(dir: string): { state: SkillState; detail: string } {
|
|
298
|
+
const stat = lstat(dir);
|
|
299
|
+
if (!stat) return { state: "missing", detail: "not installed" };
|
|
300
|
+
if (stat.isSymbolicLink()) return { state: "linked", detail: "the skill directory is a link" };
|
|
301
|
+
if (!stat.isDirectory()) return { state: "foreign", detail: "not a directory" };
|
|
302
|
+
const marker = readMarker(dir);
|
|
303
|
+
if (marker === "missing") return { state: "foreign", detail: `no ${SKILL_MARKER}` };
|
|
304
|
+
if (marker === "foreign") return { state: "foreign", detail: `${SKILL_MARKER} is not the hub's` };
|
|
305
|
+
let installed: Tree;
|
|
306
|
+
try { installed = readTree(dir); } catch (error) { return { state: "failed", detail: (error as Error).message }; }
|
|
307
|
+
if (installed.digest !== marker.sha256) return { state: "modified", detail: "edited since the hub wrote it" };
|
|
308
|
+
if (marker.version !== VERSION) return { state: "stale", detail: `${marker.version} -> ${VERSION}` };
|
|
309
|
+
return { state: "installed", detail: VERSION };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const STATE_ORDER: readonly SkillState[] = ["failed", "linked", "foreign", "modified", "stale", "missing", "installed"];
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* What the doctor reads: one state per host, without writing anything. `expected` names the skills this package ships,
|
|
316
|
+
* so a tree the hub wrote and no longer ships is not read as a missing skill.
|
|
317
|
+
*/
|
|
318
|
+
export function skillHostStates(paths: SkillPaths, expected: readonly string[]): SkillHostState[] {
|
|
319
|
+
return SKILL_HOSTS.map(host => {
|
|
320
|
+
const found = locate(host, paths);
|
|
321
|
+
if ("action" in found) return { host, dir: found.dir, state: found.action, detail: found.detail };
|
|
322
|
+
const stat = lstat(found.dir);
|
|
323
|
+
if (!stat) return { host, dir: found.dir, state: "missing", detail: "not installed" };
|
|
324
|
+
if (stat.isSymbolicLink()) return { host, dir: found.dir, state: "linked", detail: "the skills directory is a link" };
|
|
325
|
+
if (!stat.isDirectory()) return { host, dir: found.dir, state: "foreign", detail: "not a directory" };
|
|
326
|
+
const problems = [...expected].map(name => ({ name, ...skillState(join(found.dir, name)) })).filter(item => item.state !== "installed");
|
|
327
|
+
const state = STATE_ORDER.find(candidate => problems.some(problem => problem.state === candidate)) ?? "installed";
|
|
328
|
+
return {
|
|
329
|
+
host, dir: found.dir, state,
|
|
330
|
+
detail: problems.length ? problems.map(problem => `${problem.name} ${problem.state}`).join(", ") : `${expected.length} installed`,
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** One doctor row for every selected host. `undefined` is a warning: a tree the hub will not touch is not a failure. */
|
|
336
|
+
export function skillStateRow(states: SkillHostState[]): { ok: boolean | undefined; detail: string } {
|
|
337
|
+
const selected = states.filter(state => state.state !== "absent");
|
|
338
|
+
if (!selected.length) return { ok: true, detail: "no other agent host installed on this machine" };
|
|
339
|
+
const needsSetup = selected.some(state => state.state === "missing" || state.state === "stale" || state.state === "failed");
|
|
340
|
+
const warning = selected.some(state => state.state === "modified" || state.state === "foreign" || state.state === "linked");
|
|
341
|
+
return {
|
|
342
|
+
ok: needsSetup ? false : warning ? undefined : true,
|
|
343
|
+
detail: selected.map(state => `${state.host} ${state.state}`).join("; "),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface SkillInstallOptions extends SkillPaths {
|
|
348
|
+
/** The package's skill directory. Required for an install, unused by `undo`. */
|
|
349
|
+
source?: string;
|
|
350
|
+
undo?: boolean;
|
|
351
|
+
yes: boolean;
|
|
352
|
+
ask?: (prompt: string) => Promise<string | null>;
|
|
353
|
+
print: (line: string) => void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function hostEntries(plan: SkillEntry[], host: SkillHost): SkillEntry[] {
|
|
357
|
+
return plan.filter(entry => entry.host === host);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function absentLine(entry: SkillEntry): string {
|
|
361
|
+
if (entry.action === "absent") return `${entry.host} not installed (${entry.detail})`;
|
|
362
|
+
if (entry.action === "linked") return `${entry.host} link; left untouched (${entry.dir})`;
|
|
363
|
+
if (entry.action === "foreign") return `${entry.host} foreign tree; left untouched (${entry.dir})`;
|
|
364
|
+
return `${entry.host} cannot be read: ${entry.detail}`;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function skillNames(entries: SkillEntry[], actions: readonly SkillAction[]): string {
|
|
368
|
+
const names = entries.filter(entry => entry.skill && actions.includes(entry.action)).map(entry => entry.skill);
|
|
369
|
+
return names.length ? ` (${names.join(", ")} left untouched)` : "";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function hostSummary(entries: SkillEntry[], done: boolean, undo: boolean): string {
|
|
373
|
+
const count = (action: SkillAction) => entries.filter(entry => entry.action === action).length;
|
|
374
|
+
const parts: string[] = [];
|
|
375
|
+
const push = (n: number, text: string) => { if (n) parts.push(text); };
|
|
376
|
+
if (undo) {
|
|
377
|
+
push(count("remove"), `${count("remove")} would remove`);
|
|
378
|
+
push(count("removed"), `${count("removed")} removed`);
|
|
379
|
+
} else if (done) {
|
|
380
|
+
push(count("install"), `${count("install")} installed`);
|
|
381
|
+
push(count("replace"), `${count("replace")} replaced`);
|
|
382
|
+
} else {
|
|
383
|
+
push(count("install"), `${count("install")} would install`);
|
|
384
|
+
push(count("replace"), `${count("replace")} would replace`);
|
|
385
|
+
}
|
|
386
|
+
push(count("unchanged"), `${count("unchanged")} up to date`);
|
|
387
|
+
push(count("modified"), `${count("modified")} modified`);
|
|
388
|
+
push(count("foreign"), `${count("foreign")} foreign`);
|
|
389
|
+
push(count("linked"), `${count("linked")} linked`);
|
|
390
|
+
push(count("failed"), `${count("failed")} unreadable`);
|
|
391
|
+
return parts.join(", ") || "nothing to do";
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function printHosts(plan: SkillEntry[], options: SkillInstallOptions, done: boolean, undo: boolean): void {
|
|
395
|
+
for (const host of SKILL_HOSTS) {
|
|
396
|
+
const entries = hostEntries(plan, host);
|
|
397
|
+
const hostLevel = entries.find(entry => !entry.skill);
|
|
398
|
+
if (hostLevel) { options.print(`hub skills: ${absentLine(hostLevel)}`); continue; }
|
|
399
|
+
const left = skillNames(entries, ["modified", "foreign", "linked"]);
|
|
400
|
+
options.print(`hub skills: ${host} ${hostSummary(entries, done, undo)}${left}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function confirm(options: SkillInstallOptions, prompt: string): Promise<boolean> {
|
|
405
|
+
if (options.yes) return true;
|
|
406
|
+
if (!options.ask) return false;
|
|
407
|
+
const answer = await options.ask(prompt);
|
|
408
|
+
return typeof answer === "string" && /^y(es)?$/i.test(answer.trim());
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function tally(entries: SkillEntry[], action: SkillAction): number {
|
|
412
|
+
return entries.filter(entry => entry.action === action).length;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function finishLine(entries: SkillEntry[]): string {
|
|
416
|
+
const installed = tally(entries, "install"), replaced = tally(entries, "replace"), removed = tally(entries, "removed"), failed = tally(entries, "failed");
|
|
417
|
+
const changed = installed + replaced + removed;
|
|
418
|
+
return `hub skills: ${installed} installed, ${replaced} replaced, ${removed} removed, ${failed} failed, ${entries.length - changed - failed} left`;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* `ahub setup`'s skill step: print what would happen, ask once (unless `--yes`), then write or remove. Everything the
|
|
423
|
+
* hub does not own is reported and left alone. Never throws for a missing source: setup reports it and keeps going.
|
|
424
|
+
*/
|
|
425
|
+
export async function installHubSkills(options: SkillInstallOptions): Promise<void> {
|
|
426
|
+
if (options.undo) {
|
|
427
|
+
const plan = skillUndoPlan(options);
|
|
428
|
+
printHosts(plan, options, false, true);
|
|
429
|
+
const removable = plan.filter(entry => entry.action === "remove");
|
|
430
|
+
if (!removable.length) { options.print("hub skills: nothing to remove"); return; }
|
|
431
|
+
if (!(await confirm(options, `Remove ${removable.length} hub skill ${removable.length === 1 ? "tree" : "trees"}? [y/N] `))) {
|
|
432
|
+
options.print("hub skills: nothing removed; rerun with --yes");
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const done = applySkillUndo(plan);
|
|
436
|
+
printHosts(done, options, true, true);
|
|
437
|
+
options.print(finishLine(done));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!options.source) throw new SkillsInstallError("the hub skill source directory is missing");
|
|
441
|
+
let plan: SkillEntry[];
|
|
442
|
+
try { plan = skillInstallPlan(options.source, options); }
|
|
443
|
+
catch (error) {
|
|
444
|
+
options.print(`hub skills: skipped (${(error as Error).message})`);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
printHosts(plan, options, false, false);
|
|
448
|
+
const writable = plan.filter(entry => entry.action === "install" || entry.action === "replace");
|
|
449
|
+
if (!writable.length) { options.print("hub skills: up to date; nothing written"); return; }
|
|
450
|
+
const hosts = [...new Set(writable.map(entry => entry.host))];
|
|
451
|
+
if (!(await confirm(options, `Install hub skills for ${hosts.join(", ")}? [y/N] `))) {
|
|
452
|
+
options.print("hub skills: nothing written; rerun with --yes");
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
let done: SkillEntry[];
|
|
456
|
+
try { done = applySkillPlan(options.source, plan); }
|
|
457
|
+
catch (error) {
|
|
458
|
+
options.print(`hub skills: write failed (${(error as Error).message})`);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
printHosts(done, options, true, false);
|
|
462
|
+
options.print(finishLine(done));
|
|
463
|
+
}
|
package/src/cli/task-output.ts
CHANGED
|
@@ -93,7 +93,7 @@ const planBlock = (plan: any, columns: number | undefined): Line[] => {
|
|
|
93
93
|
const keys = ["paths", "symbols", "signatures", "insertion_points", "sections", "sources", "claims"];
|
|
94
94
|
return keys.flatMap(key => bullets(key.replace("_", " "), list(plan?.[key]), columns, undefined, " "));
|
|
95
95
|
};
|
|
96
|
-
const historyRows = (history: any[], now: number): Span[][] => history.map(entry => [s(when(entry.at, now), "muted"), s(entry.by ?? "-"), s(entry.event ?? "-", entry.event === "approved" ? "success" : entry.event === "changes_requested" ? "attention" : undefined), s(dash(entry.note))]);
|
|
96
|
+
const historyRows = (history: any[], now: number): Span[][] => history.map(entry => [s(when(entry.at, now), "muted"), s(entry.instructed && entry.instructedPeer ? `${entry.by ?? "user"} via ${entry.instructedPeer}` : entry.by ?? "-"), s(entry.event ?? "-", entry.event === "approved" ? "success" : entry.event === "changes_requested" ? "attention" : undefined), s(dash(entry.note))]);
|
|
97
97
|
|
|
98
98
|
/** The one task block: identity, who holds it, what it waits for, then plan, receipt and history. */
|
|
99
99
|
function taskBlock(task: any, columns: number | undefined, now: number, detail: boolean): Line[] {
|
|
@@ -24,7 +24,7 @@ export function readRecoveryPresentationFlags(
|
|
|
24
24
|
else if (flag?.kind === "verbose") { verbose = true; flags.push(arg); }
|
|
25
25
|
else args.push(arg);
|
|
26
26
|
}
|
|
27
|
-
const resolved = resolveColor(color, terminal);
|
|
27
|
+
const resolved = resolveColor(color, terminal, "ahub");
|
|
28
28
|
if (resolved instanceof Error) throw resolved;
|
|
29
29
|
const columns = terminal.columns !== undefined && Number.isFinite(terminal.columns) && terminal.columns > 0 ? Math.floor(terminal.columns) : 80;
|
|
30
30
|
return { args, flags, json, options: { columns, color: resolved, verbose, now } };
|