@linxin666/dsh-liangshen 0.3.20 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +51 -35
- package/README.zh.md +53 -37
- package/lib/client.js +640 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +10 -6
- package/lib/types/announce.test.d.ts +1 -0
- package/lib/types/client/LiangShenLever.d.ts +17 -0
- package/lib/types/client/index.d.ts +45 -0
- package/lib/types/client/lever-controller.d.ts +133 -0
- package/lib/types/client/locales.d.ts +27 -0
- package/lib/types/core/lever.d.ts +50 -0
- package/lib/types/index.d.ts +10 -6
- package/lib/types/index.test.d.ts +1 -0
- package/lib/types/schema.test.d.ts +1 -0
- package/lib/types/sync.test.d.ts +1 -0
- package/package.json +29 -2
- package/presets/liangshen/NOTICE +4 -3
- package/presets/liangshen/agent.cordis.yml +122 -86
- package/presets/liangshen/custom-bash.mjs +4 -4
- package/presets/liangshen/minimal-prompt.mjs +534 -0
- package/presets/liangshen/tool-catalog.mjs +518 -0
- package/src/client/LiangShenLever.module.css +314 -0
- package/src/client/LiangShenLever.tsx +176 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +89 -0
- package/src/client/lever-controller.ts +331 -0
- package/src/client/locales.ts +46 -0
- package/src/core/lever.ts +68 -0
- package/src/index.ts +10 -6
- package/src/schema.test.ts +1 -1
- package/src/sync.test.ts +4 -4
- package/tools/analyze-session.mjs +25 -5
- 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:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: e40dec777cb79bc41411a2b5f3a87dfc66e45c26
|
|
6
|
+
README.zh.md: 196c0c65666583edf81169a8de1a379ef2bbd782
|
package/README.md
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
|
-
# dsh-liangshen — LiangShen Mode (
|
|
1
|
+
# dsh-liangshen — LiangShen Mode (minimal persona + PTC tool surface)
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
Ships the
|
|
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 the builtin Minimal preset's one-line persona — extended with the mode's standing working discipline, the session's workspace directory, and the AGENTS.md-style workspace instructions — as the whole system prompt, and delivers its tool surface as a durable user message after the user's own message from the first turn on — the way the harness injects the skill catalog — while the wire is staged: the first (anchor) turn carries the builtin Minimal surface exactly (`bash` alone, natively presented), and from the second turn the session presents its tools in PTC mode, where the wire carries the single `run_code` transport and every other tool is reached from inside the program through the generated SDK. The one wire transition is the deterministic turn boundary, 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
|
|
9
|
+
DeepSeek V4 Pro conditions strongly on the model-visible surface of the FIRST request — the system prompt and the API tool catalog alike — when choosing its execution trajectory. In the community eval ([xiaobright/modeltest](https://github.com/xiaobright/modeltest)), Minimal reached 99/96 while Standard / PTC scored 91/92; Minimal's advantage is its one-line persona, and its price is that it keeps only two tools.
|
|
10
10
|
|
|
11
|
-
|
|
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 merges the two instead of switching between them: the anchoring part (the system prompt) stays Minimal for the whole session, and the capable part (the tool surface) is announced from the first user message through a skill-catalog-style injection, while its schemas engage at the deterministic turn boundary. Under PTC presentation that injection is the model's only source for the generated SDK's bindings, for the program contract that lets one program carry a whole multi-step plan, and for the rule that only `run_code` may be called directly, because the one-line system prompt filters the harness's own `tools:sdk` and `tools:ptc-only` sections away. The capability facts the Standard prompt would carry as tool-guidance prose arrive as a message at the prompt tail, so the stable prefix stays the one-line anchor.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## How it works
|
|
16
14
|
|
|
17
|
-
|
|
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 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 never reach the model; 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;
|
|
17
|
+
3. the anchor turn — the session's first — keeps the wire on the builtin Minimal surface: `bash` alone, presented natively (`anchorTools`); from the second turn `tool-catalog` declares PTC presentation for that session (`agent.ctx.tools.presentAs('ptc')`, declared on the anchor turn's end so the promoted turn's first request already carries the collapsed surface), so the wire collapses to the single `run_code` transport and every other tool in the preset's roster — the Standard-like set with the persistent shell in place of the ephemeral one, plus `str_replace_editor` — is reached from inside the program through the generated SDK;
|
|
18
|
+
4. `tool-catalog` appends the tool list — each tool's argument signature plus a one-line summary — as a durable user message after the user's own message from the first turn on. Its entries are the PTC surface read from the registry (`ctx.tools.sdkSchemas`), not the narrowed anchor wire, so the first turn already names what the promoted turn reaches and the rendered text does not change at the boundary. Under PTC the message also carries the program contract the harness states in those same filtered sections: 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 only `run_code` may be called directly once it is on the wire. It republishes only when the surface changed or the published copy left the visible surface (a compaction, a resume);
|
|
19
|
+
5. runtime contexts (the sandbox and approval snapshots) and the skill catalog flow as in Standard mode.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Windows note: DSH's PTY backend is linux/darwin-only, so on win32 the persistent-shell group is disabled and `bash` comes from `custom-bash` — the same tool name, spawning Git Bash through the ordinary cross-platform subprocess seam (see `presets/liangshen/custom-bash.mjs`).
|
|
20
22
|
|
|
21
|
-
The
|
|
23
|
+
## The lever
|
|
22
24
|
|
|
23
|
-
|
|
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
|
+
The browser half adds a slot-machine lever to the composer tool row, immediately left of the model selector, on the new-session screen:
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
- 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);
|
|
28
|
+
- push it up and the preset you were on before comes back — with nothing remembered yet, that is the deployment default;
|
|
29
|
+
- 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;
|
|
30
|
+
- 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.
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
## Preset configuration
|
|
35
|
+
|
|
36
|
+
Both preset-local plugins are configured in `agent.cordis.yml`:
|
|
37
|
+
|
|
38
|
+
| Key | Default | Behavior |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `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. |
|
|
41
|
+
| `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. |
|
|
42
|
+
| `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. |
|
|
43
|
+
| `descriptionMaxLength` | `200` | Cap for one tool's one-line summary in the injected catalog. The full description stays in the tool schema. |
|
|
44
|
+
| `anchorTools` | `[]` | Tool names that alone form the anchor turn's wire, presented natively; the promoted surface engages from the second turn. Empty disables staging (the assembled wire from the first request). The shipped preset sets `bash`. |
|
|
45
|
+
| `ptcPresentation` | `true` | Declare this session's tools in PTC mode from the second turn on, so the wire collapses to `run_code` and the injected catalog names the SDK bindings. Needs a mounted code runtime; a deployment without one stays native with a one-time warning. Set `false` to keep the assembled roster on the wire from the second turn. |
|
|
33
46
|
|
|
34
47
|
## Install
|
|
35
48
|
|
|
@@ -51,11 +64,12 @@ Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as th
|
|
|
51
64
|
|
|
52
65
|
Export the session JSONL and inspect `request/header`:
|
|
53
66
|
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
67
|
+
- the first header's `system` should be exactly the persona block (the one-line 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;
|
|
68
|
+
- the first header's tools should be exactly the anchor surface — `bash` alone, presented natively — never the promoted roster and never `run_code`;
|
|
69
|
+
- the first turn's admitted messages should hold one `plugin`-sourced message from `liangshen-tool-catalog` after the user message, naming the promoted surface by argument signature and stating the `run_code` contract;
|
|
70
|
+
- from the second turn on, headers carry exactly one tool, `run_code` (PTC presentation); the rendered catalog no longer changes, so no further catalog message is appended per step;
|
|
71
|
+
- after a compaction the catalog is republished once as a replacement list and the session stays in PTC mode;
|
|
72
|
+
- file writes obey the host file sandbox policy — there is no bare local-filesystem bypass.
|
|
59
73
|
|
|
60
74
|
Trajectory drift can be measured without reading raw reasoning:
|
|
61
75
|
|
|
@@ -74,20 +88,22 @@ Both fields are editable in the web settings surface (plugin config, live) or th
|
|
|
74
88
|
|
|
75
89
|
## Behavior and limits
|
|
76
90
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
- The
|
|
91
|
+
- 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;
|
|
92
|
+
- 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. The harness's dynamic reconciliation of descendant instruction files (nested `AGENTS.md` surfaced when a `read`/`write`/`edit` tool touches their directory) is not reproduced: those injections are dropped like the baseline ones, and this mode's file tools rarely carry the `read`/`write`/`edit` names that trigger it;
|
|
93
|
+
- The wire's schema set changes exactly once, at the anchor-turn boundary — from the Minimal `bash` schema to the single `run_code` transport; the catalog message itself is written once per session (plus one replacement when a compaction shadows it), so no per-step or per-turn cache-prefix churn follows;
|
|
94
|
+
- 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;
|
|
95
|
+
- A step whose prompt assembly was not observed injects nothing — the catalog is never guessed from a stale view;
|
|
96
|
+
- 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;
|
|
97
|
+
- 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;
|
|
98
|
+
- 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 the mode stays native — the assembled roster rides the wire from the second turn and the catalog carries no `run_code` contract — with a one-time warning;
|
|
99
|
+
- 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`;
|
|
100
|
+
- 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;
|
|
101
|
+
- The file tools inherit the host file sandbox (no bare `dsh-fs-local` filesystem);
|
|
86
102
|
- The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
|
|
87
103
|
- The plugin makes no network requests and adds no telemetry;
|
|
88
104
|
- Do not switch presets mid-conversation;
|
|
89
|
-
- Requires DSH 0.1.
|
|
105
|
+
- Requires DSH 0.1.5-rc.1+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
|
|
90
106
|
|
|
91
107
|
## License
|
|
92
108
|
|
|
93
|
-
Plugin body Apache-2.0 (zhu1090093659). `presets/liangshen/agent.cordis.yml` derives from the DeepSeek Harness builtin Minimal and
|
|
109
|
+
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,48 @@
|
|
|
1
|
-
# dsh-liangshen —
|
|
1
|
+
# dsh-liangshen — 梁神模式(极简 persona + PTC 工具面)
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
把梁神模式做成 DSH 全家桶里的一键安装插件:Host 启动时把内置 preset 同步到 `~/.dsh/.agent-presets`,新建会话即可在预设选择器中选择「梁神模式」,浏览器半区还在新建会话页的模型选择器旁提供一台老虎机拨杆来开关该模式。该 preset 让系统提示词永久保持官方 Minimal 的一行 persona——外加本模式的固定工作纪律、会话工作区目录与 AGENTS.md 类工作区指令——并从第一条用户消息起就把工具面作为持久 user 消息注入在用户消息之后——形状与 harness 注入 skill 目录一致——而 wire 按回合分层:首个(锚定)回合原样保持官方 Minimal 面(只有 `bash`,原生呈现),从第二个回合起该会话以 PTC 模式呈现工具,wire 上只有 `run_code` 这一条传输工具,其余工具都在程序里经生成的 SDK 调用。唯一的一次 wire 跃迁就是确定性的回合边界,没有推理内容门控、没有输出预算上限。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
|
|
6
6
|
|
|
7
7
|
## 原理
|
|
8
8
|
|
|
9
|
-
DeepSeek V4 Pro
|
|
9
|
+
DeepSeek V4 Pro 在选择执行轨迹时,会强烈依赖**第一次请求的模型可见面**——既包括系统提示词,也包括 API 工具目录。社区评测([xiaobright/modeltest](https://github.com/xiaobright/modeltest))中,Minimal 达到 99/96,而 Standard / PTC 只有 91/92:Minimal 的优势来自那一行 persona,代价是它只保留两个工具。
|
|
10
10
|
|
|
11
|
-
|
|
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
|
+
梁神模式不在这两者之间切换,而是把它们合并:负责锚定的部分(系统提示词)全程保持 Minimal,负责能力的部分(工具面)从第一条用户消息起就以 skill-catalog 式的上下文注入宣告,而它的 schema 在确定性的回合边界生效。在 PTC 呈现下,这条注入是模型了解生成 SDK 的绑定清单、「一段程序编排多步调用」的程序契约、以及「只有 `run_code` 可直接调用」这条规则的唯一来源,因为一行 persona 的系统提示词会把 harness 自己的 `tools:sdk` 与 `tools:ptc-only` 段一并裁掉。Standard 提示词里以工具用法散文承载的能力事实,改为在提示词尾部以一条消息送达,因此稳定前缀始终是那一行锚定 persona。
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 工作机制
|
|
16
14
|
|
|
17
|
-
|
|
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 注入则被丢弃以免与提示词重复;
|
|
17
|
+
3. 锚定回合(会话的第一个回合)把 wire 保持在官方 Minimal 面上:只有 `bash`,原生呈现(`anchorTools`);从第二个回合起 `tool-catalog` 为该会话声明 PTC 呈现(`agent.ctx.tools.presentAs('ptc')`,在锚定回合结束时声明,因此晋升回合的第一次请求就已经带收敛后的面),于是 wire 收拢为 `run_code` 这一条传输工具,本 preset 清单里的其余工具——Standard 的工具集,以持久 shell 取代一次性 shell,另加 `str_replace_editor`——都在程序里经生成的 SDK 调用;
|
|
18
|
+
4. `tool-catalog` 把工具清单——每个工具的参数签名加一行摘要——从第一条用户消息起作为持久 user 消息追加在用户消息之后。条目取自注册表的 PTC 面(`ctx.tools.sdkSchemas`),而不是收窄后的锚定 wire,所以第一轮就点名了晋升回合才可达的全部工具,渲染文本也不在边界处变化。PTC 下这条消息还承载 harness 在同样被裁掉的那两段里写明的程序契约:一段程序完成一个意图而不是一步一次调用、`run_code` 的 `code`/`description` 形状、独立只读调用用 `Promise.all` 并发、`ToolCallError` 的处理、程序输出需要自己挑选,以及 `run_code` 一旦在 wire 上就是唯一可直接调用的工具。只在工具面变化、或已发布副本离开可见面(压缩、恢复)时重发;
|
|
19
|
+
5. 运行时上下文(sandbox 与 approval 快照)与 skill 目录按 Standard 模式正常注入。
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Windows 说明:DSH 的 PTY 后端仅支持 linux/darwin,win32 上持久 shell 组被禁用,`bash` 由 `custom-bash` 提供——工具名相同,经普通跨平台子进程通道调起 Git Bash(见 `presets/liangshen/custom-bash.mjs`)。
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
## 拨杆
|
|
22
24
|
|
|
23
|
-
|
|
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
|
+
浏览器半区在新建会话页的输入框工具行里、模型选择器紧左侧装了一台老虎机拨杆:
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
- 把拨杆拨下——拖动、点击或用键盘激活都算——即将开始的会话就组合为梁神模式;命中后播放中奖特效(闪光、冲击环、火花,以及「梁神模式」横幅叠文言文、二进制、摩斯三行);
|
|
28
|
+
- 把拨杆上拨,就回到你此前的模式——还没有记住任何模式时,回到部署默认预设;
|
|
29
|
+
- 拨杆始终反映会话真实的预设,刷新页面后状态依然正确;且只在会话仍为空时渲染——会话一旦开始,宿主拒绝重新组合,整行控件直接从输入框中消失;
|
|
30
|
+
- 被拒绝的切换会在拨杆下方显示宿主给出的原因,且不播放特效;`prefers-reduced-motion` 下保留状态变化、去掉动画。
|
|
31
|
+
|
|
32
|
+
拨杆通过浏览器会话已经完成鉴权的 agent-preset Remote 命名空间驱动会话预设,不额外申请权限。它只在会话为空时改动预设,而那正是它渲染所在的新建会话页。
|
|
33
|
+
|
|
34
|
+
## Preset 配置
|
|
35
|
+
|
|
36
|
+
两个 preset 内置插件都在 `agent.cordis.yml` 中配置:
|
|
37
|
+
|
|
38
|
+
| 键 | 默认值 | 行为 |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `keepPlanPolicy` | `true` | 在只有一行 persona 的系统提示词中保留 plan mode 的 `plan:policy` 段。置 `false` 得到严格的一行表面,此时 plan mode 背后没有任何策略文本。 |
|
|
41
|
+
| `instructionSource` | `system-prompt` | 工作区指令送达模型的方式。`system-prompt` 在组装时读取 AGENTS.md 链并追加进系统提示词(harness 自己的注入被丢弃);`hint` 恢复指针行为:首次注入替换为一次性的、非命令式的参考文件提示,后续注入丢弃。 |
|
|
42
|
+
| `instructionMaxBytes` | `65536` | 渲染后的 workspace-instructions 段的字节预算(system-prompt 模式):最宽的文件先被省略,最具体的文件最后被截断。 |
|
|
43
|
+
| `descriptionMaxLength` | `200` | 注入目录中单个工具一行摘要的长度上限。完整描述仍留在工具 schema 中。 |
|
|
44
|
+
| `anchorTools` | `[]` | 锚定回合 wire 上仅有的工具名,原生呈现;晋升面从第二个回合起生效。留空则关闭分层(第一次请求就带组装出的 wire)。出厂 preset 设为 `bash`。 |
|
|
45
|
+
| `ptcPresentation` | `true` | 从第二个回合起为该会话声明 PTC 呈现,于是 wire 收拢为 `run_code`,注入目录列出 SDK 绑定。需要挂载 code runtime;没有 runtime 的部署保持原生并只告警一次。置 `false` 则从第二个回合起 wire 上仍是组装出的清单。 |
|
|
33
46
|
|
|
34
47
|
## 安装
|
|
35
48
|
|
|
@@ -51,16 +64,17 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
|
|
|
51
64
|
|
|
52
65
|
导出 session JSONL,检查 `request/header`:
|
|
53
66
|
|
|
54
|
-
- 第一份 header
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
67
|
+
- 第一份 header 的 `system` 应恰好是 persona 块(一行 persona、工作纪律清单、工作区目录行 `Your working directory is <cwd>.`),plan mode 开启时另加其策略段,再另加承载 AGENTS.md 链的 `workspace-instructions` 段;
|
|
68
|
+
- 第一份 header 的 tools 应恰好是锚定面——只有 `bash`,原生呈现——既不是晋升清单,也不会是 `run_code`;
|
|
69
|
+
- 首个回合放行的消息里应有一条来自 `liangshen-tool-catalog` 的 `plugin` 消息,位于用户消息之后,按参数签名列出晋升面并写明 `run_code` 契约;
|
|
70
|
+
- 从第二个回合起,header 上恰好只有一条工具 `run_code`(PTC 呈现);目录渲染文本不再变化,因此不会每步再追加目录消息;
|
|
71
|
+
- 压缩之后目录会重发一次,形式为替换清单,且会话保持 PTC 呈现;
|
|
72
|
+
- 文件写入受宿主文件沙箱策略约束,不存在裸本地文件系统绕过。
|
|
59
73
|
|
|
60
74
|
不读原始 reasoning 也能测量轨迹漂移:
|
|
61
75
|
|
|
62
76
|
```sh
|
|
63
|
-
node tools/analyze-session.mjs
|
|
77
|
+
node tools/analyze-session.mjs ~/.dsh/sessions/<workspace>/<session>/session.jsonl
|
|
64
78
|
```
|
|
65
79
|
|
|
66
80
|
## 配置
|
|
@@ -74,20 +88,22 @@ node tools/analyze-session.mjs <导出的 session.jsonl>
|
|
|
74
88
|
|
|
75
89
|
## 行为与限制
|
|
76
90
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
91
|
+
- 系统提示词在整个会话中保持稳定:persona 块(persona、工作纪律、工作区目录),plan mode 开启时另加其策略段,另加 workspace-instructions 段。工具调用后不会再追加内容,也不施加任何输出预算上限;
|
|
92
|
+
- workspace-instructions 段在每次组装时重新读取,指令文件的改动无需持久消息即可在下一次请求生效;该段渲染在稳定前缀之后的最后位置,锚定的缓存前缀不受影响。harness 对后代目录指令文件的动态 reconcile(`read`/`write`/`edit` 工具触碰其目录时浮出的嵌套 `AGENTS.md`)不被复刻:那些注入与基线注入一样被丢弃,而且本模式的文件工具很少携带触发它的 `read`/`write`/`edit` 名字;
|
|
93
|
+
- wire 的 schema 集只在锚定回合边界变化一次——从 Minimal 的 `bash` schema 换到 `run_code` 这一条传输工具;目录消息本身每会话写一次(另在压缩遮蔽时替换一次),因此不会出现每步、每回合的缓存前缀扰动;
|
|
94
|
+
- 注入的目录是持久消息:每个会话写入一次,另在工具面变化或压缩遮蔽已发布副本时替换一次,并留在历史中供后续请求使用;
|
|
95
|
+
- 未观测到 prompt 组装的步不注入任何内容——目录绝不会由过期视图推测;
|
|
96
|
+
- 若组合中不存在任何被接受的 persona section 名(`deployment:persona-prefix`、`deployment:persona`、`persona`),过滤器会保留组装结果并只告警一次,而不是发出空系统提示词;
|
|
97
|
+
- plan mode 通过其 `plan:policy` 段支持;置 `keepPlanPolicy: false` 后该模式仍有工具,但失去约束它的策略文本;
|
|
98
|
+
- PTC 呈现按会话声明,需要挂载的 code runtime(随包发布的 web 与 headless 组合都挂载 `dsh-code-runtime-worker-thread`);没有 runtime 时该模式保持原生——第二个回合起 wire 上仍是组装出的清单,目录也不带 `run_code` 契约——并只告警一次;
|
|
99
|
+
- 清单就是官方 PTC preset 的模型自著面:不在 `run_code` 之外再发布 `workflow` 工具,而 workflow 引擎仍为 `ralph` 保留挂载;
|
|
100
|
+
- 持久 `bash` 会替代 Standard 的一次性 shell 直到会话结束(两个工具都注册 `bash` 名字),因此 shell 状态跨调用保留;win32 上由 `custom-bash` 经 Git Bash 提供同名工具,无 OS 沙箱约束;
|
|
101
|
+
- 文件工具继承宿主文件沙箱(不挂载裸 `dsh-fs-local`);
|
|
102
|
+
- preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/liangshen/`;
|
|
87
103
|
- 插件不发起网络请求,也不增加遥测;
|
|
88
104
|
- 不要在已经产生内容的会话中途切换 preset;
|
|
89
|
-
- 需要 DSH 0.1.
|
|
105
|
+
- 需要 DSH 0.1.5-rc.1+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
|
|
90
106
|
|
|
91
107
|
## 许可
|
|
92
108
|
|
|
93
|
-
插件本体 Apache-2.0(zhu1090093659)。`presets/liangshen/agent.cordis.yml` 基于 DeepSeek Harness 内置 Minimal 与
|
|
109
|
+
插件本体 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`。
|