/**
 * cli/help.mjs — apt-tools --help text (C29).
 */
import { getVersion } from './util/io.mjs';
export function printHelp() {
    const help = `${getVersion()}

Usage: apt-tools <command> [args]

Commands:
  init <project-dir>                    Initialize framework in a project
  uninstall <project-dir> [--purge] [--dry-run] [--yes] [--runtime <id>]
                                        Reverse install — removes runtime files tracked by apt-file-manifest.json, strips the APT section from CLAUDE.md/AGENTS.md. Preserves .aperant/ state unless --purge.
  state <project-dir>                   Read framework state
  config <project-dir>                  Read framework config
  config upgrade-gitignore <dir> [--dry-run]  Migrate .aperant/.gitignore to R6 layout (non-destructive)
  config upgrade-layout <dir> [--dry-run]     Migrate .aperant/ folder layout to C36 shape (moves + rewrites gitignore)
  audit privacy <dir> [--scrub]         C35: diff tracked .aperant/* vs share policy (exit 2 on violations; --scrub prints filter-repo commands + checklist, never executes)
  audit visibility-signals <dir>         C35: structured JSON signals for /apt:setup's visibility mini-flow
  state-update <dir> --field --value    Update a state field
  detect-project <project-dir>          Scan project for init classification
  init-state <dir> --config <json>      Write config + state after init flow
  commit <message> --files <f1> <f2>    Commit files with message
  risk-check <dir> --paths <p1> [--operation <type>]  Classify file paths by risk level

  task create <dir> --description <text> [--scope <s>] [--milestone <id>] [--phase <id>] [--roadmap-ref-url <url>] [--depends-on <refs>] [--track <T>] [--autonomy <N>]  Create isolated task
  task list <dir> [--scope <s>] [--blocked-by <id>]  List active tasks (optionally filtered)
  task get <dir> --id <task-id>         Get task details and artifacts
  task update <dir> --id <id> [--lifecycle-phase <p>] [--pr-url <url>] [--subtasks-total <N>] [--depends-on <refs>]  Update non-linkage task state; --pr-url may arm ci-watch per ci_watch.after_ship
  task move <dir> --id <id> [--to-scope <s>] [--to-milestone <id>] [--to-phase <id>] [--to-roadmap-ref-url <url>] [--reason <text>] [--force]  Reassign scope/milestone/phase with history
  task close <dir> --id <task-id> [--verdict <v>]  Close task and move to completed
  task close-merged <dir> [--task <id>] [--narrate-only] [--dry-run]   Sweep shipped-pending-merge tasks for confirmed merges (--narrate-only returns pending_narration[] entries read-only without closing).
  task narration-drain <dir> --task <task-id>     Remove a row from state.pending_narration[] under withFileLock (called by /apt:close-task --narrate-only after a successful narrator spawn)
  task complete-subtask <dir> --task-id <id> --subtask-id <sid|a+b+c> [--commit <sha>] [--notes <text>]  Atomic plan ↔ build-progress sync
  features-audit <dir> [--task-id <id>] [--no-worktree-redirect] [--diff-files <csv>|--since <ref>] [--apply-stubs] [--format json|md]  Audit features registry for unregistered feature-qualifying files (BUG-025b: --task-id redirects writes to active task's worktree)
  docs-audit <dir> [--diff-files <csv>|--since <ref>|--dry-run] [--policy <path>] [--format json|md]  Audit documented surfaces for docs-drift

  lock claim <dir> --subtask <id>       Claim exclusive lock on a subtask
  lock release <dir> --subtask <id>     Release a lock (must be owner)
  lock check <dir> --subtask <id>       Check lock status and staleness
  lock heartbeat <dir> --subtask <id>   Update lock heartbeat timestamp
  lock cleanup <dir>                    Remove all stale locks

  tokens record <dir> --task-id <id> [--transcript <path> | --input N --output N] [--session-id <id>] [--agent <a>] [--model <id>] [--provider <id>]
                                          C11: append per-session token actuals to .aperant/tasks/{id}/tokens.json + mirror summary onto state.active_tasks[id].tokens
  tokens tally <dir> --task-id <id>       C11: emit TaskCostSummary for the task (reads tokens.json)
  tokens compare <dir> --task-id <id> [--baseline <path>]  C11: emit { aperant, baseline, ratio } (baseline JSON optional; C23 hook)
  tokens list <dir> [--scope <s>] [--since YYYY-MM-DD]  C11: scan all tasks' tokens.json, sorted desc by last_updated

  event append <dir> --type <t> --subtask <id> [--data <json>]  Append event to log
  event list <dir> [--type <t>] [--subtask <id>]                List events with optional filters
  event rebuild-state <dir>             Rebuild state.json from event log

  wave analyze <dir> [--plan <path>] [--wave <N>]              Analyze subtask dependencies into parallel waves
  coverage-check validate <dir> [--plan <path>] [--spec <path>]  Validate requirement-to-verification coverage

  route <dir> --input "text" [--flags]    Deterministic request classifier (returns JSON routing decision)
  statusline <dir> [--json|--ansi|--plain]  C22: single-line status summary (NO_COLOR/FORCE_COLOR/isTTY gated). --json emits envelope.

  gate list [--skill <skill>]                                              C2: list registered hard gates (optionally filtered by skill)
  gate check <dir> --task-id <id> --skill <skill> [--force --reason <r>]   C2: run the gate set for <skill>; exits 1 on blocking failures unless --force (audit-logged)

  design-scan <project-dir> [--out <path>] [--root <subdir>]   C27: scan UI source for design tokens (colors, spacing, typography, radii, shadows) → .aperant/design/tokens.json
  taste-infer <target> [--out <path>] [--add-to-library <slug>] [--timeout <ms>] [--no-synthesize] [--root <subdir>] [--force] [--no-screenshots]   C43: reverse-engineer design language from a URL or repo into a fresh DESIGN.md (static extraction; LLM only for semantic clustering)

  design-template list [--library-dir <path>]                  C42: list every shipped DESIGN.md template (slug, name, description, origin, source)
  design-template show <slug> [--library-dir <path>]           C42: print a single entry's DESIGN.md + parsed frontmatter + provenance
  design-template add <slug> [--project-dir <path>] [--force] [--library-dir <path>]   C42: copy a library entry into <project-dir>/DESIGN.md (refuses overwrite without --force)
  design-template submit <path> [--as <slug>] [--library-dir <path>] [--force]          C42: validate + copy a candidate DESIGN.md into the library with provenance.origin: community

  author-skill <name> [--description <text>] [--dry-run] [--framework-root <path>]   C4: scaffold a new SKILL.md + structural test under packages/framework/ (test-first skill authoring)

  standards <project-dir> [--profile <name>] [--json] [--no-color]   C20: zero-orchestration read-only bundle (constitution + profile + feature registry + design tokens + taste)

  worktree create <dir> --subtask <id> --branch <name>  Create isolated worktree for a subtask
  worktree remove <dir> --subtask <id> [--force]        Remove a subtask worktree
  worktree list <dir>                                   List active worktrees under .aperant/worktrees/

  detect-worktree <project-dir>          Check if running inside a git worktree
  template <name>                        Output a template (agents-greenfield, agents-brownfield, config, state, gitignore)

  bootstrap detect <project-dir> [--force-greenfield|--force-brownfield]   C47: recon (D-02 allowlist) + greenfield/brownfield compound heuristic (D-03)
  bootstrap scaffold <project-dir> [--force]                                C47: write a PROJECT.md (7-section D-06 template) — refuses to overwrite without --force
  bootstrap derive-sidecar <project-dir>                                    C47: derive .aperant/product-context.json from PROJECT.md (D-01; one-way)
  bootstrap run <project-dir> [--force-greenfield|--force-brownfield] [--skip-sidecar] [--force]   C47: one-shot detect → scaffold → sidecar (used by apt-tools init auto-chain, D-04)

  personas scan <project-dir>                                               C48: deterministic role-signal scan (identifiers, route prefixes, RBAC, validator enums)
  personas rubric <project-dir>                                             C48: emit the tier-rubric prompt (D-05) the SKILL.md body hands to the host LLM
  personas read <project-dir>                                               C48: emit current .aperant/personas.json envelope + runs count
  personas write <project-dir> --mode <fresh|extend|from-app> [--payload <path>] [--force]   C48: persist personas (D-06/D-10; --force overrides cloud-canonical guard)
  personas record-run <project-dir> --status <pending|running|completed|failed> [--candidates-found N] [--phase <s>] [--error <msg>]   C48: append entry to .aperant/personas-runs.json (D-09)

  create-docs plan <project-dir> [--output-dir <path>]                       C49: compose features + personas + product-context → D-02 StructurePlan (no writes)
  create-docs render-nav <project-dir> [--output-dir <path>] [--print]       C49: regenerate docs/product/README.md navigation index (D-07); --print returns markdown instead of writing
  create-docs read <project-dir> [--output-dir <path>]                       C49: list existing docs/product/*.md files (used by D-05 diff-and-confirm)
  create-docs run <project-dir> [--output-dir <path>] [--force]              C49: one-shot plan + existing-output read + next-steps envelope the apt-docs-author agent consumes

  terminal spawn --worktree <p> --task <id> [--instructions <s>] [--cli claude-code] [--yolo]   terminal-spawn: open a sibling Aperant terminal via Electron-main IPC
  terminal list                          List sessions known to AperantIpcServer
  terminal status --session <id>          Get one session's metadata
  terminal health                         Smoke-test the IPC socket (returns version + pid)
  check [<project-dir>] [--skills-root <path>]  router-0.3.0: validate every canonical apt-<slug>/SKILL.md against SkillFrontmatterSchema + cross-reference gate IDs
  check-version <project-dir>            Compare installed vs framework skill versions
  toolchain-detect <project-dir>          Detect project toolchain (linter, formatter, typecheck, test, build)
  health-check <project-dir>             Detect dirty state, stale locks, orphaned events, version drift
  host-detect                            Detect which AI CLI is running and its capability matrix
  reconcile <project-dir>               Resolve orchestration preferences against host capabilities

  migrate-pr-reviews <project-dir>       Migrate legacy .aperant/reviews/ → .aperant/pr-reviews/pr-{N}/rounds/{R}/ (idempotent)

  validate-evidence <findings-dir> --worktree <path> [--allow-approx-evidence] [--approx-floor <n>] [--llm-validator-confirmed]   Enforce the Evidence Rule (literal substring + multi-file check); mutates findings markdown in place. BUG-014: --allow-approx-evidence opts into Jaccard + line-anchor fallback (downgrade to dismissed_evidence_approx_confirmed unless --llm-validator-confirmed promotes to confirmed_valid_approx).

  vitest doctor <project-dir> [--format json|md]   BUG-026: walk vitest.config.{ts,js,mjs} files, report NODE_ENV/jsxAutomaticShim matrix, warn when JSX-rendering tests lack jsxAutomaticShim coverage (exits 1 on warnings)

  wfrun validate <workflow.yaml>                         C17: parse + schema-check a declarative YAML workflow (exits 0 on success)
  wfrun plan <workflow.yaml> [--input k=v …]             C17: resolve DAG waves + inputs, emit run-plan JSON (no side effects)
  wfrun run <workflow.yaml> [--input k=v …] [--project-dir <path>]   C17: plan + execute tool-only workflows inline, write .aperant/wfrun/{run-id}/{manifest,plan,result}.json

  pr-review init-pr <dir> --pr <N> [--head-ref <ref>] [--base-ref <ref>]  Seed .aperant/pr-reviews/pr-{N}/pr-state.json
  pr-review acquire-lock <dir> --pr <N> --owner <id> [--ttl-ms <ms>]      Take PR-level lock (exit 2 if busy)
  pr-review release-lock <dir> --pr <N> --owner <id>                      Clear lock (owner must match)
  pr-review start-round <dir> --pr <N> --head-sha <sha>                    Increment rounds_completed + pin head SHA (exit 2 if exhausted)
  pr-review close-round <dir> --pr <N> --round <R>                         Snapshot state into rounds/{R}/pr-state-snapshot.json + clear lock
  pr-review get-state <dir> --pr <N>                                       Emit current live pr-state.json
  pr-review detect-authorship <dir> --pr <N> [--gh-json <path>] [--viewer-login <login>] [--base-repo-owner <login>]  Detect authorship_mode via gh CLI
  pr-review record-comment <dir> --pr <N> --round <R> --url <url> --body-hash <sha256> [--review-id <id>] [--posted-at <iso>]  Append entry to comment_timeline (Phase 6b)
  pr-review audit-fixer <dir> --review-dir <path> --iteration <N> --fixer <name> --worktree <path> --status-line <str>  Audit fixer output against git state; exits 0 with JSON envelope (verdict: verified|hallucinated|skipped)

  ci-watch start|stop|status|tick <dir> [--pr <N>] [...]   /apt:watch-ci primitives — see SKILL.md for full flag matrix
  ci-watch sweep <dir> --orphaned [--dry-run]              BUG-027: enumerate ci-watches state files, query gh per PR, remove terminal-state (MERGED|CLOSED) entries (manual GC; rate-limited)

Flags:
  --version                             Print version and exit
  --help                                Print usage and exit

All output is JSON.`;
    process.stdout.write(`${help}\n`);
}
//# sourceMappingURL=help.mjs.map