@linxin666/dsh-liangshen 0.3.20 → 0.3.22

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 (38) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +69 -39
  3. package/README.zh.md +70 -40
  4. package/lib/client.js +640 -0
  5. package/lib/client.js.map +1 -0
  6. package/lib/index.js +11 -6
  7. package/lib/types/announce.test.d.ts +1 -0
  8. package/lib/types/client/LiangShenLever.d.ts +17 -0
  9. package/lib/types/client/index.d.ts +45 -0
  10. package/lib/types/client/lever-controller.d.ts +133 -0
  11. package/lib/types/client/locales.d.ts +27 -0
  12. package/lib/types/core/lever.d.ts +50 -0
  13. package/lib/types/index.d.ts +11 -6
  14. package/lib/types/index.test.d.ts +1 -0
  15. package/lib/types/schema.test.d.ts +1 -0
  16. package/lib/types/sync.test.d.ts +1 -0
  17. package/package.json +29 -2
  18. package/presets/liangshen/NOTICE +4 -3
  19. package/presets/liangshen/agent.cordis.yml +129 -86
  20. package/presets/liangshen/custom-bash.mjs +4 -4
  21. package/presets/liangshen/minimal-prompt.mjs +835 -0
  22. package/presets/liangshen/tool-catalog.mjs +631 -0
  23. package/src/client/LiangShenLever.module.css +314 -0
  24. package/src/client/LiangShenLever.tsx +176 -0
  25. package/src/client/css-modules.d.ts +5 -0
  26. package/src/client/index.ts +89 -0
  27. package/src/client/lever-controller.ts +331 -0
  28. package/src/client/locales.ts +46 -0
  29. package/src/core/lever.ts +68 -0
  30. package/src/index.ts +11 -6
  31. package/src/schema.test.ts +1 -1
  32. package/src/sync.test.ts +4 -4
  33. package/tools/analyze-session.mjs +25 -5
  34. package/tools/benchmark-driver.mjs +124 -0
  35. package/tools/benchmark-live-run.mjs +771 -0
  36. package/tools/benchmark-report.mjs +354 -0
  37. package/tools/tasks/liangshen-v41-flash.json +127 -0
  38. package/presets/liangshen/tool-bootstrap.mjs +0 -601
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: 3095722df534a0ae74dd6eafca74c4b55ac40b3a
6
- README.zh.md: 3e7b28a33b4503ada59435598f0f73626354ef3d
5
+ README.md: fce0b0bac57f894854372a0ad570092e6b74793d
6
+ README.zh.md: 82ed025985564508569bef37c08a07a9b5cdc452
package/README.md CHANGED
@@ -1,35 +1,58 @@
1
- # dsh-liangshen — LiangShen Mode (two-phase anchored-standard agent preset)
1
+ # dsh-liangshen — LiangShen Mode (minimal persona + PTC tool surface)
2
2
 
3
3
  English | [中文](README.zh.md)
4
4
 
5
- Ships the "Anchored Standard" 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. The first model request sees only the builtin Minimal preset's exact two tools — persistent `bash` plus `str_replace_editor` — only the one-line persona prompt section, no runtime contexts, and no injected instructions; after the anchor is established the wire switches to PTC Mode and the ordinary injections open. 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: 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.
6
6
 
7
7
  ## Why
8
8
 
