# CLI ## Shortest Useful Command ```bash narratio run 2026-04-04 ``` This command uses default system discovery for `pipeline.yml`, `campaign.yml`, and local `session.yml`. If local session discovery misses and S3 storage is configured, the positional session ID loads remote `session.yml` from the canonical session prefix. Default discovery checks system config locations only. Pass `--config`, `--campaign`, and `--session` to use files from the current working directory. Ordinary local and remote `session.yml` files must be concrete YAML. Templates belong to `narratio session init`, which renders a configured campaign template before writing the concrete file. ## Command Overview Top-level commands: - `run `: execute pipeline stages and persist manifest state. - `run-stage `: execute exactly one stage. - `resume `: continue from first non-succeeded stage unless forced. - `analyze `: force-rerun the analyze stage. - `publish `: force-rerun the archive stage. - `clean |--all`: remove local workspace/spool state. - `session `: session-scoped helper commands. Session subcommands: - `session init `: create local or remote `session.yml`. - `session validate `: run read-only preflight checks. - `session status `: inspect local/remote session state. - `session plan `: validate config, prepare workspace layout, and print stage run/skip decisions. - `session restore `: restore durable local state from committed remote archive state. - `session artifacts `: list effective artifact source IDs. - `session locks `: list archive promotion locks. - `session locks add `: add or update a remote lock. - `session locks remove `: remove a remote lock. Unknown commands print usage and exit non-zero. For config semantics, see [docs/config.md](./config.md). For operator lifecycle and recovery, see [docs/operations.md](./operations.md). ## Common Flags Most session-aware commands accept: - `--config `: optional explicit `pipeline.yml` path. - `--campaign `: optional explicit `campaign.yml` path. - `--session `: optional explicit concrete `session.yml` path. - `--previous-session-id `: expected previous session identifier. The positional `` is required even when `--session` is provided. It is used as the expected session identity and as the remote session lookup value when local session discovery misses. ## Command Reference ### `run` ```bash narratio run [--config ] [--campaign ] [--session ] [--previous-session-id ] [--force] [--artifacts ] ``` Purpose: - Execute configured stages in canonical order. Success output: - `narratio run: session ; executed= skipped=; manifest=` Common failure cases: - missing system default config/campaign/session paths when flags are omitted. - missing local session plus missing/unavailable remote `session.yml`. - templated `session.yml`; run `narratio session init` to generate concrete YAML. - concrete session identity mismatch. - unknown configured artifact key in `--artifacts`. ### `resume` ```bash narratio resume [--config ] [--campaign ] [--session ] [--previous-session-id ] [--force] [--artifacts ] ``` Purpose: - Continue from session-manifest stage status. Success output: - `narratio resume: session has no remaining stages` - or `narratio resume: session ; executed= skipped=; manifest=` ### `run-stage` ```bash narratio run-stage [--config ] [--campaign ] [--session ] [--previous-session-id ] [--force] [--artifacts ] ``` Valid stage names: - `prepare` - `transcribe` - `merge` - `polish` - `normalize` - `trim` - `analyze` - `archive` - `notify` Success output: - `narratio run-stage: stage= executed= skipped= force=; manifest=` `--artifacts` is accepted only for `analyze` and `archive`. ### `analyze` ```bash narratio analyze [--config ] [--campaign ] [--session ] [--previous-session-id ] [--artifacts ] ``` Purpose: - Force-rerun the analyze stage. - Shorter equivalent for `narratio run-stage analyze --force`. `analyze` is force-by-design and does not accept `--force`. ### `publish` ```bash narratio publish [--config ] [--campaign ] [--session ] [--previous-session-id ] [--artifacts ] ``` Purpose: - Force-rerun the archive stage. - Shorter equivalent for `narratio run-stage archive --force`. `publish` is force-by-design and does not accept `--force` or a stage positional argument. ### `clean` ```bash narratio clean [--config ] [--campaign ] [--session ] [--previous-session-id ] [--dry-run] [--clear-cache] narratio clean --all [--config ] [--dry-run] [--clear-cache] ``` Session cleanup deletes: - `{workspace.root}/work/{campaign}/{session_id}` - `{spool.root}/{campaign}/{session_id}` All-session cleanup deletes: - `{workspace.root}/work` - the contents of `{spool.root}`, while preserving the spool root directory itself. Cache behavior: - cache is preserved by default. - `--clear-cache` in session mode removes cached S3 audio files for the resolved session. - `--all --clear-cache` removes the configured Narratio S3 audio cache namespace for the configured bucket/root prefix. - `--clear-cache` does not delete arbitrary files under `pipeline.cache.root`. ### `session plan` ```bash narratio session plan [--config ] [--campaign ] [--session ] [--previous-session-id ] [--force] ``` Purpose: - Validate config, load secrets if configured, prepare workdir, and print stage run/skip decisions. Success output includes: - `narratio session plan: workdir prepared at ` - one line per stage (`: run|skip`) - `totals: run= skip=` ### `session status` ```bash narratio session status [--config ] [--campaign ] [--session ] [--previous-session-id ] ``` Output includes: - session ID, campaign, workspace, and session config source. - local manifest state when present. - remote current archive state when storage is configured. - catalog-based promoted output availability for expected transcript and artifact sources. - effective archive locks and conservative next actions. ### `session validate` ```bash narratio session validate [--config ] [--campaign ] [--session ] [--previous-session-id ] ``` Checks include: - effective config and session source. - stable input files. - local or remote audio availability. - previous-session requirements. - archive promotions and effective locks. Warnings do not fail the command. Any `ERROR` finding exits non-zero. ### `session init` ```bash narratio session init --output ./session.yml narratio session init --remote narratio session init --config --campaign --remote ``` Additional flags: - `--previous-session-id ` - `--date ` - `--title ` - `--audio-s3-prefix `: defaults to `audio/` when neither audio flag is provided. - `--audio-dir `: local audio directory; mutually exclusive with `--audio-s3-prefix`. - `--force`: overwrite existing local or remote target. Behavior: - exactly one of `--output` or `--remote` is required. - `--config` and `--campaign` are optional overrides; omitted values use normal default config discovery. - if `campaign.yml` sets `session_template_file`, the template path is resolved relative to `campaign.yml` and rendered from init flags. - if no session template is configured, a minimal concrete session file is generated directly. - template variables must be supplied by matching flags, and supplied template-related flags must be used by the template. - remote writes target `{root_prefix}/campaigns/{campaign}/sessions/{session_id}/session.yml`. - existing local or remote targets fail unless `--force` is passed. - remote writes use existence checks, not compare-and-swap. ### `session restore` ```bash narratio session restore [--config ] [--campaign ] [--session ] [--previous-session-id ] [--dry-run] [--force] [--include-audio] ``` Purpose: - Restore durable session state from the committed remote archive current state. - Default restore installs `manifest.json`, `transcripts/**`, and `artifacts/**` from the current session archive. - When configured previous-session inputs require it, restore reconstructs `previous/**` from the previous session's committed current archive. - `audio/**` is restored only with `--include-audio`. Dry-run output may include planned previous-cache downloads. Existing differing files under `previous/**` follow the normal restore conflict policy and require `--force` to overwrite. When `--include-audio` is set, S3 audio files are restored through the shared audio cache. Cache hits avoid re-downloading large audio objects. ### `session artifacts` ```bash narratio session artifacts [--config ] [--campaign ] [--session ] [--previous-session-id ] [--remote] ``` Purpose: - List built-in, configured, previous-session, promoted, and locked artifact sources. `--remote` checks promoted top-level object availability through the storage adapter. Remote markers appear only in the `Promoted` section, which reports each configured archive promotion destination and includes `dest=` when that destination differs from the source's canonical path. ### `session locks` ```bash narratio session locks [--config ] [--campaign ] [--session ] [--previous-session-id ] narratio session locks add [--config ] [--campaign ] [--session ] [--previous-session-id ] [--reason ] [--force] narratio session locks remove [--config ] [--campaign ] [--session ] [--previous-session-id ] ``` Behavior: - list mode prints effective locks from static `pipeline.archive.locks` and remote `{session_prefix}/locks.yml`. - `locks add` writes only the remote lock store and fails if the source is already locked by pipeline config. - `locks remove` removes only remote locks and cannot remove static pipeline locks. - `locks add --force` is required to update an existing remote lock reason. ## Common Workflows Default-discovery run: ```bash narratio run 2026-04-04 ``` Run only selected analyze artifacts: ```bash narratio run 2026-04-04 --artifacts session_recap,player_handout ``` Resume with selected analyze artifacts: ```bash narratio resume 2026-04-04 --artifacts player_handout ``` Force-rerun analyze with selected artifacts: ```bash narratio analyze 2026-04-04 --artifacts player_handout ``` Force-rerun archive publishing: ```bash narratio publish 2026-04-04 ``` Preview restore actions without writes: ```bash narratio session restore 2026-04-04 --dry-run ``` Restore and then force analyze: ```bash narratio session restore 2026-04-04 narratio analyze 2026-04-04 ``` Rehydrate canonical previous-session inputs after artifact-input changes: ```bash narratio run-stage prepare 2026-04-04 --force ``` Reset local state before testing restore: ```bash narratio clean 2026-04-04 --dry-run narratio clean 2026-04-04 narratio session restore 2026-04-04 --include-audio ``` Clean all local sessions while keeping cached S3 audio: ```bash narratio clean --all ``` ## `--artifacts` and `--force` - `--artifacts` filters which configured artifacts are executable when analyze runs and which configured artifact promotions archive publishes. - `--artifacts` does not imply `--force`. - if analyze is already `succeeded` and `--force` is not set, runner-level skip still applies. - `--artifacts` does not suppress built-in transcript or bounds promotions.