@linxin666/dsh-liangshen 0.3.23 → 0.4.0

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.
Files changed (59) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +55 -41
  3. package/README.zh.md +54 -40
  4. package/cordis.patch.yml +3 -2
  5. package/icon.svg +3 -0
  6. package/lib/client.js +1380 -29
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +616 -367
  9. package/lib/types/announce.test.d.ts +10 -0
  10. package/lib/types/client/LiangShenSettingsCard.d.ts +78 -0
  11. package/lib/types/client/PluginSettingsCard.d.ts +137 -0
  12. package/lib/types/client/index.d.ts +57 -4
  13. package/lib/types/client/lever-controller.d.ts +16 -2
  14. package/lib/types/client/locales.d.ts +40 -1
  15. package/lib/types/client/main-session.d.ts +32 -0
  16. package/lib/types/client/plugin-card-seat.d.ts +103 -0
  17. package/lib/types/client/settings-form.d.ts +197 -0
  18. package/lib/types/composition.d.ts +116 -0
  19. package/lib/types/composition.test.d.ts +7 -0
  20. package/lib/types/core/lever.d.ts +6 -3
  21. package/lib/types/index.d.ts +160 -33
  22. package/lib/types/index.test.d.ts +5 -0
  23. package/package.json +27 -18
  24. package/presets/liangshen/NOTICE +4 -4
  25. package/presets/liangshen/agent.cordis.yml +168 -123
  26. package/presets/liangshen/fact-ledger.mjs +141 -0
  27. package/presets/liangshen/guard.mjs +426 -0
  28. package/presets/liangshen/minimal-prompt.mjs +73 -38
  29. package/presets/liangshen/paging.mjs +232 -0
  30. package/presets/liangshen/tool-activate.mjs +176 -0
  31. package/presets/liangshen/tool-catalog.mjs +615 -219
  32. package/presets/liangshen/working-context.mjs +222 -0
  33. package/src/announce.test.ts +248 -55
  34. package/src/client/LiangShenLever.module.css +2 -0
  35. package/src/client/LiangShenLever.tsx +41 -10
  36. package/src/client/LiangShenSettingsCard.tsx +233 -0
  37. package/src/client/PluginSettingsCard.tsx +555 -0
  38. package/src/client/index.ts +102 -5
  39. package/src/client/lever-controller.ts +76 -9
  40. package/src/client/locales.ts +79 -1
  41. package/src/client/main-session.ts +43 -0
  42. package/src/client/plugin-card-seat.ts +192 -0
  43. package/src/client/settings-card.module.css +418 -0
  44. package/src/client/settings-form.ts +442 -0
  45. package/src/composition.test.ts +294 -0
  46. package/src/composition.ts +554 -0
  47. package/src/core/lever.ts +7 -4
  48. package/src/index.test.ts +68 -1
  49. package/src/index.ts +293 -101
  50. package/tools/benchmark-live-run.mjs +193 -63
  51. package/lib/types/schema.d.ts +0 -18
  52. package/lib/types/schema.test.d.ts +0 -1
  53. package/lib/types/sync.d.ts +0 -47
  54. package/lib/types/sync.test.d.ts +0 -1
  55. package/presets/liangshen/custom-bash.mjs +0 -213
  56. package/src/schema.test.ts +0 -64
  57. package/src/schema.ts +0 -110
  58. package/src/sync.test.ts +0 -224
  59. package/src/sync.ts +0 -222
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: fce0b0bac57f894854372a0ad570092e6b74793d
6
- README.zh.md: 82ed025985564508569bef37c08a07a9b5cdc452
5
+ README.md: 7812a1d2e0d7afe91640c8287bedeae85810dc56
6
+ README.zh.md: 0849beef44b789bf7f34c87a3f3fc3c0dab2374a
package/README.md CHANGED
@@ -1,34 +1,35 @@
1
- # dsh-liangshen — LiangShen Mode (minimal persona + PTC tool surface)
1
+ # dsh-liangshen — LiangShen Mode (minimal persona + programmatic tool transport)
2
2
 
3
3
  English | [中文](README.zh.md)
4
4
 
5
- Ships the LiangShen preset as a one-command plugin of the dsh-web family: on host startup it syncs the bundled preset into `~/.dsh/.agent-presets`, so new sessions can pick "梁神模式" from the preset picker, and its browser half adds a slot-machine lever beside the model selector on the new-session screen for switching that mode on and off. The preset keeps a minimal persona with standing working discipline, session workspace directory, and AGENTS.md-style workspace instructions in the system prompt, and delivers its tool surface as a durable user message after the user's message from the first turn on — the way the harness injects the skill catalog, naming exactly the tools that request opens — while the wire is staged: the session's entire first user turn natively presents a foundational tool surface (default `[bash, str_replace_editor, exit_plan_mode, skill]`, with bash-only preserved as a configuration experiment), and from the second turn the session presents its tools in PTC mode upon successful activation, where the wire carries the single `run_code` transport and other tools are reached via the generated SDK. Deterministic turn boundary transition occurs when PTC is actually activated, preserving full input and output key parameter semantics with no reasoning gating and no output-token cap. Built entirely on the official NPM SDK — no dsh source changes.
5
+ Ships the LiangShen preset as a one-command plugin of the dsh-web family: at activation the host half declares the bundled preset to the harness's agent-preset registry (declare = enabled), so new sessions can pick "梁神模式" from the preset picker, and its browser half adds a slot-machine lever beside the model selector on the new-session screen for switching that mode on and off. The preset keeps a minimal persona with standing working discipline and the session workspace directory in the system prompt, lets the harness deliver AGENTS.md-style workspace instructions as its own user-role messages, and delivers its tool surface as a durable user message after the user's message — the way the harness injects the skill catalog, naming exactly the tools that request opens. The wire keeps one presentation for the whole session (`presentation: 'both'` by default): the native roster and the `run_code` transport sit co-resident — ordinary single-step work goes through direct native calls, while programmatic batch computation, wide fan-out, and multi-step data shaping go through `run_code`. A deployment without a mounted code runtime degrades to the native surface with a one-time warning instead of presenting a transport the request cannot carry. Tools held back by paging (default pattern `mcp__*`) are unreachable until activated: they appear in the catalog as namespace summaries, and under `ptc` they stay out of the generated SDK as well, because the page is a registry restriction rather than only a wire filter. `tool_activate` loads one namespace back onto the whole surface. Built entirely on the official NPM SDK — no dsh source changes.
6
6
 
7
7
  ## Why
8
8
 
9
- DeepSeek V4 models condition strongly on the initial prompt and the first-turn model-visible tool surface when choosing their execution trajectory. Exposing an unbounded tool surface prematurely can scatter execution trajectories, while completely omitting editing or planning tools restricts the completion of complex tasks.
9
+ 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.
10
10
 
11
- LiangShen mode adopts a staged tool and compact prompt architecture: the anchoring portion (the system prompt) keeps a minimal persona with standing working discipline and workspace instructions; the capability portion (the tool surface) is announced from the first user message via a skill-catalog-style injection, while the entire first user turn natively presents a foundational anchor tool set (`[bash, str_replace_editor, exit_plan_mode, skill]`) covering discovery, editing, exiting plan mode, and skill lookups; from the second turn onward, upon meeting code runtime requirements and successful declaration, it smoothly transitions to PTC (program-as-tool) mode. Under PTC presentation, the injected message carries generated SDK bindings, complete input and output key parameter semantics, the program contract ("one program per intent"), and the rule that only `run_code` may be called directly. This mode makes no overcommitments regarding "exact identity with official Minimal", "community benchmark scores proving this version is universally superior", or "prompt cache prefix hits equating to behavioral identity", but rather ensures execution stability through a well-defined tiered contract.
11
+ 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.
12
12
 
