Skip to content

architecture startup and cli

github-actions[bot] edited this page Oct 20, 2026 · 53 revisions

Startup and CLI

Purpose

Documents how the solomon binary boots, branches on subcommands, and constructs the interactive runtime.

Packages and files

Package / file Responsibility
cmd/solomon/main.go Entry: logging, CLI branches, daemon-backed TUI client
cmd/solomon/exec.go exec / temp exec, --json / --jsonl, headless config
cmd/solomon/server/ Detached local server lifecycle (start/status/stop/restart/logs)
internal/server/ Local HTTP host: health, Vite proxy, process lifecycle
internal/agent/cievents CI event schema, JSONL/collector sinks, exit codes
internal/config/exec_resolve.go TOML → env → env-file for machine exec
internal/prompt Embedded .tmpl defaults, disk store, startup SHA review
internal/paths SolomonHome() → ~/.solomon, PromptTemplatesDir()
internal/config Load/save TOML, onboard setup, provider resolve, model pick
internal/project Resolve(wd) → canonical root + 64-char hex id
internal/logging File logs under ~/.solomon/logs
internal/chatstore Empty or loaded Session passed into runtime
internal/agent/runtime NewRuntime, InitMCP, Run, RunPromptOnce

Key functions

Function File Behavior
main cmd/solomon/main.go Init logging; maintenance commands; early exec path; daemon-backed interactive TUI
runExecCLI cmd/solomon/exec.go One-shot exec with optional machine output
config.ResolveExecConfig internal/config/exec_resolve.go Headless credentials for --json/--jsonl
prompt.InstallTemplates internal/prompt/install.go SHA review + sync before writing prompts/templates/ (make install)
paths.PromptTemplatesDir internal/paths/paths.go ~/.solomon/prompts/templates/
config.RunInitialSetup internal/config/onboard_setup.go First-run / incomplete LLM setup (required provider)
config.RunOnboardWizard internal/config/onboard.go Interactive /onboard wizard: OpenAI or Anthropic Compatible API (optional skips on re-run)
config.NeedsOnboard internal/config/onboard.go True when provider, API key, or model is missing
config.ResolveProvider internal/config/config.go Active provider from current.*
project.Resolve internal/project/project.go Map cwd → (root, hex)
agentruntime.NewRuntime runtime/core.go OpenAI client, default Mode: "agent"
Runtime.InitMCP runtime/mcp.go Start MCP manager from config
Runtime.Run runtime/repl_run.go + runtime/repl/ Interactive loop
Runtime.RunPromptOnce runtime/core.go Single user message + turns

Startup flow

flowchart LR
  start[Run solomon]
  load[Load config]
  ok{LLM setup complete}
  setup[RunInitialSetup / onboard]
  tpl[prompt.StartupTemplates]
  warn[Warn if still incomplete]
  proj[Resolve cwd]
  mode{CLI mode}
  client[daemon TUI client]
  repl[daemon PTY child / REPL]
  execOnce[exec]
  start --> load --> ok
  ok -->|no| setup --> ok
  ok -->|yes| warn
  setup --> tpl --> warn
  warn --> proj --> mode
  mode -->|default| client --> repl
  mode -->|exec args| execOnce
Loading

CLI branches (early exit)

Before initial setup, main handles:

  • solomon server ... → detached local server lifecycle; does not load provider configuration
  • solomon add ... → commands.Add with project.Resolve deps
  • solomon remove skill <name> → commands.Remove
  • solomon exec / solomon temp exec → runExecCLI (human or --json / --jsonl; readline skipped in machine mode; no StartupTemplates — use interactive REPL to accept template edits)

After initial setup on the interactive REPL path (the daemon-launched --daemon-tui child), prompt.StartupTemplates runs before the session loop: copies missing .tmpl files, then prompts only when on-disk content diverges from a saved [prompt_templates] SHA (tampering after accept). Template upgrades from a new binary are synced during make install via solomon templates install (SHA check before writing files). See Configuration.

After runtime construction (REPL path only):

  • default — solomon attaches to a daemon-owned PTY running Runtime.Run
  • solomon tui [directory] / solomon attach [directory] — explicit aliases for the same client
  • REPL /temp — ephemeral in-memory chat (commands.TempChat)

Session construction at boot

main allocates an empty chatstore.Session (placeholder checkpoint fields, empty messages). The REPL or /resume loads or assigns ids; see Sessions and storage.

Extension points

  • New global CLI subcommands: add branch in main before REPL setup (mirror add/remove pattern with commands.Deps).
  • Boot-time defaults: NewRuntime and config.Root fields.

Related code

See also

Clone this wiki locally