@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
@@ -1,13 +1,29 @@
1
- # The `liangshen` (梁神模式) agent preset: phase 1 exposes the builtin Minimal
2
- # preset's exact two tools (persistent `bash` plus `str_replace_editor`) and
3
- # the same one-line persona, with no runtime contexts and no injected pre-step
4
- # messages, anchoring the Minimal trajectory; after a stabilized anchor the
5
- # wire switches to PTC Mode and the ordinary injections open. The
6
- # phase-1 surface matches the official "exact RL prompt and schemas" snapshot
7
- # byte-for-byte on the model-visible wire shape, at the cost of keeping the
8
- # persistent shell for the whole session. Unlike the builtin Minimal preset,
9
- # the phase-1 editor inherits the host file sandbox instead of mounting a bare
10
- # local filesystem (see the filesystem section below).
1
+ # The `liangshen` (梁神模式) agent preset: the builtin Minimal preset's
2
+ # one-line persona — extended with the mode's standing working discipline and
3
+ # the session's workspace directory — as the WHOLE system prompt, with the
4
+ # session's tool surface staged behind the anchor turn and PTC presentation
5
+ # taking over after it. The session's entire first user turn runs the anchored native
6
+ # surface — the short persona block plus the default `anchorTools`
7
+ # schemas (`[bash, str_replace_editor, exit_plan_mode, skill]`), natively presented —
8
+ # and from the second turn this session presents its tools in PTC mode (when
9
+ # successfully activated): the wire carries the single `run_code`
10
+ # transport, and every other tool is reached from inside the program through
11
+ # the generated SDK. The capability facts the Standard system prompt would
12
+ # carry as tool-guidance prose — and, under PTC, the SDK bindings and the
13
+ # collapse rule that `minimal-prompt` filters out of the prompt along with
14
+ # every other section — arrive instead as a durable `tool-catalog` message
15
+ # appended after the user's own message from the FIRST turn on, the way the
16
+ # skill catalog is injected; it names exactly the tools the current request
17
+ # opens (each tool's argument signature plus a one-line summary) — the anchor
18
+ # set natively during the anchor turn, the SDK-reachable roster under PTC —
19
+ # so the declared surface and the request's own wire never disagree. The one
20
+ # wire transition is the deterministic turn boundary: no reasoning-block
21
+ # gating, no output budget cap.
22
+ #
23
+ # The persistent shell replaces the Standard ephemeral shell for the whole
24
+ # session (both register the name `bash`), and the editor inherits the host
25
+ # file sandbox instead of mounting a bare local filesystem — see the shell and
26
+ # filesystem sections below.
11
27
  #
12
28
  # Adapted from the builtin `minimal` and `standard` presets.
13
29
  #
@@ -30,82 +46,105 @@
30
46
 
31
47
  # ── identity ────────────────────────────────────────────────────────────────
32
48
 
33
- # Phase 1 shows only this one-line persona: `tool-bootstrap` filters the
34
- # assembled sections down to the persona section (`deployment:persona`, the
35
- # name `dsh-persona` registers under, plus the legacy `persona` name) during
36
- # phase 1 and restores every section after promotion, appending the session's
37
- # working directory to the persona — so the agent knows its workspace and
38
- # plan-mode's `plan:policy` takes effect instead of being permanently
39
- # shadowed by a `complete` persona.
49
+ # The persona prefix below is the preset's entire system prompt base:
50
+ # `minimal-prompt` narrows the assembled sections down to it (plus plan mode's
51
+ # `plan:policy`, which no tool restriction backs — see that plugin) and
52
+ # appends the session's workspace directory at assembly time, so identity,
53
+ # harness, web-surface, and tool-guidance sections never reach the model.
54
+ # Besides the one-line persona it carries the standing working discipline the
55
+ # mode ships with (thinking loops, design-first reasoning, YAGNI/PDCA, no
56
+ # code comments). Runtime context snapshots stay enabled: they are durable
57
+ # user-role messages, not system-prompt text.
40
58
  - id: persona
41
59
  name: '@deepseek-ai/dsh-persona'
42
60
  config:
43
- text: You are a helpful software engineer assistant.
44
-
45
- # Two-phase input bootstrap with the exact Minimal phase-1 tools. Before the
46
- # first durable tool/call event the model sees only persistent `bash` plus
47
- # `str_replace_editor`, only the `persona` prompt section, no runtime
48
- # contexts, and only whitelisted source kinds (direct user messages plus
49
- # goal auto-rounds — a filtered-out `/goal` round never reaches the model, so
50
- # no promotion branch fires and the resume/pause loop deadlocks, issue #578).
51
- # `anchorGate` holds the promotion
52
- # open until the first reasoning block is minimal-like (four-step fallback);
53
- # `promoteAfterFirstResponse` avoids a permanent two-tool session after a
54
- # tool-less first response, and releases an anchor-gated session once its
55
- # first turn ends (`turn/end`). After promotion the catalog is presented as
56
- # PTC Mode: a single `run_code` tool on the wire, switched at the step
57
- # boundary; workspace instructions and the skill catalog are deferred one
58
- # step after promotion. `bootstrapMaxTokens` caps the phase-1 request output
59
- # budget (community-observed "We need" trigger window, 1024) and is stripped
60
- # again after promotion so the cap never solders into later requests.
61
- # After a compaction the session falls back to the controlled phase — the
62
- # bootstrap pair plus `compactionTools` (a core work set) — until a NEW
63
- # promotion signal exists past the boundary, and PTC Mode is released until
64
- # the session re-promotes.
65
- # `phase1FirstCallInstruction` is an opt-in extra line appended to the
66
- # phase-1 persona for test builds (issue #274): the model is asked to ground
67
- # its first answer with one Minimal-native tool call before responding, so
68
- # first-turn capability questions are answered from the promoted registry
69
- # instead of the cropped two-tool view. It deviates from the byte-exact
70
- # Minimal surface and is therefore left unset (off) by default.
71
- - id: tool-bootstrap
72
- name: ./tool-bootstrap.mjs
61
+ prefix: |-
62
+ You are a helpful software engineer assistant.
63
+
64
+ - Avoid falling into repetitive loops during thinking; exit immediately once a loop is detected.
65
+ - Focus thinking on requirement understanding and solution design (key points, workflow, verification strategy), without pre-rehearsing specific code implementation. Code should be output during the "Do" phase based on the actual state of files, with correctness verified by the "Check" phase.
66
+ - When writing code, follow the YAGNI programming philosophy and the PDCA behavioral standard.
67
+ - No need to write comments for the code.
68
+
69
+ # The two halves of the mode, both preset-local plugins:
70
+ #
71
+ # `minimal-prompt` keeps the system prompt on the persona above, plus the
72
+ # session's workspace directory appended at assembly time (`Your working
73
+ # directory is <cwd>.` — the one orientation fact the persona block carries).
74
+ # It also lifts the AGENTS.md-style instruction files into the system prompt
75
+ # itself: at assembly time it reads the harness's baseline chain
76
+ # ($DSH_HOME/AGENTS.md, then the project root's ancestors down to the cwd) and
77
+ # appends the content as one `workspace-instructions` section after the stable
78
+ # prefix, re-read on every request so file edits propagate, and drops the
79
+ # harness's own agent-instructions injections (they would duplicate the
80
+ # prompt). Set `instructionSource: hint` to restore the one-time non-imperative
81
+ # pointer to the reference files instead (issue #388, upstream
82
+ # dsh-anchored-standard #49: a full-text dump as context measurably flips the
83
+ # anchored trajectory), or `keepPlanPolicy: false` to drop plan mode's policy
84
+ # section as well.
85
+ #
86
+ # `tool-catalog` appends the model-visible tool catalog — each tool's argument
87
+ # signature plus a one-line summary — as a durable user message after the
88
+ # user's own message from the first turn on, the way `dsh-tool-skill` injects
89
+ # the skill catalog. It republishes only when that catalog's content changes or
90
+ # the published copy left the visible surface (compaction, resume), so the
91
+ # catalog is not appended once per step. The content follows the presentation
92
+ # the next request will carry: the anchor wire before the boundary, the SDK
93
+ # roster after it. `descriptionMaxLength` caps each one-line summary; the full
94
+ # description stays in the tool schema.
95
+ #
96
+ # `anchorTools` stages the tool SCHEMAS behind the anchor turn: during the
97
+ # session's entire first user turn the assembled wire narrows to these schemas
98
+ # and the session keeps native presentation, and the catalog narrows with the
99
+ # wire, so the model is never told about a tool this request does not expose.
100
+ # The shipped default anchor tools are `[bash, str_replace_editor, exit_plan_mode, skill]`.
101
+ # The bash-only configuration experiment (`anchorTools: [bash]`) is preserved
102
+ # and supported via config without requiring extra preset registration or
103
+ # registry changes. Set it to an empty list to disable the narrowing entirely.
104
+ #
105
+ # `ptcPresentation` declares this session's tools in PTC mode from the second
106
+ # turn on (when successfully activated): the wire collapses to the reserved
107
+ # `run_code` transport and every other tool is reached inside the program through
108
+ # the generated SDK, which the injected catalog names because `minimal-prompt`
109
+ # filters the harness's own `tools:sdk` and `tools:ptc-only` sections out of the
110
+ # prompt. The SDK preserves full input and output key parameter semantics rather
111
+ # than a rigid short-summary contract. The declaration is per session
112
+ # (`agent.ctx.tools.presentAs`), needs a mounted code runtime, and degrades to
113
+ # the native surface with a one-time warning when either is missing or fails.
114
+ # Set `false` to restore the pre-PTC behavior: the full native roster on the
115
+ # wire from the second turn.
116
+ - id: minimal-prompt
117
+ name: ./minimal-prompt.mjs
118
+ config:
119
+ keepPlanPolicy: true
120
+ instructionSource: system-prompt
121
+ instructionMaxBytes: 65536
122
+
123
+ - id: tool-catalog
124
+ name: ./tool-catalog.mjs
73
125
  config:
74
- shellTools: [bash]
75
- commonTools: [str_replace_editor]
76
- messageSources: [user, goal]
77
- anchorGate: true
78
- maxBootstrapSteps: 4
79
- promoteAfterFirstResponse: true
80
- bootstrapMaxTokens: 1024
81
- compactionTools: [read, write, edit, glob, grep, todo_write, ask_user_question]
82
- deferredSources: [agent-instructions, skill-catalog]
83
- deferredGraceSteps: 1
84
- promotedPresentation: code
85
- # Issue #388: after promotion, inject one non-imperative hint (reference
86
- # files exist at these paths; read them on demand) instead of the full
87
- # AGENTS.md dump — the full-text injection measurably flips the anchored
88
- # trajectory (upstream dsh-anchored-standard #49, E1/E1.5/E2). Knowledge
89
- # stays reachable through read / skill_load. Set false to restore the
90
- # legacy full-text injection.
91
- instructionHint: true
92
- # phase1FirstCallInstruction: After your first reasoning block, before answering, make one tool call (for example run `pwd` through the shell or view a workspace file) and base your answer on its result.
93
-
94
- # Workspace instructions are quarantined by `tool-bootstrap` during phase 1
95
- # and deferred one step after promotion, then stay current.
126
+ descriptionMaxLength: 200
127
+ anchorTools: [bash, str_replace_editor, exit_plan_mode, skill]
128
+ ptcPresentation: true
129
+
130
+ # The harness's workspace-instruction loader. Under the default
131
+ # `instructionSource: system-prompt` the content reaches the model through the
132
+ # system prompt instead, and this row's injections are dropped by
133
+ # `minimal-prompt`; the row stays mounted so `instructionSource: hint` keeps
134
+ # its pointer behavior working, and its `maxBytes` remains that mode's budget.
96
135
  - id: agent-instructions
97
136
  name: '@deepseek-ai/dsh-agent-instructions'
98
137
  config:
99
138
  maxBytes: 65536
100
139
 
101
- # ── minimal phase-1 shell ───────────────────────────────────────────────────
140
+ # ── shell ───────────────────────────────────────────────────────────────────
102
141
 
103
142
  # The PTY registry is an agent-owned service, so it lives in an entry-local
104
143
  # realm. The backend still consumes the host sandbox policy and subprocess
105
144
  # implementation, while the tool registers into this agent's scoped catalog.
106
145
  # This persistent `bash` replaces the Standard ephemeral shell for the WHOLE
107
- # session (both tools register the name `bash`), which is the exact-Minimal
108
- # tradeoff this experimental preset evaluates.
146
+ # session (both tools register the name `bash`), so shell state survives across
147
+ # calls.
109
148
  - id: persistent-shell
110
149
  name: cordis:group
111
150
  group: true
@@ -138,23 +177,20 @@
138
177
  # Windows-only `bash` tool (custom-bash.mjs): the PTY backend above is
139
178
  # linux/darwin-only, so win32 disables the persistent-shell group and
140
179
  # registers this `bash` through the ordinary cross-platform subprocess seam
141
- # (Git Bash). Both platforms end up with exactly one tool named `bash`, so the
142
- # phase-1 Minimal anchor (shellTools: [bash] + str_replace_editor) is
143
- # unchanged. Non-zero exit is reported not thrown; state does NOT persist
144
- # across calls on this path; no OS sandbox confinement on Windows. `bashPath`
145
- # is optional (defaults to Git Bash inference); set it explicitly when git is
146
- # not on PATH.
180
+ # (Git Bash). Both platforms end up with exactly one tool named `bash`.
181
+ # Non-zero exit is reported not thrown; state does NOT persist across calls on
182
+ # this path; no OS sandbox confinement on Windows. `bashPath` is optional
183
+ # (defaults to Git Bash inference); set it explicitly when git is not on PATH.
147
184
  - id: custom-bash
