@oh-my-dsh/dsh-better-subagent 0.5.1 → 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 CHANGED
@@ -42,10 +42,10 @@
42
42
 
43
43
  ```sh
44
44
  # 只安装这个插件
45
- dsh plugin --profile <profile> add @oh-my-dsh/dsh-better-subagent@0.5.0
45
+ dsh plugin --profile <profile> add @oh-my-dsh/dsh-better-subagent@0.5.2
46
46
 
47
47
  # 或安装 Better DSH(会自动带上所有独立插件)
48
- dsh plugin --profile <profile> add dsh-better-dsh@0.10.0
48
+ dsh plugin --profile <profile> add dsh-better-dsh@0.10.1
49
49
  ```
50
50
 
51
51
  > 安装 / 升级 / 换包后必须重启对应 profile;只刷新网页不够。
@@ -56,8 +56,8 @@ dsh plugin --profile <profile> add dsh-better-dsh@0.10.0
56
56
  |---|---|
57
57
  | 稳定行 id | `dsh-better-subagent` |
58
58
  | 入口 / 工具 | `wait_subagent` · `/better-subagent/api/*` · 子代理设置页 |
59
- | 设置 | `childExitGuard`、`tiers.*`、两个 CLI 后端、`trustedHosts` |
60
- | npm 包 | `@oh-my-dsh/dsh-better-subagent@0.5.0` |
59
+ | 设置 | `childExitGuard`、`delegation.prompt`、`tiers.*`、两个 CLI 后端、`trustedHosts` |
60
+ | npm 包 | `@oh-my-dsh/dsh-better-subagent@0.5.2` |
61
61
  | 仓库 | https://github.com/omdsh-dev/dsh-better-subagent |
62
62
 
63
63
  ## 设置
@@ -22,7 +22,8 @@
22
22
 
23
23
  - 行 `name` 必须是 scoped npm 名:Loader 把它当模块 specifier 解析,`dsh-client-modules` 还要求 manifest 的 `name` 与行完全一致才能发现 `./client`。
24
24
  - 不允许再插入 agent preset 行;本插件不提供 preset。
25
- - 行 `Config` 在 `src/config.js`,由 `src/index.js` 重新导出。全部字段 volatile:`childExitGuard`、`tiers.fast/quality`、`subagents.eng/global`、`subagents.codex.*`、`subagents.claude.*`、`trustedHosts`(信任边界按请求重读活配置,保存即生效不重挂)。
25
+ - 行 `Config` 在 `src/config.js`,由 `src/index.js` 重新导出。全部字段 volatile:`childExitGuard`、`delegation.prompt`、`tiers.fast/quality`、`subagents.eng/global`、`subagents.codex.*`、`subagents.claude.*`、`trustedHosts`(信任边界按请求重读活配置,保存即生效不重挂)。
26
+ - `delegation.prompt`(默认 `true`)只决定 `better-subagent:delegation` 提示词段是否渲染,**对所有预设生效**;`subagents.eng/global` 只管 CLI 后端路由与 CLI 目录段。两者互不影响:把 CLI 范围全关掉,委派纪律照样渲染。
26
27
  - `normalizeConfig` 会把任意来源(volatile 引用、旧 JSON、残缺对象)规整成精确默认形状;非法值回退默认、绝不抛错。`currentConfig(ctx, fallback)` 经 `configEditor` 找**活**行配置;找不到时回退 `fallback`。
27
28
  - **命名**:S1 Spec 的 unscoped 名 `dsh-better-subagent` 已被他人占用,现使用 scoped 包名 `@oh-my-dsh/dsh-better-subagent`;行 id 仍是 `dsh-better-subagent`,行 name 与 client closure id 必须是 scoped 包名,短键 `dsh-better-subagent#dsh-better-subagent` 只作兼容别名保留。旧 `@menghuan1918/dsh-better-subagent` 作为 legacy 键保留。
28
29
  - 行配置键(浏览器半边 `plugins.row.config`)六份,全部指向同一行:
@@ -95,7 +96,7 @@
95
96
 
96
97
  | 名称 | order | 出现条件 | 内容 |
97
98
  |---|---|---|---|
