@staix/agent-hub 0.45.0 → 0.46.0

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 (107) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +10 -4
  3. package/docs/adding-an-ai-tool.md +1 -0
  4. package/docs/agent-notes/adapters.md +33 -4
  5. package/docs/agent-notes/budget.md +2 -1
  6. package/docs/agent-notes/daemon.md +5 -1
  7. package/docs/agent-notes/security-review.md +3 -2
  8. package/docs/agent-notes/tasks.md +3 -1
  9. package/docs/agent-notes/tests.md +1 -1
  10. package/docs/design/adapters.md +16 -0
  11. package/docs/design/agent-hub-architecture.md +12 -0
  12. package/docs/design/cli-output.md +2 -0
  13. package/docs/design/roadmap.md +86 -5
  14. package/docs/design/task-board.md +2 -2
  15. package/docs/dogfood.md +15 -0
  16. package/docs/events.md +2 -2
  17. package/docs/operations.md +102 -20
  18. package/docs/quickstart.md +9 -3
  19. package/docs/security.md +7 -5
  20. package/docs/smoke.md +1 -1
  21. package/docs/verification/2026-11-05-hardcoded-values-classification-rules.md +28 -0
  22. package/docs/verification/2026-11-22-agy-1.5.14.md +27 -0
  23. package/docs/verification/2026-11-22-claude-instruction-hook.md +35 -0
  24. package/docs/verification/2026-11-22-instructed-ipc.md +9 -0
  25. package/docs/verification/2026-11-22-jcode-1.0.3.md +71 -0
  26. package/docs/verification/2026-11-22-jcode-separate-home.md +14 -0
  27. package/docs/verification/2026-11-22-qwen-0283-acp.md +28 -0
  28. package/docs/verification/2026-11-22-qwen-0283-dual-output.md +33 -0
  29. package/docs/verification/2026-11-22-roadmap-r5-view-receipt.md +63 -0
  30. package/docs/verification/2026-11-23-0.46.0.md +44 -0
  31. package/docs/verification/assets/1483-r5-detail-1440-light.png +0 -0
  32. package/docs/verification/assets/1483-r5-detail-390-light.png +0 -0
  33. package/docs/verification/assets/1483-r5-view-1440-dark.png +0 -0
  34. package/docs/verification/assets/1483-r5-view-1440-light.png +0 -0
  35. package/docs/verification/assets/1483-r5-view-390-dark.png +0 -0
  36. package/docs/verification/assets/1483-r5-view-390-light.png +0 -0
  37. package/docs/verification/assets/1483-r5-view-820-dark.png +0 -0
  38. package/docs/verification/assets/1483-r5-view-820-light.png +0 -0
  39. package/docs/verified.json +23 -23
  40. package/package.json +3 -2
  41. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  42. package/plugins/agent-hub/kimi-hook.js +5951 -5499
  43. package/plugins/agent-hub/server.js +1136 -1015
  44. package/plugins/agent-hub/skills/ahub/SKILL.md +17 -0
  45. package/plugins/agent-hub/skills/ahub-manage/SKILL.md +37 -0
  46. package/plugins/agent-hub/skills/ahub-status/SKILL.md +14 -0
  47. package/plugins/agent-hub/skills/ahub-use/SKILL.md +12 -0
  48. package/src/adapters/claude-channel.ts +2 -1
  49. package/src/adapters/compat.ts +12 -11
  50. package/src/adapters/definitions/native-cli-claude-setup.ts +9 -1
  51. package/src/adapters/definitions/native-cli-doctor.ts +8 -5
  52. package/src/adapters/definitions/native-cli-jcode-home-init.ts +158 -0
  53. package/src/adapters/definitions/native-cli-jcode-home.ts +72 -0
  54. package/src/adapters/definitions/native-cli-jcode-mcp.ts +20 -0
  55. package/src/adapters/definitions/native-cli-skills.ts +29 -0
  56. package/src/cli/claude-profile-hook.ts +40 -3
  57. package/src/cli/console-state.ts +55 -26
  58. package/src/cli/console-usage.ts +5 -3
  59. package/src/cli/console.ts +35 -4
  60. package/src/cli/help.ts +15 -10
  61. package/src/cli/identity.ts +2 -1
  62. package/src/cli/instruction-hook.ts +28 -0
  63. package/src/cli/jcode-mcp.ts +2 -1
  64. package/src/cli/main.js +8 -0
  65. package/src/cli/main.ts +138 -18
  66. package/src/cli/output-standard.ts +3 -55
  67. package/src/cli/output.ts +8 -2
  68. package/src/cli/recovery-package.ts +47 -11
  69. package/src/cli/roadmap.ts +37 -3
  70. package/src/cli/setup-homes.ts +1 -0
  71. package/src/cli/setup.ts +1 -1
  72. package/src/cli/skills-install.ts +463 -0
  73. package/src/cli/task-output.ts +1 -1
  74. package/src/cli/upgrade-presentation-flags.ts +1 -1
  75. package/src/hub/board.ts +42 -4
  76. package/src/hub/budget-projection.ts +99 -0
  77. package/src/hub/claude-launch-proof.ts +5 -1
  78. package/src/hub/conductor.ts +8 -3
  79. package/src/hub/config-apply.ts +3 -2
  80. package/src/hub/config-tier.ts +1 -1
  81. package/src/hub/config-trust.ts +1 -1
  82. package/src/hub/control-client.ts +9 -2
  83. package/src/hub/daemon.ts +457 -26
  84. package/src/hub/events.ts +1 -1
  85. package/src/hub/execution-budget.ts +29 -8
  86. package/src/hub/hub-tools.ts +2 -2
  87. package/src/hub/inference.ts +1 -1
  88. package/src/hub/instances.ts +10 -1
  89. package/src/hub/instructed-exact.ts +95 -0
  90. package/src/hub/instructed-intent.ts +64 -0
  91. package/src/hub/instructed-ipc.ts +33 -0
  92. package/src/hub/instructed-runtime.ts +19 -0
  93. package/src/hub/instruction-receipt.ts +218 -0
  94. package/src/hub/manager.ts +46 -3
  95. package/src/hub/registry.ts +1 -1
  96. package/src/hub/roadmap-decompose.ts +60 -1
  97. package/src/hub/roadmap-sync.ts +2 -2
  98. package/src/hub/roadmap.ts +19 -1
  99. package/src/hub/routing.ts +18 -1
  100. package/src/hub/runtime-capture-prune.ts +2 -1
  101. package/src/hub/settings.ts +2 -1
  102. package/src/hub/tasks.ts +194 -12
  103. package/src/hub/ui.ts +6 -2
  104. package/src/hub/usage-rollup.ts +42 -2
  105. package/src/ui/index.html +342 -8
  106. package/src/ui/plugin.ts +6 -2
  107. package/src/ui/roadmap-model.ts +70 -0
