dsh-system-prompt-insertion 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +175 -2
- package/cordis.patch.yml +18 -0
- package/lib/client.js +1414 -0
- package/lib/index.d.ts +324 -0
- package/lib/index.js +902 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +97 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# dsh-system-prompt-insertion
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d2b7f30: 把预览移到段落编辑上方并常驻:进入页面、保存、切换全局启停时自动重新组装;标题旁新增刷新按钮,其他插件改动系统提示词后可手动重拉。移除底部预览按钮;保存 / 撤销移到段落区右下角,添加段落按钮移到列表末尾;全局启停改为切换即保存。
|
|
8
|
+
- e0c561f: 把插件与页面从「提示词段落」改名为「系统提示词注入」/「提示词注入」,包名与 loader id 统一为 `dsh-system-prompt-insertion` / `system-prompt-insertion`,状态文件迁移到 `$DSH_HOME/system-prompt-insertion.json`,注册名前缀改为 `user:system-prompt-insertion:`。
|
|
9
|
+
- e0c561f: 把编辑器从「设置」页挪到左侧栏面板:注册 `sidebar.panellist` 的一行(和 Plugins / 任务时间表同一排)与 `main` 槽里同 id 的面板,设置页不再出现。
|
|
10
|
+
|
|
11
|
+
面板按宿主全局页面的版式重做成**单栏**:960px 内容列居中、两侧留白随窗口宽度自适应、标题 20px/500、macOS 下让开窗口顶部。段落卡片支持逐段启停、改名、位置、上下移动与删除,停用不再把整张卡变灰;底部常驻保存条显示「已保存 / 有未保存的修改」并提供预览、撤销与保存(⌘S / Ctrl+S 可保存),保存后自动刷新预览。预览区改为全宽表格 + 全文,可一键复制;空状态、加载、读取/保存/预览失败都有专门的界面。颜色全部走 `--dsw-*` token,亮色、暗色与皮肤主题自动跟随。
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d924fe2: 发布包里带上 `CHANGELOG.md`。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-plugins contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-system-prompt-insertion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 把你的文字注入 DeepSeek Harness 的 **system prompt**:写在左侧栏的面板里,落到开头 / 中间 / 最末尾,改完下一个请求生效。
|
|
4
|
+
|
|
5
|
+
[English](#english) | 简体中文
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 它解决什么
|
|
10
|
+
|
|
11
|
+
DSH 每一步都会把 system prompt 按「段落 + order」重新组装。这个插件让你把**自己的**文字作为 system 段落注入进去:
|
|
12
|
+
|
|
13
|
+
| 你能做的事 | 怎么做 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 在提示词最末尾注入一段话 | 新建段落 → 位置选「末尾」 |
|
|
16
|
+
| 在人格之后、工具说明之前注入规则 | 位置选「开头」 |
|
|
17
|
+
| 在工具说明之后注入工作约定 | 位置选「中间」 |
|
|
18
|
+
| 临时关掉某一段 | 段落上的「启用」开关 |
|
|
19
|
+
| 看清最终发给模型的是什么 | 页面顶部的预览区(标题旁可刷新) |
|
|
20
|
+
| 手工/脚本维护 | 直接编辑 `~/.dsh/system-prompt-insertion.json` |
|
|
21
|
+
|
|
22
|
+
和 `AGENTS.md` 的区别是**优先级来源**:`AGENTS.md` 以 **user 角色消息**注入,信封里明确写着它不覆盖 system 指令;本插件注册的是真正的 `system` 段落,与平台自己的指令同层。
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
# 本地检出(开发用,link 方式,改完 build 即生效)
|
|
28
|
+
dsh plugin --profile web add link:~/projects/dsh-plugins/packages/dsh-system-prompt-insertion
|
|
29
|
+
|
|
30
|
+
# 发布后
|
|
31
|
+
dsh plugin --profile web add dsh-system-prompt-insertion
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
装完**重启一次 DSH**(新 bundle 需要宿主重新引导),左侧栏底部会多出一个「提示词注入」图标(和 Plugins / 任务时间表 / 上下文档同一排),点开就是面板。以后改代码只需 `npm run build` 再刷新页面。
|
|
35
|
+
|
|
36
|
+
## 三个落点
|
|
37
|
+
|
|
38
|
+
| 位置 | order | 落在 |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| 开头 | `10` | harness 身份(-1000)、persona(0)之后 |
|
|
41
|
+
| 中间 | `5100` | 所有工具说明(1000–3100)、SDK 段(5000)之后 |
|
|
42
|
+
| 末尾 | 宿主 `deployment:persona-suffix` + 300 | 宿主最后一段之后——即提示词真正的结尾 |
|
|
43
|
+
|
|
44
|
+
同一落点里按编辑器顺序每段 +10。末尾段的 order 基数是**运行时**从宿主读的(`getSectionOrder('DEPLOYMENT_PERSONA_SUFFIX')`),所以宿主升级调了顺序,我们的文字也不会被挤到工具说明前面。
|
|
45
|
+
|
|
46
|
+
需要精确控制时,可在状态文件里给某段写 `order: 12345`,它优先于按位置推算的 order。
|
|
47
|
+
|
|
48
|
+
## 为什么不会被「预设」遮掉
|
|
49
|
+
|
|
50
|
+
遮蔽按**段落名字**匹配。预设里的 persona 行占用 `deployment:persona-prefix` / `deployment:persona-suffix` 这两个名字,而本插件的段落叫 `user:system-prompt-insertion:<id>`——名字不重合,全局层因此对所有 agent 生效(含子代理、工作流子代理)。
|
|
51
|
+
|
|
52
|
+
唯一的例外:预设把 persona 设成 `complete: true`(内置 `minimal` 就是),整份提示词只剩那一段,任何追加都会被丢弃。**预览会直接标注这种情况**,不会假装生效。
|
|
53
|
+
|
|
54
|
+
## 侧栏面板
|
|
55
|
+
|
|
56
|
+
- 版式跟随宿主自己的全局页面(参考内置「任务时间表」页):960px 内容列居中、两侧留白随窗口 `clamp(24px, 4vw, 48px)` 自适应、标题 20px/500,macOS 下会额外让开窗口顶部 48px。
|
|
57
|
+
- **单栏,预览在上**:标题 → 当前系统提示词 → 段落编辑,自上而下排。编辑区和预览都占满内容列宽,长正文不再被挤在右半边;窄窗口不需要任何重排。
|
|
58
|
+
- **预览常驻**:进入页面、保存、切换全局启用都会自动重新组装;没有单独的「预览」按钮。标题旁的刷新图标可以手动重拉,用于其他插件改了系统提示词之后。
|
|
59
|
+
- **全局启用**:页头的开关切换即保存,并立即刷新预览;段落正文的改动仍然先暂存,需要点「保存」。
|
|
60
|
+
- **保存 / 撤销**:位于段落编辑区右下角,旁边显示「已保存 / 有未保存的修改」;`⌘S`(macOS)或 `Ctrl+S` 也能保存。
|
|
61
|
+
- **添加段落**:按钮在列表最后一张卡片下方;新卡片就地出现,并聚焦名称输入框。
|
|
62
|
+
- 每段一张卡片:逐段启停、名称(≤80 字符)、位置(开头 / 中间 / 末尾)、上移 / 下移 / 删除。停用只加「已停用」标记,卡片仍可编辑;启用但正文为空会当场标黄(空段不会被注册)。
|
|
63
|
+
- 每段显示字节数、落点提示和「解析 {{变量}}」开关。
|
|
64
|
+
- **预览当前系统提示词**:调用宿主真实的 `assemble()` + `renderPrompt()`,用表格列出每段的顺序、order、字节数、哪些是本插件的,并给出最后拼出来的全文(可一键复制)。
|
|
65
|
+
- **检查结果**:空段、与既有段落重复的行、开启插值后引用了未知变量、超过软上限的段,都会点名。
|
|
66
|
+
- 样式只读 `--dsw-*` 主题 token:亮色、暗色和皮肤主题自动跟随,面板还会校验「不写死颜色」。
|
|
67
|
+
|
|
68
|
+
预览的两条诚实边界(页面里也会写):
|
|
69
|
+
|
|
70
|
+
1. 组装时没有具体的 agent scope,所以**与预设绑定的工具段不会出现**、工具数通常显示 0;列表对「落点」仍然是准的。
|
|
71
|
+
2. 预览反映的是**已保存**的状态;有未保存修改时页面会提示。
|
|
72
|
+
|
|
73
|
+
## 状态文件
|
|
74
|
+
|
|
75
|
+
默认 `~/.dsh/system-prompt-insertion.json`(`$DSH_HOME` 优先),权限 `0600`,原子写入。也可以手工编辑——文件变化会被发现,正文改动下一个请求就生效,结构改动(增删/移动/启停)由监听器重建注册。
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"version": 1,
|
|
80
|
+
"enabled": true,
|
|
81
|
+
"sections": [
|
|
82
|
+
{
|
|
83
|
+
"id": "s-abc123",
|
|
84
|
+
"title": "回答风格",
|
|
85
|
+
"text": "始终用简体中文回答,代码与标识符保持原文。",
|
|
86
|
+
"position": "tail",
|
|
87
|
+
"order": null,
|
|
88
|
+
"enabled": true,
|
|
89
|
+
"interpolate": false
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
字段:
|
|
96
|
+
|
|
97
|
+
| 字段 | 说明 |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `id` | `[a-z0-9][a-z0-9-]{5,39}`,同时是该段落注册名的一部分 |
|
|
100
|
+
| `title` | 编辑器里的显示名(≤80 字符) |
|
|
101
|
+
| `text` | 正文,UTF-8 ≤256 KiB |
|
|
102
|
+
| `position` | `head` / `body` / `tail` |
|
|
103
|
+
| `order` | 数字则覆盖按位置推算的 order;`null` 表示跟随位置 |
|
|
104
|
+
| `enabled` | 是否注册 |
|
|
105
|
+
| `interpolate` | `true` 才解析 `{{model}}` / `{{provider}}`;`false` 原样进入提示词 |
|
|
106
|
+
|
|
107
|
+
未知字段、重复 id、非法位置都会**拒绝整份文档**并保留旧状态——宁可报错,也不静默丢配置。
|
|
108
|
+
|
|
109
|
+
## 配置(profile 行)
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
- id: system-prompt-insertion
|
|
113
|
+
name: dsh-system-prompt-insertion
|
|
114
|
+
config:
|
|
115
|
+
enabled: true # 总开关;false 时什么都不注册
|
|
116
|
+
storeFile: '' # 覆盖状态文件路径,空 = $DSH_HOME/system-prompt-insertion.json
|
|
117
|
+
maxSectionBytes: 8192 # 单段软上限,只在 UI 里提示,不截断
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
配置里刻意**没有**提示词文本:唯一真源就是那个 JSON 文件,避免「配置里一份、界面里一份」。
|
|
121
|
+
|
|
122
|
+
## HTTP 面
|
|
123
|
+
|
|
124
|
+
只有三个路由,同源、仅 JSON:
|
|
125
|
+
|
|
126
|
+
| 方法 | 路径 | 用途 |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| `GET` | `/dsh-system-prompt-insertion/state` | 读状态、文件路径、已注册段落、宿主末尾段的 order 基数 |
|
|
129
|
+
| `POST` | `/dsh-system-prompt-insertion/state` | 校验 + 持久化 + 重建注册 |
|
|
130
|
+
| `GET` | `/dsh-system-prompt-insertion/preview` | 真实组装 + 渲染 + 告警 |
|
|
131
|
+
|
|
132
|
+
防护:`Origin` 与 `Host` 不一致拒绝(403)、写请求必须 `application/json`(415)、请求体上限 512 KiB(413)、非法文档 422。
|
|
133
|
+
|
|
134
|
+
## 兼容性与限制
|
|
135
|
+
|
|
136
|
+
- 目标 `@deepseek-ai/*` **0.2.1-rc.2**(cordis 4.0.5 / schemastery 3.18.5 实测)。
|
|
137
|
+
- 宿主没有 `webServer`(headless / acp / sdk)时,只有侧栏面板消失,段落注册照常。
|
|
138
|
+
- `{{...}}` 是严格插值:开启插值又写了未知变量,请求会在组装阶段失败——所以默认关闭。
|
|
139
|
+
- 段落文字属于请求前缀,改动会让之后的缓存前缀失效;把稳定文本放「末尾」,比频繁改「开头」更省。
|
|
140
|
+
- 面板占用中间列:切到别的侧栏面板(Plugins / 任务时间表…)就离开本面板,再点回来会重新拉一次状态;没保存的草稿不会跨面板保留。
|
|
141
|
+
- 已知边界:预设 `complete: true` 时无法追加;预览看不到 scope 内的工具段。
|
|
142
|
+
|
|
143
|
+
## 开发
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
npm install
|
|
147
|
+
npm run typecheck # tsc --noEmit(isolatedDeclarations)
|
|
148
|
+
npm run build # tsdown:lib/index.js(宿主)+ lib/client.js(浏览器)
|
|
149
|
+
npm test # node --test,41 项:真实 cordis + 真实 dsh-system-prompt + 路由 + 浏览器半区
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
包结构:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
src/types.ts 数据模型 + 校验(未知字段拒绝)
|
|
156
|
+
src/orders.ts 落点数学 + 注册计划
|
|
157
|
+
src/store.ts 文件存储、原子写、变更检测
|
|
158
|
+
src/register.ts 向 ctx.systemPrompt 注册段落
|
|
159
|
+
src/preview.ts 真实组装 + 渲染 + 告警
|
|
160
|
+
src/routes.ts 同源 JSON API
|
|
161
|
+
src/index.ts 宿主入口(配置、监听器、路由装配)
|
|
162
|
+
src/client.ts 侧栏行 + 面板(仅 react,无宿主客户端包)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## English
|
|
166
|
+
|
|
167
|
+
`dsh-system-prompt-insertion` lets you inject **user-owned text** into the DeepSeek Harness system prompt as ordered sections. Write it in a left-column sidebar panel, place it at the head, the middle, or the true tail of the assembled prompt, and it applies on the next model step, with no restart.
|
|
168
|
+
|
|
169
|
+
- Host half registers one `ctx.systemPrompt.section()` per enabled entry at `user:system-prompt-insertion:<id>`; global scope, so presets cannot shadow it (except a `complete: true` persona preset, which the preview reports).
|
|
170
|
+
- Browser half is a sidebar panel: a row in the shell's own panel list (`sidebar.panellist`) plus its page in the keyed `main` slot, so the shell keeps the button, label, active highlight and collapsed rail.
|
|
171
|
+
- The panel is single-column with the preview first: heading, the assembled prompt, then the section editor. Save and discard sit at the bottom-right of the editor; Add section sits under the last card. Every colour comes from `--dsw-*` tokens, so light, dark and skin themes follow automatically.
|
|
172
|
+
- The preview is rendered on entry, after every save, and after the master switch changes. A refresh icon next to the title re-pulls it when another plugin changes the prompt; there is no separate Preview button. The master switch applies immediately, while section edits stay staged until Save (`⌘S` / `Ctrl+S` works too).
|
|
173
|
+
- The preview is produced by the host's real `assemble()` + `renderPrompt()` and can be copied whole; checks flag empty sections, repeated lines, unknown variables and oversize text.
|
|
174
|
+
- One JSON document is the single source of truth; atomic writes, `0600`, change detection, and strict validation (unknown fields are rejected rather than dropped).
|
|
175
|
+
|
|
176
|
+
MIT.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# dsh-system-prompt-insertion profile patch layer.
|
|
2
|
+
#
|
|
3
|
+
# One row mounts both halves. The row id is the profile entry id; the package
|
|
4
|
+
# name is what resolves on disk. The host half registers the stored text as
|
|
5
|
+
# sections of the system prompt, and the Web half draws the sidebar panel.
|
|
6
|
+
#
|
|
7
|
+
# Optional configuration:
|
|
8
|
+
#
|
|
9
|
+
# - id: system-prompt-insertion
|
|
10
|
+
# name: dsh-system-prompt-insertion
|
|
11
|
+
# config:
|
|
12
|
+
# enabled: true # master switch; false registers nothing
|
|
13
|
+
# storeFile: '' # override the JSON store path
|
|
14
|
+
# maxSectionBytes: 8192 # per-section soft cap reported by the UI
|
|
15
|
+
#
|
|
16
|
+
- insert:
|
|
17
|
+
- id: system-prompt-insertion
|
|
18
|
+
name: dsh-system-prompt-insertion
|