13
13
  ## How it works
14
14
 
15
- 1. `minimal-prompt` narrows every assembled prompt to the persona section — the one-line persona, the mode's standing working discipline (exit thinking loops immediately, design-first reasoning over pre-rehearsed code, YAGNI and PDCA, no redundant code 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);
16
- 2. the AGENTS.md-style workspace instructions 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 sub-calls inside PTC reaching target directories; arbitrary bash/program code is not parsed, and automatic discovery of file accesses performed directly within shell commands is not guaranteed;
17
- 3. the anchor turn (the session's entire first user turn, rather than merely a single first step) keeps the wire on the foundational anchor tool set: default `[bash, str_replace_editor, exit_plan_mode, skill]`, presented natively (`anchorTools`); the `[bash]` single-shell experimental configuration is also preserved and supported (without requiring extra preset registration or registry changes). From the second turn, when a code runtime exists and presentation declaration succeeds, `tool-catalog` activates PTC presentation for that session (`agent.ctx.tools.presentAs('ptc')`, declared on anchor turn end), collapsing the wire to `run_code` where other tools are invoked via the generated SDK; if code runtime is absent or activation fails, it gracefully degrades to the native tool surface with a one-time warning;
18
- 4. `tool-catalog` appends the tool list as a durable user message after the user's message from the first turn on, preserving complete input and output key parameter semantics rather than an oversimplified 200-character-only contract (`descriptionMaxLength: 200` only caps single-line summaries, without stripping key parameter structures). It names exactly the tools the current request opens: the anchor set during the native anchor turn, and, under PTC, the SDK-reachable roster plus the program contract — one program per intent instead of one call per step, `run_code`'s `code`/`description` shape, independent read-only calls overlapping under `Promise.all`, `ToolCallError` handling, curated program output, and the rule that `run_code` is the only directly callable tool once on the wire. It republishes only when that surface changed or the published copy left the visible surface (a compaction, a resume), so the promotion boundary carries one contract update without insisting on absolute context immutability;
19
- 5. runtime contexts (the sandbox and approval snapshots) and the skill catalog flow as in Standard mode.
15
+ 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);
16
+ 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;
17
+ 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;
18
+ 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);
19
+ 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;
20
+ 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;
21
+ 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;
22
+ 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.
23
+ 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 stepping the reasoning effort one notch down for the next few requests (max → high → low); 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);
24
+ 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.
20
25
 
21
26
  ## Security model
22
27
 
23
28
  This mode operates strictly within the official host security architecture and complies with sandbox policies:
24
29
 
25
- - **Host sandbox constraints**: All file tools (whether `str_replace_editor` and Standard file tools natively presented in the first turn, or file operations invoked via PTC `run_code` later) are subject to host file sandbox policies, inheriting the current session's sandbox level (e.g., `danger-full-access` or workspace-restricted/read-only). Bare local filesystem access does not exist (no `dsh-fs-local` mount); all reads and writes across workspaces are guarded by host policy.
26
- - **Windows platform limitations and Git Bash**: DSH's PTY backend is Linux/Darwin-only. On Windows (win32), the persistent-shell group is disabled, and `bash` is provided by `presets/liangshen/custom-bash.mjs` through system Git Bash subprocess invocation:
27
- - Windows Git Bash runs through an ordinary subprocess seam; subject to Windows platform constraints, it lacks namespace/cgroups-based OS sandbox isolation;
28
- - The shell process does not persist across invocations, so command state (environment variables, current directory, etc.) does not carry over;
29
- - Non-zero exits are returned as results rather than thrown;
30
- - Users and developers must not modify `custom-bash.mjs` to bypass security policies; privileged actions must follow host prompts and environment security guidelines.
31
- - **PTC code sandbox**: In PTC mode, `run_code` scripts execute within an isolated worker thread context, with access to system resources strictly bounded by the SDK's exposed tools.
30
+ - **Host sandbox constraints**: All file tools — the natively presented Standard file tools and any file operation a `run_code` program dispatches through the SDK — are subject to host file sandbox policies, inheriting the current session's sandbox level (e.g., `danger-full-access` or workspace-restricted/read-only). Bare local filesystem access does not exist (no `dsh-fs-local` mount); all reads and writes across workspaces are guarded by host policy.
31
+ - **Standard shell on both platforms**: the preset mounts the upstream standard Stdio shell stack on every host, mirroring the builtin Standard preset. POSIX mounts `bash` (`@deepseek-ai/dsh-tool-bash`); win32 mounts `pwsh` (`@deepseek-ai/dsh-tool-pwsh`). Each platform exposes exactly one shell tool (`bash` on POSIX, `pwsh` on win32), featuring active-voice description title cards and deterministic exit codes. The preset ships no shell implementation of its own.
32
+ - **Code runtime sandbox**: `run_code` programs execute within an isolated worker thread context, with access to system resources strictly bounded by the SDK's exposed tools.
32
33
 
33
34
  ## The lever
34
35
 
@@ -43,16 +44,19 @@ The lever drives the session's preset through the agent-preset Remote namespace
43
44
 
44
45
  ## Preset configuration
45
46
 
46
- Both preset-local plugins are configured in `agent.cordis.yml`:
47
+ The preset-local plugins are configured in `agent.cordis.yml`:
47
48
 
48
49
  | Key | Default | Behavior |
49
50
  | --- | --- | --- |
50
51
  | `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. |
51
- | `instructionSource` | `system-prompt` | Where workspace instructions reach the model. `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` restores the pointer behavior: the first injection becomes a one-time non-imperative reference-file hint and later injections are dropped. |
52
- | `instructionMaxBytes` | `65536` | Byte budget for the rendered workspace-instructions section (system-prompt mode): broadest files are omitted first, the most specific file is truncated last. |
53
- | `descriptionMaxLength` | `200` | Cap for one tool's one-line summary in the injected catalog. Complete key parameter semantics and contracts remain fully preserved by the SDK itself. |
54
- | `anchorTools` | `[bash, str_replace_editor, exit_plan_mode, skill]` | Tool set natively presented on the wire throughout the entire first user turn; promoted surface engages from the second turn. Shipped default includes the core four tools; can also be configured as `[bash]` for single-shell experiments (without modifying registry). Empty disables staging. |
55
- | `ptcPresentation` | `true` | Attempt to declare PTC presentation from the second turn onward; upon successful activation, wire collapses to `run_code` preserving complete input/output key parameter semantics. Requires a mounted code runtime and a readable tool projection; without either it keeps native presentation with a single warning. The injected catalog always describes the transport the request's own wire carries, and never announces PTC for an assembly the declaration could not reach. Set `false` to keep assembled native roster from second turn. |
52
+ | `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. |
53
+ | `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. |
54
+ | `descriptionMaxLength` | `200` | Cap for one tool's one-line summary in the injected catalog. Complete key parameter semantics remain fully preserved. |
55
+ | `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. |
56
+ | `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. |
57
+ | `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. |
58
+ | `ptcPresentation` | (retired) | Legacy alias: `true` maps to `presentation: 'ptc'` and `false` to `'native'`, both with a deprecation warning. |
59
+ | `anchorTools` | (retired) | First-turn anchor narrowing is removed; setting this key warns and no longer narrows the wire. |
56
60
 
57
61
  ## Install
58
62
 
@@ -68,17 +72,18 @@ dsh plugin --profile web add @linxin666/dsh-liangshen@latest
68
72
  dsh plugin --profile web remove @linxin666/dsh-liangshen
