The StoryMatrix CLI answers which commands and options control story generation, configuration, voices, and runtime modes.

🚀 generate

storymatrix generate loads YAML and environment configuration, layers explicitly supplied CLI values over it, validates a GenerateStoryRequest, and runs the asynchronous use case.

OptionTypeDefaultEffect
--prompt, -pstr | NoneNoneStory prompt; required by GenerateStoryRequest. The CLI’s missing-prompt guard is bypassed when --story-md is supplied, but a story-md-only invocation still fails Pydantic validation because the request DTO requires prompt.
--configPath | NoneNoneExisting YAML file merged into the request and configuration.
--title, -tstr | NoneNoneStory title.
--genre, -gstr | NoneNoneStory genre.
--style, -sstr | NoneNoneWriting style.
--language, --lang, -lstr | NoneNoneStory language.
--structurestr | NoneNoneStory structure archetype; maps to structure_type.
--character, -clist[str] | NoneNoneRepeatable character values.
--num-scenes, --scenesint | NoneNoneTarget scene count.
--story-mdPath | NoneNoneAccepted by the parser and used only to bypass the missing-prompt guard; the DTO carries story_md for use-case consumption, but the CLI never reads the file, and a story-md-only invocation fails Pydantic validation because GenerateStoryRequest still requires prompt.
--voice-idstr | NoneNoneDefault TTS voice identifier.
--output, -oPath | NoneNoneOutput path, passed through the request’s output alias.
--fast-dev-runboolFalseRequests mock services for a fast run.
--min-similarity-scorefloat | NoneNoneAccepted by Typer, but GenerateStoryRequest has no matching field, so the value is ignored after request construction. Use global --min-similarity to write the environment override instead.
--keep-temp-files/--no-keep-temp-filesbool | NoneNonePreserve or remove temporary files.
--resume/--no-resumebool | NoneNoneResume from the last successful checkpoint.
--low-resource/--no-low-resourceboolFalseWrites APP__LOW_RESOURCE_MODE=true before configuration loading when enabled.
--max-tts-concurrencyint | NoneNoneFor a positive value, writes APP__MAX_TTS_CONCURRENCY before configuration loading.
--sfx/--no-sfxboolTrueEnable or disable sound effects.
--background-music/--no-background-musicboolFalseEnable or disable background music.
--ambient-sounds/--no-ambient-soundsboolTrueEnable or disable ambient sounds.
--max-tokensint | NoneNoneMaximum LLM generation tokens.

Explicit command options are collected from Typer’s context and layered over YAML values before GenerateStoryRequest validation. The command’s --low-resource and --max-tts-concurrency write environment variables before load_config(), but those writes are not authoritative when YAML supplies the same settings: load_config() deep-merges YAML over the defaults-plus-environment mapping.

🚧 Offline and low-resource flags (B15)

--offline writes APP__DEV_LOCAL_ONLY=true, and --low-resource writes APP__LOW_RESOURCE_MODE=true into os.environ before load_config() (src/storymatrix/cli/main.py). The behavior is split: container branches that read os.environ directly honor those writes, while branches that inspect the loaded config object can lose them. load_config() first gets defaults and environment values through StoryMatrixConfig(), then deep-merges YAML over that mapping; only SERVICES__LLM__OPEN_ROUTER__TIMEOUT is reapplied from the environment afterward (src/storymatrix/config/config.py).

The shipped storymatrix_config.yaml explicitly sets app.dev_local_only: false and app.low_resource_mode: false, so those YAML values override the two flag writes for config-reading gates. Therefore --offline does not guarantee offline behavior or local/mock providers, and --low-resource does not guarantee low-resource mode across all consumers. Track this trap at B15.

🗣️ voices list

storymatrix voices list loads voice records, applies optional key=value filters, and prints a human-readable list or JSON.

Argument / optionTypeDefaultEffect
filterslist[str] | NoneNonePositional filters in key=value form; provider is converted to the provider enum. Invalid entries are ignored with a warning.
--jsonboolFalsePrint voice dataclasses as indented JSON instead of a Rich panel.

🧹 voices clear-cache

storymatrix voices clear-cache clears the in-memory voice data cache.

