@linxin666/dsh-liangshen 0.4.5 → 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.
- package/README.i18n.yaml +2 -2
- package/README.md +21 -22
- package/README.zh.md +21 -22
- package/lib/client.js +62 -212
- package/lib/client.js.map +1 -1
- package/lib/index.js +18 -46
- package/lib/types/client/LiangShenMark.d.ts +13 -0
- package/lib/types/client/LiangShenSettingsCard.d.ts +12 -25
- package/lib/types/client/locales.d.ts +2 -14
- package/lib/types/client/plugin-card-seat.d.ts +5 -0
- package/lib/types/composition.d.ts +7 -15
- package/lib/types/index.d.ts +24 -54
- package/package.json +20 -20
- package/presets/liangshen/agent.cordis.yml +48 -36
- package/presets/liangshen/dispatcher-rules.mjs +190 -0
- package/presets/liangshen/minimal-prompt.mjs +75 -12
- package/presets/liangshen/tool-catalog.mjs +177 -67
- package/src/announce.test.ts +7 -13
- package/src/client/LiangShenMark.tsx +25 -0
- package/src/client/LiangShenSettingsCard.tsx +24 -87
- package/src/client/locales.ts +6 -30
- package/src/client/plugin-card-seat.ts +7 -0
- package/src/client/settings-entry-form.ts +0 -1
- package/src/composition.test.ts +39 -22
- package/src/composition.ts +8 -22
- package/src/index.test.ts +35 -10
- package/src/index.ts +30 -62
- package/tools/benchmark-live-run.mjs +12 -17
- package/tools/benchmark-report.mjs +4 -6
- package/presets/liangshen/guard.mjs +0 -426
package/src/client/locales.ts
CHANGED
|
@@ -28,7 +28,9 @@ export const zh = {
|
|
|
28
28
|
'settings.announceToAgent': '向 agent 公告本插件',
|
|
29
29
|
'settings.announceToAgentHint': '开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。',
|
|
30
30
|
'settings.presentation': '工具面呈现方式',
|
|
31
|
-
'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:
|
|
31
|
+
'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:ptc(出厂默认)把 wire 收拢为 run_code,其余工具经生成的 SDK 调用;native 保持原生工具清单。改动立即生效,但已开始的会话保持其已声明的组合。',
|
|
32
|
+
'settings.dispatcher': '调度者身份',
|
|
33
|
+
'settings.dispatcherHint': '开启后本模式按调度 Agent 工作:先分诊复杂度(L0/L1 直接执行,L2 走完整流程),L2 任务先澄清访谈再规划,由主代理派发子代理并逐层审查与验收。与工具面呈现方式无关,只决定身份与流程纪律。出厂默认开启;关闭后回到仅含工作纪律的极简 persona。',
|
|
32
34
|
'settings.on': '开',
|
|
33
35
|
'settings.off': '关',
|
|
34
36
|
'settings.inherit': '继承(跟随部署默认)',
|
|
@@ -46,20 +48,6 @@ export const zh = {
|
|
|
46
48
|
'settings.invalidValue': '该取值不被接受',
|
|
47
49
|
'presentation.ptc': 'ptc(仅 run_code)',
|
|
48
50
|
'presentation.native': 'native(原生工具清单)',
|
|
49
|
-
'presentation.both': 'both(两者同驻)',
|
|
50
|
-
'settings.guardEnabled': '启用退化熔断器',
|
|
51
|
-
'settings.guardEnabledHint': '运行时检测思考退化(连续零产出长思考 / 同参重复失败),触发时注入熔断提示并临时下调推理档位。关闭后不干预任何请求。',
|
|
52
|
-
'settings.guardStallChars': '单步暴走字符阈值',
|
|
53
|
-
'settings.guardStallCharsHint': '单条推理达到该字符数且零产出即触发熔断(按 V4.1 官方 384K 最大输出校准;默认 8000,约 2-4K 思考 token)。',
|
|
54
|
-
'settings.guardGlobalCap': '慢烧连续步数',
|
|
55
|
-
'settings.guardGlobalCapHint': '连续多少步有真实推理但零产出触发慢烧熔断(默认 4;步数越小越敏感,真实长调查建议调大)。',
|
|
56
|
-
'settings.guardSensitivity': '熔断灵敏度',
|
|
57
|
-
'settings.guardSensitivityHint': '整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5)。阈值随推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符。',
|
|
58
|
-
'sensitivity.conservative': '保守(少打断)',
|
|
59
|
-
'sensitivity.balanced': '均衡(默认)',
|
|
60
|
-
'sensitivity.aggressive': '激进(早触发)',
|
|
61
|
-
'settings.guardEchoFailures': '同参连续失败次数',
|
|
62
|
-
'settings.guardEchoFailuresHint': '同一工具以相同参数连续失败多少次触发空转熔断(默认 3)。',
|
|
63
51
|
}
|
|
64
52
|
|
|
65
53
|
/** English counterpart; the key set mirrors {@link zh} exactly. */
|
|
@@ -86,7 +74,9 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
86
74
|
'settings.announceToAgent': 'Announce this plugin to agents',
|
|
87
75
|
'settings.announceToAgentHint': 'Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.',
|
|
88
76
|
'settings.presentation': 'Wire presentation',
|
|
89
|
-
'settings.presentationHint': 'Written into the tool-catalog row of the preset this plugin declares:
|
|
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.',
|
|
78
|
+
'settings.dispatcher': 'Dispatcher identity',
|
|
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.',
|
|
90
80
|
'settings.on': 'On',
|
|
91
81
|
'settings.off': 'Off',
|
|
92
82
|
'settings.inherit': 'Inherit (deployment default)',
|
|
@@ -104,20 +94,6 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
104
94
|
'settings.invalidValue': 'The value is not accepted',
|
|
105
95
|
'presentation.ptc': 'ptc (run_code only)',
|
|
106
96
|
'presentation.native': 'native (native tool roster)',
|
|
107
|
-
'presentation.both': 'both (both co-resident)',
|
|
108
|
-
'settings.guardEnabled': 'Degeneration circuit breaker',
|
|
109
|
-
'settings.guardEnabledHint': 'Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures), injecting a breaker message and stepping the reasoning effort down when it fires. Disabled means requests are never touched.',
|
|
110
|
-
'settings.guardStallChars': 'Runaway reasoning character floor',
|
|
111
|
-
'settings.guardStallCharsHint': 'One reasoning block reaching this many characters with no output fires the breaker (calibrated against V4.1\'s official 384K max output; default 8000, roughly 2-4K thinking tokens).',
|
|
112
|
-
'settings.guardGlobalCap': 'Slow-burn step count',
|
|
113
|
-
'settings.guardGlobalCapHint': 'Consecutive output-free steps of real reasoning that fire the slow-burn ladder (default 4; lower is more sensitive — raise it for genuinely long investigations).',
|
|
114
|
-
'settings.guardSensitivity': 'Breaker sensitivity',
|
|
115
|
-
'settings.guardSensitivityHint': 'Scales every breaker threshold: conservative (fewer interruptions, x1.5), balanced (the calibrated defaults), aggressive (fires earlier, x0.5). Thresholds adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low.',
|
|
116
|
-
'sensitivity.conservative': 'Conservative (fewer interruptions)',
|
|
117
|
-
'sensitivity.balanced': 'Balanced (default)',
|
|
118
|
-
'sensitivity.aggressive': 'Aggressive (fires earlier)',
|
|
119
|
-
'settings.guardEchoFailures': 'Identical-argument failures',
|
|
120
|
-
'settings.guardEchoFailuresHint': 'Identical-argument failures of the same tool in a row that fire the echo ladder (default 3).',
|
|
121
97
|
}
|
|
122
98
|
|
|
123
99
|
/** Every key in the locale catalog. */
|
|
@@ -86,6 +86,11 @@ export interface PluginCardSeat {
|
|
|
86
86
|
label?: () => string
|
|
87
87
|
/** Locale namespace the card renders with. */
|
|
88
88
|
locale: string
|
|
89
|
+
/**
|
|
90
|
+
* Child slots this card declares and renders. Forwarded to whichever seat
|
|
91
|
+
* the host renders; absent for a card that declares none.
|
|
92
|
+
*/
|
|
93
|
+
children?: Record<string, unknown>
|
|
89
94
|
/** Business-face factory of the registration. */
|
|
90
95
|
inject?: () => object
|
|
91
96
|
/**
|
|
@@ -162,12 +167,14 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
|
|
|
162
167
|
...(seat.order === undefined ? {} : { order: seat.order }),
|
|
163
168
|
...(seat.label === undefined ? {} : { label: seat.label }),
|
|
164
169
|
locale: seat.locale,
|
|
170
|
+
...(seat.children === undefined ? {} : { children: seat.children }),
|
|
165
171
|
...(seat.inject === undefined ? {} : { inject }),
|
|
166
172
|
}
|
|
167
173
|
: {
|
|
168
174
|
name: OFFICIAL_PLUGIN_CARD_SEAT,
|
|
169
175
|
key: seat.bundle,
|
|
170
176
|
locale: seat.locale,
|
|
177
|
+
...(seat.children === undefined ? {} : { children: seat.children }),
|
|
171
178
|
...(seat.inject === undefined ? {} : { inject }),
|
|
172
179
|
}) as never, component) as () => void
|
|
173
180
|
current = target
|
package/src/composition.test.ts
CHANGED
|
@@ -71,12 +71,20 @@ 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('
|
|
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__*'])
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
+
it('operator reads the shipped dispatcher switch ON on the minimal-prompt row', () => {
|
|
81
|
+
// Given the factory composition, When the operator reads the minimal-prompt
|
|
82
|
+
// row, Then it declares `dispatcher: true`: the shipped default appends the
|
|
83
|
+
// dispatcher block, and the key is present so the overlay writes a value
|
|
84
|
+
// rather than inventing a key the row never carried.
|
|
85
|
+
expect(configOf(rowOf(rows(), 'minimal-prompt'))['dispatcher']).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
|
|
80
88
|
it('operator keeps a literal block scalar verbatim', () => {
|
|
81
89
|
// Given the persona row's `prefix: |-` scalar, When the operator reads it,
|
|
82
90
|
// Then the prose is content and the next composition row ends it.
|
|
@@ -235,33 +243,42 @@ describe('applyPresetOverrides', () => {
|
|
|
235
243
|
expect(applyPresetOverrides(parsed, {})).toEqual(parsed)
|
|
236
244
|
})
|
|
237
245
|
|
|
238
|
-
it('operator
|
|
239
|
-
// Given
|
|
240
|
-
// the
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
guardSensitivity: 'aggressive',
|
|
245
|
-
guardStallReasoningChars: 12000,
|
|
246
|
-
guardGlobalStallCap: 6,
|
|
247
|
-
guardEchoFailures: 2,
|
|
248
|
-
})
|
|
249
|
-
expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('ptc')
|
|
250
|
-
expect(configOf(rowOf(applied, 'guard'))).toEqual({
|
|
251
|
-
enabled: false,
|
|
252
|
-
sensitivity: 'aggressive',
|
|
253
|
-
stallReasoningChars: 12000,
|
|
254
|
-
globalStallCap: 6,
|
|
255
|
-
echoFailures: 2,
|
|
256
|
-
})
|
|
257
|
-
expect(configOf(rowOf(applied, 'tool-catalog'))['descriptionMaxLength']).toBe(200)
|
|
246
|
+
it('operator leaves the dispatcher key out of the row while the setting is unset', () => {
|
|
247
|
+
// Given the shipped rows and no dispatcher choice, When the operator
|
|
248
|
+
// applies the overlay, Then the minimal-prompt row keeps exactly the keys
|
|
249
|
+
// the composition declares: the switch is only ever written when a caller
|
|
250
|
+
// committed a value for it, never invented as a factory default.
|
|
251
|
+
const applied = applyPresetOverrides(rows(), { presentation: 'native' })
|
|
258
252
|
expect(rowOf(applied, 'minimal-prompt')).toEqual(rowOf(rows(), 'minimal-prompt'))
|
|
253
|
+
expect(configOf(rowOf(applied, 'minimal-prompt'))['dispatcher']).toBe(true)
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('operator writes the dispatcher switch into the minimal-prompt row', () => {
|
|
257
|
+
// Given a committed dispatcher choice, When the operator applies the
|
|
258
|
+
// overlay, Then the minimal-prompt row carries it and the presentation key
|
|
259
|
+
// in the tool-catalog row is untouched: the two settings are orthogonal,
|
|
260
|
+
// and the row's other config keys survive.
|
|
261
|
+
const applied = applyPresetOverrides(rows(), { presentation: 'native', dispatcher: true })
|
|
262
|
+
const prompt = configOf(rowOf(applied, 'minimal-prompt'))
|
|
263
|
+
expect(prompt['dispatcher']).toBe(true)
|
|
264
|
+
expect(prompt['keepPlanPolicy']).toBe(true)
|
|
265
|
+
expect(prompt['instructionSource']).toBe('host')
|
|
266
|
+
expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('native')
|
|
267
|
+
expect(rowOf(applied, 'working-context')).toEqual(rowOf(rows(), 'working-context'))
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it('operator turns the dispatcher switch back off through the same key', () => {
|
|
271
|
+
// Given a committed `false` for the dispatcher switch, When the operator
|
|
272
|
+
// applies the overlay, Then the row carries that value: the key is written
|
|
273
|
+
// for both directions, so a session can return to the bare persona.
|
|
274
|
+
const applied = applyPresetOverrides(rows(), { dispatcher: false })
|
|
275
|
+
expect(configOf(rowOf(applied, 'minimal-prompt'))['dispatcher']).toBe(false)
|
|
259
276
|
})
|
|
260
277
|
|
|
261
278
|
it('operator is never given a row the composition does not carry', () => {
|
|
262
279
|
// Given a composition with no tool-catalog row, When the operator applies
|
|
263
280
|
// a presentation choice, Then no row is invented for it.
|
|
264
|
-
const parsed = readCompositionRows('- id: other\n name: ./other.mjs\n config:\n presentation:
|
|
281
|
+
const parsed = readCompositionRows('- id: other\n name: ./other.mjs\n config:\n presentation: native\n', presetDir)
|
|
265
282
|
const applied = applyPresetOverrides(parsed, { presentation: 'ptc' })
|
|
266
283
|
expect(applied).toEqual(parsed)
|
|
267
284
|
})
|
package/src/composition.ts
CHANGED
|
@@ -490,22 +490,14 @@ export function readPresetDefinition(id: string, dir: string): PresetDefinition
|
|
|
490
490
|
*
|
|
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
|
-
* connects the two. Every field is optional
|
|
494
|
-
*
|
|
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.
|
|
495
495
|
*/
|
|
496
496
|
export interface PresetOverrides {
|
|
497
497
|
/** The `tool-catalog` row's `presentation` value. */
|
|
498
498
|
presentation?: string
|
|
499
|
-
/** The `
|
|
500
|
-
|
|
501
|
-
/** The `guard` row's sensitivity preset. */
|
|
502
|
-
guardSensitivity?: string
|
|
503
|
-
/** The `guard` row's per-step reasoning-character floor. */
|
|
504
|
-
guardStallReasoningChars?: number
|
|
505
|
-
/** The `guard` row's slow-burn step cap. */
|
|
506
|
-
guardGlobalStallCap?: number
|
|
507
|
-
/** The `guard` row's identical-argument failure count. */
|
|
508
|
-
guardEchoFailures?: number
|
|
499
|
+
/** The `minimal-prompt` row's `dispatcher` switch. */
|
|
500
|
+
dispatcher?: boolean
|
|
509
501
|
}
|
|
510
502
|
|
|
511
503
|
/** One settings overlay entry: the row it targets and the keys it writes. */
|
|
@@ -515,13 +507,7 @@ type OverrideTarget = readonly [string, Readonly<Record<string, unknown>>]
|
|
|
515
507
|
function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
|
|
516
508
|
return [
|
|
517
509
|
['tool-catalog', { ...overrides.presentation === undefined ? {} : { presentation: overrides.presentation } }],
|
|
518
|
-
['
|
|
519
|
-
...overrides.guardEnabled === undefined ? {} : { enabled: overrides.guardEnabled },
|
|
520
|
-
...overrides.guardSensitivity === undefined ? {} : { sensitivity: overrides.guardSensitivity },
|
|
521
|
-
...overrides.guardStallReasoningChars === undefined ? {} : { stallReasoningChars: overrides.guardStallReasoningChars },
|
|
522
|
-
...overrides.guardGlobalStallCap === undefined ? {} : { globalStallCap: overrides.guardGlobalStallCap },
|
|
523
|
-
...overrides.guardEchoFailures === undefined ? {} : { echoFailures: overrides.guardEchoFailures },
|
|
524
|
-
}],
|
|
510
|
+
['minimal-prompt', { ...overrides.dispatcher === undefined ? {} : { dispatcher: overrides.dispatcher } }],
|
|
525
511
|
]
|
|
526
512
|
}
|
|
527
513
|
|
|
@@ -530,9 +516,9 @@ function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
|
|
|
530
516
|
*
|
|
531
517
|
* Rows are addressed by their `id`, and only a row the composition actually
|
|
532
518
|
* carries is touched: the overlay narrows the shipped configuration, it never
|
|
533
|
-
* invents a mount the preset did not have.
|
|
534
|
-
*
|
|
535
|
-
*
|
|
519
|
+
* invents a mount the preset did not have. A field the settings surface left
|
|
520
|
+
* unset is written as no key at all rather than as a value, so the row keeps the
|
|
521
|
+
* value the composition declares.
|
|
536
522
|
* @param rows - the parsed composition rows.
|
|
537
523
|
* @param overrides - the operator's settings-surface choices.
|
|
538
524
|
* @returns a new row list with the overlay applied.
|
package/src/index.test.ts
CHANGED
|
@@ -104,22 +104,47 @@ describe('resolveConfig', () => {
|
|
|
104
104
|
enabled: false,
|
|
105
105
|
announceToAgent: true,
|
|
106
106
|
presentation: 'ptc',
|
|
107
|
-
|
|
108
|
-
guardSensitivity: 'aggressive',
|
|
109
|
-
guardStallReasoningChars: 12000,
|
|
110
|
-
guardGlobalStallCap: 6,
|
|
111
|
-
guardEchoFailures: 2,
|
|
107
|
+
dispatcher: true,
|
|
112
108
|
})).toEqual({
|
|
113
109
|
enabled: false,
|
|
114
110
|
announceToAgent: true,
|
|
115
111
|
presentation: 'ptc',
|
|
116
|
-
|
|
117
|
-
guardSensitivity: 'aggressive',
|
|
118
|
-
guardStallReasoningChars: 12000,
|
|
119
|
-
guardGlobalStallCap: 6,
|
|
120
|
-
guardEchoFailures: 2,
|
|
112
|
+
dispatcher: true,
|
|
121
113
|
})
|
|
122
114
|
})
|
|
115
|
+
|
|
116
|
+
it('operator gets the dispatcher switch ON by default, as a volatile field', () => {
|
|
117
|
+
// Given the shipped schema, When the operator reads the effective settings,
|
|
118
|
+
// Then the dispatcher block is appended by default: a session that never
|
|
119
|
+
// touches the switch runs as a dispatcher, and switching it off is what
|
|
120
|
+
// returns the bare persona. The field is volatile like every other
|
|
121
|
+
// preset-shaping key, so the Host serves it as this entry's settings form
|
|
122
|
+
// and commits a write in place instead of remounting the row.
|
|
123
|
+
expect(DEFAULT_CONFIG.dispatcher).toBe(true)
|
|
124
|
+
expect(resolveConfig({}).dispatcher).toBe(true)
|
|
125
|
+
expect(resolveConfig(Config({})).dispatcher).toBe(true)
|
|
126
|
+
let committed = false
|
|
127
|
+
expect(resolveConfig({ dispatcher: { get: () => committed } }).dispatcher).toBe(false)
|
|
128
|
+
committed = true
|
|
129
|
+
expect(resolveConfig({ dispatcher: { get: () => committed } }).dispatcher).toBe(true)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('operator sees dispatcher and presentation as independent settings', () => {
|
|
133
|
+
// Given the two orthogonal settings (dispatcher changes the PROMPT, its
|
|
134
|
+
// appended rule block; presentation changes the WIRE, the tool surface),
|
|
135
|
+
// When the operator reads every combination, Then each field resolves to
|
|
136
|
+
// the value it was given with no cross-talk between them.
|
|
137
|
+
for (const presentation of ['ptc', 'native'] as const) {
|
|
138
|
+
for (const dispatcher of [true, false]) {
|
|
139
|
+
expect(resolveConfig({ presentation, dispatcher })).toMatchObject({ presentation, dispatcher })
|
|
140
|
+
}
|
|
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')
|
|
147
|
+
})
|
|
123
148
|
})
|
|
124
149
|
|
|
125
150
|
describe('bundledPresetDir', () => {
|
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
|
-
* '
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* instead of staged across a turn boundary
|
|
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'
|
|
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,41 +88,31 @@ export interface Config {
|
|
|
95
88
|
announceToAgent?: ConfigField<boolean>
|
|
96
89
|
/**
|
|
97
90
|
* Wire presentation written into the declared preset's tool-catalog row.
|
|
98
|
-
* `
|
|
99
|
-
*
|
|
100
|
-
* the
|
|
101
|
-
|
|
102
|
-
presentation?: ConfigField<Presentation>
|
|
103
|
-
/** Master switch for the runtime degeneration circuit breaker (default true). */
|
|
104
|
-
guardEnabled?: ConfigField<boolean>
|
|
105
|
-
/**
|
|
106
|
-
* Sensitivity preset scaling the breaker's adaptive thresholds
|
|
107
|
-
* (default 'balanced'). 'conservative' interrupts less, 'aggressive' fires earlier.
|
|
108
|
-
*/
|
|
109
|
-
guardSensitivity?: ConfigField<GuardSensitivity>
|
|
110
|
-
/**
|
|
111
|
-
* Reasoning characters one zero-output step must reach for the per-step
|
|
112
|
-
* ladder to fire (default 8000, calibrated against V4.1's 384K max output).
|
|
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'`.
|
|
113
95
|
*/
|
|
114
|
-
|
|
96
|
+
presentation?: ConfigField<Presentation | 'both'>
|
|
115
97
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
98
|
+
* When true, the preset appends the dispatcher rule block to its persona:
|
|
99
|
+
* the session becomes a dispatch agent whose deliverable is the plan, the
|
|
100
|
+
* task book, the review verdict, and the hand-off, on top of the mode's own
|
|
101
|
+
* working discipline. Orthogonal to `presentation` — the tool wire is the
|
|
102
|
+
* same either way. Default true: the shipped preset runs as a dispatcher,
|
|
103
|
+
* and the switch is what returns a session to the bare persona.
|
|
118
104
|
*/
|
|
119
|
-
|
|
120
|
-
/** Identical-argument tool failures in a row that trip the echo ladder (default 3). */
|
|
121
|
-
guardEchoFailures?: ConfigField<number>
|
|
105
|
+
dispatcher?: ConfigField<boolean>
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
export const Config = z.object({
|
|
125
109
|
enabled: z.boolean().default(true).volatile(),
|
|
126
110
|
announceToAgent: z.boolean().default(false).volatile(),
|
|
127
|
-
presentation: z.union([
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
guardEchoFailures: z.number().default(3).volatile(),
|
|
111
|
+
presentation: z.union([
|
|
112
|
+
...PRESENTATION_OPTIONS,
|
|
113
|
+
z.transform('both', (): Presentation => 'ptc').deprecated().hidden(),
|
|
114
|
+
]).default('ptc').volatile(),
|
|
115
|
+
dispatcher: z.boolean().default(true).volatile(),
|
|
133
116
|
})
|
|
134
117
|
|
|
135
118
|
/** The settings the runtime acts on, every field read at its use site. */
|
|
@@ -140,28 +123,16 @@ export interface ResolvedConfig {
|
|
|
140
123
|
announceToAgent: boolean
|
|
141
124
|
/** Wire presentation the declared preset's tool-catalog row carries. */
|
|
142
125
|
presentation: Presentation
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
/** Breaker sensitivity written into the declared preset's guard row. */
|
|
146
|
-
guardSensitivity: GuardSensitivity
|
|
147
|
-
/** Per-step reasoning-character floor written into the guard row. */
|
|
148
|
-
guardStallReasoningChars: number
|
|
149
|
-
/** Slow-burn step cap written into the guard row. */
|
|
150
|
-
guardGlobalStallCap: number
|
|
151
|
-
/** Echo-ladder failure count written into the guard row. */
|
|
152
|
-
guardEchoFailures: number
|
|
126
|
+
/** Whether the declared preset's minimal-prompt row appends the dispatcher rule block. */
|
|
127
|
+
dispatcher: boolean
|
|
153
128
|
}
|
|
154
129
|
|
|
155
130
|
/** Schema defaults, re-read for hand-built test contexts. */
|
|
156
131
|
export const DEFAULT_CONFIG: ResolvedConfig = {
|
|
157
132
|
enabled: true,
|
|
158
133
|
announceToAgent: false,
|
|
159
|
-
presentation: '
|
|
160
|
-
|
|
161
|
-
guardSensitivity: 'balanced',
|
|
162
|
-
guardStallReasoningChars: 8000,
|
|
163
|
-
guardGlobalStallCap: 4,
|
|
164
|
-
guardEchoFailures: 3,
|
|
134
|
+
presentation: 'ptc',
|
|
135
|
+
dispatcher: true,
|
|
165
136
|
}
|
|
166
137
|
|
|
167
138
|
/**
|
|
@@ -183,20 +154,17 @@ function readField<T>(field: ConfigField<T>, fallback: T): T {
|
|
|
183
154
|
* @returns every field resolved against the schema defaults.
|
|
184
155
|
*/
|
|
185
156
|
export function resolveConfig(config?: Config): ResolvedConfig {
|
|
157
|
+
const rawPresentation = readField<Presentation | 'both'>(config?.presentation, DEFAULT_CONFIG.presentation)
|
|
186
158
|
return {
|
|
187
159
|
enabled: readField(config?.enabled, DEFAULT_CONFIG.enabled),
|
|
188
160
|
announceToAgent: readField(config?.announceToAgent, DEFAULT_CONFIG.announceToAgent),
|
|
189
|
-
presentation:
|
|
190
|
-
|
|
191
|
-
guardSensitivity: readField(config?.guardSensitivity, DEFAULT_CONFIG.guardSensitivity),
|
|
192
|
-
guardStallReasoningChars: readField(config?.guardStallReasoningChars, DEFAULT_CONFIG.guardStallReasoningChars),
|
|
193
|
-
guardGlobalStallCap: readField(config?.guardGlobalStallCap, DEFAULT_CONFIG.guardGlobalStallCap),
|
|
194
|
-
guardEchoFailures: readField(config?.guardEchoFailures, DEFAULT_CONFIG.guardEchoFailures),
|
|
161
|
+
presentation: rawPresentation === 'both' ? 'ptc' : rawPresentation,
|
|
162
|
+
dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher),
|
|
195
163
|
}
|
|
196
164
|
}
|
|
197
165
|
|
|
198
166
|
/** Model-facing announcement: plugin presence, principle, and limits. */
|
|
199
|
-
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 按会话一次声明,取值 \'
|
|
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」时即指本插件,请据此协作。'
|
|
200
168
|
|
|
201
169
|
/** Order of the announcement section within the tool-guidance band. */
|
|
202
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
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* persona +
|
|
23
|
-
* (
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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,
|
|
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/
|
|
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 '
|
|
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 '
|
|
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', '
|
|
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('
|
|
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-
|
|
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) {
|