/** * src/agent/goal-bootstrap.ts * * F-207 — Mike autonomous goal / ultragoal bootstrap. * * Exports: * bootstrapGoal({ openKanDir?, features?, specsDir }) → BootstrapVerdict * loadOpenKanSeeds({ openKanDir? }) → OpenKanSeed[] * bootstrapGoalFromFile({ openKanDir?, featureListPath?, specsDir }) → verdict * GoalBootstrapError * * On every SessionStart the `office-manager` agent (Mike) must either * resume an in-flight ultragoal charter or self-seed one for the next * `not_started` feature. The decision is a pure discriminated union so * the host hook and CLI can route on it without re-deriving the answer: * * { action: "resume", id, source } * — `docs/specs/ultragoal-.md` already exists AND the feature * with that id is non-passing (in_progress, blocked, …). * { action: "bootstrap", id, charterPath } * — no resume possible AND at least one `not_started` feature. * Picks the smallest F-ID and writes the aggregate charter. * { action: "idle" } * — zero `not_started` features (all passing or no features). * * Charter format mirrors `config/skills/ultragoal/SKILL.md` aggregate * shape: single ledger, one weighted subgoal. The charter is the * durable artifact the orchestrator passes to `bizar goal start` * downstream; bootstrap must be cheap, idempotent, and read-only * outside `specsDir`. */ /** Bumped when the on-disk charter shape changes in a breaking way. */ export declare const GOAL_BOOTSTRAP_SCHEMA_VERSION: "1.0.0"; /** A minimal feature record the bootstrap reads from a seed (legacy feature_list.json or OpenKan PRDs/plans). */ export interface BootstrapFeature { readonly id: string; readonly title?: string; readonly behavior?: string; readonly description?: string; readonly state?: string; readonly category?: string; readonly layer?: string; readonly owner?: string; } /** * A seed derived from a single OpenKan PRD goal plus its plan * acceptance. The bootstrap converts these into `BootstrapFeature` * records so the existing decision logic (resume / bootstrap / idle) * works unchanged against either the legacy `feature_list.json` or * the live OpenKan workspace. */ export interface OpenKanSeed { /** Synthetic id used to key the charter (e.g. `prd-zxfjEL_3/g2`). */ readonly id: string; /** Goal text from the PRD's `goals[]` entry. */ readonly title: string; /** PRD goal id (e.g. `g2`). */ readonly goalId: string; /** PRD id this goal belongs to. */ readonly prdId: string; /** PRD goal status (`open` maps to `not_started` for the bootstrap). */ readonly status: string; /** Plan acceptance items joined into a single behavior string. */ readonly behavior: string; /** Plan ids that reference this PRD, used as `layer` hint. */ readonly planIds: ReadonlyArray; /** PRD-level owner if set. */ readonly owner?: string; } export interface BootstrapGoalInput { /** * Optional parsed legacy `feature_list.json` (object form). Bootstrap * is read-only here. If omitted, the bootstrap reads from the OpenKan * workspace at `openKanDir`. */ readonly features?: { features?: ReadonlyArray; } & Record; /** * Path to the OpenKan workspace. Defaults to `.ok` at the process * `cwd`. Ignored when `features` is provided. */ readonly openKanDir?: string; /** Directory under which `ultragoal-.md` will be created / detected. */ readonly specsDir: string; } export type BootstrapVerdict = { readonly action: "resume"; readonly id: string; readonly source: "spec"; } | { readonly action: "bootstrap"; readonly id: string; readonly charterPath: string; } | { readonly action: "idle"; }; export declare class GoalBootstrapError extends Error { readonly code: string; constructor(code: string, message: string); } /** * Render the aggregate-mode charter that `bizar goal start --mode * aggregate` consumes. The shape mirrors * `config/skills/ultragoal/SKILL.md` (aggregate: single ledger, * weighted subtasks; one weighted subgoal matching the chosen * feature). The skill is the source of truth for the lifecycle and * four-lane fence; bootstrap only emits the durable opening * artifact. */ export declare function renderAggregateCharter(input: { id: string; title: string; behavior: string; owner?: string; layer?: string; category?: string; schemaVersion?: string; }): string; /** * Decide whether to resume, bootstrap, or stay idle. The function is * pure with respect to the input — it only writes when bootstrap is * the chosen action. Throws `GoalBootstrapError` on malformed * features JSON or a charter-write failure so callers can surface a * clear error instead of silently skipping the bootstrap. */ export declare function bootstrapGoal(input: BootstrapGoalInput): BootstrapVerdict; /** * Read every PRD under `.ok/prds/` and every plan under `.ok/plans/`, * then synthesize one `OpenKanSeed` per PRD goal. Plan acceptance * items are joined into the seed's `behavior` field so the existing * `bootstrapGoal` decision logic can route on them without parsing * OpenKan schemas itself. Returns an empty array when the workspace * is missing or unreadable so callers degrade to `idle`. */ export declare function loadOpenKanSeeds(input?: { openKanDir?: string; }): OpenKanSeed[]; /** * Convenience helper for the SessionStart hook. Loads planning state * from `.ok/` (preferred) or the legacy `feature_list.json` and * runs `bootstrapGoal`. Returns the verdict on success; returns * `{ action: "idle" }` with `warning` set when the source is missing * or malformed so the hook can degrade gracefully without aborting * SessionStart. */ export declare function bootstrapGoalFromFile(input: { /** @deprecated Use `openKanDir` instead. Tolerated with a warning. */ featureListPath?: string; /** Path to the OpenKan workspace. Defaults to `.ok` at the process `cwd`. */ openKanDir?: string; specsDir: string; }): { verdict: BootstrapVerdict; warning?: string; }; //# sourceMappingURL=goal-bootstrap.d.ts.map