import { ADAPTERS, deriveAdapterLists, type AdapterDefinition } from "../adapters/registry.ts"; import { VERSION } from "../version.ts"; import { ROADMAP_FORMS } from "./roadmap.ts"; import { paint, wrap, Report as LayoutReport, type Span } from "./console-state.ts"; /** One usage form of `ahub help`: the usage starts with `ahub `, alternatives joined by `|`. */ export interface HelpEntry { section: string; usage: string; description: string; /** #1504: the overview row of a native agent, from the third element of its definition's `cli.usage` entry; never a table in this file that names a peer. */ summary?: string } /** #1405: one source for the probe usage, read by `ahub help` and by the refusal of a malformed probe command. */ export const GUIDANCE_PROBE_USAGE = { register: "register --file JSON [--json]", start: "start --id HASH --revision N [--variant G1-HASH] [--json]", show: "show --id HASH [--json]", receipts: "receipts --id HASH [--json]", cancel: "cancel --id HASH --revision N [--json]", } as const; /** What to print when `ahub guidance probe ...` did not parse: the typed subcommand's own usage, or all five for an unknown one. */ export function guidanceProbeUsage(args: readonly string[]): string { const typed = args[1], known = typed !== undefined && Object.hasOwn(GUIDANCE_PROBE_USAGE, typed); const forms = known ? [GUIDANCE_PROBE_USAGE[typed as keyof typeof GUIDANCE_PROBE_USAGE]] : Object.values(GUIDANCE_PROBE_USAGE); const id = known && typed === "register" ? "" : " HASH is the 64-character probe id that ahub guidance probe register printed; no command lists probes."; return `${known ? `ahub guidance probe ${typed} has a missing or malformed argument` : "unknown guidance probe command"}; usage: ${forms.map(form => `ahub guidance probe ${form}`).join(" | ")}.${id}`; } const SECTIONS: [string, [usage: string, description: string][]][] = [ ["Projects", [ ["ahub specs list [--json] | check [--require-fresh] [--base ] [--json] | covers | stamp [--yes]", "read design specs, validate their graph and source freshness, or find covering specs; runs without a daemon; check exits 1 on errors and, with --require-fresh, stale documents; stamp is person only (a terminal, never an agent): it shows old -> new, asks (--yes skips the question but still needs a terminal), and then changes only the verified-against line (or the stamps-file entry) to the full HEAD SHA, refused while the covered paths have uncommitted changes"], ["ahub worktrees [--json] | tidy [--json] | tidy --confirm [--json]", "list live and settled worktrees; preview what is safe to remove; `--confirm` (the person only) runs git worktree remove and git branch -d, never forced"], ["ahub --project ", "select a repository or worktree explicitly"], ["ahub projects [--json] [--full] [--color=auto|always|never]", "list registered projects and live status"], ["ahub projects remove ", "forget a stopped registration (keeps project files)"], ["ahub setup [--yes] [--agents ] [--research|--no-research] [--undo]", "install or update the channel plugin and project-neutral hook in Claude configuration homes in use, preserving unrelated profile settings, ask once which agents ahub up starts (--agents answers it, --yes keeps the current choice or claude,codex, no terminal keeps the default), save the research default only with explicit --research/--no-research (ordinary setup leaves it unchanged), install the hub's own skills in every other agent host installed here (Codex, Kimi, Qwen, Jcode, Pi, agy; each tree carries a .ahub-skill.json marker and a tree the hub did not write unmodified is reported and left alone), register the acon console plugin (console/plugins/ahub.json in the hub home, read at acon's next start), then run doctor; --undo removes only the hub's own unmodified skill trees and asks once unless --yes is given"], ["ahub init [--profile dev|research|writing|general|] [--agents ] [--sdlc off|advise|enforce] [--required-checks ] [--coordination advisory|turn-free] [--memory|--no-memory] [--research|--no-research] [--snapshots|--no-snapshots] [--pi|--no-pi] [--specs|--no-specs] [--spec-review off|report|require] [--conductor |none] [--planner ] [--reviewer |person] [--track-config|--no-track-config] [--no-jcode-home] [--autonomy inherit|off] [--shadow] [--release-guard] [--yes] [--dry-run --json]", "preview or write .agenthub/config.json and the AGENTS.md marker block (drops a legacy CLAUDE.md block); a pack is a shipped one (writing-pack, analysis, ops) or a project file .agenthub/roles/.pack.json; a new project inherits a trusted machine autonomy default and the agent set chosen at ahub setup (start.agents) into config.local.json. Settings flags (#1065): --agents sets start.agents (none starts no agent), --research/--no-research sets research.enabled (new project default: the trusted setup choice, else off) and --autonomy off skips the autonomy inheritance, all in config.local.json; --sdlc sets sdlc.toml mode (off writes no file on a new project); advise/enforce discovers required checks from CI or literal workflow job names; --required-checks overrides discovery, and enforce without names refuses before writes; --coordination, --memory, --snapshots and --pi set their keys in config.json. On an existing project only a flag you give changes anything, and --dry-run shows each change as old -> new (--dry-run --json adds a settings array); a value equal to the current one is a no-op, an invalid value is refused with the allowed ones and nothing is written. --specs/--no-specs and --spec-review set the design-specs keys (and the AGENTS.md specs block). --track-config keeps .agenthub/config.json, routing.toml and sdlc.toml visible to git (a rule that ignores one is named and nothing is written; a routing.toml that names a machine endpoint stays ignored) and lists them to commit; --no-track-config ignores them; either sets the AGENTS.md role sentence, and neither keeps what git and the block say today. A person at a terminal who runs ahub init on a new project with no flag that sets anything and no --yes is asked each setting in turn with its default in brackets (Enter keeps it, a wrong answer asks again, and a third wrong answer ends init with nothing written), sees the plan and answers y/N; N, Ctrl-C and Ctrl-D write nothing. A peer, a live test, a pipe and --dry-run are never asked, and --yes takes the defaults. Success prints next steps to commit shared init changes, start with ahub up or ahub claude and, for advise/enforce, accept specs/departures and use guarded merge. --conductor, --planner and --reviewer (#1408) choose who conducts, plans and reviews, each on its own: the shared config.json roles are written as an explicit list for every peer whose roles change (the one that loses a role too), implementer and verifier are untouched, a peer that cannot hold the role (a headless conductor, a kind that cannot plan) is refused before any write with the reason and the eligible peers, --conductor none leaves the person conducting from ahub console and --reviewer person sends reviews to the person; Executables, secrets, models and permissions stay file edits"], ["ahub --live-test [--project ] [args...]", "user-authorized operational console delegation; ordinary calls retain peer identity; person-authored content refuses"], ["ahub help [command [--ascii]]", "this help, or one command's entries; also --help and -h"], ["ahub version | --version", "print the installed version"], ["ahub instructed run [ ]", "with a confirmed managed Claude receipt, run the person's exact command with no arguments or a supported intent command with arguments; unsafe or unclassified forms stay closed"], ["ahub instruction-hook", "internal Claude prompt and Stop hook; pending evidence grants no authority"], ["ahub completion zsh|bash|fish", "print a shell completion script; its candidates come from these help entries"], ]], ["Daemon and runtime", [ ["ahub up [--unattended] [--no-console] [--no-agents]", "start the daemon, then ask it to start this project's default agents (start.agents, claude and codex unless chosen at setup; one line each, a refusal names the manual command; --no-agents skips them), then enter console in an interactive terminal"], ["ahub console [--panels] [--color=auto|always|never]", "enter the human console; P cycles built-in pet characters/off; exiting leaves the daemon running"], ["ahub console --no-pet", "turn off attention for this session; combines with --panels and --color"], ["ahub pet [--short]", "read attention without connecting; --short prints ahub!N only when action is needed"], ["ahub pet --window [--close]", "retired floating-window options: run acon ui and open Mini"], ["ahub pet --palette ", "retired floating-window option: run acon ui and open Mini"], ["ahub sdlc status [task] | explain [--json] [--color=auto|always|never] | export | record ", "read head-bound lifecycle gates and the next actor/action; status and explain are open to any agent as a public view (private tasks stay stubs), export and record are person only; export stays JSON"], ["ahub sdlc queue | release [live-issue...] [--json] [--color=auto|always|never]", "read-only merge and release evidence; open to any agent as public readback of the checkout's repositories, never an authorization"], ["ahub sdlc survey start [--focus bugs|tests|debt|deps|dx|docs] [--json] [--color=auto|always|never]", "person or current conductor: file one read-only planner survey at a pinned source ref; only explicitly vetted findings produce backlog cards"], ["ahub sdlc survey show [--json] [--color=auto|always|never]", "read findings and their vet decisions; unchanged or unknown prior rejections remain rejected before, and reconsideration needs an explicit vetted reason"], ["ahub sdlc audit start [--profile quick|standard] [--since ] [--json] [--color=auto|always|never]", "file one read-only security audit task and seed its coverage ledger from [security] in sdlc.toml (person or current conductor); quick and scoped runs read as partial"], ["ahub sdlc audit show [] [--json] [--color=auto|always|never]", "the newest (or named) audit: source, coverage counts by unit state, each unit and finding; open important finding details are shown to the person only"], ["ahub sdlc adopt-merge --pr ", "record an already merged PR at the task's recorded head with green required checks and no open Important finding; approve and release dependents (person or current conductor)"], ["ahub sdlc merge [--dry-run] [--json] [--color=auto|always|never]", "guarded squash merge of an approved task at its approved head after every gate is re-read; follows sdlc.toml auto_merge (off, dry-run, on); --dry-run only reports (person or conductor)"], ["ahub sdlc authorize-release [--json] [--color=auto|always|never]", "approve this daemon checkout commit, configured version source and docs policy (person or unique configured conductor on the person's explicit release instruction naming the release in its own session; hub/task/review/file/peer relays never qualify; restart revokes)"], ["ahub sdlc configure [--mode off|advise] [--required-checks names] [--json] [--color=auto|always|never]", "save only lifecycle mode/check names through loader validation and backup, pending restart (person or current unique conductor on the person's explicit instruction in its own session; enforce and other fields remain person-only; no release consent)"], ["ahub sdlc release-guard -- ", "read-only authorization preflight; init --release-guard installs the tag pre-push hook"], ["ahub sdlc release-guard-hook ", "internal pre-push readback; validates version tags and forwards exact stdin on success"], ["ahub sdlc accept --issue [--repo owner/repo]", "accept the task's spec issue at its current body; build entry needs it in enforce (person only)"], ["ahub sdlc accept-departure ", "accept current plan departures on that exact PR head (person only)"], ["ahub sdlc plan-review [--review full|delta|none --reviewers N] [--ci full|focused|reuse]", "record planner review, scope and host-read issue metadata"], ["ahub sdlc train report|configure|cut [revision] [json]", "plan a release and freeze its approved scope after resource/quota admission"], ["ahub sdlc release-assign ", "assign approved/in-flight work without changing execution"], ["ahub sdlc costs [owner/repo] [--json] [--color=auto|always|never]", "read bounded planner cost metrics for linked merged PRs"], ["ahub sdlc metrics [--since ] [--json] [--color=auto|always|never]", "read SDLC metrics and control band tiers from board history (planner or person; read-only)"], ["ahub backlog groom | return [--reserved | --unreserve] [--json] [--color=auto|always|never]", "read grooming findings or return accepted untouched work to backlog (planner/person); --reserved names the peer the card is reserved for as it goes back, --unreserve clears the reservation (a person's reservation needs the person)"], ["ahub status [--json] [--full] [--verbose] [--ascii] [--color=auto|always|never]", "is the hub OK, and what to do next: an Attention list (each item with its next command), then the hub, peers and tasks; --verbose or --full prints every detail (model backends, specs, queue pressure, schedules, per-peer notes)"], ["ahub status --all [--json] [--color=auto|always|never]", "show every registered project"], ["ahub logs [-f]", "person: last 100 hub.log lines (-f starts at 10); conductor: bounded public lines and follow while authority remains"], ["ahub doctor [--json] [--full] [--ascii] [--color=auto|always|never]", "check the tools, daemon, plugin, gateway, models, memory library and memory capture setup (read from `amem setup --json`, a preview) this project uses, the runtime capture pruning ledger, whether the shared config.json tracking matches the AGENTS.md roles sentence, and who holds conductor, planner and reviewer as the loader settled them (a warning, never a failure), the hub skills of the Claude plugin and every other agent host (installed, stale, missing, modified, foreign or linked, with a repair command), and any rostered implementer that no routing class lists (a warning); warn when the CLI or plugin is older than its running daemon"], ["ahub doctor --stale-anchors [--json]", "read-only bounded report of public memory symbol anchors at current HEAD; private or unavailable evidence stays unknown"], ["ahub doctor --orphans [--kill] [--json] [--color=auto|always|never]", "person: inspect missing-root registrations; conductor --kill: selected project only; signed hub ownership is required before any stop"], ["ahub agents [--json]", "show each gated agent CLI's installed version and verdict (verified, in-line, trusted, refused or unknown)"], ["ahub agents trust [--revoke]", "accept an untested agent CLI version on this machine (person only; runtime proofs still run)"], ["ahub kill", "stop this project's hub"], ["ahub down", "stop this project's hub, the counterpart of ahub up (same as ahub kill)"], ["ahub reset [--all] [--yes]", "list, then with --yes stop the hub and discard every queued and needs_review delivery, clear holds and pauses and drop session pointers; --all moves the state directory to .agenthub/archive instead"], ["ahub restart [--dry-run] [--yes] [--json] [--verbose] [--color=auto|always|never]", "recover this project's runtime; a configured conductor's --yes requires a same-project, source-issued continuation proof, otherwise run it as the person"], ["ahub upgrade [--project | --all-stopped] [--to ] [--dry-run] [--yes] [--json] [--verbose] [--color=auto|always|never]", "review and upgrade this selected project (default: current directory; --project selects another); a project whose hub is stopped has only its runtime selection retargeted: no hub, terminal, peer or recovery operation is started; --all-stopped does that for every registered stopped project, each independently (rows: retarget, already at , skipped: running with its per-project command, refused: with its next step), exits nonzero when a planned retarget fails, and conflicts with --project; global CLI/plugin updates are separate; --to defaults to latest for interactive review or dry-run, while --yes requires --to , and for a running hub waits through a pipe until its recovery operation ends and exits nonzero unless it completed; conductor apply needs the same project's supported proof (a stopped-project retarget is person-only), and a newer-coordinator handoff is person-only"], ["ahub recovery [status|resume|abort] [] [--json] [--color=auto|always|never]", "inspect a preflight; without an id, resume/abort select this project's hold or a retained legacy machine hold; a bare terminal opens the person's screen; only its initiating conductor may continue its own supported restart/upgrade with fresh proof"], ["ahub recovery reattach codex|claude|pi", "person only: repair that blocked peer with its recorded session; leaves the rest for recovery resume"], ["ahub recovery dispose [] --fresh-session codex|claude --reason ", "end a partial operation by starting that peer as a new session, recording the lost conversation"], ["ahub recovery dispose [] --stop-and-archive --reason ", "end a partial operation: stop its own targets, archive its snapshot and release the lock; the upgrade is abandoned, not completed"], ["ahub daemon [--unattended]", "internal: the detached hub process that ahub up or the dashboard manager starts"], ["ahub recovery-run ", "internal: a detached runner; conductor use is limited to the captured operation continuation, not a general command"], ]], ["Agents", [ ["ahub [--mode headless] [--as ] [--session-id ] [--print-command | --dry-run]", "start a trusted config.local.json ACP kind (default off roster); native argv is withheld in previews; an external module instance needs the person's start"], ["ahub role list [--group ] | show ", "read bounded catalog guidance with layer and content hash"], ["ahub role assign | clear []", "person only: add or clear catalog guidance, applied at the next peer start"], ["ahub stop ", "person or configured conductor: stop a hub-owned headless peer; end TUI agents in their terminals"], ["ahub peer takeover [standby-id] [--json] [--color=auto|always|never]", "person only: detach the attached session without stopping its process and request that the selected standby session attach; ahub status shows standby identities"], ["ahub models status [--json] [--color=auto|always|never]", "inspect local model state as labelled fields"], ["ahub models setup|start [--json] [--color=auto|always|never] | stop", "prepare or inspect local Ollama MLX; setup and start print the model state like status (legacy stop is explicit)"], ]], ["Messages and approvals", [ ["ahub say [@peer ...] ", "send as the console user (no @peer = broadcast); delivered at once, start the text with [STATUS] to let it batch or [FYI] for the record only"], ["ahub watch kimi|qwen [--no-thoughts] [--color=auto|always|never]", "person-only transient activity from a headless ACP peer; q quits, approvals stay in console"], ["ahub tail", "live stream of messages, states and permission requests"], ["ahub permission [ [ask|ask-when-needed|never-ask]] [--yes]", "human only: inspect or set a running peer mode; never-ask requires --yes; config never-ask waits for console y"], ["ahub permit