/** * `harn init`: idempotently wire harnery into a project. * * Two things a fresh consumer otherwise has to know to do by hand (both silent * if skipped): * 1. Create the `.harnery/` coord root; without it `findCoordRoot` returns * null and every hook no-ops forever. * 2. Register the agent-hook entries in the adapter settings file. * * Wires whichever adapter `--adapter` names (Claude Code `.claude/settings.json`, * Cursor `.cursor/hooks.json`, or Codex `.codex/hooks.json`): the per-adapter * file path, event list, and hook-entry shape all come from ADAPTER_SPECS. * * `harn init` does both, non-destructively: it merges hook entries into an * existing settings file (preserving any other hooks) and skips entries that are * already wired, so it's safe to re-run. `--dry-run` previews without writing. */ import type { Command } from "commander"; import type { EmitContext } from "../commander.js"; import type { EventV3ControlState } from "../core/events/v3/control.js"; import { type AdapterId, type AdapterSpec } from "../core/hooks/adapter/events.js"; import { type SettingsFile } from "../core/hooks/adapter/wiring.js"; export declare function registerInitCommand(program: Command, emit: EmitContext, binName?: string): void; /** * Runtime contracts bound into an immutable V3 epoch. `init` replaces the * epoch only when the schema or adapter capability contract changed. A new * Harnery build alone keeps the current epoch and its live session generations. */ export declare function eventLedgerV3RuntimeIssues(control: EventV3ControlState): string[]; export declare function codexHookReviewAction(adapter: AdapterId): string | null; /** * Merge agent-hook entries into a adapter settings object in place, idempotently. * Preserves every existing hook; rewrites events already wired to * `agent-hook ` when their command string is stale (e.g. an older * harnery wired a bare relative path). Honors the adapter's entry shape * (Claude/Codex nest under an inner `hooks` array; Cursor uses a flat * `{ command }`) and ensures the root `version` key when the adapter requires * one. Pure (no fs/git) so it's unit-testable. * * Token-aware matching keeps `stop` from matching `stop-failure`. */ export declare function wireHooks(settings: SettingsFile, spec: AdapterSpec, agentHookPath: string, adapter: AdapterId): { wired: number; already: number; removed: number; upgraded: number; }; /** * Inverse of {@link wireHooks}: strip every harnery-owned hook entry from a * settings object in place, idempotently. A hook is "harnery's" when its command * contains `agent-hook ` (the trailing space matches `agent-hook `), * so any non-harnery hook the consumer added is preserved. Emptied * `hooks[settingsKey]` arrays are dropped; an emptied `hooks` object is dropped * entirely. Adapter-agnostic (scans every key) so it removes entries left by any * adapter. Pure (no fs) so it's unit-testable. Returns the count removed and the * count of non-harnery hooks left behind. */ export declare function unwireHooks(settings: SettingsFile): { removed: number; remaining: number; }; /** * Idempotently record `binName` in `.harnery/config.jsonc`, preserving any * existing JSONC comments and the `files` section. Returns an action line, or * null when nothing changed. Three cases: * - file absent → write a minimal commented stub; * - `binName` already present + matching → no-op; * - present-but-different value → comment-safe in-place value swap; * - key absent → splice it in as the first key (comment-safe). */ export declare function stampBinName(configPath: string, binName: string, dryRun: boolean): string | null; /** * Idempotently pin `workflow.subscriptionOnly: true` in `.harnery/config.jsonc` * (see `workflowSubscriptionOnly()` in core/config.ts and the `workflow run` * billing safeguards). Same comment-preserving discipline as `stampBinName`. * A `workflow` key of ANY shape (including `subscriptionOnly: false`) is a * deliberate project choice and is left alone. */ export declare function stampWorkflowDefaults(configPath: string, dryRun: boolean): string | null; //# sourceMappingURL=init.d.ts.map