69
73
  ```
70
74
 
71
- Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as the preset. The plugin syncs the presets into `~/.dsh/.agent-presets` at startup (upgrades refresh them automatically on next restart).
75
+ Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as the preset. The plugin declares the preset from its own bundled files at activation and releases the declaration when the plugin (or its row) unloads; nothing is written into `~/.dsh/.agent-presets`, and an upgrade takes effect on the next start.
72
76
 
73
77
  ## Verify
74
78
 
75
79
  Export the session JSONL and inspect `request/header`:
76
80
 
77
- - 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, plus the `workspace-instructions` section carrying the AGENTS.md chain;
78
- - the entire first user turn's header tools should be exactly the anchor surface — default `[bash, str_replace_editor, exit_plan_mode, skill]`, presented natively — never the promoted roster and never an unactivated `run_code`;
79
- - the anchor turn's admitted messages should hold one `plugin`-sourced message from `liangshen-tool-catalog` after the user message, naming exactly the anchor tools by argument signature; from the promoted turn on, that message names the SDK-reachable roster and states the `run_code` program contract, including that `run_code` is the only directly callable tool;
80
- - from the second turn on, provided PTC successfully activates, headers carry exactly one tool, `run_code` (PTC presentation); without code runtime it gracefully degrades to native roster with a single warning;
81
- - after a compaction the catalog is republished once as a replacement list and the session stays in its current presentation mode;
81
+ - 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;
82
+ - 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;
83
+ - 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;
84
+ - 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;
85
+ - 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;
86
+ - after a compaction the catalog is republished once as a replacement list, paged activations are rebuilt from the durable event stream, and the presentation mode is unchanged;
82
87
  - file writes obey the host file sandbox policy — there is no bare local-filesystem bypass.
83
88
 
84
89
  ### Real session validation conditions and benchmark evaluation
@@ -87,37 +92,46 @@ When validating mode behavior and evaluating performance, verification tiers mus
87
92
 
88
93
  1. **Real inference probe ≠ Mode integration pass ≠ Statistical improvement**:
89
94
  - **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.
90
- - **Mode integration pass**: Requires full session verification of complete headers, tiered tool transitions, actual PTC activation, SDK parameter semantics parsing, and sandbox policy enforcement.
95
+ - **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.
91
96
  - **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.
92
- 2. **Benchmark tooling**: the isolated runner is `packages/dsh-liangshen/tools/benchmark-live-run.mjs`. It writes the evaluated preset into a temporary root selected through the roster's own `roots` config, 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 is `B` (shipped persona and two-stage strategy), `P` (candidate persona), `T` (candidate persona, PTC from the first turn), `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-usd 5`; 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 and cost totals, infrastructure failures separately, and the recorded baseline. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
97
+ 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-usd 5`; 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 and cost totals, infrastructure failures separately, and the recorded baseline. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
93
98
 
94
99
  ## Configuration
95
100
 
96
101
  | Key | Default | Behavior |
97
102
  | --- | --- | --- |
98
- | `enabled` | `true` | Master switch: when false, neither preset sync nor announcement runs. |
103
+ | `enabled` | `true` | Master switch: when false, the preset is not declared and the announcement does not run. |
99
104
  | `announceToAgent` | `false` | Opt-in: when true, a system-prompt section announces the plugin. Off by default so agent system prompts stay clean. |
