@chaoset/adaptive-perf 0.9.0 → 0.10.1
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/CHANGELOG.md +169 -152
- package/README.md +56 -162
- package/client/client.cjs +14 -6
- package/client/index.tsx +17 -6
- package/lib/index.d.ts +14 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +44 -12
- package/lib/index.js.map +1 -1
- package/lib/remote.d.ts.map +1 -1
- package/lib/remote.js +21 -0
- package/lib/remote.js.map +1 -1
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -1,116 +1,47 @@
|
|
|
1
1
|
# @chaoset/adaptive-perf — DSH 极简性能自适应插件
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
**resident 阶段**:保留 bootstrap 工具对 + 常驻发现工具(0.7.0 语义:
|
|
36
|
-
只锚定首轮,不减少后续功能;完整目录经 `dev_tool_search` 按需解锁——
|
|
37
|
-
晋升时一次性倒出完整目录会把轨迹拉回 standard-like,anchored-standard
|
|
38
|
-
实测的"晋升后回退"问题),常规注入(技能目录提醒 + AGENTS.md 摘要)
|
|
39
|
-
恢复可见;阶段从持久会话事件推导,**resume / reload 不丢状态**,晋升
|
|
40
|
-
信号**持久**(`compaction/end` 不重置,与 dsh-anchored-standard 一致);
|
|
41
|
-
- `maxTokens > 0` 时可给请求 #1 封顶输出预算(晋升后自动剥离)。
|
|
42
|
-
- **常驻上下文抑制(suppressInjectedContext,默认开启)**:整个会话持续
|
|
43
|
-
剥离技能目录提醒 + AGENTS.md 摘要注入——实测晋升后恢复注入会把轨迹拉回
|
|
44
|
-
standard-like("Let me…" 叙述回归),且每请求多耗数千 token。功能可见性
|
|
45
|
-
由常驻发现工具承担:`dev_tool_search` 搜索完整目录并按名解锁、
|
|
46
|
-
`skill_search` / `skill_load` 按需搜索/加载技能说明。设为 `false` 时只剥
|
|
47
|
-
离请求 #1,晋升后恢复常规注入(功能不减少但轨迹回退,opt-in)。
|
|
48
|
-
- **运行时上下文抑制**:对目标 preset 的会话调用 `suppressRuntimeContext()`
|
|
49
|
-
(与极简模式的 `includeRuntimeContext: false` 同一机制),每次模型请求省掉
|
|
50
|
-
"Current runtime context" 快照文本,**零功能损失**。
|
|
51
|
-
- **极简提示词层(minimalPrompt)**:参考实现的完整锚定条件——首轮轨迹由
|
|
52
|
-
**Minimal 的完整 system prompt** 决定,只收窄工具 schema 不够(标准/PTC 的
|
|
53
|
-
系统提示仍带 `harness:identity` / `harness:source` / `app:web-surface` 三个
|
|
54
|
-
全局引导段与标准 persona,思维链仍是 standard-like 的 "Let me…" 叙述)。本层
|
|
55
|
-
对目标会话:
|
|
56
|
-
- 按名阴影屏蔽三个全局引导段(空段在装配时被丢弃,等同极简 `complete`
|
|
57
|
-
persona 的效果;plan-mode 与 PTC 的 SDK 段不受影响);
|
|
58
|
-
- 按名阴影替换 `deployment:persona` 为极简语域 persona(默认与极简模式
|
|
59
|
-
逐字相同:`You are a helpful software engineer assistant.`);
|
|
60
|
-
- 挂载真实工具对时按名阴影 `tool:bash` 引导段(与可见工具一致)。
|
|
61
|
-
各处均为 agent 作用域的 prompt 段阴影,仅影响目标会话;**对已恢复/已晋升的
|
|
62
|
-
旧会话同样生效**(不依赖 bootstrap 阶段)。
|
|
63
|
-
- **工具目录自适应精简(leanByDefault,0.7.0 起为 opt-in)**:默认 `false` =
|
|
64
|
-
工具目录零裁剪,编排类工具族(子代理 / 工作流 / ralph / goal)始终可用。
|
|
65
|
-
设为 `true` 时会话启动按"工具族"隐藏高开销低频工具,只保留核心编码工具
|
|
66
|
-
(bash / 文件读写编辑 / 检索 / jobs / todo / 提问 / 网页搜索 / 技能 / 计划),
|
|
67
|
-
标准模式的工具目录因此逼近极简;PTC 模式系统提示里的 **SDK 参考段同步缩小**。
|
|
68
|
-
- **需求信号自动放行**(会话内单调升级,只升不降,限制请求缓存失效次数):
|
|
69
|
-
- 关键词信号:用户消息命中工具族触发词(如"子代理"、"工作流")→ 放行该族;
|
|
70
|
-
- 失败信号:PTC 程序调用被隐藏工具报 `UNKNOWN_TOOL` → 放行该族,下次即可调用。
|
|
71
|
-
|
|
72
|
-
所有开关与工具族可在设置页配置、随时放行;配置保存后**热生效**(无需重启)。
|
|
73
|
-
|
|
74
|
-
## 为什么极简模式最快(源码对照 + 社区实测结论)
|
|
75
|
-
|
|
76
|
-
| 维度 | 极简模式 | 标准 / PTC 模式 | 本插件做法 |
|
|
77
|
-
|---|---|---|---|
|
|
78
|
-
| 首轮轨迹(决定后续行为风格) | Minimal 真实工具对锚定(5/5) | 任何 standard 系 schema(含 sandboxed bash)落入 standard-like(11/11) | realPair 挂载官方同款插件:请求 #1 的 schema 与 Minimal 逐字相同 |
|
|
79
|
-
| 首轮注入提醒 | 无 skill 目录/AGENTS.md 注入 | 自动注入(在场时锚定 0/9) | 请求 #1 剥离 `skill-catalog` + `agent-instructions` |
|
|
80
|
-
| 后置阶段注入 | 永不注入 | 晋升后每请求恢复 ~9KB 目录 + AGENTS.md 全文 | 默认全程剥离(发现工具承担可见性);`suppressInjectedContext=false` opt-in 恢复 |
|
|
81
|
-
| 系统提示语域(persona + 全局引导段) | 一句话 persona,无任何引导段 | identity/source/web-surface 引导段 + 标准 persona("Let me…" 叙述来源) | minimalPrompt 层按名阴影屏蔽 3 个全局段 + 替换极简 persona(对旧会话同样生效) |
|
|
82
|
-
| 运行时上下文快照 | 关闭(`includeRuntimeContext: false`) | 每次请求注入文件策略/审批策略等快照 | 同一机制:`suppressRuntimeContext()` |
|
|
83
|
-
| 模型可见工具目录 | 2 个(bash、str_replace_editor) | ~22 个工具 schema 全部进请求 | 首轮 2 个;晋升后 resident(2 + 3 个发现工具,完整目录按需解锁);opt-in lean 时隐藏编排族按需放行 |
|
|
84
|
-
| PTC SDK 参考段 | 无 | 全部工具的类型+描述渲染进提示 | 随目录缩小(同一 `visible` 视图驱动) |
|
|
85
|
-
|
|
86
|
-
## 安装(npm 生态方式)
|
|
87
|
-
|
|
88
|
-
本包是 DSH bundle:自带 `cordis.patch.yml`,使用 `dsh plugin` 安装后会
|
|
89
|
-
自动加入 profile 的 `dsh.profile.bundles`,无需手改 `cordis.patch.yml`。
|
|
90
|
-
|
|
91
|
-
> 给 AI agent:直接执行下面的 `dsh plugin ...` 命令即可,不要手动编辑 `cordis.patch.yml`。
|
|
3
|
+
让标准(standard)/ PTC(code)/ 创造(cordis)模式达到极简模式级别的高性能,
|
|
4
|
+
同时保留完整能力——不是静态裁剪,而是动态自适应。锚定条件参照社区实测的
|
|
5
|
+
[dsh-anchored-standard](https://github.com/xiaobright/dsh-anchored-standard/)。
|
|
6
|
+
|
|
7
|
+
- **首轮锚定(bootstrap,默认开启)**:请求 #1 按极简模式条件组装——挂载官方
|
|
8
|
+
minimal preset 同款**真实工具对**(持久 PTY bash + `str_replace_editor`,
|
|
9
|
+
schema 与 Minimal 逐字相同),剥离技能目录提醒(`skill-catalog`)与
|
|
10
|
+
AGENTS.md 摘要(`agent-instructions`)注入,可选封顶首轮输出预算。首个持久
|
|
11
|
+
晋升信号(首个 `tool/call` 或 `assistant/message`)后进入 resident 阶段:
|
|
12
|
+
保留工具对与常驻发现工具(`dev_tool_search` / `skill_search` / `skill_load`),
|
|
13
|
+
完整目录经 `dev_tool_search` 按需解锁,常规注入恢复可见。阶段从持久会话事件
|
|
14
|
+
推导,resume / reload / compaction 不丢状态。
|
|
15
|
+
- **常驻上下文抑制(suppressInjectedContext,默认开启)**:整个会话持续剥离
|
|
16
|
+
技能目录提醒与 AGENTS.md 摘要注入,功能可见性由发现工具承担;设为 `false`
|
|
17
|
+
时只在请求 #1 剥离,晋升后恢复常规注入。
|
|
18
|
+
- **运行时上下文抑制(suppressRuntimeContext,默认开启)**:与极简模式同一
|
|
19
|
+
机制关闭运行时快照注入,每次请求省掉快照文本,零功能损失。
|
|
20
|
+
- **极简提示词层(minimalPrompt,默认开启)**:屏蔽三个全局引导段
|
|
21
|
+
(`harness:identity` / `harness:source` / `app:web-surface`)并把 persona
|
|
22
|
+
替换为极简语域文本,让系统提示回到极简语域;对已恢复/已晋升的旧会话同样生效。
|
|
23
|
+
- **工具目录精简(leanByDefault,默认关闭)**:默认零裁剪。开启后按「工具族」
|
|
24
|
+
隐藏编排类工具(子代理/工作流/ralph/goal),只保留核心编码工具,标准模式的
|
|
25
|
+
工具目录逼近极简,PTC 的 SDK 参考段同步缩小。
|
|
26
|
+
- **需求信号自动放行**:用户消息命中工具族触发词,或 PTC 程序调用被隐藏工具报
|
|
27
|
+
`UNKNOWN_TOOL` 时,放行对应工具族(会话内单调升级,只升不降)。
|
|
28
|
+
|
|
29
|
+
所有开关与工具族可在设置页配置,保存后热生效(无需重启)。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
本包是 DSH bundle:自带 `cordis.patch.yml`,`dsh plugin` 安装后自动加入
|
|
34
|
+
profile 的 `dsh.profile.bundles`,无需手改 `cordis.patch.yml`。
|
|
92
35
|
|
|
93
36
|
```bash
|
|
94
|
-
# 安装到默认 web profile
|
|
95
37
|
dsh plugin --profile web add @chaoset/adaptive-perf
|
|
96
|
-
|
|
97
|
-
# 指定其他 profile
|
|
98
|
-
dsh plugin --profile tui add @chaoset/adaptive-perf
|
|
99
|
-
|
|
100
|
-
# 卸载
|
|
101
38
|
dsh plugin --profile web remove @chaoset/adaptive-perf
|
|
102
39
|
```
|
|
103
40
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- **GitHub**:如果该包有独立 Git 仓库或 Release tarball,可用
|
|
107
|
-
`dsh plugin --profile web add github:owner/repo` 或
|
|
108
|
-
`dsh plugin --profile web add https://github.com/owner/repo/releases/download/v1.0.0/adaptive-perf.tgz`
|
|
109
|
-
- **镜像站**:`dsh plugin --profile web add @chaoset/adaptive-perf --registry=https://registry.npmmirror.com`
|
|
41
|
+
也支持本地路径 / GitHub / 镜像站安装,见仓库根 `README.md` 的「安装」。
|
|
42
|
+
安装后重启 harness 生效。
|
|
110
43
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
安装后**重启 harness** 生效(或等待 DSH 对配置层变更的响应)。
|
|
44
|
+
> 给 AI agent:直接执行 `dsh plugin ...` 命令即可,不要手动编辑 `cordis.patch.yml`。
|
|
114
45
|
|
|
115
46
|
## 配置
|
|
116
47
|
|
|
@@ -120,22 +51,22 @@ dsh plugin --profile web remove @chaoset/adaptive-perf
|
|
|
120
51
|
2. bundle patch 中 `cordis.patch.yml` 的 config
|
|
121
52
|
3. 用户 profile/home 的 `cordis.patch.yml` 覆盖
|
|
122
53
|
4. **DSH 设置页 → 插件配置 → 极简性能自适应**(保存到
|
|
123
|
-
|
|
54
|
+
`~/.dsh/plugins/adaptive-perf/config.json`,立即热生效)
|
|
124
55
|
|
|
125
56
|
| 字段 | 默认值 | 说明 |
|
|
126
57
|
|---|---|---|
|
|
127
58
|
| `enabled` | `true` | 总开关 |
|
|
128
|
-
| `presets` | `["standard", "code", "cordis"]` | 应用自适应的 preset id |
|
|
59
|
+
| `presets` | `["standard", "code", "ptc", "cordis"]` | 应用自适应的 preset id |
|
|
129
60
|
| `suppressRuntimeContext` | `true` | 抑制运行时上下文快照(零功能损失) |
|
|
130
|
-
| `suppressInjectedContext` | `true` |
|
|
131
|
-
| `leanByDefault` | `false` | 工具目录精简(opt-in):`true` =
|
|
61
|
+
| `suppressInjectedContext` | `true` | 整个会话剥离技能目录/AGENTS.md 注入;`false` = 只在请求 #1 剥离,晋升后恢复 |
|
|
62
|
+
| `leanByDefault` | `false` | 工具目录精简(opt-in):`true` = 会话启动即隐藏编排类工具族 |
|
|
132
63
|
| `escalateOnKeyword` | `true` | 用户消息命中触发词 → 放行该族(匹配方式见 `keywordMatchMode`) |
|
|
133
|
-
| `keywordMatchMode` | `"smart"` |
|
|
64
|
+
| `keywordMatchMode` | `"smart"` | `smart` = 含 CJK 的触发词子串匹配、纯 ASCII 词词边界匹配;`substring` = 一律子串;`word` = 一律词边界 |
|
|
134
65
|
| `escalateOnUnknownTool` | `true` | 工具调用失败(UNKNOWN_TOOL)→ 放行该族 |
|
|
135
66
|
| `coreTools` | 核心编码工具 | 展示用:不进入任何限制族 |
|
|
136
67
|
| `families` | 见下 | 工具族:`{ 族名: { enabled, tools, keywords } }` |
|
|
137
|
-
| `bootstrap` | 见下 |
|
|
138
|
-
| `minimalPrompt` | 见下 |
|
|
68
|
+
| `bootstrap` | 见下 | 首轮锚定 |
|
|
69
|
+
| `minimalPrompt` | 见下 | 极简提示词层 |
|
|
139
70
|
|
|
140
71
|
`bootstrap`(首轮锚定):
|
|
141
72
|
|
|
@@ -151,28 +82,18 @@ dsh plugin --profile web remove @chaoset/adaptive-perf
|
|
|
151
82
|
}
|
|
152
83
|
```
|
|
153
84
|
|
|
154
|
-
- `realPair
|
|
155
|
-
`str_replace_editor
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
- `tools`:请求 #1 可见的工具(真实 Minimal 对)。
|
|
85
|
+
- `realPair`:挂载官方 minimal preset 同款插件(持久 PTY bash +
|
|
86
|
+
`str_replace_editor`),请求 #1 的 schema 与 Minimal 逐字相同。依赖
|
|
87
|
+
`@deepseek-ai` 官方插件包(optionalDependencies);缺失或 Windows(无 PTY
|
|
88
|
+
后端)时自动降级为「仅收窄目录」并告警。
|
|
89
|
+
- `tools`:请求 #1 可见的工具。
|
|
160
90
|
- `promoteOn`:`either`(默认)/ `tool-call` / `assistant-message`。
|
|
161
91
|
- `suppressedContextSources`:首轮剥离的自动注入 source.kind;`[]` 关闭剥离。
|
|
162
|
-
- `discoveryTools
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
~9KB 技能目录)。
|
|
166
|
-
- `maxTokens`:请求 #1 输出预算封顶(0 = 不封顶,opt-in)。
|
|
167
|
-
|
|
168
|
-
> 0.7.0 破坏性变更:移除 `skillDiscovery` / `instructionHint` /
|
|
169
|
-
> `bootstrap.compactionTools` 三个字段(resident 语义下不再需要:
|
|
170
|
-
> `dev_tool_search` 常驻提供按需发现,无压缩回退、无指令提示补偿);
|
|
171
|
-
> `bootstrap.discoveryTools` **恢复**为 resident 目录的常驻发现工具
|
|
172
|
-
> (默认 `dev_tool_search` / `skill_search` / `skill_load`)。已保存的旧配置
|
|
173
|
-
> 会自动忽略被移除字段。
|
|
92
|
+
- `discoveryTools`:晋升后常驻的发现工具——`dev_tool_search` 搜索完整目录并
|
|
93
|
+
按名解锁,`skill_search` / `skill_load` 按需搜索/加载技能说明。
|
|
94
|
+
- `maxTokens`:请求 #1 输出预算封顶(0 = 不封顶)。
|
|
174
95
|
|
|
175
|
-
`minimalPrompt
|
|
96
|
+
`minimalPrompt`(极简提示词层):
|
|
176
97
|
|
|
177
98
|
```json
|
|
178
99
|
{
|
|
@@ -184,11 +105,9 @@ dsh plugin --profile web remove @chaoset/adaptive-perf
|
|
|
184
105
|
|
|
185
106
|
- `persona`:按名阴影替换 `deployment:persona`;默认与极简模式逐字相同,留空
|
|
186
107
|
(`""`)则不替换。
|
|
187
|
-
- `suppressSections`:屏蔽 `harness:identity` / `harness:source` /
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
- 生效范围:目标 preset 的全部会话,**包括已恢复/已晋升的旧会话**(不依赖
|
|
191
|
-
bootstrap 阶段);配置保存后热生效。
|
|
108
|
+
- `suppressSections`:屏蔽 `harness:identity` / `harness:source` /
|
|
109
|
+
`app:web-surface` 三个全局引导段(plan-mode 与 PTC 的 SDK 段不受影响)。
|
|
110
|
+
- 生效范围:目标 preset 的全部会话,包括已恢复/已晋升的旧会话。
|
|
192
111
|
|
|
193
112
|
默认工具族(可整族禁用、改名、增删触发词):
|
|
194
113
|
|
|
@@ -202,30 +121,5 @@ dsh plugin --profile web remove @chaoset/adaptive-perf
|
|
|
202
121
|
```
|
|
203
122
|
|
|
204
123
|
> 工具名只在目标 preset 目录中**实际存在**时才被隐藏(运行时取交集),preset
|
|
205
|
-
>
|
|
206
|
-
>
|
|
207
|
-
|
|
208
|
-
## 实现要点
|
|
209
|
-
|
|
210
|
-
- 监听 host 根作用域的 `agent/created` / `agent/disposed` / `agent/inbox/inserted`
|
|
211
|
-
/ `tools/result`(与 `dsh-agent-presets` 自身同款事件用法),按
|
|
212
|
-
`agentPresets.composedPreset(agent.ctx)` 识别目标 preset
|
|
213
|
-
- **真实工具对**:`agent.ctx.plugin()` 把 `dsh-terminal` + `dsh-terminal-bash`
|
|
214
|
-
+ `dsh-tool-bash-persistent`(Minimal 逐字描述)+ `dsh-fs-local` +
|
|
215
|
-
`dsh-tool-str-replace-editor` 挂进 agent 作用域;scoped registration 按名
|
|
216
|
-
阴影继承的 sandboxed bash,且 `view()` 对 own layer 豁免 restrict——首轮
|
|
217
|
-
目录 = 真实工具对 + 被 deny 的其他继承工具;每个挂载是独立 fiber,
|
|
218
|
-
agent 销毁/插件卸载/配置关闭时全部撤销
|
|
219
|
-
- 限制通过 `agent.ctx.tools.restrict({ deny })` 逐族注册:多族限制自动取交集,
|
|
220
|
-
升级 = 释放该族 disposer(单会话单调、一次性目录变化,缓存失效有界)
|
|
221
|
-
- 发现工具(`dev_tool_search` / `skill_search` / `skill_load`)同样注册在
|
|
222
|
-
agent 作用域:已解锁工具写入会话状态并重算 deny 集;技能经宿主 `skills`
|
|
223
|
-
服务按 agent scope 查询,`skill_load` 用 `agent.inject` 以
|
|
224
|
-
`skill-invocation` 来源注入(用户技能手势同款,不被默认抑制集剥离)
|
|
225
|
-
- 上下文剥离与 instruction-hint 都在 `agent/pre-step`(prepend 注册,最后
|
|
226
|
-
一道变换):剥离失败绝不吞用户上下文;指令文件探测走宿主 `fs`,失败不注入
|
|
227
|
-
- 会话启动/插件重载时用 `tools.schemas(agent)` 记录可见目录,限制与之取交集
|
|
228
|
-
- 全部副作用(抑制器、限制、工具注册、提示段、监听)随 agent 销毁或插件
|
|
229
|
-
卸载自动释放
|
|
230
|
-
- **fail-safe**:插件任何内部错误只记日志,不拖垮 harness;官方插件包缺失
|
|
231
|
-
时自动降级
|
|
124
|
+
> 升级改名/删除工具不会导致插件报错;限制按 agent 作用域生效,子代理同样遵循
|
|
125
|
+
> 自适应策略。
|
package/client/client.cjs
CHANGED
|
@@ -40,7 +40,7 @@ window.__ModuleLoader__.load({
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
var React = __toESM(require("react"), 1);
|
|
43
|
-
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_section{border-top:1px dashed var(--dsw-alias-border-l2);margin-top:8px;padding-top:2px}.ap_sectionHead{appearance:none;width:100%;font:inherit;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;align-items:center;justify-content:space-between;gap:8px;padding:6px 2px;display:flex}.ap_sectionHead:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ap_sectionTitle{font-size:12px;font-weight:600;line-height:18px}.ap_sectionChevron{flex:none;font-size:10px}.ap_sectionBody{flex-direction:column;display:flex}.ap_status.ap_error{color:var(--dsw-alias-state-error-primary)}.ap_badge_error{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px;max-width:260px;overflow:hidden;text-overflow:ellipsis}";
|
|
43
|
+
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_section{border-top:1px dashed var(--dsw-alias-border-l2);margin-top:8px;padding-top:2px}.ap_sectionHead{appearance:none;width:100%;font:inherit;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;align-items:center;justify-content:space-between;gap:8px;padding:6px 2px;display:flex}.ap_sectionHead:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ap_sectionTitle{font-size:12px;font-weight:600;line-height:18px}.ap_sectionChevron{flex:none;font-size:10px}.ap_sectionBody{flex-direction:column;display:flex}.ap_status.ap_error{color:var(--dsw-alias-state-error-primary)}.ap_badge_error{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.ap_spin{flex:none;width:10px;height:10px;border:1.5px solid var(--dsw-alias-border-l2);border-top-color:var(--dsw-alias-label-secondary);border-radius:50%;animation:ap-spin .8s linear infinite}@keyframes ap-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.ap_spin{animation:none}}";
|
|
44
44
|
var tagId = "@chaoset/adaptive-perf/client.css";
|
|
45
45
|
if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="' + tagId + '"]') === null) {
|
|
46
46
|
tag = document.createElement("style");
|
|
@@ -61,10 +61,11 @@ window.__ModuleLoader__.load({
|
|
|
61
61
|
saveFailed: "\u4FDD\u5B58\u5931\u8D25",
|
|
62
62
|
saved: "\u5DF2\u4FDD\u5B58\uFF0C\u70ED\u751F\u6548\uFF08\u65B0\u4F1A\u8BDD\u7ACB\u5373\u751F\u6548\uFF09",
|
|
63
63
|
loadFailed: "\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25",
|
|
64
|
+
loading: "\u52A0\u8F7D\u4E2D\u2026",
|
|
64
65
|
invalidFamilies: "families \u5FC5\u987B\u662F\u5408\u6CD5 JSON \u5BF9\u8C61",
|
|
65
66
|
enabled: "\u542F\u7528\u63D2\u4EF6",
|
|
66
67
|
presets: "\u76EE\u6807 preset",
|
|
67
|
-
fieldPresets: "\u9017\u53F7\u5206\u9694\u7684 preset id\uFF08\u5982 standard, code\uFF09\u3002\u7559\u7A7A = \u4E0D\u5E94\u7528\u4EFB\u4F55 preset",
|
|
68
|
+
fieldPresets: "\u9017\u53F7\u5206\u9694\u7684 preset id\uFF08\u5982 standard, code, ptc\uFF09\u3002\u7559\u7A7A = \u4E0D\u5E94\u7528\u4EFB\u4F55 preset",
|
|
68
69
|
suppressRuntimeContext: "\u6291\u5236\u8FD0\u884C\u65F6\u4E0A\u4E0B\u6587\u5FEB\u7167",
|
|
69
70
|
fieldSuppressRuntimeContext: "\u7B49\u540C\u6781\u7B80\u6A21\u5F0F\u7684 includeRuntimeContext: false\uFF0C\u6BCF\u6B21\u8BF7\u6C42\u7701\u6389\u5FEB\u7167\u6587\u672C\uFF08\u96F6\u529F\u80FD\u635F\u5931\uFF09",
|
|
70
71
|
leanByDefault: "\u542F\u52A8\u5373\u7CBE\u7B80\u5DE5\u5177\u76EE\u5F55",
|
|
@@ -113,10 +114,11 @@ window.__ModuleLoader__.load({
|
|
|
113
114
|
saveFailed: "Save failed",
|
|
114
115
|
saved: "Saved; hot-applied (new sessions take effect immediately)",
|
|
115
116
|
loadFailed: "Failed to load config",
|
|
117
|
+
loading: "Loading\u2026",
|
|
116
118
|
invalidFamilies: "families must be valid JSON object",
|
|
117
119
|
enabled: "Enable plugin",
|
|
118
120
|
presets: "Target presets",
|
|
119
|
-
fieldPresets: "Comma-separated preset ids (e.g. standard, code). Empty = apply to no preset.",
|
|
121
|
+
fieldPresets: "Comma-separated preset ids (e.g. standard, code, ptc). Empty = apply to no preset.",
|
|
120
122
|
suppressRuntimeContext: "Suppress runtime-context snapshot",
|
|
121
123
|
fieldSuppressRuntimeContext: "Same as minimal's includeRuntimeContext: false; drops the snapshot text from every request (zero feature loss)",
|
|
122
124
|
leanByDefault: "Lean tool catalog at session start",
|
|
@@ -329,7 +331,7 @@ window.__ModuleLoader__.load({
|
|
|
329
331
|
React.createElement(TextField, {
|
|
330
332
|
label: t("presets"),
|
|
331
333
|
hint: t("fieldPresets"),
|
|
332
|
-
value: draft === null ? "standard, code, cordis" : (draft.presets || []).join(", "),
|
|
334
|
+
value: draft === null ? "standard, code, ptc, cordis" : (draft.presets || []).join(", "),
|
|
333
335
|
disabled: draft === null,
|
|
334
336
|
onChange: (v) => setDraft({ ...draft, presets: v.split(/[,,\s]+/).filter((x) => x.length > 0) })
|
|
335
337
|
}),
|
|
@@ -506,8 +508,14 @@ window.__ModuleLoader__.load({
|
|
|
506
508
|
{ className: "ap_footer" },
|
|
507
509
|
React.createElement(
|
|
508
510
|
"span",
|
|
509
|
-
{
|
|
510
|
-
|
|
511
|
+
{
|
|
512
|
+
className: "ap_status" + (status !== null && status.kind === "error" ? " ap_error" : ""),
|
|
513
|
+
role: "status",
|
|
514
|
+
// 初次读取配置期间给出加载提示:此前字段只以禁用态显示默认值,
|
|
515
|
+
// 无法区分加载中与加载失败。
|
|
516
|
+
style: status === null && draft === null ? { display: "inline-flex", alignItems: "center", gap: "5px" } : void 0
|
|
517
|
+
},
|
|
518
|
+
status !== null ? status.text : draft === null ? [React.createElement("span", { className: "ap_spin", key: "spin", "aria-hidden": true }), t("loading")] : ""
|
|
511
519
|
),
|
|
512
520
|
React.createElement(
|
|
513
521
|
"button",
|
package/client/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
3
|
|
|
4
4
|
// ── 样式(注入 style 标签,模仿官方卡片外观)──────────────────────────
|
|
5
|
-
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_section{border-top:1px dashed var(--dsw-alias-border-l2);margin-top:8px;padding-top:2px}.ap_sectionHead{appearance:none;width:100%;font:inherit;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;align-items:center;justify-content:space-between;gap:8px;padding:6px 2px;display:flex}.ap_sectionHead:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ap_sectionTitle{font-size:12px;font-weight:600;line-height:18px}.ap_sectionChevron{flex:none;font-size:10px}.ap_sectionBody{flex-direction:column;display:flex}.ap_status.ap_error{color:var(--dsw-alias-state-error-primary)}.ap_badge_error{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px;max-width:260px;overflow:hidden;text-overflow:ellipsis}";
|
|
5
|
+
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_section{border-top:1px dashed var(--dsw-alias-border-l2);margin-top:8px;padding-top:2px}.ap_sectionHead{appearance:none;width:100%;font:inherit;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;align-items:center;justify-content:space-between;gap:8px;padding:6px 2px;display:flex}.ap_sectionHead:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ap_sectionTitle{font-size:12px;font-weight:600;line-height:18px}.ap_sectionChevron{flex:none;font-size:10px}.ap_sectionBody{flex-direction:column;display:flex}.ap_status.ap_error{color:var(--dsw-alias-state-error-primary)}.ap_badge_error{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.ap_spin{flex:none;width:10px;height:10px;border:1.5px solid var(--dsw-alias-border-l2);border-top-color:var(--dsw-alias-label-secondary);border-radius:50%;animation:ap-spin .8s linear infinite}@keyframes ap-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.ap_spin{animation:none}}";
|
|
6
6
|
var tagId = "@chaoset/adaptive-perf/client.css";
|
|
7
7
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
|
|
8
8
|
var tag = document.createElement("style");
|
|
@@ -24,10 +24,11 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
24
24
|
saveFailed: "保存失败",
|
|
25
25
|
saved: "已保存,热生效(新会话立即生效)",
|
|
26
26
|
loadFailed: "读取配置失败",
|
|
27
|
+
loading: "加载中…",
|
|
27
28
|
invalidFamilies: "families 必须是合法 JSON 对象",
|
|
28
29
|
enabled: "启用插件",
|
|
29
30
|
presets: "目标 preset",
|
|
30
|
-
fieldPresets: "逗号分隔的 preset id(如 standard, code)。留空 = 不应用任何 preset",
|
|
31
|
+
fieldPresets: "逗号分隔的 preset id(如 standard, code, ptc)。留空 = 不应用任何 preset",
|
|
31
32
|
suppressRuntimeContext: "抑制运行时上下文快照",
|
|
32
33
|
fieldSuppressRuntimeContext: "等同极简模式的 includeRuntimeContext: false,每次请求省掉快照文本(零功能损失)",
|
|
33
34
|
leanByDefault: "启动即精简工具目录",
|
|
@@ -76,10 +77,11 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
76
77
|
saveFailed: "Save failed",
|
|
77
78
|
saved: "Saved; hot-applied (new sessions take effect immediately)",
|
|
78
79
|
loadFailed: "Failed to load config",
|
|
80
|
+
loading: "Loading…",
|
|
79
81
|
invalidFamilies: "families must be valid JSON object",
|
|
80
82
|
enabled: "Enable plugin",
|
|
81
83
|
presets: "Target presets",
|
|
82
|
-
fieldPresets: "Comma-separated preset ids (e.g. standard, code). Empty = apply to no preset.",
|
|
84
|
+
fieldPresets: "Comma-separated preset ids (e.g. standard, code, ptc). Empty = apply to no preset.",
|
|
83
85
|
suppressRuntimeContext: "Suppress runtime-context snapshot",
|
|
84
86
|
fieldSuppressRuntimeContext: "Same as minimal's includeRuntimeContext: false; drops the snapshot text from every request (zero feature loss)",
|
|
85
87
|
leanByDefault: "Lean tool catalog at session start",
|
|
@@ -298,7 +300,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
298
300
|
React.createElement(TextField, {
|
|
299
301
|
label: t("presets"),
|
|
300
302
|
hint: t("fieldPresets"),
|
|
301
|
-
value: draft === null ? "standard, code, cordis" : (draft.presets || []).join(", "),
|
|
303
|
+
value: draft === null ? "standard, code, ptc, cordis" : (draft.presets || []).join(", "),
|
|
302
304
|
disabled: draft === null,
|
|
303
305
|
onChange: (v: any) => setDraft({ ...draft, presets: v.split(/[,,\s]+/).filter((x: any) => x.length > 0) })
|
|
304
306
|
}),
|
|
@@ -461,8 +463,17 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
461
463
|
{ className: "ap_footer" },
|
|
462
464
|
React.createElement(
|
|
463
465
|
"span",
|
|
464
|
-
{
|
|
465
|
-
|
|
466
|
+
{
|
|
467
|
+
className: "ap_status" + (status !== null && status.kind === "error" ? " ap_error" : ""),
|
|
468
|
+
role: "status",
|
|
469
|
+
// 初次读取配置期间给出加载提示:此前字段只以禁用态显示默认值,
|
|
470
|
+
// 无法区分加载中与加载失败。
|
|
471
|
+
style: status === null && draft === null ? { display: "inline-flex", alignItems: "center", gap: "5px" } : void 0
|
|
472
|
+
},
|
|
473
|
+
status !== null ? status.text
|
|
474
|
+
: draft === null
|
|
475
|
+
? [React.createElement("span", { className: "ap_spin", key: "spin", "aria-hidden": true }), t("loading")]
|
|
476
|
+
: ""
|
|
466
477
|
),
|
|
467
478
|
React.createElement(
|
|
468
479
|
"button",
|
package/lib/index.d.ts
CHANGED
|
@@ -135,7 +135,9 @@ export declare const name = "adaptive-perf";
|
|
|
135
135
|
export declare const DEFAULT_CONFIG: {
|
|
136
136
|
/** 总开关:关闭后插件对会话不产生任何影响。 */
|
|
137
137
|
enabled: boolean;
|
|
138
|
-
/** 应用自适应的 agent preset 列表(composedPreset 返回值)。
|
|
138
|
+
/** 应用自适应的 agent preset 列表(composedPreset 返回值)。'ptc' 是
|
|
139
|
+
* DSH 0.1.2 起对原 'code'(PTC 模式)的重命名;保留 'code' 兼容
|
|
140
|
+
* 0.1.1-rc.x 安装版宿主,宿主不存在的 id 不会有会话命中,无副作用。 */
|
|
139
141
|
presets: string[];
|
|
140
142
|
/**
|
|
141
143
|
* 默认策略(0.7.0):首轮锚定、晋升后 resident 目录(dsh-anchored-standard
|
|
@@ -245,8 +247,13 @@ export declare function normalizeConfig(source: any, defaults?: any): any;
|
|
|
245
247
|
/** remote.set 的严格校验:非法值直接拒绝并返回错误,而不是静默写坏文件。 */
|
|
246
248
|
export declare const MATCH_MODES: string[];
|
|
247
249
|
export declare function validateConfig(partial: any): void;
|
|
248
|
-
/**
|
|
249
|
-
*
|
|
250
|
+
/**
|
|
251
|
+
* 被极简提示词层屏蔽的全局引导段(name, order)。段名与 dsh-app-boot /
|
|
252
|
+
* dsh-web-app 的注册一致;阴影按 name 覆盖(宿主 layer.sections.insert 按
|
|
253
|
+
* name upsert),order 仅参与最终排序、不参与匹配,且空段在装配时被丢弃。
|
|
254
|
+
* DSH 0.1.2 把这些段的 order 调整为 -1000/-900/-800(0.1.1 为
|
|
255
|
+
* -100/-99/-98),此处沿用 0.1.2 参考值,对新旧宿主效果一致。
|
|
256
|
+
*/
|
|
250
257
|
export declare const SECTION_SHADOWS: (string | number)[][];
|
|
251
258
|
/** persona 段的注册名与顺序(dsh-system-prompt 的 PERSONA_SECTION/PERSONA_ORDER)。 */
|
|
252
259
|
export declare const PERSONA_SECTION_NAME = "deployment:persona";
|
|
@@ -268,8 +275,9 @@ export declare function collectFailureText(result: any): string;
|
|
|
268
275
|
export declare const MINIMAL_BASH_DESCRIPTION: string;
|
|
269
276
|
/**
|
|
270
277
|
* 被真实工具对按名阴影的工具引导段:standard 的 sandboxed bash 注册了
|
|
271
|
-
* `tool:bash
|
|
272
|
-
*
|
|
278
|
+
* `tool:bash` 引导段,挂载真实工具对后该文本已与可见工具不符,按名阴影为
|
|
279
|
+
* 空段(装配时丢弃)。阴影按 name 覆盖,order 仅排序:DSH 0.1.2 的
|
|
280
|
+
* FIRST_PARTY_SECTION_ORDER.TOOL_BASH 为 1000(0.1.1 为 105),效果一致。
|
|
273
281
|
*/
|
|
274
282
|
export declare const TOOL_GUIDANCE_SHADOWS: (string | number)[][];
|
|
275
283
|
/** 真实工具对挂载所需的官方插件包说明符(声明在 optionalDependencies)。 */
|
|
@@ -283,7 +291,7 @@ export declare const REAL_PAIR_SPECS: {
|
|
|
283
291
|
/**
|
|
284
292
|
* 加载真实 Minimal 工具对所需模块。任一包不可用即整体返回 null(调用方
|
|
285
293
|
* 降级为旧行为),绝不抛出。
|
|
286
|
-
* @param importFn - 测试可注入的 import
|
|
294
|
+
* @param importFn - 测试可注入的 import 实现(默认经安装闭包 fallback 导入)。
|
|
287
295
|
*/
|
|
288
296
|
export declare function loadRealPairModules(importFn?: any): Promise<any>;
|
|
289
297
|
/**
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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|
73
73
|
* optionalDependencies)。它们不可用时本插件自动降级(告警 + 退回旧行为:
|
|
74
74
|
* 只收窄目录、不替换 schema),绝不拖垮 harness。
|
|
75
75
|
*/
|
|
76
|
+
import { createRequire } from 'node:module';
|
|
77
|
+
import { realpathSync } from 'node:fs';
|
|
78
|
+
import { homedir } from 'node:os';
|
|
79
|
+
import { join, resolve } from 'node:path';
|
|
80
|
+
import { pathToFileURL } from 'node:url';
|
|
76
81
|
import { createConfigStore } from './config-store.js';
|
|
77
82
|
// remote 服务(设置页 UI 的配置读写)可选:typert-protocol 不可用时
|
|
78
83
|
// 动态 import 失败,核心功能(自适应)照常工作。
|
|
@@ -109,8 +114,10 @@ export const name = 'adaptive-perf';
|
|
|
109
114
|
export const DEFAULT_CONFIG = {
|
|
110
115
|
/** 总开关:关闭后插件对会话不产生任何影响。 */
|
|
111
116
|
enabled: true,
|
|
112
|
-
/** 应用自适应的 agent preset 列表(composedPreset 返回值)。
|
|
113
|
-
|
|
117
|
+
/** 应用自适应的 agent preset 列表(composedPreset 返回值)。'ptc' 是
|
|
118
|
+
* DSH 0.1.2 起对原 'code'(PTC 模式)的重命名;保留 'code' 兼容
|
|
119
|
+
* 0.1.1-rc.x 安装版宿主,宿主不存在的 id 不会有会话命中,无副作用。 */
|
|
120
|
+
presets: ['standard', 'code', 'ptc', 'cordis'],
|
|
114
121
|
/**
|
|
115
122
|
* 默认策略(0.7.0):首轮锚定、晋升后 resident 目录(dsh-anchored-standard
|
|
116
123
|
* 语义)。非极简 preset 的会话:请求 #1 按极简条件组装(真实 Minimal 工具
|
|
@@ -396,12 +403,17 @@ export function validateConfig(partial) {
|
|
|
396
403
|
}
|
|
397
404
|
}
|
|
398
405
|
// ── 纯函数(导出便于回归测试)────────────────────────────────────────────
|
|
399
|
-
/**
|
|
400
|
-
*
|
|
406
|
+
/**
|
|
407
|
+
* 被极简提示词层屏蔽的全局引导段(name, order)。段名与 dsh-app-boot /
|
|
408
|
+
* dsh-web-app 的注册一致;阴影按 name 覆盖(宿主 layer.sections.insert 按
|
|
409
|
+
* name upsert),order 仅参与最终排序、不参与匹配,且空段在装配时被丢弃。
|
|
410
|
+
* DSH 0.1.2 把这些段的 order 调整为 -1000/-900/-800(0.1.1 为
|
|
411
|
+
* -100/-99/-98),此处沿用 0.1.2 参考值,对新旧宿主效果一致。
|
|
412
|
+
*/
|
|
401
413
|
export const SECTION_SHADOWS = [
|
|
402
|
-
['harness:identity', -
|
|
403
|
-
['harness:source', -
|
|
404
|
-
['app:web-surface', -
|
|
414
|
+
['harness:identity', -1000],
|
|
415
|
+
['harness:source', -900],
|
|
416
|
+
['app:web-surface', -800],
|
|
405
417
|
];
|
|
406
418
|
/** persona 段的注册名与顺序(dsh-system-prompt 的 PERSONA_SECTION/PERSONA_ORDER)。 */
|
|
407
419
|
export const PERSONA_SECTION_NAME = 'deployment:persona';
|
|
@@ -495,11 +507,12 @@ export const MINIMAL_BASH_DESCRIPTION = [
|
|
|
495
507
|
].join('\n');
|
|
496
508
|
/**
|
|
497
509
|
* 被真实工具对按名阴影的工具引导段:standard 的 sandboxed bash 注册了
|
|
498
|
-
* `tool:bash
|
|
499
|
-
*
|
|
510
|
+
* `tool:bash` 引导段,挂载真实工具对后该文本已与可见工具不符,按名阴影为
|
|
511
|
+
* 空段(装配时丢弃)。阴影按 name 覆盖,order 仅排序:DSH 0.1.2 的
|
|
512
|
+
* FIRST_PARTY_SECTION_ORDER.TOOL_BASH 为 1000(0.1.1 为 105),效果一致。
|
|
500
513
|
*/
|
|
501
514
|
export const TOOL_GUIDANCE_SHADOWS = [
|
|
502
|
-
['tool:bash',
|
|
515
|
+
['tool:bash', 1000],
|
|
503
516
|
];
|
|
504
517
|
/** 真实工具对挂载所需的官方插件包说明符(声明在 optionalDependencies)。 */
|
|
505
518
|
export const REAL_PAIR_SPECS = {
|
|
@@ -509,13 +522,32 @@ export const REAL_PAIR_SPECS = {
|
|
|
509
522
|
fsLocal: '@deepseek-ai/dsh-fs-local',
|
|
510
523
|
strReplaceEditor: '@deepseek-ai/dsh-tool-str-replace-editor',
|
|
511
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* 官方包默认导入:安装闭包共享 fallback($DSH_HOME/profiles/node_modules,
|
|
527
|
+
* harness 启动时 heal 出来的依赖闭包镜像,与 harness 同模块实例)优先,
|
|
528
|
+
* 失败再走本包依赖树。源码运行 + 本地路径安装时插件 realpath 在插件仓库,
|
|
529
|
+
* 裸 import 无法解析官方包,这一 fallback 是真实工具对能挂载的关键;
|
|
530
|
+
* npm 安装模式下它同样命中 harness 同源包,优于 profile 内的依赖副本。
|
|
531
|
+
* Node ESM 不支持目录导入:用包目录的 package.json 作 require 锚解析入口
|
|
532
|
+
* 文件(require.resolve 默认 realpath 化,得到 harness 同源实体路径)。
|
|
533
|
+
*/
|
|
534
|
+
function defaultRealPairImport(spec) {
|
|
535
|
+
try {
|
|
536
|
+
const dshHome = process.env.DSH_HOME?.trim() ? resolve(process.env.DSH_HOME) : join(homedir(), '.dsh');
|
|
537
|
+
const anchor = join(dshHome, 'profiles', 'node_modules', spec, 'package.json');
|
|
538
|
+
const real = realpathSync(createRequire(anchor).resolve(spec));
|
|
539
|
+
return import(pathToFileURL(real).href);
|
|
540
|
+
}
|
|
541
|
+
catch { }
|
|
542
|
+
return import(spec);
|
|
543
|
+
}
|
|
512
544
|
/**
|
|
513
545
|
* 加载真实 Minimal 工具对所需模块。任一包不可用即整体返回 null(调用方
|
|
514
546
|
* 降级为旧行为),绝不抛出。
|
|
515
|
-
* @param importFn - 测试可注入的 import
|
|
547
|
+
* @param importFn - 测试可注入的 import 实现(默认经安装闭包 fallback 导入)。
|
|
516
548
|
*/
|
|
517
549
|
export async function loadRealPairModules(importFn) {
|
|
518
|
-
const dynamicImport = importFn ??
|
|
550
|
+
const dynamicImport = importFn ?? defaultRealPairImport;
|
|
519
551
|
const modules = {};
|
|
520
552
|
for (const [key, spec] of Object.entries(REAL_PAIR_SPECS)) {
|
|
521
553
|
try {
|