# The `oh-my-dsh` agent preset: the standard coding agent, plus an
# orchestration vocabulary layered over DSH's native primitives.
#
# It is a copy of `standard` with two changes:
#   1. a persona that names the oh-my-dsh orchestration modes, and
#   2. `skill-filesystem` configured to bundle the omd-* skills that travel
#      with this preset (resolved via `baseUrl`, so the root follows wherever
#      the preset is installed).
#
# Everything else — tools, groups, realms, compaction, plan mode — is the
# `standard` composition unchanged. The orchestration is SKILLS, not new
# machinery: the Plan/Execute/Review/Verify pipeline, Team, Autopilot, Ralph,
# Ralplan, Research, Autoresearch, and Ultragoal all map onto the native
# `workflow` / `subagent` / `ralph` / `goal` tools already mounted below.

# ── identity ────────────────────────────────────────────────────────────────

# The preset's own persona, shadowing the deployment default for this agent.
# `{{model}}` resolves from the agent's own route. The working directory is NOT a
# prompt variable: current DSH registers only `provider` and `model`, and injects
# the working directory as its own runtime-context section. A `cwd` reference here
# fails prompt assembly for the whole turn, so leave it out.
# The row uses the `prefix:` key. `text:` is an older key the persona row's schema
# no longer accepts — it is dropped, and a required `prefix` then fails the mount.
- id: persona
  name: '@deepseek-ai/dsh-persona'
  config:
    prefix: >-
      You are a coding agent powered by the {{model}} model, running on the oh-my-dsh
      orchestration layer of the DeepSeek Harness.

      MODES (load the matching omd-* skill before entering; each also has a /omd-* command):
      plan, execute, review, verify, team, autopilot, ralph, deep-interview, ralplan,
      research, autoresearch, ultragoal, cancel, hud.

      SKILL ROUTING — when the situation matches below, LOAD that skill before answering.
      Do not skip loading just because you can answer from general knowledge; the skill
      carries the discipline that makes the answer reliable.
      - Multi-step work → plan → execute → review → verify (team/autopilot/ralph for larger scope)
      - Vague or undecided need → deep-interview (Socratic clarification)
      - Need breadth (evidence, many angles) → deep-analyze; need exhaustive reasoning → ultrathink
      - Several real problems competing → contradictions (rank with evidence, pick ONE main thread)
      - Convention inherited, need to rebuild from facts → first-principles (every fact needs a source)
      - Before adopting a plan, attack it → challenge (steelman → 5 attack surfaces → verdict)
      - Something failed, spun, or produced nothing → postmortem (timeline → layered root cause → guards)
      - A decision worth remembering → decision-record (ADR with reversal conditions)
      - "What is actually running?" → observe (process args > config; disk config ≠ live config)
      - Structure the answer → pyramid (conclusion first, MECE); plain spoken → plain-writing
      - Code work → tdd, deepsearch, debug (reproduce→isolate→fix→verify), minimal-code-discipline (smallest correct diff)
      - Ship it → release (version→changelog→tag→artifact); self-check → doctor
      - Knowledge & utilities → wiki, skillify, remember, external-context, visual-verdict, ai-slop-cleaner, help

      Default: lead each report with its conclusion (omd-pyramid lists the exceptions);
      prefer parallel subagent delegation; drive every long-running objective through goal
      tools rather than a single turn. When several skills plausibly match, load the more
      specific one. /omd-* commands are a direct entry; natural language triggers by description.

      写作约束（每轮生效）：每句要有一个具体的东西——谁、做了什么、多少、什么时候；想不出就不写这句。
      判断句用动词，不用比喻。一段只讲一件事，段首句就是这件事。不写对偶开场（`不是 A，而是 B`、
      `不仅 A，更是 B`），只写成立的那半句。
      不叙述自己的更正（`前面说错了`、`纠正一下`），直接写正确版本。不造抽象名词（钉死、抓手、
      闭环、骨架、台账），换成动作。不把动词砍成两字缩写（机器判、判死、落盘、口径），展开成完整
      说法。发送前删掉只复述段落的收尾句，停在最后一个具体事实上。