9
- DeepSeek V4 Pro conditions strongly on the API tool catalog visible in the FIRST request when choosing its execution trajectory. In the community eval ([xiaobright/modeltest](https://github.com/xiaobright/modeltest)), Standard / PTC scored 91/92 while Minimal reached 99/96 — but Minimal keeps only two tools. This two-phase approach separates the first-trajectory choice from full later capability:
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.
10
10
 
11
- 1. The first model request exposes only the builtin Minimal preset's exact two tools (persistent `bash` plus `str_replace_editor`), keeps only the `deployment:persona` prompt section, empties runtime contexts, and passes only the user's own messages;
12
- 2. After the session's first durable `tool/call`, promotion waits until the first reasoning block is minimal-like (contains `we` and no `let me`), with a four-step fallback; the wire then switches to PTC Mode — a single `run_code` tool backed by the full tool registry SDK — and every assembled prompt section plus the ordinary workspace-instruction, skill-catalog, and runtime-context injections return;
13
- 3. The phase derives from persisted session events, so resume / reload never lose state.
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.
14
12
 
15
- Measured on native Windows (DeepSeek V4 Pro, max, V4.1b task): 98 / 99, mean 98.5, zero `let me` traces in the second run — reproducible, not a lucky draw, and no tool capability sacrificed. Original experiment: [xiaobright/dsh-anchored-standard](https://github.com/xiaobright/dsh-anchored-standard).
13
+ ## How it works
16
14
 
17
- Windows note: DSH's PTY backend is linux/darwin-only, so on win32 the persistent-shell group is disabled and phase-1 `bash` switches to `custom-bash` — the same name and Minimal-compatible schema, spawning Git Bash through the ordinary cross-platform subprocess seam (see `presets/liangshen/custom-bash.mjs`).
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.
18
20
 
19
- ## Stabilization controls
21
+ ## Security model
20
22
 
21
- The preset ships with extra safeguards on top of the reference mechanism, all configured in `agent.cordis.yml` under `tool-bootstrap`:
23
+ This mode operates strictly within the official host security architecture and complies with sandbox policies:
22
24
 
23
- - `anchorGate` — after the first `tool/call`, the catalog stays two-tool until the first reasoning block classifies minimal-like, so a `Let me` first block does not immediately earn the full catalog;
24
- - `maxBootstrapSteps` — fallback promotion after N steps when no anchored block appeared;
25
- - `promoteAfterFirstResponse` — a tool-less first response promotes once it has responded; an anchor-gated session also releases when its first turn ends (`turn/end`), so the next user turn already sees the promoted catalog;
26
- - `promotedPresentation: code` — after promotion the wire is PTC Mode: one `run_code` tool with the full registry available through the generated SDK, switched at the step boundary so the current step's native calls are never interrupted;
27
- - `deferredSources` + `deferredGraceSteps` — workspace instructions and the skill catalog wait one extra step after promotion, so the tool-catalog switch and the injection shock do not land in the same step;
28
- - `instructionHint` (on by default, issue #388) — the post-promotion full-text AGENTS.md injection is replaced by a single non-imperative hint naming the reference files and suggesting on-demand reads, so the injection never flips the anchored trajectory; the model still reaches the knowledge through read / skill_load. Set `false` to restore the legacy full-text injection;
29
- - `bootstrapMaxTokens` — caps the phase-1 request output budget (community measurements put `max_tokens=1024` in the high-hit "We need" window, versus 0/5 at the 256k DSH default), and the cap is stripped again after promotion so `requestProposal` never solders 1024 into every later request;
30
- - `phase1FirstCallInstruction` — an opt-in extra line appended to the phase-1 persona, off by default: test builds use it to ask the model to ground its first answer with one Minimal-native tool call before responding, so first-turn capability questions are answered from the promoted registry instead of the cropped two-tool view. It deviates from the byte-exact Minimal surface, which is why it ships unset.
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.
31
32
 
32
- Plan mode is supported: phase 1 filters the assembled prompt sections down to the one-line `deployment:persona`, and promotion restores all sections and appends the session's working directory to the persona, so the agent knows its workspace and the plan-mode `plan:policy` section takes effect for every step after promotion.
33
+ ## The lever
34
+
35
+ The browser half adds a slot-machine lever to the composer tool row, immediately left of the model selector, on the new-session screen:
36
+
37
+ - pull the lever down — drag it, click it, or press it with the keyboard — and the session about to start composes LiangShen mode; a landed pull plays the jackpot burst (flash, shockwave, sparks, and a banner reading 梁神模式 over classical Chinese, binary, and Morse lines);
38
+ - push it up and the preset you were on before comes back — with nothing remembered yet, that is the deployment default;
39
+ - the arm always reports the session's real preset, so a reload shows the true state, and the lever renders only while the session is still blank — in a session that has started, the host refuses to recompose, and the row disappears from the composer entirely;
40
+ - a refused switch prints the host's reason under the lever and never plays the burst, and `prefers-reduced-motion` keeps the state change while dropping the animation.
41
+
42
+ The lever drives the session's preset through the agent-preset Remote namespace the browser session is already authenticated for, so it needs no additional permissions. It acts on the preset only while the session is blank, which is exactly the new-session screen it renders on.
43
+
44
+ ## Preset configuration
45
+
46
+ Both preset-local plugins are configured in `agent.cordis.yml`:
47
+
48
+ | Key | Default | Behavior |
49
+ | --- | --- | --- |
50
+ | `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. |
33
56
 
34
57
  ## Install
35
58
 
@@ -51,17 +74,22 @@ Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as th
51
74
 
52
75
  Export the session JSONL and inspect `request/header`:
53
76
 
54
- - The first header should carry only `bash/str_replace_editor` (the persistent shell plus the sandboxed editor);
55
- - The first turn should contain only whitelisted source kinds (the user's own messages and `/goal` auto-round messages) — no workspace-instruction baseline, no runtime snapshot, no skill-catalog message — and only the `deployment:persona` prompt section;
56
- - After the first tool call, the next changed header should carry exactly `run_code` (PTC); the runtime snapshot and all prompt sections arrive with that step (including plan mode's `plan:policy`, and the persona now ends with the selected workspace path), and the workspace instructions and skill catalog arrive one step later;
57
- - Phase-1 editor writes obey the host file sandbox policy — there is no bare local-filesystem bypass;
58
- - Later requests keep `run_code`.
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;
82
+ - file writes obey the host file sandbox policy — there is no bare local-filesystem bypass.
59
83
 
60
- Trajectory drift can be measured without reading raw reasoning:
84
+ ### Real session validation conditions and benchmark evaluation
61
85
 
62
- ```sh
63
- node tools/analyze-session.mjs ~/.dsh/sessions/<workspace>/<session>/session.jsonl
64
- ```
86
+ When validating mode behavior and evaluating performance, verification tiers must be strictly distinguished:
87
+
88
+ 1. **Real inference probe ≠ Mode integration pass ≠ Statistical improvement**:
89
+ - **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.
91
+ - **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.
65
93
 
66
94
  ## Configuration
67
95
 
@@ -74,20 +102,22 @@ Both fields are editable in the web settings surface (plugin config, live) or th
74
102
 
75
103
  ## Behavior and limits
76
104
 
77
- - A first model response that calls no tool promotes once it has responded; an anchor-gated session also releases when its first turn ends (`turn/end`). The release is decided during prompt assembly, so the new user turn already gets the promoted PTC catalog and its messages are not stripped;
78
- - After the first tool call, promotion waits for the first minimal-like reasoning block or the `maxBootstrapSteps` fallback, whichever comes first;
79
- - A tool call that fails still counts toward promotion as long as `tool/call` was persisted;
80
- - Phase 1 keeps only the `deployment:persona` prompt section; promotion restores every assembled section and appends the session's working directory (`Your working directory is <cwd>.`) to the persona, so the agent works in the selected workspace and plan mode's `plan:policy` is enforced after phase 1;
81
- - Workspace instructions, the skill catalog, and the runtime snapshot stay out of phase 1; the snapshot returns with the catalog and the other two arrive one step later;
82
- - Phase-1 file tools inherit the host file sandbox (no bare `dsh-fs-local` filesystem);
83
- - The phase-1 persistent `bash` replaces the Standard ephemeral shell for the whole session (both tools register the name `bash`);
84
- - Phase 1 shows the two Minimal tools by design, so a first-turn capability question (for example "can you browse the web") can be answered from the cropped view and then corrected after promotion; the opt-in `phase1FirstCallInstruction` (see Stabilization controls) asks for a grounding tool call first, and otherwise task-style first turns avoid the mismatch;
85
- - The catalog changes exactly once, so a prefix-cache change happens between the first and second request;
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;
109
+ - A step whose prompt assembly was not observed injects nothing — the catalog is never guessed from a stale view;
110
+ - 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
+ - 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;
115
+ - The file tools inherit the host file sandbox (no bare `dsh-fs-local` filesystem);
86
116
  - The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
87
117
  - The plugin makes no network requests and adds no telemetry;
88
118
  - Do not switch presets mid-conversation;
89
- - Requires DSH 0.1.0-rc.5+ (preset mechanism and the `system-prompt/assemble` hook).
119
+ - Requires DSH 0.1.5-rc.1+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
90
120
 
91
121
  ## License
92
122
 
93
- Plugin body Apache-2.0 (zhu1090093659). `presets/liangshen/agent.cordis.yml` derives from the DeepSeek Harness builtin Minimal and Standard presets, and `tool-bootstrap.mjs` comes from xiaobright/dsh-anchored-standard — all MIT, with copyright and license notices kept in the preset's `NOTICE`.
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`.
package/README.zh.md CHANGED
@@ -1,35 +1,58 @@
1
- # dsh-liangshen — 梁神模式(两阶段锚定 agent preset)
1
+ # dsh-liangshen — 梁神模式(极简 persona + PTC 工具面)
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- 把「Anchored Standard」preset 做成 DSH 全家桶里的一键安装插件:Host 启动时把内置 preset 同步到 `~/.dsh/.agent-presets`,新建会话即可在预设选择器中选择「梁神模式」。首轮模型请求只看到官方 Minimal 精确双工具——持久 `bash` 与 `str_replace_editor`——与一行 persona,没有运行时上下文和指令注入;锚定建立后 wire 切换为 PTC Mode,并开放全部 prompt section 与常规注入。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
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 源码。
6
6
 
7
7
  ## 原理
8
8
 
9
- DeepSeek V4 Pro 会强烈依赖 API 中可见的**首轮工具目录**选择执行轨迹。社区评测([xiaobright/modeltest](https://github.com/xiaobright/modeltest))中,Standard / PTC 只有 91/92 分,Minimal 达到 99/96,但 Minimal 只有两个工具。两阶段方案把「首次轨迹选择」与「后续完整工具能力」拆开:
9
+ DeepSeek V4 模型在选择执行轨迹时,会受到初始提示词与首轮可见工具面的显著影响。过多过早暴露未受约束的工具可能分散执行轨迹,而完全缺乏编辑或规划手段又限制了复杂任务的完成。
10
10
 
11
- 1. 首轮模型请求只暴露官方 Minimal 精确双工具(持久 `bash` 与 `str_replace_editor`),只保留 `deployment:persona` 一个 prompt section,清空运行时上下文,并且只放行白名单内的消息(用户自己的消息与 `/goal` 自动轮次消息);
12
- 2. 会话出现首次持久 `tool/call` 后,晋升会等到首个 reasoning 块呈 minimal-like(包含 `we` 且无 `let me`)才发生,四步兜底;随后 wire 切换为 PTC Mode——只暴露一个 `run_code`,完整工具注册表通过生成的 SDK 调用——并恢复全部 prompt section(含 plan mode 的 `plan:policy`)以及 workspace 指令、skill 目录与运行时快照等常规注入;
13
- 3. 阶段从持久化 session events 推导,resume / reload 不丢失状态。
11
+ 梁神模式采用分层工具与紧凑提示词架构:负责锚定的部分(系统提示词)保持极简 persona 与明确的工作纪律,并注入工作区指令;负责能力的部分(工具面)从第一条用户消息起以 skill-catalog 式的上下文注入宣告,并在首轮整个 user turn 原生呈现基础锚定工具集(`[bash, str_replace_editor, exit_plan_mode, skill]`),提供探索、编辑、退出规划与技能查询的基础能力;从第二个回合起在满足 code runtime 条件并成功声明后,平滑过渡至 PTC(程序即代码)模式。在 PTC 呈现下,注入消息承载生成 SDK 的绑定清单、完整输入输出关键参数语义、「一段程序编排多步调用」的程序契约、以及「只有 `run_code` 可直接调用」的规则。本模式不做出「与官方 Minimal 完全一致」、「社区评测分数证明本版必定更优」或「提示词缓存命中等同于行为一致」的过度承诺,而是以清晰的分层契约保障执行稳定性。
14
12
 
15
- Windows 原生环境实测(DeepSeek V4 Pro、max、V4.1b 题面):98 / 99,均值 98.5,第二轮全程无 `let me` 痕迹,证明不是抽卡,也不需要牺牲完整工具能力。原始实验 preset:[xiaobright/dsh-anchored-standard](https://github.com/xiaobright/dsh-anchored-standard)。
13
+ ## 工作机制
16
14
 
17
- Windows 说明:DSH 的 PTY 后端仅支持 linux/darwin,win32 上持久 shell 组被禁用,phase-1 的 `bash` 切换为 `custom-bash`——同名且 schema 与 Minimal 兼容,经普通跨平台子进程通道调起 Git Bash(见 `presets/liangshen/custom-bash.mjs`)。
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 模式正常注入。
18
20
 
19
- ## 稳定化控制
21
+ ## 安全模型
20
22
 
21
- preset 在参考机制之上内置了额外保护,全部在 `agent.cordis.yml` 的 `tool-bootstrap` 段配置:
23
+ 本模式坚持在官方宿主安全架构内运行,严格遵守沙箱策略:
22
24
 
23
- - `anchorGate`:首次 `tool/call` 后,目录继续保持双工具,直到首个 reasoning 块被判定为 minimal-like,避免 `Let me` 开局立刻拿到完整目录;
24
- - `maxBootstrapSteps`:N 步后仍无锚定块时强制晋升;
25
- - `promoteAfterFirstResponse`:首轮无工具调用的回答在响应后自动晋升;锚定门控中的会话也会在首轮结束时(`turn/end`)释放,因此新用户轮次一开始就拿到晋升后的目录;
26
- - `promotedPresentation: code`:晋升后 wire 为 PTC Mode——一个 `run_code` 工具、完整注册表通过生成 SDK 调用;切换发生在 step 边界,不会打断当前步的原生工具调用;
27
- - `deferredSources` + `deferredGraceSteps`:workspace 指令与 skill 目录在晋升后再等一步注入,工具目录切换和注入冲击不同时落地;
28
- - `instructionHint`(默认开启,issue #388):晋升后的 AGENTS.md 全文注入替换为一条非命令式 hint(列出参考文件路径、建议按需读取),模型经 read / skill_load 按需获取,避免全量注入翻转锚定轨迹;置 `false` 恢复旧的全文注入;
29
- - `bootstrapMaxTokens`:phase 1 请求的输出预算封顶(社区实测 `max_tokens=1024` 是 "We need" 轨迹的高命中窗口,DSH 默认 256k 命中率为 0),晋升后自动剥离该封顶,避免 `requestProposal` 把 1024 焊进后续每个请求;
30
- - `phase1FirstCallInstruction`:追加到 phase-1 persona 的可选一行指令,默认关闭:测试版本用它要求模型在正式作答前先做一次 Minimal 原生工具调用,让首轮能力类提问在晋升后的完整目录下作答,而不是基于被裁剪的双工具视图回答。因为它偏离了逐字节一致的 Minimal 表面,所以默认不开启。
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 边界。
31
32
 
32
- 已支持 plan mode:phase 1 会把 prompt sections 过滤为仅剩一行 `deployment:persona`,晋升后恢复全部 sections 并在 persona 末尾追加所选工作区路径,因此 Agent 明确自己的工作目录,plan-mode 的 `plan:policy` 也在晋升后的每一步都生效。
33
+ ## 拨杆
34
+
35
+ 浏览器半区在新建会话页的输入框工具行里、模型选择器紧左侧装了一台老虎机拨杆:
36
+
37
+ - 把拨杆拨下——拖动、点击或用键盘激活都算——即将开始的会话就组合为梁神模式;命中后播放中奖特效(闪光、冲击环、火花,以及「梁神模式」横幅叠文言文、二进制、摩斯三行);
38
+ - 把拨杆上拨,就回到你此前的模式——还没有记住任何模式时,回到部署默认预设;
39
+ - 拨杆始终反映会话真实的预设,刷新页面后状态依然正确;且只在会话仍为空时渲染——会话一旦开始,宿主拒绝重新组合,整行控件直接从输入框中消失;
40
+ - 被拒绝的切换会在拨杆下方显示宿主给出的原因,且不播放特效;`prefers-reduced-motion` 下保留状态变化、去掉动画。
41
+
42
+ 拨杆通过浏览器会话已经完成鉴权的 agent-preset Remote 命名空间驱动会话预设,不额外申请权限。它只在会话为空时改动预设,而那正是它渲染所在的新建会话页。
43
+
44
+ ## Preset 配置
45
+
46
+ 两个 preset 内置插件都在 `agent.cordis.yml` 中配置:
47
+
48
+ | 键 | 默认值 | 行为 |
49
+ | --- | --- | --- |
50
+ | `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 上仍是组装出的原生清单。 |
33
56
 
34
57
  ## 安装
35
58
 
@@ -51,17 +74,22 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
51
74
 
52
75
  导出 session JSONL,检查 `request/header`:
53
76
 
54
- - 第一份 header 应只有 `bash/str_replace_editor`(持久 shell + 沙箱化编辑器);
55
- - 第一轮应只包含用户自己的消息:没有 workspace 指令 baseline、没有运行时快照、没有 skill 目录消息,并且只有 `deployment:persona` 一个 prompt section;
56
- - 首次工具调用后,下一份变更 header 应恰好为 `run_code`(PTC);运行时快照与全部 prompt section 随该步出现(含 plan mode 的 `plan:policy`,且 persona 末尾带有所选工作区路径),workspace 指令与 skill 目录再晚一步出现;
57
- - phase 1 编辑器写入受宿主文件沙箱策略约束,不存在裸本地文件系统绕过;
58
- - 此后的请求保持 `run_code`。
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
+ - 压缩之后目录会重发一次,形式为替换清单,且会话保持当前呈现模式;
82
+ - 文件写入受宿主文件沙箱策略约束,不存在裸本地文件系统绕过。
59
83
 
60
- 不读原始 reasoning 也能测量轨迹漂移:
84
+ ### 真实会话验证条件与评测说明
61
85
 
62
- ```sh
63
- node tools/analyze-session.mjs <导出的 session.jsonl>
64
- ```
86
+ 在进行模式验证与性能评估时,必须严格区分验证层级:
87
+
88
+ 1. **真实推理探针 ≠ 模式集成通过 ≠ 统计提升**:
89
+ - **真实推理探针**:仅验证链路连通性与模型对特定格式的最小响应能力(例如使用 headless 探针验证模型是否能正常解析输出);单次探针成功仅代表功能未阻断,绝不证明模式集成已达标。
90
+ - **模式集成通过**:要求在真实完整会话中,验证完整 header、工具分层流转、PTC 真实激活、SDK 参数语义解析与沙箱策略执行无误。
91
+ - **统计显著性提升**:必须在固定 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 只验证协议与费用估算,不构成通用编码能力提升的证据。
65
93
 
66
94
  ## 配置
67
95
 
@@ -74,20 +102,22 @@ node tools/analyze-session.mjs <导出的 session.jsonl>
74
102
 
75
103
  ## 行为与限制
76
104
 
77
- - 第一次模型响应如果没有调用工具,在响应后即自动晋升;锚定门控中的会话也会在首轮结束(`turn/end`)时释放。释放判定发生在 prompt assemble 阶段,所以新用户轮次一开始就拿到晋升后的 PTC 目录,其消息也不会再被剥离;
78
- - 首次工具调用后,晋升等待首个 minimal-like reasoning 块或 `maxBootstrapSteps` 兜底,先到者生效;
79
- - 工具执行即使失败,只要 `tool/call` 已持久化,仍计入晋升条件;
80
- - phase 1 只保留 `deployment:persona` prompt section;晋升后恢复全部 assembled sections 并在 persona 末尾追加所选工作区路径(`Your working directory is <cwd>.`),因此 Agent 会在选中的工作区工作,plan mode 的 `plan:policy` 也在晋升后生效;
81
- - workspace 指令、skill 目录与运行时快照在首轮不注入;快照随 PTC 目录出现,前两者再晚一步出现;
82
- - phase 1 文件工具继承宿主文件沙箱(不挂载裸 `dsh-fs-local`);
83
- - phase 1 的持久 `bash` 会替代 Standard 的一次性 shell 直到会话结束(两个工具都注册 `bash` 名字);
84
- - phase 1 有意只显示 Minimal 双工具,因此首轮能力类提问(如「你能联网吗」)可能基于被裁剪的视图作答、晋升后再被纠正;可开启 `phase1FirstCallInstruction`(见稳定化控制)要求先做一次 grounding 工具调用,或首轮直接问任务类问题避免该错位;
85
- - 工具目录只变化一次,因此第一、二次请求之间会发生一次前缀缓存变化;
86
- - preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/`;
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
+ - 注入的目录是持久消息:每个会话写入一次,另在工具面变化或压缩遮蔽已发布副本时替换一次,并留在历史中供后续请求使用;
109
+ - 未观测到 prompt 组装的步不注入任何内容——目录绝不会由过期视图推测;
110
+ - 若组合中不存在任何被接受的 persona section 名(`deployment:persona-prefix`、`deployment:persona`、`persona`),过滤器会保留组装结果并只告警一次,而不是发出空系统提示词;
111
+ - 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 沙箱约束且状态不跨调用保留;
115
+ - 文件工具继承宿主文件沙箱(不挂载裸 `dsh-fs-local`);
116
+ - preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/liangshen/`;
87
117
  - 插件不发起网络请求,也不增加遥测;
88
118
  - 不要在已经产生内容的会话中途切换 preset;
89
- - 需要 DSH 0.1.0-rc.5+(preset 机制与 `system-prompt/assemble` 钩子)。
119
+ - 需要 DSH 0.1.5-rc.1+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
90
120
 
91
121
  ## 许可
92
122
 
93
- 插件本体 Apache-2.0(zhu1090093659)。`presets/liangshen/agent.cordis.yml` 基于 DeepSeek Harness 内置 Minimal 与 Standard preset 修改,`tool-bootstrap.mjs` 来自 xiaobright/dsh-anchored-standard,均为 MIT,版权与许可声明见 preset 的 `NOTICE`。
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`。