148
185
  name: ./custom-bash.mjs
149
186
  disabled: !!js process.platform !== 'win32'
150
187
 
151
- # ── minimal phase-1 filesystem ──────────────────────────────────────────────
188
+ # ── filesystem ──────────────────────────────────────────────────────────────
152
189
 
153
- # Phase-1 editor as a direct top-level row: it reuses the host's sandboxed
190
+ # The editor is a direct top-level row: it reuses the host's sandboxed
154
191
  # `ctx.fs`, not a bare local filesystem. No `dsh-fs-local` realm is mounted, so
155
- # the phase-1 editor inherits the host file sandbox exactly like every
156
- # Standard file tool, and the model-facing schema stays the builtin Minimal
157
- # `str_replace_editor`.
192
+ # it inherits the host file sandbox exactly like every Standard file tool, and
193
+ # the model-facing schema stays the builtin Minimal `str_replace_editor`.
158
194
  - id: str-replace-editor
159
195
  name: '@deepseek-ai/dsh-tool-str-replace-editor'
160
196
  config:
@@ -189,8 +225,7 @@
189
225
  # `skill-filesystem` contributes local-root discovery for agents on this preset, and
190
226
  # `tool-skill` gives them the catalog and loader; the merged catalog also
191
227
  # carries whatever the deployment registered globally (repository plugins).
192
- # The `skill-catalog` pre-step message is quarantined by `tool-bootstrap`
193
- # during phase 1 and deferred one step after promotion, then stays current.
228
+ # The `skill-catalog` pre-step message stays current like any other injection.
194
229
  - id: skill-filesystem
195
230
  name: '@deepseek-ai/dsh-skill-filesystem'
196
231
 
@@ -211,7 +246,10 @@
211
246
  # ── plan mode ───────────────────────────────────────────────────────────────
212
247
 
213
248
  # Plan state is per-agent by nature, so an entry-local realm is not a
214
- # workaround here — it is the correct lifetime.
249
+ # workaround here — it is the correct lifetime. `minimal-prompt` keeps this
250
+ # row's `plan:policy` section in the otherwise one-line system prompt, because
251
+ # the section is the only thing that enforces plan mode: the exit tool stays
252
+ # registered in every mode and no tool restriction backs the policy.
215
253
  - id: planning
216
254
  name: cordis:group
217
255
  group: true
@@ -334,8 +372,13 @@
334
372
  config:
335
373
  provider: spawn
336
374
 
375
+ # Keep the engine above for `ralph`, but do not publish a second
376
+ # model-authored orchestration surface beside `run_code`: this is the one
377
+ # roster difference the builtin `ptc` preset ships with, and the mode's
378
+ # whole promoted surface is run_code.
337
379
  - id: tool-workflow
338
380
  name: '@deepseek-ai/dsh-tool-workflow'
381
+ disabled: true
339
382
 
340
383
  - id: tool-ralph
341
384
  name: '@deepseek-ai/dsh-tool-ralph'
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * custom-bash — a Windows-capable `bash` tool for the liangshen preset. It
3
- * registers under the SAME name (`bash`) as the persistent shell so the
4
- * phase-1 Minimal anchor (bash + str_replace_editor) holds on every platform,
5
- * but executes through `ctx.subprocess.spawn` instead of a PTY.
3
+ * registers under the SAME name (`bash`) as the persistent shell so every
4
+ * platform exposes one shell tool of that name, but executes through
5
+ * `ctx.subprocess.spawn` instead of a PTY.
6
6
  *
7
7
  * WHY: DSH's PTY backend is linux/darwin-only — subprocess-local throws
8
8
  * "terminal inspection is unsupported on platform win32", so the
9
9
  * persistent-shell group (dsh-terminal + dsh-terminal-bash +
10
10
  * dsh-tool-bash-persistent) cannot spawn on Windows. agent.cordis.yml disables
11
11
  * that group on win32 and enables this tool instead; both platforms end up
12
- * with exactly one `bash` tool and the byte-exact schema anchor is kept.
12
+ * with exactly one `bash` tool.
13
13
  *
14
14
  * Executable resolution (config `bashPath`, no hardcoded install path):
15
15
  * an explicit non-empty `bashPath` wins unconditionally. Unset, the Git Bash