Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 258 additions & 0 deletions dsh-presets/standard-bili-auto-off/agent.cordis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
# The `standard` agent preset: the full coding agent, mounted once per process.
#
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
# standing scope; every session naming it joins by scope parentage, so the
# tools and prompt sections registered here cover each joined agent while a
# session's own state stays keyed per Session/Agent inside the plugins. The
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
# preset must not own: the registries themselves, the sandbox and approval
# stack, persistence, and the model route.
#
# A service row here MUST sit inside a group carrying an `isolate` realm.
# Without one it publishes into the root realm, where it is process-global —
# another preset publishing the same name collides, and a host reader would
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
# that at mount. `true` means an entry-local realm: this standing mount's own
# private instance, apart from every other preset's. (A shared label does NOT
# pool instances — `provide()` throws on the second registration under the
# same realm symbol; labels join REALMS, and are not what this file needs.)

# ── identity ────────────────────────────────────────────────────────────────

# The preset's own persona, shadowing the deployment default for this agent.
# `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
- id: persona
name: '@deepseek-ai/dsh-persona'
config:
suffix: Your working directory is {{cwd}}.
prefix: >-
You are a coding agent powered by the {{model}} model.

- 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, and
# `tool-skill` gives them 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'

- 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'

- 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'
# bili (#1772): ACP 压缩接管 — 关闭 dsh 原生自动压缩,保留手动 /compact 与 tool-result-pruner
config:
auto: false

- 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

- id: present
name: '@deepseek-ai/dsh-tool-present'
3 changes: 3 additions & 0 deletions dsh-presets/standard-bili-auto-off/preset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: 标准模式(bili 托管压缩)
description: 与「标准模式」完全一致的编码 Agent;仅关闭 dsh 原生自动压缩,由 bili 的上下文压缩接管,避免双重压缩。手动 /compact 与工具结果修剪保留。
order: 1
21 changes: 19 additions & 2 deletions dsh.bundle.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
- insert:
- id: bili-native
name: billion-context
- id: compaction-basic
# #1772: the shipped `standard` preset mounts `dsh-compaction-basic` with
# auto-compaction ON, which double-compresses alongside bili's own pipeline.
# The compaction row lives inside the preset's agent.cordis.yml — below the
# patch engine's reach (patch rows only match boot-tree rows). The lever we
# CAN turn from a bundle layer is the `agent-presets` row itself (inserted at
# boot-tree top level by dsh-web-app): its config is replaced wholesale here
# to (a) register the in-package `dsh-presets/` directory as an extra roster
# root — trust: system, path resolved from the loader ctx `baseUrl` (profile
# dir), win32 strips the leading slash — and (b) make `standard-bili-auto-off`
# (a byte-copy of `standard` with compaction-basic `auto: false`) the default.
# Shipped + user roots stay enabled (Config schema defaults), every native
# preset remains selectable, and an explicit settings/UI choice still wins
# over this row-config default. Drift is release-managed: the preset ships in
# this package, so every bili upgrade refreshes it.
- id: agent-presets
config:
auto: false
default: standard-bili-auto-off
roots:
- path: !!js "(u => process.platform === 'win32' ? u.pathname.slice(1) : u.pathname)(new URL('node_modules/billion-context/dsh-presets/', baseUrl))"
trust: system
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"README.md",
"dist",
"dsh.bundle.patch.yml",
"dsh-presets",
"hermes-plugin"
],
"pi": {
Expand Down
51 changes: 51 additions & 0 deletions tests/dsh-bundle-preset.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");

// #1772: bili ships a byte-copy of dsh's `standard` preset with
// compaction-basic auto-compaction off, and the bundle layer's
// `agent-presets` config override (a) adds the in-package preset root and
// (b) makes it the default. These guards keep the shipped pieces from
// silently drifting apart.

const patchPath = path.join(ROOT, "dsh.bundle.patch.yml");
const presetDir = path.join(ROOT, "dsh-presets", "standard-bili-auto-off");

test("dsh bundle patch registers the bili preset root as default", () => {
const yaml = fs.readFileSync(patchPath, "utf8");
const row = yaml.split(/^-\s+id:\s*agent-presets\s*$/m);
assert.equal(row.length, 2, "exactly one `agent-presets` row");
const block = row[1]!.split(/^-\s+id:\s*\S+\s*$/m)[0]!;
assert.match(block, /default:\s*standard-bili-auto-off\b/);
// Root path must be resolved from the loader ctx `baseUrl` (profile dir),
// not a baked-in absolute path, and must cover the win32 leading-slash fix.
assert.match(block, /!!js/);
assert.match(block, /node_modules\/billion-context\/dsh-presets\//);
assert.match(block, /win32/);
assert.match(block, /trust:\s*system/);
});

test("shipped preset disables compaction-basic auto, keeps manual /compact and pruner", () => {
const preset = fs.readFileSync(path.join(presetDir, "preset.yml"), "utf8");
assert.match(preset, /^name:\s*标准模式\(bili 托管压缩\)\s*$/m);

const cordis = fs.readFileSync(path.join(presetDir, "agent.cordis.yml"), "utf8");
const compactionBasic = cordis.split(/^ {4}- id:\s*compaction-basic\s*$/m);
assert.equal(compactionBasic.length, 2, "compaction-basic row present");
const block = compactionBasic[1]!.split(/^ {4}- id:\s*\S+\s*$/m)[0]!;
assert.match(block, /auto:\s*false/, "auto compaction off");
assert.match(cordis, /^ {4}- id:\s*command-compact\b/m, "manual /compact stays");
assert.match(cordis, /^ {4}- id:\s*tool-result-pruner\b/m, "tool-result pruner stays");
});

test("npm package ships dsh-presets and the e2e profile mirrors published files", () => {
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8"));
assert.ok((pkg.files as string[]).includes("dsh-presets"));

const e2e = fs.readFileSync(path.join(ROOT, "tests", "e2e", "e2e-native-dsh.test.ts"), "utf8");
assert.match(e2e, /"dsh-presets"/, "wireProfile copies dsh-presets like a registry install");
});
7 changes: 7 additions & 0 deletions tests/e2e/e2e-native-dsh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ function wireProfile(ctx: Ctx): void {
path.join(REPO_ROOT, "dsh.bundle.patch.yml"),
path.join(pkgDir, "dsh.bundle.patch.yml"),
);
// Published shape (#1772): the bundle patch registers the in-package preset
// root, so the profile copy must carry `dsh-presets/` like a registry install.
fs.cpSync(
path.join(REPO_ROOT, "dsh-presets"),
path.join(pkgDir, "dsh-presets"),
{ recursive: true },
);

const biliVersion = JSON.parse(
fs.readFileSync(path.join(REPO_ROOT, "package.json"), "utf8"),
Expand Down
Loading