@oh-my-dsh/dsh-better-subagent 0.0.0-stage → 0.5.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,88 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/omdsh-dev/dsh-better-subagent/main/docs/assets/banner-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/omdsh-dev/dsh-better-subagent/main/docs/assets/banner-light.svg" width="100%" alt="Part of Better DSH — @oh-my-dsh/dsh-better-subagent">
5
+ </picture>
6
+ </p>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ <h1 align="center">@oh-my-dsh/dsh-better-subagent</h1>
9
+
10
+ <p align="center">把 Codex / Claude CLI 接成可续接的 DSH 子代理,并给它们统一的路由、等待和分档。</p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/@oh-my-dsh/dsh-better-subagent"><img src="https://img.shields.io/npm/v/%40oh-my-dsh%2Fdsh-better-subagent.svg" alt="npm 版本"></a>
14
+ <a href="LICENSE"><img alt="Apache-2.0" src="https://img.shields.io/github/license/omdsh-dev/dsh-better-subagent?color=blue"></a>
15
+ <a href="package.json"><img alt="DSH 0.2.2-rc.1" src="https://img.shields.io/badge/DSH-0.2.2--rc.1-4B32C3"></a>
16
+ <a href="https://github.com/omdsh-dev/dsh-better-dsh"><img alt="Part of Better DSH" src="https://img.shields.io/badge/part%20of-dsh--better--dsh-2F80B7"></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="https://github.com/omdsh-dev/dsh-better-dsh">Better DSH 插件集合</a> ·
21
+ <a href="#安装">安装</a> ·
22
+ <a href="#它拥有什么">它拥有什么</a> ·
23
+ <a href="#设置">设置</a> ·
24
+ <a href="#与-better-dsh-的关系">与 Better DSH 的关系</a>
25
+ </p>
26
+
27
+ ## 它做什么
28
+
29
+ - Codex / Claude CLI 适配器
30
+ - `wait_subagent` 等待续接
31
+ - 运行中子代理退出守卫
32
+ - 模型分档、路由与子代理提示词
33
+
34
+ <p align="center">
35
+ <picture>
36
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/omdsh-dev/dsh-better-subagent/main/docs/assets/ownership-dark.svg">
37
+ <img src="https://raw.githubusercontent.com/omdsh-dev/dsh-better-subagent/main/docs/assets/ownership-light.svg" width="100%" alt="@oh-my-dsh/dsh-better-subagent 与 Better DSH 的装配关系">
38
+ </picture>
39
+ </p>
40
+
41
+ ## 安装
42
+
43
+ ```sh
44
+ # 只安装这个插件
45
+ dsh plugin --profile <profile> add @oh-my-dsh/dsh-better-subagent@0.5.0
46
+
47
+ # 或安装 Better DSH(会自动带上所有独立插件)
48
+ dsh plugin --profile <profile> add dsh-better-dsh@0.10.0
49
+ ```
50
+
51
+ > 安装 / 升级 / 换包后必须重启对应 profile;只刷新网页不够。
52
+
53
+ ## 它拥有什么
54
+
55
+ | | |
56
+ |---|---|
57
+ | 稳定行 id | `dsh-better-subagent` |
58
+ | 入口 / 工具 | `wait_subagent` · `/better-subagent/api/*` · 子代理设置页 |
59
+ | 设置 | `childExitGuard`、`tiers.*`、两个 CLI 后端、`trustedHosts` |
60
+ | npm 包 | `@oh-my-dsh/dsh-better-subagent@0.5.0` |
61
+ | 仓库 | https://github.com/omdsh-dev/dsh-better-subagent |
62
+
63
+ ## 设置
64
+
65
+ 可以在 Plugins 页的 `dsh-better-subagent` 行设置,也可以在 Better DSH 详情页的「集成设置」里打开同名页面。两个入口共用同一份配置和同一个设置组件,不会产生第二份存储。
66
+
67
+ - 模型 / effort / profile 在子代理创建时固定;权限每轮读取。
68
+ - 旧 `@menghuan1918/dsh-better-subagent` 的配置键保留兼容;行 id 仍是 `dsh-better-subagent`。
69
+
70
+ ## 与 Better DSH 的关系
71
+
72
+ - **同一个稳定行**:独立安装或由 `dsh-better-dsh` 装配,行 id 和设置命名空间都不变。
73
+ - **旧入口兼容**:早期 Apollo 集成使用的行配置键仍然注册,指向同一份配置。
74
+ - **可以单独使用**:不安装 Better DSH 也能工作;只是不会得到工程预设、流程技能或后台 job 守卫。
75
+ - **Apache-2.0**:本仓库与 Better DSH 的其他仓库统一使用 Apache License 2.0。
76
+
77
+ ## 开发
78
+
79
+ ```sh
80
+ npm test # 单元 / 组件测试
81
+ npm run smoke # 如仓库提供运行时冒烟
82
+ ```
83
+
84
+ 实现与测试说明见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
85
+
86
+ ## 许可
87
+
88
+ [Apache License 2.0](LICENSE)。
@@ -0,0 +1,31 @@
1
+ # dsh-better-subagent bundle patch: inserts the one host-plane row this package
2
+ # needs into the profile roster. Applied as a profile bundle layer; activate
3
+ # with `dsh plugin --profile <name> add @oh-my-dsh/dsh-better-subagent` (or
4
+ # `link:<path>` during development).
5
+ #
6
+ # The row name must be this package's scoped npm name: the Loader resolves a
7
+ # row's `name` as a module specifier, and `dsh-client-modules` discovers the
8
+ # browser half (`dsh.client` -> exports "./client") from that same manifest,
9
+ # requiring the manifest name to equal the row exactly. The client closure id
10
+ # is the package name too.
11
+ #
12
+ # The row registers, in one host-plane plugin:
13
+ # - the Codex/Claude CLI llm adapters and the subagent routing bridge;
14
+ # - the `wait_subagent` tool and the subagents-only child exit guard;
15
+ # - the subagent-specific prompt sections (delegation, model tiers, PTC
16
+ # fanout, CLI catalog, child guard);
17
+ # - the read-only API /better-subagent/api/* (plus /apollo/api/* read
18
+ # aliases) consumed by the row config page.
19
+ #
20
+ # Volatile row config (applies without reloading the row): childExitGuard,
21
+ # tiers.{fast,quality}, subagents.{eng,global}, subagents.{codex,claude}.*.
22
+ # Deployment flag, hand-written only: trustedHosts.
23
+ - insert:
24
+ # Singleton PTC deadline-exemption row. The ask-user bundle inserts the
25
+ # same id/name; the Loader deduplicates so both plugins share one service
26
+ # and one runtime wrapper.
27
+ - id: dsh-better-ptc
28
+ name: dsh-better-ptc
29
+
30
+ - id: dsh-better-subagent
31
+ name: '@oh-my-dsh/dsh-better-subagent'
@@ -0,0 +1,181 @@
1
+ # dsh-better-subagent 开发说明
2
+
3
+ 本文件面向维护者:说明插件在 DSH 宿主里的装配方式、与 Better DSH / Apollo 的兼容契约、文件职责、验证命令与已知边界。
4
+
5
+ ## 1. 包形态
6
+
7
+ - 纯 ESM、无构建步骤;宿主入口 `src/index.js`,浏览器入口 `src/client.js`。
8
+ - `package.json` 的 `dsh.bundle.patch` 指向 `cordis.patch.yml`;`dsh.client.platform = "web"`。
9
+ - `files` 白名单:`src`、`docs`、`cordis.patch.yml`、`README.md`、`LICENSE`、`third-party`。测试、脚本、设计 Spec、凭据、临时 profile 都不进发布包。
10
+ - 依赖:运行时只直接 import `@deepseek-ai/schemastery`;其余 DSH 包是精确 peer(`0.2.2-rc.1`),由宿主运行环境提供,服务全部经 `ctx` 获取。
11
+ - 浏览器半边只 `require('react')`,不 import 任何 DSH client 包;样式全部使用宿主主题 token(`--dsw-alias-*`),不写 DOM。
12
+
13
+ ## 2. 宿主行与配置
14
+
15
+ `cordis.patch.yml` 只插入一行:
16
+
17
+ ```yaml
18
+ - insert:
19
+ - id: dsh-better-subagent
20
+ name: '@oh-my-dsh/dsh-better-subagent'
21
+ ```
22
+
23
+ - 行 `name` 必须是 scoped npm 名:Loader 把它当模块 specifier 解析,`dsh-client-modules` 还要求 manifest 的 `name` 与行完全一致才能发现 `./client`。
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`(信任边界按请求重读活配置,保存即生效不重挂)。
26
+ - `normalizeConfig` 会把任意来源(volatile 引用、旧 JSON、残缺对象)规整成精确默认形状;非法值回退默认、绝不抛错。`currentConfig(ctx, fallback)` 经 `configEditor` 找**活**行配置;找不到时回退 `fallback`。
27
+ - **命名**: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
+ - 行配置键(浏览器半边 `plugins.row.config`)六份,全部指向同一行:
29
+ - `@oh-my-dsh/dsh-better-subagent#dsh-better-subagent`
30
+ - `dsh-better-dsh#dsh-better-subagent`
31
+ - `@menghuan1918/dsh-better-subagent#dsh-better-subagent`
32
+ - `@menghuan1918/dsh-apollo#dsh-better-subagent`
33
+ - `dsh-apollo#dsh-better-subagent`
34
+ - `dsh-better-subagent#dsh-better-subagent`
35
+
36
+ ## 3. 装配
37
+
38
+ `src/index.js` 的 `apply(ctx, config)` 依次调用:
39
+
40
+ | 模块 | 装配内容 | 需要的服务 |
41
+ |---|---|---|
42
+ | `mountSettings` | `/better-subagent/api/*` 路由(+ `/apollo/api/*` 读别名)、行配置页面策略 | `webServer`、`settings` |
43
+ | `mountSubagents` | Codex/Claude llm adapter、`subagent` 路由桥、身份 KV | `tools`、`subagents`、`agents`、`llm`、`storage`、`subprocess`、`workingDirectory` |
44
+ | `mountWaitSubagent` | 宿主工具 `wait_subagent` | `tools`、`subagents`、`agents`、`sessionQuery` |
45
+ | `mountChildExitGuard` | `agent/turn-stopping` 上的运行中子代理拦截 | `subagents`、`agents` |
46
+ | `mountPrompt` | `agent/created` 时给该 Agent 的 `agent.ctx.systemPrompt` 注册三个 section | `systemPrompt`、`agents` |
47
+
48
+ 所有 `ctx.inject` 都是延迟的:headless 组合缺少 `webServer` 时只有设置路由跳过,其余照常工作;缺少 CLI 所需服务时只有 CLI 桥不挂载。
49
+
50
+ ## 4. CLI 桥(`src/subagents.js` + `src/cli-adapter.js` + `src/cli/*`)
51
+
52
+ - 不注册第二个 spawn/fork registry;CLI 子代理仍是原生 `subagents.startActivation({provider:'spawn', childId, ...})`,只是 `agentOptions.provider` 是内部 synthetic route。
53
+ - 内部 route 历史固定为 `apollo-cli-codex` / `apollo-cli-claude`;不要为新包名重命名,否则旧会话不可续接。
54
+ - 拦截点:
55
+ - `ctx.tools.guard`:内部 route 保留、禁用范围明确拒绝、fork 拒绝;
56
+ - `ctx.tools.execute`:`subagent` + `provider=codex|claude` 短路创建;`list_subagent_models` 合并 CLI 目录;
57
+ - `ctx.on('tools/result')`:未被调用方接受的 child 回收(drain + 删 KV)。
58
+ - 创建流程:模型/effort 白名单校验 → 父当前目录解析(`workingDirectory.ensure`)→ `resolveExecutable` 预检 → `<executable> --version` 版本预检(`src/cli/version.js`:Codex 基线 `0.162.1`,Claude 基线 `2.1.300`;无法执行/无法识别/过旧都给出点名可执行文件与安装/升级方式的可操作错误)→ 先落 KV 再 `startActivation` → 失败/取消 drain + 删记录。`ctx.cliVersionProbe` 是测试 seam;真实运行时用 `execFile`,无 shell。
59
+ - 每个 adapter:一轮一个子进程;`delivered` 在 spawn 前落 KV;`remoteId` 第一行事件即落盘;`parse` 失败/非零退出/缺完成标志都抛错且不自动重试;`dispose()` 等待进程句柄退出。没有 `subprocess` 服务或 spawn 未发布时回滚 `started/delivered`。
60
+ - 身份 KV(`src/cli-sessions.js`):命名空间前缀 `apollo_cli_` + `sha256(profile.dir)[:16]`,version 1,`sessions` 表,`per-record`。**包名变化不重命名/复制/清空**。
61
+ - 权限/模型/effort 与父子归属在启动前失败;缺 CLI 或版本不兼容给可操作诊断,不回退到另一后端。
62
+
63
+ ## 5. wait_subagent 的跨回合判定(`src/wait-subagent.js`)
64
+
65
+ 旧实现的缺陷:`settled` 只按 childId 缓存 `subagent/end`,当同一 child 被续接(新 activation 或 resident 新回合)时会把旧 end 当成本轮完成。
66
+
67
+ 现实现只依据宿主可证明的事实:
68
+
69
+ 1. 监听 `subagent/start` / `subagent/end`,记录每个 child 最近的 activation `runId`;
70
+ 2. `status === 'running'` → 继续等待;
71
+ 3. 匹配 end:最近一次 end 的 runId 与最近一次 start 相同(或挂载后只见到 end)。不匹配(新 activation)→ 继续等;
72
+ 4. 匹配 end 后再读 durable 日志(`ctx.sessionQuery.observeSession(childId)`):只 fold `inheritedEventCount` 之后的**子代理自有**事件(fork 前缀的父 turn/end、splice 不属于该 child);
73
+ 5. fold `agent/inbox/spliced` 的 `inserted`/`removedCount`/`outcome:'canceled'`,按 target(`next-turn`/`next-step`)维护队列长度:turn claim(`removedCount` 无 outcome)与取消删除都会清掉排队计数;`pending = nextTurn + nextStep > 0`;
74
+ 6. 匹配 end + `pending > 0` → 继续等(resident idle child 收到新输入时没有新 `subagent/start`,这是唯一的当前回合证明);`pending === 0` → done;
75
+ 7. durable 不可读:只有原生 `subagent/end.local === false` 的 external provider 可用匹配的 start/end 对 settle;本地 child(即使已不在 registry)仍返回 `could not be confirmed`,不把不可读会话伪报成功;
76
+ 8. 无 end 时:`pending > 0` 继续等;不在 registry 且自有日志有 `turn/end` → “已在此次等待前结束”的说明(不是旧 done);30s 启动宽限后仍无法证明 → not-started/不可确认行。
77
+
78
+ `observeSession` 是异步边界:读取返回后必须重新检查 live running,并确认 start/end 记录仍是读取前的同一代(事件每次替换记录对象,即使 runId 相同也能识别新的 end)。跨代读取不参与完成判断,由现有 250ms poller 重读;不立即循环重试。否则新回合在读取期间 claim 掉 pending 后,会被旧 end 误判为 done。
79
+
80
+ 输出行保持旧契约:done/timeout/aborted/not-started/不可确认;正文交给框架 settlement notice,工具不碰父代理 inbox。
81
+
82
+ 回归测试:`tests/wait-subagent.test.mjs` 构造「旧 end → 新 start + 排队 idle → running → 新 end」与「同一 run 内 turn 结束后又有 splice」;另通过真实 `installWaitTool` 注册 seam 的 deferred `observeSession`,覆盖读取挂起期间的新 activation / 无新 start 的 resident running + claim,以及 start/end 换代后 idle 的旧日志快照。
83
+
84
+ ## 6. 子代理退出守卫(`src/child-exit-guard.js`)
85
+
86
+ - 只由 volatile `childExitGuard`(默认 false)控制;
87
+ - 只听 `agent/turn-stopping`,只收集 `subagents.listChildren(agent.id)` 中 **live status === running** 的直接子代理;
88
+ - 只做一次 `agent.steer(buildChildGuardMessage(children))`;
89
+ - 查询/注入异常 → 告警并放行(fail open);`payload.signal.aborted` 直接返回;
90
+ - 不看 jobs、不 import Apollo、不扩大权限。
91
+
92
+ ## 7. 提示词(`src/prompt.js`)
93
+
94
+ 在 `agent/created` 时向该 Agent 的 `agent.ctx.systemPrompt` 注册(effect 随 Agent 释放):
95
+
96
+ | 名称 | order | 出现条件 | 内容 |
97
+ |---|---|---|---|
98
+ | `better-subagent:delegation` | 60 | `subagents.global` 或(`subagents.eng` 且 preset ∈ {eng, eng-ptc}) | 委派纪律 + fast/quality 分档;preset 以 `ptc` 结尾时追加 run_code fanout 规则 |
99
+ | `better-subagent:child-guard` | 70 | `childExitGuard` | 运行中子代理退出守卫措辞 |
100
+ | `better-subagent:cli-subagents` | 80 | 路由范围 + 至少一个后端 enabled | 旧 CLI 目录内容(provider、后台、send_message/wait_subagent/list_agents/interrupt_agent、模型/effort 目录) |
101
+
102
+ preset 解析优先 `agentPresets.composedPreset(agent.ctx)`,回退 `sessionProjections`/session header;文本是函数,按活配置每次请求渲染。Apollo 的 PRINCIPLES、工作流 skills、job/general guard 文本不在此处。
103
+
104
+ ## 8. 只读 API(`src/panel.js` + `src/settings.js`)
105
+
106
+ - `registerCapabilitiesRoute` 一次注册两个 prefix:`/better-subagent/api` 与 `/apollo/api`,共享同一 handler;`settings.js` 只注册一次。
107
+ - 路由:`/capabilities`、`/models?cli=codex|claude`、`/routes`;GET only;未知路径 404;非 GET 405;不读请求体。
108
+ - 信任边界:loopback 或 `trustedHosts`;拒绝跨站 `Sec-Fetch-Site` 与异源 Origin。`trustedHosts` 每请求读活配置。
109
+ - 能力探针:30s 有界缓存 + 并发去重。发现:Codex `codex debug models`(失败回退 `--bundled`);Claude 读 `ANTHROPIC_BASE_URL`/凭据并请求 `/v1/models`。发现只在显式调用时触发(不做后台缓存/重探);响应不回凭据,只回可执行文件路径/版本、profile 名、模型 id/effort。
110
+ - `trustedHosts` 只约束本插件的读接口,不改变宿主设置镜像的可写性。
111
+
112
+ ## 9. 客户端设置页(`src/client.js`)
113
+
114
+ - `window.__ModuleLoader__.load({id:'@oh-my-dsh/dsh-better-subagent', factory})`;只 require React。
115
+ - 使用 `form.state`(`{status, value, revision, writable, mode}`)与 `form.mutate(ops, revision)`;只在保存时提交与宿主快照的差异 `set` ops。
116
+ - 可写字段只包含 volatile 路径;`writable === false` / `mode === 'memory'` 禁用配置写入控件,保留页签导航与只读探测刷新;冲突(mutate 返回 false)回退宿主值并提示;异常保留草稿。
117
+ - 六份 `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
+ - 依赖:重命名默认模型会同步默认选择,删除时清空;effort 列表变更会清空失效默认 effort。后端停用时仍可提前编辑配置;scope 全关闭时提示路由不可见。未保存 executable / profile 时禁用模型发现,保存 revision 变更后重读探针;请求期间路径 / profile 改变、放弃改动或 revision 更新都会丢弃旧目录。失效请求会结束自己的加载状态,旧请求不会覆盖新一次发现的状态。
120
+ - 校验:模型 id 非空且唯一;启用的后端必须有模型、默认模型与默认 effort;白名单读到时已存分档路由必须在白名单内,已选 effort 必须属于模型提供的候选列表;trustedHosts 接受不含协议和路径的主机名或 host:port。已存但不在候选中的值保留并标注,不静默改值。分档本身只是提示词建议,实际子代理路由仍由宿主模型选择策略决定。
121
+
122
+ ## 10. 验证
123
+
124
+ ```sh
125
+ cd /path/to/dsh-better-subagent
126
+ npm install
127
+ npm test
128
+
129
+ # 真实宿主(headless,无需 CLI 凭据):原生 subagent create→wait→continue→wait→interrupt→wait
130
+ DSH_PACKAGE_ROOT="/path/to/dependencies/dsh/node_modules/@deepseek-ai/dsh" npm run smoke
131
+
132
+ # 真实 Claude CLI(需要已登录;会消耗少量额度;含同 profile 的进程内宿主重启 + KV 重开 + cold resume)
133
+ DSH_PACKAGE_ROOT="/path/to/dependencies/dsh/node_modules/@deepseek-ai/dsh" node scripts/cli-smoke.mjs claude
134
+
135
+ # 真实 Codex CLI(需要 `codex login`;当前机器未登录时不可用)
136
+ DSH_PACKAGE_ROOT="/path/to/dependencies/dsh/node_modules/@deepseek-ai/dsh" node scripts/cli-smoke.mjs codex
137
+
138
+ npm pack --dry-run --json
139
+ npm ci --dry-run
140
+ ```
141
+
142
+ 测试目录:
143
+
144
+ | 文件 | 覆盖 |
145
+ |---|---|
146
+ | `tests/config.test.mjs` | 默认形状、volatile 集合、normalize 去重/回退/展开、活配置读取、settings 投影契约 |
147
+ | `tests/cli.test.mjs` | JSONL 切行/多字节/错误去敏、Codex/Claude argv 精确构造与事件语义 |
148
+ | `tests/cli-sessions.test.mjs` | KV 命名空间 `apollo_cli_*`、descriptor、校验、串行写、重开/关闭;真实 `@deepseek-ai/dsh-storage-json` per-record 重开/跨 profile 隔离 |
149
+ | `tests/cli-adapter.test.mjs` | provider 元数据、早存 remoteId、resume、env snapshot、并发、坏 JSON/非零退出、中断、游标、归属、dispose、rollback |
150
+ | `tests/subagents.test.mjs` | guard/路由、范围开关、fork/agent_preset/run_in_background 拒绝、白名单、降级、cwd、KV/预检/回收 |
151
+ | `tests/wait-subagent.test.mjs` | 契约/批量/去重/直接子代理/fail-fast/超时下限/宽限/取消/inbox 零手术 + 跨回合回归 |
152
+ | `tests/child-exit-guard.test.mjs` | 运行中子代理拦截、标签、开关、abort、fail-open、无 job 依赖 |
153
+ | `tests/prompt.test.mjs` | per-agent 注册、scope 门控、tiers/PTC/guard/catalog、活配置重渲染、preset 解析 |
154
+ | `tests/panel.test.mjs` | 探针、模型发现、信任边界、路由、canonical + Apollo 别名 |
155
+ | `tests/settings.test.mjs` | 延迟注入、路由注册、页面策略、无旧配置导入 |
156
+ | `tests/client.test.mjs` | 真实 React hooks/元素树:四个槽键、表单控件、保存/冲突/只读、发现、分档 |
157
+ | `tests/assembly.test.mjs` | manifest、bundle patch、exports、client closure id/键、发布工作流、包白名单、NOTICE |
158
+
159
+ 真实宿主 smoke 会打印 `BETTER_SUBAGENT_RUNTIME_SMOKE_PASSED`(检查:精确宿主/隔离包路径、真实 step admission 阻止 CLI 越权启动、CLI advisory model catalog/精确 metadata、原生 local/runId 字段、真实 settings 投影/volatile 热更新、真实 webServer canonical+别名路由、结算通知正文、childExitGuard 真实 turn-stopping;模型输出由明确的 scripted adapter 提供,不是在线 LLM),CLI smoke 会打印 `BETTER_SUBAGENT_CLI_SMOKE_PASSED`(检查:真实 CLI 创建/等待、身份记录落盘、同 profile/DSH_HOME 的进程内宿主重启+父 Agent 恢复、KV 重开+cold CLI resume、remoteId 稳定、中断;不是独立 OS 进程),并在临时 `DSH_HOME/results.json` 留下检查项。
160
+
161
+ CLI smoke 会把 DSH profile 放在临时目录,但不会改 Claude/Codex 的原生 home(改 `CLAUDE_CONFIG_DIR` 会改变凭据/keychain 查找);真实 CLI 自己的原生会话因此会留在该 CLI 的用户目录下,脚本不清理这些原生会话。
162
+
163
+ ### 已知未验证项
164
+
165
+ - Codex CLI 端到端:实现机 `codex login status` 为 `Not logged in`,属于凭据阻塞;测试替身只能证明 argv/解析/生命周期边界。
166
+ - 从 npm 发布后的 `dsh plugin add` 与真实 Web GUI 点击:本仓库尚未发布;临时 profile 用同样的 scoped 安装布局 + `runProfile` 验证了加载(含真实 webServer 路由与真实 settings 投影/写入)。
167
+ - Apollo + 本插件组合运行与旧配置迁移:由 S4(Apollo 集成)负责并验证。
168
+
169
+ ## 11. 迁移与边界
170
+
171
+ - 本仓库**不删除 Apollo 文件**、不修改 Apollo 预设/配置。Apollo 在执行 S4 之前仍保留旧的 `wait-subagent`、`exit-guard`、`mode-instructions` 与 `/apollo/api/*` 处理器。
172
+ - 同时安装时:preset 作用域的同名工具会遮蔽宿主工具;`/apollo/api` 路由可能由 Apollo 与本插件各注册一次(webServer 的重复 (kind,path) 会抛错)——这是迁移窗口的已知状态,S4 删除 Apollo 旧实现后消失。不要在这个窗口里声称组合安装已完成验收。
173
+ - 旧 `exitGuard` → `childExitGuard` 的映射归 S4;本插件只读自己的行配置,不读 `eng.json`/`atlas.json`。
174
+ - 身份 KV 与内部 route 是兼容契约:不要为了包名/品牌改名。
175
+ - 包名从 Spec 的 unscoped `dsh-better-subagent` 改为 scoped `@oh-my-dsh/dsh-better-subagent`(npm 名被他人占用);旧 `@menghuan1918/dsh-better-subagent` 作为 legacy 键保留;行 id 与短槽键保留 `dsh-better-subagent`。
176
+
177
+ ## 12. 发布
178
+
179
+ - `.github/workflows/release.yml`:GitHub Release `published` 触发;校验 tag `v<version>` 与 `package.json` 版本一致;`npm ci` → `npm test` → `npm publish --provenance --access public`。
180
+ - 使用 npm trusted publishing(OIDC),仓库与 workflow 中不保存 npm token;npmjs.com 的 trusted publisher 需指向本仓库与 `release.yml`。
181
+ - 发布前检查:`npm pack --dry-run --json` 的文件列表只含白名单(无 tests/scripts/docs 之外的内部 Spec、无 `.env`/`.npmrc`/凭据/临时 profile)。
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1600" height="240" viewBox="0 0 1600 240" role="img" aria-labelledby="title desc"><title id="title">Part of Better DSH — Better Subagent</title><desc id="desc">Better Subagent 属于 Better DSH 插件集合,也可以独立安装。</desc><defs><pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse"><path d="M40 0H0V40" fill="none" stroke="#122033" stroke-width="1" opacity="0.7"/></pattern><radialGradient id="glow" cx="50%" cy="50%" r="50%"><stop offset="0%" stop-color="#4EB0E8" stop-opacity="0.18"/><stop offset="100%" stop-color="#4EB0E8" stop-opacity="0"/></radialGradient></defs><rect x="0" y="0" width="1600" height="240" fill="#0A101B"/><rect x="0" y="0" width="1600" height="240" fill="url(#grid)" opacity="0.55"/><rect x="0.5" y="0.5" width="1599" height="239" fill="none" stroke="#22314A" stroke-width="1" opacity="0.9"/><ellipse cx="420" cy="120" rx="520" ry="220" fill="url(#glow)"/><rect x="80" y="40" width="286" height="32" rx="16" fill="#101A2A" stroke="#22314A" stroke-width="1" opacity="1"/><circle cx="100" cy="56" r="4.5" fill="#4EB0E8" opacity="1"/><text x="114" y="56" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="600" fill="#8FD3F5" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0.5">PART OF dsh-better-dsh</text><text x="80" y="116" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="44" font-weight="700" fill="#F1F5F9" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">Better Subagent</text><text x="80" y="154" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="17" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">@oh-my-dsh/dsh-better-subagent</text><text x="80" y="192" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="18" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">CLI 子代理 · wait · 分档</text><rect x="820" y="56" width="700" height="128" rx="16" fill="#101A2A" stroke="#22314A" stroke-width="1" opacity="1"/><text x="844" y="80" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="11" font-weight="600" fill="#6B7C93" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="1">BETTER DSH ECOSYSTEM</text><rect x="844" y="112" width="138" height="40" rx="9" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="913" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#CBD5E1" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Better DSH</text><rect x="990" y="112" width="92" height="40" rx="9" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="1036" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#CBD5E1" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Goal</text><rect x="1090" y="112" width="124" height="40" rx="9" fill="#A78BFA" stroke="#A78BFA" stroke-width="1" opacity="1"/><text x="1152" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="600" fill="#FFFFFF" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Subagent</text><circle cx="1152" cy="100" r="3" fill="#A78BFA" opacity="1"/><rect x="1222" y="112" width="116" height="40" rx="9" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="1280" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#CBD5E1" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Compact</text><rect x="1346" y="112" width="80" height="40" rx="9" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="1386" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#CBD5E1" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Ask</text><rect x="1434" y="112" width="70" height="40" rx="9" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="1469" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#CBD5E1" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">PTC</text><text x="844" y="208" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">同一份 profile · 同一稳定行 · 可独立安装</text></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1600" height="240" viewBox="0 0 1600 240" role="img" aria-labelledby="title desc"><title id="title">Part of Better DSH — Better Subagent</title><desc id="desc">Better Subagent 属于 Better DSH 插件集合,也可以独立安装。</desc><defs><pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse"><path d="M40 0H0V40" fill="none" stroke="#E6EDF5" stroke-width="1" opacity="0.7"/></pattern><radialGradient id="glow" cx="50%" cy="50%" r="50%"><stop offset="0%" stop-color="#2F80B7" stop-opacity="0.18"/><stop offset="100%" stop-color="#2F80B7" stop-opacity="0"/></radialGradient></defs><rect x="0" y="0" width="1600" height="240" fill="#F6F8FB"/><rect x="0" y="0" width="1600" height="240" fill="url(#grid)" opacity="0.55"/><rect x="0.5" y="0.5" width="1599" height="239" fill="none" stroke="#DCE5F0" stroke-width="1" opacity="0.9"/><ellipse cx="420" cy="120" rx="520" ry="220" fill="url(#glow)"/><rect x="80" y="40" width="286" height="32" rx="16" fill="#FFFFFF" stroke="#DCE5F0" stroke-width="1" opacity="1"/><circle cx="100" cy="56" r="4.5" fill="#2F80B7" opacity="1"/><text x="114" y="56" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="600" fill="#14587F" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0.5">PART OF dsh-better-dsh</text><text x="80" y="116" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="44" font-weight="700" fill="#0B1524" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">Better Subagent</text><text x="80" y="154" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="17" font-weight="400" fill="#5B6B80" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">@oh-my-dsh/dsh-better-subagent</text><text x="80" y="192" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="18" font-weight="400" fill="#334155" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">CLI 子代理 · wait · 分档</text><rect x="820" y="56" width="700" height="128" rx="16" fill="#FFFFFF" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="844" y="80" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="11" font-weight="600" fill="#8A99AC" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="1">BETTER DSH ECOSYSTEM</text><rect x="844" y="112" width="138" height="40" rx="9" fill="#F1F5F9" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="913" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#334155" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Better DSH</text><rect x="990" y="112" width="92" height="40" rx="9" fill="#F1F5F9" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="1036" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#334155" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Goal</text><rect x="1090" y="112" width="124" height="40" rx="9" fill="#7A5AF8" stroke="#7A5AF8" stroke-width="1" opacity="1"/><text x="1152" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="600" fill="#FFFFFF" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Subagent</text><circle cx="1152" cy="100" r="3" fill="#7A5AF8" opacity="1"/><rect x="1222" y="112" width="116" height="40" rx="9" fill="#F1F5F9" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="1280" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#334155" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Compact</text><rect x="1346" y="112" width="80" height="40" rx="9" fill="#F1F5F9" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="1386" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#334155" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">Ask</text><rect x="1434" y="112" width="70" height="40" rx="9" fill="#F1F5F9" stroke="#DCE5F0" stroke-width="1" opacity="1"/><text x="1469" y="132" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="500" fill="#334155" text-anchor="middle" dominant-baseline="middle" opacity="1" letter-spacing="0">PTC</text><text x="844" y="208" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="400" fill="#5B6B80" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">同一份 profile · 同一稳定行 · 可独立安装</text></svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1600" height="600" viewBox="0 0 1600 600" role="img" aria-labelledby="title desc"><title id="title">Better Subagent 与 Better DSH 的装配关系</title><desc id="desc">Better Subagent 由 Better DSH 装配,或独立安装;使用同一稳定行。</desc><defs>
2
+ <pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse"><path d="M40 0H0V40" fill="none" stroke="#122033" stroke-width="1" opacity="0.7"/></pattern>
3
+ <radialGradient id="glow" cx="50%" cy="50%" r="50%"><stop offset="0%" stop-color="#4EB0E8" stop-opacity="0.18"/><stop offset="100%" stop-color="#4EB0E8" stop-opacity="0"/></radialGradient>
4
+ <marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#22314A"/></marker>
5
+ <marker id="arrowA" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#4EB0E8"/></marker>
6
+ </defs><rect x="0" y="0" width="1600" height="600" fill="#0A101B"/><rect x="0" y="0" width="1600" height="600" fill="url(#grid)" opacity="0.55"/><rect x="0.5" y="0.5" width="1599" height="599" fill="none" stroke="#22314A" stroke-width="1" opacity="0.9"/><text x="80" y="72" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="38" font-weight="700" fill="#F1F5F9" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">与 Better DSH 的装配关系</text><text x="80" y="110" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="18" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">同一稳定行;独立安装或由 Better DSH 装配</text><rect x="80" y="150" width="400" height="300" rx="16" fill="#0F2A3D" stroke="#4EB0E8" stroke-width="1" opacity="1"/><text x="108" y="190" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="24" font-weight="700" fill="#F1F5F9" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">Better DSH bundle</text><text x="108" y="220" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="16" font-weight="400" fill="#8FD3F5" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">dsh-better-dsh</text><circle cx="116" cy="264" r="3.5" fill="#4EB0E8" opacity="1"/><text x="132" y="264" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">bundle patch 插入同一行</text><circle cx="116" cy="298" r="3.5" fill="#4EB0E8" opacity="1"/><text x="132" y="298" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">精确依赖 / 独立安装</text><circle cx="116" cy="332" r="3.5" fill="#4EB0E8" opacity="1"/><text x="132" y="332" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">旧 profile 兼容键保留</text><rect x="108" y="388" width="344" height="34" rx="9" fill="#060B12" stroke="#22314A" stroke-width="1" opacity="1"/><text x="124" y="405" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="12" font-weight="400" fill="#7CC8F2" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">dsh plugin add @oh-my-dsh/dsh-better-subagent</text><rect x="520" y="150" width="560" height="300" rx="16" fill="#101A2A" stroke="#22314A" stroke-width="1" opacity="1"/><rect x="520" y="150" width="560" height="6" rx="3" fill="#A78BFA"/><text x="548" y="190" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="26" font-weight="700" fill="#F1F5F9" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">Better Subagent</text><text x="548" y="220" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="15" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">@oh-my-dsh/dsh-better-subagent</text><rect x="548" y="240" width="190" height="28" rx="14" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="566" y="254" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="12" font-weight="500" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">dsh-better-subagent</text><text x="548" y="300" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" font-weight="600" fill="#6B7C93" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="1">这个插件拥有</text><circle cx="558" cy="330" r="3.5" fill="#A78BFA" opacity="1"/><text x="574" y="330" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">Codex / Claude CLI 适配</text><circle cx="558" cy="358" r="3.5" fill="#A78BFA" opacity="1"/><text x="574" y="358" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">wait_subagent</text><circle cx="558" cy="386" r="3.5" fill="#A78BFA" opacity="1"/><text x="574" y="386" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">运行中子代理退出守卫</text><circle cx="558" cy="414" r="3.5" fill="#A78BFA" opacity="1"/><text x="574" y="414" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">模型分档 / 路由</text><rect x="1120" y="150" width="400" height="300" rx="16" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="1148" y="190" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="24" font-weight="700" fill="#F1F5F9" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">DSH host</text><text x="1148" y="220" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="15" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">profile / Loader / settings</text><circle cx="1156" cy="264" r="3.5" fill="#4EB0E8" opacity="1"/><text x="1172" y="264" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">加载 bundle</text><circle cx="1156" cy="298" r="3.5" fill="#4EB0E8" opacity="1"/><text x="1172" y="298" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">注册行 / 工具 / client</text><circle cx="1156" cy="332" r="3.5" fill="#4EB0E8" opacity="1"/><text x="1172" y="332" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="16" font-weight="400" fill="#CBD5E1" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">设置写回 profile</text><text x="1148" y="396" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="14" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">设置:childExitGuard / tiers / CLI</text><line x1="480" y1="300" x2="518" y2="300" stroke="#4EB0E8" stroke-width="1.5" stroke-dasharray="5 7" marker-end="url(#arrowA)" opacity="1"/><text x="486" y="282" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">同一行</text><line x1="1080" y1="300" x2="1118" y2="300" stroke="#4EB0E8" stroke-width="1.5" marker-end="url(#arrowA)" opacity="1"/><text x="1086" y="282" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">注册</text><rect x="80" y="500" width="1440" height="52" rx="12" fill="#0D1624" stroke="#22314A" stroke-width="1" opacity="1"/><text x="104" y="526" font-family="Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" font-weight="400" fill="#9AA9BD" text-anchor="start" dominant-baseline="middle" opacity="1" letter-spacing="0">独立安装或随 Better DSH 安装都使用同一行;所有行 id 与设置命名空间保持稳定。</text></svg>