@linxin666/dsh-liangshen 0.4.6 → 0.4.8
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 +16 -22
- package/README.zh.md +16 -22
- package/lib/client.js +28 -228
- package/lib/client.js.map +1 -1
- package/lib/index.js +19 -61
- package/lib/types/client/LiangShenSettingsCard.d.ts +1 -18
- package/lib/types/client/PluginSettingsCard.d.ts +39 -0
- package/lib/types/client/locales.d.ts +0 -15
- package/lib/types/composition.d.ts +3 -15
- package/lib/types/index.d.ts +14 -66
- package/package.json +19 -19
- package/presets/liangshen/agent.cordis.yml +17 -40
- package/presets/liangshen/dispatcher-rules.mjs +175 -106
- package/presets/liangshen/minimal-prompt.mjs +17 -10
- package/presets/liangshen/tool-catalog.mjs +159 -82
- package/src/announce.test.ts +7 -14
- package/src/client/LiangShenSettingsCard.tsx +3 -85
- package/src/client/PluginSettingsCard.tsx +63 -3
- package/src/client/locales.ts +2 -32
- package/src/client/settings-card.module.css +70 -1
- package/src/client/settings-entry-form.ts +0 -1
- package/src/composition.test.ts +6 -45
- package/src/composition.ts +3 -22
- package/src/index.test.ts +6 -37
- package/src/index.ts +20 -80
- package/tools/benchmark-live-run.mjs +12 -17
- package/tools/benchmark-report.mjs +4 -6
- package/presets/liangshen/guard.mjs +0 -526
|
@@ -54,6 +54,19 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
|
|
|
54
54
|
onSave: () => void
|
|
55
55
|
/** Drop every staged edit. */
|
|
56
56
|
onDiscard: () => void
|
|
57
|
+
/**
|
|
58
|
+
* Id applied to the card's title element, so a header control (an immediate
|
|
59
|
+
* toggle in `headerAction`) can name itself through `aria-labelledby`
|
|
60
|
+
* instead of repeating the title as a string.
|
|
61
|
+
*/
|
|
62
|
+
titleId?: string
|
|
63
|
+
/**
|
|
64
|
+
* Render the header only, with no body region. A card whose whole setting is
|
|
65
|
+
* the header control (a switch whose explanation is the description) has no
|
|
66
|
+
* controls to lay out below it, and an empty body would draw a divider line
|
|
67
|
+
* with nothing under it.
|
|
68
|
+
*/
|
|
69
|
+
headerOnly?: boolean
|
|
57
70
|
/**
|
|
58
71
|
* Render the controls expanded on arrival (still collapsible). Defaults to
|
|
59
72
|
* true: promoted first-level sections show their settings immediately.
|
|
@@ -71,6 +84,13 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
|
|
|
71
84
|
* edits, so the footer would sit there permanently disabled.
|
|
72
85
|
*/
|
|
73
86
|
hideFooter?: boolean
|
|
87
|
+
/**
|
|
88
|
+
* Optional control rendered at the header's trailing edge, before the pending
|
|
89
|
+
* badge and the chevron. A card whose setting is one immediate flip (it
|
|
90
|
+
* applies outside the staged form) puts its ToggleSwitch here, so the control
|
|
91
|
+
* is reachable without opening the card and matches a plugin card's shape.
|
|
92
|
+
*/
|
|
93
|
+
headerAction?: ReactNode
|
|
74
94
|
/** Render children even when the settings namespace is not exposed by the host. */
|
|
75
95
|
renderChildrenWhenNotExposed?: boolean
|
|
76
96
|
/** Hide the 'not exposed' warning banner when the settings namespace is not exposed. */
|
|
@@ -100,9 +120,10 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
|
|
|
100
120
|
<div className={css.headerStatic}>
|
|
101
121
|
{props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
|
|
102
122
|
<span className={css.headText}>
|
|
103
|
-
<span className={css.name} title={title}>{title}</span>
|
|
123
|
+
<span className={css.name} id={props.titleId} title={title}>{title}</span>
|
|
104
124
|
<span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
|
|
105
125
|
</span>
|
|
126
|
+
{props.headerAction !== undefined ? <span className={css.headerAction}>{props.headerAction}</span> : null}
|
|
106
127
|
{state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}
|
|
107
128
|
</div>
|
|
108
129
|
)
|
|
@@ -116,9 +137,10 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
|
|
|
116
137
|
>
|
|
117
138
|
{props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
|
|
118
139
|
<span className={css.headText}>
|
|
119
|
-
<span className={css.name} title={title}>{title}</span>
|
|
140
|
+
<span className={css.name} id={props.titleId} title={title}>{title}</span>
|
|
120
141
|
<span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
|
|
121
142
|
</span>
|
|
143
|
+
{props.headerAction !== undefined ? <span className={css.headerAction}>{props.headerAction}</span> : null}
|
|
122
144
|
{state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}
|
|
123
145
|
<svg
|
|
124
146
|
width="14"
|
|
@@ -154,10 +176,13 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
|
|
|
154
176
|
</li>
|
|
155
177
|
)
|
|
156
178
|
}
|
|
179
|
+
// A header-only card has no body region at all: the divider would otherwise
|
|
180
|
+
// sit above an empty box.
|
|
181
|
+
const bodyVisible = expanded && props.headerOnly !== true
|
|
157
182
|
return (
|
|
158
183
|
<li className={cardClass}>
|
|
159
184
|
{header}
|
|
160
|
-
{
|
|
185
|
+
{bodyVisible
|
|
161
186
|
? (
|
|
162
187
|
<div className={css.body}>
|
|
163
188
|
{!state.writable ? <p className={css.readOnly} role="status">{props.t('settings.readOnly')}</p> : null}
|
|
@@ -562,3 +587,38 @@ export function ChoiceField(props: FieldProps & {
|
|
|
562
587
|
</div>
|
|
563
588
|
)
|
|
564
589
|
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* An immediate boolean toggle drawn as a switch track, for a setting that
|
|
593
|
+
* applies on flip rather than through a staged save. It is a real button with
|
|
594
|
+
* `role="switch"` and `aria-checked`, so keyboard and assistive activation
|
|
595
|
+
* arrive as a click and the state is announced instead of inferred from a
|
|
596
|
+
* checkbox tick.
|
|
597
|
+
*/
|
|
598
|
+
export function ToggleSwitch(props: {
|
|
599
|
+
/** Id of the element naming the switch (the card's title). */
|
|
600
|
+
labelledBy?: string
|
|
601
|
+
/** Accessible name when no element labels it. */
|
|
602
|
+
ariaLabel?: string
|
|
603
|
+
/** Current state. */
|
|
604
|
+
checked: boolean
|
|
605
|
+
/** Disables the switch while a write is in flight or the Host refuses writes. */
|
|
606
|
+
disabled?: boolean
|
|
607
|
+
/** Called with the requested next state. */
|
|
608
|
+
onChange: (next: boolean) => void
|
|
609
|
+
}) {
|
|
610
|
+
return (
|
|
611
|
+
<button
|
|
612
|
+
type="button"
|
|
613
|
+
className={css.toggle}
|
|
614
|
+
role="switch"
|
|
615
|
+
aria-checked={props.checked}
|
|
616
|
+
aria-labelledby={props.labelledBy}
|
|
617
|
+
aria-label={props.labelledBy === undefined ? props.ariaLabel : undefined}
|
|
618
|
+
disabled={props.disabled}
|
|
619
|
+
onClick={() => { props.onChange(!props.checked) }}
|
|
620
|
+
>
|
|
621
|
+
<span className={css.toggleTrack}><span className={css.toggleThumb} /></span>
|
|
622
|
+
</button>
|
|
623
|
+
)
|
|
624
|
+
}
|
package/src/client/locales.ts
CHANGED
|
@@ -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 行:
|
|
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:
|
|
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. */
|
|
@@ -111,6 +111,14 @@
|
|
|
111
111
|
line-height: 17px;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/* Header trailing control (an immediate toggle): a flex item that keeps its
|
|
115
|
+
natural width while the title block takes the remaining space. */
|
|
116
|
+
.headerAction {
|
|
117
|
+
flex: none;
|
|
118
|
+
display: inline-flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
.chevron {
|
|
115
123
|
color: var(--dsw-alias-label-tertiary);
|
|
116
124
|
flex: none;
|
|
@@ -428,6 +436,65 @@
|
|
|
428
436
|
line-height: 1.5;
|
|
429
437
|
}
|
|
430
438
|
|
|
439
|
+
/* Immediate boolean toggle: the official switch shape (30x16 track, 12px
|
|
440
|
+
thumb). The on state fills with the primary-action pair rather than a fixed
|
|
441
|
+
state color, so it stays legible in every theme; disabled dims through
|
|
442
|
+
opacity instead of a second palette. */
|
|
443
|
+
.toggle {
|
|
444
|
+
appearance: none;
|
|
445
|
+
display: inline-flex;
|
|
446
|
+
align-items: center;
|
|
447
|
+
background: transparent;
|
|
448
|
+
border: 0;
|
|
449
|
+
border-radius: 999px;
|
|
450
|
+
margin: 0;
|
|
451
|
+
padding: 0;
|
|
452
|
+
cursor: pointer;
|
|
453
|
+
font: inherit;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.toggleTrack {
|
|
457
|
+
position: relative;
|
|
458
|
+
flex: none;
|
|
459
|
+
width: 30px;
|
|
460
|
+
height: 16px;
|
|
461
|
+
border-radius: 999px;
|
|
462
|
+
/* Off must still read as a rail: border-l2 is an alpha hairline color and
|
|
463
|
+
leaves the track nearly invisible on a card surface. */
|
|
464
|
+
background: var(--dsw-alias-label-dimmed);
|
|
465
|
+
transition: background 0.18s ease;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.toggleThumb {
|
|
469
|
+
position: absolute;
|
|
470
|
+
top: 2px;
|
|
471
|
+
left: 2px;
|
|
472
|
+
width: 12px;
|
|
473
|
+
height: 12px;
|
|
474
|
+
border-radius: 50%;
|
|
475
|
+
background: var(--dsw-alias-bg-layer-3);
|
|
476
|
+
transition: left 0.18s ease;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.toggle[aria-checked='true'] .toggleTrack {
|
|
480
|
+
background: var(--dsw-alias-button-primary-fill, var(--dsw-alias-label-primary));
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.toggle[aria-checked='true'] .toggleThumb {
|
|
484
|
+
left: 16px;
|
|
485
|
+
background: var(--dsw-alias-label-primary-foreground, var(--dsw-alias-bg-layer-3));
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.toggle:focus-visible {
|
|
489
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
490
|
+
outline-offset: 2px;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.toggle:disabled {
|
|
494
|
+
opacity: 0.45;
|
|
495
|
+
cursor: default;
|
|
496
|
+
}
|
|
497
|
+
|
|
431
498
|
@media (prefers-reduced-motion: reduce) {
|
|
432
499
|
.card,
|
|
433
500
|
.header,
|
|
@@ -438,7 +505,9 @@
|
|
|
438
505
|
.save,
|
|
439
506
|
.selectChevron,
|
|
440
507
|
.selectChevronOpen,
|
|
441
|
-
.selectPopup
|
|
508
|
+
.selectPopup,
|
|
509
|
+
.toggleTrack,
|
|
510
|
+
.toggleThumb {
|
|
442
511
|
transition: none;
|
|
443
512
|
}
|
|
444
513
|
}
|
package/src/composition.test.ts
CHANGED
|
@@ -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('
|
|
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: '
|
|
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: '
|
|
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('
|
|
306
|
-
expect(rowOf(applied, '
|
|
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:
|
|
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
|
})
|
package/src/composition.ts
CHANGED
|
@@ -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
|
|
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,
|
|
539
|
-
*
|
|
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'
|
|
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
|
|