dsh-efm-integration 0.4.2 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -45
- package/README.zh.md +18 -43
- package/client.js +42 -4
- package/lib/prompt/index.d.ts +5 -4
- package/lib/prompt/index.d.ts.map +1 -1
- package/lib/prompt/index.js +53 -16
- package/lib/prompt/index.js.map +1 -1
- package/lib/prompt/pure-mode.d.ts +54 -5
- package/lib/prompt/pure-mode.d.ts.map +1 -1
- package/lib/prompt/pure-mode.js +156 -24
- package/lib/prompt/pure-mode.js.map +1 -1
- package/lib/prompt/store.d.ts +19 -3
- package/lib/prompt/store.d.ts.map +1 -1
- package/lib/prompt/store.js +31 -8
- package/lib/prompt/store.js.map +1 -1
- package/lib/skill-router/index.js +2 -2
- package/lib/skill-router/index.js.map +1 -1
- package/lib/verification/index.js +2 -2
- package/lib/verification/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
English | [简体中文](README.zh.md)
|
|
4
4
|
|
|
5
5
|
`dsh-efm-integration` is a DeepSeek Harness (DSH) plugin bundle that adds coding
|
|
6
|
-
discipline, skill routing,
|
|
6
|
+
discipline, skill routing, and archived-session maintenance to the
|
|
7
7
|
same underlying model. It does not replace the model, fork DSH, or modify the
|
|
8
8
|
upstream DeepSeek Harness checkout.
|
|
9
9
|
|
|
@@ -14,7 +14,6 @@ upstream DeepSeek Harness checkout.
|
|
|
14
14
|
| `prompt` | Adds an action-first coding contract to the system prompt. |
|
|
15
15
|
| `skill-router` | Publishes `whenToUse` routing hints and injects `always-load` or resident skill bodies, deduplicating unchanged content. |
|
|
16
16
|
| `skill-guard` | Denies configured tools until their required skills have been loaded. |
|
|
17
|
-
| `verification` | Emits one corrective steer when a turn edits files without running a recognized verification command. |
|
|
18
17
|
| `command-guard` | Refuses long foreground sleeps and filesystem-root scans before execution. |
|
|
19
18
|
| `bundled-skill` | Ships the `powershell-usage` skill and exposes it without a user-directory copy. |
|
|
20
19
|
| `archive-cleaner` | Adds a sidebar page that permanently deletes archived Sessions and their descendants. |
|
|
@@ -105,21 +104,34 @@ takes effect from the next model step without restarting DSH. **恢复默认**
|
|
|
105
104
|
deletes the saved file and restores the bundled contract. Text is limited to
|
|
106
105
|
128 KiB (UTF-8).
|
|
107
106
|
|
|
108
|
-
|
|
107
|
+
The page also has an **agent preset** selector. The saved text can target one
|
|
108
|
+
DSH preset (`standard`, `minimal`, …) or **全部预设** (all presets, the original
|
|
109
|
+
global behavior). Only sessions using the target preset receive the replacement
|
|
110
|
+
and its pure-mode effects; other presets keep their own prompt, runtime context,
|
|
111
|
+
tools, and plugin injections. The selector lists the presets DSH currently
|
|
112
|
+
declares, hiding broken ones. A saved target that later disappears is reported
|
|
113
|
+
as unavailable and does not silently become global. Older single-prompt files
|
|
114
|
+
are migrated to the all-presets target.
|
|
115
|
+
|
|
116
|
+
A saved prompt activates **pure mode** for its target:
|
|
109
117
|
|
|
110
118
|
- The saved text becomes the only system prompt. Harness identity, skill
|
|
111
119
|
routing, MCP instructions, tool guidance, and other plugins' sections are not
|
|
112
120
|
sent.
|
|
113
|
-
- `skill-router`
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
- `skill-router` stops injecting user-role messages for those sessions.
|
|
122
|
+
- Runtime-context snapshots are stripped entirely — including the required
|
|
123
|
+
working-directory snapshot that plain suppression keeps. A session that
|
|
124
|
+
already retained a snapshot records one "runtime context: none" reminder when
|
|
125
|
+
pure mode starts applying; snapshots already committed to history are never
|
|
126
|
+
rewritten.
|
|
127
|
+
- Tools are denied for agents using the target preset (or for every agent with
|
|
128
|
+
the all-presets target), so the model receives no tool schemas and cannot
|
|
129
|
+
execute tools.
|
|
118
130
|
|
|
119
131
|
Deployment configuration wins: if `prompt`/`promptFile` is set on the plugin
|
|
120
132
|
row, the page is read-only and the configured replacement keeps its original
|
|
121
|
-
semantics (tools and runtime context remain). The management route
|
|
122
|
-
owner principal, a same-origin request, and the header
|
|
133
|
+
global semantics (tools and runtime context remain). The management route
|
|
134
|
+
requires an owner principal, a same-origin request, and the header
|
|
123
135
|
`x-dsh-efm-integration-confirm: SYSTEM_PROMPT_CHANGE`.
|
|
124
136
|
|
|
125
137
|
Pure mode has three limits: DSH records prompt changes as `system/message`
|
|
@@ -178,29 +190,6 @@ successful `skill` call, an explicit user skill invocation, a resident skill
|
|
|
178
190
|
injection, or a matching event in resumed session history satisfies the guard.
|
|
179
191
|
Additional tool/skill pairs can be added under the same configuration key.
|
|
180
192
|
|
|
181
|
-
## Verification gate
|
|
182
|
-
|
|
183
|
-
The gate recognises successful `write`, `edit`, `apply_patch`, and
|
|
184
|
-
`str_replace_editor` calls. If a turn stops after a mutation without a recognised
|
|
185
|
-
successful verification command, it emits one corrective steer.
|
|
186
|
-
|
|
187
|
-
The default command pattern covers npm/pnpm/yarn/bun `test`, `typecheck`, `lint`,
|
|
188
|
-
and `build`, plus pytest, vitest, jest, Cargo test, Go test, .NET test, Maven test,
|
|
189
|
-
and Gradle test. Override it for project-specific commands:
|
|
190
|
-
|
|
191
|
-
```yaml
|
|
192
|
-
- id: dsh-efm-integration-verification
|
|
193
|
-
config:
|
|
194
|
-
mutationTools:
|
|
195
|
-
- write
|
|
196
|
-
- edit
|
|
197
|
-
- apply_patch
|
|
198
|
-
verificationCommandPattern: '(?:^|\s)(?:just\s+test|make\s+check)\b'
|
|
199
|
-
maxRemindersPerTurn: 1
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
The reminder is advisory and limited to one continuation per turn by default.
|
|
203
|
-
|
|
204
193
|
## Legacy session repair
|
|
205
194
|
|
|
206
195
|
Earlier releases shipped `execution-budget` and `reasoning-budget` modules; both
|
|
@@ -269,7 +258,7 @@ model-facing `lsp` tool.
|
|
|
269
258
|
The seam offers exactly four read-only operations — `goToDefinition`,
|
|
270
259
|
`findReferences`, `goToImplementation`, and `hover`. DSH deliberately excludes
|
|
271
260
|
diagnostics, symbol lists, rename, and formatting, so this bundle does not add
|
|
272
|
-
them either. Use
|
|
261
|
+
them either. Use a compiler for correctness checks.
|
|
273
262
|
|
|
274
263
|
### Sidebar page
|
|
275
264
|
|
|
@@ -362,20 +351,11 @@ credentials in DSH's credential provider rather than in this bundle or its files
|
|
|
362
351
|
|
|
363
352
|
```powershell
|
|
364
353
|
pnpm install # runs `prepare` and builds lib/
|
|
365
|
-
pnpm test # all tests
|
|
366
|
-
pnpm run typecheck # src/ and tests/
|
|
367
354
|
pnpm run build # src/ -> lib/
|
|
368
355
|
```
|
|
369
356
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
```powershell
|
|
373
|
-
pnpm exec vitest run tests/skill-guard.test.ts
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
`lib/` is generated and not committed. `client.js` is maintained by hand; the
|
|
377
|
-
client tests execute it directly in a VM. Before packaging, build first and then
|
|
378
|
-
inspect the tarball:
|
|
357
|
+
`lib/` is generated and not committed. `client.js` is maintained by hand. Before
|
|
358
|
+
packaging, build first and then inspect the tarball:
|
|
379
359
|
|
|
380
360
|
```powershell
|
|
381
361
|
pnpm pack --pack-destination .pack
|
package/README.zh.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[English](README.md) | 简体中文
|
|
4
4
|
|
|
5
5
|
`dsh-efm-integration` 是一个 DeepSeek Harness(DSH)插件包,为同一个底层模型补上编码纪律、
|
|
6
|
-
|
|
6
|
+
技能路由以及归档会话维护能力。它不会替换模型、分叉 DSH,也不会修改上游的
|
|
7
7
|
DeepSeek Harness 代码。
|
|
8
8
|
|
|
9
9
|
## 增加了什么
|
|
@@ -13,7 +13,6 @@ DeepSeek Harness 代码。
|
|
|
13
13
|
| `prompt` | 在 system prompt 中加入"先行动"的编码契约。 |
|
|
14
14
|
| `skill-router` | 发布 `whenToUse` 路由提示,注入 `always-load` 或常驻技能正文,并对未变化的内容去重。 |
|
|
15
15
|
| `skill-guard` | 在所需技能加载完成之前拒绝被配置的工具。 |
|
|
16
|
-
| `verification` | 当一轮改动文件却没有执行可识别的验证命令时,发出一次纠正提示。 |
|
|
17
16
|
| `command-guard` | 在执行前拒绝长时间前台 sleep 与文件系统根目录扫描。 |
|
|
18
17
|
| `bundled-skill` | 随包提供 `powershell-usage` 技能,无需复制到用户目录。 |
|
|
19
18
|
| `archive-cleaner` | 增加一个可永久删除归档会话及其子会话的侧栏页面。 |
|
|
@@ -93,16 +92,24 @@ profile 中应包含 `dsh-efm-integration-client-anchor` 行,以及 `cordis.pa
|
|
|
93
92
|
`$DSH_HOME/plugins/dsh-efm-integration/system-prompt.json`,从下一个模型步骤开始生效,无需重启
|
|
94
93
|
DSH。**恢复默认**会删除该文件并恢复本包的执行契约。文本上限为 128 KiB(UTF-8)。
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
页面还提供 **agent 预设**选择器。保存的文本可以只针对某个 DSH 预设(`standard`、`minimal` 等),
|
|
96
|
+
也可以选择 **全部预设**(保持原有的全局行为)。只有使用该预设的会话会收到替换文本和纯净模式的
|
|
97
|
+
效果;其他预设保留各自的提示词、运行时上下文、工具和插件注入。选择器只列出 DSH 当前声明的可用
|
|
98
|
+
预设,故障预设会被隐藏。若已保存的目标预设后来消失,页面会提示它已失效,而不会悄悄变成全局生效。
|
|
99
|
+
旧版单段提示词会自动迁移为「全部预设」。
|
|
100
|
+
|
|
101
|
+
保存提示词后,目标会话进入**纯净模式**:
|
|
97
102
|
|
|
98
103
|
- 该文本成为唯一发送给模型的 system prompt;harness 身份、技能路由、MCP 说明、工具指引以及其他
|
|
99
104
|
插件的小节全部不发送。
|
|
100
|
-
- `skill-router`
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
- 这些会话中 `skill-router` 停止注入 user 角色消息。
|
|
106
|
+
- 运行时上下文快照被整体剥离——包括普通抑制拦不住的必需工作目录快照。已经保留过快照的会话,在
|
|
107
|
+
纯净模式开始生效时会记录一条「运行时上下文:无」的提醒;已提交进历史的快照不会被改写。
|
|
108
|
+
- 使用目标预设的 agent 的工具会被拒绝(选择「全部预设」时则对所有 agent 生效),因此模型看不到
|
|
109
|
+
工具 schema,也无法执行工具。
|
|
110
|
+
|
|
111
|
+
配置优先:如果插件行设置了 `prompt`/`promptFile`,页面只读,配置替换仍保持原有的全局语义(工具和
|
|
112
|
+
运行时上下文仍然存在)。管理路由要求 owner 身份、同源请求,以及
|
|
106
113
|
`x-dsh-efm-integration-confirm: SYSTEM_PROMPT_CHANGE` 请求头。
|
|
107
114
|
|
|
108
115
|
纯净模式有三点限制:DSH 会把提示词变更记录为 Session 里的 `system/message` 事件;直接在 agent
|
|
@@ -155,28 +162,6 @@ requiredSkillsByTool:
|
|
|
155
162
|
技能、常驻技能注入,或恢复的历史会话中匹配的事件,都能满足门禁要求。可以在同一个配置
|
|
156
163
|
键下追加更多"工具/技能"组合。
|
|
157
164
|
|
|
158
|
-
## 验证门
|
|
159
|
-
|
|
160
|
-
该门禁会识别成功的 `write`、`edit`、`apply_patch` 与 `str_replace_editor` 调用。如果一轮
|
|
161
|
-
在产生改动后停止,却没有执行可识别的成功验证命令,它会发出一次纠正提示。
|
|
162
|
-
|
|
163
|
-
默认命令模式覆盖 npm/pnpm/yarn/bun 的 `test`、`typecheck`、`lint`、`build`,以及 pytest、
|
|
164
|
-
vitest、jest、Cargo test、Go test、.NET test、Maven test 与 Gradle test。项目自定义命令可以
|
|
165
|
-
覆盖该模式:
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
- id: dsh-efm-integration-verification
|
|
169
|
-
config:
|
|
170
|
-
mutationTools:
|
|
171
|
-
- write
|
|
172
|
-
- edit
|
|
173
|
-
- apply_patch
|
|
174
|
-
verificationCommandPattern: '(?:^|\s)(?:just\s+test|make\s+check)\b'
|
|
175
|
-
maxRemindersPerTurn: 1
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
该提醒只是建议,默认每轮最多触发一次续跑。
|
|
179
|
-
|
|
180
165
|
## 修复旧版本写入的会话
|
|
181
166
|
|
|
182
167
|
更早的版本曾包含 `execution-budget` 与 `reasoning-budget` 两个模块,二者已在 0.4.0 中移除。
|
|
@@ -236,8 +221,7 @@ DSH 自带 LSP 栈(`@deepseek-ai/dsh-lsp`、`@deepseek-ai/dsh-lsp-stdio`、
|
|
|
236
221
|
provider,以及面向模型的 `lsp` 工具。
|
|
237
222
|
|
|
238
223
|
能力层只提供四个只读操作:`goToDefinition`、`findReferences`、`goToImplementation`、`hover`。
|
|
239
|
-
DSH
|
|
240
|
-
`verification`(或直接跑编译器)。
|
|
224
|
+
DSH 刻意不包含诊断、符号列表、重命名与格式化,本包也不额外提供。正确性校验请直接跑编译器。
|
|
241
225
|
|
|
242
226
|
### 侧栏页面
|
|
243
227
|
|
|
@@ -321,19 +305,10 @@ DSH 的 MCP 客户端支持按需加载工具,但本包不会改写不属于
|
|
|
321
305
|
|
|
322
306
|
```powershell
|
|
323
307
|
pnpm install # 会执行 prepare 并构建 lib/
|
|
324
|
-
pnpm test # 全部测试
|
|
325
|
-
pnpm run typecheck # 覆盖 src/ 与 tests/
|
|
326
308
|
pnpm run build # src/ -> lib/
|
|
327
309
|
```
|
|
328
310
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
```powershell
|
|
332
|
-
pnpm exec vitest run tests/skill-guard.test.ts
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
`lib/` 是生成产物且不提交。`client.js` 手工维护,客户端测试会直接在 VM 中执行它。打包前
|
|
336
|
-
请先构建,再检查 tarball:
|
|
311
|
+
`lib/` 是生成产物且不提交。`client.js` 手工维护。打包前请先构建,再检查 tarball:
|
|
337
312
|
|
|
338
313
|
```powershell
|
|
339
314
|
pnpm pack --pack-destination .pack
|
package/client.js
CHANGED
|
@@ -309,12 +309,18 @@ window.__ModuleLoader__.load({
|
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
function SystemPromptPage() {
|
|
312
|
-
const initial = {
|
|
312
|
+
const initial = {
|
|
313
|
+
loading: true, source: 'default', text: '', length: 0, pureMode: false,
|
|
314
|
+
lockedByConfig: false, maxPromptBytes: 0, error: '',
|
|
315
|
+
presets: [], targetPreset: null, defaultPresetId: '', targetPresetAvailable: true,
|
|
316
|
+
}
|
|
313
317
|
const [state, setState] = useState(initial)
|
|
314
318
|
const [draft, setDraft] = useState('')
|
|
319
|
+
const [draftTarget, setDraftTarget] = useState('all')
|
|
315
320
|
const [busy, setBusy] = useState(false)
|
|
316
321
|
|
|
317
322
|
const apply = (payload) => {
|
|
323
|
+
const target = !payload.targetPreset || payload.targetPreset === 'all' ? 'all' : payload.targetPreset
|
|
318
324
|
setState({
|
|
319
325
|
loading: false,
|
|
320
326
|
source: payload.source || 'default',
|
|
@@ -324,8 +330,13 @@ window.__ModuleLoader__.load({
|
|
|
324
330
|
lockedByConfig: payload.lockedByConfig === true,
|
|
325
331
|
maxPromptBytes: payload.maxPromptBytes || 0,
|
|
326
332
|
error: '',
|
|
333
|
+
presets: Array.isArray(payload.presets) ? payload.presets : [],
|
|
334
|
+
targetPreset: target === 'all' ? null : target,
|
|
335
|
+
defaultPresetId: payload.defaultPresetId || '',
|
|
336
|
+
targetPresetAvailable: payload.targetPresetAvailable !== false,
|
|
327
337
|
})
|
|
328
338
|
if (payload.source !== 'default') setDraft(payload.text || '')
|
|
339
|
+
setDraftTarget(target)
|
|
329
340
|
}
|
|
330
341
|
|
|
331
342
|
useEffect(() => {
|
|
@@ -367,13 +378,40 @@ window.__ModuleLoader__.load({
|
|
|
367
378
|
}
|
|
368
379
|
|
|
369
380
|
const sourceLabel = { config: '由 cordis.patch.yml 配置', custom: '自定义(纯净模式)', default: '默认执行契约' }[state.source] || state.source
|
|
381
|
+
const presetOptions = [{ value: 'all', label: '全部预设(保持原有全局行为)' }].concat(
|
|
382
|
+
state.presets.map(preset => ({
|
|
383
|
+
value: preset.id,
|
|
384
|
+
label: `${preset.name || preset.id}${preset.isDefault ? '(默认)' : ''}`,
|
|
385
|
+
})),
|
|
386
|
+
)
|
|
387
|
+
if (state.targetPreset && !state.presets.some(preset => preset.id === state.targetPreset)) {
|
|
388
|
+
presetOptions.push({ value: state.targetPreset, label: `${state.targetPreset}(已失效)` })
|
|
389
|
+
}
|
|
390
|
+
const targetLabel = state.targetPreset === null
|
|
391
|
+
? '全部预设'
|
|
392
|
+
: state.presets.find(preset => preset.id === state.targetPreset)?.name || state.targetPreset
|
|
370
393
|
|
|
371
394
|
return React.createElement('main', { style: pageStyle }, React.createElement('section', { style: cardStyle },
|
|
372
395
|
React.createElement('h1', { style: { margin: '0 0 12px', fontSize: '24px' } }, '系统提示词'),
|
|
373
396
|
React.createElement('p', { style: { color: '#aaa', lineHeight: 1.7 } },
|
|
374
|
-
'填入一段提示词并保存后,模型只会收到这段文字:技能路由、MCP
|
|
397
|
+
'填入一段提示词并保存后,模型只会收到这段文字:技能路由、MCP/工具说明、运行时上下文快照都会被去掉,工具调用也会被关闭。可选择只对某个 agent preset 生效,其他预设不受影响;“全部预设”保持原有全局行为。点击“恢复默认”可回到当前执行契约。'),
|
|
375
398
|
state.loading && React.createElement('p', null, '正在读取配置…'),
|
|
376
|
-
!state.loading && React.createElement('p', { style: { fontSize: '15px' } }, `当前来源:${sourceLabel};长度:${state.length} 字节;纯净模式:${state.pureMode ? '开启' : '关闭'}`),
|
|
399
|
+
!state.loading && React.createElement('p', { style: { fontSize: '15px' } }, `当前来源:${sourceLabel};长度:${state.length} 字节;纯净模式:${state.pureMode ? '开启' : '关闭'};目标预设:${targetLabel}`),
|
|
400
|
+
state.source === 'custom' && !state.targetPresetAvailable && React.createElement('div', { style: noticeStyle },
|
|
401
|
+
'当前目标预设已不在可用列表中,替换暂时不会生效。请重新选择预设,或恢复默认。'),
|
|
402
|
+
React.createElement('label', { style: { display: 'block', marginTop: '12px' } },
|
|
403
|
+
React.createElement('span', { style: { fontSize: '13px', color: '#999' } }, '替换范围(agent preset)'),
|
|
404
|
+
React.createElement('select', {
|
|
405
|
+
value: draftTarget,
|
|
406
|
+
onChange: event => setDraftTarget(event.target.value),
|
|
407
|
+
disabled: busy || state.lockedByConfig,
|
|
408
|
+
style: {
|
|
409
|
+
display: 'block', width: '100%', boxSizing: 'border-box', marginTop: '8px', padding: '10px',
|
|
410
|
+
borderRadius: '10px', border: '1px solid #555', background: '#0003', color: 'inherit',
|
|
411
|
+
},
|
|
412
|
+
}, presetOptions.map(option => React.createElement('option', {
|
|
413
|
+
key: option.value, value: option.value,
|
|
414
|
+
}, option.label)))),
|
|
377
415
|
state.lockedByConfig && React.createElement('div', { style: noticeStyle },
|
|
378
416
|
'cordis.patch.yml 已配置 prompt/promptFile,配置优先;此页面只读。'),
|
|
379
417
|
state.error && React.createElement('pre', {
|
|
@@ -399,7 +437,7 @@ window.__ModuleLoader__.load({
|
|
|
399
437
|
React.createElement('button', {
|
|
400
438
|
type: 'button',
|
|
401
439
|
disabled: busy || state.lockedByConfig || draft.trim().length === 0,
|
|
402
|
-
onClick: () => post({ action: 'save', text: draft }),
|
|
440
|
+
onClick: () => post({ action: 'save', text: draft, targetPreset: draftTarget }),
|
|
403
441
|
style: {
|
|
404
442
|
appearance: 'none', border: 0, borderRadius: '8px', padding: '10px 16px', cursor: 'pointer',
|
|
405
443
|
background: '#1f6f43', color: 'white', fontWeight: 600,
|
package/lib/prompt/index.d.ts
CHANGED
|
@@ -16,10 +16,11 @@ export interface Config {
|
|
|
16
16
|
/**
|
|
17
17
|
* Add the coding-agent execution contract to the system prompt, or replace the
|
|
18
18
|
* whole system prompt when `prompt` or `promptFile` is configured. A sidebar
|
|
19
|
-
* saved prompt
|
|
20
|
-
* waterfall substitutes it
|
|
21
|
-
* and denies
|
|
22
|
-
*
|
|
19
|
+
* saved prompt replaces the prompt of its target agent preset: the assembly
|
|
20
|
+
* waterfall substitutes it for matching agents, suppresses their optional
|
|
21
|
+
* runtime context, and denies their tools. The "all presets" target keeps the
|
|
22
|
+
* original global behavior. Deployment configuration still wins and makes the
|
|
23
|
+
* sidebar read-only.
|
|
23
24
|
* @param ctx - plugin context carrying the prompt, web server, and connection seams.
|
|
24
25
|
* @param config - optional complete replacement; invalid input fails at load.
|
|
25
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAgBlD,eAAO,MAAM,IAAI,+BAA+B,CAAA;AAChD,eAAO,MAAM,MAAM,UAA8C,CAAA;AAEjE,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAoCD;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoK5E"}
|
package/lib/prompt/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { MAX_BODY_BYTES, messageOf, readJson, sameOrigin, writeJson, writeText } from './http.js';
|
|
3
|
-
import { createPureMode } from './pure-mode.js';
|
|
4
|
-
import { clearStored, MAX_PROMPT_BYTES, readStored, validatePromptText, writeStored } from './store.js';
|
|
3
|
+
import { createPureMode, presetRegistryOf } from './pure-mode.js';
|
|
4
|
+
import { clearStored, MAX_PROMPT_BYTES, readStored, validatePromptText, validateTargetPreset, writeStored, } from './store.js';
|
|
5
5
|
export const name = 'dsh-efm-integration-prompt';
|
|
6
6
|
export const inject = ['systemPrompt', 'webServer', 'connection'];
|
|
7
7
|
const ROUTE = '/plugins/dsh-efm-integration/system-prompt';
|
|
@@ -39,10 +39,11 @@ const CONTRACT = `
|
|
|
39
39
|
/**
|
|
40
40
|
* Add the coding-agent execution contract to the system prompt, or replace the
|
|
41
41
|
* whole system prompt when `prompt` or `promptFile` is configured. A sidebar
|
|
42
|
-
* saved prompt
|
|
43
|
-
* waterfall substitutes it
|
|
44
|
-
* and denies
|
|
45
|
-
*
|
|
42
|
+
* saved prompt replaces the prompt of its target agent preset: the assembly
|
|
43
|
+
* waterfall substitutes it for matching agents, suppresses their optional
|
|
44
|
+
* runtime context, and denies their tools. The "all presets" target keeps the
|
|
45
|
+
* original global behavior. Deployment configuration still wins and makes the
|
|
46
|
+
* sidebar read-only.
|
|
46
47
|
* @param ctx - plugin context carrying the prompt, web server, and connection seams.
|
|
47
48
|
* @param config - optional complete replacement; invalid input fails at load.
|
|
48
49
|
*/
|
|
@@ -50,9 +51,12 @@ export async function apply(ctx, config = {}) {
|
|
|
50
51
|
const configured = await resolveReplacement(config);
|
|
51
52
|
const lockedByConfig = configured !== undefined;
|
|
52
53
|
let savedText = '';
|
|
54
|
+
let savedTarget = null;
|
|
53
55
|
if (!lockedByConfig) {
|
|
54
56
|
try {
|
|
55
|
-
|
|
57
|
+
const saved = await readStored();
|
|
58
|
+
savedText = saved?.text ?? '';
|
|
59
|
+
savedTarget = saved?.targetPreset ?? null;
|
|
56
60
|
}
|
|
57
61
|
catch (error) {
|
|
58
62
|
ctx.logger.warn(`system-prompt: ignoring unreadable saved prompt: ${messageOf(error)}`);
|
|
@@ -60,7 +64,7 @@ export async function apply(ctx, config = {}) {
|
|
|
60
64
|
}
|
|
61
65
|
const pure = createPureMode(ctx, lockedByConfig
|
|
62
66
|
? undefined
|
|
63
|
-
: { enabled: savedText.length > 0, text: savedText });
|
|
67
|
+
: { enabled: savedText.length > 0, text: savedText, targetPreset: savedTarget });
|
|
64
68
|
if (configured !== undefined) {
|
|
65
69
|
ctx.systemPrompt.section({
|
|
66
70
|
name: 'dsh-efm-integration:complete',
|
|
@@ -78,12 +82,17 @@ export async function apply(ctx, config = {}) {
|
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
if (!lockedByConfig) {
|
|
81
|
-
ctx.on('system-prompt/assemble', async (assembly,
|
|
85
|
+
ctx.on('system-prompt/assemble', async (assembly, context, next) => {
|
|
82
86
|
const result = await next();
|
|
83
|
-
if (!pure.
|
|
87
|
+
if (!pure.appliesToScope(context.scope))
|
|
84
88
|
return result;
|
|
89
|
+
// Pure mode sends no runtime context at all. The working-directory
|
|
90
|
+
// listener re-adds its required snapshot after `next()`, so blank the
|
|
91
|
+
// whole list here; the scoped empty shadow registered by pure mode keeps
|
|
92
|
+
// `refreshContext()` from restoring the real value at admission.
|
|
85
93
|
return {
|
|
86
94
|
...result,
|
|
95
|
+
contexts: [],
|
|
87
96
|
sections: [{
|
|
88
97
|
name: 'dsh-efm-integration:system-prompt',
|
|
89
98
|
text: pure.text,
|
|
@@ -92,7 +101,8 @@ export async function apply(ctx, config = {}) {
|
|
|
92
101
|
};
|
|
93
102
|
}, { prepend: true });
|
|
94
103
|
}
|
|
95
|
-
const snapshot = () => {
|
|
104
|
+
const snapshot = async () => {
|
|
105
|
+
const presets = await presetOptions(ctx);
|
|
96
106
|
const source = lockedByConfig ? 'config' : pure.enabled ? 'custom' : 'default';
|
|
97
107
|
const text = lockedByConfig ? configured ?? '' : pure.enabled ? pure.text : CONTRACT;
|
|
98
108
|
return {
|
|
@@ -101,6 +111,11 @@ export async function apply(ctx, config = {}) {
|
|
|
101
111
|
text,
|
|
102
112
|
length: Buffer.byteLength(text, 'utf8'),
|
|
103
113
|
pureMode: pure.enabled,
|
|
114
|
+
targetPreset: pure.targetPreset,
|
|
115
|
+
presets,
|
|
116
|
+
defaultPresetId: presetRegistryOf(ctx)?.defaultId ?? '',
|
|
117
|
+
targetPresetAvailable: pure.targetPreset === null
|
|
118
|
+
|| presets.some(preset => preset.id === pure.targetPreset),
|
|
104
119
|
maxPromptBytes: MAX_PROMPT_BYTES,
|
|
105
120
|
};
|
|
106
121
|
};
|
|
@@ -121,7 +136,7 @@ export async function apply(ctx, config = {}) {
|
|
|
121
136
|
return;
|
|
122
137
|
}
|
|
123
138
|
if (req.method === 'GET') {
|
|
124
|
-
writeJson(res, 200, snapshot());
|
|
139
|
+
writeJson(res, 200, await snapshot());
|
|
125
140
|
return;
|
|
126
141
|
}
|
|
127
142
|
if (req.method !== 'POST') {
|
|
@@ -149,22 +164,28 @@ export async function apply(ctx, config = {}) {
|
|
|
149
164
|
const action = body['action'];
|
|
150
165
|
if (action === 'save') {
|
|
151
166
|
let text;
|
|
167
|
+
let targetPreset;
|
|
152
168
|
try {
|
|
153
169
|
text = validatePromptText(body['text']);
|
|
170
|
+
targetPreset = validateTargetPreset(body['targetPreset']);
|
|
154
171
|
}
|
|
155
172
|
catch (error) {
|
|
156
173
|
writeJson(res, 400, { error: messageOf(error) });
|
|
157
174
|
return;
|
|
158
175
|
}
|
|
176
|
+
if (targetPreset !== null && !(await presetOptions(ctx)).some(preset => preset.id === targetPreset)) {
|
|
177
|
+
writeJson(res, 400, { error: `unknown agent preset "${targetPreset}"` });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
159
180
|
try {
|
|
160
|
-
await writeStored(text);
|
|
161
|
-
pure.set(true, text);
|
|
181
|
+
await writeStored(text, targetPreset);
|
|
182
|
+
pure.set(true, text, targetPreset);
|
|
162
183
|
}
|
|
163
184
|
catch (error) {
|
|
164
185
|
writeJson(res, 500, { error: messageOf(error) });
|
|
165
186
|
return;
|
|
166
187
|
}
|
|
167
|
-
writeJson(res, 200, snapshot());
|
|
188
|
+
writeJson(res, 200, await snapshot());
|
|
168
189
|
return;
|
|
169
190
|
}
|
|
170
191
|
if (action === 'clear') {
|
|
@@ -176,7 +197,7 @@ export async function apply(ctx, config = {}) {
|
|
|
176
197
|
writeJson(res, 500, { error: messageOf(error) });
|
|
177
198
|
return;
|
|
178
199
|
}
|
|
179
|
-
writeJson(res, 200, snapshot());
|
|
200
|
+
writeJson(res, 200, await snapshot());
|
|
180
201
|
return;
|
|
181
202
|
}
|
|
182
203
|
writeJson(res, 400, { error: 'action must be "save" or "clear"' });
|
|
@@ -187,6 +208,22 @@ export async function apply(ctx, config = {}) {
|
|
|
187
208
|
handler: (req, res) => exclusive(() => handler(req, res)),
|
|
188
209
|
}), 'dsh-efm-integration: system prompt management route');
|
|
189
210
|
}
|
|
211
|
+
/** Read the usable agent-preset roster for the sidebar selector. */
|
|
212
|
+
async function presetOptions(ctx) {
|
|
213
|
+
const registry = presetRegistryOf(ctx);
|
|
214
|
+
if (registry === undefined)
|
|
215
|
+
return [];
|
|
216
|
+
const rows = await registry.list();
|
|
217
|
+
const defaultId = registry.defaultId;
|
|
218
|
+
return rows
|
|
219
|
+
.filter(row => row.broken === undefined)
|
|
220
|
+
.map(row => ({
|
|
221
|
+
id: row.id,
|
|
222
|
+
isDefault: row.id === defaultId,
|
|
223
|
+
...(row.name === undefined ? {} : { name: row.name }),
|
|
224
|
+
...(row.description === undefined ? {} : { description: row.description }),
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
190
227
|
/** Validate the optional replacement and load it from disk when a file is named. */
|
|
191
228
|
async function resolveReplacement(config) {
|
|
192
229
|
const inline = config.prompt;
|
package/lib/prompt/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAQ3C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACjG,OAAO,EAAE,c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,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IACD,IAAI,IAAY,CAAA;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACrC,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC3C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,YAAY,CAAC,CAAA;IAC1D,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1,26 +1,67 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import type { TargetPreset } from './store.js';
|
|
4
|
+
/** One row of the DSH agent-preset roster, as read by the management route. */
|
|
5
|
+
export interface PresetRow {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly broken?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Minimal view of the optional DSH agent-preset registry service. */
|
|
12
|
+
export interface PresetRegistryView {
|
|
13
|
+
readonly defaultId: string;
|
|
14
|
+
list(): Promise<readonly PresetRow[]>;
|
|
15
|
+
composedPreset(ctx: Context): string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Read the optional preset registry without declaring a hard injection. The
|
|
19
|
+
* service is absent from unit harnesses and from deployments without presets;
|
|
20
|
+
* those fall back to the original global pure-mode behavior.
|
|
21
|
+
* @param ctx - plugin context that may see the registry.
|
|
22
|
+
* @returns the registry view, or undefined when not mounted.
|
|
23
|
+
*/
|
|
24
|
+
export declare function presetRegistryOf(ctx: Context): PresetRegistryView | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Read the preset an Agent actually uses. A preset switch takes effect on its
|
|
27
|
+
* next assembly without any state in this plugin.
|
|
28
|
+
* @param ctx - plugin context carrying the optional registry.
|
|
29
|
+
* @param agent - live Agent to inspect.
|
|
30
|
+
* @returns the preset id, or undefined when unknown.
|
|
31
|
+
*/
|
|
32
|
+
export declare function presetOfAgent(ctx: Context, agent: Agent): string | undefined;
|
|
33
|
+
/** Shared switch describing which sessions the sidebar prompt replaces. */
|
|
3
34
|
export interface PureMode {
|
|
4
35
|
readonly enabled: boolean;
|
|
5
36
|
readonly text: string;
|
|
37
|
+
/** Preset id, or null when the replacement applies to every preset. */
|
|
38
|
+
readonly targetPreset: TargetPreset;
|
|
6
39
|
/**
|
|
7
40
|
* Enable or disable the replacement. Enabling suppresses optional runtime
|
|
8
|
-
* context and denies global tools for
|
|
41
|
+
* context and denies global tools for the matching agents; agents of other
|
|
42
|
+
* presets keep their tools and injected guidance.
|
|
9
43
|
* @param enabled - whether the replacement applies.
|
|
10
44
|
* @param text - replacement text; required when enabling.
|
|
45
|
+
* @param targetPreset - preset id, `null`/`'all'` for every preset. Omission
|
|
46
|
+
* keeps the current target. Disabling resets the target to every preset.
|
|
11
47
|
*/
|
|
12
|
-
set(enabled: boolean, text?: string): void;
|
|
48
|
+
set(enabled: boolean, text?: string, targetPreset?: TargetPreset): void;
|
|
49
|
+
/** Whether an Agent belongs to the targeted preset while the mode is on. */
|
|
50
|
+
appliesTo(agent: Agent): boolean;
|
|
51
|
+
/** Whether one prompt assembly belongs to the targeted preset. */
|
|
52
|
+
appliesToScope(scope: object | undefined): boolean;
|
|
13
53
|
/** Observe state changes so the management route can report the current mode. */
|
|
14
54
|
subscribe(listener: (state: PureMode) => void): () => void;
|
|
15
55
|
}
|
|
16
56
|
interface InitialPureMode {
|
|
17
57
|
readonly enabled: boolean;
|
|
18
58
|
readonly text: string;
|
|
59
|
+
readonly targetPreset: TargetPreset;
|
|
19
60
|
}
|
|
20
61
|
/**
|
|
21
|
-
* Own the pure-mode switch, its runtime-context
|
|
62
|
+
* Own the pure-mode switch, its runtime-context suppressors, and the per-agent
|
|
22
63
|
* tool restrictions. The state is published as an optional Cordis service so
|
|
23
|
-
* other plugins can skip their own model-facing injections.
|
|
64
|
+
* other plugins can skip their own model-facing injections for affected agents.
|
|
24
65
|
* @param ctx - plugin context owning the prompt service and agent events.
|
|
25
66
|
* @param initial - starting state, normally derived from the saved prompt.
|
|
26
67
|
* @returns the live state object.
|
|
@@ -32,5 +73,13 @@ export declare function createPureMode(ctx: Context, initial?: InitialPureMode):
|
|
|
32
73
|
* @returns the shared state when the prompt plugin is mounted.
|
|
33
74
|
*/
|
|
34
75
|
export declare function pureModeOf(ctx: Context): PureMode | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the sidebar replacement affects this Agent, for plugins that inject
|
|
78
|
+
* model-facing messages outside the prompt assembly.
|
|
79
|
+
* @param ctx - plugin context that may see the pure-mode service.
|
|
80
|
+
* @param agent - Agent about to receive an injection.
|
|
81
|
+
* @returns true only while pure mode applies to that Agent.
|
|
82
|
+
*/
|
|
83
|
+
export declare function pureModeAppliesTo(ctx: Context, agent: Agent): boolean;
|
|
35
84
|
export {};
|
|
36
85
|
//# sourceMappingURL=pure-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure-mode.d.ts","sourceRoot":"","sources":["../../src/prompt/pure-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"pure-mode.d.ts","sourceRoot":"","sources":["../../src/prompt/pure-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAA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K,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IAClD,iFAAiF;IACjF,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CAC3D;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,QAAQ,CA4JhF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAMrE"}
|
package/lib/prompt/pure-mode.js
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Read the optional preset registry without declaring a hard injection. The
|
|
3
|
+
* service is absent from unit harnesses and from deployments without presets;
|
|
4
|
+
* those fall back to the original global pure-mode behavior.
|
|
5
|
+
* @param ctx - plugin context that may see the registry.
|
|
6
|
+
* @returns the registry view, or undefined when not mounted.
|
|
7
|
+
*/
|
|
8
|
+
export function presetRegistryOf(ctx) {
|
|
9
|
+
return ctx
|
|
10
|
+
.get('agentPresets', false);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read the preset an Agent actually uses. A preset switch takes effect on its
|
|
14
|
+
* next assembly without any state in this plugin.
|
|
15
|
+
* @param ctx - plugin context carrying the optional registry.
|
|
16
|
+
* @param agent - live Agent to inspect.
|
|
17
|
+
* @returns the preset id, or undefined when unknown.
|
|
18
|
+
*/
|
|
19
|
+
export function presetOfAgent(ctx, agent) {
|
|
20
|
+
try {
|
|
21
|
+
return presetRegistryOf(ctx)?.composedPreset(agent.ctx);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Own the pure-mode switch, its runtime-context suppressors, and the per-agent
|
|
3
29
|
* tool restrictions. The state is published as an optional Cordis service so
|
|
4
|
-
* other plugins can skip their own model-facing injections.
|
|
30
|
+
* other plugins can skip their own model-facing injections for affected agents.
|
|
5
31
|
* @param ctx - plugin context owning the prompt service and agent events.
|
|
6
32
|
* @param initial - starting state, normally derived from the saved prompt.
|
|
7
33
|
* @returns the live state object.
|
|
@@ -9,10 +35,16 @@
|
|
|
9
35
|
export function createPureMode(ctx, initial) {
|
|
10
36
|
let enabled = initial?.enabled === true;
|
|
11
37
|
let text = initial?.text ?? '';
|
|
38
|
+
let targetPreset = initial?.targetPreset ?? null;
|
|
12
39
|
const listeners = new Set();
|
|
13
40
|
const agents = new Set();
|
|
41
|
+
const byScope = new Map();
|
|
14
42
|
const restrictions = new Map();
|
|
15
|
-
|
|
43
|
+
const contextSuppressors = new Map();
|
|
44
|
+
const contextShadows = new Map();
|
|
45
|
+
let globalSuppressor;
|
|
46
|
+
/** The working-directory context this plugin blanks for pure-mode agents. */
|
|
47
|
+
const WORKING_DIRECTORY_CONTEXT = 'working-directory:current';
|
|
16
48
|
const restrict = (agent) => {
|
|
17
49
|
if (restrictions.has(agent))
|
|
18
50
|
return;
|
|
@@ -30,52 +62,136 @@ export function createPureMode(ctx, initial) {
|
|
|
30
62
|
restrictions.delete(agent);
|
|
31
63
|
dispose();
|
|
32
64
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
65
|
+
const releaseContext = (agent) => {
|
|
66
|
+
const dispose = contextSuppressors.get(agent);
|
|
67
|
+
if (dispose === undefined)
|
|
68
|
+
return;
|
|
69
|
+
contextSuppressors.delete(agent);
|
|
70
|
+
dispose();
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Shadow the required `working-directory:current` context with an empty
|
|
74
|
+
* scoped provider. Suppression alone cannot remove it: it is registered as
|
|
75
|
+
* required, and `refreshContext()` restores missing required entries at
|
|
76
|
+
* request admission. The scoped shadow makes admission resolve the name to
|
|
77
|
+
* empty text instead; the assembly waterfall blanks whatever the
|
|
78
|
+
* working-directory listener re-added. Empty sections are dropped when the
|
|
79
|
+
* snapshot renders, so no runtime-context message reaches the model.
|
|
80
|
+
*/
|
|
81
|
+
const installContextShadow = (agent) => {
|
|
82
|
+
if (contextShadows.has(agent))
|
|
83
|
+
return;
|
|
84
|
+
try {
|
|
85
|
+
const prompt = agent.ctx.systemPrompt;
|
|
86
|
+
contextShadows.set(agent, prompt.context({
|
|
87
|
+
name: WORKING_DIRECTORY_CONTEXT,
|
|
88
|
+
order: prompt.getContextOrder('WORKING_DIRECTORY'),
|
|
89
|
+
required: true,
|
|
90
|
+
interpolate: false,
|
|
91
|
+
text: () => '',
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
contextShadows.delete(agent);
|
|
96
|
+
ctx.logger.warn(`system-prompt: could not blank the working-directory context: ${messageOf(error)}`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const releaseContextShadow = (agent) => {
|
|
100
|
+
const dispose = contextShadows.get(agent);
|
|
101
|
+
if (dispose === undefined)
|
|
102
|
+
return;
|
|
103
|
+
contextShadows.delete(agent);
|
|
104
|
+
dispose();
|
|
105
|
+
};
|
|
106
|
+
const syncGlobalSuppressor = () => {
|
|
107
|
+
if (enabled && targetPreset === null) {
|
|
108
|
+
if (globalSuppressor === undefined)
|
|
109
|
+
globalSuppressor = ctx.systemPrompt.suppressRuntimeContext();
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
globalSuppressor?.();
|
|
113
|
+
globalSuppressor = undefined;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
36
116
|
const state = {
|
|
37
117
|
get enabled() { return enabled; },
|
|
38
118
|
get text() { return text; },
|
|
39
|
-
|
|
119
|
+
get targetPreset() { return targetPreset; },
|
|
120
|
+
set(next, nextText, nextTarget) {
|
|
40
121
|
const shouldEnable = next === true;
|
|
41
122
|
const replacement = shouldEnable ? nextText ?? text : '';
|
|
42
123
|
if (shouldEnable && replacement.trim().length === 0) {
|
|
43
124
|
throw new Error('pure mode requires a non-empty prompt');
|
|
44
125
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else if (!shouldEnable && enabled) {
|
|
49
|
-
suppressRuntimeContext?.();
|
|
50
|
-
suppressRuntimeContext = undefined;
|
|
51
|
-
}
|
|
126
|
+
const nextTargetPreset = shouldEnable
|
|
127
|
+
? nextTarget === undefined ? targetPreset : nextTarget
|
|
128
|
+
: null;
|
|
52
129
|
enabled = shouldEnable;
|
|
53
130
|
text = replacement;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
else {
|
|
59
|
-
for (const agent of [...restrictions.keys()])
|
|
60
|
-
release(agent);
|
|
61
|
-
}
|
|
131
|
+
targetPreset = nextTargetPreset;
|
|
132
|
+
syncGlobalSuppressor();
|
|
133
|
+
for (const agent of agents)
|
|
134
|
+
sync(agent);
|
|
62
135
|
for (const listener of listeners)
|
|
63
136
|
listener(state);
|
|
64
137
|
},
|
|
138
|
+
appliesTo(agent) {
|
|
139
|
+
if (!enabled)
|
|
140
|
+
return false;
|
|
141
|
+
// No registry means no way to tell presets apart: keep the global behavior.
|
|
142
|
+
if (targetPreset === null || presetRegistryOf(ctx) === undefined)
|
|
143
|
+
return true;
|
|
144
|
+
return presetOfAgent(ctx, agent) === targetPreset;
|
|
145
|
+
},
|
|
146
|
+
appliesToScope(scope) {
|
|
147
|
+
if (!enabled)
|
|
148
|
+
return false;
|
|
149
|
+
if (targetPreset === null || presetRegistryOf(ctx) === undefined)
|
|
150
|
+
return true;
|
|
151
|
+
if (scope === undefined)
|
|
152
|
+
return false;
|
|
153
|
+
const agent = byScope.get(scope);
|
|
154
|
+
return agent !== undefined && state.appliesTo(agent);
|
|
155
|
+
},
|
|
65
156
|
subscribe(listener) {
|
|
66
157
|
listeners.add(listener);
|
|
67
158
|
return () => listeners.delete(listener);
|
|
68
159
|
},
|
|
69
160
|
};
|
|
161
|
+
function sync(agent) {
|
|
162
|
+
if (state.appliesTo(agent)) {
|
|
163
|
+
restrict(agent);
|
|
164
|
+
if (targetPreset === null)
|
|
165
|
+
releaseContext(agent);
|
|
166
|
+
else if (!contextSuppressors.has(agent)) {
|
|
167
|
+
try {
|
|
168
|
+
contextSuppressors.set(agent, agent.ctx.systemPrompt.suppressRuntimeContext());
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
ctx.logger.warn(`system-prompt: could not suppress runtime context: ${messageOf(error)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
installContextShadow(agent);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
release(agent);
|
|
178
|
+
releaseContext(agent);
|
|
179
|
+
releaseContextShadow(agent);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
syncGlobalSuppressor();
|
|
70
183
|
ctx.on('agent/created', ({ agent }) => {
|
|
71
184
|
agents.add(agent);
|
|
72
|
-
|
|
73
|
-
|
|
185
|
+
byScope.set(agent, agent);
|
|
186
|
+
sync(agent);
|
|
74
187
|
return undefined;
|
|
75
188
|
});
|
|
76
189
|
ctx.on('agent/disposed', ({ agent }) => {
|
|
77
190
|
release(agent);
|
|
191
|
+
releaseContext(agent);
|
|
192
|
+
releaseContextShadow(agent);
|
|
78
193
|
agents.delete(agent);
|
|
194
|
+
byScope.delete(agent);
|
|
79
195
|
});
|
|
80
196
|
ctx.provide('dshEfmPureMode', state);
|
|
81
197
|
return state;
|
|
@@ -88,6 +204,22 @@ export function createPureMode(ctx, initial) {
|
|
|
88
204
|
export function pureModeOf(ctx) {
|
|
89
205
|
return ctx.get('dshEfmPureMode', false);
|
|
90
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Whether the sidebar replacement affects this Agent, for plugins that inject
|
|
209
|
+
* model-facing messages outside the prompt assembly.
|
|
210
|
+
* @param ctx - plugin context that may see the pure-mode service.
|
|
211
|
+
* @param agent - Agent about to receive an injection.
|
|
212
|
+
* @returns true only while pure mode applies to that Agent.
|
|
213
|
+
*/
|
|
214
|
+
export function pureModeAppliesTo(ctx, agent) {
|
|
215
|
+
const state = pureModeOf(ctx);
|
|
216
|
+
if (state === undefined)
|
|
217
|
+
return false;
|
|
218
|
+
// Some harnesses publish a minimal state without the scoped predicate.
|
|
219
|
+
if (typeof state.appliesTo === 'function')
|
|
220
|
+
return state.appliesTo(agent);
|
|
221
|
+
return state.enabled === true;
|
|
222
|
+
}
|
|
91
223
|
function messageOf(error) {
|
|
92
224
|
return error instanceof Error ? error.message : String(error);
|
|
93
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure-mode.js","sourceRoot":"","sources":["../../src/prompt/pure-mode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pure-mode.js","sourceRoot":"","sources":["../../src/prompt/pure-mode.ts"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAQ,GAAmE;SACxE,GAAG,CAAC,cAAc,EAAE,KAAK,CAAmC,CAAA;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,KAAY;IACtD,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAgCD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,OAAyB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CAAC,GAAY,EAAE,KAAY;IAC1D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACrC,uEAAuE;IACvE,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACxE,OAAO,KAAK,CAAC,OAAO,KAAK,IAAI,CAAA;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC"}
|
package/lib/prompt/store.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/** Largest accepted replacement prompt, measured in UTF-8 bytes. */
|
|
2
2
|
export declare const MAX_PROMPT_BYTES: number;
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Agent preset the replacement applies to. `null` means every preset, which
|
|
5
|
+
* keeps the original global pure-mode behavior.
|
|
6
|
+
*/
|
|
7
|
+
export type TargetPreset = string | null;
|
|
8
|
+
/** Persisted replacement prompt, its target preset, and the time it was saved. */
|
|
4
9
|
export interface StoredPrompt {
|
|
5
10
|
readonly text: string;
|
|
11
|
+
readonly targetPreset: TargetPreset;
|
|
6
12
|
readonly updatedAt: string;
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
9
15
|
* Read the saved replacement prompt. A missing file is the unset state; an
|
|
10
16
|
* unreadable or malformed file is reported so the caller can warn and fall back
|
|
11
|
-
* to the default contract.
|
|
17
|
+
* to the default contract. Version 1 records predate preset targeting and are
|
|
18
|
+
* read as targeting every preset; they are rewritten on the next save.
|
|
12
19
|
* @returns the saved prompt, or undefined when none is saved.
|
|
13
20
|
*/
|
|
14
21
|
export declare function readStored(): Promise<StoredPrompt | undefined>;
|
|
@@ -18,11 +25,20 @@ export declare function readStored(): Promise<StoredPrompt | undefined>;
|
|
|
18
25
|
* @returns the normalized prompt text.
|
|
19
26
|
*/
|
|
20
27
|
export declare function validatePromptText(value: unknown): string;
|
|
28
|
+
/**
|
|
29
|
+
* Normalize an untrusted target preset. Omission, `null`, and `'all'` mean
|
|
30
|
+
* every preset; any other non-empty string is an agent preset id whose existence
|
|
31
|
+
* the management route checks against the live roster.
|
|
32
|
+
* @param value - untrusted JSON value from the management route or stored file.
|
|
33
|
+
* @returns the normalized target, or null for every preset.
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateTargetPreset(value: unknown): TargetPreset;
|
|
21
36
|
/**
|
|
22
37
|
* Atomically replace the saved prompt.
|
|
23
38
|
* @param text - validated replacement text.
|
|
39
|
+
* @param targetPreset - preset the replacement applies to, or null for all.
|
|
24
40
|
*/
|
|
25
|
-
export declare function writeStored(text: string): Promise<void>;
|
|
41
|
+
export declare function writeStored(text: string, targetPreset?: TargetPreset): Promise<void>;
|
|
26
42
|
/** Remove the saved prompt, restoring the bundled contract. */
|
|
27
43
|
export declare function clearStored(): Promise<void>;
|
|
28
44
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/prompt/store.ts"],"names":[],"mappings":"AAKA,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,QAAa,CAAA;AAE1C,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/prompt/store.ts"],"names":[],"mappings":"AAKA,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,QAAa,CAAA;AAE1C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,CAAA;AAExC,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAQD;;;;;;GAMG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CA6BpE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASzD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAMjE;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,YAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhG;AAED,+DAA+D;AAC/D,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAEjD"}
|
package/lib/prompt/store.js
CHANGED
|
@@ -3,14 +3,15 @@ import { dirname } from 'node:path';
|
|
|
3
3
|
import { dshHomePath } from '@deepseek-ai/dsh-home-paths';
|
|
4
4
|
/** Largest accepted replacement prompt, measured in UTF-8 bytes. */
|
|
5
5
|
export const MAX_PROMPT_BYTES = 128 * 1024;
|
|
6
|
-
const VERSION =
|
|
6
|
+
const VERSION = 2;
|
|
7
7
|
function storePath() {
|
|
8
8
|
return dshHomePath('plugins', 'dsh-efm-integration', 'system-prompt.json');
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Read the saved replacement prompt. A missing file is the unset state; an
|
|
12
12
|
* unreadable or malformed file is reported so the caller can warn and fall back
|
|
13
|
-
* to the default contract.
|
|
13
|
+
* to the default contract. Version 1 records predate preset targeting and are
|
|
14
|
+
* read as targeting every preset; they are rewritten on the next save.
|
|
14
15
|
* @returns the saved prompt, or undefined when none is saved.
|
|
15
16
|
*/
|
|
16
17
|
export async function readStored() {
|
|
@@ -28,9 +29,6 @@ export async function readStored() {
|
|
|
28
29
|
throw new Error('saved system prompt is not an object');
|
|
29
30
|
}
|
|
30
31
|
const record = value;
|
|
31
|
-
if (record['version'] !== VERSION) {
|
|
32
|
-
throw new Error(`saved system prompt has unsupported version ${String(record['version'])}`);
|
|
33
|
-
}
|
|
34
32
|
const text = record['text'];
|
|
35
33
|
const updatedAt = record['updatedAt'];
|
|
36
34
|
if (typeof text !== 'string' || text.trim().length === 0) {
|
|
@@ -39,7 +37,14 @@ export async function readStored() {
|
|
|
39
37
|
if (typeof updatedAt !== 'string' || updatedAt.trim().length === 0) {
|
|
40
38
|
throw new Error('saved system prompt has no updatedAt');
|
|
41
39
|
}
|
|
42
|
-
|
|
40
|
+
if (record['version'] === 1) {
|
|
41
|
+
return { text: text.replace(/^\uFEFF/, ''), targetPreset: null, updatedAt };
|
|
42
|
+
}
|
|
43
|
+
if (record['version'] !== VERSION) {
|
|
44
|
+
throw new Error(`saved system prompt has unsupported version ${String(record['version'])}`);
|
|
45
|
+
}
|
|
46
|
+
const targetPreset = validateTargetPreset(record['targetPreset']);
|
|
47
|
+
return { text: text.replace(/^\uFEFF/, ''), targetPreset, updatedAt };
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Validate text supplied by the sidebar before it becomes a replacement.
|
|
@@ -58,15 +63,33 @@ export function validatePromptText(value) {
|
|
|
58
63
|
}
|
|
59
64
|
return text;
|
|
60
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize an untrusted target preset. Omission, `null`, and `'all'` mean
|
|
68
|
+
* every preset; any other non-empty string is an agent preset id whose existence
|
|
69
|
+
* the management route checks against the live roster.
|
|
70
|
+
* @param value - untrusted JSON value from the management route or stored file.
|
|
71
|
+
* @returns the normalized target, or null for every preset.
|
|
72
|
+
*/
|
|
73
|
+
export function validateTargetPreset(value) {
|
|
74
|
+
if (value === undefined || value === null || value === 'all')
|
|
75
|
+
return null;
|
|
76
|
+
if (typeof value !== 'string')
|
|
77
|
+
throw new Error('targetPreset must be a preset id or "all"');
|
|
78
|
+
const id = value.trim();
|
|
79
|
+
if (id.length === 0 || id === 'all')
|
|
80
|
+
return null;
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
61
83
|
/**
|
|
62
84
|
* Atomically replace the saved prompt.
|
|
63
85
|
* @param text - validated replacement text.
|
|
86
|
+
* @param targetPreset - preset the replacement applies to, or null for all.
|
|
64
87
|
*/
|
|
65
|
-
export async function writeStored(text) {
|
|
88
|
+
export async function writeStored(text, targetPreset = null) {
|
|
66
89
|
const file = storePath();
|
|
67
90
|
await mkdir(dirname(file), { recursive: true });
|
|
68
91
|
const temporary = `${file}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
69
|
-
const stored = { text, updatedAt: new Date().toISOString() };
|
|
92
|
+
const stored = { text, targetPreset, updatedAt: new Date().toISOString() };
|
|
70
93
|
try {
|
|
71
94
|
await writeFile(temporary, JSON.stringify({ version: VERSION, ...stored }), {
|
|
72
95
|
encoding: 'utf8',
|
package/lib/prompt/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/prompt/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/prompt/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,oEAAoE;AACpE,MAAM,CAAC,MA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,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACpD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACxC,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;WAC7C,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;AACjD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { pureModeAppliesTo } from '../prompt/pure-mode.js';
|
|
3
3
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
4
4
|
import { isModelInvocable, isSkillName, renderSkillContent, } from '@deepseek-ai/dsh-skill';
|
|
5
5
|
import { SessionSeq } from '@deepseek-ai/dsh-session';
|
|
@@ -18,7 +18,7 @@ export function apply(ctx, config = {}) {
|
|
|
18
18
|
}
|
|
19
19
|
ctx.on('agent/pre-step', async ({ agent, signal }, next) => {
|
|
20
20
|
const decision = await next();
|
|
21
|
-
if (decision.kind === 'reject' ||
|
|
21
|
+
if (decision.kind === 'reject' || pureModeAppliesTo(ctx, agent))
|
|
22
22
|
return decision;
|
|
23
23
|
const cwd = await ctx.workingDirectory.ensure(agent, signal);
|
|
24
24
|
const snapshot = await ctx.skills.snapshot({ cwd, signal, scope: agent });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skill-router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","source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AK,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACvD,OAAO,UAAU,CAAC,MAAM,IAAI,SAAS;QACnC,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,CAAA;AAChD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
2
|
-
import {
|
|
2
|
+
import { pureModeAppliesTo } from '../prompt/pure-mode.js';
|
|
3
3
|
export const name = 'dsh-efm-integration-verification';
|
|
4
4
|
export const inject = ['agents'];
|
|
5
5
|
const DEFAULT_MUTATION_TOOLS = [
|
|
@@ -53,7 +53,7 @@ export function apply(ctx, config = {}) {
|
|
|
53
53
|
return decision;
|
|
54
54
|
});
|
|
55
55
|
ctx.on('agent/turn-stopping', ({ agent, turn }) => {
|
|
56
|
-
if (
|
|
56
|
+
if (pureModeAppliesTo(ctx, agent))
|
|
57
57
|
return;
|
|
58
58
|
const state = states.get(agent);
|
|
59
59
|
if (state === undefined || state.turn !== turn)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"m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CAAC,cAAc,CAAC,EAAE,CAAC;QACnG,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,OAAO,GAAI,cAAwC,CAAC,OAAO,CAAA;IACjE,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-efm-integration",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "A DSH plugin bundle with coding discipline, skill routing, verification, archived Session cleanup, and sidebar-managed language servers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|