105
+ | `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. |
106
+ | `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. |
107
+ | `guardSensitivity` | `balanced` | Sensitivity preset scaling every breaker threshold: `conservative` (fewer interruptions, x1.5), `balanced` (the calibrated defaults), `aggressive` (fires earlier, x0.5). |
108
+ | `guardStallReasoningChars` | `8000` | **Override** for the per-step runaway floor: the floor adapts to the reasoning effort by default (8000 at max / 12000 at high / 20000 at low, calibrated against V4.1's official 384K max output); setting this field wins over the adaptive table for every effort level. |
109
+ | `guardGlobalStallCap` | `4` | **Override** for the slow-burn step count: the cap scales with the sensitivity preset by default (4 at balanced); setting this field wins. |
110
+ | `guardEchoFailures` | `3` | **Override** for the echo ladder: identical-argument failures of the same tool in a row that fire the breaker. All guard fields reach a session through the declared preset, exactly like `presentation`. |
100
111
 
101
- Both fields are editable in the web settings surface (plugin config, live) or through the profile patch (`dsh plugin` / `cordis.patch.yml`).
112
+ 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.
102
113
 
103
114
  ## Behavior and limits
104
115
 
105
- - 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. Nothing is appended after a tool call, and no output-token cap is applied;
106
- - 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 anchor's cache prefix stays intact. Subdirectory dynamic rules will subsequently support registered file tools (including `str_replace_editor`) and sub-calls inside PTC reaching target directories; arbitrary bash/program code is not parsed, and automatic discovery of file accesses performed directly within shell commands is not guaranteed;
107
- - The wire's schema set stays on the foundational anchor tool set during the entire first user turn (default `[bash, str_replace_editor, exit_plan_mode, skill]`, supporting `[bash]` experiments); from the second turn onward, upon successful PTC activation, it collapses to `run_code`; the catalog message is written once per session plus one replacement when the exposed surface changes — the promotion boundary included — or a compaction shadows it;
108
- - The injected catalog is durable: it is written once per session, plus one replacement when the tool surface changes or a compaction shadows the published copy, and it stays in the history for later requests;
116
+ - 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;
117
+ - 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;
118
+ - 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;
119
+ - 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;
109
120
  - A step whose prompt assembly was not observed injects nothing — the catalog is never guessed from a stale view;
110
121
  - 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;
111
122
  - 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;
112
- - PTC presentation is declared per session and needs a mounted code runtime (the shipped web and headless compositions mount `dsh-code-runtime-worker-thread`); without one or upon activation failure, the mode stays native with a one-time warning;
113
- - The roster is the builtin PTC preset's model-authored surface: the `workflow` tool is not published beside `run_code`, while the workflow engine stays mounted for `ralph`;
114
- - The persistent `bash` replaces the Standard ephemeral shell for the whole session (both tools register the name `bash`), so shell state survives across calls; on win32 `custom-bash` provides the same-named tool through Git Bash, with no OS sandbox confinement and non-persistent state;
123
+ - 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;
124
+ - The working-context line is injected only when its sources (plan-mode state, active paged namespaces, in-progress todos) are readable, and omitted otherwise;
125
+ - 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;
126
+ - `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;
127
+ - The roster does not publish the `workflow` tool, while the workflow engine stays mounted for `ralph`;
128
+ - The shell mounts the upstream standard Stdio stack, registering `bash` on POSIX and `pwsh` on win32 — each host mounts exactly one shell tool, featuring concise description title cards and deterministic exit codes;
115
129
  - The file tools inherit the host file sandbox (no bare `dsh-fs-local` filesystem);
116
130
  - The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
117
131
  - The plugin makes no network requests and adds no telemetry;
118
132
  - Do not switch presets mid-conversation;
119
- - Requires DSH 0.1.5-rc.1+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
133
+ - Requires DSH 0.1.7-rc.1+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
120
134
 
121
135
  ## License
122
136
 
123
- Plugin body Apache-2.0 (zhu1090093659). `presets/liangshen/agent.cordis.yml` derives from the DeepSeek Harness builtin Minimal, Standard, and PTC presets (MIT), and `custom-bash.mjs` comes from xiaobright/dsh-anchored-standard (MIT) — copyright and license notices are kept in the preset's `NOTICE`.
137
+ Plugin body Apache-2.0 (zhu1090093659). `presets/liangshen/agent.cordis.yml` derives from the DeepSeek Harness builtin Minimal, Standard, and PTC presets (MIT) — copyright and license notices are kept in the preset's `NOTICE`.
package/README.zh.md CHANGED
@@ -1,34 +1,35 @@
1
- # dsh-liangshen — 梁神模式(极简 persona + PTC 工具面)
1
+ # dsh-liangshen — 梁神模式(极简 persona + 程序化工具传输)
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- 把梁神模式做成 DSH 全家桶里的一键安装插件:Host 启动时把内置 preset 同步到 `~/.dsh/.agent-presets`,新建会话即可在预设选择器中选择「梁神模式」,浏览器半区还在新建会话页的模型选择器旁提供一台老虎机拨杆来开关该模式。该 preset 让系统提示词保持极简 persona——外加本模式的固定工作纪律、会话工作区目录与 AGENTS.md 类工作区指令——并从第一条用户消息起就把工具面作为持久 user 消息注入在用户消息之后——形状与 harness 注入 skill 目录一致,且只宣告该次请求实际开放的工具——而 wire 按回合分层:首轮整个 user turn 原生呈现基础锚定工具集(默认 `[bash, str_replace_editor, exit_plan_mode, skill]`,并保留 bash-only 配置实验),从第二个回合起在 PTC 成功激活后以 PTC 模式呈现工具,wire 上只有 `run_code` 这一条传输工具,其余工具都在程序里经生成的 SDK 调用。PTC 实际激活时发生确定性的回合边界跃迁,保留完整输入输出关键参数语义,没有推理内容门控、没有输出预算上限。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
5
+ 把梁神模式做成 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 源码。
6
6
 
7
7
  ## 原理
8
8
 
9
- DeepSeek V4 模型在选择执行轨迹时,会受到初始提示词与首轮可见工具面的显著影响。过多过早暴露未受约束的工具可能分散执行轨迹,而完全缺乏编辑或规划手段又限制了复杂任务的完成。
9
+ DeepSeek V4.1 Flash 的后训练直接对齐其原生 DSML 工具调用面,官方脚手架横评中代码 Agent 基准上原生极简面领先于程序化(PTC)面(DeepSWE v1.1:72.6% 对 67.6%;Terminal-Bench 2.1:90.6% 对 85.8%)。而真实工程会话依赖 MCP 服务与插件生态——封闭的 4 工具极简面在物理上够不到它们,无边界平铺的全量清单又会把会话内容埋在工具定义之下。
10
10
 
11
- 梁神模式采用分层工具与紧凑提示词架构:负责锚定的部分(系统提示词)保持极简 persona 与明确的工作纪律,并注入工作区指令;负责能力的部分(工具面)从第一条用户消息起以 skill-catalog 式的上下文注入宣告,并在首轮整个 user turn 原生呈现基础锚定工具集(`[bash, str_replace_editor, exit_plan_mode, skill]`),提供探索、编辑、退出规划与技能查询的基础能力;从第二个回合起在满足 code runtime 条件并成功声明后,平滑过渡至 PTC(程序即代码)模式。在 PTC 呈现下,注入消息承载生成 SDK 的绑定清单、完整输入输出关键参数语义、「一段程序编排多步调用」的程序契约、以及「只有 `run_code` 可直接调用」的规则。本模式不做出「与官方 Minimal 完全一致」、「社区评测分数证明本版必定更优」或「提示词缓存命中等同于行为一致」的过度承诺,而是以清晰的分层契约保障执行稳定性。
11
+ 梁神模式因此在整个会话中保持由 `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 实际携带的面」永不矛盾。
12
12
 
13
13
  ## 工作机制
14
14
 
15
- 1. `minimal-prompt` 把每次组装出的提示词收窄到 persona 一段——一行 persona、本模式的固定工作纪律(思维循环即断、先理解需求与方案再实现验证、YAGNI/PDCA、代码不加冗余注释)、以及一行从会话头读取的方位信息 `Your working directory is <cwd>.`——因此 harness identity、web surface、工具用法、文件引用与结构化输出等 section 默认不会到达模型;plan mode 的 `plan:policy` 保留,因为该 section 是 plan mode 唯一的执行依据(它的退出工具在任何模式下都保持注册);
16
- 2. AGENTS.md 类工作区指令直接进入系统提示词本身:组装时 `minimal-prompt` 读取 harness 的基线链(`$DSH_HOME/AGENTS.md`,再从项目根到会话 cwd 沿途的 `AGENTS.md` / `CLAUDE.md` 及其 `.local` 覆盖层),把内容作为一段 `workspace-instructions` 追加在稳定前缀之后,受字节预算约束——放不下时先省略最宽的文件、最后才截断最具体的文件;读取在每次组装时都发生,文件改动无需持久消息即可在下次请求生效,harness 自己的 agent-instructions 注入则被丢弃以免与提示词重复。工作区子目录动态规则后续将支持注册文件工具(含 `str_replace_editor`)及 PTC 内子调用触达的目录;不解析任意 bash/program 代码,不保证 shell 自行文件访问的自动发现;
17
- 3. 锚定回合(会话的首轮整个 user turn,而非仅第一步单次请求)把 wire 保持在基础锚定工具集上:默认 `[bash, str_replace_editor, exit_plan_mode, skill]`,原生呈现(`anchorTools`);同时保留 `[bash]` 的单 shell 实验配置(无需额外注册预设,无需更改注册表)。从第二个回合起,在 code runtime 存在且声明成功时,`tool-catalog` 为该会话激活 PTC 呈现(`agent.ctx.tools.presentAs('ptc')`,在锚定回合结束时声明),wire 收拢为 `run_code` 这一条传输工具,其余工具都在程序里经生成的 SDK 调用;若缺少 code runtime 或激活失败,则优雅回退至原生工具面并发出一次性告警;
18
- 4. `tool-catalog` 把工具清单从第一条用户消息起作为持久 user 消息追加在用户消息之后,保留完整输入输出关键参数语义而非 200 字唯一契约(`descriptionMaxLength: 200` 仅作为一行摘要长度上限,不裁剪关键参数结构)。目录只宣告该次请求实际开放的工具:原生锚定回合是锚定工具集,PTC 下则是经 SDK 可达的完整工具面,并附带程序契约:一段程序完成一个意图而不是一步一次调用、`run_code` 的 `code`/`description` 形状、独立只读调用用 `Promise.all` 并发、`ToolCallError` 的处理、程序输出需要自己挑选,以及 `run_code` 一旦在 wire 上就是唯一可直接调用的工具。只在工具面变化、或已发布副本离开可见面(压缩、恢复)时重发,因此晋升边界会进行一次契约更新,不再坚持上下文绝对不变;
19
- 5. 运行时上下文(sandbox 与 approval 快照)与 skill 目录按 Standard 模式正常注入。
15
+ 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 唯一的执行依据(它的退出工具在任何模式下都保持注册);
16
+ 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 自行文件访问的自动发现;
17
+ 3. wire 在整个会话中保持由 `presentation` 选定的同一种呈现:`both`(出厂默认)让原生清单与 `run_code` 传输工具同驻,目录文案明确「原生直调优先、`run_code` 仅用于程序化批处理/并发扇出/重计算」;`native` 携带组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`、其余工具经生成的 SDK 调用;`ptc` 与 `both` 需要挂载的 code runtime;没有时插件不做声明,会话直接运行原生工具面。旧键 `ptcPresentation` 映射到 `ptc`/`native` 并发出弃用告警,已退役的 `anchorTools` 首回合收窄不再生效——设置它会收到告警;
18
+ 4. `tool-catalog` 把工具清单作为持久 user 消息追加在用户消息之后,保留完整输入输出关键参数语义(`descriptionMaxLength: 200` 仅限制一行摘要长度)。目录只宣告该次请求实际开放的工具——原生清单加上同驻时的 `run_code`——并在分页开启时为被扣留的命名空间附上一行摘要;`ptc` 下这些摘要代表真正不可达的命名空间——既不在该请求的 `tools:sdk` 段中,也不能在 `run_code` 程序内调用——直到 `tool_activate`;只在工具面变化、或已发布副本离开可见面(压缩、恢复)时重发;
19
+ 5. 温和分页出厂开启(`pagedToolPatterns: ['mcp__*']`):匹配的 MCP 工具被扣留在 wire 与生成的 SDK 之外,以命名空间摘要出现在目录中,直到模型经 `tool_activate({ namespace })` 激活——激活的命名空间从下一个请求起重新可达,最多保持三个已激活的分页命名空间(激活第四个时将最久未用的逐回摘要状态)。激活状态从持久事件流重建,压缩与恢复均可还原;
20
+ 6. 最小版 working-context 行——plan-mode 状态、已激活的分页命名空间、进行中的 todo——只在其来源可读时注入到最新消息尾部,让当前状态落在模型的局部注意力窗口内;运行时上下文(sandbox 与 approval 快照)与 skill 目录按 Standard 模式正常注入;
21
+ 7. 目录把已激活分页家族的工具归在 `namespace `<名称>` (activated):` 标题之下,而不是把一个服务端的工具散落在字母序清单里;未被分页的工具仍保持扁平条目;
22
+ 8. `maxResidentTokens`(默认 8000)估算常驻 wire 面并在超过时告警一次,列出最重的工具并把 `pagedToolPatterns` 指为处置手段。该阈值按 V4.1 的 KV 压缩重新校准(其 KV cache 为 V4-Flash 的 1/4,同样的 schema 负载只占 1/4 的稀疏索引槽位,阈值由 6000 上调至 8000),仍校准在出厂清单之上,用于发现真实增长而非出厂配置本身。该守卫从不截断:静默丢掉会话需要的工具,等于用可度量的上下文成本换取不可度量的能力损失。
23
+ 9. 运行时退化熔断器(`guard`)每步从会话事件流折叠信号,在两类形态下每个 episode 触发一次——停摆(连续零产出的长思考回合)或空转(同一工具以相同参数连续失败)——注入熔断消息,并在接下来几个请求内把推理档位临时下调一档(max → high → low);无信号时它从不改写任何请求,路由的显式档位与前缀缓存都不受影响。这是 persona 反思熔断无法充当的外力(DSH discussion #5976);
24
+ 10. 关键事实登记簿(`fact_register`)让模型把用户硬性约束、已确认的架构决策、失败过的路径登记为一行短事实;登记簿从持久事件流折叠,随 `[Working Context: ...]` 行投射——每步都落在保证命中的局部注意力窗口内——以此对抗 V4.1 的长会话遗忘。
20
25
 
21
26
  ## 安全模型
22
27
 
23
28
  本模式坚持在官方宿主安全架构内运行,严格遵守沙箱策略:
24
29
 
25
- - **宿主沙箱约束**:所有文件工具(无论是首轮原生呈现的 `str_replace_editor`、Standard 文件工具,还是后续在 PTC `run_code` 中调用的文件操作)均受宿主文件沙箱策略约束,继承当前会话的沙箱级别(如 `danger-full-access` 或只读/工作区受限)。不存在裸本地文件系统访问(不挂载 `dsh-fs-local`),所有跨越工作区的读写均受宿主策略拦截。
26
- - **Windows 平台现有限制与 Git Bash**:DSH 的 PTY 后端仅支持 Linux/Darwin。在 Windows (win32) 下,持久 shell 组被禁用,`bash` 由 `presets/liangshen/custom-bash.mjs` 调用系统 Git Bash 子进程提供:
27
- - Windows Git Bash 运行于普通子进程通道,受 Windows 平台限制,不具备 Linux 下基于 namespace/cgroups 的 OS 沙箱隔离;
28
- - shell 进程不跨调用常驻,命令状态(环境变量、当前目录等)不跨调用保留;
29
- - 非零退出码以结果返回而非抛错;
30
- - 用户与开发者切勿修改 `custom-bash.mjs` 去尝试规避安全策略;高权限操作需遵从宿主提示和环境安全规范。
31
- - **PTC 代码沙箱**:PTC 模式下执行的 `run_code` 代码运行于独立的 worker thread 隔离上下文,其对系统资源的访问完全受限于 SDK 暴露的 tools 边界。
30
+ - **宿主沙箱约束**:所有文件工具——原生呈现的 Standard 文件工具,以及 `run_code` 程序经 SDK 分发的任何文件操作——均受宿主文件沙箱策略约束,继承当前会话的沙箱级别(如 `danger-full-access` 或只读/工作区受限)。不存在裸本地文件系统访问(不挂载 `dsh-fs-local`),所有跨越工作区的读写均受宿主策略拦截。
31
+ - **两个平台都挂标准 shell**:本 preset 在每个宿主上挂载上游的标准 Stdio shell 栈,与内置 Standard 一致。POSIX 挂 `bash`(`@deepseek-ai/dsh-tool-bash`);win32 挂 `pwsh`(`@deepseek-ai/dsh-tool-pwsh`)。每个平台恰好暴露一个 shell 工具(POSIX 为 `bash`,win32 为 `pwsh`),带有主动语态简短描述标题卡片与确定性退出码。本 preset 不自带任何 shell 实现。
32
+ - **代码运行时沙箱**:`run_code` 程序运行于独立的 worker thread 隔离上下文,其对系统资源的访问完全受限于 SDK 暴露的 tools 边界。
32
33
 
33
34
  ## 拨杆
34
35
 
@@ -48,11 +49,14 @@ DeepSeek V4 模型在选择执行轨迹时,会受到初始提示词与首轮
48
49
  | 键 | 默认值 | 行为 |
49
50
  | --- | --- | --- |
50
51
  | `keepPlanPolicy` | `true` | 在只有一行 persona 的系统提示词中保留 plan mode 的 `plan:policy` 段。置 `false` 得到严格的一行表面,此时 plan mode 背后没有任何策略文本。 |
51
- | `instructionSource` | `system-prompt` | 工作区指令送达模型的方式。`system-prompt` 在组装时读取 AGENTS.md 链并追加进系统提示词(harness 自己的注入被丢弃);`hint` 恢复指针行为:首次注入替换为一次性的、非命令式的参考文件提示,后续注入丢弃。 |
52
- | `instructionMaxBytes` | `65536` | 渲染后的 workspace-instructions 段的字节预算(system-prompt 模式):最宽的文件先被省略,最具体的文件最后被截断。 |
53
- | `descriptionMaxLength` | `200` | 注入目录中单个工具一行摘要的长度上限。完整关键参数语义与契约仍由 SDK 自身完整保留。 |
54
- | `anchorTools` | `[bash, str_replace_editor, exit_plan_mode, skill]` | 首轮整个 user turn wire 上原生呈现的工具集;晋升面从第二个回合起生效。出厂默认包含基础四工具,亦可按需配置为 `[bash]` 进行单 shell 实验(无需额外注册预设,无需修改注册表)。留空则关闭分层。 |
55
- | `ptcPresentation` | `true` | 从第二个回合起尝试为该会话声明 PTC 呈现,成功激活后 wire 收拢为 `run_code`,保留完整输入输出关键参数语义。需要挂载 code runtime 与可读取的工具投影;缺失任一项时保持原生呈现并只告警一次。注入目录始终描述该次请求 wire 实际携带的传输方式,声明无法在本回合生效时不会宣告 PTC。置 `false` 则从第二个回合起 wire 上仍是组装出的原生清单。 |
52
+ | `instructionSource` | `host` | 工作区指令送达模型的方式。`host`(默认)不追加任何自有段,也不改动宿主的 agent-instructions 注入,工作区指令以宿主自己的 user 角色消息送达:一条持久基线,加上触碰目录后的增量、替换与移除;`system-prompt` 在组装时读取 AGENTS.md 链并追加进系统提示词(harness 自己的注入被丢弃);`hint` 把首次注入替换为一次性的、非命令式的参考文件提示,后续注入丢弃。 |
53
+ | `instructionMaxBytes` | `65536` | 渲染后的 workspace-instructions 段的字节预算,仅在 `system-prompt` 模式下生效:最宽的文件先被省略,最具体的文件最后被截断。 |
54
+ | `descriptionMaxLength` | `200` | 注入目录中单个工具一行摘要的长度上限。完整关键参数语义保持完整。 |
55
+ | `presentation` | `both` | 整个会话的 wire 呈现方式。`both`(出厂默认)保持完整原生清单并同驻一个 `run_code`(原生直调优先、传输工具用于程序化批处理与并发扇出);`native` 保持组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`,其余工具经生成的 SDK 调用。`ptc` 与 `both` 需要挂载的 code runtime;没有时插件根本不做声明,会话直接运行原生工具面。 |
56
+ | `pagedToolPatterns` | `['mcp__*']` | 出厂开启温和分页:命中的 MCP 工具被扣留在 wire 与生成的 SDK 之外,直到模型通过 `tool_activate({ namespace })` 激活其命名空间。被扣留的命名空间在目录中以一行摘要出现。最多同时保持三个已激活的分页命名空间,激活状态从持久事件流重建。 |
57
+ | `maxResidentTokens` | `8000` | 常驻 wire 面的估算 token 上限(按序列化 schema 约四字符一 token),按 V4.1 的 KV 压缩重新校准后仍高于出厂清单,用于发现真实增长而非出厂配置本身。超过时告警一次、列出最重的工具并指向 `pagedToolPatterns`;不会截断工具清单。 |
58
+ | `ptcPresentation` | (已退役) | 旧别名:`true` 映射为 `presentation: 'ptc'`,`false` 映射为 `'native'`,两者都伴随弃用告警。 |
59
+ | `anchorTools` | (已退役) | 首回合锚定收窄已移除;设置该键会收到告警,且不再收窄 wire。 |
56
60
 
57
61
  ## 安装
58
62
 
@@ -68,17 +72,18 @@ dsh plugin --profile web add @linxin666/dsh-liangshen@latest
68
72
  dsh plugin --profile web remove @linxin666/dsh-liangshen
69
73
  ```
70
74
 
71
- 装完**完整重启 `dsh web`**,新建空 session,预设选择「梁神模式」。插件会在启动时把 presets 同步进 `~/.dsh/.agent-presets`(升级插件后重启即自动更新)。
75
+ 装完**完整重启 `dsh web`**,新建空 session,预设选择「梁神模式」。插件在激活时用包内自带文件声明该 preset,插件(或其行)卸载时注销;不会向 `~/.dsh/.agent-presets` 写入任何内容,升级后在下次启动即生效。
72
76
 
73
77
  ## 验证
74
78
 
75
79
  导出 session JSONL,检查 `request/header`:
76
80
 
77
- - 第一份 header 的 `system` 应恰好是 persona 块(极简 persona、工作纪律清单、工作区目录行 `Your working directory is <cwd>.`),plan mode 开启时另加其策略段,再另加承载 AGENTS.md 链的 `workspace-instructions` 段;
78
- - 首轮整个 user turn 的 header tools 应恰好是锚定面——默认 `[bash, str_replace_editor, exit_plan_mode, skill]`,原生呈现——既不是全量晋升清单,也不会是未激活的 `run_code`;
79
- - 锚定回合放行的消息里应有一条来自 `liangshen-tool-catalog` 的 `plugin` 消息,位于用户消息之后,按参数签名恰好列出锚定工具;从晋升回合起,该消息改为列出经 SDK 可达的完整工具面并写明 `run_code` 程序契约,其中 `run_code` 是唯一可直接调用的工具;
80
- - 从第二个回合起,在 PTC 成功激活的前提下,header 上恰好只有一条工具 `run_code`(PTC 呈现);若无 code runtime 则优雅回退到原生清单并伴随一次性告警;
81
- - 压缩之后目录会重发一次,形式为替换清单,且会话保持当前呈现模式;
81
+ - `instructionSource: host` 下第一份 header 的 `system` 应恰好是 persona 块(极简 persona、工作纪律清单、工作区目录行 `Your working directory is <cwd>.`)加上 plan mode 开启时的策略段——AGENTS.md 链则以宿主自己的 user 角色消息抵达;`instructionSource: system-prompt` 下 `system` 改为多出一段 `workspace-instructions`;
82
+ - 每份 header 在整个会话中保持同一种呈现:默认 `presentation: 'both'` 下 wire 同驻原生清单与 `run_code`,任何回合边界都不会再收窄 wire;
83
+ - 放行的消息里应有一条来自 `liangshen-tool-catalog` 的 `plugin` 消息,位于用户消息之后,按参数签名恰好列出该次请求开放的工具;被分页扣留的工具以一行命名空间摘要出现;
84
+ - `ptc` 下未激活的命名空间既不出现在该请求的 `tools:sdk` 段中,也不能在 `run_code` 程序内调用——**从第一个请求起**成立,而不是晚一个请求;
85
+ - `tool_activate({ namespace })` 成功后,该命名空间的工具从下一个请求起进入 wire,且同时激活的分页命名空间不超过三个;
86
+ - 压缩之后目录会重发一次,形式为替换清单,分页激活状态从持久事件流重建,呈现模式保持不变;
82
87
  - 文件写入受宿主文件沙箱策略约束,不存在裸本地文件系统绕过。
83
88
 
84
89
  ### 真实会话验证条件与评测说明
@@ -87,37 +92,46 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
87
92
 
88
93
  1. **真实推理探针 ≠ 模式集成通过 ≠ 统计提升**:
89
94
  - **真实推理探针**:仅验证链路连通性与模型对特定格式的最小响应能力(例如使用 headless 探针验证模型是否能正常解析输出);单次探针成功仅代表功能未阻断,绝不证明模式集成已达标。
90
- - **模式集成通过**:要求在真实完整会话中,验证完整 header、工具分层流转、PTC 真实激活、SDK 参数语义解析与沙箱策略执行无误。
95
+ - **模式集成通过**:要求在真实完整会话中,验证完整 header、所配置呈现行为、分页激活与驱逐、`run_code` 下的 SDK 参数语义解析与沙箱策略执行无误。
91
96
  - **统计显著性提升**:必须在固定 route 与源码 hash 记录的隔离环境中进行多轮对比评测,综合评估任务完成率、工具失败率、规则违反率、人工介入次数与耗时/token 开销。单次或少数 smoke 运行不构成效果提升的证据。
92
- 2. **评测工具**:隔离 runner 位于 `packages/dsh-liangshen/tools/benchmark-live-run.mjs`:它把被评测 preset 写入临时目录并通过 roster 自己的 `roots` 配置选中,把会话持久化改写到本次运行目录,并为每次运行记录基线(仓库提交、出厂 preset hash、DSH 版本、固定 route、任务版本)。候选矩阵为 `B`(出厂 persona 与两阶段策略)、`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-usd 5`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 与费用合计、单独列出的基础设施失败以及记录的基线。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
97
+ 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-usd 5`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 与费用合计、单独列出的基础设施失败以及记录的基线。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
93
98
 
94
99
  ## 配置
95
100
 
96
101
  | 键 | 默认值 | 行为 |
97
102
  | --- | --- | --- |
98
- | `enabled` | `true` | 总开关:关闭后预设同步与公告都不执行。 |
103
+ | `enabled` | `true` | 总开关:关闭后不声明预设、也不发公告。 |
99
104
  | `announceToAgent` | `false` | 按需开启:开启后向 agent 系统提示注入本插件公告。默认关闭,保持系统提示词干净。 |
105
+ | `presentation` | `both` | 写入本插件所声明 preset 之 `tool-catalog` 行的 wire 呈现:`both`(默认)让原生清单与 `run_code` 同驻;`native` 保持组装出的原生清单;`ptc` 把 wire 收拢为 `run_code`。Host 提交改动后立即重新声明 preset,此后新建的会话即采用新值;已开始的会话保持其已声明的组合。 |
106
+ | `guardEnabled` | `true` | 运行时退化熔断器总开关:检测连续零产出长思考与同参重复失败,触发时注入熔断提示并临时下调推理档位;关闭后不干预任何请求。 |
107
+ | `guardSensitivity` | `balanced` | 熔断灵敏度预设:整体缩放阈值——`conservative`(更少打断,×1.5)、`balanced`(出厂校准值)、`aggressive`(更早触发,×0.5)。 |
108
+ | `guardStallReasoningChars` | `8000` | 单步暴走梯字符阈值的**覆写值**:阈值默认随推理档位自适应(max 档 8000 / high 档 12000 / low 档 20000,按 V4.1 官方 384K 最大输出校准),设置本字段则以本值为准、覆盖所有档位的自适应表。 |
109
+ | `guardGlobalStallCap` | `4` | 熔断器慢烧梯连续步数的**覆写值**:默认随灵敏度预设缩放(balanced 为 4),设置本字段则以本值为准。 |
110
+ | `guardEchoFailures` | `3` | 熔断器空转梯的**覆写值**:同一工具以相同参数连续失败多少次触发。以上熔断字段与 `presentation` 一样写入所声明的 preset 生效。 |
100
111
 
101
- 两个字段都可在 Web 设置界面(插件配置,即时生效)或 profile patch(`dsh plugin` / `cordis.patch.yml`)中编辑。
112
+ 各字段都可在 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 拒绝重组已开始的会话。
102
113
 
103
114
  ## 行为与限制
104
115
 
105
- - 系统提示词在整个会话中保持稳定:persona 块(persona、工作纪律、工作区目录),plan mode 开启时另加其策略段,另加 workspace-instructions 段。工具调用后不会再追加内容,也不施加任何输出预算上限;
106
- - workspace-instructions 段在每次组装时重新读取,指令文件的改动无需持久消息即可在下一次请求生效;该段渲染在稳定前缀之后的最后位置,锚定的缓存前缀不受影响。工作区子目录动态规则后续将扩展支持注册文件工具(含 `str_replace_editor`)及 PTC 内子调用触达的目录;不解析任意 bash/program 代码,不保证 shell 自行文件访问的自动发现;
107
- - wire 的 schema 集在首轮整个 user turn 保持在基础锚定工具集(默认 `[bash, str_replace_editor, exit_plan_mode, skill]`,且支持 `[bash]` 实验);在第二个回合起且仅在 PTC 成功激活时收拢为 `run_code`;目录消息每会话写一次,另在工具面变化(含晋升边界)或压缩遮蔽时替换一次;
108
- - 注入的目录是持久消息:每个会话写入一次,另在工具面变化或压缩遮蔽已发布副本时替换一次,并留在历史中供后续请求使用;
116
+ - 系统提示词在整个会话中保持稳定:persona 块(persona、工作纪律、工作区目录),plan mode 开启时另加其策略段,`system-prompt` 模式下另加 workspace-instructions 段。工具调用后不会再追加内容,也不施加任何输出预算上限;
117
+ - `system-prompt` 模式下 workspace-instructions 段在每次组装时重新读取,指令文件的改动无需持久消息即可在下一次请求生效;该段渲染在稳定前缀之后的最后位置,缓存前缀不受影响。工作区子目录动态规则后续将扩展支持注册文件工具(含 `str_replace_editor`)及 `run_code` 内子调用触达的目录;不解析任意 bash/program 代码,不保证 shell 自行文件访问的自动发现;
118
+ - wire 在整个会话中保持同一种呈现——不存在回合边界跃迁:`both`(出厂默认)同驻原生清单与一个 `run_code`,`native` 携带组装出的原生清单,`ptc` 把 wire 收拢为 `run_code` 一条,其余工具经生成的 SDK 调用;
119
+ - 注入的目录是持久消息:每个会话写入一次,另在工具面变化(分页激活、呈现变更)或压缩遮蔽已发布副本时替换一次,并留在历史中供后续请求使用;
109
120
  - 未观测到 prompt 组装的步不注入任何内容——目录绝不会由过期视图推测;
110
121
  - 若组合中不存在任何被接受的 persona section 名(`deployment:persona-prefix`、`deployment:persona`、`persona`),过滤器会保留组装结果并只告警一次,而不是发出空系统提示词;
111
122
  - plan mode 通过其 `plan:policy` 段支持;置 `keepPlanPolicy: false` 后该模式仍有工具,但失去约束它的策略文本;
112
- - PTC 呈现按会话声明,需要挂载的 code runtime(随包发布的 web 与 headless 组合都挂载 `dsh-code-runtime-worker-thread`);没有 runtime 或激活失败时该模式保持原生呈现并只告警一次;
113
- - 清单就是官方 PTC preset 的模型自著面:不在 `run_code` 之外再发布 `workflow` 工具,而 workflow 引擎仍为 `ralph` 保留挂载;
114
- - 持久 `bash` 会替代 Standard 的一次性 shell 直到会话结束(两个工具都注册 `bash` 名字),因此 shell 状态跨调用保留;win32 上由 `custom-bash` 经 Git Bash 提供同名工具,无 OS 沙箱约束且状态不跨调用保留;
123
+ - 被分页扣留的工具(出厂模式 `mcp__*`)在模型经 `tool_activate` 激活其命名空间之前不进 wire、也不进生成的 SDK;同时最多三个分页命名空间保持激活,激活第四个会把最近最少使用的逐回摘要状态,激活状态在压缩与恢复后从持久事件流重建;
124
+ - working-context 行只在其来源(plan-mode 状态、已激活的分页命名空间、进行中的 todo)可读时注入,否则省略;
125
+ - 工具结果超过 4096 字符即被修剪,保留 2048 字符头部与 1024 字符尾部(守护稀疏索引槽位的同时保住错误尾部与退出码),避免超大输出挤占上下文;
126
+ - `run_code` 需要挂载的 code runtime(随包发布的 web 与 headless 组合都挂载 `dsh-code-runtime-worker-thread`);没有时 `ptc` 与 `both` 不做声明,会话运行原生工具面;
127
+ - 清单不发布 `workflow` 工具,而 workflow 引擎仍为 `ralph` 保留挂载;
128
+ - shell 挂载上游标准 Stdio 栈,POSIX 注册 `bash`,win32 注册 `pwsh`——每个宿主恰好挂一个 shell 工具,带简短功能描述标题卡片与确定性退出码;
115
129
  - 文件工具继承宿主文件沙箱(不挂载裸 `dsh-fs-local`);
116
130
  - preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/liangshen/`;
117
131
  - 插件不发起网络请求,也不增加遥测;
118
132
  - 不要在已经产生内容的会话中途切换 preset;
119
- - 需要 DSH 0.1.5-rc.1+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
133
+ - 需要 DSH 0.1.7-rc.1+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
120
134
 
121
135
  ## 许可
122
136
 
123
- 插件本体 Apache-2.0(zhu1090093659)。`presets/liangshen/agent.cordis.yml` 基于 DeepSeek Harness 内置 Minimal、Standard 与 PTC preset 修改(MIT),`custom-bash.mjs` 来自 xiaobright/dsh-anchored-standard(MIT),版权与许可声明见 preset 的 `NOTICE`。
137
+ 插件本体 Apache-2.0(zhu1090093659)。`presets/liangshen/agent.cordis.yml` 基于 DeepSeek Harness 内置 Minimal、Standard 与 PTC preset 修改(MIT),版权与许可声明见 preset 的 `NOTICE`。
package/cordis.patch.yml CHANGED
@@ -4,8 +4,9 @@
4
4
  # `dsh plugin --profile <name> add link:~/code/dsh-web-ui/packages/dsh-liangshen`.
5
5
  #
6
6
  # The row is a bare plugin by package name: the node half (exports ".") runs
7
- # in the host process and syncs the bundled LiangShen agent preset into
8
- # ~/.dsh/.agent-presets/liangshen on startup. No browser half.
7
+ # in the host process and declares the bundled LiangShen agent preset to the
8
+ # agent-preset registry at activation. No browser half beyond the composer
9
+ # lever and the settings card.
9
10
  - insert:
10
11
  - id: liangshen
11
12
  name: '@linxin666/dsh-liangshen'
package/icon.svg ADDED
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
2
+ <path fill="#4d6bfe" fill-rule="evenodd" d="M 67.5 120 L 70.5 120 L 72.5 121 L 80.5 129 L 81.5 129 L 84.5 132 L 85.5 132 L 90.5 136 L 93.5 137 L 95.5 139 L 101.5 142 L 103.5 142 L 106.5 144 L 111.5 145 L 112.5 146 L 115.5 146 L 119.5 148 Q 122.75 147.25 123.5 149 L 127.5 149 L 128.5 150 L 133.5 150 L 134.5 151 L 140.5 151 L 141.5 152 L 150.5 152 L 151.5 153 L 160.5 153 L 161.5 154 L 171.5 154 L 172.5 155 L 178.5 155 L 179.5 156 Q 183.5 155 184.5 157 L 189.5 157 Q 190.5 159 194.5 158 L 195.5 159 L 197.5 159 L 198.5 160 L 200.5 160 L 201.5 161 L 206.5 162 L 209.5 164 L 211.5 164 L 219.5 168 L 224.5 172 L 227.5 173 L 247 191.5 L 247 192.5 L 253 199.5 L 255.5 204 L 258 201.5 L 263 193.5 L 272.5 183 L 273.5 183 L 280.5 176 L 281.5 176 L 292.5 168 L 300.5 164 L 302.5 164 L 305.5 162 L 307.5 162 L 308.5 161 L 310.5 161 L 314.5 159 L 317.5 159 L 318.5 158 Q 321.75 158.75 322.5 157 L 326.5 157 L 327.5 156 L 331.5 156 L 332.5 155 L 337.5 155 L 338.5 154 L 348.5 154 L 349.5 153 L 358.5 153 L 359.5 152 L 368.5 152 L 369.5 151 L 376.5 151 L 377.5 150 L 383.5 150 L 384.5 149 L 388.5 149 L 389.5 148 L 392.5 148 L 393.5 147 L 396.5 147 L 397.5 146 L 399.5 146 L 400.5 145 L 405.5 144 L 423.5 135 L 426.5 132 L 431.5 129 L 439.5 121 L 441.5 120 L 444.5 120 L 448 123.5 L 448 140.5 L 447 141.5 L 447 149.5 L 446 150.5 L 446 154.5 L 445 155.5 Q 445.75 158.75 444 159.5 L 444 163.5 Q 442.25 164.25 443 167.5 L 440 173.5 L 439 178.5 L 435 185.5 L 435 187.5 L 432 193.5 L 430 195.5 L 429 198.5 L 427 200.5 L 425 204.5 L 419 211.5 L 419 212.5 L 402.5 229 L 401.5 229 L 394.5 235 L 393.5 235 L 388.5 239 L 385.5 240 L 383.5 242 L 371.5 248 L 369.5 248 L 364.5 251 L 362.5 251 L 361.5 252 L 359.5 252 L 358.5 253 L 356.5 253 L 355.5 254 L 353.5 254 L 349.5 256 L 342.5 257 L 338.5 259 L 335.5 259 L 334.5 260 L 327.5 261 L 326.5 262 L 324.5 262 L 323.5 263 L 321.5 263 L 320.5 264 L 318.5 264 L 317.5 265 L 312.5 266 L 309.5 268 L 307.5 268 L 295.5 275 L 288 282.5 Q 287.5 286 285 287.5 Q 285.5 290 284 290.5 L 284 293.5 L 283 294.5 L 283 311.5 L 284 312.5 L 284 318.5 L 285 319.5 L 285 323.5 L 286 324.5 L 286 328.5 Q 288 329.5 287 333.5 L 288 334.5 L 288 337.5 L 289 338.5 L 289 341.5 L 290 342.5 L 290 345.5 L 291 346.5 L 292 353.5 L 293 354.5 L 293 356.5 L 295 360.5 L 295 363.5 L 296 364.5 L 296 367.5 L 297 368.5 L 297 370.5 L 298 371.5 L 298 373.5 L 299 374.5 L 299 376.5 L 301 380.5 L 301 386.5 L 298.5 389 L 294.5 391 Q 292 390.5 291.5 392 L 286.5 392 L 285.5 393 L 272.5 393 L 271.5 394 L 240.5 394 L 239.5 393 L 227.5 393 L 226.5 392 L 221.5 392 Q 220.75 390.25 217.5 391 L 212 387.5 L 211 385.5 L 211 381.5 L 212 380.5 Q 211.5 378 213 377.5 L 213 374.5 L 214 373.5 L 214 371.5 L 216 367.5 L 216 364.5 L 217 363.5 L 217 361.5 L 219 357.5 L 219 354.5 L 221 350.5 L 221 347.5 L 222 346.5 L 222 343.5 L 223 342.5 L 223 339.5 L 224 338.5 L 224 335.5 L 225 334.5 Q 224.25 331.25 226 330.5 L 226 326.5 L 227 325.5 Q 226 321.5 228 320.5 L 228 315.5 L 229 314.5 L 229 292.5 L 228 291.5 L 227 286.5 L 225 284.5 L 223 280.5 L 219.5 277 L 218.5 277 L 212.5 272 L 202.5 267 L 200.5 267 L 197.5 265 L 194.5 265 L 193.5 264 L 191.5 264 L 190.5 263 L 188.5 263 L 184.5 261 L 181.5 261 L 180.5 260 L 173.5 259 L 172.5 258 L 170.5 258 L 166.5 256 L 159.5 255 L 158.5 254 L 156.5 254 L 155.5 253 L 150.5 252 L 147.5 250 L 145.5 250 L 142.5 248 L 140.5 248 L 128.5 242 L 123.5 238 L 120.5 237 L 109.5 228 L 108.5 228 L 95 214.5 L 95 213.5 L 87 204.5 L 84 198.5 L 82 196.5 L 80 191.5 L 77 187.5 L 77 185.5 L 72 175.5 L 72 173.5 L 71 172.5 L 71 170.5 L 69 166.5 L 69 163.5 L 68 162.5 Q 68.75 159.25 67 158.5 L 67 154.5 L 66 153.5 L 66 148.5 L 65 147.5 L 65 139.5 L 64 138.5 L 64 124.5 L 67.5 120 Z"/>
3
+ </svg>