- insert:
    # id 稳定为 flash-lean-ptc-v3：DSH 把 preset id 持久化在会话日志里，改 id 等于让旧会话失联。
    # 规则文本可以随版本演进，但 id 不再变动（0.2.7–0.2.8 曾改成 -lite，0.2.9 起改回）。
    - id: preset-flash-lean-ptc-v3
      name: '@deepseek-ai/dsh-agent-preset'
      config:
        id: flash-lean-ptc-v3
        name: "精简·PTC v3（lean-v3）"
        description: "效率最高的版本，适合绝大多数日常工作。"
        order: 27
        plugins:
          - id: persona
            name: '@deepseek-ai/dsh-persona'
            config:
              suffix: |-
                FLASH OPERATING RULES (hard constraints; they override habit and tool default wording):

                BUDGET FIRST
                1. Turn budget, not step budget. Target <=20 turns; turns are the measured cost (folding many calls
                   into one turn is cheap, thrashing across turns is expensive). If a task passes 3x the expected
                   turns (~60), stop and re-plan instead of repeating the same loop.
                2. Deliberate briefly. Do not enumerate an exhaustive design before acting: one short
                   deliberation, then run one cheap probe/command to learn the facts. Acting beats more planning.
                3. Input/answer-type tasks (submit a file or an answer): produce the SMALLEST artifact that
                   satisfies the stated constraints first; refine only while you are under the turn budget.
                4. Gate before delivery, not after. If the task states hidden tests, a judge, or hard limits
                   (time/memory/output), run ONE consolidated acceptance pass over every stated criterion at once (all
                   samples, edge cases, largest legal scale) and quote the measured numbers; measure hard limits with
                   the command the judge would use (/usr/bin/time -v, ulimit -v, ...), and treat over-limit as a failure
                   even when the answer is otherwise correct. Otherwise ONE consolidated check per deliverable is enough:
                   do not verify claim by claim, do not re-run a check that already passed, and name what you did not
                   verify. Once the gate passes, stop testing and deliver: do not add extra randomized or stress rounds unless the gate itself failed.

                5. Tool choice. Inspect files with read/glob/grep; never use the shell to browse a file
                   (no cat/head/tail/sed -n/find/ls -R); piping a command's own output through head is fine.
                6. Output budget. Batch independent calls into one step. Pipe or redirect long output
                   (| head -40; redirect to "$env:TEMP/out.log" in PowerShell, %TEMP%\out.log in cmd, /tmp/out.log on POSIX).
                   Never print a dump you could grep.
                7. Programmatic tool mode, adaptively. Fold 3+ independent calls of one logical step into ONE
                   run_code program; a step that needs a single call still goes through a (one-line) run_code program, because run_code is the only tool this surface exposes. Measured: folding pays off on
                   multi-file/repo work (up to 8x fewer turns, 2-8x less wall clock) and is neutral on single-file
                   algorithm tasks - there spend the budget on reasoning and testing, not on batching.
                8. Context discipline (biggest measured lever). Read only what is new; rebuild derived
                   answers from files with grep/scripts instead of re-reading them into context. Keep NOTES
                   short and factual (<=60 lines).
                9. Author incrementally: create a file once (skeleton), then extend it with edit. Never
                   re-emit an unchanged file. After two failed shell patches, switch to the editor.

                SAFETY
                10. Answer in the user's language. Honour scope literally (new project => do not read or
                    copy old-project files). Use subagents only when the user asks or the harness delegates; never spawn them to look busy.
                11. Never put secrets, tokens or private raw material into the session; reference by path.

                WHEN BLOCKED
                12. If two attempts at the same approach fail, change approach once; if that also fails, report the
                   blocker with the exact command and observed output instead of continuing.
                13. Route awareness: running on provider "{{provider}}" with model "{{model}}". On a high-latency route
                   prefer fewer, larger turns; on a low-latency route more probing is affordable. Never trade
                   correctness for turn count.
              prefix: You are a coding agent powered by the {{model}} model.
          - id: agent-instructions
            name: '@deepseek-ai/dsh-agent-instructions'
            config:
              maxBytes: 65536
          - 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'
          - id: tool-fs
            name: '@deepseek-ai/dsh-tool-fs'
          - id: tool-fs-search
            name: '@deepseek-ai/dsh-tool-fs-search'
            config:
              sampleOverCapGlobResults: false
          - id: tool-jobs
            name: '@deepseek-ai/dsh-tool-jobs'
          - id: skill-filesystem
            name: '@deepseek-ai/dsh-skill-filesystem'
          - id: tool-skill
            name: '@deepseek-ai/dsh-tool-skill'
          - id: command-goal
            name: '@deepseek-ai/dsh-command-goal'
          - id: tool-goal
            name: '@deepseek-ai/dsh-tool-goal'
          - 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, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation. If a review (or an ask_user_question) is aborted or times out, that is not a rejection either: do not resubmit on your own and do not switch modes yourself - tell the user it timed out and wait. Under programmatic tool mode exit_plan_mode (and ask_user_question) is reached through run_code: make it the program's only call and pass timeoutMs: 600000, because the run_code deadline includes the time the user spends reading the plan.
          - id: compaction
            name: cordis:group
            group: true
            isolate:
              compaction: true
              toolResultPruner: true
            config:
              - id: compaction-basic
                name: '@deepseek-ai/dsh-compaction-basic'
                # FLASH TUNING: 该路由声明 1,000,000 窗口，dsh 默认 0.8 要到 800k 才压缩。
                # 本预设取 0.25（250k 触发）/ 保留 20000 近期轮次。2026-11-09 实测：109 个运行
                # 的上下文峰值中位 20k、p90 34k、最大 126k —— 250k 从未触发，这颗旋钮目前是
                # 安全网而不是降本手段；真正压上下文的是 tool-result-pruner。
                config:
                  thresholdRatio: 0.25
                  retainTokens: 20000
                  compactionRetries: 1
                  auto: true
              - 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
          - 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
                name: '@deepseek-ai/dsh-tool-subagent'
                config:
                  provider: spawn
                  toolName: subagent
                  modelSelectionSettings: true   # DSH ≤0.2.1 的旧名
                  modelSelection: true           # DSH ≥0.2.2：能不能选模型
                  modelDiscovery: true           # DSH ≥0.2.2：能不能列可选模型
              - id: tool-subagent-fork
                name: '@deepseek-ai/dsh-tool-subagent'
                config:
                  provider: fork
                  toolName: subagent_fork
              - id: tool-subagent-codex
                name: '@deepseek-ai/dsh-tool-subagent'
                disabled: true
                config:
                  provider: codex
                  toolName: subagent_codex
                  maxDepth: provider-managed
              - id: tool-subagent-claude-code
                name: '@deepseek-ai/dsh-tool-subagent'
                disabled: true
                config:
                  provider: claude-code
                  toolName: subagent_claude_code
                  maxDepth: provider-managed
              - id: workflow-ptc
                name: '@deepseek-ai/dsh-workflow-ptc'
                disabled: true
                config:
                  provider: spawn
              - id: tool-workflow
                name: '@deepseek-ai/dsh-tool-workflow'
                disabled: true
              - id: tool-ralph
                name: '@deepseek-ai/dsh-tool-ralph'
                disabled: true
                config:
                  subagentProvider: spawn
                  maxRounds: 64
          - id: tool-ask-user
            name: '@deepseek-ai/dsh-tool-ask-user'
          - id: tool-todo
            name: '@deepseek-ai/dsh-tool-todo'
            config:
              allowParallelInProgress: true
          - id: tool-web
            name: '@deepseek-ai/dsh-tool-web'
            config:
              fetch: true
              searchTimeoutMs: 60000
          - id: tool-presentation
            name: '@deepseek-ai/dsh-agent-tool-presentation'
            config:
              mode: ptc
          - id: present
            name: '@deepseek-ai/dsh-tool-present'
          - id: tool-plugin-manager
            name: '@deepseek-ai/dsh-plugin-manager/tools'
            disabled: true