OptionTypeDefaultEffect
-pstr | NoneNoneClear one provider’s cache; omit it to clear all voice caches. Unknown provider values are ignored after a warning.

⚙️ config show

storymatrix config show prints the effective settings as YAML with secret values redacted, followed by a provider-strategy summary.

OptionTypeDefaultEffect
--configPath | NoneNoneExisting YAML file merged through load_config(); without it, StoryMatrixConfig() shows defaults and environment values.

📝 config set-pref

storymatrix config set-pref KEY VALUE persists one user preference through UserPreferences.

ArgumentTypeDefaultEffect
keystrrequiredPreference key such as tts.default_voice_id.
valuestrrequiredPreference value to save.

🔎 config get-pref

storymatrix config get-pref KEY prints one persisted user preference.

ArgumentTypeDefaultEffect
keystrrequiredPreference key to retrieve.

🌐 Global callback options

These options apply before a subcommand runs. The callback loads configuration for logging and stores selected values in the Click context.

OptionTypeDefaultEffect
--versionboolNoneEagerly prints the package version and exits.
--log-level, -lstr | NoneNoneSets logging level; otherwise the configured application log level applies.
--offline/--onlineboolFalseWhen enabled, writes APP__DEV_LOCAL_ONLY=true before configuration loading; direct environment consumers honor it, but config-reading gates can be overridden by YAML and therefore local/mock selection is not guaranteed.
--low-resource/--no-low-resourceboolFalseWhen enabled, writes APP__LOW_RESOURCE_MODE=true before configuration loading; direct environment consumers honor it, but config-reading gates can be overridden by YAML.
--max-tts-concurrencyint | NoneNoneFor a positive value, writes APP__MAX_TTS_CONCURRENCY before configuration loading.
--min-similarityfloat | NoneNoneFor a value from 0.0 through 1.0, writes SERVICES__LOCAL_ASSETS__MIN_SIMILARITY_SCORE before configuration loading.

The generate command repeats --low-resource and --max-tts-concurrency for command-local use. The global callback accepts --online, but it only represents the false side of the offline boolean and does not write an environment value when selected.

🎭 Interactive builder

InteractiveStoryBuilder exists in cli/interactive.py, but cli/main.py does not expose an --interactive option or call build_story_request(). There is therefore no current CLI trigger for this flow; embedding code must instantiate the builder and call build_story_request().

When called, it prompts in this order:

  1. Story idea: Story prompt, defaulting to A brave knight rescues a princess from a dragon; input must contain at least 10 non-whitespace characters.
  2. Story style: displays nine choices—fantasy, scifi, horror, comedy, drama, mystery, adventure, children, and educational. none (the default) returns no style.
  3. Story structure: displays three_act, hero_journey, and five_act. auto (the default) returns no explicit structure.
  4. Audio mixing: displays the configured mixing profiles and defaults to profile 1.
  5. Advanced options: asks whether to specify a scene count (default False); if enabled, accepts 120 scenes with default 5, then asks whether to create a final audio montage (default True).
  6. Preview and confirmation: shows prompt, selected style, structure, mixing profile, scene count, and montage choice, then asks Create this story? (default True). A negative answer cancels with KeyboardInterrupt.

📦 Console scripts

The project exposes three console scripts from pyproject.toml:

ScriptEntry pointPurpose
storymatrixstorymatrix.cli.main:appTyper command-line application.
storymatrix-apistorymatrix.interfaces.api.main:runFastAPI service launched through Uvicorn.
storymatrix-webstorymatrix.interfaces.web.main:runNiceGUI web service.
uv run storymatrix generate --prompt "A lighthouse keeper finds a voice in the fog"
uv run storymatrix voices list --json
uv run storymatrix voices clear-cache -p piper
uv run storymatrix config show --config storymatrix_config.yaml
uv run storymatrix-api
uv run storymatrix-web

📚 README coverage

README.md documents generate, --config, --scenes, --sfx, --background-music, --resume, and the two service scripts. It does not document the voices group, either config subcommand, global callback options, most generate options, or the interactive builder. Its four-profile summary also omits the additional dev, test, docs, and deploy profiles defined by the project configuration.