98
- | `better-subagent:delegation` | 60 | `subagents.global` 或(`subagents.eng` 且 preset ∈ {eng, eng-ptc}) | 委派纪律 + fast/quality 分档;preset 以 `ptc` 结尾时追加 run_code fanout 规则 |
99
+ | `better-subagent:delegation` | 60 | `delegation.prompt` | 委派纪律(含等待纪律)+ fast/quality 分档;preset 以 `ptc` 结尾时追加 run_code fanout 规则 |
99
100
  | `better-subagent:child-guard` | 70 | `childExitGuard` | 运行中子代理退出守卫措辞 |
100
101
  | `better-subagent:cli-subagents` | 80 | 路由范围 + 至少一个后端 enabled | 旧 CLI 目录内容(provider、后台、send_message/wait_subagent/list_agents/interrupt_agent、模型/effort 目录) |
101
102
 
@@ -115,7 +116,7 @@ preset 解析优先 `agentPresets.composedPreset(agent.ctx)`,回退 `sessionPr
115
116
  - 使用 `form.state`(`{status, value, revision, writable, mode}`)与 `form.mutate(ops, revision)`;只在保存时提交与宿主快照的差异 `set` ops。
116
117
  - 可写字段只包含 volatile 路径;`writable === false` / `mode === 'memory'` 禁用配置写入控件,保留页签导航与只读探测刷新;冲突(mutate 返回 false)回退宿主值并提示;异常保留草稿。
117
118
  - 六份 `plugins.row.config` 键注册同一个组件;locale 命名空间 `better-subagent`(zh/en 字典键一致)。
118
- - 表单分为概览、CLI(Codex / Claude)、模型分档、连接;覆盖 scope(eng/global)、fast/quality(路由 + effort)、两个后端(enabled/executable/profile/permission/defaultModel/models + 自动发现)、childExitGuard 与 trustedHosts。页签支持方向键 / Home / End,切换保留草稿和未输入完的 effort 文本。说明使用标签旁的原生信息折叠控件,保留 aria-describedby 与控件关联。
119
+ - 表单分为概览、CLI(Codex / Claude)、模型分档、连接;覆盖 scope(eng/global)、fast/quality(路由 + effort)、两个后端(enabled/executable/profile/permission/defaultModel/models + 自动发现)、delegationPrompt、childExitGuard 与 trustedHosts。页签支持方向键 / Home / End,切换保留草稿和未输入完的 effort 文本。说明使用标签旁的原生信息折叠控件,保留 aria-describedby 与控件关联。
119
120
  - 依赖:重命名默认模型会同步默认选择,删除时清空;effort 列表变更会清空失效默认 effort。后端停用时仍可提前编辑配置;scope 全关闭时提示路由不可见。未保存 executable / profile 时禁用模型发现,保存 revision 变更后重读探针;请求期间路径 / profile 改变、放弃改动或 revision 更新都会丢弃旧目录。失效请求会结束自己的加载状态,旧请求不会覆盖新一次发现的状态。
120
121
  - 校验:模型 id 非空且唯一;启用的后端必须有模型、默认模型与默认 effort;白名单读到时已存分档路由必须在白名单内,已选 effort 必须属于模型提供的候选列表;trustedHosts 接受不含协议和路径的主机名或 host:port。已存但不在候选中的值保留并标注,不静默改值。分档本身只是提示词建议,实际子代理路由仍由宿主模型选择策略决定。
121
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-dsh/dsh-better-subagent",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Standalone DSH plugin: Codex/Claude continuable CLI subagents, wait_subagent, child exit guard and model tiers. Pure ESM, no build step.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/client.js CHANGED
@@ -137,6 +137,8 @@ window.__ModuleLoader__.load({
137
137
  readonly: "当前连接仅供查看,无法保存设置。",
138
138
  childExitGuardLabel: "等待子代理完成",
139
139
  childExitGuardHint: "子代理仍在运行时继续等待;按 Esc 仍可中断。",
140
+ delegationPromptLabel: "委派提示词",
141
+ delegationPromptHint: "把委派纪律与模型分档写进系统提示词,对所有预设生效;与 CLI 接入范围无关。",
140
142
  tiersTitle: "子代理模型选择",
141
143
  tiersIntro: "为工程预设推荐子代理模型;实际调用仍需符合允许使用的模型范围。",
142
144
  tierFast: '快速档',
@@ -298,6 +300,8 @@ window.__ModuleLoader__.load({
298
300
  readonly: "This connection is view-only. Settings cannot be saved.",
299
301
  childExitGuardLabel: "Wait for subagents to finish",
300
302
  childExitGuardHint: "Keep waiting while subagents run. You can still interrupt with Esc.",
303
+ delegationPromptLabel: "Delegation prompt",
304
+ delegationPromptHint: "Adds the delegation rules and model tiers to the system prompt for every preset; independent of the CLI scope.",
301
305
  tiersTitle: "Subagent model selection",
302
306
  tiersIntro: "Recommend subagent models in engineering presets; calls must still use a permitted model.",
303
307
  tierFast: 'Fast tier',
@@ -603,6 +607,7 @@ window.__ModuleLoader__.load({
603
607
  const tiers = isRecord(source.tiers) ? source.tiers : {};
604
608
  const result = {
605
609
  childExitGuard: source.childExitGuard === true,
610
+ delegationPrompt: !isRecord(source.delegation) || source.delegation.prompt !== false,
606
611
  trustedHosts: Array.isArray(source.trustedHosts) ? [...new Set(source.trustedHosts.filter((item) => typeof item === 'string').map((item) => item.trim()).filter(Boolean))] : [],
607
612
  tiers: {},
608
613
  subagents: {
@@ -635,6 +640,9 @@ window.__ModuleLoader__.load({
635
640
  if (host.childExitGuard !== current.childExitGuard) {
636
641
  ops.push({ op: 'set', path: ['childExitGuard'], value: current.childExitGuard });
637
642
  }
643
+ if (host.delegationPrompt !== current.delegationPrompt) {
644
+ ops.push({ op: 'set', path: ['delegation', 'prompt'], value: current.delegationPrompt });
645
+ }
638
646
  for (const tier of TIERS) {
639
647
  if (JSON.stringify(host.tiers[tier]) === JSON.stringify(current.tiers[tier])) continue;
640
648
  ops.push({ op: 'set', path: ['tiers', tier], value: tierShape(current.tiers[tier]) });
@@ -1462,6 +1470,8 @@ window.__ModuleLoader__.load({
1462
1470
  !scopeActive ? h('p', { className: 'bs-note', 'data-tone': 'warn' }, translate('scopeNone')) : null),
1463
1471
  h('section', { className: 'bs-section' },
1464
1472
  h('div', { className: 'bs-sectionHead' }, h('h3', { className: 'bs-sectionTitle' }, translate('behaviorTitle'))),
1473
+ h(SwitchRow, { id: 'bs-delegation-prompt', label: translate('delegationPromptLabel'), hint: translate('delegationPromptHint'),
1474
+ checked: live.delegationPrompt, disabled: !writable || busy, onChange: (delegationPrompt) => edit((current) => ({ ...current, delegationPrompt })) }),
1465
1475
  h(SwitchRow, { id: 'bs-child-exit-guard', label: translate('childExitGuardLabel'), hint: translate('childExitGuardHint'),
1466
1476
  checked: live.childExitGuard, disabled: !writable || busy, onChange: (childExitGuard) => edit((current) => ({ ...current, childExitGuard })) })),
1467
1477
  h('section', { className: 'bs-section', 'aria-label': translate('readonlyDiagnostics') },
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`、`subagents.eng`、
18
- * `subagents.global`、`subagents.codex.*`、`subagents.claude.*`、`trustedHosts`。
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}`、`subagents.{codex,claude}`、
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, normalizeConfig } from './config.js'
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 = `- Do not repeatedly prod normally running subagents with send_message, poll list_agents frequently, or interrupt them with interrupt_agent. Intervene only for substantive new information, corrections, clear failure or blockage, or a user request to stop.
43
- - Do independent work first; when progress truly depends on subagent results, wait patiently with wait_subagent for all needed results together.
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
  })