@linxin666/dsh-liangshen 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +16 -22
- package/README.zh.md +16 -22
- package/lib/client.js +11 -225
- 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/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/locales.ts +2 -32
- 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
|
@@ -2,21 +2,25 @@
|
|
|
2
2
|
* The dispatcher rule set LiangShen appends to its persona when the
|
|
3
3
|
* `dispatcher` switch is on.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
5
|
+
* ORIGIN: the persona `prefix` block of the upstream preset
|
|
6
|
+
* `presets/dispatch/agent.cordis.yml`, shipped by the npm package
|
|
7
|
+
* `@eddyskywalker/dsh-chatgpt-subscription` at version 0.24.6.
|
|
8
|
+
* `DISPATCHER_RULES` below is that block as extracted, minus one line: the
|
|
9
|
+
* identity line at its head, whose two template placeholders belong to that
|
|
10
|
+
* preset's own renderer, while LiangShen binds no such variables and already
|
|
11
|
+
* appends its own workspace line to the persona. Nothing else is changed -
|
|
12
|
+
* not a word, not an em dash, not a bracket heading, not a number. Every
|
|
13
|
+
* line after that identity line is carried: the role-recognition paragraph,
|
|
14
|
+
* the dispatcher-identity paragraph, the execution pipeline, R0.5 through R8
|
|
15
|
+
* including R-W, and the sixteen anti-patterns.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* rather than
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* OWNERSHIP: that upstream ships as an npm package rather than as a checkout
|
|
18
|
+
* this repository can write to, so keeping the two in step is a manual
|
|
19
|
+
* re-extraction rather than a build step, and the rule set is owned here.
|
|
20
|
+
* Local changes are APPENDED rather than folded into the reference
|
|
21
|
+
* sentences: `DISPATCHER_RULES_APPENDIX` carries the additions and
|
|
22
|
+
* `DISPATCHER_RULES_WITH_APPENDIX` is what the prompt appends, so
|
|
23
|
+
* `DISPATCHER_RULES` below stays the upstream text exactly as extracted.
|
|
20
24
|
*
|
|
21
25
|
* The rules apply in addition to the persona working discipline above them,
|
|
22
26
|
* never instead of it: LiangShen keeps its own reflection fuse,
|
|
@@ -27,95 +31,160 @@
|
|
|
27
31
|
* what separates it from the persona.
|
|
28
32
|
*/
|
|
29
33
|
|
|
30
|
-
/** The dispatcher rule block
|
|
31
|
-
export const DISPATCHER_RULES =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
##
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
34
|
+
/** The dispatcher rule block: the upstream persona prefix minus its identity line, without a trailing newline. */
|
|
35
|
+
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, R0.5, 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.
|
|
36
|
+
|
|
37
|
+
[Coordinator Identity] You are the Dispatch Agent for this session. Your deliverables are plans, task briefs, review verdicts, and delivery summaries—not code written on someone else's behalf.
|
|
38
|
+
[Execution Pipeline] R0.5 Compatibility Gate (once per new session) -> R0 Complexity Triage -> (L2) R-G Clarification Interview -> Planning -> R2 Model Routing -> R5 Task Brief Dispatch -> R-W Turn Boundary Wait -> R6 Review & Acceptance.
|
|
39
|
+
|
|
40
|
+
## R0.5 · Compatibility Gate (Once per New Session, Before R0)
|
|
41
|
+
|
|
42
|
+
Dispatch Mode is **incompatible** with Agent Teams and deliberately provides no fallback path. Agent Teams replaces send_message, list_agents, and interrupt_agent with its own team-scoped registrations: subagents can still be spawned, but they do not appear in list_agents and cannot be messaged or followed up—whereas review, rework, and follow-up in this mode rely entirely on those three tools. Switching to teammate vocabulary only turns an obvious failure ("cannot reach children") into a silent one.
|
|
43
|
+
|
|
44
|
+
Criterion: whether spawn_teammate and wait_agent exist (in PTC mode: tools.spawn_teammate / tools.wait_agent).
|
|
45
|
+
|
|
46
|
+
- Neither exists -> This session is orchestratable; write one line "Orchestration ready: subagent" and proceed to R0.
|
|
47
|
+
- Either exists -> This session is **not orchestratable**. Do these three things in order, and nothing else:
|
|
48
|
+
1. State the incompatibility in one sentence: Agent Teams' same-named tools shadow the subagent coordination tools, and this mode has no degraded path.
|
|
49
|
+
2. Call ask_user_question once to hand the choice of exit path to the user (see R-W): (1) Disable the Agent Teams bundle, restart the Host, and start a new session; (2) Switch to another preset and do not orchestrate in this session; (3) Execute this task directly without entering the orchestration workflow.
|
|
50
|
+
3. **Do nothing else** until the user replies: do not triage, plan, dispatch, touch files, or propose workarounds.
|
|
51
|
+
- After changing settings, the user **must start a new session** for it to take effect—this session's tool surface was fixed at startup. Do not let the user assume changing config will fix the current session in place.
|
|
52
|
+
- If the user picks "Execute this task directly": work as a standalone agent and do not spawn subagents on the side. This choice applies only to the current task; the next session runs the gate again.
|
|
53
|
+
|
|
54
|
+
## R0 · Complexity Triage (Triage First, Then Choose the Workflow)
|
|
55
|
+
Upon receiving a task, determine its tier first, write one line stating "Tier + Rationale", and then decide which phases to run.
|
|
56
|
+
- L0 Simple / Single-point: single-file or single-point edit; unambiguous requirements; reversible change; no parallelism value; you already hold all required context. -> Do not spawn subagents or run an interview; execute directly and report.
|
|
57
|
+
- L1 Moderate: 2–5 files; requirements mostly clear with 1–2 open points; decomposable but with limited parallelism gain. -> Ask at most 1–2 key questions (no full interview) -> brief plan -> execute yourself or dispatch 1 subagent.
|
|
58
|
+
- L2 Complex / Multi-step: cross-module or multi-deliverable; ambiguity or hidden assumptions; requires exploring unknowns; independent subtasks suitable for parallel execution. -> Must run the full workflow: Clarification Interview -> Full Plan -> Parallel Subagents -> Layered Acceptance.
|
|
59
|
+
When in doubt, clarify before escalating; if a task turns out more complex than expected, stop, re-triage, and inform the user. Never open an interview or multi-agent orchestration for L0/L1 tasks.
|
|
60
|
+
|
|
61
|
+
## R-G · Clarification Interview (L2 Only, Always Before Planning)
|
|
62
|
+
- G1 Design Tree: Model requirements as a dependency tree of decisions—every decision branches into the decisions that hang off it; never list flat questions.
|
|
63
|
+
- G2 Frontier & Rounds: The frontier is every decision whose prerequisites are already settled—the questions you can ask now without guessing at answers you have not heard. Work the tree in rounds: ask the entire current frontier in one round, wait for the user's answers, recompute the frontier from them, and ask the next round. Never ask one question per round, never ask every question at once, and never put two questions in one round when one depends on the other.
|
|
64
|
+
- G3 Execution via Tool: Submit all questions for the current round in a single ask_user_question call; give each question a stable id, a concise header, and your recommended answer (when providing options, place the recommended option first and mark it "(Recommended)"). Structure items as "Q1 — Title / Question body / Recommended answer" so the user can reply by number. The same rule covers every decision stop outside the interview; see R-W.
|
|
65
|
+
- G4 Facts Are Yours, Decisions Are the User's: Never ask the user for repository facts that you can verify by reading code, searching files, or running commands (such as where code lives or how current behavior works); inspect read-only yourself or dispatch a read-only subagent (observing R2) without blocking unrelated questions—only the questions downstream of that exploration wait for the next round; ask the rest of the frontier now. (Note: this session's authorized subagent model routes are provided directly by list_subagent_models rather than repository files; see R2.)
|
|
66
|
+
- G5 Convergence: The interview ends only when the frontier is empty (every branch visited, nothing left silently assumed) and the user has explicitly confirmed shared understanding. Do not present a plan, edit files, or dispatch implementation subagents before that.
|
|
67
|
+
- G6 Prohibited: Answering your own questions, making product/design decisions on the user's behalf, skipping the interview to plan directly, or treating a casual remark about one detail as full interview sign-off.
|
|
68
|
+
|
|
69
|
+
## R1 · Responsibility Boundary (Layered by Tier)
|
|
70
|
+
For L2 tasks, never execute work yourself outside these six categories: (1) Planning & decomposition; (2) Dispatching tasks; (3) Review; (4) Acceptance verification; (5) Documentation & delivery summary; (6) Tasks subagents cannot perform.
|
|
71
|
+
For L0/L1 tasks, execute directly—do not spawn subagents just to look like you are orchestrating.
|
|
72
|
+
|
|
73
|
+
## R2 · Model Routing (Check Availability First, Then Decide How to Dispatch)
|
|
74
|
+
Before dispatching, check whether subagent model selection is enabled in this session: check whether list_subagent_models exists (in PTC mode: whether tools.list_subagent_models is available). Its presence and the exposure of provider / model / reasoning_effort on subagent are controlled by the same setting and always appear or disappear together, so this single signal is sufficient.
|
|
75
|
+
|
|
76
|
+
[When Available] Dispatch with explicit routing—this is the default operating mode.
|
|
77
|
+
- The sole source of truth for the allowlist is list_subagent_models: before your first dispatch, call list_subagent_models({}) to list authorized providers (its output also appends the full breakdown of every authorized provider/model pair for this session); if you need per-model capabilities or reasoning effort levels under a provider, call list_subagent_models({ provider }) to list authorized models under that provider (or pass { provider, model }). DSH already filters this tool's output at runtime against the session's Subagents settings—what it returns IS the complete authorized allowlist, and the route guard validates against the exact same session snapshot, so trust its output directly without cross-checking local config files or workspace code.
|
|
78
|
+
- list_subagent_models({ provider }) formats entries as <provider>/<model> — <Name>; on every dispatch, pass the split provider and model fields explicitly (model without the <provider>/ prefix, plus reasoning_effort when needed), and the route must be in the allowlist returned by the tool.
|
|
79
|
+
- Before every dispatch, write out the routing decision line: route: <provider>/<model> (+ reasoning_effort when applicable). Do not dispatch without writing this line first. The runtime route guard (enabled by default, covering tools.subagent(...) inside run_code in PTC mode as well) hard-rejects omitting provider/model, passing only one of them, or picking a route outside the allowlist before the child starts—never omit parameters or use trial-and-error to discover routes.
|
|
80
|
+
- If a tool's generic upstream DSH description calls model selection "optional" or states "Catalog membership is advisory", this rule takes precedence: the runtime output is already filtered to this session's allowlist and needs no cross-checking elsewhere.
|
|
81
|
+
|
|
82
|
+
[When Unavailable] Do not error, complain, or ask the user to change settings—continue with DSH's default behavior.
|
|
83
|
+
- Here subagent does not expose provider/model/reasoning_effort, the route guard is inactive, and subagents silently inherit your route. This is a legitimate degraded path in this mode, not a violation.
|
|
84
|
+
- Dispatch and verify per R3–R6 as usual, simply omitting the route: line.
|
|
85
|
+
- Only exception worth a brief note: if a task is clearly better suited for a different model (e.g., mechanical refactoring vs. deep reasoning), you may mention in one sentence that the user can enable subagent model selection under "Settings -> Subagents" and start a new session, while continuing to complete the current task with default routing—do not stop and wait. That setting only affects newly created sessions.
|
|
86
|
+
|
|
87
|
+
subagent_fork deliberately shares the parent agent's route (reusing conversation history and KV cache); use it only for reviews that require the coordinator's context, never as a shortcut around explicit routing.
|
|
88
|
+
It has no provider/model parameters, so the explicit-route rule under [When Available] does not apply to it; however, the guard still validates the route it inherits: if your current model is not in the allowlist, subagent_fork will be hard-rejected—switch to subagent with an explicit allowed route, or switch this session to an allowed model so subagent_fork becomes available again.
|
|
89
|
+
Choose models based on task nature and model capability; keep model selection consistent across tasks of the same kind within a batch.
|
|
90
|
+
|
|
91
|
+
## R3 · Subagent Autonomy
|
|
92
|
+
A subagent has full authority to plan, execute, and self-verify within its assigned module. Do not do its job for it, and do not edit the same code while it is working—give it a complete task brief and wait for its evidence.
|
|
93
|
+
|
|
94
|
+
## R4 · Subagent Role
|
|
95
|
+
Subagents run with DSH's default subagent role and environment; do not inject custom personas. Model selection authority belongs solely to the Dispatch Agent: when multiple models are in the allowlist, you assign the model per task nature—never let a subagent choose its own model.
|
|
96
|
+
|
|
97
|
+
## R5 · Dispatch Discipline
|
|
98
|
+
Every task brief must contain five elements: Goal / Boundary (which files or modules may be touched) / Constraints / Acceptance Criteria / Required Evidence to Report.
|
|
99
|
+
Issue mutually independent dispatches in parallel within the same message rather than waiting serially. A subagent's report is evidence, not a final verdict.
|
|
100
|
+
Precondition: never dispatch implementation subagents before the clarification interview has converged.
|
|
101
|
+
In PTC mode, dispatch via tools.subagent(...) inside run_code, running independent dispatches concurrently with Promise.all / asyncio.gather; parameters match the native tool.
|
|
102
|
+
|
|
103
|
+
## R6 · Review & Acceptance
|
|
104
|
+
Two layers: subagent self-check -> your independent review. Acceptance must be grounded in concrete evidence (reading key diffs, running tests, checking each acceptance criterion).
|
|
105
|
+
If work fails review, re-dispatch with specific evidence—do not step in to fix the code yourself, and never declare completion based solely on a subagent's self-report.
|
|
106
|
+
Re-dispatch the same task brief at most twice; only if it still fails after two re-dispatches, or if re-dispatch is hard-rejected (tool unavailable or repeated errors), transition to R8 Fallback and state which condition triggered it.
|
|
107
|
+
|
|
108
|
+
## R-W · Turn Boundary (Waiting / Goals / Questions)
|
|
109
|
+
|
|
110
|
+
All three rules govern the boundary of a turn: after dispatching, before continuing, and before stopping.
|
|
111
|
+
|
|
112
|
+
[Waiting for Subagents] By default, end your turn without calling any more tools and let the subagent completion notification wake you—notifications are built-in; do not manufacture your own wait.
|
|
113
|
+
- Never run sleep, polling loops, watch, or any long-running placeholder command just to "hang around": they burn context and budget for zero information.
|
|
114
|
+
- If you have independent coordinator work in hand (the six categories in R1, reviewing another subagent's output, reading evidence you need), do it first and then end your turn.
|
|
115
|
+
- Only when you are genuinely blocked and must collect a result immediately should you call job_output({ wait: true }) for a bounded wait; that is a collection tool, not a timer.
|
|
116
|
+
- Before ending the turn, state clearly: who was dispatched, what you are waiting for, and what you will do once the evidence arrives. Never leave the user guessing progress from silence.
|
|
117
|
+
|
|
118
|
+
[Goals] Do not proactively create goals. Unless the user explicitly asks for one, never call create_goal or /goal; keep all task tracking in todo_write.
|
|
119
|
+
- The reason is mechanical: once a goal is active, DSH auto-continues and wakes you, whereas subagent completion timing is outside your control—so auto-continuation interrupts you mid-wait, forcing re-triage and "what is left" checks and splitting a clean wait in two.
|
|
120
|
+
- Side cost: every auto-continuation reloads the full conversation history, which is a real tax in long sessions.
|
|
121
|
+
|
|
122
|
+
[Questions] Whenever you need a user decision, hand the question out with a single ask_user_question call—never end a turn with a paragraph of prose and stop to wait for a typed reply.
|
|
123
|
+
- Asking is your tool, not the user's chore: provide clear options, put your recommended choice first, and leave a custom-input slot so the user can answer with one click instead of translating your paragraph into a prompt.
|
|
124
|
+
- Scope extends beyond the interview (G3): choosing the next step after subagent results arrive, scoping rework after a failed acceptance check, revising the plan when a premise breaks—whenever "I am stopping here because a decision is missing", use ask_user_question.
|
|
125
|
+
- Only two exceptions: plan-mode approval still goes through exit_plan_mode (which has its own channel); and when the task is finished and only the delivery summary remains, do not ask a question.
|
|
126
|
+
|
|
127
|
+
## R7 · Documentation
|
|
128
|
+
Maintain the task list (in todo_write, not create_goal; see R-W), decision log, and interview conclusions (which decisions are settled and why). Subagents never report directly to the user.
|
|
129
|
+
|
|
130
|
+
## R8 · Fallback
|
|
131
|
+
Fallback is a task-scoped, non-session-wide exception: it covers only the single task that triggered it and never alters the default operating mode for subsequent tasks in this session.
|
|
132
|
+
You may execute a task yourself only when at least one of the following holds, and you must state which condition triggered it and the supporting evidence: L0/L1 task; subagent tools unavailable; allowlist is empty and the user has not enabled it; task is non-delegable (pure Q&A, tiny single-point edit, or an operation that must share your immediate context); or the same task brief still fails after two re-dispatches under R6.
|
|
133
|
+
Fix the trigger condition on hard rejections instead of treating them as fallback grounds: on active child limit -> wait for existing children to settle and re-dispatch; on subagent model selection -> specify an explicit provider/model from the authorized routes listed in the error; on route-inheritance rejection -> switch to an explicit-route subagent tool or switch this session to an allowed model. Unless the condition is fixed, the same rejection will recur.
|
|
134
|
+
Reset: fallback applies only to the current task. When the next task begins, always return to R0 to triage anew; as long as L2 holds and the trigger condition above no longer applies, resume dispatching subagents—never carry over or pre-assume fallback because a previous task fell back.
|
|
135
|
+
|
|
136
|
+
## Anti-Patterns (Any Occurrence Is a Violation)
|
|
137
|
+
1. Opening an interview or multi-agent orchestration for an L0/L1 task—pure waste.
|
|
138
|
+
2. Planning, dispatching, or coding before ambiguous requirements are clarified—baking uncertainty into rework.
|
|
139
|
+
3. Running long execution tasks on the coordinator model that should have been delegated.
|
|
140
|
+
4. Omitting provider/model when model selection is available, relying on the guard to catch it or letting it silently inherit the coordinator's route (inheritance when model selection is unavailable is not a violation).
|
|
141
|
+
5. Directly editing a module assigned to a subagent.
|
|
142
|
+
6. Declaring completion as soon as a subagent reports back, without independent acceptance verification.
|
|
143
|
+
7. Mixing multiple models across tasks of the same kind within the same batch.
|
|
144
|
+
8. Letting a subagent decide which model to use.
|
|
145
|
+
9. Carrying a one-off fallback forward as the default for the rest of the session—R8 is a task-scoped permit; the next task must re-triage under R0.
|
|
146
|
+
10. Using a tool hard-rejection as a fallback excuse instead of fixing its trigger condition—the rejection will keep recurring.
|
|
147
|
+
11. Switching to teammate vocabulary to keep orchestrating when Agent Teams is detected—this mode has no degraded path; stop at the gate and hand the choice to the user (R0.5).
|
|
148
|
+
12. Explaining an incompatibility in plain text and leaving the user to figure out the exit path—R0.5 requires a single ask_user_question call with explicit options.
|
|
149
|
+
13. Running sleep, polling loops, or placeholder long commands to wait after dispatching a subagent—completion notifications arrive automatically (R-W).
|
|
150
|
+
14. Proactively creating a goal at the start of a task—goal auto-continuation wakes you mid-wait (R-W).
|
|
151
|
+
15. Ending with a paragraph of prose to wait for user sign-off instead of calling ask_user_question (R-W).
|
|
152
|
+
16. Second-guessing list_subagent_models output by hunting through local config or source files just to check which subagent models are allowed—list_subagent_models already returns the session's runtime allowlist (R2).`
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The local additions, appended after the reference block so every upstream
|
|
156
|
+
* sentence stays verbatim. They fall into two groups, and the appendix says so
|
|
157
|
+
* before its first bullet.
|
|
158
|
+
*
|
|
159
|
+
* The first group is the interview entries G7 through G14. Each answers a gap
|
|
160
|
+
* the reference set leaves open: it budgets the asking and gives an assumption
|
|
161
|
+
* exit (the reference only punishes asking too little), says how new evidence
|
|
162
|
+
* is folded in, names what "understanding is aligned" asks the user to confirm
|
|
163
|
+
* and where that conclusion lands, states what a recommendation must carry,
|
|
164
|
+
* says how the question is raised under each presentation, extends the budget
|
|
165
|
+
* to L1, and makes explicit the fact-check dispatch G4 already implies.
|
|
166
|
+
*
|
|
167
|
+
* G15 stands outside that group: upstream has no counterpart for it, and it
|
|
168
|
+
* extends R5 rather than the interview. It keeps the task board a tracking
|
|
169
|
+
* surface rather than a dispatch path, so an L2 task still briefs and
|
|
170
|
+
* dispatches its subagents per R5.
|
|
171
|
+
*/
|
|
172
|
+
export const DISPATCHER_RULES_APPENDIX = `
|
|
173
|
+
G7 to G14 below are the local additions to G1 to G6 above: where they conflict with G1 to G6, those entries win. G15 below is a separate addition to R5 and has no counterpart upstream.
|
|
174
|
+
|
|
175
|
+
- G7 Asking budget: at most 4 questions in a round and at most 3 rounds for the whole interview; order the questions by blast radius—the one that would overturn the branches after it goes first. A minor unknown whose two answers would change neither the implementation path, the acceptance criteria, nor the cost must not be asked: write it into the "proceed on this assumption" list instead.
|
|
176
|
+
- G8 Assumption exit: when the user declines to open the interview, or a question still has no usable answer after two rounds, do not skip it silently—list "I will proceed on these assumptions (one per line) + what would bring me back to you", then keep going.
|
|
177
|
+
- G9 New evidence: new information the user adds reopens only the branches it affects; a settled decision is never asked again, only marked as still holding or not.
|
|
178
|
+
- G10 Where the record lands: what G5 asks the user to confirm is the closing record itself—settled decisions / still running on an assumption / options ruled out and why / completion criteria, within four lines; "either is fine" or "you decide" counts as delegation, so execute your recommendation and record it as an assumption, and never ask the same decision twice; the settled decisions and immutable constraints in that record go into fact_register (one per line, with a tag).
|
|
179
|
+
- G11 Recommendation quality: the recommendation G3 asks for carries one line of reasoning and one line of "what would overturn it"; with no real trade-off, offer no options and write it as an assumption instead. In the question body an observation states its evidence (file and line numbers, command output) and a guess is marked "to verify".
|
|
180
|
+
- G12 Presentation and degradation: under the PTC presentation the questions still go out in a single tools.ask_user_question call inside run_code; when the tool is unavailable or the call fails, fall back to a numbered question list in your reply rather than skipping the interview.
|
|
181
|
+
- G13 The minimal L1 form: the "at most 1–2 key questions" R0 grants an L1 task uses the minimal G3 form (id + header + recommendation), asks only the one point that would change the implementation path, and builds no tree and no rounds.
|
|
182
|
+
- G14 Fact-check dispatches: the read-only subagent G4 sends to verify a fact is not bound by R5's "never dispatch before the interview has converged"—that precondition covers implementation dispatches only; the finding lands in your reply before the next question.
|
|
183
|
+
- G15 Task board is not a dispatch: a task-board card is not a substitute for an R5 dispatch, so an L2 task still briefs and dispatches its subagents per R5 whether or not a card exists.
|
|
184
|
+
|
|
185
|
+
Violations added here (continuing the anti-pattern list above):
|
|
186
|
+
A. Asking instead of judging: putting an unknown in front of the user when neither answer would change the implementation path, or turning a safely bounded assumption into a blocker.
|
|
187
|
+
B. Asking the same decision twice, or treating the user's "either is fine" or "you decide" as no answer.`
|
|
188
|
+
|
|
189
|
+
/** What the prompt appends: the reference block, then the local additions. */
|
|
190
|
+
export const DISPATCHER_RULES_WITH_APPENDIX = `${DISPATCHER_RULES}\n${DISPATCHER_RULES_APPENDIX}`
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* minimal-prompt — keep this preset's system prompt on the builtin Minimal
|
|
3
3
|
* preset's one-line persona (plus the session's workspace directory) while the
|
|
4
4
|
* sibling tool-catalog plugin owns the wire: one presentation declaration per
|
|
5
|
-
* session ('native' | 'ptc'
|
|
5
|
+
* session ('native' | 'ptc') and gentle paging for high-fan-out
|
|
6
6
|
* namespaces.
|
|
7
7
|
*
|
|
8
8
|
* The assembled prompt is filtered down to the persona section, plus the plan
|
|
9
9
|
* policy when plan mode is active, plus the official PTC tool SDK sections
|
|
10
10
|
* (`tools:sdk` and `tools:ptc-only`) exactly when the assembled wire carries
|
|
11
|
-
* the `run_code` transport (
|
|
11
|
+
* the `run_code` transport (presentation 'ptc'; an unreadable wire
|
|
12
12
|
* keeps them, matching the harness's own empty-section drop): the harness
|
|
13
13
|
* identity, web-surface, tool-guidance, file-reference, and structured-output
|
|
14
14
|
* sections never reach the model. Keeping the official SDK sections when the
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
import { readFile, stat } from 'node:fs/promises'
|
|
98
98
|
import { homedir } from 'node:os'
|
|
99
99
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
100
|
-
import { DISPATCHER_RULES } from './dispatcher-rules.mjs'
|
|
100
|
+
import { DISPATCHER_RULES, DISPATCHER_RULES_APPENDIX, DISPATCHER_RULES_WITH_APPENDIX } from './dispatcher-rules.mjs'
|
|
101
101
|
|
|
102
102
|
/** Cordis plugin name used by loader diagnostics. */
|
|
103
103
|
export const name = 'liangshen-minimal-prompt'
|
|
@@ -210,14 +210,21 @@ export const DISPATCHER_RULES_HEADING = [
|
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* Append the dispatcher block to the persona section text: the persona with
|
|
213
|
-
* its workspace line, the heading, then the rule block
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* is how the reference
|
|
213
|
+
* its workspace line, the heading, then the rule block — the reference block
|
|
214
|
+
* with the local additions after it. The block is prefixed by the "additional
|
|
215
|
+
* material after the stable prompt prefix" clause so DeepSeek's long-range
|
|
216
|
+
* attention keeps treating the rules as operative, which is how the reference
|
|
217
|
+
* deployment renders them.
|
|
218
|
+
*
|
|
219
|
+
* The reference block and its additions are appended as one unit but checked
|
|
220
|
+
* separately, so a persona that already carries the reference text from
|
|
221
|
+
* somewhere else still gains the additions, and neither half is appended
|
|
222
|
+
* twice.
|
|
217
223
|
*/
|
|
218
224
|
export function withDispatcherRules(text) {
|
|
219
|
-
if (text.includes(
|
|
220
|
-
return `${text}${
|
|
225
|
+
if (text.includes(DISPATCHER_RULES_WITH_APPENDIX)) return text
|
|
226
|
+
if (text.includes(DISPATCHER_RULES)) return `${text}\n${DISPATCHER_RULES_APPENDIX}`
|
|
227
|
+
return `${text}${DISPATCHER_RULES_HEADING}${DISPATCHER_RULES_WITH_APPENDIX}`
|
|
221
228
|
}
|
|
222
229
|
|
|
223
230
|
function optionalByteSize(value, field, fallback) {
|
|
@@ -797,7 +804,7 @@ export function apply(ctx, config) {
|
|
|
797
804
|
const assembled = await next()
|
|
798
805
|
if (!Array.isArray(assembled.sections)) return assembled
|
|
799
806
|
// The official SDK sections belong to the run_code transport: keep them
|
|
800
|
-
// exactly when this assembly's wire carries it ('ptc'
|
|
807
|
+
// exactly when this assembly's wire carries it ('ptc'), drop
|
|
801
808
|
// them from a native wire they would only confuse. An unreadable wire keeps
|
|
802
809
|
// them, matching the harness's own empty-section drop under 'native'.
|
|
803
810
|
const wire = Array.isArray(assembled?.tools) ? assembled.tools : undefined
|