@oh-my-dsh/dsh-better-subagent 0.5.0 → 0.5.2
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.md +4 -4
- package/docs/DEVELOPMENT.md +4 -3
- package/package.json +1 -1
- package/src/client.js +397 -334
- package/src/config.js +17 -5
- package/src/prompt.js +6 -15
package/src/config.js
CHANGED
|
@@ -14,8 +14,13 @@
|
|
|
14
14
|
* `src/panel.js`),改完即时生效、不重挂。
|
|
15
15
|
*
|
|
16
16
|
* 可编辑范围(volatile,即 dsh-settings 投影出的行配置表单字段):
|
|
17
|
-
* `childExitGuard`、`tiers.fast`、`tiers.quality
|
|
18
|
-
* `subagents.global`、`subagents.codex.*`、`subagents.claude
|
|
17
|
+
* `childExitGuard`、`delegation.prompt`、`tiers.fast`、`tiers.quality`、
|
|
18
|
+
* `subagents.eng`、`subagents.global`、`subagents.codex.*`、`subagents.claude.*`、
|
|
19
|
+
* `trustedHosts`。
|
|
20
|
+
*
|
|
21
|
+
* `delegation.prompt` 只决定 `better-subagent:delegation` 提示词段是否渲染(默认
|
|
22
|
+
* 开启、对所有预设生效);`subagents.eng/global` 只管 CLI 后端路由与 CLI 目录段,
|
|
23
|
+
* 两者互不影响。
|
|
19
24
|
* 表单写入只能落在 volatile 路径上(dsh-settings 会拒绝其他路径)。
|
|
20
25
|
*
|
|
21
26
|
* 读取入口:
|
|
@@ -116,12 +121,17 @@ export const TIER_NAMES = Object.freeze(['fast', 'quality'])
|
|
|
116
121
|
/**
|
|
117
122
|
* 本插件行的正式配置 schema。
|
|
118
123
|
*
|
|
119
|
-
* `childExitGuard`、`subagents.{eng,global}
|
|
120
|
-
* `trustedHosts` 全部标 volatile(即时生效、不重挂):信任边界按请求重读活配置。
|
|
124
|
+
* `childExitGuard`、`delegation.prompt`、`subagents.{eng,global}`、
|
|
125
|
+
* `subagents.{codex,claude}`、`trustedHosts` 全部标 volatile(即时生效、不重挂):信任边界按请求重读活配置。
|
|
121
126
|
*/
|
|
122
127
|
export const Config = z.object({
|
|
123
128
|
/** 运行中子代理退出拦截总开关(默认关闭,显式开启才拦回合结束)。 */
|
|
124
129
|
childExitGuard: z.boolean().default(false).volatile(),
|
|
130
|
+
/** 委派提示词段(`better-subagent:delegation`);与 CLI 路由范围 `subagents.*` 无关。 */
|
|
131
|
+
delegation: z.object({
|
|
132
|
+
/** 是否把委派纪律与模型分档渲染进系统提示词(默认开启,对所有预设生效)。 */
|
|
133
|
+
prompt: z.boolean().default(true).volatile(),
|
|
134
|
+
}),
|
|
125
135
|
/** 子代理模型分档(工程模式提示词按此渲染;路由须在 allowedModels 白名单内)。 */
|
|
126
136
|
tiers: z.object({
|
|
127
137
|
fast: TierSchema,
|
|
@@ -248,15 +258,17 @@ function tierOf(value) {
|
|
|
248
258
|
* 输入可以是 `entry.fiber.config`(volatile 字段是引用对象)、旧 JSON 文档、
|
|
249
259
|
* 残缺对象或 `undefined`;返回值总是全新的、可安全改写的普通对象。
|
|
250
260
|
* @param config - 任意配置值。
|
|
251
|
-
* @returns `{ childExitGuard, tiers: { fast, quality }, subagents: { eng, global, codex, claude }, trustedHosts }`。
|
|
261
|
+
* @returns `{ childExitGuard, delegation: { prompt }, tiers: { fast, quality }, subagents: { eng, global, codex, claude }, trustedHosts }`。
|
|
252
262
|
*/
|
|
253
263
|
export function normalizeConfig(config) {
|
|
254
264
|
const projected = plain(config)
|
|
255
265
|
const source = isRecord(projected) ? projected : {}
|
|
256
266
|
const subagents = isRecord(source.subagents) ? source.subagents : {}
|
|
257
267
|
const tiers = isRecord(source.tiers) ? source.tiers : {}
|
|
268
|
+
const delegation = isRecord(source.delegation) ? source.delegation : {}
|
|
258
269
|
return {
|
|
259
270
|
childExitGuard: booleanOf(source.childExitGuard, false),
|
|
271
|
+
delegation: { prompt: booleanOf(delegation.prompt, true) },
|
|
260
272
|
tiers: { fast: tierOf(tiers.fast), quality: tierOf(tiers.quality) },
|
|
261
273
|
subagents: {
|
|
262
274
|
eng: booleanOf(subagents.eng, true),
|
package/src/prompt.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* with the session header/projection as fallback.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { currentConfig
|
|
18
|
+
import { currentConfig } from './config.js'
|
|
19
19
|
import { enabledIn } from './cli-adapter.js'
|
|
20
20
|
import { cliCatalog } from './subagents.js'
|
|
21
21
|
|
|
@@ -28,9 +28,6 @@ export const DELEGATION_ORDER = 60
|
|
|
28
28
|
export const CHILD_GUARD_ORDER = 70
|
|
29
29
|
export const CLI_CATALOG_ORDER = 80
|
|
30
30
|
|
|
31
|
-
/** Presets that opt into the eng-scope subagent behavior. */
|
|
32
|
-
export const ENG_PRESETS = Object.freeze(['eng', 'eng-ptc'])
|
|
33
|
-
|
|
34
31
|
const DELEGATION_HEAD = `## Delegation
|
|
35
32
|
- Subagents cannot see this conversation: state the goal, write scope, deliverable, and verification, and give real file paths for prior outputs.
|
|
36
33
|
- Opening reconnaissance: when starting non-trivial work in an unfamiliar or large codebase, immediately dispatch fast-tier scouts in parallel (structure, relevant modules, conventions, test entry points), all in one message; the main agent reads only the instruction files that define the task. A scout prompt needs only goal, boundaries, and deliverable.
|
|
@@ -39,8 +36,8 @@ const DELEGATION_HEAD = `## Delegation
|
|
|
39
36
|
|
|
40
37
|
const FANOUT_PTC = '- For repeated same-shaped work, dispatch all subagents inside one run_code program, then collect them with wait_subagent.'
|
|
41
38
|
|
|
42
|
-
const DELEGATION_TAIL = `-
|
|
43
|
-
-
|
|
39
|
+
const DELEGATION_TAIL = `- Waiting is done with wait_subagent only: do independent work first, then pass every id you need to a single wait_subagent call and let it block. Do not end the turn to wait for a notification unless nothing else is left to do.
|
|
40
|
+
- send_message is for new information or a correction, never for asking about progress, nudging, or checking in. Do not poll list_agents in place of waiting, and do not interrupt_agent a normally running subagent; intervene only for substantive new information, a clear failure or blockage, or a user request to stop.
|
|
44
41
|
- A wait_subagent timeout while a subagent is still running is not a failure: wait again or do independent work. Do not re-dispatch or take over solely because it is taking a long time.
|
|
45
42
|
- The main agent owns integration, review, and final verification. Subagent reports are leads, not evidence: check the actual changes yourself.
|
|
46
43
|
- When a subagent ends in an error or empty result, read why, fix the cause, and re-dispatch once; take over in the main thread only if it fails again without an external blocker, and say why.`
|
|
@@ -57,7 +54,8 @@ export function renderTier(tier) {
|
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
/**
|
|
60
|
-
* Render the delegation + model-tier section.
|
|
57
|
+
* Render the delegation + model-tier section. Scope gating (the
|
|
58
|
+
* `delegation.prompt` switch) happens in the caller, not here.
|
|
61
59
|
* @param config - normalized Better Subagent config (`tiers`).
|
|
62
60
|
* @param options - `{ ptc }` (true for the eng-ptc preset).
|
|
63
61
|
* @returns the section markdown; never empty (scope gating happens outside).
|
|
@@ -110,13 +108,6 @@ export function presetOf(ctx, agent) {
|
|
|
110
108
|
return preset
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
/** Whether the preset participates in the subagent scope. */
|
|
114
|
-
export function scopeEnabled(config, agent, preset) {
|
|
115
|
-
if (normalizeConfig(config).subagents.global) return true
|
|
116
|
-
if (!normalizeConfig(config).subagents.eng) return false
|
|
117
|
-
return ENG_PRESETS.includes(preset)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
111
|
/**
|
|
121
112
|
* Register the per-agent prompt sections.
|
|
122
113
|
* @param ctx - context with systemPrompt + agents.
|
|
@@ -138,8 +129,8 @@ export function installPromptSections(ctx, config) {
|
|
|
138
129
|
interpolate: false,
|
|
139
130
|
text: () => {
|
|
140
131
|
const live = currentConfig(ctx, config)
|
|
132
|
+
if (!live.delegation.prompt) return ''
|
|
141
133
|
const preset = currentPreset()
|
|
142
|
-
if (!scopeEnabled(live, agent, preset)) return ''
|
|
143
134
|
return renderDelegation(live, { ptc: typeof preset === 'string' && preset.endsWith('ptc') })
|
|
144
135
|
},
|
|
145
136
|
})
|