Image Sprout is a local image-generation tool with two interfaces over the same on-disk project model:
- a CLI for shell and agent workflows
- a local web app launched through the CLI bridge
# Web app
npm run dev # Vite dev server for the Svelte app
npm run build # Build the web app into dist/app
npm run web # Build web + CLI, then launch the local web bridge
# CLI
npm run build:cli # Build the CLI bundle into dist/cli
node dist/cli/index.js help
node dist/cli/index.js project list
# Quality
npm run check # Svelte + TypeScript checks
npm test # Run all Vitest tests
npm run test:watch # Watch testsImage Sprout stores shared state on disk under a per-user app directory. Both the CLI and the web app read and write the same:
- config
- model registry
- projects
- refs
- sessions
- runs
- CLI mode
- entrypoint:
image-sprout/node dist/cli/index.js - text output by default
- pass
--jsonfor machine-readable responses - best for agents, scripts, and explicit project automation
- Web mode
- entrypoint:
image-sprout webornpm run web --openopens the app in the default browser--port <number>sets a custom port (default: 4310)- launches the Svelte app against the same shared project/config store
- browser talks to the local
/api/*bridge backed by Node
src/
├── cli/
│ ├── index.ts # CLI entrypoint and command dispatch
│ ├── help.ts # Human-facing help text
│ ├── argv.ts # Arg parsing utilities
│ ├── errors.ts # Structured CLI errors and exit codes
│ ├── config.ts # User config (API key, defaults)
│ ├── model-registry.ts # Shared model registry on disk
│ ├── project-store.ts # Shared project/session/run/ref persistence on disk
│ ├── paths.ts # Per-user data/config paths
│ ├── io.ts # File/data-url helpers
│ └── web-server.ts # Local bridge server for the web app
│
├── lib/
│ ├── api/
│ │ ├── openrouter.ts # OpenRouter generation + guide derivation
│ │ └── local-bridge.ts # Browser client for the local bridge
│ ├── components/
│ │ ├── canvas/ # Results grid, run strip, action bar
│ │ ├── drawer/ # Generate / iterate controls
│ │ ├── sidebar/ # Project/session navigation and refs UI
│ │ └── settings/ # Project + model settings modals
│ ├── stores/
│ │ ├── projects.svelte.ts
│ │ ├── generation.svelte.ts
│ │ ├── sessions.svelte.ts
│ │ └── settings.svelte.ts
│ ├── models.config.ts # Built-in image models and request formats
│ └── types.ts # Shared domain types
│
├── App.svelte
├── app.css
└── main.ts
A project contains persistent generation context:
visualStylesubjectGuideinstructions- reference images
- sessions and runs
Refs are role-aware:
both— affects both guidesstyle— affects visual style derivationsubject— affects subject guide derivation
Projects can derive:
visualStylesubjectGuide
Guide derivation uses a configurable analysis model (default: google/gemini-3.1-flash-image-preview).
The model is set via config set analysisModel <model-id> or the --analysis-model flag on derive.
When deriving both guides from different reference sets, both API calls run in parallel.
Projects can also store manual instructions for persistent generation constraints.
Examples:
- watermark requirements
- framing instructions
- branding requirements
- Session: one generation thread inside a project
- Run: one prompt/feedback/model/size/count attempt within a session
Disk-backed storage is the source of truth.
Typical project layout:
<app-home>/
config.json
state.json
models.json
projects/
<project-id>/
project.json
refs.json
refs/
sessions/
runs/
<run-id>.json
images/
Notes:
state.jsonstores convenience state like the current projectproject.jsonstill supports legacy key reads forcoreInstructionandstyleDescriptionwhile the codebase usessubjectGuideandvisualStyle- the browser no longer treats IndexedDB as canonical persistence
- text output is the default
--jsonswitches to structured machine-readable outputhelpis plain text by default and JSON only with--json--value,--ids, and--limitare primarily useful with--json
Primary commands:
projectrefsessionrunmodelconfigwebhelp
Aliases:
generate— shorthand forproject generateanalyze— shorthand forproject derive
Important project flow:
image-sprout project create comic-hero
image-sprout ref add --project comic-hero ./hero.png
image-sprout project derive comic-hero --target both
image-sprout project generate comic-hero --prompt "hero running through rain"Sessions can be listed, shown, and deleted from the CLI:
image-sprout session list --project comic-hero
image-sprout session show --project comic-hero <session-id>
image-sprout session delete --project comic-hero <session-id>Deleting a session removes its runs and generated images.
Supported image counts per generation run: 1, 2, 4, 6.
The default is 4. Override per-run with --count or set the default with config set imageCount.
- never echo the raw API key in normal output
config showandconfig get apiKeyexpose only public/masked status
Config keys:
apiKey— OpenRouter API keymodel— default generation modelsizePreset— default aspect ratio (16:9,1:1,9:16)imageCount— default images per run (1,2,4,6)analysisModel— model used for guide derivation (optional; defaults togoogle/gemini-3.1-flash-image-preview)
The web app is a local interface over the same shared state.
Important UX concepts:
- project settings manage refs, derived guides, and instructions
- split style/subject references are optional advanced behavior
- deriving guides in the web app is local until the user saves edits
- sessions/runs are explicit in the sidebar and run strip
- the canvas is for comparison/review, not hidden state
The local bridge maps CLI errors to HTTP status codes:
NOT_FOUND→ 404AUTH_REQUIRED→ 401API_ERROR→ 502IO_ERROR→ 500INTERNAL_ERROR→ 500PROJECT_NOT_READY→ 409INVALID_ARGS,CONFIG_ERROR, and others → 400
Implemented in src/lib/api/openrouter.ts.
Key rules:
- generation uses multimodal chat completions
- Gemini-style models use
image_config - OpenAI-style image models use
size - model compatibility is mediated through the shared model registry
- custom models must be valid OpenRouter models that:
- accept image input
- produce image output
Guide derivation:
- uses a configurable analysis model (exported as
DEFAULT_ANALYSIS_MODEL) - accepts an optional
analysisModelparameter to override the default - extracts JSON from markdown-fenced responses when the model wraps output in code blocks
- logs a warning when falling back to raw text parsing
Prompt layers currently map to:
visualStylesubjectGuideinstructions- run
prompt - optional run
feedback
Models are shared between CLI and web app.
Storage:
models.jsonunder app home
Behavior:
- built-in defaults come from
src/lib/models.config.ts - users can add/remove/update models in CLI and web
- restore defaults is supported
- user-facing labels default to OpenRouter
namewhen available - internal
requestFormatstays implementation detail, not normal UI
- stores use runes:
$state,$derived,$effect - prefer explicit
value={...}+ event handlers for form inputs when testability matters - keep browser state thin; push durable state changes through the bridge-backed stores
- Vitest + jsdom + Testing Library
- tests mirror
src/undertests/ - CLI tests live under
tests/cli/ - component/store tests live under
tests/lib/
Important patterns:
- many component tests mock the rune stores directly
- when changing CLI defaults, update tests to pass
--jsonexplicitly where structured output is expected vi.clearAllMocks()does not reset mock implementations; reset them deliberately inbeforeEach
Use conventional commit messages. The release workflow generates CHANGELOG.md from these prefixes:
feat:— new featurefix:— bug fixrefactor:— code restructuring without behavior changechore:— build, deps, config, CIdocs:— documentation onlytest:— adding or updating tests
Include a scope when it clarifies context: feat(cli): add batch mode, fix(canvas): grid overflow.
Append ! before the colon for breaking changes: feat!: remove legacy config format, refactor(cli)!: new arg syntax.
Two skill files ship with the repo:
| File | Distribution | CI Workflow |
|---|---|---|
skills/agents/SKILL.md |
tmc-marketplace plugin | sync-skill-to-marketplace.yml |
skills/openclaw/SKILL.md |
ClawHub | publish-openclaw-skill.yml |
When skills/agents/SKILL.md is changed on main, the sync workflow automatically:
- Copies the updated skill file to tmc-marketplace
- Commits directly to
mainwith a conventional commit (fix(image-sprout): ...) - release-please in tmc-marketplace picks up the commit and handles the version bump in its next release PR
When skills/openclaw/SKILL.md is changed on main, the publish workflow automatically:
- Publishes the skill to ClawHub using the CLI version from
package.json - Falls back to prerelease suffixes (
<version>-skill.N) if the base version already exists
Keep both skill files in sync with CLI behavior. If you change commands, flags, defaults, or workflows that the skills document, update both skill files in the same PR.
When spawned via ACP (Agentic Client Protocol):
- Break multi-step work into a visible checklist at the start of the task.
- Signal each item as in-progress before starting it and completed immediately after.
- The final item marked completed serves as the task-completion checkpoint for the orchestrator.
Use whatever task/todo mechanism your agent runtime provides. The key requirement is that progress is externally observable — not just internal reasoning.
- Do not assume the old IndexedDB architecture described in earlier docs still applies.
- Treat
src/cli/project-store.tsas the canonical persistence layer. - Treat the web app as a client of the local bridge, not an independent persistence system.
- If changing user-visible CLI behavior, verify both:
- source tests
- built CLI output from
dist/cli/index.js
- If changing canvas or run-strip layout, verify against the real running app when possible, not just tests.