@linxin666/dsh-liangshen 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 75f5ffa338130e19fc9b70463a5e34d8fdb4e20d
6
- README.zh.md: a6817b19478158365369a3131d4fb237a6e63299
5
+ README.md: fcadb5c2ab0a74c4b61435a869e97b9c1df87e49
6
+ README.zh.md: 2708a979569921f4c3df9bd3507d9bf97b69cdf1
package/README.md CHANGED
@@ -12,29 +12,28 @@ English | [中文](README.zh.md)
12
12
 
13
13
  <p align="center">
14
14
  <strong>Minimal LiangShen Persona & Programmatic Tool Transport for DeepSeek Harness (DSH)</strong><br>
15
- <em>Minimal Persona · Native & run_code Dual Transport · Gentle MCP Paging · Runtime Degradation Fuse · Fact Register</em>
15
+ <em>Minimal Persona · run_code Program Transport · Gentle MCP Paging · Fact Register</em>
16
16
  </p>
17
17
 
18
- An all-in-one plugin for DeepSeek Harness (DSH) Web GUI and desktop client: declares the built-in "LiangShen Mode" preset to the official agent-preset registry upon activation and offers a slot-machine lever toggle alongside the model selector in the blank conversation page. Keeps system prompts concise to a minimal persona with strict operational disciplines while workspace instructions arrive via user turns. Tools operate under a unified presentation contract (defaulting to `both`: cohabiting native tools with `run_code` for batching and fan-outs). Features gentle MCP namespace paging, runtime degradation safety fuses, and a key fact register for long-horizon context retention.
18
+ An all-in-one plugin for DeepSeek Harness (DSH) Web GUI and desktop client: declares the built-in "LiangShen Mode" preset to the official agent-preset registry upon activation and offers a slot-machine lever toggle alongside the model selector in the blank conversation page. Keeps system prompts concise to a minimal persona with strict operational disciplines while workspace instructions arrive via user turns. Tools operate under a unified presentation contract (defaulting to `ptc`: the wire collapses to the official `run_code` transport and every other tool is reached through the generated SDK; `native` keeps the assembled roster alone). Features gentle MCP namespace paging, runtime degradation safety fuses, and a key fact register for long-horizon context retention.
19
19
 
20
20
  ## Why
21
21
 
22
22
  DeepSeek V4.1 Flash is post-trained against its native DSML tool-call surface, and the official scaffold comparison for code-agent benchmarks places a native minimal surface ahead of a programmatic (PTC) one (DeepSWE v1.1: 72.6% native minimal vs 67.6% PTC; Terminal-Bench 2.1: 90.6% vs 85.8%). Real engineering sessions, meanwhile, depend on MCP servers and plugins that a closed four-tool surface cannot reach, while a flat roster carrying every external schema buries the conversation under tool definitions.
23
23
 
