@linxin666/dsh-liangshen 0.2.1 → 0.2.2

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 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: 5699b2aee7b9cfdec6184e042a48ab359a76b5d7
6
- README.zh.md: 44295097d6561d0d5db7388b438f4bef8509ff4e
5
+ README.md: 369bb8384a73650063d3d040f1aecc4d7f11f842
6
+ README.zh.md: 96ce3a7db25f7696368b7e0d8440c42df457e571
package/README.md CHANGED
@@ -52,7 +52,7 @@ Fully restart `dsh web`, open a NEW empty session, and pick "梁神模式" as th
52
52
  Export the session JSONL and inspect `request/header`:
53
53
 
54
54
  - The first header should carry only `bash/str_replace_editor` (the persistent shell plus the sandboxed editor);
55
- - The first turn should contain only the user's own messages — no workspace-instruction baseline, no runtime snapshot, no skill-catalog message — and only the `deployment:persona` prompt section;
55
+ - The first turn should contain only whitelisted source kinds (the user's own messages and `/goal` auto-round messages) — no workspace-instruction baseline, no runtime snapshot, no skill-catalog message — and only the `deployment:persona` prompt section;
56
56
  - After the first tool call, the next changed header should carry exactly `run_code` (PTC); the runtime snapshot and all prompt sections arrive with that step (including plan mode's `plan:policy`, and the persona now ends with the selected workspace path), and the workspace instructions and skill catalog arrive one step later;
57
57
  - Phase-1 editor writes obey the host file sandbox policy — there is no bare local-filesystem bypass;
58
58
  - Later requests keep `run_code`.
package/README.zh.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  DeepSeek V4 Pro 会强烈依赖 API 中可见的**首轮工具目录**选择执行轨迹。社区评测([xiaobright/modeltest](https://github.com/xiaobright/modeltest))中,Standard / PTC 只有 91/92 分,Minimal 达到 99/96,但 Minimal 只有两个工具。两阶段方案把「首次轨迹选择」与「后续完整工具能力」拆开:
10
10
 
11
- 1. 首轮模型请求只暴露官方 Minimal 精确双工具(持久 `bash` 与 `str_replace_editor`),只保留 `deployment:persona` 一个 prompt section,清空运行时上下文,并且只放行用户自己的消息;
11
+ 1. 首轮模型请求只暴露官方 Minimal 精确双工具(持久 `bash` 与 `str_replace_editor`),只保留 `deployment:persona` 一个 prompt section,清空运行时上下文,并且只放行白名单内的消息(用户自己的消息与 `/goal` 自动轮次消息);
12
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
13
  3. 阶段从持久化 session events 推导,resume / reload 不丢失状态。
14
14
 
package/lib/index.js CHANGED
@@ -399,7 +399,7 @@ const DEFAULT_ANNOUNCE = true;
399
399
  /** Order of the announcement section within the tool-guidance band. */
400
400
  const SECTION_ORDER = 150;
401
401
  /** Model-facing announcement: plugin presence, principle, and limits. */
402
- const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:两阶段锚定——首轮模型请求仅暴露官方 Minimal 精确双工具(持久 bash 与 str_replace_editor,文件工具继承宿主沙箱),只保留一行 persona,清空运行时上下文并只放行用户的直接消息,锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 PTC Mode(单一 run_code)并在 persona 追加所选工作区路径,workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
402
+ const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:两阶段锚定——首轮模型请求仅暴露官方 Minimal 精确双工具(持久 bash 与 str_replace_editor,文件工具继承宿主沙箱),只保留一行 persona,清空运行时上下文并只放行白名单消息(用户直接消息与 /goal 自动轮次),锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 PTC Mode(单一 run_code)并在 persona 追加所选工作区路径,workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
403
403
  /** Absolute path of the bundled preset tree inside this package. */
404
404
  function bundledPresetsRoot() {
405
405
  return fileURLToPath(new URL("../presets/", import.meta.url));
@@ -28,7 +28,7 @@ export interface Config {
28
28
  }
29
29
  export declare const Config: z<Config>;
30
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\u3002\u539F\u7406\uFF1A\u4E24\u9636\u6BB5\u951A\u5B9A\u2014\u2014\u9996\u8F6E\u6A21\u578B\u8BF7\u6C42\u4EC5\u66B4\u9732\u5B98\u65B9 Minimal \u7CBE\u786E\u53CC\u5DE5\u5177\uFF08\u6301\u4E45 bash \u4E0E str_replace_editor\uFF0C\u6587\u4EF6\u5DE5\u5177\u7EE7\u627F\u5BBF\u4E3B\u6C99\u7BB1\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 PTC Mode\uFF08\u5355\u4E00 run_code\uFF09\u5E76\u5728 persona \u8FFD\u52A0\u6240\u9009\u5DE5\u4F5C\u533A\u8DEF\u5F84\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";
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\u3002\u539F\u7406\uFF1A\u4E24\u9636\u6BB5\u951A\u5B9A\u2014\u2014\u9996\u8F6E\u6A21\u578B\u8BF7\u6C42\u4EC5\u66B4\u9732\u5B98\u65B9 Minimal \u7CBE\u786E\u53CC\u5DE5\u5177\uFF08\u6301\u4E45 bash \u4E0E str_replace_editor\uFF0C\u6587\u4EF6\u5DE5\u5177\u7EE7\u627F\u5BBF\u4E3B\u6C99\u7BB1\uFF09\uFF0C\u53EA\u4FDD\u7559\u4E00\u884C persona\uFF0C\u6E05\u7A7A\u8FD0\u884C\u65F6\u4E0A\u4E0B\u6587\u5E76\u53EA\u653E\u884C\u767D\u540D\u5355\u6D88\u606F\uFF08\u7528\u6237\u76F4\u63A5\u6D88\u606F\u4E0E /goal \u81EA\u52A8\u8F6E\u6B21\uFF09\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 PTC Mode\uFF08\u5355\u4E00 run_code\uFF09\u5E76\u5728 persona \u8FFD\u52A0\u6240\u9009\u5DE5\u4F5C\u533A\u8DEF\u5F84\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
32
  export { dshHome } from './dsh-home.ts';
33
33
  /** Absolute path of the bundled preset tree inside this package. */
34
34
  export declare function bundledPresetsRoot(): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
3
  "description": "LiangShen (梁神) agent preset for the dsh web GUI: a two-phase anchored-standard preset — the first model request exposes only the builtin Minimal exact two-tool surface (persistent bash plus str_replace_editor) with no runtime contexts or injected instructions (Minimal-aligned trajectory anchor), promotion is gated on the first minimal-like reasoning block with a fallback, and the wire then switches to PTC Mode (a single run_code tool over the full registry) with the ordinary injections returning afterwards. The preset files are synced into ~/.dsh/.agent-presets on host startup. Hot-pluggable — mounted via cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
@@ -45,7 +45,10 @@
45
45
  # Two-phase input bootstrap with the exact Minimal phase-1 tools. Before the
46
46
  # first durable tool/call event the model sees only persistent `bash` plus
47
47
  # `str_replace_editor`, only the `persona` prompt section, no runtime
48
- # contexts, and only direct user messages. `anchorGate` holds the promotion
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
49
52
  # open until the first reasoning block is minimal-like (four-step fallback);
50
53
  # `promoteAfterFirstResponse` avoids a permanent two-tool session after a
51
54
  # tool-less first response, and releases an anchor-gated session once its
@@ -70,7 +73,7 @@
70
73
  config:
71
74
  shellTools: [bash]
72
75
  commonTools: [str_replace_editor]
73
- messageSources: [user]
76
+ messageSources: [user, goal]
74
77
  anchorGate: true
75
78
  maxBootstrapSteps: 4
76
79
  promoteAfterFirstResponse: true
@@ -7,7 +7,8 @@
7
7
  * - prompt sections: only the persona section (all other sections,
8
8
  * including plan-mode's `plan:policy`, return after promotion)
9
9
  * - runtime contexts: emptied (no sandbox/approval snapshot)
10
- * - pre-step messages: only explicit user messages pass
10
+ * - pre-step messages: only whitelisted source kinds pass (direct user
11
+ * messages and goal auto-rounds by default)
11
12
  *
12
13
  * Promotion opens the full tool catalog and restores runtime contexts and all
13
14
  * prompt sections. With `anchorGate` the promotion after the first tool call
@@ -73,8 +74,13 @@ const PERSONA_SECTION_NAMES = new Set(['deployment:persona', 'persona'])
73
74
  */
74
75
  const WORKSPACE_LINE_PREFIX = '\n\nYour working directory is '
75
76
 
76
- /** Message-source kinds the model may see during phase 1. */
77
- const DEFAULT_MESSAGE_SOURCES = ['user']
77
+ /**
78
+ * Message-source kinds the model may see during phase 1. Goal auto-rounds
79
+ * (source kind `goal`, issue #578) must be here: a filtered-out goal round
80
+ * never produces a response or tool call, so no promotion branch ever fires
81
+ * and the goal resume/pause loop deadlocks.
82
+ */
83
+ const DEFAULT_MESSAGE_SOURCES = ['user', 'goal']
78
84
 
79
85
  /** Message-source kinds delayed after promotion. */
80
86
  const DEFAULT_DEFERRED_SOURCES = []
@@ -144,12 +150,15 @@ export function hasAnchoredReasoning(content) {
144
150
  }
145
151
 
146
152
  /**
147
- * Whether one pre-step message is an explicit user message. Only `kind:
148
- * 'user'` passes; injected kinds and source-less seed messages never pass.
153
+ * Whether one pre-step message belongs to a whitelisted source kind. The
154
+ * configured whitelist alone decides; injected kinds and source-less seed
155
+ * messages never pass unless explicitly named. (Before issue #578 this also
156
+ * hardcoded `kind === 'user'`, so no whitelist entry could ever admit a
157
+ * goal auto-round and `/goal` sessions deadlocked in phase 1.)
149
158
  */
150
159
  function isAllowedMessage(message, allowedSources) {
151
160
  const kind = message.source?.kind
152
- return kind === 'user' && allowedSources.has(kind)
161
+ return kind !== undefined && allowedSources.has(kind)
153
162
  }
154
163
 
155
164
  /** Whether one pre-step message belongs to a deferred injection kind. */
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * https://github.com/xiaobright/dsh-anchored-standard (MIT).
15
15
  */
16
16
 
17
- import { existsSync, mkdirSync } from 'node:fs'
17
+ import { mkdirSync } from 'node:fs'
18
18
  import { join } from 'node:path'
19
19
  import { fileURLToPath } from 'node:url'
20
20
  import type { Context } from '@deepseek-ai/cordis'
@@ -50,7 +50,7 @@ const DEFAULT_ANNOUNCE = true
50
50
  const SECTION_ORDER = 150
51
51
 
52
52
  /** Model-facing announcement: plugin presence, principle, and limits. */
53
- export const LIANGSHEN_GUIDANCE = '本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:两阶段锚定——首轮模型请求仅暴露官方 Minimal 精确双工具(持久 bash 与 str_replace_editor,文件工具继承宿主沙箱),只保留一行 persona,清空运行时上下文并只放行用户的直接消息,锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 PTC Mode(单一 run_code)并在 persona 追加所选工作区路径,workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。'
53
+ export const LIANGSHEN_GUIDANCE = '本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:两阶段锚定——首轮模型请求仅暴露官方 Minimal 精确双工具(持久 bash 与 str_replace_editor,文件工具继承宿主沙箱),只保留一行 persona,清空运行时上下文并只放行白名单消息(用户直接消息与 /goal 自动轮次),锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 PTC Mode(单一 run_code)并在 persona 追加所选工作区路径,workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。'
54
54
  // The harness-home resolution (DSH_HOME override with the platform-home
55
55
  // fallback and ~ expansion) lives in the family-shared copy ./dsh-home.ts.
56
56
  // Re-export it so the plugin surface stays stable while the implementation is
@@ -181,7 +181,7 @@ export function analyzeSession(events) {
181
181
  * Returns null when no line yielded a processable event, preserving the
182
182
  * historical empty/all-bad file behavior of the CLI.
183
183
  */
184
- export async function analyzeSessionStream(lines) {
184
+ async function analyzeSessionStream(lines) {
185
185
  const acc = createSessionAccumulator()
186
186
  let droppedLines = 0
187
187
  for await (const line of lines) {