@mealsea/dsh-prompt-enhance 1.0.0 → 1.1.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 +48 -0
- package/README.md +49 -14
- package/client.js +685 -49
- package/docs/AUDIT-1.0.0.md +76 -0
- package/docs/DETAIL.md +95 -3
- package/docs/RELEASE.md +143 -0
- package/docs/dev/awareness-contract.md +1253 -0
- package/docs/dev/context-facts.md +643 -0
- package/docs/images/enhance-panel.png +0 -0
- package/docs/images/icon-180.png +0 -0
- package/docs/images/settings.png +0 -0
- package/docs/prompt-enhance-plugin-dev.md +3 -3
- package/docs/report-2026-12-06-awareness.md +209 -0
- package/icon.svg +1 -1
- package/index.js +796 -6
- package/locale/en.json +1 -1
- package/package.json +4 -4
- package/test/host.mjs +606 -1
- package/test/smoke.mjs +265 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
本项目遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
|
|
4
4
|
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [1.1.0] - 2026-12-06
|
|
8
|
+
|
|
9
|
+
### 新增
|
|
10
|
+
|
|
11
|
+
- 工作区/文件感知(只读、默认关闭):设置页可打开「读取工作区上下文」,Host 半按草稿里的路径与关键词在**当前会话工作区**内搜索并读取文本片段(最多文件数、每文件行数、总 token 三层预算);读取经 `fs.resolve` + `fs.contains` 读前/读后双重围栏,只调用 `workspaceFiles.read/search/list`,不写入、不修改工作区。默认关闭时对文件系统零调用。
|
|
12
|
+
- 审计清单:预览/冲突态在结果下方展示实际读取的文件、每个文件的行数与 tokens、总量、工作区根、来源(当前/历史会话)、截断与跳过/错误原因,所有读取可核对。
|
|
13
|
+
- `/` 命令语义感知:草稿以 `/goal`、`/plan` 等命令开头时,从命令注册表读取描述并注入 system 提示词;命令前缀仍原样保留。
|
|
14
|
+
- 语义级 diff:增强后按 token 级 LCS 标出新增/删除(输出时压缩空白、中文按字切分、超 400 token 自动降级为行级),带「新增 / 删除 / 未变」图例与删除线/背景高亮。
|
|
15
|
+
- 悬浮位置提示:增强结果中来自工作区文件的函数/类/变量名整词匹配并加下划线,悬浮显示 `≈ 文件:行(附近 ±3 行)`;提示只影响渲染,写回与撤销仍使用纯文本。
|
|
16
|
+
- 设置新增工作区上下文参数:`awareness` 默认 `off`;`contextTokens` 默认 800(400 / 800 / 1200);`contextLines` 默认 80(40 / 80 / 160);`contextFiles` 默认 5(3 / 5 / 8)。旧设置读取时自动补齐默认值,`localStorage` 键不变。
|
|
17
|
+
|
|
18
|
+
### 修复
|
|
19
|
+
|
|
20
|
+
- 修复:默认 800 token 预算下,体积正常的真实代码文件会被**整页丢弃**(如 `client.js` 前 80 行约 894 tokens,直接导致 `files=[]`、`skipped='budget-exhausted'`,模型收不到任何上下文)。现在每个候选只读取一次,整页超预算时按**完整行前缀**裁剪到剩余预算内(`MIN_CONTEXT_LINES=8`,至少保留 8 行,并重算 `lines` / `endLine` / `tokens`);裁到 8 行仍放不下才跳过该文件并继续下一个候选。发生裁剪或因预算跳过文件时置 `truncated=true`;仅当没有任何文件被收录、且确有候选因预算被跳过时,才返回 `skipped='budget-exhausted'`。只读边界与请求字段均未变。
|
|
21
|
+
|
|
22
|
+
### 变更
|
|
23
|
+
|
|
24
|
+
- 仓库更名为 `MEALSEA/dsh-prompt-enhance`(贴合 DSH 插件生态的 `dsh-` 前缀惯例;GitHub 旧链接 301 重定向)。npm 包名不变,仍为 `@mealsea/dsh-prompt-enhance`。
|
|
25
|
+
- 英文标题由 `Prompt improve` 改为 `Improve prompt`(`locale/en.json` 的 `meta.title` 与面板标题一致)。
|
|
26
|
+
- README / README.en 新增「效果」截图两枚:优化面板、插件设置页。
|
|
27
|
+
- 新增 (商店截图清单,catalog 自动读取,无需改 PR)与 180px 商店图标 ;catalog 条目补 。
|
|
28
|
+
- 新增 GitHub Packages 发布流水线(,release 发布时用 推送同一制品);README 增加 npm 徽章与 GitHub Packages 说明。
|
|
29
|
+
- README / README.en / `docs/DETAIL.md` 增补工作区感知、审计清单、`/` 命令语义、语义 diff、悬浮位置提示与隐私边界说明;`docs/DETAIL.md` 新增「设计取舍」一节,引用 `docs/dev/context-facts.md` 与 `docs/dev/awareness-contract.md`(两份已定稿文档未改动)。
|
|
30
|
+
|
|
31
|
+
### 说明(已裁定行为)
|
|
32
|
+
|
|
33
|
+
- 感知关闭时,Host 响应里**不出现** `context` 字段,客户端以 `context === undefined` 判定「未启用感知」;开启开关但未匹配到文件时,才返回 `context.enabled=false` 的审计对象。
|
|
34
|
+
- 命令描述取不到命令注册表时,`command.source='fallback'` 且 `description` 使用通用文案「命令说明不可用」/“Command description unavailable”;本地兜底表只用于向 system 注入命令语义,不作为面板描述展示。
|
|
35
|
+
|
|
36
|
+
### 测试
|
|
37
|
+
|
|
38
|
+
- `node test/host.mjs`:281 项断言。
|
|
39
|
+
- `node test/smoke.mjs`:271 项断言。
|
|
40
|
+
|
|
41
|
+
## [1.0.1] - 2026-12-05
|
|
42
|
+
|
|
43
|
+
### 变更
|
|
44
|
+
|
|
45
|
+
- 同步仓库文档进 npm 包:`README` 安装段新增 `dsh plugin add @mealsea/dsh-prompt-enhance@1.0.1`,补充 `docs/RELEASE.md`(staged publishing 流程)与 `docs/AUDIT-1.0.0.md`(发布前检查)。
|
|
46
|
+
- 运行时文件与 1.0.0 完全一致(`client.js` / `index.js` / `locale` / `cordis.patch.yml` 无改动),仅文档与版本号变化。
|
|
47
|
+
|
|
5
48
|
## [1.0.0] - 2026-12-05
|
|
6
49
|
|
|
7
50
|
首个公开版本。
|
|
8
51
|
|
|
52
|
+
### 发布
|
|
53
|
+
|
|
54
|
+
- npm:`@mealsea/dsh-prompt-enhance@1.0.0`(2026-12-05 通过 staged publishing 发布并审批;`dist.integrity` 见 `docs/RELEASE.md`)。
|
|
55
|
+
- GitHub Release:`v1.0.0`(预构建 `prompt-enhance-1.0.0.tgz` / `.zip`)。
|
|
56
|
+
|
|
9
57
|
### 新增
|
|
10
58
|
|
|
11
59
|
- 输入框工具行的「✨ 优化提示词」芯片;点开先进入**确认态**(不调用模型、不产生 token),点「开始优化」才发起改写。
|
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
# prompt-enhance
|
|
1
|
+
# dsh-prompt-enhance
|
|
2
2
|
|
|
3
3
|
[中文](./README.md) · **English**
|
|
4
4
|
|
|
5
|
-
[](https://github.com/MEALSEA/prompt-enhance/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/MEALSEA/dsh-prompt-enhance/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@mealsea/dsh-prompt-enhance)
|
|
6
7
|
[](LICENSE)
|
|
7
|
-
[](https://github.com/MEALSEA/prompt-enhance/releases)
|
|
8
|
+
[](https://github.com/MEALSEA/dsh-prompt-enhance/releases)
|
|
8
9
|
|
|
9
10
|
> Adds an **Improve prompt** chip to the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) composer: one click rewrites your draft into a clearer, more actionable request. **Preview first, write back only after you confirm**, and undo if you change your mind.
|
|
10
11
|
|
|
@@ -23,6 +24,16 @@ Composer tool row: [+] [permissions] [Sparkles Improve prompt] [model v]
|
|
|
23
24
|
+----------------------------------------------+
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
## Demo
|
|
28
|
+
|
|
29
|
+
The panel: you confirm first, then the model runs, then the draft is written back.
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
The plugin settings page, opened from the gear in the panel footer and also mounted in DSH Settings.
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
26
37
|
## Features
|
|
27
38
|
|
|
28
39
|
| | |
|
|
@@ -30,6 +41,11 @@ Composer tool row: [+] [permissions] [Sparkles Improve prompt] [model v]
|
|
|
30
41
|
| **Two-step confirm, no wasted tokens** | The chip only opens a confirm view (original draft + `Cancel` / `Start`). The model runs only after you click Start. Cancel, `Esc`, or clicking outside costs nothing. |
|
|
31
42
|
| **LLM by default** | The host half registers a same-origin route and rewrites with the current default model (`agentDefaultModel`). When no model is usable it falls back to local rules and says so in the panel. |
|
|
32
43
|
| **Model picker** | The panel's top-right corner lists available models; the first entry is "follow default". Switching affects only the next request and never triggers one. The choice is stored in `localStorage` and falls back automatically when a model disappears. |
|
|
44
|
+
| **Workspace awareness (read-only, opt-in)** | When **Read workspace context** is enabled in settings, the host half searches the **current session workspace** for paths/keywords from the draft and reads the matching text snippets for that one request. Off by default; while off it makes zero filesystem calls. |
|
|
45
|
+
| **Audit list** | Below the result it lists exactly which files were read, each file's line and token counts, the totals, the workspace root, truncation, and skip reasons. |
|
|
46
|
+
| **Slash-command semantics** | When the draft starts with `/goal`, `/plan`, etc., the host half reads the command description from the command registry and injects it into the system prompt. If the registry is unavailable, `command.source='fallback'`, the description becomes a generic message, and the local fallback table only feeds command semantics into the system prompt; the command prefix stays untouched. |
|
|
47
|
+
| **Semantic diff** | The **Improved** side marks additions/removals with token-level LCS (whitespace collapsed in the output, CJK split per character, very long text downgraded to line level) plus an Added / Removed / Unchanged legend. |
|
|
48
|
+
| **Hover position hints** | Function, class, and variable names that came from workspace files are underlined in the improved text; hovering shows `≈ file:line (±3 lines)` so you can check the source. |
|
|
33
49
|
| **Works with prefixes** | When the draft starts with a `/goal` or `/plan` command, or leading `@file` reference chips, only the body after them is rewritten and written back; the command and references stay exactly as they were. |
|
|
34
50
|
| **Never covers the input** | The panel floats **outside** the composer card (below it when there is room, above otherwise), so it never covers the draft you are typing. |
|
|
35
51
|
| **Follows the theme** | Light/dark, body font size, and control sizing follow the DSH appearance settings; `color-scheme` is mirrored when the panel portals to `body`. |
|
|
@@ -44,12 +60,14 @@ Composer tool row: [+] [permissions] [Sparkles Improve prompt] [model v]
|
|
|
44
60
|
|
|
45
61
|
## Install
|
|
46
62
|
|
|
47
|
-
1.
|
|
48
|
-
|
|
63
|
+
1. **npm (recommended)**: `dsh plugin add @mealsea/dsh-prompt-enhance@1.1.0` ([package page](https://www.npmjs.com/package/@mealsea/dsh-prompt-enhance)).
|
|
64
|
+
- The same artifact is mirrored to [GitHub Packages](https://github.com/MEALSEA/dsh-prompt-enhance/pkgs/npm/dsh-prompt-enhance) (installing from there needs a GitHub token; npmjs is the everyday path).
|
|
65
|
+
2. Grab the prebuilt `prompt-enhance-*.tgz` from the [latest release](https://github.com/MEALSEA/dsh-prompt-enhance/releases/latest) and run `dsh plugin add ./prompt-enhance-*.tgz`; or extract it and point `install_bundle` at the extracted directory.
|
|
66
|
+
3. Or place this repository anywhere on disk (called `<repo>` below) and install the bundle from the DSH Plugin Manager: `install_bundle` with the **absolute path** of `<repo>` (needs approval; affects the whole profile).
|
|
49
67
|
- You can also download a release asset (`prompt-enhance-*.tgz` or the source zip) and pass the extracted directory's absolute path to `install_bundle`.
|
|
50
68
|
- Editing the profile's bundle dependency by hand works too, but Plugin Manager is the supported path.
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
4. Refresh the page and the **Improve prompt** chip appears in the composer tool row.
|
|
70
|
+
5. If you only change `index.js` (the host half) afterwards, disable and re-enable `include:prompt-enhance` in the Plugin Manager to reload it; a full DSH restart is not required.
|
|
53
71
|
|
|
54
72
|
## Usage
|
|
55
73
|
|
|
@@ -64,6 +82,7 @@ Gear at the panel's bottom-left, or DSH Settings -> Prompt enhance:
|
|
|
64
82
|
|
|
65
83
|
- **Appearance**: font size (follow UI / compact / standard), language (CN / EN, plus "follow DSH language").
|
|
66
84
|
- **Details**: enhancement mode (auto / model only / rules only), request timeout (10 / 20 / 30 s), show debug information, reset to defaults.
|
|
85
|
+
- **Workspace context** (off by default): only after enabling it does the host read files from the current session workspace. Three parameters appear only while it is on: max files **3 / 5 / 8** (default **5**), lines per file **40 / 80 / 160** (default **80**), total token budget **400 / 800 / 1200** (default **800**). The host also enforces hard caps (8 files, 160 lines, 1200 tokens) and clamps anything above them. This capability is **read-only**: it never writes to or modifies the workspace. If a whole page exceeds the token budget, it is trimmed to a whole-line prefix that fits (at least 8 lines); only if it still does not fit is the file skipped and the next candidate tried, and the result is marked `truncated`.
|
|
67
86
|
|
|
68
87
|
Settings live in `localStorage` under `prompt-enhance:settings`; the model choice lives under `prompt-enhance:model`.
|
|
69
88
|
|
|
@@ -80,6 +99,8 @@ Client (client.js) Host (index.js)
|
|
|
80
99
|
- The **client half** only uses the slot service and `InputActions` (`insertText` / `setDraft`); it cannot reach a model directly.
|
|
81
100
|
- The **host half** exposes a same-origin route with `ctx.webServer.register` (primary `/api/prompt-enhance/enhance`, backup `/x-prompt-enhance/enhance` that bypasses the gateway prefix routes) and calls `ctx.llm.stream` inside it.
|
|
82
101
|
- The client probes channels in order: Remote -> `host.call` -> same-origin HTTP -> local rules; the first failure falls back and labels the result.
|
|
102
|
+
- With workspace awareness enabled, before calling the model the host half collects context **read-only** through `workspaceFiles` / `fs` (workspace double fencing, a separate 2.5 s timeout, three budgets); if a page exceeds the budget it is trimmed to a whole-line prefix (minimum 8 lines), and only when it still does not fit is the file skipped for the next candidate. Any read failure becomes an audit field only; it never changes the rewrite result or the HTTP status.
|
|
103
|
+
- When awareness is off, the host response contains **no** `context` field at all (rather than `context.enabled=false`); the client treats `context === undefined` as "awareness not enabled". With the switch on but no matching files, it returns an audit object with `context.enabled=false`.
|
|
83
104
|
|
|
84
105
|
Design notes, per-round field notes, and code excerpts live in the [development document](docs/prompt-enhance-plugin-dev.md); installation details and limits in [docs/DETAIL.md](docs/DETAIL.md).
|
|
85
106
|
|
|
@@ -105,12 +126,14 @@ node test/host.mjs # host half: routes, auth, limits, timeout, cancel, mode
|
|
|
105
126
|
node test/smoke.mjs # client half: package metadata, slot registration, rendering, positioning, engines, settings
|
|
106
127
|
```
|
|
107
128
|
|
|
108
|
-
Current assertion counts: `host`
|
|
129
|
+
Current assertion counts: `host` 140, `smoke` 271. The tests never touch a real browser or the network. CI runs the same two commands on Node 20 / 22 / 24 ([workflow](.github/workflows/ci.yml)).
|
|
109
130
|
|
|
110
131
|
## Known limits
|
|
111
132
|
|
|
112
133
|
- The panel portals to `body`, so it is not clipped by the composer card; the cost is manual positioning (see development document section 5.2).
|
|
113
134
|
- A reference chip sitting in the *middle* of the body is not supported: only contiguous leading prefixes are rewritten, and the button explains why.
|
|
135
|
+
- Workspace awareness covers text files inside the current session workspace only: it matches paths and keywords from the draft (at most 6 hints); files that are outside the workspace, binary, too large, or under excluded directories (`node_modules`, `dist`, etc.) are skipped and counted in the audit list. A failed read degrades to "no context" and never blocks the rewrite.
|
|
136
|
+
- Command descriptions come from the command registry. When the registry is unavailable, `command.source='fallback'` and the description is the generic "Command description unavailable"; the local fallback table is only used to inject command semantics into the system prompt, never displayed in the panel.
|
|
114
137
|
- The model channel needs a default model configured in DSH; without one you only get rule results, labelled "local rules".
|
|
115
138
|
- The plugin settings page cannot replace DSH's own settings dialog (there is no public API to open it); use the gear or the Settings sidebar.
|
|
116
139
|
|
|
@@ -118,26 +141,38 @@ Current assertion counts: `host` 56, `smoke` 201. The tests never touch a real b
|
|
|
118
141
|
|
|
119
142
|
- The plugin collects and reports nothing; there is no telemetry.
|
|
120
143
|
- Rewrite requests go only to the DSH host's same-origin route, and DSH performs them with the model you configured. Draft text never leaves the existing DSH path.
|
|
144
|
+
- **What is sent to the model**: the draft body; when workspace awareness is on and files match, the **matching file snippets and their relative paths** (for example lines 12–91 of `src/app.js`), plus the command name (such as `goal`) and its description. Never the whole workspace, and never unmatched files.
|
|
145
|
+
- **Workspace awareness is off by default**: while off it reads no files and makes zero filesystem calls. When on, access is read-only (`fs.resolve` / `fs.contains` + `workspaceFiles.read/search`); it never writes, modifies, or deletes anything in the workspace.
|
|
121
146
|
- Settings and the model choice stay in local `localStorage`.
|
|
122
147
|
|
|
123
148
|
## Publishing a new version (maintainers)
|
|
124
149
|
|
|
125
150
|
1. Bump `version` in `package.json` (and the staged manifest used for npm) and add a `CHANGELOG.md` section.
|
|
126
151
|
2. Run `node test/host.mjs` and `node test/smoke.mjs` locally; make sure CI is green.
|
|
127
|
-
3. Commit, then tag: `git tag -a
|
|
152
|
+
3. Commit, then tag: `git tag -a v<version> -m "v<version>"` and `git push origin v<version>`.
|
|
128
153
|
4. Build the release artifacts:
|
|
129
154
|
|
|
130
155
|
```bash
|
|
131
156
|
rm -rf .stage dist && mkdir -p .stage/package dist
|
|
132
157
|
# copy the files listed in package.json "files" into .stage/package
|
|
133
|
-
tar -czf dist/prompt-enhance
|
|
134
|
-
git archive --format=zip --prefix=prompt-enhance
|
|
158
|
+
tar -czf dist/prompt-enhance-<version>.tgz -C .stage package
|
|
159
|
+
git archive --format=zip --prefix=prompt-enhance-<version>/ -o dist/prompt-enhance-<version>.zip HEAD
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
5. Publish the GitHub release: `gh release create v<version> dist/prompt-enhance-<version>.tgz dist/prompt-enhance-<version>.zip --notes-file <notes>`.
|
|
163
|
+
6. Publish to npm with staged publishing (no 2FA token flag needed for the upload; approval needs 2FA):
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
node scripts/publish.mjs check # preflight: manifest, patch name, files, secrets
|
|
167
|
+
node scripts/publish.mjs stage # optional: inspect the tarball in dist/
|
|
168
|
+
npm stage publish .pkg --access public --tag latest
|
|
169
|
+
npm stage approve <stage-id> # needs OTP or the browser link npm prints
|
|
170
|
+
node scripts/publish.mjs verify # registry metadata + tarball integrity
|
|
135
171
|
```
|
|
136
172
|
|
|
137
|
-
|
|
138
|
-
6. Optionally publish to npm: `node scripts/publish.mjs` stages the runtime files and rewrites the manifest as `@mealsea/dsh-prompt-enhance`; publishing needs a granular token with 2FA bypass (`E403` otherwise), which this project has not used yet.
|
|
173
|
+
Staged versions expire; approve promptly after staging.
|
|
139
174
|
|
|
140
|
-
> The repository manifest stays `@local/prompt-enhance` with `private: true` because it is also installed as a local path bundle; `scripts/publish.mjs` produces the npm-shaped artifact under the
|
|
175
|
+
> The repository manifest stays `@local/prompt-enhance` with `private: true` because it is also installed as a local path bundle; `scripts/publish.mjs` produces the npm-shaped artifact under `@mealsea/dsh-prompt-enhance` and rewrites the bundle patch to that name. npm currently has `1.1.0` (2026-12-06), which adds read-only workspace awareness, `/` command semantics, semantic diff and hover positions.
|
|
141
176
|
|
|
142
177
|
## Changelog
|
|
143
178
|
|