@linxin666/dsh-liangshen 0.1.13
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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +85 -0
- package/README.zh.md +85 -0
- package/cordis.patch.yml +11 -0
- package/lib/index.js +212 -0
- package/lib/types/index.d.ts +42 -0
- package/lib/types/sync.d.ts +31 -0
- package/package.json +61 -0
- package/presets/liangshen/NOTICE +3 -0
- package/presets/liangshen/agent.cordis.yml +289 -0
- package/presets/liangshen/preset.yml +3 -0
- package/presets/liangshen/tool-bootstrap.mjs +293 -0
- package/presets/liangshen-exact/NOTICE +4 -0
- package/presets/liangshen-exact/agent.cordis.yml +321 -0
- package/presets/liangshen-exact/preset.yml +3 -0
- package/presets/liangshen-exact/tool-bootstrap.mjs +10 -0
- package/src/index.test.ts +61 -0
- package/src/index.ts +119 -0
- package/src/sync.test.ts +125 -0
- package/src/sync.ts +131 -0
- package/tools/analyze-session.mjs +289 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
+
README.md: faa89c7ebfcda993030419a64a1a0ea306bf2ef0
|
|
6
|
+
README.zh.md: b28751b649dff1d0a72c77f21e927671350e5661
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# dsh-liangshen — LiangShen Mode (two-phase anchored-standard agent preset)
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Ships the "Anchored Standard" preset family as a one-command plugin of the dsh-web-ui family: on host startup it syncs the bundled presets into `~/.dsh/.agent-presets`, so new sessions can pick "梁神模式" or the experimental "梁神模式-精确实验" from the preset picker. The first model request sees only a two-tool surface, only the one-line persona prompt section, no runtime contexts, and no injected instructions; the full catalog, all prompt sections, and the ordinary injections open after the anchor is established. Built entirely on the official NPM SDK — no dsh source changes.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
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:
|
|
10
|
+
|
|
11
|
+
1. The first model request exposes only the platform shell plus `read`, keeps only the `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 Code Mode (PTC) — 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.
|
|
14
|
+
|
|
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).
|
|
16
|
+
|
|
17
|
+
## Stabilization controls
|
|
18
|
+
|
|
19
|
+
The preset ships with extra safeguards on top of the reference mechanism, all configured in `agent.cordis.yml` under `tool-bootstrap`:
|
|
20
|
+
|
|
21
|
+
- `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;
|
|
22
|
+
- `maxBootstrapSteps` — fallback promotion after N steps when no anchored block appeared;
|
|
23
|
+
- `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;
|
|
24
|
+
- `promotedPresentation: code` — after promotion the wire is Code Mode (PTC): 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;
|
|
25
|
+
- `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.
|
|
26
|
+
|
|
27
|
+
Plan mode is supported: phase 1 filters the assembled prompt sections down to the one-line `persona`, and promotion restores all sections, so the plan-mode `plan:policy` section takes effect for every step after promotion.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# Option 1: family bundle (recommended)
|
|
33
|
+
dsh plugin --profile web add @linxin666/dsh-web-ui-all@0.1.12
|
|
34
|
+
|
|
35
|
+
# Option 2: standalone
|
|
36
|
+
dsh plugin --profile web add @linxin666/dsh-liangshen@0.1.12
|
|
37
|
+
|
|
38
|
+
# Pick ONE of the two: the bundle and the standalone @linxin666/dsh-liangshen
|
|
39
|
+
# both mount this preset. If you switch between them, remove the other first:
|
|
40
|
+
dsh plugin --profile web remove @linxin666/dsh-liangshen
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
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).
|
|
44
|
+
|
|
45
|
+
## Experimental exact preset
|
|
46
|
+
|
|
47
|
+
"梁神模式-精确实验" (`liangshen-exact`) keeps the same stabilization controls and shares the main preset's `tool-bootstrap.mjs` implementation (only the `tool-bootstrap` config differs), but matches the builtin Minimal preset's exact phase-1 surface: persistent `bash` plus `str_replace_editor`, byte-identical tool description and one-line persona. After promotion it opens the full Standard catalog and all prompt sections.
|
|
48
|
+
|
|
49
|
+
Sandboxing: unlike the builtin Minimal preset, `liangshen-exact` does not mount a bare `dsh-fs-local` filesystem — its phase-1 file tools inherit the host file sandbox (the editor reuses the host sandboxed `ctx.fs`), exactly like every Standard file tool.
|
|
50
|
+
|
|
51
|
+
Tradeoff: the persistent shell replaces the Standard ephemeral `bash` for the whole session (both tools register the name `bash`), so it is the A/B variant for comparing anchor hit rate, not a drop-in replacement for the main preset.
|
|
52
|
+
|
|
53
|
+
## Verify
|
|
54
|
+
|
|
55
|
+
Export the session JSONL and inspect `request/header`:
|
|
56
|
+
|
|
57
|
+
- The first header should carry only `bash/read` (macOS/Linux) or `pwsh/read` (Windows); `liangshen-exact` should carry `bash/str_replace_editor`;
|
|
58
|
+
- The first turn should contain only the user's own messages — no workspace-instruction baseline, no runtime snapshot, no skill-catalog message — and only the `persona` prompt section;
|
|
59
|
+
- After the first tool call, the next changed header should carry exactly `run_code` (PTC); the runtime snapshot and all prompt sections (including plan mode's `plan:policy`) arrive with that step and the workspace instructions and skill catalog arrive one step later;
|
|
60
|
+
- In `liangshen-exact`, phase-1 editor writes still obey the host file sandbox policy — there is no bare local-filesystem bypass;
|
|
61
|
+
- Later requests keep `run_code`.
|
|
62
|
+
|
|
63
|
+
Trajectory drift can be measured without reading raw reasoning:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
node tools/analyze-session.mjs ~/.dsh/sessions/<workspace>/<session>/session.jsonl
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Behavior and limits
|
|
70
|
+
|
|
71
|
+
- 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;
|
|
72
|
+
- After the first tool call, promotion waits for the first minimal-like reasoning block or the `maxBootstrapSteps` fallback, whichever comes first;
|
|
73
|
+
- A tool call that fails still counts toward promotion as long as `tool/call` was persisted;
|
|
74
|
+
- Phase 1 keeps only the `persona` prompt section; promotion restores every assembled section, so plan mode's `plan:policy` is enforced after phase 1;
|
|
75
|
+
- 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;
|
|
76
|
+
- `liangshen-exact` file tools inherit the host file sandbox (no bare `dsh-fs-local` filesystem);
|
|
77
|
+
- The catalog changes exactly once, so a prefix-cache change happens between the first and second request;
|
|
78
|
+
- The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
|
|
79
|
+
- The plugin makes no network requests and adds no telemetry;
|
|
80
|
+
- Do not switch presets mid-conversation;
|
|
81
|
+
- Requires DSH 0.1.0-rc.5+ (preset mechanism and the `system-prompt/assemble` hook).
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Plugin body Apache-2.0 (zhu1090093659). `presets/liangshen/agent.cordis.yml` derives from the DeepSeek Harness Standard preset, `presets/liangshen-exact/agent.cordis.yml` derives from the builtin Minimal and Standard presets, and `tool-bootstrap.mjs` comes from xiaobright/dsh-anchored-standard — all MIT, with copyright and license notices kept in each preset's `NOTICE`. `presets/liangshen-exact/tool-bootstrap.mjs` is a thin re-export of `presets/liangshen/tool-bootstrap.mjs`, so the two presets share one implementation.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# dsh-liangshen — 梁神模式(两阶段锚定 agent preset)
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
把「Anchored Standard」preset 家族做成 DSH 全家桶里的一键安装插件:Host 启动时把内置 presets 同步到 `~/.dsh/.agent-presets`,新建会话即可在预设选择器中选择「梁神模式」或实验性的「梁神模式-精确实验」。首轮模型请求只看到双工具表面与一行 persona,没有运行时上下文和指令注入;锚定建立后开放完整工具目录、全部 prompt section 与常规注入。全部通过官方 NPM SDK 实现,不修改 DSH 源码。
|
|
6
|
+
|
|
7
|
+
## 原理
|
|
8
|
+
|
|
9
|
+
DeepSeek V4 Pro 会强烈依赖 API 中可见的**首轮工具目录**选择执行轨迹。社区评测([xiaobright/modeltest](https://github.com/xiaobright/modeltest))中,Standard / PTC 只有 91/92 分,Minimal 达到 99/96,但 Minimal 只有两个工具。两阶段方案把「首次轨迹选择」与「后续完整工具能力」拆开:
|
|
10
|
+
|
|
11
|
+
1. 首轮模型请求只暴露平台 shell 与 `read`,只保留 `persona` 一个 prompt section,清空运行时上下文,并且只放行用户自己的消息;
|
|
12
|
+
2. 会话出现首次持久 `tool/call` 后,晋升会等到首个 reasoning 块呈 minimal-like(包含 `we` 且无 `let me`)才发生,四步兜底;随后 wire 切换为 Code Mode(PTC)——只暴露一个 `run_code`,完整工具注册表通过生成的 SDK 调用——并恢复全部 prompt section(含 plan mode 的 `plan:policy`)以及 workspace 指令、skill 目录与运行时快照等常规注入;
|
|
13
|
+
3. 阶段从持久化 session events 推导,resume / reload 不丢失状态。
|
|
14
|
+
|
|
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)。
|
|
16
|
+
|
|
17
|
+
## 稳定化控制
|
|
18
|
+
|
|
19
|
+
preset 在参考机制之上内置了额外保护,全部在 `agent.cordis.yml` 的 `tool-bootstrap` 段配置:
|
|
20
|
+
|
|
21
|
+
- `anchorGate`:首次 `tool/call` 后,目录继续保持双工具,直到首个 reasoning 块被判定为 minimal-like,避免 `Let me` 开局立刻拿到完整目录;
|
|
22
|
+
- `maxBootstrapSteps`:N 步后仍无锚定块时强制晋升;
|
|
23
|
+
- `promoteAfterFirstResponse`:首轮无工具调用的回答在响应后自动晋升;锚定门控中的会话也会在首轮结束时(`turn/end`)释放,因此新用户轮次一开始就拿到晋升后的目录;
|
|
24
|
+
- `promotedPresentation: code`:晋升后 wire 为 Code Mode(PTC)——一个 `run_code` 工具、完整注册表通过生成 SDK 调用;切换发生在 step 边界,不会打断当前步的原生工具调用;
|
|
25
|
+
- `deferredSources` + `deferredGraceSteps`:workspace 指令与 skill 目录在晋升后再等一步注入,工具目录切换和注入冲击不同时落地。
|
|
26
|
+
|
|
27
|
+
已支持 plan mode:phase 1 会把 prompt sections 过滤为仅剩一行 `persona`,晋升后恢复全部 sections,因此 plan-mode 的 `plan:policy` 在晋升后的每一步都生效。
|
|
28
|
+
|
|
29
|
+
## 安装
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# 方式一:全家桶(推荐)
|
|
33
|
+
dsh plugin --profile web add @linxin666/dsh-web-ui-all@0.1.12
|
|
34
|
+
|
|
35
|
+
# 方式二:单独安装
|
|
36
|
+
dsh plugin --profile web add @linxin666/dsh-liangshen@0.1.12
|
|
37
|
+
|
|
38
|
+
# 两种方式二选一:聚合包与独立 @linxin666/dsh-liangshen 都会挂载本 preset。
|
|
39
|
+
# 需要在两者之间切换时,先 dsh plugin remove 移除另一个再安装:
|
|
40
|
+
dsh plugin --profile web remove @linxin666/dsh-liangshen
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
装完**完整重启 `dsh web`**,新建空 session,预设选择「梁神模式」。插件会在启动时把 presets 同步进 `~/.dsh/.agent-presets`(升级插件后重启即自动更新)。
|
|
44
|
+
|
|
45
|
+
## 精确实验预设
|
|
46
|
+
|
|
47
|
+
「梁神模式-精确实验」(`liangshen-exact`)保留相同的稳定化控制,并与主 preset 共用同一份 `tool-bootstrap.mjs` 实现(只有 `tool-bootstrap` config 不同),但 phase 1 与内置 Minimal 预设逐字节对齐:持久 `bash` + `str_replace_editor`,工具描述与一行 persona 完全一致;晋升后开放完整 Standard 目录与全部 prompt section。
|
|
48
|
+
|
|
49
|
+
沙箱说明:与内置 Minimal 预设不同,`liangshen-exact` 不挂载裸的 `dsh-fs-local` 文件系统——phase 1 文件工具继承宿主文件沙箱(编辑器复用宿主的 sandboxed `ctx.fs`),与所有 Standard 文件工具一致。
|
|
50
|
+
|
|
51
|
+
代价:持久 shell 会替代 Standard 的一次性 `bash` 直到会话结束(两个工具都注册 `bash` 名字),所以它用于对比锚定命中率的 A/B 实验,不替代主 preset。
|
|
52
|
+
|
|
53
|
+
## 验证
|
|
54
|
+
|
|
55
|
+
导出 session JSONL,检查 `request/header`:
|
|
56
|
+
|
|
57
|
+
- 第一份 header 应只有 `bash/read`(macOS/Linux)或 `pwsh/read`(Windows);`liangshen-exact` 应为 `bash/str_replace_editor`;
|
|
58
|
+
- 第一轮应只包含用户自己的消息:没有 workspace 指令 baseline、没有运行时快照、没有 skill 目录消息,并且只有 `persona` 一个 prompt section;
|
|
59
|
+
- 首次工具调用后,下一份变更 header 应恰好为 `run_code`(PTC);运行时快照与全部 prompt section(含 plan mode 的 `plan:policy`)随该步出现,workspace 指令与 skill 目录再晚一步出现;
|
|
60
|
+
- `liangshen-exact` 的 phase 1 编辑器写入仍受宿主文件沙箱策略约束,不存在裸本地文件系统绕过;
|
|
61
|
+
- 此后的请求保持 `run_code`。
|
|
62
|
+
|
|
63
|
+
不读原始 reasoning 也能测量轨迹漂移:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
node tools/analyze-session.mjs <导出的 session.jsonl>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 行为与限制
|
|
70
|
+
|
|
71
|
+
- 第一次模型响应如果没有调用工具,在响应后即自动晋升;锚定门控中的会话也会在首轮结束(`turn/end`)时释放。释放判定发生在 prompt assemble 阶段,所以新用户轮次一开始就拿到晋升后的 PTC 目录,其消息也不会再被剥离;
|
|
72
|
+
- 首次工具调用后,晋升等待首个 minimal-like reasoning 块或 `maxBootstrapSteps` 兜底,先到者生效;
|
|
73
|
+
- 工具执行即使失败,只要 `tool/call` 已持久化,仍计入晋升条件;
|
|
74
|
+
- phase 1 只保留 `persona` prompt section;晋升后恢复全部 assembled sections,因此 plan mode 的 `plan:policy` 在晋升后生效;
|
|
75
|
+
- workspace 指令、skill 目录与运行时快照在首轮不注入;快照随 PTC 目录出现,前两者再晚一步出现;
|
|
76
|
+
- `liangshen-exact` 的文件工具继承宿主文件沙箱(不挂载裸 `dsh-fs-local`);
|
|
77
|
+
- 工具目录只变化一次,因此第一、二次请求之间会发生一次前缀缓存变化;
|
|
78
|
+
- preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/`;
|
|
79
|
+
- 插件不发起网络请求,也不增加遥测;
|
|
80
|
+
- 不要在已经产生内容的会话中途切换 preset;
|
|
81
|
+
- 需要 DSH 0.1.0-rc.5+(preset 机制与 `system-prompt/assemble` 钩子)。
|
|
82
|
+
|
|
83
|
+
## 许可
|
|
84
|
+
|
|
85
|
+
插件本体 Apache-2.0(zhu1090093659)。`presets/liangshen/agent.cordis.yml` 基于 DeepSeek Harness Standard preset 修改,`presets/liangshen-exact/agent.cordis.yml` 基于内置 Minimal 与 Standard preset 修改,`tool-bootstrap.mjs` 来自 xiaobright/dsh-anchored-standard,均为 MIT,版权与许可声明见各 preset 的 `NOTICE`。`presets/liangshen-exact/tool-bootstrap.mjs` 是对 `presets/liangshen/tool-bootstrap.mjs` 的薄 re-export,两个 preset 共用同一份实现。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# dsh-liangshen bundle patch: inserts the host plugin row into the web
|
|
2
|
+
# profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
|
|
3
|
+
# manifest field) over dsh-base; activate with
|
|
4
|
+
# `dsh plugin --profile <name> add link:~/code/dsh-web-ui/packages/dsh-liangshen`.
|
|
5
|
+
#
|
|
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.
|
|
9
|
+
- insert:
|
|
10
|
+
- id: liangshen
|
|
11
|
+
name: '@linxin666/dsh-liangshen'
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import z from "schemastery";
|
|
6
|
+
//#region src/sync.ts
|
|
7
|
+
/**
|
|
8
|
+
* Sync every preset directory under `sourceRoot` into `targetRoot` — the
|
|
9
|
+
* dsh agent-presets discovery root (harness-home `.agent-presets`).
|
|
10
|
+
*
|
|
11
|
+
* A preset is a directory holding `agent.cordis.yml`; the directory name is
|
|
12
|
+
* the preset id. Copy is per-directory and idempotent: a preset whose target
|
|
13
|
+
* tree is byte-identical to the source tree is skipped, otherwise the source
|
|
14
|
+
* tree is copied and any target files the source does not contain are removed.
|
|
15
|
+
* Directories the plugin does not own (other presets the user authored) are
|
|
16
|
+
* never touched.
|
|
17
|
+
*/
|
|
18
|
+
function filesUnder(root) {
|
|
19
|
+
const out = [];
|
|
20
|
+
const walk = (dir) => {
|
|
21
|
+
for (const entry of readdirSync(dir)) {
|
|
22
|
+
const path = join(dir, entry);
|
|
23
|
+
if (statSync(path).isDirectory()) walk(path);
|
|
24
|
+
else out.push(path);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
walk(root);
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
/** Preset files are small; identity means identical bytes, not just size/mtime. */
|
|
31
|
+
function sameFile(a, b) {
|
|
32
|
+
return readFileSync(a).equals(readFileSync(b));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remove files not in `keep` (relative paths), then remove only the
|
|
36
|
+
* directories those removals left empty — still strictly inside `root`, so
|
|
37
|
+
* sibling presets are never touched.
|
|
38
|
+
*/
|
|
39
|
+
function pruneExtras(root, keep) {
|
|
40
|
+
const parents = /* @__PURE__ */ new Set();
|
|
41
|
+
for (const file of filesUnder(root)) if (!keep.has(relative(root, file))) {
|
|
42
|
+
parents.add(dirname(file));
|
|
43
|
+
rmSync(file, { force: true });
|
|
44
|
+
}
|
|
45
|
+
for (const start of parents) {
|
|
46
|
+
let dir = start;
|
|
47
|
+
while (dir !== void 0 && relative(root, dir) !== "") if (existsSync(dir) && readdirSync(dir).length === 0) {
|
|
48
|
+
rmSync(dir, {
|
|
49
|
+
recursive: true,
|
|
50
|
+
force: true
|
|
51
|
+
});
|
|
52
|
+
dir = dirname(dir);
|
|
53
|
+
} else dir = void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Copy `sourceRoot/<id>` into `targetRoot/<id>`, idempotently. */
|
|
57
|
+
function syncOnePreset(sourceDir, targetDir) {
|
|
58
|
+
const sourceFiles = filesUnder(sourceDir);
|
|
59
|
+
const sourceSet = new Set(sourceFiles.map((file) => relative(sourceDir, file)));
|
|
60
|
+
if (existsSync(targetDir) && !statSync(targetDir).isDirectory()) rmSync(targetDir, {
|
|
61
|
+
recursive: true,
|
|
62
|
+
force: true
|
|
63
|
+
});
|
|
64
|
+
if (!existsSync(targetDir)) {
|
|
65
|
+
cpSync(sourceDir, targetDir, {
|
|
66
|
+
recursive: true,
|
|
67
|
+
preserveTimestamps: true
|
|
68
|
+
});
|
|
69
|
+
pruneExtras(targetDir, sourceSet);
|
|
70
|
+
return "synced";
|
|
71
|
+
}
|
|
72
|
+
let dirty = false;
|
|
73
|
+
for (const file of sourceFiles) {
|
|
74
|
+
const dest = join(targetDir, relative(sourceDir, file));
|
|
75
|
+
if (!existsSync(dest) || !sameFile(file, dest)) {
|
|
76
|
+
dirty = true;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!dirty) {
|
|
81
|
+
for (const file of filesUnder(targetDir)) if (!sourceSet.has(relative(targetDir, file))) {
|
|
82
|
+
dirty = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!dirty) return "current";
|
|
87
|
+
pruneExtras(targetDir, sourceSet);
|
|
88
|
+
cpSync(sourceDir, targetDir, {
|
|
89
|
+
recursive: true,
|
|
90
|
+
preserveTimestamps: true
|
|
91
|
+
});
|
|
92
|
+
pruneExtras(targetDir, sourceSet);
|
|
93
|
+
return "synced";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sync every preset under `sourceRoot` into `targetRoot`.
|
|
97
|
+
* @param sourceRoot - plugin-owned preset tree (bundled in the package).
|
|
98
|
+
* @param targetRoot - dsh agent-presets discovery root (e.g. <home>/.dsh/.agent-presets).
|
|
99
|
+
*/
|
|
100
|
+
function syncPresetTrees(sourceRoot, targetRoot) {
|
|
101
|
+
const result = {
|
|
102
|
+
synced: [],
|
|
103
|
+
current: [],
|
|
104
|
+
failed: []
|
|
105
|
+
};
|
|
106
|
+
if (!existsSync(sourceRoot)) return result;
|
|
107
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
108
|
+
for (const entry of readdirSync(sourceRoot)) {
|
|
109
|
+
const source = join(sourceRoot, entry);
|
|
110
|
+
if (!statSync(source).isDirectory()) continue;
|
|
111
|
+
const id = basename(source);
|
|
112
|
+
try {
|
|
113
|
+
(syncOnePreset(source, join(targetRoot, id)) === "synced" ? result.synced : result.current).push(id);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
result.failed.push({
|
|
116
|
+
id,
|
|
117
|
+
error: error instanceof Error ? error.message : String(error)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/index.ts
|
|
125
|
+
/**
|
|
126
|
+
* dsh-liangshen — LiangShen (梁神) agent preset plugin.
|
|
127
|
+
*
|
|
128
|
+
* Host half only: on startup it syncs the bundled `presets/` tree into the
|
|
129
|
+
* harness-home agent-presets root (`~/.dsh/.agent-presets`), making the
|
|
130
|
+
* LiangShen preset selectable for new sessions without copying files by hand,
|
|
131
|
+
* and announces the capability through a system-prompt section. No browser
|
|
132
|
+
* half, no routes, no agent tools — the preset itself provides the tools.
|
|
133
|
+
*
|
|
134
|
+
* The preset is the "anchored-standard" idea shipped as a named mode: the
|
|
135
|
+
* first model request sees only the platform shell plus `read` (Minimal
|
|
136
|
+
* prompt condition), and the full Standard tool catalog opens after the
|
|
137
|
+
* session's first durable tool call. Derived from
|
|
138
|
+
* https://github.com/xiaobright/dsh-anchored-standard (MIT).
|
|
139
|
+
*/
|
|
140
|
+
/** Stable cordis plugin name. */
|
|
141
|
+
const name = "liangshen";
|
|
142
|
+
/** Prompt assembly must exist before the announcement section can register. */
|
|
143
|
+
const inject = ["systemPrompt"];
|
|
144
|
+
const Config = z.object({
|
|
145
|
+
enabled: z.boolean().default(true),
|
|
146
|
+
announceToAgent: z.boolean().default(true)
|
|
147
|
+
});
|
|
148
|
+
/** Schema default, re-read for hand-built test contexts. */
|
|
149
|
+
const DEFAULT_ANNOUNCE = true;
|
|
150
|
+
/** Order of the announcement section within the tool-guidance band. */
|
|
151
|
+
const SECTION_ORDER = 150;
|
|
152
|
+
/** Model-facing announcement: plugin presence, principle, and limits. */
|
|
153
|
+
const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」与「梁神模式-精确实验」。原理:两阶段锚定——首轮模型请求仅暴露平台 shell 与 read(精确实验版为持久 bash 与 str_replace_editor),只保留一行 persona,清空运行时上下文并只放行用户的直接消息,锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 Code Mode(PTC,单一 run_code),workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
|
|
154
|
+
/** Expand a leading `~`, `~/` or `~\` to the current user's home directory. */
|
|
155
|
+
function expandTilde(path) {
|
|
156
|
+
if (path === "~") return homedir();
|
|
157
|
+
if (path.startsWith("~/") || path.startsWith("~\\")) return join(homedir(), path.slice(2));
|
|
158
|
+
return path;
|
|
159
|
+
}
|
|
160
|
+
/** Resolve the harness home (DSH_HOME overrides the conventional ~/.dsh). */
|
|
161
|
+
function dshHome() {
|
|
162
|
+
const override = process.env.DSH_HOME;
|
|
163
|
+
if (override === void 0) return join(homedir(), ".dsh");
|
|
164
|
+
const trimmed = override.trim();
|
|
165
|
+
return trimmed === "" ? join(homedir(), ".dsh") : expandTilde(trimmed);
|
|
166
|
+
}
|
|
167
|
+
/** Absolute path of the bundled preset tree inside this package. */
|
|
168
|
+
function bundledPresetsRoot() {
|
|
169
|
+
return fileURLToPath(new URL("../presets/", import.meta.url));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Mount the plugin: sync bundled presets into the harness-home agent-presets
|
|
173
|
+
* root, then announce through a system-prompt section.
|
|
174
|
+
* @param ctx - host plugin context carrying systemPrompt.
|
|
175
|
+
* @param config - resolved plugin config (schema defaults applied by the loader).
|
|
176
|
+
*/
|
|
177
|
+
function apply(ctx, config) {
|
|
178
|
+
const resolve = () => ({
|
|
179
|
+
announceToAgent: config?.announceToAgent ?? DEFAULT_ANNOUNCE,
|
|
180
|
+
enabled: config?.enabled ?? true
|
|
181
|
+
});
|
|
182
|
+
const sync = () => {
|
|
183
|
+
const targetRoot = join(dshHome(), ".agent-presets");
|
|
184
|
+
try {
|
|
185
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
186
|
+
const result = syncPresetTrees(bundledPresetsRoot(), targetRoot);
|
|
187
|
+
for (const { id, error } of result.failed) ctx.logger?.warn?.(`dsh-liangshen: preset ${id} sync failed: ${error}`);
|
|
188
|
+
if (result.synced.length > 0) ctx.logger?.info?.(`dsh-liangshen: presets synced into ${targetRoot}: ${result.synced.join(", ")}`);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
ctx.logger?.warn?.(`dsh-liangshen: preset sync failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
let disposeSection;
|
|
194
|
+
const refresh = () => {
|
|
195
|
+
disposeSection?.();
|
|
196
|
+
disposeSection = void 0;
|
|
197
|
+
if (!resolve().enabled) return;
|
|
198
|
+
sync();
|
|
199
|
+
if (resolve().announceToAgent) disposeSection = ctx.systemPrompt.section({
|
|
200
|
+
name: "plugin:dsh-liangshen",
|
|
201
|
+
order: SECTION_ORDER,
|
|
202
|
+
text: LIANGSHEN_GUIDANCE
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
refresh();
|
|
206
|
+
ctx.effect(() => () => {
|
|
207
|
+
disposeSection?.();
|
|
208
|
+
disposeSection = void 0;
|
|
209
|
+
}, "dsh-liangshen: announcement");
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { Config, LIANGSHEN_GUIDANCE, apply, bundledPresetsRoot, dshHome, inject, name };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-liangshen — LiangShen (梁神) agent preset plugin.
|
|
3
|
+
*
|
|
4
|
+
* Host half only: on startup it syncs the bundled `presets/` tree into the
|
|
5
|
+
* harness-home agent-presets root (`~/.dsh/.agent-presets`), making the
|
|
6
|
+
* LiangShen preset selectable for new sessions without copying files by hand,
|
|
7
|
+
* and announces the capability through a system-prompt section. No browser
|
|
8
|
+
* half, no routes, no agent tools — the preset itself provides the tools.
|
|
9
|
+
*
|
|
10
|
+
* The preset is the "anchored-standard" idea shipped as a named mode: the
|
|
11
|
+
* first model request sees only the platform shell plus `read` (Minimal
|
|
12
|
+
* prompt condition), and the full Standard tool catalog opens after the
|
|
13
|
+
* session's first durable tool call. Derived from
|
|
14
|
+
* https://github.com/xiaobright/dsh-anchored-standard (MIT).
|
|
15
|
+
*/
|
|
16
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
17
|
+
import z from 'schemastery';
|
|
18
|
+
/** Stable cordis plugin name. */
|
|
19
|
+
export declare const name = "liangshen";
|
|
20
|
+
/** Prompt assembly must exist before the announcement section can register. */
|
|
21
|
+
export declare const inject: string[];
|
|
22
|
+
/** Plugin config, validated by the same-named schemastery schema. */
|
|
23
|
+
export interface Config {
|
|
24
|
+
/** Master switch: when false, neither sync nor announcement runs. */
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** When true (default), a system-prompt section announces the plugin. */
|
|
27
|
+
announceToAgent?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const Config: z<Config>;
|
|
30
|
+
/** Model-facing announcement: plugin presence, principle, and limits. */
|
|
31
|
+
export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u4E0E\u300C\u6881\u795E\u6A21\u5F0F-\u7CBE\u786E\u5B9E\u9A8C\u300D\u3002\u539F\u7406\uFF1A\u4E24\u9636\u6BB5\u951A\u5B9A\u2014\u2014\u9996\u8F6E\u6A21\u578B\u8BF7\u6C42\u4EC5\u66B4\u9732\u5E73\u53F0 shell \u4E0E read\uFF08\u7CBE\u786E\u5B9E\u9A8C\u7248\u4E3A\u6301\u4E45 bash \u4E0E str_replace_editor\uFF09\uFF0C\u53EA\u4FDD\u7559\u4E00\u884C persona\uFF0C\u6E05\u7A7A\u8FD0\u884C\u65F6\u4E0A\u4E0B\u6587\u5E76\u53EA\u653E\u884C\u7528\u6237\u7684\u76F4\u63A5\u6D88\u606F\uFF0C\u951A\u5B9A Minimal \u63A8\u7406\u8F68\u8FF9\uFF1B\u664B\u5347\u53D7\u9996\u5757\u951A\u5B9A\u95E8\u63A7\uFF08\u9996\u5757\u5305\u542B we \u4E14\u65E0 let me\uFF0C\u56DB\u6B65\u515C\u5E95\uFF09\uFF0C\u65E0\u5DE5\u5177\u9996\u8F6E\u4F1A\u5728\u54CD\u5E94\u540E\u81EA\u52A8\u664B\u5347\uFF0C\u664B\u5347\u540E wire \u5207\u6362\u4E3A Code Mode\uFF08PTC\uFF0C\u5355\u4E00 run_code\uFF09\uFF0Cworkspace \u6307\u4EE4\u4E0E skill \u76EE\u5F55\u5728\u664B\u5347\u540E\u518D\u5EF6\u8FDF\u4E00\u6B65\u6CE8\u5165\u3002preset \u6587\u4EF6\u7531\u63D2\u4EF6\u7EF4\u62A4\u4E8E ~/.dsh/.agent-presets\uFF0C\u5347\u7EA7\u63D2\u4EF6\u65F6\u81EA\u52A8\u66F4\u65B0\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
|
|
32
|
+
/** Resolve the harness home (DSH_HOME overrides the conventional ~/.dsh). */
|
|
33
|
+
export declare function dshHome(): string;
|
|
34
|
+
/** Absolute path of the bundled preset tree inside this package. */
|
|
35
|
+
export declare function bundledPresetsRoot(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Mount the plugin: sync bundled presets into the harness-home agent-presets
|
|
38
|
+
* root, then announce through a system-prompt section.
|
|
39
|
+
* @param ctx - host plugin context carrying systemPrompt.
|
|
40
|
+
* @param config - resolved plugin config (schema defaults applied by the loader).
|
|
41
|
+
*/
|
|
42
|
+
export declare function apply(ctx: Context, config?: Config): void;
|