packages feed

seihou-cli-0.17.0.0: help/blueprints.md

BLUEPRINTS

A blueprint is an agent-driven runnable artifact. Modules and recipes use
Seihou's deterministic execution engine to write files from declared steps.
Blueprints instead package a prompt, optional baseline modules, variables,
and reference files for `seihou agent run`. They can also package ordered
library-upgrade prompts for `seihou agent migrate`.

Use a blueprint when the desired output needs judgement, iteration, or
project-specific design decisions that do not fit a fixed module template.
Use a module or recipe when the same inputs should always produce the same
file plan.

BLUEPRINT STRUCTURE

  A blueprint directory looks like:

    my-blueprint/
      blueprint.dhall     Blueprint definition (required)
      prompt.md           Markdown prompt imported by blueprint.dhall
      files/              Optional reference files for the agent
        example.md
        config.sample

  `seihou new-blueprint my-blueprint` creates this layout. The generated
  `blueprint.dhall` imports `prompt.md` as Text so authors can edit the
  prompt as normal Markdown instead of escaping it through a Dhall string.

SCHEMA FIELDS

  The Dhall record uses the Blueprint schema:

    name           Blueprint name. Must match [a-z][a-z0-9-]*.
    version        Optional dotted version for provenance and status.
    description    Optional human-facing summary.
    prompt         Required prompt body. Usually `./prompt.md as Text`.
    vars           Variables resolved before the prompt is rendered.
    prompts        Interactive questions for missing required variables.
    baseModules    Modules to apply before the agent runs.
    files          Reference files under the blueprint's files/ directory.
    allowedTools   Extra tools to pre-approve in addition to the base set.
    tags           Optional discovery tags.
    migrations     Agent-guided library edges (from, to, prompt, optional entails).
    versionProbe   Optional read-only command to infer the target library version.
    launch         Optional provider/model/effort preferences; mode is reserved.

  Blueprints share the same name lookup namespace as modules and recipes.
  If a directory contains more than one runnable definition, lookup prefers
  `module.dhall`, then `recipe.dhall`, then `blueprint.dhall`, then `prompt.dhall`.

VARIABLES AND PROMPTS

  Blueprint variables use the same declaration and resolution model as
  module variables:

    seihou agent run my-blueprint --var project.name=demo

  Resolution follows the normal precedence chain: CLI overrides, environment,
  local config, namespace config, context config, global config, defaults,
  then interactive prompts. Resolved values are substituted into the blueprint
  prompt with `{{variable.name}}` placeholders before the agent sees it.

  `seihou vars my-blueprint` lists a blueprint's declared variables.

BASELINE MODULES

  `baseModules` lets a blueprint apply deterministic scaffolding before the
  agent starts. This is useful for stable foundations such as a language
  skeleton, Nix setup, CI defaults, or shared repository conventions.

  Each base module entry has the same dependency shape used by recipes:

    { module = "haskell-base"
    , vars = [ { name = "project.name", value = "demo" } ]
    }

  Use actual modules in baseModules. Named recipes run separately through
  `seihou run`; they are not executable blueprint baselines. The
  agent runner records the applied blueprint in `.seihou/manifest.json` after
  a successful run, including baseline provenance.

  Applying the baseline matches `seihou run` of its modules: files first,
  then each module's commands in composition order, all before the provider
  starts. Every `seihou agent run` applies it again, so its commands run
  again too. A failing command exits 1 without starting the agent and names
  the command, its module, and how to retry; `--no-baseline` starts the
  agent without applying the baseline. Parent `--debug` lists the declared
  baseline modules and renders the prompt without writing files, running
  baseline commands, or starting the provider. The command phase reports on
  standard error. Baseline commands run directly under Seihou and the
  provider's tool policy applies to the agent.

  Releases through 0.16.0.2 skipped baseline commands. Once consumers run a
  fixed release, remove any prompt text or `allowedTools` entries that only
  existed to make the agent run them, or each command runs twice.

  Baseline seed steps create project-owned starters once and preserve edits or
  deliberate deletion on rerun, including force. Agents extend those files as
  authorized project work. Status/diff do not compare their contents. Commit seed
  receipts for clones; ordinary update owns lifecycle transitions (see modules).

REFERENCE FILES

  Files declared in the `files` list must live under the blueprint's `files/`
  directory:

    files =
      [ { src = "example.md", description = Some "Reference README style" }
      ]

  Reference files are meant for examples, snippets, partial templates, design
  notes, or sample configs that help the agent produce the right project. They
  are not copied automatically by the deterministic engine. During interactive
  and batch `claude-cli` and `codex-cli` runs, the runner mounts the existing `files/`
  directory and prints its absolute path in the agent prompt so the agent can
  read references directly. API providers receive fallback guidance because
  they cannot access local directories.

ALLOWED TOOLS

  `allowedTools` grants a blueprint extra tools beyond the base set required by
  every blueprint run. The runner keeps the base tools first and removes
  duplicates:

    allowedTools = Some [ "Bash(cabal *)", "Bash(mori *)" ]

  Claude Code receives the effective set through `--allowedTools`. Codex keeps
  its workspace-write sandbox and on-request approval policy because it has no
  equivalent per-tool allow-list option.

  Claude starts with the base set and any blueprint allowedTools. A batch run
  can supply additional policy using the flags below. When Claude reports
  a refusal, `seihou agent run` exits 1 and names each refused tool call.
  `seihou validate-blueprint` reports an advisory when a blueprint declares
  no allowedTools.