- id: agent-instructions
  name: '@deepseek-ai/dsh-agent-instructions'
  config:
    maxBytes: 65536

# ── shell ───────────────────────────────────────────────────────────────────

# `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
# publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
# the criterion for host-plane ownership — injection resolves before any session
# exists, so there is no agent to key by. Behind a preset realm those variables
# never reached the model's shell at all. Both shell tools consume the host
# registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
# host-plane too.
- id: tool-bash
  name: '@deepseek-ai/dsh-tool-bash'
  disabled: !!js process.platform === 'win32'

- id: tool-pwsh
  name: '@deepseek-ai/dsh-tool-pwsh'
  disabled: !!js process.platform !== 'win32'

# ── filesystem ──────────────────────────────────────────────────────────────

# Both register into the host `tools` registry and provide nothing, so
# they need no realm. The `fs` service and its policy stay in the host.
- id: tool-fs
  name: '@deepseek-ai/dsh-tool-fs'

- id: tool-fs-search
  name: '@deepseek-ai/dsh-tool-fs-search'
  config:
    sampleOverCapGlobResults: false

# ── background jobs ────────────────────────────────────────────────────────

# Only the model-facing controls. The task REGISTRY stays on the host plane:
# its producers sit outside any realm this file could put it in — `tool-bash`
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
# to every sibling row, so `run_in_background` would answer "background jobs
# unavailable" while these controls sat in the catalog. The registry is keyed by
# owning agent anyway, so one host instance serves every session. What a preset
# chooses is whether its agent can collect and stop background work at all.
- id: tool-jobs
  name: '@deepseek-ai/dsh-tool-jobs'

# ── skills ──────────────────────────────────────────────────────────────────

# The skill REGISTRY lives in the host composition and is layered per scope:
# these rows register into THIS preset's layer of it, so they need no realm.
# `skill-filesystem` contributes local-root discovery for agents on this preset,
# plus the omd-* orchestration skills bundled in this preset's own `skills/`
# directory (`baseUrl` is the preset's directory, so the root follows the
# install). `tool-skill` gives the catalog and loader; the merged catalog also
# carries whatever the deployment registered globally (repository plugins).
- id: skill-filesystem
  name: '@deepseek-ai/dsh-skill-filesystem'
  config:
    customSkillDirs:
      - !!js "process.getBuiltinModule('node:url').fileURLToPath(new URL('skills/', baseUrl))"

- id: tool-skill
  name: '@deepseek-ai/dsh-tool-skill'

# ── goals ───────────────────────────────────────────────────────────────────

# The goal service and session driver stay on the host plane, where the Gateway
# can resolve them. The human command and model-facing tool register into this
# preset's scoped layers.
- id: command-goal
  name: '@deepseek-ai/dsh-command-goal'

# oh-my-dsh slash commands (/omd-plan /omd-execute /omd-review /omd-verify
# /omd-team /omd-autopilot /omd-ralph /omd-deep-interview /omd-ralplan
# /omd-research /omd-autoresearch /omd-ultragoal /omd-pyramid): a preset-shipped ESM producer
# — the relative `name` resolves against the preset's own directory. Each handler
# submits a user message that steers the model into the matching omd-* skill,
# then returns a direct UI acknowledgement.
- id: command-omd
  name: './commands/omd-commands.mjs'

- id: tool-goal
  name: '@deepseek-ai/dsh-tool-goal'

# ── plan mode ───────────────────────────────────────────────────────────────

# Plan state is per-agent by nature, so an entry-local realm is not a
# workaround here — it is the correct lifetime.
- id: planning
  name: cordis:group
  group: true
  isolate:
    planMode: true
  config:
    - id: plan-mode
      name: '@deepseek-ai/dsh-plan-mode'
      config:
        section: |
              You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.

              Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.

              The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.

              Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.

              Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.

              When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.