@@ -85,10 +85,50 @@ function removeManifest(home: string, instanceId: string) {
85
85
  rmSync(files(home).token, { force: true });
86
86
  }
87
87
 
88
+ /** #1483 R5: one project's public roadmap summary for `ahub ui --all`. `partial` means the hub could not answer, so the counts are a floor, not a zero. */
89
+ export interface ProjectRoadmapSummary { total: number; byHorizon: Record<string, number>; byState: Record<string, number>; drift: number; partial: boolean }
90
+ /** Lanes and states come from the milestone rows' own fields, so an unknown value is counted under its own name instead of dropped. */
91
+ export function roadmapSummary(milestones: readonly Record<string, unknown>[], drift = 0): ProjectRoadmapSummary {
92
+ const byHorizon: Record<string, number> = {}, byState: Record<string, number> = {};
93
+ for (const milestone of milestones) {
94
+ const horizon = String(milestone.horizon ?? "later"), state = String(milestone.state ?? "proposed");
95
+ byHorizon[horizon] = (byHorizon[horizon] ?? 0) + 1;
96
+ byState[state] = (byState[state] ?? 0) + 1;
97
+ }
98
+ return { total: milestones.length, byHorizon, byState, drift, partial: false };
99
+ }
100
+
88
101
  /** The manager's project listing and forwarding (#935): shared by `ahub ui --all` and the acon plugin, never widened for either. */