LIBRARY UPGRADE MIGRATIONS

  A blueprint migration describes one forward dotted-numeric version edge:

    migrations =
      [ S.BlueprintMigration::{
          from = "1.0.0"
        , to = "2.0.0"
        , prompt = ./migrations/1-to-2.md as Text
        }
      , S.BlueprintMigration::{
          from = "2.5.0"
        , to = "3.0.0"
        , prompt = ./migrations/2-5-to-3.md as Text
        }
      ]

  Run an installed library blueprint with explicit versions:

    seihou agent migrate my-library --from 1.0.0 --to 3.0.0

  --to can be inferred by versionProbe; --from can be inferred from receipts.
  With no previous receipts, pass --from explicitly. An edge may declare
  `entails` to schedule another blueprint's edges in the same plan. Receipts
  belong to the blueprint owning each edge. A not-applicable result records
  the reason without suppressing a future run when its precondition is met.

  Edges run in ascending `from` order and gaps are allowed. Duplicate starts
  are invalid; overlaps already passed by the cursor and edges overshooting the
  target are skipped. Each successful provider interaction writes an exact-edge
  receipt before the next session. Rerunning resumes; --rerun repeats matching
  receipts. Parent --debug prints pending prompts without launching or writing.

  --mark-applied records the pending edges in a window as already applied
  without running them, for a consumer who performed the upgrade by hand.

  Migration mode reuses variables, shared prompt, references, and allowed tools,
  but never applies baseModules. A receipt records that an edge has been dealt
  with -- an agent session returned, or the consumer marked it -- not proof that
  a package manager now reports the target version.

COMMON COMMANDS

  seihou new-blueprint api-service       Scaffold a blueprint
  seihou validate-blueprint api-service  Check blueprint.dhall and files/
  seihou list                            List modules, recipes, blueprints, and prompts
  seihou list --full                     Show every description in full
  seihou outdated                        Check installed blueprints against their source
  seihou upgrade api-service             Refresh an installed blueprint with its base modules
  seihou vars api-service                Show blueprint variables
  seihou agent run api-service           Run the blueprint with an agent
  seihou agent migrate my-library --from 1.0.0 --to 3.0.0

  `seihou run api-service` refuses when `api-service` resolves to a blueprint.
  That command is reserved for deterministic modules and recipes; use
  `seihou agent run` for blueprints.

VALIDATION

  `seihou validate-blueprint [PATH]` checks that:

    - blueprint.dhall exists and evaluates
    - the name, version, tags, and allowed tool entries are valid
    - the prompt body is non-empty
    - variables are unique
    - prompts reference declared variables
    - baseModules targets are discoverable; executable baselines use modules
    - declared reference files exist under files/
    - migrations have dotted forward versions, unique starts, and non-empty prompts

  If validation fails, fix the reported check before publishing or running
  the blueprint.

FURTHER READING

  docs/cli/new-blueprint.md        command reference for scaffolding
  docs/cli/validate-blueprint.md   command reference for validation
  seihou help variables            variable precedence and overrides
  seihou help modules              deterministic module authoring


Blueprint migration CLI sessions automatically run in batch mode when stdin is
not a terminal. Use `seihou agent migrate BLUEPRINT --batch` to request batch
mode explicitly, including when only stdout is redirected. Authenticate the
selected `claude` or `codex` CLI first and supply required blueprint inputs with
`--var KEY=VALUE` or normal configuration. Batch mode keeps workspace permissions,
blueprint tools, and reference directories; it does not bypass approvals.
It also preapproves specific read-only Mori discovery commands for dependency
inspection, excluding registry mutations.

Batch processes return when work finishes. With terminal input, sessions remain
interactive: exit each session normally to record its edge. If a batch provider
fails, reports a permission denial, or returns incomplete output, no receipt is
written for that edge. Inspect partial edits, repair the reported problem, and
rerun the same command; completed edges are skipped. Receipts do not verify that
the migrated project builds or passes tests.

CALLER TOOL POLICY

A Claude CLI batch run or migration accepts repeatable --allowed-tool PATTERN and
--settings FILE. For example, --allowed-tool 'Bash(grep *)' adds one static
grant. Pass an existing Claude settings file with --settings ./campaign/claude-settings.json
to use its permission rules and hooks. Both flags apply only to this invocation.
Baseline commands run directly under Seihou before the agent starts.

  seihou agent run fix-nix-haskell-flake-customizations --batch --provider claude-cli --allowed-tool 'Bash(grep *)'
  seihou agent migrate keiro-upgrade --from 0.22.0.0 --to 0.25.0.0 --batch --provider claude-cli --settings ./campaign/claude-settings.json

Inspect the working diff after a refusal and retry with the intended rule or gate.
The manifest records inputs in blueprint.callerToolPolicy or each executed
blueprintMigrations entry. Rules are literal. Files are identified by SHA-256.

Codex batch runs and migrations accept --codex-hooks FILE for synchronous
PreToolUse command handlers. Run seihou agent review-codex-hooks FILE in a
terminal from the consuming project to review new or changed declarations.
A successful receipt stores the file digest, and a reported denial stops the
attempt. See seihou help agent for the full invocation.