24
- LiangShen mode therefore keeps the whole session on one presentation, chosen by the `presentation` key. The shipped default is `both`: the native roster and the `run_code` transport sit co-resident — the direction the official scaffold comparison supports (the native surface leads PTC on DeepSWE v1.1 and Terminal-Bench 2.1: 72.6 against 67.6 and 90.6 against 85.8) — while keeping `run_code` as the specialized outlet for programmatic batch work and wide fan-out. `native` (the roster alone) and `ptc` (the wire collapsed to `run_code`: the cheapest static context but the comparison's lowest-ranked surface) remain one-line opt-ins. The anchoring part (the system prompt) stays a compact persona with an action-triggered working discipline; the capability part is announced from the first user message on as a durable skill-catalog-style injection that names exactly the tools the request opens. External tools matched by the paging patterns (default `mcp__*`) are announced as namespace summaries and stay off the wire — and, under `ptc`, out of the generated SDK, because the page is applied to the registry a program dispatches against — until `tool_activate`, so the static schema surface stays small. The mode makes no overcommitment of benchmark superiority; it guarantees that the declared surface and the request's own wire never disagree.
24
+ LiangShen mode therefore keeps the whole session on one presentation, chosen by the `presentation` key. The shipped default is `ptc`: the wire collapses to the single `run_code` transport and every other tool is reached from inside the program through the generated SDK — the cheapest static context, though the official scaffold comparison ranks that surface below the native one (the native surface leads PTC on DeepSWE v1.1 and Terminal-Bench 2.1: 72.6 against 67.6 and 90.6 against 85.8) — while `native` (the assembled roster alone, no program transport) remains the one-line opt-in. An older profile that still names the removed `both` presentation is refused outright: the SDK dropped the mode, this preset ships no compatibility mapping, and the migration path is to pick `ptc` or `native`. The anchoring part (the system prompt) stays a compact persona with an action-triggered working discipline; the capability part is announced from the first user message on as a durable skill-catalog-style injection that names exactly the tools the request opens. External tools matched by the paging patterns (default `mcp__*`) are announced as namespace summaries and stay off the wire — and, under `ptc`, out of the generated SDK, because the page is applied to the registry a program dispatches against — until `tool_activate`, so the static schema surface stays small. The mode makes no overcommitment of benchmark superiority; it guarantees that the declared surface and the request's own wire never disagree.
25
25
 
26
26
  ## How it works
27
27
 
28
28
  1. `minimal-prompt` narrows every assembled prompt to the persona section — the one-line persona, the mode's standing working discipline (close a repeated hypothesis after two reasoning passes and call an inspection tool instead of speculating; think only about the next concrete operation rather than pre-rehearsing code; emit multiple tool calls concurrently in a single turn for independent inspections; treat shell processes as ephemeral with no directory persistence across calls and use compound commands or explicit workdir for subdirectories; verify against actual tool output during execution; YAGNI and PDCA; no redundant comments), and one appended orientation line, `Your working directory is <cwd>.` read from the session header — so the harness identity, web-surface, tool-guidance, file-reference, and structured-output sections do not reach the model by default; plan mode's `plan:policy` is kept, because that section is the only thing that enforces plan mode (its exit tool stays registered in every mode);
29
29
  2. AGENTS.md-style workspace instructions reach the model through `instructionSource`: by default (`host`) the preset appends no section of its own and leaves the harness's own delivery of those instructions untouched, so they arrive as its user-role messages — one persistent baseline plus incremental additions, replacements, and removals as directories are touched; under `system-prompt` they join the system prompt itself: at assembly time `minimal-prompt` reads the harness's baseline chain (`$DSH_HOME/AGENTS.md`, then `AGENTS.md` / `CLAUDE.md` and their `.local` overlays from the project root down to the session cwd) and appends the content as one `workspace-instructions` section after the stable prefix, under a byte budget that omits broadest files first and truncates the most specific last; the read happens on every assembly, so file edits propagate without durable messages, and the harness's own agent-instructions injections are dropped instead of duplicating the prompt. Subdirectory dynamic rules will subsequently support registered file tools (including `str_replace_editor`) and `run_code` sub-calls reaching target directories; arbitrary bash or program code is not parsed, and automatic discovery of file accesses performed directly within shell commands is not guaranteed;
30
- 3. the wire keeps one presentation for the entire session, selected by `presentation`: `both` (the default) keeps the native roster and the `run_code` transport co-resident, with catalog guidance that direct native calls come first and `run_code` is reserved for programmatic batch computation, wide fan-out, and heavy computation; `native` carries the assembled native roster; `ptc` collapses the wire to `run_code` with every other tool reached through the generated SDK; `ptc` and `both` need a mounted code runtime; without one the plugin declares no presentation at all and the session simply runs the native surface. The legacy `ptcPresentation` key maps onto `ptc`/`native` with a deprecation warning, and the retired `anchorTools` first-turn narrowing no longer engages — setting it warns;
31
- 4. `tool-catalog` appends the tool list as a durable user message after the user's message, preserving complete input and output key parameter semantics (`descriptionMaxLength: 200` caps only the one-line summaries). It names exactly the tools the current request opens — the native roster, plus `run_code` when it is co-resident — and, under tool paging, adds one-line summaries for the namespaces whose tools are held back. Under `ptc` the summaries name namespaces that are genuinely unreachable — neither listed in the request's `tools:sdk` section nor callable from inside a `run_code` program — until `tool_activate`; It republishes only when that surface changes or the published copy left the visible surface (a compaction, a resume);
30
+ 3. the wire keeps one presentation for the entire session, selected by `presentation`: `ptc` (the default) collapses the wire to `run_code` with every other tool reached through the generated SDK, and `native` carries the assembled native roster; `ptc` needs a mounted code runtime — without one the plugin declares no presentation at all and the session simply runs the native surface. The legacy `ptcPresentation` key maps onto `ptc`/`native` with a deprecation warning, and the retired `anchorTools` first-turn narrowing no longer engages — setting it warns;
31
+ 4. `tool-catalog` appends the tool list as a durable user message after the user's message, preserving complete input and output key parameter semantics (`descriptionMaxLength: 200` caps only the one-line summaries). The plugin carries a hand-written one-line summary for each host builtin this preset mounts: a curated tool renders that line whole, so a length cut never slices off the sentence that says what the tool is for, and `descriptionMaxLength` remains the fallback for every tool the table does not name. It names exactly the tools the current request opens — the native roster, or the SDK-reachable projection under `ptc` — and, under tool paging, adds one-line summaries for the namespaces whose tools are held back. Under `ptc` the summaries name namespaces that are genuinely unreachable — neither listed in the request's `tools:sdk` section nor callable from inside a `run_code` program — until `tool_activate`; It republishes only when that surface changes or the published copy left the visible surface (a compaction, a resume);
32
32
  5. gentle tool paging ships on (`pagedToolPatterns: ['mcp__*']`): matching MCP tools stay off the wire and out of the generated SDK, announced as namespace summaries in the catalog, until the model activates one through `tool_activate({ namespace })` — the namespace returns from the next request on, at most three stay active (a fourth evicts the least recently used back to summary). Activation state is rebuilt from the durable event stream across compactions and resumes;
33
33
  6. a minimal working-context line — plan-mode state, active paged namespaces, and in-progress todos — is injected at the tail of the latest message only when its sources are readable, keeping current state inside the model's local attention window; runtime contexts (the sandbox and approval snapshots) and the skill catalog flow as in Standard mode;
34
34
  7. the catalog groups the tools of an activated paged family under a `namespace `<name>` (activated):` heading instead of scattering one server's tools through the alphabetical list, while every non-paged tool keeps its flat entry;
35
35
  8. `maxResidentTokens` (default 8000) estimates the always-on-wire surface and warns once when it is crossed, naming the heaviest tools and `pagedToolPatterns` as the remedy. The threshold was re-estimated for V4.1 (its KV cache is a quarter of V4-Flash's, so the same schema load occupies a quarter of the sparse-index slots and the budget moved from 6000 to 8000), still calibrated above the shipped roster so only real growth trips it. The guard never truncates: silently dropping a tool the session needs would trade a measurable context cost for an unmeasurable capability loss.
36
- 9. a runtime degeneration circuit breaker (`guard`) folds the session event stream each step and fires once per episode on either signal — a stall (consecutive zero-output long-reasoning steps) or an echo (the same tool call failing repeatedly with identical arguments) — injecting a breaker message and — for a stall only, where the cause is an over-large reasoning budget — stepping the reasoning effort one notch down for the next few requests (max → high, and high is left alone because it already sits in the model's measured effort sweet spot); an echo fires the message alone, since its cause is a broken call rather than an over-large budget; with no signal it never rewrites a request, so the route's explicit effort and the prefix cache stay untouched. This is the outside force the persona's reflection fuse cannot be (DSH discussion #5976);
37
- 10. a key-fact register (`fact_register`) lets the model pin a hard user constraint, a confirmed decision, or a failed path as one short line; the register is folded from the durable event stream and rides the `[Working Context: ...]` line — the surface that lands inside the guaranteed local attention window every step — as the counter to V4.1's long-session forgetting.
36
+ 9. a key-fact register (`fact_register`) lets the model pin a hard user constraint, a confirmed decision, or a failed path as one short line; the register is folded from the durable event stream and rides the `[Working Context: ...]` line — the surface that lands inside the guaranteed local attention window every step — as the counter to V4.1's long-session forgetting.
38
37
 
39
38
  ## Security model
40
39
 
@@ -66,8 +65,8 @@ The preset-local plugins are configured in `agent.cordis.yml`:
66
65
  | `keepPlanPolicy` | `true` | Keep plan mode's `plan:policy` section in the otherwise one-line system prompt. Set `false` for the strict one-line surface, which leaves plan mode with no policy text behind it. |
67
66
  | `instructionSource` | `host` | Where workspace instructions reach the model. `host` (the default) appends no section of its own and leaves the harness's agent-instructions injection untouched, so the instructions arrive as the harness's own user-role messages: one persistent baseline plus incremental additions, replacements, and removals as directories are touched; `system-prompt` reads the AGENTS.md-style chain at assembly time and appends it to the system prompt (the harness's own injections are dropped); `hint` replaces the first injection with a one-time non-imperative reference-file hint and drops later ones. |
68
67
  | `instructionMaxBytes` | `65536` | Byte budget for the rendered workspace-instructions section, used only in `system-prompt` mode: broadest files are omitted first, the most specific file is truncated last. |
69
- | `descriptionMaxLength` | `200` | Cap for one tool's one-line summary in the injected catalog. Complete key parameter semantics remain fully preserved. |
70
- | `presentation` | `both` | Wire presentation for the whole session. `both` (the shipped default) keeps the full native roster and adds `run_code` co-resident (direct native calls first, the transport for programmatic batch computation and wide fan-out); `native` keeps the assembled native roster; `ptc` collapses the wire to `run_code`. `ptc` and `both` need a mounted code runtime and degrade to `native` with a one-time warning when missing. |
68
+ | `descriptionMaxLength` | `200` | Cap for one tool's one-line summary in the injected catalog, applied to every tool the curated table does not name. A curated host builtin renders its hand-written line whole. Complete key parameter semantics remain fully preserved. |
69
+ | `presentation` | `ptc` | Wire presentation for the whole session. `ptc` (the shipped default) collapses the wire to `run_code` with every other tool reached through the generated SDK; `native` keeps the assembled native roster. `ptc` needs a mounted code runtime and degrades to `native` with a one-time warning when missing. The removed `both` mode is not accepted: an old profile naming it fails registration, so migrate the key to `ptc` or `native`. |
71
70
  | `pagedToolPatterns` | `['mcp__*']` | Gentle paging ships on: matching MCP tools are held back from the wire and the generated SDK until activated through `tool_activate({ namespace })`. Held-back namespaces appear in the catalog as one-line summaries. At most three paged namespaces stay active at once, rebuilt from the event stream. |
72
71
  | `maxResidentTokens` | `8000` | Estimated-token ceiling for the always-on-wire surface (the serialized schemas at roughly four characters per token), re-estimated for V4.1's compressed KV cache and still calibrated above the shipped roster so it flags real growth rather than the factory configuration. Crossing it warns once, names the heaviest tools, and points at `pagedToolPatterns`; it never truncates the roster. |
73
72
  | `ptcPresentation` | (retired) | Legacy alias: `true` maps to `presentation: 'ptc'` and `false` to `'native'`, both with a deprecation warning. |
@@ -94,7 +93,7 @@ Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as th
94
93
  Export the session JSONL and inspect `request/header`:
95
94
 
96
95
  - with `instructionSource: host` the first header's `system` should be exactly the persona block (the minimal persona, the working-discipline list, and the workspace line `Your working directory is <cwd>.`) plus plan mode's policy while plan mode is on — while the AGENTS.md chain arrives as the harness's own user-role message; under `instructionSource: system-prompt` the `system` carries one extra `workspace-instructions` section instead;
97
- - every header keeps the same presentation for the whole session: under the default `presentation: 'both'` the wire carries the native roster plus `run_code`, and no turn boundary ever collapses the wire further;
96
+ - every header keeps the same presentation for the whole session: under the default `presentation: 'ptc'` the wire collapses to `run_code`, and no turn boundary ever re-expands it;
98
97
  - the admitted messages hold one `plugin`-sourced message from `liangshen-tool-catalog` after the user message, naming exactly the tools the request opens by argument signature; tools held back by paging appear as one-line namespace summaries instead;
99
98
  - under `ptc` an unactivated namespace is absent from the request's `tools:sdk` section and cannot be called from inside a `run_code` program — from the FIRST request on, not one request later;
100
99
  - after `tool_activate({ namespace })` succeeds, that namespace's tools join the wire from the next request, and no more than three paged namespaces are active at once;
@@ -109,7 +108,7 @@ When validating mode behavior and evaluating performance, verification tiers mus
109
108
  - **Real inference probe**: Verifies only transport connectivity and minimal model response capability to specific formats (e.g. using a headless probe to verify output parsing); a single successful probe demonstrates absence of blockers, but never that mode integration has succeeded.
110
109
  - **Mode integration pass**: Requires full session verification of complete headers, the configured presentation behavior, paged activation and eviction, SDK parameter semantics under `run_code`, and sandbox policy enforcement.
111
110
  - **Statistical improvement**: Must be evaluated across multiple comparative benchmark rounds in an isolated environment with recorded fixed routes and source hashes, evaluating task completion rate, tool failure rate, rule violation rate, human intervention frequency, and time/token costs. Single or few smoke runs do not constitute evidence of performance improvement.
112
- 2. **Benchmark tooling**: the isolated runner is `packages/dsh-liangshen/tools/benchmark-live-run.mjs`. It materializes the evaluated preset into a temporary directory and declares it from the run's own agent-preset registry through a variant patch, redirects session persistence into the run directory, and records a baseline (repository commit, shipped preset hash, DSH version, fixed route, task revision) with every run. The candidate matrix isolates the persona and the presentation strategy: `B` (shipped defaults), `P` (candidate persona), the presentation arms `T` (candidate persona, PTC from the first turn) and `N` (candidate persona, full native roster throughout), and `M` (the bundle's official Minimal preset, an external reference rather than a single-factor arm). Run one smoke case with `node tools/benchmark-live-run.mjs --variant B`, or the bounded matrix over the seed corpus with `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`; aggregate the run records in a results directory with `node tools/benchmark-report.mjs .benchmark-results`, which reports per-group success rates with Wilson intervals, paired per-task deltas with confidence intervals, token totals, cost in the price book's currency, model tool errors and transport failures separately, research calls and the inspections preceding the first write, infrastructure failures separately, and the recorded baseline. Cost is CNY because the route bills in CNY, and `tools/prices/deepseek-flash.json` carries the published off-peak row: a peak-hour run costs double what the book records. A budget the run cannot price is refused rather than silently disarmed. A tool result whose error carries a `WEB_*` code counts as a transport failure, so a workspace that could not reach a host never reads as a model that guessed. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
111
+ 2. **Benchmark tooling**: the isolated runner is `packages/dsh-liangshen/tools/benchmark-live-run.mjs`. It materializes the evaluated preset into a temporary directory and declares it from the run's own agent-preset registry through a variant patch, redirects session persistence into the run directory, and records a baseline (repository commit, shipped preset hash, DSH version, fixed route, task revision) with every run. The candidate matrix isolates the persona and the presentation strategy: `B` (shipped defaults), `P` (candidate persona), `N` (candidate persona, full native roster throughout), and `M` (the bundle's official Minimal preset, an external reference rather than a single-factor arm); the retired `both` presentation arm left with the SDK mode it measured. Run one smoke case with `node tools/benchmark-live-run.mjs --variant B`, or the bounded matrix over the seed corpus with `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`; aggregate the run records in a results directory with `node tools/benchmark-report.mjs .benchmark-results`, which reports per-group success rates with Wilson intervals, paired per-task deltas with confidence intervals, token totals, cost in the price book's currency, model tool errors and transport failures separately, research calls and the inspections preceding the first write, infrastructure failures separately, and the recorded baseline. Cost is CNY because the route bills in CNY, and `tools/prices/deepseek-flash.json` carries the published off-peak row: a peak-hour run costs double what the book records. A budget the run cannot price is refused rather than silently disarmed. A tool result whose error carries a `WEB_*` code counts as a transport failure, so a workspace that could not reach a host never reads as a model that guessed. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
113
112
 
114
113
  ## Configuration
115
114
 
@@ -117,13 +116,8 @@ When validating mode behavior and evaluating performance, verification tiers mus
117
116
  | --- | --- | --- |
118
117
  | `enabled` | `true` | Master switch: when false, the preset is not declared and the announcement does not run. |
119
118
  | `announceToAgent` | `false` | Opt-in: when true, a system-prompt section announces the plugin. Off by default so agent system prompts stay clean. |
120
- | `presentation` | `both` | Wire presentation written into the `tool-catalog` row of the preset this plugin declares: `both` (default) keeps the roster and transport co-resident; `native` keeps the assembled roster; `ptc` collapses the wire to `run_code`. A change re-declares the preset as soon as the Host commits it, so the next session picks it up; a session that already started keeps the composition it declared. |
121
- | `dispatcher` | `true` | Identity switch: when true (the shipped default), the declared preset appends the dispatcher rules section after the persona — complexity triage (L0/L1 direct, L2 through the full flow), an interview before planning on an L2 task, and delegation with layer-by-layer review and acceptance. Switching it off returns the session to the bare persona with its working discipline. It is orthogonal to `presentation`: `presentation` decides the tool surface, `dispatcher` decides the identity and the process discipline. |
122
- | `guardEnabled` | `true` | Master switch for the runtime degeneration circuit breaker: detects consecutive zero-output long reasoning and repeated identical-argument failures, injecting a breaker message and stepping the reasoning effort down when it fires; disabled means requests are never touched. |
123
- | `guardSensitivity` | `balanced` | Sensitivity preset scaling every breaker threshold: `conservative` (fewer interruptions, x1.5), `balanced` (the calibrated defaults), `aggressive` (fires earlier, x0.5). |
124
- | `guardStallReasoningChars` | (unset) | **Override** for the per-step runaway floor. Left unset, the floor adapts to the reasoning effort (8000 at max / 12000 at high / 20000 at low, calibrated against V4.1's official 384K max output) and is then scaled by `guardSensitivity`; setting this field wins over the adaptive table for every effort level. |
125
- | `guardGlobalStallCap` | (unset) | **Override** for the slow-burn step count. Left unset, the cap scales with the sensitivity preset (4 at balanced); setting this field wins. |
126
- | `guardEchoFailures` | (unset) | **Override** for the echo ladder: identical-argument failures of the same tool in a row that fire the breaker. Left unset, the count scales with the sensitivity preset (3 at balanced). All guard fields reach a session through the declared preset, exactly like `presentation`. |
119
+ | `presentation` | `ptc` | Wire presentation written into the `tool-catalog` row of the preset this plugin declares: `ptc` (default) collapses the wire to `run_code` with every other tool reached through the generated SDK; `native` keeps the assembled roster. A change re-declares the preset as soon as the Host commits it, so the next session picks it up; a session that already started keeps the composition it declared. The removed `both` mode is rejected at registration — migrate an old profile to `ptc` or `native`. |
120
+ | `dispatcher` | `true` | Identity switch: when true (the shipped default), the declared preset appends the dispatcher rules section after the persona — complexity triage (L0/L1 direct, L2 through the full flow), the R0.5 compatibility gate that refuses Agent Teams, an interview before planning on an L2 task, delegation with layer-by-layer review and acceptance, and task tracking in `todo_write` — then a local English supplement with the interview additions and the one rule the reference text does not carry: a task-board card is not a substitute for a dispatch. Switching it off returns the session to the bare persona with its working discipline. It is orthogonal to `presentation`: `presentation` decides the tool surface, `dispatcher` decides the identity and the process discipline. |
127
121
 
128
122
  All fields are editable in the web settings surface (plugin config) or through the profile patch (`dsh plugin` / `cordis.patch.yml`). Under the 0.1.7 settings contract a plugin's own Config IS its settings page: the Host serves one form per profile entry (the entry id `liangshen`, or the aggregate's generated `web-ui-liangshen` row) and every field is declared `volatile()`, so a write is committed into the running plugin instead of remounting its row. The preset-shaping presentation field then reaches a session through the declaration: the plugin applies the committed values to the composition rows of `presets/liangshen/agent.cordis.yml` and re-declares the preset, so the settings surface — not the bundled file — is what the operator's sessions actually run. A row or key the composition does not carry is never invented: the overlay only narrows the shipped configuration. A change applies to sessions created after it; a session that already started keeps the composition it declared, because the registry refuses to recompose a started conversation.
129
123
 
@@ -131,15 +125,15 @@ All fields are editable in the web settings surface (plugin config) or through t
131
125
 
132
126
  - The system prompt is stable for the whole session: the persona block (persona, working discipline, workspace directory), plus plan mode's policy while plan mode is on, plus the workspace-instructions section in `system-prompt` mode. Nothing is appended after a tool call, and no output-token cap is applied;
133
127
  - In `system-prompt` mode the workspace-instructions section is re-read at every assembly, so instruction-file edits propagate on the next request without a durable message; the section renders last, after the stable prefix, so the cache prefix stays intact. Subdirectory dynamic rules will subsequently support registered file tools (including `str_replace_editor`) and `run_code` sub-calls reaching target directories; arbitrary bash or program code is not parsed, and automatic discovery of file accesses performed directly within shell commands is not guaranteed;
134
- - The wire keeps one presentation for the entire session with no turn-boundary transition: `both` (default) keeps the native roster and one `run_code` co-resident, `native` carries the assembled roster, and `ptc` collapses the wire to the single `run_code` with every other tool reached through the generated SDK;
128
+ - The wire keeps one presentation for the entire session with no turn-boundary transition: `ptc` (default) collapses the wire to the single `run_code` with every other tool reached through the generated SDK, and `native` carries the assembled roster;
135
129
  - The injected catalog is durable: it is written once per session, plus one replacement when the tool surface changes (a paged activation, a presentation change) or a compaction shadows the published copy, and it stays in the history for later requests;
136
130
  - A step whose prompt assembly was not observed injects nothing — the catalog is never guessed from a stale view;
137
131
  - A composition exposing none of the accepted persona section names (`deployment:persona-prefix`, `deployment:persona`, `persona`) keeps the assembled prompt and warns once instead of sending an empty system prompt;
138
132
  - Plan mode is supported through its `plan:policy` section; with `keepPlanPolicy: false` the mode keeps its tool but loses the policy text that enforces it;
139
- - Paged tools (default pattern `mcp__*`) stay off the wire until the model activates their namespace through `tool_activate`; at most three paged namespaces are active at once, activating a fourth evicts the least recently used one back to its summary, and activation state is rebuilt from the durable event stream after compactions and resumes. Under `ptc` the page also restricts the scope's tool registry, so an unactivated namespace is unreachable from inside a `run_code` program too; under `both` no registry restriction is installed, so a paged namespace stays reachable from inside a program even before activation, because the native wire itself carries it;
133
+ - Paged tools (default pattern `mcp__*`) stay off the wire until the model activates their namespace through `tool_activate`; at most three paged namespaces are active at once, activating a fourth evicts the least recently used one back to its summary, and activation state is rebuilt from the durable event stream after compactions and resumes. Under `ptc` the page also restricts the scope's tool registry, so an unactivated namespace is unreachable from inside a `run_code` program too;
140
134
  - The working-context line is injected only when its sources (plan-mode state, active paged namespaces, in-progress todos) are readable, and omitted otherwise;
141
135
  - Tool results are pruned once they exceed 4096 characters, keeping a 2048-character head and a 1024-character tail (guarding the sparse-index slots while preserving the error tail and exit code), so oversized outputs do not crowd the context;
142
- - `run_code` needs a mounted code runtime (the shipped web and headless compositions mount `dsh-code-runtime-worker-thread`); without one, `ptc` and `both` declare nothing and the session runs the native surface;
136
+ - `run_code` needs a mounted code runtime (the shipped web and headless compositions mount `dsh-code-runtime-worker-thread`); without one, `ptc` declares nothing and the session runs the native surface;
143
137
  - The spawn delegation row opts into child-model selection (`modelSelectionSettings: true`), so the settings page's subagent model-selection toggle is honored under this preset: the model sees `provider` / `model` / `reasoning_effort` on `subagent` and the `list_subagent_models` discovery tool, and an explicit route is checked against the Session's allowed list;
144
138
  - Exactly one delegation row in a composition scope may opt in. The upstream opt-in registers `list_subagent_models` under a fixed tool name in the scope the row composes into, and the registry refuses a second registration of that name in one scope, so a second opt-in row fails the whole session instead of adding a second opt-in. The fork row therefore ships without the flag (as the builtin Standard, PTC, and Cordis presets ship it), and the composition test counts the opt-ins structurally;
145
139
  - The roster does not publish the `workflow` tool, while the workflow engine stays mounted for `ralph`;
@@ -148,7 +142,7 @@ All fields are editable in the web settings surface (plugin config) or through t
148
142
  - The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
149
143
  - The plugin makes no network requests and adds no telemetry;
150
144
  - Do not switch presets mid-conversation;
151
- - Requires DSH 0.2.0-rc.2+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
145
+ - Requires DSH 0.2.1-rc.2+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
152
146
 
153
147
  ## License
154
148
 
package/README.zh.md CHANGED
@@ -12,29 +12,28 @@
12
12
 
13
13
  <p align="center">
14
14
  <strong>DeepSeek Harness(DSH)官方 Web GUI 与桌面客户端极简 Agent 预设与高效代码工具传输引擎</strong><br>
15
- <em>极简 Persona 系统提示词 · 原生直调与 run_code 混合传输 · MCP 工具温和分页 · 运行时退化熔断 · 关键事实登记簿</em>
15
+ <em>极简 Persona 系统提示词 · run_code 程序化工具传输 · MCP 工具温和分页 · 关键事实登记簿</em>
16
16
  </p>
17
17
 
18
- 把梁神模式做成 DSH 全家桶里的一键安装插件:Host 半区在激活时把内置 preset 直接声明给 harness 的 agent-preset registry(声明即启用),新建会话即可在预设选择器中选择「梁神模式」,浏览器半区还在新建会话页的模型选择器旁提供一台老虎机拨杆来开关该模式。该 preset 让系统提示词保持极简 persona——外加本模式的固定工作纪律与会话工作区目录——AGENTS.md 类工作区指令交由 harness 以自己的 user 角色消息送达;工具面则从第一条用户消息起作为持久 user 消息注入在用户消息之后——形状与 harness 注入 skill 目录一致,且只宣告该次请求实际开放的工具。wire 在整个会话中保持由 `presentation` 选定的同一种呈现(出厂默认 `presentation: 'both'`):原生清单与 `run_code` 传输工具同驻——日常单步工作走原生直调,程序化批处理、并发扇出与多步数据塑形走 `run_code`;未挂载 code runtime 的部署回退为原生呈现并一次性告警,而不是宣告一个该请求无法承载的传输工具。被分页扣留的匹配工具(默认 `mcp__*`)在激活前不可达:它们以命名空间摘要出现在目录里,`ptc` 下同时不出现在生成的 SDK 中——分页是注册表级限制,不只是 wire 过滤。`tool_activate` 把一个命名空间挂回整个可达面。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
18
+ 把梁神模式做成 DSH 全家桶里的一键安装插件:Host 半区在激活时把内置 preset 直接声明给 harness 的 agent-preset registry(声明即启用),新建会话即可在预设选择器中选择「梁神模式」,浏览器半区还在新建会话页的模型选择器旁提供一台老虎机拨杆来开关该模式。该 preset 让系统提示词保持极简 persona——外加本模式的固定工作纪律与会话工作区目录——AGENTS.md 类工作区指令交由 harness 以自己的 user 角色消息送达;工具面则从第一条用户消息起作为持久 user 消息注入在用户消息之后——形状与 harness 注入 skill 目录一致,且只宣告该次请求实际开放的工具。wire 在整个会话中保持由 `presentation` 选定的同一种呈现(出厂默认 `presentation: 'ptc'`):wire 收拢为唯一的 `run_code` 传输工具,其余工具经生成的 SDK 在程序内调用;未挂载 code runtime 的部署回退为原生呈现并一次性告警,而不是宣告一个该请求无法承载的传输工具。被分页扣留的匹配工具(默认 `mcp__*`)在激活前不可达:它们以命名空间摘要出现在目录里,`ptc` 下同时不出现在生成的 SDK 中——分页是注册表级限制,不只是 wire 过滤。`tool_activate` 把一个命名空间挂回整个可达面。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
19
19
 
20
20
  ## 原理
21
21
 
22
22
  DeepSeek V4.1 Flash 的后训练直接对齐其原生 DSML 工具调用面,官方脚手架横评中代码 Agent 基准上原生极简面领先于程序化(PTC)面(DeepSWE v1.1:72.6% 对 67.6%;Terminal-Bench 2.1:90.6% 对 85.8%)。而真实工程会话依赖 MCP 服务与插件生态——封闭的 4 工具极简面在物理上够不到它们,无边界平铺的全量清单又会把会话内容埋在工具定义之下。
23
23
 
24
- 梁神模式因此在整个会话中保持由 `presentation` 选定的同一种呈现。出厂默认为 `both`:原生清单与 `run_code` 传输工具同驻——这是官方横评数据支持的方向(原生面在 DeepSWE v1.1 与 Terminal-Bench 2.1 上均领先 PTC:72.6% 对 67.6%、90.6% 对 85.8%),同时保留 `run_code` 作为程序化批处理与并发扇出的特化出口。`native`(去掉传输工具的纯原生面)与 `ptc`(wire 收拢为 `run_code`,静态上下文最省但官方横评垫底的呈现)都保留为一行切换的选项。被分页模式匹配的外部工具(默认 `mcp__*`)先以命名空间摘要宣告,`tool_activate` 激活前既不在 wire 上、`ptc` 下也不在生成的 SDK 中(分页施加在程序分派所依据的注册表上),静态 Schema 面因此保持小巧。本模式不承诺基准领先,只保证「目录宣告的面」与「请求 wire 实际携带的面」永不矛盾。
24
+ 梁神模式因此在整个会话中保持由 `presentation` 选定的同一种呈现。出厂默认为 `ptc`:wire 收拢为唯一的 `run_code` 传输工具,其余工具经生成的 SDK 在程序内调用——静态上下文最省,但官方横评把该面排在原生面之后(原生面在 DeepSWE v1.1 与 Terminal-Bench 2.1 上均领先 PTC:72.6% 对 67.6%、90.6% 对 85.8%);`native`(仅组装出的原生清单、无程序化传输)保留为一行切换的选项。官方 SDK 已删除 `both` 呈现,本插件不做兼容映射:旧配置里仍写着 `both` 的 profile 会被直接拒绝注册,迁移路径是把它改为 `ptc` 或 `native`。被分页模式匹配的外部工具(默认 `mcp__*`)先以命名空间摘要宣告,`tool_activate` 激活前既不在 wire 上、`ptc` 下也不在生成的 SDK 中(分页施加在程序分派所依据的注册表上),静态 Schema 面因此保持小巧。本模式不承诺基准领先,只保证「目录宣告的面」与「请求 wire 实际携带的面」永不矛盾。
25
25
 
26
26
  ## 工作机制
27
27
 
28
28
  1. `minimal-prompt` 把每次组装出的提示词收窄到 persona 一段——一行 persona、本模式的固定工作纪律(同一假设的思考推演不超过两轮,缺少事实时立即闭合思考并调用检查工具而非空想;思考只决定下一步具体操作,不预演完整代码实现;多处独立检查或搜索在单轮内并发发射多个工具调用;Shell 为无状态进程,跨调用目录不保留,子目录操作使用复合命令或显式 workdir;正确性一律在执行阶段以工具实际输出验证;YAGNI 与 PDCA;不写冗余注释)、以及一行从会话头读取的方位信息 `Your working directory is <cwd>.`——因此 harness identity、web surface、工具用法、文件引用与结构化输出等 section 默认不会到达模型;plan mode 的 `plan:policy` 保留,因为该 section 是 plan mode 唯一的执行依据(它的退出工具在任何模式下都保持注册);
29
29
  2. AGENTS.md 类工作区指令经 `instructionSource` 送达模型:默认(`host`)下 preset 不追加任何自有段,也不改动宿主自己的送达,工作区指令以宿主的 user 角色消息抵达——一条持久基线,加上触碰目录后的增量、替换与移除;`system-prompt` 下它们直接进入系统提示词本身:组装时 `minimal-prompt` 读取 harness 的基线链(`$DSH_HOME/AGENTS.md`,再从项目根到会话 cwd 沿途的 `AGENTS.md` / `CLAUDE.md` 及其 `.local` 覆盖层),把内容作为一段 `workspace-instructions` 追加在稳定前缀之后,受字节预算约束——放不下时先省略最宽的文件、最后才截断最具体的文件;读取在每次组装时都发生,文件改动无需持久消息即可在下次请求生效,harness 自己的 agent-instructions 注入则被丢弃以免与提示词重复。工作区子目录动态规则后续将支持注册文件工具(含 `str_replace_editor`)及 `run_code` 内子调用触达的目录;不解析任意 bash/program 代码,不保证 shell 自行文件访问的自动发现;
30
- 3. wire 在整个会话中保持由 `presentation` 选定的同一种呈现:`both`(出厂默认)让原生清单与 `run_code` 传输工具同驻,目录文案明确「原生直调优先、`run_code` 仅用于程序化批处理/并发扇出/重计算」;`native` 携带组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`、其余工具经生成的 SDK 调用;`ptc` 与 `both` 需要挂载的 code runtime;没有时插件不做声明,会话直接运行原生工具面。旧键 `ptcPresentation` 映射到 `ptc`/`native` 并发出弃用告警,已退役的 `anchorTools` 首回合收窄不再生效——设置它会收到告警;
31
- 4. `tool-catalog` 把工具清单作为持久 user 消息追加在用户消息之后,保留完整输入输出关键参数语义(`descriptionMaxLength: 200` 仅限制一行摘要长度)。目录只宣告该次请求实际开放的工具——原生清单加上同驻时的 `run_code`——并在分页开启时为被扣留的命名空间附上一行摘要;`ptc` 下这些摘要代表真正不可达的命名空间——既不在该请求的 `tools:sdk` 段中,也不能在 `run_code` 程序内调用——直到 `tool_activate`;只在工具面变化、或已发布副本离开可见面(压缩、恢复)时重发;
30
+ 3. wire 在整个会话中保持由 `presentation` 选定的同一种呈现:`ptc`(出厂默认)把 wire 收拢为 `run_code`、其余工具经生成的 SDK 调用;`native` 携带组装出的原生清单;`ptc` 需要挂载的 code runtime;没有时插件不做声明,会话直接运行原生工具面。旧键 `ptcPresentation` 映射到 `ptc`/`native` 并发出弃用告警,已退役的 `anchorTools` 首回合收窄不再生效——设置它会收到告警;
31
+ 4. `tool-catalog` 把工具清单作为持久 user 消息追加在用户消息之后,保留完整输入输出关键参数语义(`descriptionMaxLength: 200` 仅限制一行摘要长度)。插件为该预设挂载的每个宿主内置工具配有一行手写短描述:被策展的工具直接使用整行策展文,长度截断不会切掉说明工具用途的那句话,`descriptionMaxLength` 只作为未被策展工具的兜底。目录只宣告该次请求实际开放的工具——原生清单,或 `ptc` 下经 SDK 可达的投影——并在分页开启时为被扣留的命名空间附上一行摘要;`ptc` 下这些摘要代表真正不可达的命名空间——既不在该请求的 `tools:sdk` 段中,也不能在 `run_code` 程序内调用——直到 `tool_activate`;只在工具面变化、或已发布副本离开可见面(压缩、恢复)时重发;
32
32
  5. 温和分页出厂开启(`pagedToolPatterns: ['mcp__*']`):匹配的 MCP 工具被扣留在 wire 与生成的 SDK 之外,以命名空间摘要出现在目录中,直到模型经 `tool_activate({ namespace })` 激活——激活的命名空间从下一个请求起重新可达,最多保持三个已激活的分页命名空间(激活第四个时将最久未用的逐回摘要状态)。激活状态从持久事件流重建,压缩与恢复均可还原;
33
33
  6. 最小版 working-context 行——plan-mode 状态、已激活的分页命名空间、进行中的 todo——只在其来源可读时注入到最新消息尾部,让当前状态落在模型的局部注意力窗口内;运行时上下文(sandbox 与 approval 快照)与 skill 目录按 Standard 模式正常注入;
34
34
  7. 目录把已激活分页家族的工具归在 `namespace `<名称>` (activated):` 标题之下,而不是把一个服务端的工具散落在字母序清单里;未被分页的工具仍保持扁平条目;
35
35
  8. `maxResidentTokens`(默认 8000)估算常驻 wire 面并在超过时告警一次,列出最重的工具并把 `pagedToolPatterns` 指为处置手段。该阈值按 V4.1 的 KV 压缩重新校准(其 KV cache 为 V4-Flash 的 1/4,同样的 schema 负载只占 1/4 的稀疏索引槽位,阈值由 6000 上调至 8000),仍校准在出厂清单之上,用于发现真实增长而非出厂配置本身。该守卫从不截断:静默丢掉会话需要的工具,等于用可度量的上下文成本换取不可度量的能力损失。
36
- 9. 运行时退化熔断器(`guard`)每步从会话事件流折叠信号,在两类形态下每个 episode 触发一次——停摆(连续零产出的长思考回合)或空转(同一工具以相同参数连续失败)——注入熔断消息;并且仅在停摆信号下——其成因是推理预算过大——在接下来几个请求内把推理档位临时下调一档(max → high,high 档保持不变,因为它已处于模型实测的推理甜区);空转信号只注入消息,因为它的成因是调用本身失效而非预算过大;无信号时它从不改写任何请求,路由的显式档位与前缀缓存都不受影响。这是 persona 反思熔断无法充当的外力(DSH discussion #5976);
37
- 10. 关键事实登记簿(`fact_register`)让模型把用户硬性约束、已确认的架构决策、失败过的路径登记为一行短事实;登记簿从持久事件流折叠,随 `[Working Context: ...]` 行投射——每步都落在保证命中的局部注意力窗口内——以此对抗 V4.1 的长会话遗忘。
36
+ 9. 关键事实登记簿(`fact_register`)让模型把用户硬性约束、已确认的架构决策、失败过的路径登记为一行短事实;登记簿从持久事件流折叠,随 `[Working Context: ...]` 行投射——每步都落在保证命中的局部注意力窗口内——以此对抗 V4.1 的长会话遗忘。
38
37
 
39
38
  ## 安全模型
40
39
 
@@ -66,8 +65,8 @@ DeepSeek V4.1 Flash 的后训练直接对齐其原生 DSML 工具调用面,官
66
65
  | `keepPlanPolicy` | `true` | 在只有一行 persona 的系统提示词中保留 plan mode 的 `plan:policy` 段。置 `false` 得到严格的一行表面,此时 plan mode 背后没有任何策略文本。 |
67
66
  | `instructionSource` | `host` | 工作区指令送达模型的方式。`host`(默认)不追加任何自有段,也不改动宿主的 agent-instructions 注入,工作区指令以宿主自己的 user 角色消息送达:一条持久基线,加上触碰目录后的增量、替换与移除;`system-prompt` 在组装时读取 AGENTS.md 链并追加进系统提示词(harness 自己的注入被丢弃);`hint` 把首次注入替换为一次性的、非命令式的参考文件提示,后续注入丢弃。 |
68
67
  | `instructionMaxBytes` | `65536` | 渲染后的 workspace-instructions 段的字节预算,仅在 `system-prompt` 模式下生效:最宽的文件先被省略,最具体的文件最后被截断。 |
69
- | `descriptionMaxLength` | `200` | 注入目录中单个工具一行摘要的长度上限。完整关键参数语义保持完整。 |
70
- | `presentation` | `both` | 整个会话的 wire 呈现方式。`both`(出厂默认)保持完整原生清单并同驻一个 `run_code`(原生直调优先、传输工具用于程序化批处理与并发扇出);`native` 保持组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`,其余工具经生成的 SDK 调用。`ptc` 与 `both` 需要挂载的 code runtime;没有时插件根本不做声明,会话直接运行原生工具面。 |
68
+ | `descriptionMaxLength` | `200` | 注入目录中单个工具一行摘要的长度上限,作用于所有未被策展表覆盖的工具;被策展的宿主内置工具直接使用整行手写短描述。完整关键参数语义保持完整。 |
69
+ | `presentation` | `ptc` | 整个会话的 wire 呈现方式。`ptc`(出厂默认)把 wire 收拢为 `run_code`,其余工具经生成的 SDK 调用;`native` 保持组装出的原生清单。`ptc` 需要挂载的 code runtime;没有时插件根本不做声明,会话直接运行原生工具面。已删除的 `both` 取值不被接受:旧 profile 写明它会在注册时被拒绝,请迁移为 `ptc` 或 `native`。 |
71
70
  | `pagedToolPatterns` | `['mcp__*']` | 出厂开启温和分页:命中的 MCP 工具被扣留在 wire 与生成的 SDK 之外,直到模型通过 `tool_activate({ namespace })` 激活其命名空间。被扣留的命名空间在目录中以一行摘要出现。最多同时保持三个已激活的分页命名空间,激活状态从持久事件流重建。 |
72
71
  | `maxResidentTokens` | `8000` | 常驻 wire 面的估算 token 上限(按序列化 schema 约四字符一 token),按 V4.1 的 KV 压缩重新校准后仍高于出厂清单,用于发现真实增长而非出厂配置本身。超过时告警一次、列出最重的工具并指向 `pagedToolPatterns`;不会截断工具清单。 |
73
72
  | `ptcPresentation` | (已退役) | 旧别名:`true` 映射为 `presentation: 'ptc'`,`false` 映射为 `'native'`,两者都伴随弃用告警。 |
@@ -94,7 +93,7 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
94
93
  导出 session JSONL,检查 `request/header`:
95
94
 
96
95
  - `instructionSource: host` 下第一份 header 的 `system` 应恰好是 persona 块(极简 persona、工作纪律清单、工作区目录行 `Your working directory is <cwd>.`)加上 plan mode 开启时的策略段——AGENTS.md 链则以宿主自己的 user 角色消息抵达;`instructionSource: system-prompt` 下 `system` 改为多出一段 `workspace-instructions`;
97
- - 每份 header 在整个会话中保持同一种呈现:默认 `presentation: 'both'` 下 wire 同驻原生清单与 `run_code`,任何回合边界都不会再收窄 wire;
96
+ - 每份 header 在整个会话中保持同一种呈现:默认 `presentation: 'ptc'` 下 wire 收拢为 `run_code`,任何回合边界都不会再展开 wire;
98
97
  - 放行的消息里应有一条来自 `liangshen-tool-catalog` 的 `plugin` 消息,位于用户消息之后,按参数签名恰好列出该次请求开放的工具;被分页扣留的工具以一行命名空间摘要出现;
99
98
  - `ptc` 下未激活的命名空间既不出现在该请求的 `tools:sdk` 段中,也不能在 `run_code` 程序内调用——**从第一个请求起**成立,而不是晚一个请求;
100
99
  - `tool_activate({ namespace })` 成功后,该命名空间的工具从下一个请求起进入 wire,且同时激活的分页命名空间不超过三个;
@@ -109,7 +108,7 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
109
108
  - **真实推理探针**:仅验证链路连通性与模型对特定格式的最小响应能力(例如使用 headless 探针验证模型是否能正常解析输出);单次探针成功仅代表功能未阻断,绝不证明模式集成已达标。
110
109
  - **模式集成通过**:要求在真实完整会话中,验证完整 header、所配置呈现行为、分页激活与驱逐、`run_code` 下的 SDK 参数语义解析与沙箱策略执行无误。
111
110
  - **统计显著性提升**:必须在固定 route 与源码 hash 记录的隔离环境中进行多轮对比评测,综合评估任务完成率、工具失败率、规则违反率、人工介入次数与耗时/token 开销。单次或少数 smoke 运行不构成效果提升的证据。
112
- 2. **评测工具**:隔离 runner 位于 `packages/dsh-liangshen/tools/benchmark-live-run.mjs`:它把被评测 preset 物化到临时目录,并通过 variant patch 在本轮自己的 agent-preset registry 中声明它,把会话持久化改写到本次运行目录,并为每次运行记录基线(仓库提交、出厂 preset hash、DSH 版本、固定 route、任务版本)。候选矩阵隔离 persona 与呈现策略两个因素:`B`(出厂默认)、`P`(候选 persona)、呈现臂 `T`(候选 persona,首轮即 PTC)与 `N`(候选 persona,全程原生清单)、以及 `M`(内置包官方 Minimal preset,仅作外部参照而非单因素对照)。单次 smoke 用 `node tools/benchmark-live-run.mjs --variant B`,按种子任务集跑有界矩阵用 `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 合计、按价格书币种计的费用、分列的模型工具错误与传输失败、研究调用次数与首次写入前的检查次数、单独列出的基础设施失败以及记录的基线。费用以 CNY 计,因为该路由以 CNY 计费,`tools/prices/deepseek-flash.json` 承载已发布的非高峰价:高峰时段运行的实际成本是该记录的两倍。无法计价的预算会被拒绝而不是被静默解除。错误码以 `WEB_*` 开头的工具结果计为传输失败,因此无法访问主机的环境绝不会被读成模型靠猜。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
111
+ 2. **评测工具**:隔离 runner 位于 `packages/dsh-liangshen/tools/benchmark-live-run.mjs`:它把被评测 preset 物化到临时目录,并通过 variant patch 在本轮自己的 agent-preset registry 中声明它,把会话持久化改写到本次运行目录,并为每次运行记录基线(仓库提交、出厂 preset hash、DSH 版本、固定 route、任务版本)。候选矩阵隔离 persona 与呈现策略两个因素:`B`(出厂默认)、`P`(候选 persona)、`N`(候选 persona,全程原生清单)、以及 `M`(内置包官方 Minimal preset,仅作外部参照而非单因素对照);随着 SDK 删除 `both` 呈现,测量该呈现的对照臂 `T` 一并退役。单次 smoke 用 `node tools/benchmark-live-run.mjs --variant B`,按种子任务集跑有界矩阵用 `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 合计、按价格书币种计的费用、分列的模型工具错误与传输失败、研究调用次数与首次写入前的检查次数、单独列出的基础设施失败以及记录的基线。费用以 CNY 计,因为该路由以 CNY 计费,`tools/prices/deepseek-flash.json` 承载已发布的非高峰价:高峰时段运行的实际成本是该记录的两倍。无法计价的预算会被拒绝而不是被静默解除。错误码以 `WEB_*` 开头的工具结果计为传输失败,因此无法访问主机的环境绝不会被读成模型靠猜。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
113
112
 
114
113
  ## 配置
115
114
 
@@ -117,13 +116,8 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
117
116
  | --- | --- | --- |
118
117
  | `enabled` | `true` | 总开关:关闭后不声明预设、也不发公告。 |
119
118
  | `announceToAgent` | `false` | 按需开启:开启后向 agent 系统提示注入本插件公告。默认关闭,保持系统提示词干净。 |
120
- | `presentation` | `both` | 写入本插件所声明 preset 之 `tool-catalog` 行的 wire 呈现:`both`(默认)让原生清单与 `run_code` 同驻;`native` 保持组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`。Host 提交改动后立即重新声明 preset,此后新建的会话即采用新值;已开始的会话保持其已声明的组合。 |
121
- | `dispatcher` | `true` | 身份开关:开启时(出厂默认)所声明的 preset 在 persona 之后追加调度者规则段——复杂度分诊(L0/L1 直接执行,L2 走完整流程)、L2 任务先澄清访谈再规划、派发子代理并逐层审查与验收。关闭后回到仅含工作纪律的极简 persona。它与 `presentation` 正交:`presentation` 决定工具面,`dispatcher` 决定身份与流程纪律。 |
122
- | `guardEnabled` | `true` | 运行时退化熔断器总开关:检测连续零产出长思考与同参重复失败,触发时注入熔断提示并临时下调推理档位;关闭后不干预任何请求。 |
123
- | `guardSensitivity` | `balanced` | 熔断灵敏度预设:整体缩放阈值——`conservative`(更少打断,×1.5)、`balanced`(出厂校准值)、`aggressive`(更早触发,×0.5)。 |
124
- | `guardStallReasoningChars` | (未设置) | 单步暴走梯字符阈值的**覆写值**:不设置时阈值随推理档位自适应(max 档 8000 / high 档 12000 / low 档 20000,按 V4.1 官方 384K 最大输出校准),并再按 `guardSensitivity` 缩放;设置本字段则以本值为准、覆盖所有档位的自适应表。 |
125
- | `guardGlobalStallCap` | (未设置) | 熔断器慢烧梯连续步数的**覆写值**:不设置时随灵敏度预设缩放(balanced 为 4),设置本字段则以本值为准。 |
126
- | `guardEchoFailures` | (未设置) | 熔断器空转梯的**覆写值**:同一工具以相同参数连续失败多少次触发;不设置时该次数随灵敏度预设缩放(balanced 为 3)。以上熔断字段与 `presentation` 一样写入所声明的 preset 生效。 |
119
+ | `presentation` | `ptc` | 写入本插件所声明 preset 之 `tool-catalog` 行的 wire 呈现:`ptc`(默认)把 wire 收拢为 `run_code`,其余工具经生成的 SDK 调用;`native` 保持组装出的原生清单。Host 提交改动后立即重新声明 preset,此后新建的会话即采用新值;已开始的会话保持其已声明的组合。已删除的 `both` 取值在注册时被拒绝——旧 profile 请迁移为 `ptc` 或 `native`。 |
120
+ | `dispatcher` | `true` | 身份开关:开启时(出厂默认)所声明的 preset 在 persona 之后追加调度者规则段——复杂度分诊(L0/L1 直接执行,L2 走完整流程)、拒绝 Agent Teams 的 R0.5 兼容性闸门、L2 任务先澄清访谈再规划、派发子代理并逐层审查与验收,以及落在 `todo_write` 的任务跟踪——其后是本地英文补充:访谈类新增内容,加上参考文本没有的那一条规则——看板卡片不替代派发。关闭后回到仅含工作纪律的极简 persona。它与 `presentation` 正交:`presentation` 决定工具面,`dispatcher` 决定身份与流程纪律。 |
127
121
 
128
122
  各字段都可在 Web 设置界面(插件配置)或 profile patch(`dsh plugin` / `cordis.patch.yml`)中编辑。0.1.7 的设置契约下,插件自身的 Config 就是它的设置页:Host 为每个 profile entry 生成一张表单(entry id 为 `liangshen`,聚合安装下为生成的 `web-ui-liangshen` 行),每个字段都声明为 `volatile()`,因此写入被提交进运行中的插件实例,而不是重挂该行。塑造 preset 的 presentation 字段再经声明抵达会话:插件把已提交的取值应用到 `presets/liangshen/agent.cordis.yml` 的对应行并重新声明 preset,因此真正被会话运行的是设置界面的取值,而不是包内文件。组合里没有的行或键绝不会被凭空写入——覆写只会收窄出厂配置。改动对之后新建的会话生效;已开始的会话保持其已声明的组合,因为 registry 拒绝重组已开始的会话。
129
123
 
@@ -131,15 +125,15 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
131
125
 
132
126
  - 系统提示词在整个会话中保持稳定:persona 块(persona、工作纪律、工作区目录),plan mode 开启时另加其策略段,`system-prompt` 模式下另加 workspace-instructions 段。工具调用后不会再追加内容,也不施加任何输出预算上限;
133
127
  - `system-prompt` 模式下 workspace-instructions 段在每次组装时重新读取,指令文件的改动无需持久消息即可在下一次请求生效;该段渲染在稳定前缀之后的最后位置,缓存前缀不受影响。工作区子目录动态规则后续将扩展支持注册文件工具(含 `str_replace_editor`)及 `run_code` 内子调用触达的目录;不解析任意 bash/program 代码,不保证 shell 自行文件访问的自动发现;
134
- - wire 在整个会话中保持同一种呈现——不存在回合边界跃迁:`both`(出厂默认)同驻原生清单与一个 `run_code`,`native` 携带组装出的原生清单,`ptc` 把 wire 收拢为 `run_code` 一条,其余工具经生成的 SDK 调用;
128
+ - wire 在整个会话中保持同一种呈现——不存在回合边界跃迁:`ptc`(出厂默认)把 wire 收拢为 `run_code` 一条,其余工具经生成的 SDK 调用;`native` 携带组装出的原生清单;
135
129
  - 注入的目录是持久消息:每个会话写入一次,另在工具面变化(分页激活、呈现变更)或压缩遮蔽已发布副本时替换一次,并留在历史中供后续请求使用;
136
130
  - 未观测到 prompt 组装的步不注入任何内容——目录绝不会由过期视图推测;
137
131
  - 若组合中不存在任何被接受的 persona section 名(`deployment:persona-prefix`、`deployment:persona`、`persona`),过滤器会保留组装结果并只告警一次,而不是发出空系统提示词;
138
132
  - plan mode 通过其 `plan:policy` 段支持;置 `keepPlanPolicy: false` 后该模式仍有工具,但失去约束它的策略文本;
139
- - 被分页扣留的工具(出厂模式 `mcp__*`)在模型经 `tool_activate` 激活其命名空间之前不进 wire、也不进生成的 SDK;同时最多三个分页命名空间保持激活,激活第四个会把最近最少使用的逐回摘要状态,激活状态在压缩与恢复后从持久事件流重建。`ptc` 下分页同时作用于作用域的工具注册表,未激活的命名空间在 `run_code` 程序内同样不可达;`both` 下不安装注册表级限制,被分页的命名空间在程序内仍可达——可达性来自原生 wire 本身,而非分页豁免;
133
+ - 被分页扣留的工具(出厂模式 `mcp__*`)在模型经 `tool_activate` 激活其命名空间之前不进 wire、也不进生成的 SDK;同时最多三个分页命名空间保持激活,激活第四个会把最近最少使用的逐回摘要状态,激活状态在压缩与恢复后从持久事件流重建。`ptc` 下分页同时作用于作用域的工具注册表,未激活的命名空间在 `run_code` 程序内同样不可达;
140
134
  - working-context 行只在其来源(plan-mode 状态、已激活的分页命名空间、进行中的 todo)可读时注入,否则省略;
141
135
  - 工具结果超过 4096 字符即被修剪,保留 2048 字符头部与 1024 字符尾部(守护稀疏索引槽位的同时保住错误尾部与退出码),避免超大输出挤占上下文;
142
- - `run_code` 需要挂载的 code runtime(随包发布的 web 与 headless 组合都挂载 `dsh-code-runtime-worker-thread`);没有时 `ptc` 与 `both` 不做声明,会话运行原生工具面;
136
+ - `run_code` 需要挂载的 code runtime(随包发布的 web 与 headless 组合都挂载 `dsh-code-runtime-worker-thread`);没有时 `ptc` 不做声明,会话运行原生工具面;
143
137
  - spawn 委派行已开启子 agent 模型选择(`modelSelectionSettings: true`),因此设置界面的子智能体模型选择开关在本预设下生效:模型在 `subagent` 上看到 `provider` / `model` / `reasoning_effort` 参数与 `list_subagent_models` 发现工具,显式路由会按会话的允许清单校验;
144
138
  - 同一组合 scope 内只允许一行委派工具开启该开关:上游开启时以固定工具名在该行所合入的 scope 中注册 `list_subagent_models`,而注册表拒绝同一 scope 内同名工具的第二次注册,因此第二行开启会让整个会话创建失败而不是多出一份能力。fork 行因此不带该键(官方 Standard、PTC、Cordis 预设同样如此),组合测试按结构统计开启行数;
145
139
  - 清单不发布 `workflow` 工具,而 workflow 引擎仍为 `ralph` 保留挂载;
@@ -148,7 +142,7 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
148
142
  - preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/liangshen/`;
149
143
  - 插件不发起网络请求,也不增加遥测;
150
144
  - 不要在已经产生内容的会话中途切换 preset;
151
- - 需要 DSH 0.2.0-rc.2+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
145
+ - 需要 DSH 0.2.1-rc.2+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
152
146
 
153
147
  ## 许可
154
148