@linxin666/dsh-liangshen 0.4.18 → 0.4.19
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 +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +52 -9
- package/lib/client.js.map +1 -1
- package/lib/index.js +28 -6
- package/lib/types/client/lever-controller.d.ts +26 -2
- package/package.json +15 -15
- package/presets/liangshen/dispatcher-rules.mjs +87 -62
- package/presets/liangshen/fact-ledger.mjs +41 -25
- package/presets/liangshen/minimal-prompt.mjs +35 -16
- package/presets/liangshen/paging.mjs +140 -7
- package/presets/liangshen/subagent-routes.mjs +11 -22
- package/presets/liangshen/tool-activate.mjs +1 -7
- package/presets/liangshen/tool-catalog.mjs +141 -99
- package/presets/liangshen/working-context.mjs +81 -95
- package/src/announce.test.ts +58 -0
- package/src/client/lever-controller.ts +57 -15
- package/src/composition.test.ts +26 -0
- package/src/composition.ts +9 -1
- package/src/index.ts +22 -4
package/lib/index.js
CHANGED
|
@@ -266,7 +266,12 @@ function parseMap(cursor, indent) {
|
|
|
266
266
|
if (entry === void 0) throw new CompositionError(`line ${String(cursor.index + 1)}: expected "key: value", got "${line.trim()}"`);
|
|
267
267
|
if (Object.hasOwn(map, entry.key)) throw new CompositionError(`line ${String(cursor.index + 1)}: duplicate key "${entry.key}"`);
|
|
268
268
|
cursor.index += 1;
|
|
269
|
-
map
|
|
269
|
+
Object.defineProperty(map, entry.key, {
|
|
270
|
+
value: parseValue(cursor, indent, entry.rest),
|
|
271
|
+
enumerable: true,
|
|
272
|
+
writable: true,
|
|
273
|
+
configurable: true
|
|
274
|
+
});
|
|
270
275
|
}
|
|
271
276
|
return map;
|
|
272
277
|
}
|
|
@@ -702,14 +707,14 @@ function bundledPresetDir() {
|
|
|
702
707
|
/**
|
|
703
708
|
* Build the registry declaration of the bundled preset with the settings
|
|
704
709
|
* currently committed applied to the rows they shape.
|
|
710
|
+
* @param base - the bundled preset as parsed for this activation.
|
|
705
711
|
* @param values - the activation's effective settings.
|
|
706
712
|
* @returns the definition to submit to `ctx.agentPresets.register`.
|
|
707
713
|
*/
|
|
708
|
-
function declaration(values) {
|
|
709
|
-
const definition = readPresetDefinition(LIANGSHEN_PRESET_ID, bundledPresetDir());
|
|
714
|
+
function declaration(base, values) {
|
|
710
715
|
return {
|
|
711
|
-
...
|
|
712
|
-
plugins: applyPresetOverrides(
|
|
716
|
+
...base,
|
|
717
|
+
plugins: applyPresetOverrides(base.plugins, values)
|
|
713
718
|
};
|
|
714
719
|
}
|
|
715
720
|
/**
|
|
@@ -743,6 +748,23 @@ function applyImpl(ctx, config) {
|
|
|
743
748
|
* already present at activation is never re-declared.
|
|
744
749
|
*/
|
|
745
750
|
let registryMissing = false;
|
|
751
|
+
/**
|
|
752
|
+
* The bundled preset as parsed by this activation, read on first declaration.
|
|
753
|
+
* Every settings write re-declares, and the two preset files cannot change
|
|
754
|
+
* under a running row, so re-reading and re-parsing them on each write would
|
|
755
|
+
* block the event loop for a result identical to the one already held. A
|
|
756
|
+
* failed read is not remembered: the next declaration tries the disk again.
|
|
757
|
+
*/
|
|
758
|
+
let basePreset;
|
|
759
|
+
/**
|
|
760
|
+
* The bundled preset definition for this activation, parsed at most once.
|
|
761
|
+
* The overlay derives a new row list from it, so the cached base keeps the
|
|
762
|
+
* values the composition ships for every declaration that follows.
|
|
763
|
+
*/
|
|
764
|
+
const baseDefinition = () => {
|
|
765
|
+
if (basePreset === void 0) basePreset = readPresetDefinition(LIANGSHEN_PRESET_ID, bundledPresetDir());
|
|
766
|
+
return basePreset;
|
|
767
|
+
};
|
|
746
768
|
const warn = (message) => {
|
|
747
769
|
ctx.logger?.warn?.(`dsh-liangshen: ${message}`);
|
|
748
770
|
};
|
|
@@ -779,7 +801,7 @@ function applyImpl(ctx, config) {
|
|
|
779
801
|
return;
|
|
780
802
|
}
|
|
781
803
|
try {
|
|
782
|
-
release = await registry.register(declaration(values));
|
|
804
|
+
release = await registry.register(declaration(baseDefinition(), values));
|
|
783
805
|
registryMissing = false;
|
|
784
806
|
ctx.logger?.info?.(`liangshen: preset ${LIANGSHEN_PRESET_ID} declared`);
|
|
785
807
|
} catch (error) {
|
|
@@ -108,6 +108,14 @@ export declare class LeverController {
|
|
|
108
108
|
/** Ceiling on one in-flight switch, so a lost Remote answer cannot hang the row. */
|
|
109
109
|
private readonly selectTimeoutMs;
|
|
110
110
|
private readonly disposers;
|
|
111
|
+
/** The one face this controller hands out: the view reads it on every render. */
|
|
112
|
+
private cachedFace;
|
|
113
|
+
/**
|
|
114
|
+
* The translator bound to this plugin's locale namespace, resolved on first
|
|
115
|
+
* use. A lookup that resolved nothing is never cached, so a locale service
|
|
116
|
+
* registered after activation still reaches the same face.
|
|
117
|
+
*/
|
|
118
|
+
private cachedTranslate;
|
|
111
119
|
constructor(ctx: ClientContext, options?: LeverControllerOptions);
|
|
112
120
|
/** The snapshot store the view subscribes to. */
|
|
113
121
|
snapshot(): SnapshotStore<LeverSnapshot>;
|
|
@@ -115,8 +123,14 @@ export declare class LeverController {
|
|
|
115
123
|
start(): void;
|
|
116
124
|
/** Release every subscription. Idempotent. */
|
|
117
125
|
dispose(): void;
|
|
118
|
-
/** The inject face handed to the slot entry. */
|
|
126
|
+
/** The inject face handed to the slot entry; the same instance on every read. */
|
|
119
127
|
face(): LeverFace;
|
|
128
|
+
/**
|
|
129
|
+
* The translator bound to this plugin's locale namespace, or undefined while
|
|
130
|
+
* none answers. The binding is resolved once and only on success: a locale
|
|
131
|
+
* service that arrives later than this controller still gets its chance.
|
|
132
|
+
*/
|
|
133
|
+
private translate;
|
|
120
134
|
/** Read the roster; a refusal leaves the lever as it was. */
|
|
121
135
|
load(): Promise<void>;
|
|
122
136
|
/**
|
|
@@ -125,6 +139,8 @@ export declare class LeverController {
|
|
|
125
139
|
* and the burst counter belong to the gesture, not to a session refresh.
|
|
126
140
|
*/
|
|
127
141
|
refresh(): void;
|
|
142
|
+
/** Display name of the preset a push-up would restore; empty when there is none. */
|
|
143
|
+
private restoreLabelOf;
|
|
128
144
|
/** The verb behind one gesture direction. */
|
|
129
145
|
private toggle;
|
|
130
146
|
/**
|
|
@@ -133,7 +149,15 @@ export declare class LeverController {
|
|
|
133
149
|
*/
|
|
134
150
|
private detectPreset;
|
|
135
151
|
private rememberPrevious;
|
|
136
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* The facts one decision reads, from the live session and the roster.
|
|
154
|
+
*
|
|
155
|
+
* `previous` is resolved only for a blank session: it exists to name the
|
|
156
|
+
* preset a push-up restores, and only a blank session may switch preset at
|
|
157
|
+
* all. Resolving it costs a DOM chip lookup and a session-storage read
|
|
158
|
+
* ({@link detectPreset}), which a started session -- reported as 'locked' or
|
|
159
|
+
* 'missing' -- would pay for on every roster and session update and never use.
|
|
160
|
+
*/
|
|
137
161
|
private facts;
|
|
138
162
|
private currentSessionId;
|
|
139
163
|
private currentSession;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-liangshen",
|
|
3
3
|
"description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. High-fan-out tool families (default `['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']`, while every host builtin stays resident; customizable via `pagedToolPatterns`) stay paged out of the wire and generated SDK until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the reachable tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.19",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dsh": {
|
|
27
27
|
"engines": {
|
|
28
|
-
"dsh": ">=0.2.2-rc.
|
|
28
|
+
"dsh": ">=0.2.2-rc.3"
|
|
29
29
|
},
|
|
30
30
|
"bundle": {
|
|
31
31
|
"patch": "./cordis.patch.yml"
|
|
@@ -42,25 +42,25 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@deepseek-ai/dsh": ">=0.2.2-rc.
|
|
45
|
+
"@deepseek-ai/dsh": ">=0.2.2-rc.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@deepseek-ai/schemastery": "^3.19.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
52
|
-
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.
|
|
53
|
-
"@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.
|
|
54
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.
|
|
55
|
-
"@deepseek-ai/dsh-client-connection": "^0.2.2-rc.
|
|
56
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.
|
|
57
|
-
"@deepseek-ai/dsh-client-store": "^0.2.2-rc.
|
|
58
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-settings": "^0.2.2-rc.
|
|
63
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.
|
|
52
|
+
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.3",
|
|
53
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.3",
|
|
54
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.3",
|
|
55
|
+
"@deepseek-ai/dsh-client-connection": "^0.2.2-rc.3",
|
|
56
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.3",
|
|
57
|
+
"@deepseek-ai/dsh-client-store": "^0.2.2-rc.3",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.3",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.3",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.3",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.3",
|
|
62
|
+
"@deepseek-ai/dsh-settings": "^0.2.2-rc.3",
|
|
63
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.3",
|
|
64
64
|
"@testing-library/react": "^16.1.0",
|
|
65
65
|
"@types/node": "^22.20.0",
|
|
66
66
|
"@types/react": "~18.3.1",
|
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
* planned direct execution, and the R0.5 rewrite for the CURRENT built-in team
|
|
26
26
|
* runtime, whose only addition over plain subagents is a shared task board.
|
|
27
27
|
*
|
|
28
|
+
* RE-SYNCED at 2026-11-13 against 0.72.0 (`64cf068`, reading `f1121c8` at 0.71.0
|
|
29
|
+
* and `75aeea2` first). That pass DELETED the R0.5 compatibility gate
|
|
30
|
+
* (`c182e68`): harness 0.2.1-rc.2 removed the legacy Agent Teams runtime, so the
|
|
31
|
+
* criterion can only ever answer "absent", and this deployment runs a newer
|
|
32
|
+
* harness still—its surviving task-board contract became the `[Agent Teams Board]`
|
|
33
|
+
* paragraph. It also narrowed the UI visual evidence gate to regression-risk
|
|
34
|
+
* changes, folded external prior-art lookup into G4, added the
|
|
35
|
+
* L2-Clear/L2-Governed split and `[Execution Economy]`, and adopted upstream's
|
|
36
|
+
* one-decision-per-rule rewrite. R9 still stays adapted: the enter_plan_mode row
|
|
37
|
+
* upstream drives does not exist here.
|
|
38
|
+
*
|
|
28
39
|
* Two upstream entries are deliberately NOT carried, recorded under
|
|
29
40
|
* `provenance.omissions` with the reason: `[Dispatch Ledger]` names a
|
|
30
41
|
* `dispatch_ledger` tool this preset does not mount, and upstream's R9 drives
|
|
@@ -84,12 +95,12 @@
|
|
|
84
95
|
/** Where the rule text came from, and every correction folded into it. */
|
|
85
96
|
export const DISPATCHER_RULES_PROVENANCE = {
|
|
86
97
|
package: '@eddyskywalker/dsh-chatgpt-subscription',
|
|
87
|
-
inheritedVersion: '0.
|
|
88
|
-
/** The upstream
|
|
89
|
-
inheritedRevision: '
|
|
90
|
-
reExtractedAt: '2026-11-
|
|
91
|
-
/** The rule sections the block carries, in order: a section added upstream means a re-extraction. */
|
|
92
|
-
sections: ['R0
|
|
98
|
+
inheritedVersion: '0.72.0',
|
|
99
|
+
/** The upstream revisions the 2026-11-13 pass read: the governance/execution streamline, the verification-pressure cut, and the prompt/prior-art rewrite. */
|
|
100
|
+
inheritedRevision: 'f1121c8 (0.71.0) + 75aeea2 + 64cf068 (0.72.0); R0.5 removed upstream in c182e68',
|
|
101
|
+
reExtractedAt: '2026-11-13',
|
|
102
|
+
/** The rule sections the block carries, in order: a section added upstream means a re-extraction. R0.5 is gone because upstream deleted it (c182e68). */
|
|
103
|
+
sections: ['R0', 'R-G', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R-W', 'R7', 'R8', 'R9'],
|
|
93
104
|
/**
|
|
94
105
|
* What the 2026-11-02 re-sync folded in from upstream, section by section.
|
|
95
106
|
*
|
|
@@ -190,10 +201,16 @@ export const DISPATCHER_RULES_PROVENANCE = {
|
|
|
190
201
|
why: 'With R1 allowing direct execution, "execute it yourself" stopped being evidence of a fallback; the rule had to say which direct work is planned and which is the exception.',
|
|
191
202
|
},
|
|
192
203
|
{
|
|
193
|
-
rule: '
|
|
194
|
-
upstreamCommit: '
|
|
195
|
-
now: '
|
|
196
|
-
why: '
|
|
204
|
+
rule: '[Execution Economy]',
|
|
205
|
+
upstreamCommit: 'f1121c8',
|
|
206
|
+
now: 'L0/L1 and every implementation phase spend one cheap probe and the smallest complete change, stop after at most 2 consecutive model steps without new evidence or a verified criterion, and re-triage if complexity grows mid-task.',
|
|
207
|
+
why: 'A per-step brake that names what counts as progress keeps a session from grinding through equivalent probes; it is the same rule R0.5 used to carry once the compatibility check itself stopped existing.',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
rule: '[Agent Teams Board]',
|
|
211
|
+
upstreamCommit: 'c182e68',
|
|
212
|
+
now: 'The shared task board is bookkeeping, not a second dispatcher: the R5 brief stays the task contract, the board tools stay declared whether or not the board is on, and a ready task never starts work or skips R6.',
|
|
213
|
+
why: 'Replaces the R0.5 compatibility gate, which upstream deleted once harness 0.2.1-rc.2 removed the legacy Agent Teams runtime: the generation that gate told apart no longer exists, so only the board contract is left to state.',
|
|
197
214
|
},
|
|
198
215
|
],
|
|
199
216
|
/**
|
|
@@ -213,6 +230,18 @@ export const DISPATCHER_RULES_PROVENANCE = {
|
|
|
213
230
|
why: 'Upstream R9 enters plan mode itself once the interview converges, using rows this preset does not mount; R9 stays adapted to plan mode as the user\'s switch, which is recorded under additions.',
|
|
214
231
|
},
|
|
215
232
|
],
|
|
233
|
+
/**
|
|
234
|
+
* Upstream entries this block carried until they were deleted upstream. A
|
|
235
|
+
* removal is its own category: unlike an omission it once ran here, and unlike
|
|
236
|
+
* a correction nothing replaced it—the situation it described stopped existing.
|
|
237
|
+
*/
|
|
238
|
+
removals: [
|
|
239
|
+
{
|
|
240
|
+
rule: 'R0.5 · Compatibility Gate',
|
|
241
|
+
upstreamCommit: 'c182e68',
|
|
242
|
+
why: 'Upstream deleted the gate once harness 0.2.1-rc.2 removed the legacy Agent Teams runtime (spawn_teammate plus the team-scoped send_message/list_agents/interrupt_agent): the criterion can only ever answer "absent" now, so every new session would pay one tool-enumeration just to learn that. This deployment runs a newer harness still, so the gate is unconditionally dead weight here too. The block had carried it since the 2026-11-03 sync, where it was added as the fixed criterion for that generation pair; the task-board contract that outlived it is kept as a [Agent Teams Board] paragraph, recorded under additions.',
|
|
243
|
+
},
|
|
244
|
+
],
|
|
216
245
|
/** Corrections that are NOT appendix entries, because an appended contradiction is worse than a rewrite. */
|
|
217
246
|
corrections: [
|
|
218
247
|
{
|
|
@@ -245,50 +274,50 @@ export const DISPATCHER_RULES_PROVENANCE = {
|
|
|
245
274
|
now: 'A fork carries the conversation and inherits your route, which makes it the cheapest same-route child (no route: line owed, prefix and KV cache kept) as long as your own route is one the allowlist returned; the built-in assertion skips an inherited route, so that check is the model\'s to make. A deployment may police inherit-only tools from the host plane and refuse such a fork outright. The same reading applies to any delegation tool mounted without route fields: it cannot be given a route, so an explicit-pair demand on it is a denial no call can satisfy.',
|
|
246
275
|
why: 'Read off the current cohort: the route assertion returns early unless the call names a route, and the subagent runtime never consults the policy, so the promised built-in rejection does not exist; where a host guard does police the inherited route, its refusal names the authorized routes and cannot be repaired by any argument. The old text also banned a legitimate, cheaper form for every task that did not need the conversation.',
|
|
247
276
|
},
|
|
277
|
+
{
|
|
278
|
+
rule: 'R6 [UI Visual Evidence Gate]',
|
|
279
|
+
superseded: 'Any task that changes visible UI, layout, styling or a client component is not accepted on After evidence alone; After-only evidence fails review.',
|
|
280
|
+
now: 'Only a regression-risk change to existing layout, styling or components owes Before and After captures; pure copy, logic-only or additive work owes none, and with no reliable Before an After plus a note suffices.',
|
|
281
|
+
why: 'Measured against what the gate protects, a wording or logic change cannot regress a layout, so demanding a Before capture for it charges a screenshot that proves nothing and hides the captures that do matter in noise; upstream reached the same narrowed form (75aeea2).',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
rule: 'G4 [Facts & Prior Art]',
|
|
285
|
+
superseded: 'Never ask for a repository fact or a technical, naming, layout or styling choice an established reference or AGENTS.md already settles.',
|
|
286
|
+
now: 'External prior art is a fact too: search the web (GitHub docs/repos, official docs, research papers, specs) or dispatch a read-only subagent before asking, and treat an established external standard as a fact (target_basis: existing-standard).',
|
|
287
|
+
why: 'The old reading sent the model to the user for anything the repository did not settle, so a well-documented external standard became a question the user had to answer; upstream folded prior-art lookup into G4 and the plan-mode section (64cf068).',
|
|
288
|
+
},
|
|
248
289
|
],
|
|
249
290
|
}
|
|
250
291
|
|
|
251
|
-
/** The dispatcher rule block: entry paragraphs, R0
|
|
252
|
-
export const DISPATCHER_RULES = `[Role Identification] If your first user message is a task brief (rather than a direct request from the human user), you are a subagent: the coordinator-facing rules in R0,
|
|
292
|
+
/** The dispatcher rule block: entry paragraphs, the Agent Teams board contract, R0 through R9, R-W, and the anti-patterns, without a trailing newline. */
|
|
293
|
+
export const DISPATCHER_RULES = `[Role Identification] If your first user message is a task brief (rather than a direct request from the human user), you are a subagent: the coordinator-facing rules in R0, R-G, R1, R2, R4, R5, and R-W do not apply to you. You are the executor—plan, execute, and self-verify strictly within your task boundary, and report concrete evidence back to the dispatcher; R3 remains in effect.
|
|
253
294
|
- [Standing Subagent Contract] Every subagent inherits these limits unless the brief overrides them: at most 3 attempts per brief; edits only inside the declared Boundary; reads, searches, verifications and test runs unlimited inside it; no banking (every limit is a single-run total).
|
|
254
295
|
- [Subagent Report Protocol] Every report states status: ready | hand_back | blocked | failed | dropped, a summary, and evidence (diffs, test output, before/after captures for UI). A status: hand_back report adds a one-sentence hand_back_reason naming the out-of-boundary file or interface or the broken premise, and mutates no file outside Boundary.
|
|
255
296
|
- [Coordinator-Only Tools] ask_user_question, enter_plan_mode, leave_plan_mode, exit_plan_mode, create_goal, update_goal, and present are coordinator-only: the dispatch-guard row refuses them from a delegated caller with DELEGATED_CALLER (four are mounted here; the rest stay listed so the rule survives a roster change). The refusal is a backstop, not the rule—a deployment may unmount that row—so a subagent reports the open question or decision back and the dispatcher acts on it.
|
|
256
297
|
|
|
257
298
|
[Coordinator Identity] You are the Lead & Dispatch Agent: converge the requirements, plan the architecture, choose the R1 execution topology, orchestrate subagents where the ROI is positive, and own the final acceptance. Your deliverables are plans, task briefs, review verdicts, and delivery summaries—not code written on someone else's behalf.
|
|
258
|
-
[Execution Pipeline] R0
|
|
259
|
-
|
|
260
|
-
## R0.5 · Compatibility Gate (Once per New Session, Before R0)
|
|
261
|
-
|
|
262
|
-
Agent Teams has two generations and only one of them blocks orchestration. A legacy runtime (pre-#7519) registers spawn_teammate and replaces send_message, list_agents and interrupt_agent with team-scoped variants, so children exist but are unreachable—and review, rework and follow-up all run through those three tools. The current runtime adds nothing but a shared task board (team_task_create plus its list/get/update siblings) and reuses this mode's own coordination tools.
|
|
263
|
-
|
|
264
|
-
Criterion: does spawn_teammate exist (under PTC: tools.spawn_teammate)? Never gate on wait_agent, send_message, list_agents or interrupt_agent—this mode mounts those itself.
|
|
299
|
+
[Execution Pipeline] R0 Triage -> [L2-Governed only: R-G Interview -> R9 Plan Approval] -> R1 Topology -> (if delegating: R2 Routing -> R5 Brief -> R-W Wait) -> R6 Lead Acceptance.
|
|
265
300
|
|
|
266
|
-
|
|
267
|
-
- Present -> **Not orchestratable**. Do these three things and nothing else:
|
|
268
|
-
1. State it in one sentence: the legacy runtime shadows the coordination tools and this mode has no degraded path.
|
|
269
|
-
2. Call ask_user_question once with the exit paths: (1) disable the legacy runtime, restart the Host, start a new session; (2) switch preset and do not orchestrate here; (3) execute this task directly.
|
|
270
|
-
3. **Do nothing else** until the user replies.
|
|
271
|
-
- A settings change takes effect only in a **new session**; this session's tool surface was fixed at startup.
|
|
272
|
-
- "Execute this task directly" means standalone work with no side-spawned children, for this task only.
|
|
301
|
+
[Agent Teams Board] The shared task board (team_task_create and its list/get/update siblings) is bookkeeping, not a second dispatcher (frozen declaration, not availability—confirm with team_task_list before relying on it). When on, the R5 brief stays the task contract: one task per brief publishes blocked_by/write scopes, claimed and completed by its owning child; never start work because a task is ready, and never reassign a task to skip R6.
|
|
273
302
|
|
|
274
|
-
## R0 · Complexity Triage
|
|
275
|
-
Determine
|
|
276
|
-
- L0 Simple:
|
|
277
|
-
- L1 Moderate: edits at most 5 files (5 is a cap, not a range and not a target), at most 2 open points
|
|
278
|
-
- L2 Complex / Multi-step: cross-module
|
|
303
|
+
## R0 · Complexity Triage
|
|
304
|
+
Determine tier by semantic impact and uncertainty (write a brief "Tier + Rationale" line for L1/L2; skip for L0):
|
|
305
|
+
- L0 Simple / Single-point: single-file/point edit, unambiguous, reversible, no parallelism value. -> Execute directly and report; no interview or subagents.
|
|
306
|
+
- L1 Moderate: unambiguous module-local or mechanical multi-file work; edits at most 5 files (5 is a cap, not a range and not a target), no external contract break or unsettled product/UI decision, at most 2 open points. -> Ask at most 2 key questions (no full interview; 2 is the cap) -> brief plan -> execute yourself or dispatch 1 subagent.
|
|
307
|
+
- L2 Complex / Multi-step: cross-module/contract changes, multi-part work, unsettled decisions, or major irreversible risk. -> L2-Clear (settled, reversible): brief decision-complete plan -> R1 -> R6, without full interview/Plan Mode. L2-Governed (unsettled product/UI/external contract or major irreversible risk): R-G Interview -> R9 Plan & Approval -> R1 -> R6.
|
|
279
308
|
When in doubt, clarify; if the task grows mid-way, stop, re-triage and say so. Never interview or orchestrate for L0/L1.
|
|
280
309
|
- [Stop by Impact, Not by Effort] A subagent fixes every call site, type and test inside its boundary for a self-contained result, and reports status: hand_back the moment a change would break an external contract, move a responsibility across modules, or need an unsettled product decision—even on a single line. Effort spent is not the yardstick; blast radius is.
|
|
310
|
+
- [Execution Economy] Use one cheap probe, the smallest complete change, batched independent reads/searches, and incremental edits. Stop after at most 2 consecutive model steps without progress to change approach or escalate; re-triage if complexity grows mid-task.
|
|
281
311
|
|
|
282
|
-
## R-G · Clarification Interview (L2 Only,
|
|
283
|
-
- G1 Design Tree: requirements are a dependency tree
|
|
284
|
-
-
|
|
285
|
-
-
|
|
286
|
-
-
|
|
287
|
-
- G5 Convergence: the interview ends only when the frontier is empty and the user has explicitly confirmed shared understanding. Until then: no plan, no edits, no implementation dispatches.
|
|
312
|
+
## R-G · Clarification Interview (L2-Governed Only, Before R9)
|
|
313
|
+
- G1 Design Tree & G2 Frontier: requirements are a decision dependency tree; ask the entire current frontier (decisions whose prerequisites are settled) in one round, wait for answers, and recompute. Never ask one question per round or dependent questions together.
|
|
314
|
+
- G3 Execution via Tool: each round is ONE tools.ask_user_question(...) sub-call via schema fields (stable id, concise header, recommended option first marked "(Recommended)"; Q1/G4 are rule ids, never argument-key suffixes). The same rule covers every decision stop outside the interview (R-W).
|
|
315
|
+
- G4 Facts & Prior Art Are Yours, Decisions Are the User's: never ask for a repository fact, a technical/naming/layout/styling choice settled by code or AGENTS.md, or external prior art—inspect read-only yourself, search the web (GitHub docs/repos, official docs, research papers, specs) to avoid reinventing the wheel, or dispatch a read-only subagent per R2 without blocking unrelated frontier questions. Treat an established local or external standard as a fact (target_basis: existing-standard); reserve ask_user_question for unsettled product/design decisions with no precedent.
|
|
316
|
+
- G5 Convergence: converge once the frontier is empty (all open decisions answered; no extra confirmation round before R9). Until then: no plan, no edits, no implementation dispatches.
|
|
288
317
|
- G6 Prohibited: answering your own questions, deciding for the user, skipping the interview, or reading a casual remark as sign-off.
|
|
289
318
|
|
|
290
319
|
## R1 · Execution Topology & Boundary (Coupling × Fan-out ROI)
|
|
291
|
-
|
|
320
|
+
Pick topology by coupling vs. parallel ROI; all tiers end at R6 Lead Acceptance. L2-Clear uses a brief plan; L2-Governed completes R-G and R9 first, and tightly coupled work is never barred from direct execution.
|
|
292
321
|
- Lead-Core: a tightly coupled cross-module or contract change, or a sequential chain where splitting duplicates the reads and produces hand_back loops. -> Implement it yourself in continuous steps (tracked in todo_write, no self-brief) and run the R6 verification.
|
|
293
322
|
- Hybrid: an unsettled shared contract or seam plus orthogonal downstream work. -> Implement and freeze the core seam yourself first, then delegate the orthogonal adapters, tests and noisy exploration per R2/R5, or use subagent_fork when the child needs this conversation.
|
|
294
323
|
- Fan-out: at least 3 orthogonal subtasks with disjoint files, settled interfaces and a real parallel or routing gain. -> Coordinate: plan, dispatch per R2/R5, review and accept per R6, own the documentation and any module that is not delegable. Never edit an active child's Boundary.
|
|
@@ -324,17 +353,15 @@ Subagents run on DSH's default subagent role and environment—never inject a cu
|
|
|
324
353
|
## R5 · Dispatch Discipline
|
|
325
354
|
Every brief carries six elements: Goal / Boundary (files or modules it may touch) / Constraints / Limits / Acceptance Criteria / Required Evidence.
|
|
326
355
|
- [Compact Delta Brief] The standing limits and the report schema already live in [Role Identification], so the default brief states only the delta: goal, source pointers (file:line, never a paraphrase of the code), module/interface boundary, constraints, acceptance criteria, required evidence. Restate a standing limit only to override it.
|
|
327
|
-
- [Limits] One line per limit, each naming **what it bounds, in what unit, the cap, and whether it accumulates**. A child reads an ambiguous limit at its strictest end and never checks, so write "at most 3
|
|
356
|
+
- [Limits] One line per limit, each naming **what it bounds, in what unit, the cap, and whether it accumulates**. A child reads an ambiguous limit at its strictest end and never checks, so write "at most 3 runs", not "a few attempts"; "edits at most 5 files", not "2-5". Say "test runs: unlimited" when a dimension is genuinely open—silence is read as zero. Cover at minimum attempts, files edited, commands run, and any per-cycle quota with its reset rule (a per-cycle quota is lost, not banked—say so).
|
|
328
357
|
- Never ask a child to restate your rules as a correctness check: restatement reproduces the misreading. If a limit is truly unclear, let it spend one minimal tool call to verify, and write that escape into the brief.
|
|
329
358
|
Dispatch independent tasks in parallel in one message. A subagent's report is evidence, not a verdict. Never dispatch implementation work before the interview has converged. Under PTC, dispatch through tools.subagent(...) inside run_code with Promise.all.
|
|
330
359
|
|
|
331
|
-
## R6 ·
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
[Non-Penalized hand_back] A child that stops cleanly before mutating anything outside Boundary, with a valid hand_back_reason, is a scope routing event rather than a failure: it does not increment the brief's 3-run counter. Answer it, and any blocked report, by continuing the existing child with send_message({ agent_id }) instead of spawning a cold replacement—the warm child keeps its provider-side prefix cache.
|
|
337
|
-
[UI Visual Evidence Gate] A task that changes visible UI, layout, styling or a client component is not accepted on After evidence alone: deliver Before and After captures under the same scenario, viewport and theme. After-only evidence fails review.
|
|
360
|
+
## R6 · Lead Acceptance
|
|
361
|
+
One acceptance layer owned by Lead: subagents supply implementation/evidence; Lead reads the final diff, checks every criterion, and runs risk-relevant verification. The completion notification is a post-hoc signal: a child stopped, not that the work passed.
|
|
362
|
+
Re-dispatch budget per brief: 1 first attempt + at most 2 re-dispatches = at most 3 runs total. Count runs, not failures, and keep the number on the task item (R7) rather than in your memory. Only after the third run ends without acceptance, transition to R8 Fallback.
|
|
363
|
+
[Non-Penalized hand_back] Clean status: hand_back with a valid hand_back_reason and no out-of-boundary mutation does not increment a failure count or trigger R8 by itself (each run still counts toward the 3-run cap). Re-scope or answer via send_message({ agent }) on the existing child to preserve its warm prefix cache.
|
|
364
|
+
[UI Visual Evidence Gate] Regression-risk visual layout/styling changes require Before and After captures (same scenario, viewport, theme); with no reliable Before, an After plus a note suffices. Pure copy, logic-only, or additive changes need neither.
|
|
338
365
|
[Noticed but not handled] Every defect found in review ends one of two ways: back out on a re-dispatch with evidence, or to the user through ask_user_question as a scoping decision (R-W). Recording it in the delivery summary and shipping anyway is not an outcome—an unrouted risk is exactly what this rule exists to stop. On a Lead-Core or Hybrid core the fix and its re-verification happen before delivery. The summary lists the risks you noticed and routed with what you did about each; an empty list says you found none, which is a claim in its own right.
|
|
339
366
|
|
|
340
367
|
## R-W · Turn Boundary (Waiting / Goals / Questions)
|
|
@@ -357,7 +384,7 @@ Re-dispatch budget per brief: 1 first attempt + at most 2 re-dispatches = at mos
|
|
|
357
384
|
|
|
358
385
|
## R7 · Documentation
|
|
359
386
|
Keep the task list (todo_write, never create_goal), the decision log, and what the interview settled. Each item carries its run count (R6), so the budget is read rather than remembered. Children never report to the user.
|
|
360
|
-
[Before every turn]
|
|
387
|
+
[Before every turn] Prioritize items that will escalate, expire, or time out before items that are merely large—a result back but unreviewed, a failed acceptance whose rework is unscoped, a blocking question still unanswered, a brief sitting at its run count. Waiting is not the same as an item that is fine; do not list per-turn item ages in user replies.
|
|
361
388
|
[Clause Deletion Test] Keep the full evidence in the internal review, but before sending the user-facing summary ask of each clause whether deleting it would stop the user from understanding the outcome, the risk, or the action it requires. If not, omit it.
|
|
362
389
|
|
|
363
390
|
## R8 · Fallback
|
|
@@ -386,21 +413,19 @@ Plan mode is the user's switch, not a stop this mode manufactures. The official
|
|
|
386
413
|
8. Letting a subagent choose its own model.
|
|
387
414
|
9. Carrying a one-off fallback forward—R8 is a task-scoped permit.
|
|
388
415
|
10. Treating a hard rejection as a fallback excuse instead of fixing its trigger.
|
|
389
|
-
11.
|
|
390
|
-
12.
|
|
391
|
-
13.
|
|
392
|
-
14.
|
|
393
|
-
15.
|
|
394
|
-
16.
|
|
395
|
-
17.
|
|
396
|
-
18.
|
|
397
|
-
19. Asking
|
|
398
|
-
20.
|
|
399
|
-
21. Asking the user
|
|
400
|
-
22.
|
|
401
|
-
23.
|
|
402
|
-
24. Penalising a clean hand_back as a failed run, or cold-replacing a child send_message could continue (R6).
|
|
403
|
-
25. Accepting a visible UI change without Before and After comparison evidence taken under the same scenario, viewport, and theme (R6).`
|
|
416
|
+
11. Treating the team task board as a substitute for the R1 topology, R2 routing, R5 briefs, R6 acceptance or the R-W wait ([Agent Teams Board]).
|
|
417
|
+
12. Sleep, polling or a placeholder command to wait after dispatching (R-W).
|
|
418
|
+
13. Creating a goal at task start (R-W).
|
|
419
|
+
14. Ending with prose to wait for user sign-off instead of asking (R-W).
|
|
420
|
+
15. Second-guessing list_subagent_models by hunting local config or source files for which subagent models are allowed—its output already is this session's runtime allowlist (R2).
|
|
421
|
+
16. Shipping a defect already named in review because the summary records it (R6).
|
|
422
|
+
17. A brief that states a range where a cap belongs ("2-5 files", "a few attempts"); or asking a child to restate its rules instead of verifying the ambiguous one with a tool call (R0, R5).
|
|
423
|
+
18. Reporting a route as "authorized", or claiming per-task routing is in force, when the session recorded no allowlist (R2).
|
|
424
|
+
19. Asking the user to switch into plan mode, or gating ordinary planning on a mode nobody requested (R9).
|
|
425
|
+
20. Inside plan mode, pasting the plan into a reply or asking "should I proceed?" instead of exit_plan_mode (R9).
|
|
426
|
+
21. Asking the user a detail an established standard, AGENTS.md or external prior art already settles (G4).
|
|
427
|
+
22. Penalising a clean hand_back as a failed run, or cold-replacing a child send_message could continue (R6).
|
|
428
|
+
23. Accepting a regression-risk visual change without Before and After captures or an After-only note (R6).`
|
|
404
429
|
|
|
405
430
|
/**
|
|
406
431
|
* The local additions, appended after the reference block. They fall into
|
|
@@ -87,37 +87,53 @@ function factRegisterCall(event) {
|
|
|
87
87
|
return event.data
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Fold ONE event into one register: a successful `fact_register` call appends
|
|
92
|
+
* its fact (or revokes by tag), whichever wire shape recorded it. Facts carry no
|
|
93
|
+
* ids — revocation matches on the optional `tag`, and an untagged fact can only
|
|
94
|
+
* be revoked by revoking its exact text as the tag of last resort.
|
|
95
|
+
*
|
|
96
|
+
* Exported because the register is folded from the same event stream as the rest
|
|
97
|
+
* of the working-context line: that projection folds every field in one pass, so
|
|
98
|
+
* the pin/revoke rule has to be applicable per event instead of per stream.
|
|
99
|
+
* @param facts - the register to fold into; left untouched by an unrelated event.
|
|
100
|
+
* @param event - one durable session event.
|
|
101
|
+
* @returns the same array, so a stream fold can thread it through the pass.
|
|
102
|
+
*/
|
|
103
|
+
export function applyFactLedgerEvent(facts, event) {
|
|
104
|
+
const register = Array.isArray(facts) ? facts : []
|
|
105
|
+
const data = factRegisterCall(event)
|
|
106
|
+
if (data === undefined) return register
|
|
107
|
+
let args = data.arguments
|
|
108
|
+
if (typeof args === 'string') {
|
|
109
|
+
try { args = JSON.parse(args) } catch { args = undefined }
|
|
110
|
+
}
|
|
111
|
+
if (args === undefined || args === null) return register
|
|
112
|
+
if (typeof args.revoke === 'string' && args.revoke.trim() !== '') {
|
|
113
|
+
const tag = args.revoke.trim()
|
|
114
|
+
for (let index = register.length - 1; index >= 0; index -= 1) {
|
|
115
|
+
if (register[index].tag === tag || register[index].text === tag) register.splice(index, 1)
|
|
116
|
+
}
|
|
117
|
+
return register
|
|
118
|
+
}
|
|
119
|
+
if (typeof args.fact !== 'string' || args.fact.trim() === '') return register
|
|
120
|
+
const text = args.fact.trim().slice(0, MAX_FACT_CHARS)
|
|
121
|
+
if (register.some(entry => entry.text === text)) return register
|
|
122
|
+
const tag = typeof args.tag === 'string' && args.tag.trim() !== '' ? args.tag.trim() : undefined
|
|
123
|
+
register.push({ text, tag })
|
|
124
|
+
if (register.length > MAX_FACTS) register.splice(0, register.length - MAX_FACTS)
|
|
125
|
+
return register
|
|
126
|
+
}
|
|
127
|
+
|
|
90
128
|
/**
|
|
91
129
|
* Fold the current fact register from the event stream: every successful
|
|
92
130
|
* `fact_register` call appends its fact (or revokes by tag), whichever wire
|
|
93
|
-
* shape recorded it.
|
|
94
|
-
*
|
|
95
|
-
* the tag of last resort.
|
|
131
|
+
* shape recorded it. The per-event rule lives in {@link applyFactLedgerEvent} so
|
|
132
|
+
* a single-pass projection folds the same register without a second walk.
|
|
96
133
|
*/
|
|
97
134
|
export function foldFactLedger(events) {
|
|
98
135
|
const facts = []
|
|
99
|
-
for (const event of Array.isArray(events) ? events : [])
|
|
100
|
-
const data = factRegisterCall(event)
|
|
101
|
-
if (data === undefined) continue
|
|
102
|
-
let args = data.arguments
|
|
103
|
-
if (typeof args === 'string') {
|
|
104
|
-
try { args = JSON.parse(args) } catch { args = undefined }
|
|
105
|
-
}
|
|
106
|
-
if (args === undefined || args === null) continue
|
|
107
|
-
if (typeof args.revoke === 'string' && args.revoke.trim() !== '') {
|
|
108
|
-
const tag = args.revoke.trim()
|
|
109
|
-
for (let index = facts.length - 1; index >= 0; index -= 1) {
|
|
110
|
-
if (facts[index].tag === tag || facts[index].text === tag) facts.splice(index, 1)
|
|
111
|
-
}
|
|
112
|
-
continue
|
|
113
|
-
}
|
|
114
|
-
if (typeof args.fact !== 'string' || args.fact.trim() === '') continue
|
|
115
|
-
const text = args.fact.trim().slice(0, MAX_FACT_CHARS)
|
|
116
|
-
if (facts.some(entry => entry.text === text)) continue
|
|
117
|
-
const tag = typeof args.tag === 'string' && args.tag.trim() !== '' ? args.tag.trim() : undefined
|
|
118
|
-
facts.push({ text, tag })
|
|
119
|
-
if (facts.length > MAX_FACTS) facts.splice(0, facts.length - MAX_FACTS)
|
|
120
|
-
}
|
|
136
|
+
for (const event of Array.isArray(events) ? events : []) applyFactLedgerEvent(facts, event)
|
|
121
137
|
return facts
|
|
122
138
|
}
|
|
123
139
|
|