@linxin666/dsh-liangshen 0.4.6 → 0.4.7

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.
@@ -28,7 +28,7 @@ export const zh = {
28
28
  'settings.announceToAgent': '向 agent 公告本插件',
29
29
  'settings.announceToAgentHint': '开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。',
30
30
  'settings.presentation': '工具面呈现方式',
31
- 'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:both(出厂默认)让原生清单与 run_code 同驻(原生直调优先);native 保持原生工具清单;ptc 把 wire 收拢为 run_code。改动立即生效,但已开始的会话保持其已声明的组合。',
31
+ 'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:ptc(出厂默认)把 wire 收拢为 run_code,其余工具经生成的 SDK 调用;native 保持原生工具清单。改动立即生效,但已开始的会话保持其已声明的组合。',
32
32
  'settings.dispatcher': '调度者身份',
33
33
  'settings.dispatcherHint': '开启后本模式按调度 Agent 工作:先分诊复杂度(L0/L1 直接执行,L2 走完整流程),L2 任务先澄清访谈再规划,由主代理派发子代理并逐层审查与验收。与工具面呈现方式无关,只决定身份与流程纪律。出厂默认开启;关闭后回到仅含工作纪律的极简 persona。',
34
34
  'settings.on': '开',
@@ -48,21 +48,6 @@ export const zh = {
48
48
  'settings.invalidValue': '该取值不被接受',
49
49
  'presentation.ptc': 'ptc(仅 run_code)',
50
50
  'presentation.native': 'native(原生工具清单)',
51
- 'presentation.both': 'both(两者同驻)',
52
- 'settings.guardEnabled': '启用退化熔断器',
53
- 'settings.guardEnabledHint': '运行时检测思考退化(连续零产出长思考 / 同参重复失败),触发时注入熔断提示;仅停摆信号额外临时下调推理档位(max→high,不下探到甜区以下)。关闭后不干预任何请求。',
54
- 'settings.guardStallChars': '单步暴走字符阈值',
55
- 'settings.guardStallCharsHint': '留空即按推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符(按 V4.1 官方 384K 最大输出校准,约 2-4K 思考 token),再按灵敏度预设缩放。填写本字段则以该固定值覆盖所有档位。',
56
- 'settings.guardGlobalCap': '慢烧连续步数',
57
- 'settings.guardGlobalCapHint': '留空即按灵敏度预设缩放(均衡档为 4);provider 不持久化推理文本的会话也以此为兜底步骤计数。填写本字段则以该固定值覆盖。步数越小越敏感,真实长调查建议调大。',
58
- 'settings.guardSensitivity': '熔断灵敏度',
59
- 'settings.guardSensitivityHint': '整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5)。仅在对应细调字段留空时生效——阈值随推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符。',
60
- 'sensitivity.conservative': '保守(少打断)',
61
- 'sensitivity.balanced': '均衡(默认)',
62
- 'sensitivity.aggressive': '激进(早触发)',
63
- 'settings.guardEchoFailures': '同参连续失败次数',
64
- 'settings.guardEchoFailuresHint': '留空即按灵敏度预设缩放(均衡档为 3);填写本字段则以该固定值覆盖。空转信号只注入熔断消息,不下调推理档位。',
65
- 'settings.guardAdaptive': '自适应',
66
51
  }
67
52
 
68
53
  /** English counterpart; the key set mirrors {@link zh} exactly. */
@@ -89,7 +74,7 @@ export const en: Record<keyof typeof zh, string> = {
89
74
  'settings.announceToAgent': 'Announce this plugin to agents',
90
75
  'settings.announceToAgentHint': 'Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.',
91
76
  'settings.presentation': 'Wire presentation',
92
- 'settings.presentationHint': 'Written into the tool-catalog row of the preset this plugin declares: both (the shipped default) keeps the roster and run_code co-resident (direct native calls first); native keeps the native roster; ptc collapses the wire to run_code. A change re-declares the preset immediately; sessions that already started keep the composition they declared.',
77
+ 'settings.presentationHint': 'Written into the tool-catalog row of the preset this plugin declares: ptc (the shipped default) collapses the wire to run_code with every other tool reached through the generated SDK; native keeps the native roster. A change re-declares the preset immediately; sessions that already started keep the composition they declared.',
93
78
  'settings.dispatcher': 'Dispatcher identity',
94
79
  'settings.dispatcherHint': 'When on, the mode works as a dispatcher agent: it triages complexity first (L0/L1 work is done directly, an L2 task runs the full flow), clarifies an L2 task through an interview before planning, and the lead agent dispatches subagents and reviews and accepts them layer by layer. It is unrelated to the wire presentation and decides identity and process discipline only. On by default; switching it off returns the prompt to the bare persona with its working discipline.',
95
80
  'settings.on': 'On',
@@ -109,21 +94,6 @@ export const en: Record<keyof typeof zh, string> = {
109
94
  'settings.invalidValue': 'The value is not accepted',
110
95
  'presentation.ptc': 'ptc (run_code only)',
111
96
  'presentation.native': 'native (native tool roster)',
112
- 'presentation.both': 'both (both co-resident)',
113
- 'settings.guardEnabled': 'Degeneration circuit breaker',
114
- 'settings.guardEnabledHint': 'Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures) and injects a breaker message; only a stall also steps the reasoning effort down (max to high, never below the sweet spot). Disabled means requests are never touched.',
115
- 'settings.guardStallChars': 'Runaway reasoning character floor',
116
- 'settings.guardStallCharsHint': 'Leave empty to adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low characters (calibrated against V4.1\'s official 384K max output, roughly 2-4K thinking tokens), then scaled by the sensitivity preset. Setting a value pins it for every effort level.',
117
- 'settings.guardGlobalCap': 'Slow-burn step count',
118
- 'settings.guardGlobalCapHint': 'Leave empty to scale with the sensitivity preset (4 at balanced); it is also the fallback step count for a session whose provider persists no reasoning text. Setting a value pins it. Lower is more sensitive — raise it for genuinely long investigations.',
119
- 'settings.guardSensitivity': 'Breaker sensitivity',
120
- 'settings.guardSensitivityHint': 'Scales every breaker threshold: conservative (fewer interruptions, x1.5), balanced (the calibrated defaults), aggressive (fires earlier, x0.5). It applies only where the matching fine-tuning field is left empty — thresholds adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low.',
121
- 'sensitivity.conservative': 'Conservative (fewer interruptions)',
122
- 'sensitivity.balanced': 'Balanced (default)',
123
- 'sensitivity.aggressive': 'Aggressive (fires earlier)',
124
- 'settings.guardEchoFailures': 'Identical-argument failures',
125
- 'settings.guardEchoFailuresHint': 'Leave empty to scale with the sensitivity preset (3 at balanced); setting a value pins it. An echo only injects the breaker message — it never steps the reasoning effort down.',
126
- 'settings.guardAdaptive': 'Adaptive',
127
97
  }
128
98
 
129
99
  /** Every key in the locale catalog. */
@@ -52,7 +52,6 @@ function pendingSnapshot<T>(): ConfigFormSnapshot<T> {
52
52
  user: undefined,
53
53
  revision: undefined,
54
54
  writable: false,
55
- mode: 'host',
56
55
  }
57
56
  }
58
57
 
@@ -71,7 +71,7 @@ describe('readCompositionRows', () => {
71
71
  // Given the tool-catalog row, When the operator reads its config, Then the
72
72
  // shipped scalars and the single-line flow sequence survive.
73
73
  const catalog = configOf(rowOf(rows(), 'tool-catalog'))
74
- expect(catalog['presentation']).toBe('both')
74
+ expect(catalog['presentation']).toBe('ptc')
75
75
  expect(catalog['descriptionMaxLength']).toBe(200)
76
76
  expect(catalog['maxResidentTokens']).toBe(8000)
77
77
  expect(catalog['pagedToolPatterns']).toEqual(['mcp__*'])
@@ -243,51 +243,12 @@ describe('applyPresetOverrides', () => {
243
243
  expect(applyPresetOverrides(parsed, {})).toEqual(parsed)
244
244
  })
245
245
 
246
- it('operator leaves every guard key out of the row while the settings are unset', () => {
247
- // Given the shipped rows and settings whose guard overrides are unset (the
248
- // factory state), When the operator applies the overlay, Then the guard row
249
- // carries no fine-tuning key at all, so the guard's own effort-adaptive
250
- // thresholds and sensitivity preset are what a session actually runs.
251
- const applied = applyPresetOverrides(rows(), {
252
- presentation: 'both',
253
- guardEnabled: true,
254
- guardSensitivity: 'balanced',
255
- guardStallReasoningChars: undefined,
256
- guardGlobalStallCap: undefined,
257
- guardEchoFailures: undefined,
258
- })
259
- expect(configOf(rowOf(applied, 'guard'))).toEqual({ enabled: true, sensitivity: 'balanced' })
260
- })
261
-
262
- it('operator writes the settings into the rows that carry them', () => {
263
- // Given committed settings, When the operator applies the overlay, Then
264
- // the tool-catalog and guard rows carry them and nothing else moves.
265
- const applied = applyPresetOverrides(rows(), {
266
- presentation: 'ptc',
267
- guardEnabled: false,
268
- guardSensitivity: 'aggressive',
269
- guardStallReasoningChars: 12000,
270
- guardGlobalStallCap: 6,
271
- guardEchoFailures: 2,
272
- })
273
- expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('ptc')
274
- expect(configOf(rowOf(applied, 'guard'))).toEqual({
275
- enabled: false,
276
- sensitivity: 'aggressive',
277
- stallReasoningChars: 12000,
278
- globalStallCap: 6,
279
- echoFailures: 2,
280
- })
281
- expect(configOf(rowOf(applied, 'tool-catalog'))['descriptionMaxLength']).toBe(200)
282
- expect(rowOf(applied, 'minimal-prompt')).toEqual(rowOf(rows(), 'minimal-prompt'))
283
- })
284
-
285
246
  it('operator leaves the dispatcher key out of the row while the setting is unset', () => {
286
247
  // Given the shipped rows and no dispatcher choice, When the operator
287
248
  // applies the overlay, Then the minimal-prompt row keeps exactly the keys
288
249
  // the composition declares: the switch is only ever written when a caller
289
250
  // committed a value for it, never invented as a factory default.
290
- const applied = applyPresetOverrides(rows(), { presentation: 'both' })
251
+ const applied = applyPresetOverrides(rows(), { presentation: 'native' })
291
252
  expect(rowOf(applied, 'minimal-prompt')).toEqual(rowOf(rows(), 'minimal-prompt'))
292
253
  expect(configOf(rowOf(applied, 'minimal-prompt'))['dispatcher']).toBe(true)
293
254
  })
@@ -297,13 +258,13 @@ describe('applyPresetOverrides', () => {
297
258
  // overlay, Then the minimal-prompt row carries it and the presentation key
298
259
  // in the tool-catalog row is untouched: the two settings are orthogonal,
299
260
  // and the row's other config keys survive.
300
- const applied = applyPresetOverrides(rows(), { presentation: 'both', dispatcher: true })
261
+ const applied = applyPresetOverrides(rows(), { presentation: 'native', dispatcher: true })
301
262
  const prompt = configOf(rowOf(applied, 'minimal-prompt'))
302
263
  expect(prompt['dispatcher']).toBe(true)
303
264
  expect(prompt['keepPlanPolicy']).toBe(true)
304
265
  expect(prompt['instructionSource']).toBe('host')
305
- expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('both')
306
- expect(rowOf(applied, 'guard')).toEqual(rowOf(rows(), 'guard'))
266
+ expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('native')
267
+ expect(rowOf(applied, 'working-context')).toEqual(rowOf(rows(), 'working-context'))
307
268
  })
308
269
 
309
270
  it('operator turns the dispatcher switch back off through the same key', () => {
@@ -317,7 +278,7 @@ describe('applyPresetOverrides', () => {
317
278
  it('operator is never given a row the composition does not carry', () => {
318
279
  // Given a composition with no tool-catalog row, When the operator applies
319
280
  // a presentation choice, Then no row is invented for it.
320
- const parsed = readCompositionRows('- id: other\n name: ./other.mjs\n config:\n presentation: both\n', presetDir)
281
+ const parsed = readCompositionRows('- id: other\n name: ./other.mjs\n config:\n presentation: native\n', presetDir)
321
282
  const applied = applyPresetOverrides(parsed, { presentation: 'ptc' })
322
283
  expect(applied).toEqual(parsed)
323
284
  })
@@ -491,24 +491,13 @@ export function readPresetDefinition(id: string, dir: string): PresetDefinition
491
491
  * The settings surface edits the PLUGIN's own Config, while the values that
492
492
  * shape a session live in the declared preset's rows; applying them here is what
493
493
  * connects the two. Every field is optional, and an absent OR `undefined` value
494
- * writes nothing at all — the key stays out of the row and the guard's own
495
- * adaptive resolution decides the effective threshold.
494
+ * writes nothing at all — the key stays out of the row.
496
495
  */
497
496
  export interface PresetOverrides {
498
497
  /** The `tool-catalog` row's `presentation` value. */
499
498
  presentation?: string
500
499
  /** The `minimal-prompt` row's `dispatcher` switch. */
501
500
  dispatcher?: boolean
502
- /** The `guard` row's `enabled` switch. */
503
- guardEnabled?: boolean
504
- /** The `guard` row's sensitivity preset. */
505
- guardSensitivity?: string
506
- /** The `guard` row's per-step reasoning-character floor override. */
507
- guardStallReasoningChars?: number | undefined
508
- /** The `guard` row's slow-burn step cap override. */
509
- guardGlobalStallCap?: number | undefined
510
- /** The `guard` row's identical-argument failure count override. */
511
- guardEchoFailures?: number | undefined
512
501
  }
513
502
 
514
503
  /** One settings overlay entry: the row it targets and the keys it writes. */
@@ -519,13 +508,6 @@ function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
519
508
  return [
520
509
  ['tool-catalog', { ...overrides.presentation === undefined ? {} : { presentation: overrides.presentation } }],
521
510
  ['minimal-prompt', { ...overrides.dispatcher === undefined ? {} : { dispatcher: overrides.dispatcher } }],
522
- ['guard', {
523
- ...overrides.guardEnabled === undefined ? {} : { enabled: overrides.guardEnabled },
524
- ...overrides.guardSensitivity === undefined ? {} : { sensitivity: overrides.guardSensitivity },
525
- ...overrides.guardStallReasoningChars === undefined ? {} : { stallReasoningChars: overrides.guardStallReasoningChars },
526
- ...overrides.guardGlobalStallCap === undefined ? {} : { globalStallCap: overrides.guardGlobalStallCap },
527
- ...overrides.guardEchoFailures === undefined ? {} : { echoFailures: overrides.guardEchoFailures },
528
- }],
529
511
  ]
530
512
  }
531
513
 
@@ -535,9 +517,8 @@ function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
535
517
  * Rows are addressed by their `id`, and only a row the composition actually
536
518
  * carries is touched: the overlay narrows the shipped configuration, it never
537
519
  * invents a mount the preset did not have. A field the settings surface left
538
- * unset is written as no key at all rather than as a value, which is what keeps
539
- * the guard's effort-adaptive thresholds the shipped behavior: the overlay only
540
- * ever adds an override on top of them.
520
+ * unset is written as no key at all rather than as a value, so the row keeps the
521
+ * value the composition declares.
541
522
  * @param rows - the parsed composition rows.
542
523
  * @param overrides - the operator's settings-surface choices.
543
524
  * @returns a new row list with the overlay applied.
package/src/index.test.ts CHANGED
@@ -86,32 +86,6 @@ describe('resolveConfig', () => {
86
86
  expect(resolveConfig(Config({}))).toEqual(DEFAULT_CONFIG)
87
87
  })
88
88
 
89
- it('operator gets the guard fine-tuning fields UNSET by default', () => {
90
- // Given the shipped schema and the reader, When the operator reads the
91
- // effective guard settings, Then the three fine-tuning overrides resolve to
92
- // undefined rather than to a factory constant. That is what lets the
93
- // guard's effort-adaptive table and the sensitivity preset be the shipped
94
- // behavior: a default here would be written into the declared preset's
95
- // guard row on every activation and mask both.
96
- const values = resolveConfig(Config({}))
97
- expect(values.guardStallReasoningChars).toBeUndefined()
98
- expect(values.guardGlobalStallCap).toBeUndefined()
99
- expect(values.guardEchoFailures).toBeUndefined()
100
- // The two fields that are NOT overrides keep their real defaults.
101
- expect(values.guardEnabled).toBe(true)
102
- expect(values.guardSensitivity).toBe('balanced')
103
- expect(DEFAULT_CONFIG.guardStallReasoningChars).toBeUndefined()
104
- })
105
-
106
- it('operator who clears a guard field gets undefined, not the previous value', () => {
107
- // Given a volatile reference the Host clears, When the operator reads the
108
- // effective settings, Then the field reads as unset so the overlay leaves
109
- // the guard row's key out and the adaptive table applies again.
110
- const cleared = { get: () => undefined }
111
- expect(resolveConfig({ guardStallReasoningChars: cleared }).guardStallReasoningChars).toBeUndefined()
112
- expect(resolveConfig({ guardStallReasoningChars: undefined }).guardStallReasoningChars).toBeUndefined()
113
- })
114
-
115
89
  it('operator sees a committed volatile write through the held reference', () => {
116
90
  // Given a volatile field the Host hands over as a stable reference, When
117
91
  // the operator commits a write and reads again, Then the read moves with it.
@@ -131,21 +105,11 @@ describe('resolveConfig', () => {
131
105
  announceToAgent: true,
132
106
  presentation: 'ptc',
133
107
  dispatcher: true,
134
- guardEnabled: false,
135
- guardSensitivity: 'aggressive',
136
- guardStallReasoningChars: 12000,
137
- guardGlobalStallCap: 6,
138
- guardEchoFailures: 2,
139
108
  })).toEqual({
140
109
  enabled: false,
141
110
  announceToAgent: true,
142
111
  presentation: 'ptc',
143
112
  dispatcher: true,
144
- guardEnabled: false,
145
- guardSensitivity: 'aggressive',
146
- guardStallReasoningChars: 12000,
147
- guardGlobalStallCap: 6,
148
- guardEchoFailures: 2,
149
113
  })
150
114
  })
151
115
 
@@ -170,11 +134,16 @@ describe('resolveConfig', () => {
170
134
  // appended rule block; presentation changes the WIRE, the tool surface),
171
135
  // When the operator reads every combination, Then each field resolves to
172
136
  // the value it was given with no cross-talk between them.
173
- for (const presentation of ['ptc', 'native', 'both'] as const) {
137
+ for (const presentation of ['ptc', 'native'] as const) {
174
138
  for (const dispatcher of [true, false]) {
175
139
  expect(resolveConfig({ presentation, dispatcher })).toMatchObject({ presentation, dispatcher })
176
140
  }
177
141
  }
142
+ // Pre-0.2.1 profiles persisted `presentation: 'both'` (the former default);
143
+ // both the schema and the reader normalize it to `'ptc'` so upgrading never
144
+ // degrades the row at startup.
145
+ expect(resolveConfig(Config({ presentation: 'both' })).presentation).toBe('ptc')
146
+ expect(resolveConfig({ presentation: 'both' }).presentation).toBe('ptc')
178
147
  })
179
148
  })
180
149
 
package/src/index.ts CHANGED
@@ -19,11 +19,10 @@
19
19
  * The preset combines a minimal persona with a lifetime-declared tool
20
20
  * presentation: the system prompt keeps a minimal persona with standing
21
21
  * working discipline and workspace instructions, and the wire runs the SDK's
22
- * 'both' presentation by default — the assembled native roster stays on the
23
- * wire for ordinary work and the `run_code` transport sits co-resident for
24
- * programmatic batch computation and wide fan-out, declared once per session
25
- * instead of staged across a turn boundary ('native' and 'ptc' are one-line
26
- * opt-outs). High-fan-out tool families
22
+ * 'ptc' presentation by default — the wire collapses to the `run_code`
23
+ * transport and every other tool is reached from inside the program through
24
+ * the generated SDK ('native' keeps the assembled roster alone), declared once
25
+ * per session instead of staged across a turn boundary. High-fan-out tool families
27
26
  * (default `mcp__*`) stay paged out of the executed surface through the
28
27
  * host's scoped tool restriction until the preset's own `tool_activate` tool
29
28
  * loads their namespace (LRU cap three), with the activation state replayed
@@ -61,17 +60,11 @@ export const LIANGSHEN_SETTINGS_NAMESPACE = 'liangshen' as SettingsNamespace
61
60
  export const inject = ['systemPrompt']
62
61
 
63
62
  /** The wire presentations the preset's tool catalog accepts. */
64
- export const PRESENTATION_OPTIONS = ['ptc', 'native', 'both'] as const
65
-
66
- /** Sensitivity presets for the circuit breaker's adaptive thresholds. */
67
- export const SENSITIVITY_OPTIONS = ['conservative', 'balanced', 'aggressive'] as const
63
+ export const PRESENTATION_OPTIONS = ['ptc', 'native'] as const
68
64
 
69
65
  /** One wire presentation. */
70
66
  export type Presentation = (typeof PRESENTATION_OPTIONS)[number]
71
67
 
72
- /** One circuit-breaker sensitivity preset. */
73
- export type GuardSensitivity = (typeof SENSITIVITY_OPTIONS)[number]
74
-
75
68
  /**
76
69
  * One activation field as the Host hands it over: a stable reference whose
77
70
  * `get()` reads the value committed for this instance (a settings write updates
@@ -95,11 +88,12 @@ export interface Config {
95
88
  announceToAgent?: ConfigField<boolean>
96
89
  /**
97
90
  * Wire presentation written into the declared preset's tool-catalog row.
98
- * `both` (default) keeps the assembled roster and the `run_code` transport
99
- * co-resident; `native` keeps only the roster; `ptc` collapses the wire to
100
- * the transport.
91
+ * `ptc` (default) collapses the wire to the single `run_code` transport and
92
+ * reaches every other tool through the generated SDK; `native` keeps the
93
+ * assembled roster alone. Legacy `'both'` (the pre-0.2.1 shipped default) is
94
+ * accepted from older saved profiles and normalized to `'ptc'`.
101
95
  */
102
- presentation?: ConfigField<Presentation>
96
+ presentation?: ConfigField<Presentation | 'both'>
103
97
  /**
104
98
  * When true, the preset appends the dispatcher rule block to its persona:
105
99
  * the session becomes a dispatch agent whose deliverable is the plan, the
@@ -109,45 +103,16 @@ export interface Config {
109
103
  * and the switch is what returns a session to the bare persona.
110
104
  */
111
105
  dispatcher?: ConfigField<boolean>
112
- /** Master switch for the runtime degeneration circuit breaker (default true). */
113
- guardEnabled?: ConfigField<boolean>
114
- /**
115
- * Sensitivity preset scaling the breaker's adaptive thresholds
116
- * (default 'balanced'). 'conservative' interrupts less, 'aggressive' fires earlier.
117
- */
118
- guardSensitivity?: ConfigField<GuardSensitivity>
119
- /**
120
- * Override for the per-step runaway-reasoning character floor. Left unset,
121
- * the floor adapts to the session's reasoning effort and is then scaled by
122
- * `guardSensitivity`; setting it wins over both for every effort level.
123
- */
124
- guardStallReasoningChars?: ConfigField<number | undefined>
125
- /**
126
- * Override for the slow-burn step count. Left unset, the cap scales with
127
- * `guardSensitivity`.
128
- */
129
- guardGlobalStallCap?: ConfigField<number | undefined>
130
- /**
131
- * Override for the echo ladder. Left unset, the count scales with
132
- * `guardSensitivity`.
133
- */
134
- guardEchoFailures?: ConfigField<number | undefined>
135
106
  }
136
107
 
137
108
  export const Config = z.object({
138
109
  enabled: z.boolean().default(true).volatile(),
139
110
  announceToAgent: z.boolean().default(false).volatile(),
140
- presentation: z.union([...PRESENTATION_OPTIONS]).default('both').volatile(),
111
+ presentation: z.union([
112
+ ...PRESENTATION_OPTIONS,
113
+ z.transform('both', (): Presentation => 'ptc').deprecated().hidden(),
114
+ ]).default('ptc').volatile(),
141
115
  dispatcher: z.boolean().default(true).volatile(),
142
- guardEnabled: z.boolean().default(true).volatile(),
143
- guardSensitivity: z.union([...SENSITIVITY_OPTIONS]).default('balanced').volatile(),
144
- // Deliberately WITHOUT a default: these three are fine-tuning overrides, and
145
- // a factory value here would be written into the declared preset's guard row
146
- // on every activation, permanently masking the effort-adaptive table and the
147
- // sensitivity preset behind a constant.
148
- guardStallReasoningChars: z.number().volatile(),
149
- guardGlobalStallCap: z.number().volatile(),
150
- guardEchoFailures: z.number().volatile(),
151
116
  })
152
117
 
153
118
  /** The settings the runtime acts on, every field read at its use site. */
@@ -160,42 +125,21 @@ export interface ResolvedConfig {
160
125
  presentation: Presentation
161
126
  /** Whether the declared preset's minimal-prompt row appends the dispatcher rule block. */
162
127
  dispatcher: boolean
163
- /** Breaker master switch written into the declared preset's guard row. */
164
- guardEnabled: boolean
165
- /** Breaker sensitivity written into the declared preset's guard row. */
166
- guardSensitivity: GuardSensitivity
167
- /** Per-step reasoning-character floor written into the guard row, or undefined to leave the adaptive table in charge. */
168
- guardStallReasoningChars: number | undefined
169
- /** Slow-burn step cap written into the guard row, or undefined to leave the sensitivity preset in charge. */
170
- guardGlobalStallCap: number | undefined
171
- /** Echo-ladder failure count written into the guard row, or undefined to leave the sensitivity preset in charge. */
172
- guardEchoFailures: number | undefined
173
128
  }
174
129
 
175
- /**
176
- * Schema defaults, re-read for hand-built test contexts. The three guard
177
- * fine-tuning fields default to undefined — "unset" IS the shipped default,
178
- * and the guard resolves the effective thresholds per request from the
179
- * session's reasoning effort and the sensitivity preset.
180
- */
130
+ /** Schema defaults, re-read for hand-built test contexts. */
181
131
  export const DEFAULT_CONFIG: ResolvedConfig = {
182
132
  enabled: true,
183
133
  announceToAgent: false,
184
- presentation: 'both',
134
+ presentation: 'ptc',
185
135
  dispatcher: true,
186
- guardEnabled: true,
187
- guardSensitivity: 'balanced',
188
- guardStallReasoningChars: undefined,
189
- guardGlobalStallCap: undefined,
190
- guardEchoFailures: undefined,
191
136
  }
192
137
 
193
138
  /**
194
139
  * Read one activation field. The Host validates the raw profile config and
195
140
  * hands volatile fields over as references, so a read goes through `get()`; a
196
141
  * plain value passes through, and an absent field falls back to the schema
197
- * default — which is `undefined` for the three guard fine-tuning overrides,
198
- * so "unset" survives as a real value instead of collapsing into a constant.
142
+ * default.
199
143
  */
200
144
  function readField<T>(field: ConfigField<T>, fallback: T): T {
201
145
  if (field === undefined || field === null) return fallback
@@ -210,21 +154,17 @@ function readField<T>(field: ConfigField<T>, fallback: T): T {
210
154
  * @returns every field resolved against the schema defaults.
211
155
  */
212
156
  export function resolveConfig(config?: Config): ResolvedConfig {
157
+ const rawPresentation = readField<Presentation | 'both'>(config?.presentation, DEFAULT_CONFIG.presentation)
213
158
  return {
214
159
  enabled: readField(config?.enabled, DEFAULT_CONFIG.enabled),
215
160
  announceToAgent: readField(config?.announceToAgent, DEFAULT_CONFIG.announceToAgent),
216
- presentation: readField(config?.presentation, DEFAULT_CONFIG.presentation),
161
+ presentation: rawPresentation === 'both' ? 'ptc' : rawPresentation,
217
162
  dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher),
218
- guardEnabled: readField(config?.guardEnabled, DEFAULT_CONFIG.guardEnabled),
219
- guardSensitivity: readField(config?.guardSensitivity, DEFAULT_CONFIG.guardSensitivity),
220
- guardStallReasoningChars: readField(config?.guardStallReasoningChars, DEFAULT_CONFIG.guardStallReasoningChars),
221
- guardGlobalStallCap: readField(config?.guardGlobalStallCap, DEFAULT_CONFIG.guardGlobalStallCap),
222
- guardEchoFailures: readField(config?.guardEchoFailures, DEFAULT_CONFIG.guardEchoFailures),
223
163
  }
224
164
  }
225
165
 
226
166
  /** Model-facing announcement: plugin presence, principle, and limits. */
227
- export const LIANGSHEN_GUIDANCE = '本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 \'both\'(默认:原生清单与 run_code 同驻,原生直调优先、run_code 用于程序化批处理与并发扇出)、\'native\'(组装出的原生清单)或 \'ptc\'(wire 收拢为唯一的 run_code),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 [\'mcp__*\']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。运行时退化熔断器(guard)从事件流折叠停摆(连续零产出长思考)与空转(同参重复失败)信号,每 episode 触发一次:注入熔断消息;仅停摆信号(成因是推理预算过剩)额外把推理档位临时下调一档(max→high,窗口 3 个请求,high 档本身处于甜区不动),空转信号只注入消息。阈值随会话推理档位自适应(max 8000 / high 12000 / low 20000 字符)并再按灵敏度预设缩放;provider 不持久化推理文本的会话降级为连续零产出步骤计数。无信号时从不改写请求。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。'
167
+ export const LIANGSHEN_GUIDANCE = '本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 \'ptc\'(默认:wire 收拢为唯一的 run_code,其余工具经生成的 SDK 调用)或 \'native\'(组装出的原生清单,无程序化传输),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 [\'mcp__*\']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。'
228
168
 
229
169
  /** Order of the announcement section within the tool-guidance band. */
230
170
  const SECTION_ORDER = 150
@@ -16,18 +16,18 @@
16
16
  * - Session persistence is redirected into the run directory, so real session
17
17
  * history is never appended to.
18
18
  *
19
- * The candidate matrix follows the LiangShen V4.1 Flash improvement plan:
20
- * B (current persona), P (candidate persona), T (candidate persona + PTC-only
21
- * presentation), T (candidate persona + 'both' presentation), N (candidate
22
- * persona + native presentation throughout), and M
23
- * (the official bundle's Minimal preset as an external reference). Persona
24
- * wording and tool presentation vary independently, and a run records the
25
- * baseline it ran against so an aggregated report can attribute a difference to
26
- * one factor.
19
+ * The candidate matrix follows the LiangShen V4.1 Flash improvement plan,
20
+ * minus the retired 'both' presentation arm (the SDK dropped the mode, so the
21
+ * shipped default IS the ptc wire): B (current persona + shipped 'ptc'
22
+ * presentation), P (candidate persona + shipped 'ptc' presentation), N
23
+ * (candidate persona + native presentation throughout), and M (the official
24
+ * bundle's Minimal preset as an external reference). Persona wording and tool
25
+ * presentation vary independently, and a run records the baseline it ran
26
+ * against so an aggregated report can attribute a difference to one factor.
27
27
  *
28
28
  * Usage:
29
29
  * node tools/benchmark-live-run.mjs --variant B [--timeout 300000] [--keep]
30
- * node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json --out .benchmark-results
30
+ * node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json --out .benchmark-results
31
31
  *
32
32
  * Cost is CNY: DeepSeek bills in CNY, and the published row the route prices at
33
33
  * is quoted in CNY per million tokens (cache hit / cache miss / output) off-peak,
@@ -60,7 +60,7 @@ export const DEFAULT_TURNS = [
60
60
  ]
61
61
 
62
62
  /**
63
- * The candidate persona for groups P/T/N. It keeps the identity line and replaces
63
+ * The candidate persona for groups P/N. It keeps the identity line and replaces
64
64
  * the shipped discipline: no ban on reasoning through concrete implementation, a
65
65
  * loop exits by changing method or using a tool instead of stopping, and PDCA is
66
66
  * expressed as inspect, smallest sufficient change, verify.
@@ -86,17 +86,12 @@ export const LIVE_VARIANTS = {
86
86
  B: {
87
87
  persona: 'current',
88
88
  presentation: null,
89
- note: "baseline: shipped persona, shipped 'both' presentation",
89
+ note: "baseline: shipped persona, shipped 'ptc' presentation",
90
90
  },
91
91
  P: {
92
92
  persona: 'candidate',
93
93
  presentation: null,
94
- note: "candidate persona, shipped 'both' presentation",
95
- },
96
- T: {
97
- persona: 'candidate',
98
- presentation: 'ptc',
99
- note: "candidate persona, 'ptc' presentation (collapsed wire to run_code)",
94
+ note: "candidate persona, shipped 'ptc' presentation",
100
95
  },
101
96
  N: {
102
97
  persona: 'candidate',
@@ -16,7 +16,7 @@ import { join } from 'node:path'
16
16
  import { pathToFileURL } from 'node:url'
17
17
 
18
18
  /** Presentational order of the candidate matrix. */
19
- export const GROUP_ORDER = ['B', 'P', 'T', 'N', 'M']
19
+ export const GROUP_ORDER = ['B', 'P', 'N', 'M']
20
20
 
21
21
  /** Two-sided 95% t critical values for small samples; the normal limit past 30 df. */
22
22
  const T95 = {
@@ -180,8 +180,7 @@ export function plannedComparisons(runs, baselineGroup = 'B') {
180
180
  const present = new Set(runs.map((run) => run.variant))
181
181
  const comparisons = []
182
182
  if (present.has(baselineGroup) && present.has('P')) comparisons.push(pairedComparison(runs, baselineGroup, 'P'))
183
- if (present.has('P') && present.has('T')) comparisons.push(pairedComparison(runs, 'P', 'T'))
184
- if (present.has('T') && present.has('N')) comparisons.push(pairedComparison(runs, 'T', 'N'))
183
+ if (present.has('P') && present.has('N')) comparisons.push(pairedComparison(runs, 'P', 'N'))
185
184
  if (present.has(baselineGroup) && present.has('M')) comparisons.push(pairedComparison(runs, baselineGroup, 'M'))
186
185
  return comparisons
187
186
  }
@@ -322,9 +321,8 @@ export function renderMarkdown(report) {
322
321
  lines.push('| Comparison | Purpose | Tasks paired | Mean delta (95% CI) |')
323
322
  lines.push('| --- | --- | --- | --- |')
324
323
  const purposes = {
325
- 'B-P': 'isolates the persona change',
326
- 'P-T': "compares the 'both' presentation against 'ptc'",
327
- 'T-N': 'compares the PTC transport against the native roster',
324
+ 'B-P': 'isolates the persona change at the shipped ptc wire',
325
+ 'P-N': "compares the 'ptc' presentation against the native roster",
328
326
  'B-M': 'external reference, not single-factor attribution',
329
327
  }
330
328
  for (const comparison of report.comparisons) {