# ── compaction ──────────────────────────────────────────────────────────────

# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
# share this realm rather than sit outside it.
#
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
# plane, and the rows here resolve that one instance. It takes no configuration,
# keys every fold by Session, and owns the context-meter projection units the
# browser reads for every session — behind a realm those units would come and go
# with whichever presets happen to be mounted. What a preset chooses is whether
# its agent compacts at all, which is `compaction-basic` below.
- id: compaction
  name: cordis:group
  group: true
  isolate:
    compaction: true
    toolResultPruner: true
  config:
    - id: compaction-basic
      name: '@deepseek-ai/dsh-compaction-basic'

    - id: command-compact
      name: '@deepseek-ai/dsh-command-compact'

    - id: tool-result-pruner
      name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
      config:
        thresholdChars: 8192
        headChars: 4096
        tailChars: 1024

# ── delegation and workflows ────────────────────────────────────────────────

# The `subagents` registry and its spawn/fork backends live in the HOST
# composition: the registry is a process singleton whose cross-session queries
# the api-proxy serves to the browser, and a provider name may only be
# registered once. This preset contributes the delegation TOOLS, which resolve
# that host registry.
#
# `workflows` is different — nothing outside an agent reads it — so every row
# that reaches it shares one entry-local realm here, and a consumer left
# outside would resolve a host registry this preset does not populate.
- id: delegation
  name: cordis:group
  group: true
  isolate:
    workflowEngine: true
  config:
    - id: tool-subagent-control
      name: '@deepseek-ai/dsh-tool-subagent-control'

    - id: tool-subagent-list-agents
      name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'

    - id: tool-subagent
      name: '@deepseek-ai/dsh-tool-subagent'
      config:
        provider: spawn
        toolName: subagent
        modelSelectionSettings: true
        backgroundMode: continuable

    # Fork omits model selection so provider/model stay equal to the parent and
    # the inherited history remains eligible for KV Cache reuse. This preset
    # keeps fork continuable; parent and child inherit the same messaging tool,
    # while the parent id and return guidance follow the inherited history.
    - id: tool-subagent-fork
      name: '@deepseek-ai/dsh-tool-subagent'
      config:
        provider: fork
        toolName: subagent_fork
        backgroundMode: continuable

    # Production dsh does not install these optional providers. Install the
    # matching Bundle in this Profile and restart the Host, then copy this
    # preset and remove `disabled` from the matching tool row. Host availability
    # alone grants no tool.
    - id: tool-subagent-codex
      name: '@deepseek-ai/dsh-tool-subagent'
      disabled: true
      config:
        provider: codex
        toolName: subagent_codex
        backgroundMode: one-shot
        maxDepth: provider-managed

    - id: tool-subagent-claude-code
      name: '@deepseek-ai/dsh-tool-subagent'
      disabled: true
      config:
        provider: claude-code
        toolName: subagent_claude_code
        backgroundMode: one-shot
        maxDepth: provider-managed

    - id: workflow-worker-thread
      name: '@deepseek-ai/dsh-workflow-worker-thread'
      config:
        provider: spawn

    - id: tool-workflow
      name: '@deepseek-ai/dsh-tool-workflow'

    - id: tool-ralph
      name: '@deepseek-ai/dsh-tool-ralph'
      config:
        subagentProvider: spawn
        maxRounds: 64

# ── remaining model-facing rows ─────────────────────────────────────────────

- id: tool-ask-user
  name: '@deepseek-ai/dsh-tool-ask-user'

- id: tool-todo
  name: '@deepseek-ai/dsh-tool-todo'
  config:
    allowParallelInProgress: true

# The `web` service and its search provider stay in the host composition; only
# the model-facing tool is per-session.
- id: tool-web
  name: '@deepseek-ai/dsh-tool-web'
  config:
    fetch: true
    searchTimeoutMs: 60000
