# `dsh` (the default surface) — the full-screen TUI, as a patch list over
# `base.cordis.yml`. The launcher includes the base and applies this file, then
# any `--config` overlay, then the personal `~/.dsh/config.yaml`, as sibling
# patch lists at ONE include level: patches never cross an include boundary, so
# stacking overlays as nested includes would silently stop reaching base rows.
#
# A patch replaces the targeted row's whole `config`, so each row below restates
# every key it owns. A patch whose `id` matches no row is skipped with a Loader
# warning, which is deliberate: one personal overlay is shared across surfaces,
# so a row that exists only under `web` must not fail the TUI's boot.
#
# The launcher owns session identity and the exit line, and provides both on the
# boot context rather than through config, so no key here — and no overlay
# replacing one — can drop `--resume`.

# ── surface-specific values the base deliberately omits ─────────────────────

# `main` is the agent the TUI drives. `provider`/`model` are the route `dsh
# login` rewrites and a personal overlay repoints; `cwd` anchors the session to
# the invoking directory, which is also what scopes `/resume` to this workspace.
- id: agent-loop
  config:
    agents:
      - id: main
        provider: deepseek-official
        model: deepseek-v4-pro
        cwd: !!js process.cwd()

# Keep the persona to identity and behavior; tool plugins own tool guidance.
# The loop resolves {{model}} from this agent's configuration.
- id: system-prompt
  config:
    persona: |
      You are a coding agent powered by the {{model}} model.

      Verify your work by running the code or tests. Keep answers brief and
      factual.

# Shipped default: full thinking at max effort on every request. Exact-model
# resolution materializes request defaults before the request header is logged.
- id: llm-deepseek
  config:
    apiKey: !!js process.env.DEEPSEEK_API_KEY
    baseURL: !!js process.env.DEEPSEEK_BASE_URL
    thinking: enabled
    reasoningEffort: max

# This single-session app resolves relative paths from the process cwd.
- id: fs-local
  config:
    cwd: !!js process.cwd()

# The shipped TUI presents the native tool registry.
- id: tools
  config:
    mode: native

# ── TUI-only rows ───────────────────────────────────────────────────────────

- insert:
    # Relational runtime checks over the authoritative event streams; each
    # companion registers the assertions its own package owns.
    - id: invariants
      name: '@deepseek-ai/dsh-invariants'
    - id: session-invariant
      name: '@deepseek-ai/dsh-session/invariant'
    - id: agent-invariant
      name: '@deepseek-ai/dsh-agent/invariant'
    - id: scope-invariant
      name: '@deepseek-ai/dsh-scope/invariant'
    - id: agent-loop-invariant
      name: '@deepseek-ai/dsh-agent-loop/invariant'

    - id: session-checkpoint-policy
      name: '@deepseek-ai/dsh-session-checkpoint-policy'

    # The derived query index behind `/resume`. The launcher provides a unique
    # process-local path because this SQLite backend has one writer owner; the
    # project-local fallback applies when no launcher sets the typed slot.
    - id: session-reference
      name: '@deepseek-ai/dsh-session-reference'

    # Compacts oversized tool results before the broader conversation compactor
    # runs, preserving the model-visible result within the configured budget.
    - id: tool-result-prune
      name: '@deepseek-ai/dsh-compact-tool-result-prune'

    # Persisted same-session goals reach the model and the slash menu here; the
    # domain, driver, and `/goal` command are in the base.
    - id: tool-goal
      name: '@deepseek-ai/dsh-tool-goal'

    # A separate fixed consumer demonstrates fresh-agent Ralph iteration without
    # changing the workflow tool or same-session goal behavior.
    - id: tool-ralph
      name: '@deepseek-ai/dsh-tool-ralph'

    # The keyboard-backed provider behind ask_user_question and the plan-mode
    # review, and the front door it renders inside.
    - id: tui-prompt
      name: '@deepseek-ai/dsh-tui/prompt'

    # The TUI renders exactly the agent the agent-loop row bound, so it reads the
    # same launcher-owned identity rather than restating one.
    - id: tui
      name: '@deepseek-ai/dsh-tui'
      config:
        sessionId: !!js configuredAgentIdentities?.main?.id ?? 'main'
        showReasoning: true
        maxToolOutputLines: 6

    - id: tool-ask-user
      name: '@deepseek-ai/dsh-tool-ask-user'