89
- export function projectConsole(options: { registry: Registry; lifecycle: Lifecycle; home: string; stopping?: () => boolean; forwardTimeoutMs?: ManagerOptions["forwardTimeoutMs"]; afterStart?: ManagerOptions["afterStart"] }) {
102
+ export function projectConsole(options: { registry: Registry; lifecycle: Lifecycle; home: string; stopping?: () => boolean; forwardTimeoutMs?: ManagerOptions["forwardTimeoutMs"]; afterStart?: ManagerOptions["afterStart"]; roadmap?: boolean }) {
90
103
  const { registry, lifecycle, home } = options;
91
104
  const aliases = new Map<string, { at: number; names: string[] }>();
105
+ // #1483 R5: a project's roadmap is read once a minute, because the manager's page polls this listing every three seconds.
106
+ // It is opt-in, so the acon plugin's listing pays nothing for a field it does not show, and the whole read is bounded.
107
+ const roadmaps = new Map<string, { at: number; instanceId: string | null; summary: ProjectRoadmapSummary }>();
108
+ const roadmap = async (project: { id: string; root: string; stateDir: string }, instanceId: string | null): Promise<ProjectRoadmapSummary> => {
109
+ const cached = roadmaps.get(project.id);
110
+ if (cached && cached.instanceId === instanceId && Date.now() - cached.at < 60_000) return cached.summary;
111
+ const unavailable: ProjectRoadmapSummary = { total: 0, byHorizon: {}, byState: {}, drift: 0, partial: true };
112
+ let summary = unavailable, client: ControlClient | undefined;
113
+ try {
114
+ client = await bounded(ControlClient.connect(project.stateDir, { role: "console", projectId: project.id, projectRoot: project.root }, 3000), 4000);
115
+ const listed = await bounded(client.request({ t: "task", op: "hub_roadmap_list", args: {} }, 5000), 6000);
116
+ if (listed && listed.ok !== false) {
117
+ let report: any;
118
+ try { report = JSON.parse(String(listed.text ?? "")); } catch { report = undefined; }
119
+ if (Array.isArray(report?.milestones)) {
120
+ // The drift read is the hub's own findings count; a refusal only drops the count, never the milestones.
121
+ const checked = await bounded(client.request({ t: "task", op: "hub_roadmap_check", args: {} }, 15_000), 16_000).catch(() => undefined);
122
+ let drift = 0;
123
+ if (checked && checked.ok !== false) { try { const findings = JSON.parse(String(checked.text ?? ""))?.findings; drift = Array.isArray(findings) ? findings.length : 0; } catch { drift = 0; } }
124
+ summary = roadmapSummary(report.milestones, drift);
125
+ }
126
+ }
127
+ } catch { summary = unavailable; }
128
+ finally { client?.close(); }
129
+ roadmaps.set(project.id, { at: Date.now(), instanceId, summary });
130
+ return summary;
131
+ };
92
132
  const list = async () => {
93
133
  const projects = registry.list();
94
134
  for (const p of projects) if (!aliases.has(p.id) || Date.now() - aliases.get(p.id)!.at > 60_000) {
@@ -100,9 +140,12 @@ export function projectConsole(options: { registry: Registry; lifecycle: Lifecyc
100
140
  catch (error) { result = { state: "unavailable", error: safeError(error) }; }
101
141
  const names = aliases.get(project.id)!.names;
102
142
  const shared = projects.some((other) => other.id !== project.id && aliases.get(other.id)!.names.some((name) => names.includes(name)));
143
+ const instanceId = result.state === "running" ? result.status?.instanceId ?? null : null;
103
144
  return { id: project.id, root: project.root, state: result.state,
104
- instanceId: result.state === "running" ? result.status?.instanceId ?? null : null,
145
+ instanceId,
105
146
  peers: result.status?.peers ?? {}, tasks: result.status?.tasks ?? {},
147
+ // #1483 R5: a running project answers with its own public roadmap summary; a stopped one has none to read.
148
+ ...(instanceId && options.roadmap ? { roadmap: await roadmap(project, instanceId) } : {}),
106
149
  ...(shared ? { warning: "Native memory aliases are shared with another registered project." } : {}),
107
150
  ...(result.error ? { error: result.error } : {}) };
108
151
  }));
@@ -327,7 +370,7 @@ export async function startManager(options: ManagerOptions = {}): Promise<Manage
327
370
  try { publicationRegistry.runtimeCaptureLocked(() => {
328
371
  assertExecutableRuntimeRoot(realPath(resolve(import.meta.dir, "../..")));
329
372
  owner = claimOwner(f.owner, instanceId, pidSignature);
330
- const { list, act } = projectConsole({ registry, lifecycle, home, stopping: () => stopping, forwardTimeoutMs: options.forwardTimeoutMs, ...(options.afterStart && !options.liveTest ? { afterStart: options.afterStart } : {}) });
373
+ const { list, act } = projectConsole({ registry, lifecycle, home, roadmap: true, stopping: () => stopping, forwardTimeoutMs: options.forwardTimeoutMs, ...(options.afterStart && !options.liveTest ? { afterStart: options.afterStart } : {}) });
331
374
  dashboard = startDashboard({ projects: list, snapshot: (after, input = {}) => act({ ...input, action: "snapshot", after }), action: act });
332
375
  server = Bun.serve({ hostname: "127.0.0.1", port: 0, maxRequestBodySize: 1024,
333
376
  async fetch(req) {
@@ -38,7 +38,7 @@ export function projectFromRow(raw: Record<string, unknown>): Project {
38
38
  return project;
39
39
  }
40
40
 
41
- const idFor = (root: string) => `p_${createHash("sha256").update(root).digest("hex").slice(0, 24)}`;
41
+ export const idFor = (root: string) => `p_${createHash("sha256").update(root).digest("hex").slice(0, 24)}`;
42
42
  // Preserve the original identifier of missing legacy checkouts as a reservation.
43
43
  const legacyRoot = (path: string) => { try { return realpathSync(path); } catch { return resolve(path); } };
44
44
  const canonicalState = canonicalPath;
@@ -1,12 +1,14 @@
1
1
  /** R2 (#1480): the decompose prompt and the strict reader of what a model answers. Pure: no clock, no I/O, no authority. */
2
2
  import { CLASSES } from "./board.ts";
3
- import { DECOMPOSE_LIMITS, type DecomposeIntake, type DecomposePart } from "./roadmap.ts";
3
+ import { DECOMPOSE_LIMITS, githubRepo, milestoneId, milestoneMembershipField, type DecomposeIntake, type DecomposePart } from "./roadmap.ts";
4
4
 
5
5
  export const DECOMPOSE_ITEMS = 40;
6
6
  export const DECOMPOSE_OUTCOME_CHARS = 2000;
7
7
  export const DECOMPOSE_ITEM_CHARS = 300;
8
8
  /** Paths shown from one spec summary. The screen and the prompt read this one number, so what is screened is what is shown. */
9
9
  export const DECOMPOSE_PATHS = 6;
10
+ /** A part title is cut to this before it becomes an issue title: a bound on what leaves the hub, not a claim about GitHub. */
11
+ export const PART_ISSUE_TITLE_CHARS = 256;
10
12
  export interface DecomposeItem { ref: string; /** The label shown to the model: `spec <id>` or `issue <owner/repo#N>`. */ label: string; /** The only item text the model sees. */ text: string }
11
13
  export interface DecomposeMilestone { id: number; title: string; outcome: string }
12
14
  export interface DecomposeInput { milestone: DecomposeMilestone; specs: readonly DecomposeItem[]; issues: readonly DecomposeItem[] }
@@ -78,3 +80,60 @@ export function parseDecomposition(text: string, prompt: DecomposePrompt): Decom
78
80
  }
79
81
  return { parts, dropped };
80
82
  }
83
+
84
+ /**
85
+ * R2 (#1480) part 3: one held draft of a milestone, as the publish preview reads it. `title`/`detail`/`cites` come from the
86
+ * answer the accept came from; the caller screens them and leaves a part it cannot render out of this list.
87
+ */
88
+ export interface PublishDraft {
89
+ /** The part's 1-based position, as the accept recorded it. */
90
+ part: number;
91
+ /** The held draft task the part became. */
92
+ task: number;
93
+ intake: DecomposeIntake;
94
+ title: string;
95
+ detail: string;
96
+ cites: readonly string[];
97
+ /** The issue a previous apply recorded for this draft, or null. */
98
+ published: number | null;
99
+ /** `held` while the intake hold stands; `released` once the person approved the draft. */
100
+ hold: "held" | "released";
101
+ }
102
+ /** `create`: this apply makes the issue; `published`: an earlier apply did; `task`: the draft is the work item; `released`: no hold. */
103
+ export type PublishAction = "create" | "published" | "task" | "released";
104
+ export interface PublishPlanPart { part: number; task: number; intake: DecomposeIntake; issue: number | null; action: PublishAction }
105
+ export interface PublishPlan { parts: PublishPlanPart[]; calls: string[][] }
106
+
107
+ /** The issue's own identity: the project, milestone and draft it was created for, readable long after the local row is gone. */
108
+ export function partIssueMarker(project: string, milestone: number, task: number): string {
109
+ if (typeof project !== "string" || !/^[A-Za-z0-9._-]{1,64}$/.test(project)) throw new Error("invalid roadmap project marker");
110
+ return `<!-- ahub-roadmap-decompose:${project}:${milestoneId(milestone)}:${milestoneId(task)} -->`;
111
+ }
112
+
113
+ /**
114
+ * Plan the publish of one milestone's held drafts. Only a held `spec` part creates anything: it needs its own spec issue before
115
+ * implementation, so the create carries the part's text and, when the milestone is bound to a GitHub milestone, the same
116
+ * membership field `planRoadmapMirror` writes. A `task` part is already its own work item, a released draft is no longer this
117
+ * hold's work and a part recorded as published is not created again. Pure: the caller owns authority, privacy and the calls.
118
+ */
119
+ export function planPartPublish(input: { project: string; repo: string; milestone: number; githubMilestone: number | null; parts: readonly PublishDraft[] }): PublishPlan {
120
+ const repo = githubRepo(input.repo), milestone = milestoneId(input.milestone);
121
+ const githubMilestone = input.githubMilestone === null ? null : milestoneId(input.githubMilestone);
122
+ const parts: PublishPlanPart[] = [], calls: string[][] = [], seen = new Set<number>();
123
+ for (const draft of input.parts) {
124
+ const task = milestoneId(draft.task), part = milestoneId(draft.part);
125
+ if (seen.has(task)) throw new Error("duplicate decomposition draft");
126
+ seen.add(task);
127
+ if (draft.hold === "released") { parts.push({ part, task, intake: draft.intake, issue: draft.published, action: "released" }); continue; }
128
+ if (draft.published !== null) { parts.push({ part, task, intake: draft.intake, issue: milestoneId(draft.published), action: "published" }); continue; }
129
+ if (draft.intake === "task") { parts.push({ part, task, intake: draft.intake, issue: null, action: "task" }); continue; }
130
+ const title = clean(draft.title, PART_ISSUE_TITLE_CHARS), detail = clean(draft.detail, DECOMPOSE_LIMITS.detail), cites = clean(draft.cites.join(", "), DECOMPOSE_LIMITS.detail);
131
+ if (!title || !detail) throw new Error("a decomposition part has no text to publish");
132
+ const body = [detail, "", `Roadmap milestone ${milestone}, part ${part}: this part needs its own spec issue before implementation.`,
133
+ ...(cites ? ["", `Cites: ${cites}`] : []), "", partIssueMarker(input.project, milestone, task)].join("\n");
134
+ calls.push(["api", `repos/${repo}/issues`, "--hostname", "github.com", "--method", "POST", "-f", `title=${title}`, "-f", `body=${body}`,
135
+ ...(githubMilestone === null ? [] : milestoneMembershipField(githubMilestone))]);
136
+ parts.push({ part, task, intake: draft.intake, issue: null, action: "create" });
137
+ }
138
+ return { parts, calls };
139
+ }
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { githubRepo, milestoneId } from "./roadmap.ts";
2
+ import { githubRepo, milestoneId, milestoneMembershipField } from "./roadmap.ts";
3
3
  import type { SdlcGh } from "./sdlc.ts";
4
4
 
5
5
  export interface MirrorIssue { number: number; milestone: number | null }
@@ -87,7 +87,7 @@ export function planRoadmapMirror(repoInput: string, desired: MirrorDesired, rem
87
87
  seen.add(id);
88
88
  if (issue.milestone !== null) milestoneId(issue.milestone);
89
89
  if (desiredIds.has(id) && issue.milestone !== number)
90
- calls.push(["api", `repos/${repo}/issues/${id}`, "--hostname", "github.com", "--method", "PATCH", "-F", `milestone=${number}`]);
90
+ calls.push(["api", `repos/${repo}/issues/${id}`, "--hostname", "github.com", "--method", "PATCH", ...milestoneMembershipField(number)]);
91
91
  else if (!desiredIds.has(id) && issue.milestone === number)
92
92
  calls.push(["api", `repos/${repo}/issues/${id}`, "--hostname", "github.com", "--method", "PATCH", "-F", "milestone=null"]);
93
93
  }
@@ -17,6 +17,8 @@ export type MilestoneLinkKind = typeof MILESTONE_LINK_KINDS[number];
17
17
  export interface MilestoneHistoryEntry {
18
18
  at: number; by: string; event: "created" | "edited" | "linked" | "unlinked" | "ordered" | "state";
19
19
  fields?: string[]; kind?: MilestoneLinkKind;
20
+ /** #1622 family 4: the same three keys task history carries for an instructed person verdict. Only on a `state` entry; the write path restricts them to done and dropped. */
21
+ instructed?: true; instructedPeer?: string; instructionReceipt?: string;
20
22
  }
21
23
  export interface MilestoneInput {
22
24
  title: string; outcome: string; state?: MilestoneState; horizon?: MilestoneHorizon; order?: number;
@@ -99,7 +101,7 @@ export function milestoneHistory(raw: unknown): MilestoneHistoryEntry[] {
99
101
  if (!Array.isArray(raw) || raw.length > MILESTONE_HISTORY_LIMIT) throw new Error("roadmap history is full or invalid");
100
102
  return raw.map(value => {
101
103
  const row = object(value);
102
- if (Object.keys(row).some(key => !["at", "by", "event", "fields", "kind"].includes(key)) || !["created", "edited", "linked", "unlinked", "ordered", "state"].includes(String(row.event))) throw new Error("roadmap history event is invalid");
104
+ if (Object.keys(row).some(key => !["at", "by", "event", "fields", "kind", "instructed", "instructedPeer", "instructionReceipt"].includes(key)) || !["created", "edited", "linked", "unlinked", "ordered", "state"].includes(String(row.event))) throw new Error("roadmap history event is invalid");
103
105
  const entry: MilestoneHistoryEntry = { at: milestoneId(row.at), by: milestoneActor(row.by), event: row.event as MilestoneHistoryEntry["event"] };
104
106
  if (row.fields !== undefined) {
105
107
  if (!Array.isArray(row.fields) || row.fields.length > FIELDS.length || new Set(row.fields).size !== row.fields.length || row.fields.some(field => !(FIELDS as readonly unknown[]).includes(field))) throw new Error("roadmap history fields are invalid");
@@ -109,10 +111,26 @@ export function milestoneHistory(raw: unknown): MilestoneHistoryEntry[] {
109
111
  if (!(MILESTONE_LINK_KINDS as readonly unknown[]).includes(row.kind)) throw new Error("roadmap history link kind is invalid");
110
112
  entry.kind = row.kind as MilestoneLinkKind;
111
113
  }
114
+ const provenance = ["instructed", "instructedPeer", "instructionReceipt"].filter(key => row[key] !== undefined);
115
+ if (provenance.length) {
116
+ // All three together, on a state entry that names exactly the state field; anything else is a forged or truncated record.
117
+ if (provenance.length !== 3 || row.instructed !== true || row.event !== "state" || !Array.isArray(row.fields) || row.fields.length !== 1 || row.fields[0] !== "state"
118
+ || typeof row.instructedPeer !== "string" || row.instructedPeer.length > MILESTONE_LIMITS.actor || !/^[a-z][a-z0-9-]*$/.test(row.instructedPeer)
119
+ || typeof row.instructionReceipt !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(row.instructionReceipt)) throw new Error("roadmap history instructed provenance is invalid");
120
+ entry.instructed = true; entry.instructedPeer = row.instructedPeer; entry.instructionReceipt = row.instructionReceipt;
121
+ }
112
122
  return entry;
113
123
  });
114
124
  }
115
125
 
126
+ /**
127
+ * R4 (#1482) and R2 part 3 (#1480): the one typed GitHub milestone-membership field. `planRoadmapMirror` attaches an existing
128
+ * issue with it and a decomposition publish carries it on the issue it creates, so both reach GitHub through one construction.
129
+ */
130
+ export function milestoneMembershipField(milestone: number): [string, string] {
131
+ return ["-F", `milestone=${milestoneId(milestone)}`];
132
+ }
133
+
116
134
  /** R3: a qualified GitHub repository, lower-cased the way issue refs are. */
117
135
  export function githubRepo(raw: unknown): string {
118
136
  if (typeof raw !== "string" || raw.length > MILESTONE_LIMITS.issue || !/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9_.-]{1,100}$/.test(raw)) throw new Error("roadmap repo needs owner/name");
@@ -145,7 +145,7 @@ function siblingOrder(states: Readonly<Record<string, PeerState>>, opts: Instanc
145
145
  return (a, b) => Number(states[a] !== "idle") - Number(states[b] !== "idle") || count(opts.wip, a) - count(opts.wip, b) || count(opts.load, a) - count(opts.load, b);
146
146
  }
147
147
  /** A class kind expands once; an explicitly declared instance remains an exact id. */
148
- function expandClassPeers(peers: readonly PeerId[], states: Readonly<Record<string, PeerState>>, opts: InstanceRoutingOptions): PeerId[] {
148
+ export function expandClassPeers(peers: readonly PeerId[], states: Readonly<Record<string, PeerState>>, opts: InstanceRoutingOptions): PeerId[] {
149
149
  if (!hasInstances(opts)) return [...peers];
150
150
  return [...new Set(peers.flatMap(peer => {
151
151
  const kind = (opts.adapterCatalog?.kindOf ?? kindOf)(peer, opts.instances);
@@ -365,6 +365,23 @@ export function implementers(history: readonly { by: PeerId; event: string }[] |
365
365
  return new Set((history ?? []).filter(entry => (entry.event === "accepted" || entry.event === "done") && entry.by !== "user").map(entry => entry.by));
366
366
  }
367
367
 
368
+ /**
369
+ * #1626 C: `ahub doctor`'s routing row. The caller passes the peers it found rostered with implementer work; a peer that no
370
+ * `[classes.*].peers` list names can never be offered a task automatically, so the row says which peers those are and where the
371
+ * class lists live. Pure, and a warning rather than a failure: routing and the file facts come in from the caller.
372
+ */
373
+ export function classListRow(implementers: readonly PeerId[], routing: Routing, file: string, present: boolean): { ok: boolean | undefined; detail: string } {
374
+ const listed = new Set<string>();
375
+ for (const policy of Object.values(routing.classes)) for (const peer of policy?.peers ?? []) listed.add(peer);
376
+ const missing = [...new Set(implementers)].filter(peer => !listed.has(peer)).sort();
377
+ if (!missing.length) return { ok: true, detail: "every rostered implementer is in a class peer list" };
378
+ const classes = Object.keys(routing.classes).sort();
379
+ const lists = classes.length ? classes.map(name => `[classes.${name}].peers`).join(", ") : "[classes.implement].peers";
380
+ const where = present ? file : `${file} (no such file yet, so the shipped default is in use: create it)`;
381
+ const them = missing.length === 1 ? "it" : "them";
382
+ return { ok: undefined, detail: `${missing.join(", ")} can implement but no [classes.*].peers list names ${them}, so the hub never offers ${them} a task automatically; add ${missing.join(", ")} to one of the class peer lists in ${where} (${lists})` };
383
+ }
384
+
368
385
  export interface PlannerWalkInput {
369
386
  /** The settled planner holders, sorted by id. The walk sorts again, so an unsorted input cannot change the result. */
370
387
  planners: readonly PeerId[];
@@ -276,8 +276,9 @@ function captureLayout(root: string): void {
276
276
  if (optionalInfo(join(root, "scripts"))) knownLayout(join(root, "scripts"), [], ["check-docs.mjs"]);
277
277
  const modules = join(root, "node_modules");
278
278
  if (optionalInfo(modules)) {
279
- knownLayout(modules, ["@staix"], []); const scope = join(modules, "@staix"); knownLayout(scope, ["agent-mem"], []);
279
+ knownLayout(modules, ["@staix"], []); const scope = join(modules, "@staix"); knownLayout(scope, ["agent-mem"], [], ["cli-output"]);
280
280
  knownLayout(join(scope, "agent-mem"), ["src", "bin"], ["package.json", "README.md", "LICENSE"]);
281
+ if (optionalInfo(join(scope, "cli-output"))) knownLayout(join(scope, "cli-output"), ["src"], ["package.json", "README.md", "LICENSE"]);
281
282
  }
282
283
  }
283
284
  function verifyQuarantine(root: string, capture: Capture): void {
@@ -73,6 +73,7 @@ export const SETTINGS: readonly SettingDef[] = [
73
73
  { key: "tasks.queue_backpressure.max_oldest_s", group: "Routing", label: "Automatic offers: max oldest queued age in seconds (0 disables)", type: "integer", min: 0, max: QUEUE_BACKPRESSURE_LIMITS.max_oldest_s, store: "config", applies: "live", risk: "raises", path: ["tasks", "queue_backpressure", "max_oldest_s"] },
74
74
  { key: "planner", group: "Roles", label: "Planners (task-local selection)", type: "peers", values: PLANNER_PEERS, store: "config", applies: "live", risk: "raises", path: ["planner"] },
75
75
  ...SETTING_PEERS.map((peer): SettingDef => ({ key: `catalog_roles.${peer}`, group: "Roles", label: `${peer}: catalog guidance`, type: "roles", store: "config", applies: "next use", risk: "safe", path: ["catalog_roles", peer] })),
76
+ { key: "instructed.mode", group: "Permissions", label: "Instructed mode (person terminal only)", type: "enum", values: ["off", "exact", "intent"], store: "config", applies: "live", risk: "raises", floor: "off", path: ["instructed", "mode"] },
76
77
  { key: "scoped_grants.protect_instructions", group: "Permissions", label: "Ask before writing instruction files", type: "boolean", store: "config", applies: "live", risk: "raises", floor: true, path: ["protect_instruction_files"] },
77
78
  ...SETTING_PEERS.map((peer): SettingDef => ({ key: `roster.${peer}`, group: "Roster", label: `${peer}: participates`, type: "boolean", store: "config", applies: "live", risk: "raises", floor: false, path: ["roster", peer] })),
78
79
  { key: "action_policy.enabled", group: "Permissions", label: "Always-ask action policy", type: "boolean", store: "config", applies: "live", risk: "raises", floor: true, path: ["action_policy", "enabled"] },
@@ -106,7 +107,7 @@ export const SETTINGS: readonly SettingDef[] = [
106
107
  * Never editable from settings, whatever the session: these choose what the hub executes or where secrets and task
107
108
  * text go. A key equal to an entry, or below it, is refused by name.
108
109
  */
109
- export const NEVER_EDITABLE = ["invocation", "kimi_cmd", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_provider_profile", "codex_bin", "pi.cmd", "checks", "mlx", "omniroute", "memory.worker_url", "local.read_allow", "local.bash_network", "local.network_allow", "bench.enabled", "terminal", "schedules", "folder_triggers", "corpus", "rooms", "instances", "adapters", "adapter_modules", "local.doc_read", "local.web_fetch"] as const;
110
+ export const NEVER_EDITABLE = ["invocation", "kimi_cmd", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_mcp_allow", "jcode_provider_profile", "codex_bin", "pi.cmd", "checks", "mlx", "omniroute", "memory.worker_url", "local.read_allow", "local.bash_network", "local.network_allow", "bench.enabled", "terminal", "schedules", "folder_triggers", "corpus", "rooms", "instances", "adapters", "adapter_modules", "local.doc_read", "local.web_fetch"] as const;
110
111
 
111
112
  /**
112
113
  * The one key `ahub learn accept` writes (#514b): the active profile's review checklist, which replaces as a unit. It is NOT a row of `SETTINGS` and `settingDef` does NOT resolve it, so