@mealsea/dsh-prompt-enhance 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ 本项目遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
+
5
+ ## [1.0.0] - 2026-12-05
6
+
7
+ 首个公开版本。
8
+
9
+ ### 新增
10
+
11
+ - 输入框工具行的「✨ 优化提示词」芯片;点开先进入**确认态**(不调用模型、不产生 token),点「开始优化」才发起改写。
12
+ - 面板展示「原文 / 增强后」与改动说明;「应用修改」写回草稿,5 秒内可撤销。
13
+ - 模型选择器:面板右上角列出可用模型,首项「跟随默认」,选择存于 `localStorage`,切换不触发请求。
14
+ - Host 半同源路由(主 `/api/prompt-enhance/enhance`,备用 `/x-prompt-enhance/enhance`),内部用 `ctx.llm.stream` 调当前默认模型;失败自动降级为本地规则结果并标注原因。
15
+ - 跟随 DSH 外观(亮/暗、字号、控件尺寸)与语言;设置页可锁定 CN / EN。
16
+ - 插件设置页(齿轮入口),同一组件挂载到 DSH「设置」栏的 `settings.section`。
17
+ - 命令/引用前缀(`/goal`、开头的 `@文件`)下只改写正文,前缀原样保留。
18
+ - 写回使用 detect 坐标并带 revision CAS;冲突判定只比较正文,未改草稿不会误报。
19
+
20
+ ### 修复
21
+
22
+ - 模型列表在打开选择器时被自身清理逻辑中止、永久停在「加载模型列表…」。
23
+ - 带前缀芯片时写回区间用 clipboard 坐标导致 `insertText` 静默失败、面板误报「草稿在你确认前被修改过」。
24
+ - 面板向下展开遮挡输入框;改为浮在输入卡片外侧(下方优先、空间不足翻上方)。
25
+ - 暗色下半透明菜单底导致的配色偏差;改用实色 `--dsw-specific-sidebar-fill`。
26
+
27
+ ### 测试
28
+
29
+ - `node test/host.mjs`:56 项断言。
30
+ - `node test/smoke.mjs`:201 项断言。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MEALSEA
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,150 @@
1
- # Temporary Holding Version
1
+ # prompt-enhance
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [中文](./README.md) · **English**
4
+
5
+ [![CI](https://github.com/MEALSEA/prompt-enhance/actions/workflows/ci.yml/badge.svg)](https://github.com/MEALSEA/prompt-enhance/actions/workflows/ci.yml)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![release](https://img.shields.io/github/v/release/MEALSEA/prompt-enhance)](https://github.com/MEALSEA/prompt-enhance/releases)
8
+
9
+ > 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
+ Plain JavaScript, a single client file, no build step, no third-party runtime dependencies.
12
+
13
+ ```
14
+ Composer tool row: [+] [permissions] [Sparkles Improve prompt] [model v] [send]
15
+ | click (no model call)
16
+ v
17
+ +----------------------------------------------+
18
+ | Sparkles Prompt enhance model not called yet |
19
+ | Original |
20
+ | fix this error for me |
21
+ | The model only runs after you click Start. |
22
+ | [Cancel] [Start] |
23
+ +----------------------------------------------+
24
+ ```
25
+
26
+ ## Features
27
+
28
+ | | |
29
+ | --- | --- |
30
+ | **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
+ | **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
+ | **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. |
33
+ | **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
+ | **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
+ | **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`. |
36
+ | **Language aware / EN-CN** | Follows the DSH language by default; the settings page can pin EN or CN, which also switches the model's system prompt language. |
37
+ | **Settings page** | The gear at the panel's bottom-left opens the plugin settings page, which is also mounted in the DSH Settings sidebar (`settings.section`). |
38
+ | **Safe write-back** | Conflicts compare only the body text; write-back uses detect-space coordinates (chips count as one character) plus a revision check, and reports the real reason on failure instead of faking a conflict. Undo is available for 5 seconds after applying. |
39
+
40
+ ## Requirements
41
+
42
+ - DeepSeek Harness (desktop or web) with the plugin system available; the host half needs the `webServer` service.
43
+ - Node.js 18+ to run the tests (ESM and built-in test scripts, no third-party packages).
44
+
45
+ ## Install
46
+
47
+ 1. Grab the prebuilt `prompt-enhance-*.tgz` from the [latest release](https://github.com/MEALSEA/prompt-enhance/releases/latest) and run `dsh plugin add ./prompt-enhance-*.tgz`; or extract it and point `install_bundle` at the extracted directory.
48
+ 2. 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
+ - 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
+ - Editing the profile's bundle dependency by hand works too, but Plugin Manager is the supported path.
51
+ 3. Refresh the page and the **Improve prompt** chip appears in the composer tool row.
52
+ 4. 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
+
54
+ ## Usage
55
+
56
+ 1. Type a draft in the composer (a `/goal` prefix or `@file` reference is fine).
57
+ 2. Click **Improve prompt**. The panel shows your original text; **no model call has happened yet**.
58
+ 3. Click **Start**. The panel shows original vs. enhanced text plus what changed; you can switch the model in the top-right and retry.
59
+ 4. Click **Apply** to write the result back into the draft; undo is available for 5 seconds.
60
+
61
+ ## Settings
62
+
63
+ Gear at the panel's bottom-left, or DSH Settings -> Prompt enhance:
64
+
65
+ - **Appearance**: font size (follow UI / compact / standard), language (CN / EN, plus "follow DSH language").
66
+ - **Details**: enhancement mode (auto / model only / rules only), request timeout (10 / 20 / 30 s), show debug information, reset to defaults.
67
+
68
+ Settings live in `localStorage` under `prompt-enhance:settings`; the model choice lives under `prompt-enhance:model`.
69
+
70
+ ## How it works
71
+
72
+ ```
73
+ Client (client.js) Host (index.js)
74
+ conversation.input.left slot
75
+ chip / panel / settings --- POST /api/prompt-enhance/enhance ---> validate, timeout, cancel
76
+ ctx.llm.stream(...)
77
+ rule engine (fallback) <--- { text } -------------------------- clean output
78
+ ```
79
+
80
+ - The **client half** only uses the slot service and `InputActions` (`insertText` / `setDraft`); it cannot reach a model directly.
81
+ - 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
+ - The client probes channels in order: Remote -> `host.call` -> same-origin HTTP -> local rules; the first failure falls back and labels the result.
83
+
84
+ 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
+
86
+ ## Repository layout
87
+
88
+ ```
89
+ package.json # bundle metadata (dsh.bundle.patch / dsh.client)
90
+ cordis.patch.yml # plugin insert patch
91
+ index.js # host half: same-origin route + ctx.llm.stream
92
+ client.js # client half: chip + panel + engines (model/HTTP/rules)
93
+ locale/{zh,en}.json # plugin list display metadata
94
+ icon.svg # icon
95
+ docs/ # development document and detail page
96
+ test/host.mjs # host-half unit tests (fake ctx/req/res)
97
+ test/smoke.mjs # browser-free smoke tests
98
+ ```
99
+
100
+ ## Develop and test
101
+
102
+ ```bash
103
+ # all green before committing
104
+ node test/host.mjs # host half: routes, auth, limits, timeout, cancel, model catalog/selection
105
+ node test/smoke.mjs # client half: package metadata, slot registration, rendering, positioning, engines, settings
106
+ ```
107
+
108
+ Current assertion counts: `host` 56, `smoke` 201. 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
+
110
+ ## Known limits
111
+
112
+ - 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
+ - A reference chip sitting in the *middle* of the body is not supported: only contiguous leading prefixes are rewritten, and the button explains why.
114
+ - The model channel needs a default model configured in DSH; without one you only get rule results, labelled "local rules".
115
+ - 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
+
117
+ ## Privacy
118
+
119
+ - The plugin collects and reports nothing; there is no telemetry.
120
+ - 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.
121
+ - Settings and the model choice stay in local `localStorage`.
122
+
123
+ ## Publishing a new version (maintainers)
124
+
125
+ 1. Bump `version` in `package.json` (and the staged manifest used for npm) and add a `CHANGELOG.md` section.
126
+ 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 v1.0.1 -m "v1.0.1"` and `git push origin v1.0.1`.
128
+ 4. Build the release artifacts:
129
+
130
+ ```bash
131
+ rm -rf .stage dist && mkdir -p .stage/package dist
132
+ # copy the files listed in package.json "files" into .stage/package
133
+ tar -czf dist/prompt-enhance-1.0.1.tgz -C .stage package
134
+ git archive --format=zip --prefix=prompt-enhance-1.0.1/ -o dist/prompt-enhance-1.0.1.zip HEAD
135
+ ```
136
+
137
+ 5. Publish the GitHub release: `gh release create v1.0.1 dist/prompt-enhance-1.0.1.tgz dist/prompt-enhance-1.0.1.zip --notes-file <notes>`.
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.
139
+
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 public name when a 2FA-capable token is available.
141
+
142
+ ## Changelog
143
+
144
+ See [CHANGELOG.md](CHANGELOG.md).
145
+
146
+ ## License
147
+
148
+ [MIT License](LICENSE) (c) 2026 MEALSEA. Third-party icon and trademark notes: [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
149
+
150
+ Unofficial extension; not affiliated with DeepSeek.
@@ -0,0 +1,44 @@
1
+ # 第三方声明 / Third-Party Notices
2
+
3
+ 本项目自身以 [MIT License](LICENSE) 发布。以下内容来自第三方,按其各自许可使用。
4
+
5
+ ## Feather Icons
6
+
7
+ - 用途:`client.js` 中的齿轮图标与下拉箭头图标的 SVG 路径。
8
+ - 来源:<https://github.com/feathericons/feather>
9
+ - 许可:MIT License
10
+ - 版权:Copyright (c) 2013-2023 Cole Bemis
11
+
12
+ ```
13
+ The MIT License (MIT)
14
+
15
+ Copyright (c) 2013-2023 Cole Bemis
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
34
+ ```
35
+
36
+ ## DeepSeek Harness(DSH)
37
+
38
+ 本插件是面向 DeepSeek Harness 客户端契约(slot、InputActions、Host 服务)编写的**非官方**扩展,与 DeepSeek 无隶属关系。
39
+ 仓库中不包含任何 DSH 源码或其 `node_modules` 内容;文档里出现的包名、源码路径仅用于说明对接点。
40
+
41
+ ## 其他
42
+
43
+ - 图标 `icon.svg`、`client.js` 中的星形图标为本项目原创。
44
+ - 运行时不依赖任何第三方 npm 包;测试仅使用 Node.js 内置模块。