dsh-plugin-greeting-bubble 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 腾盛
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,268 @@
1
- # Temporary Holding Version
1
+ # dsh-plugin-greeting-bubble · 你好,腾盛
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
+ 一个用于 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)Web 界面的小型 UI 插件:页面加载后,在**窗口右下角**弹出「你好,腾盛」问候气泡,点 × 即可关闭。
4
+
5
+ - 不联网、不收集任何数据、不读写会话内容;
6
+ - 不修改 DSH 自带界面,只是往整帧浮层 `shell.overlay` 里加一个自己的气泡;
7
+ - 跟随亮色 / 暗色主题,支持键盘操作与 `prefers-reduced-motion`;
8
+ - Host 端不执行任何逻辑(`apply()` 为空),只负责让浏览器半加载。
9
+
10
+ > 适配版本:DeepSeek Harness **0.2.2-rc.5**(Desktop 与浏览器 Web GUI)。
11
+
12
+ ---
13
+
14
+ ## 目录
15
+
16
+ - [效果](#效果)
17
+ - [安装](#安装)
18
+ - [使用](#使用)
19
+ - [自定义](#自定义)
20
+ - [工作原理(完整流程)](#工作原理完整流程)
21
+ - [文件结构](#文件结构)
22
+ - [本地开发与测试](#本地开发与测试)
23
+ - [兼容性与限制](#兼容性与限制)
24
+ - [English](#english)
25
+ - [License](#license)
26
+
27
+ ---
28
+
29
+ ## 效果
30
+
31
+ - 页面加载约 0.35 秒后,右下角(距右 20px、距底 84px,即输入框发送按钮上方)淡入气泡:👋 你好,腾盛 ×
32
+ - 点气泡右侧的 **×** 关闭;关闭只对当前页面生效,**刷新页面后会再次出现**。
33
+ - **按住气泡可以拖动**:光标变成抓手,拖到任意位置松手即可;位置会记在浏览器里,下次打开(包括刷新)仍在原处。
34
+ - 默认位置刻意抬到输入框上方,不会盖住发送按钮;拖动后由你决定位置。气泡本体需要接收拖动事件,所以它所在的小块区域会接住点击,其余区域不受影响。
35
+ - 在「插件」「设置」等页面同样显示(浮层属于整个应用框架)。
36
+ - 进入动画在系统开启“减少动态效果”时自动关闭;窄窗口下气泡最大宽度自动收缩,不会被拖出屏幕(拖动时自动限制在可视区内)。
37
+
38
+ ## 安装
39
+
40
+ 四种方式任选其一。都需要本机可用的 `pnpm`(DSH 插件安装自带);GitHub 安装还需要能访问 `github.com` 的 `git`。
41
+
42
+ ### 方式一:从 npm 安装(最稳,推荐)
43
+
44
+ 插件发布到 npm 后,在 **插件 → 添加插件** 中直接填包名:
45
+
46
+ ```
47
+ dsh-plugin-greeting-bubble
48
+ ```
49
+
50
+ 安装走 npm 源(国内可用镜像兜底),不经过 GitHub 的网络检查;发布新版本后还能在插件页直接“更新”。
51
+
52
+ ### 方式二:从 GitHub 直接安装
53
+
54
+ 1. 打开 DSH Web 界面,左侧边栏进入 **插件**。
55
+ 2. 点右上角 **添加插件**。
56
+ 3. 在「包名或地址」中填入仓库地址(把用户名换成实际的):
57
+
58
+ ```
59
+ https://github.com/liwei169/dsh-plugin-greeting-bubble
60
+ ```
61
+
62
+ 也支持 pnpm 的简写:`github:liwei169/dsh-plugin-greeting-bubble`。
63
+ 4. 点 **安装**,等待下载完成。安装成功后会自动启用,气泡随即出现(页面已打开时通常无需刷新;若没出现,刷新一次)。
64
+
65
+ ### 方式三:本地目录安装
66
+
67
+ ```powershell
68
+ git clone https://github.com/liwei169/dsh-plugin-greeting-bubble.git
69
+ ```
70
+
71
+ 然后在 **插件 → 添加插件** 中填入克隆下来的本地目录路径(例如 `D:\dsh-plugin-greeting-bubble`)并安装。
72
+
73
+ > 本地目录安装是软链接(`link:`):移动或删除该目录,插件会失效。长期使用建议用方式一或方式二。
74
+
75
+ ### 方式四:让 agent 安装
76
+
77
+ 在 DSH 对话里说“安装 D:\dsh-plugin-greeting-bubble 这个插件”,agent 会调用 `plugin_manager` 的 `install_bundle` 完成同样的步骤。
78
+
79
+ ### 验证安装
80
+
81
+ - **插件** 页的「已安装插件」列表里出现 **Greeting bubble / 右下角问候气泡**,状态为运行中;
82
+ - 右下角出现气泡。
83
+
84
+ ## 使用
85
+
86
+ | 操作 | 结果 |
87
+ | --- | --- |
88
+ | 页面加载 | 气泡出现(每个页面视图一次) |
89
+ | **按住气泡拖动** | 气泡跟着指针移动,松手后记住位置 |
90
+ | 点 ×(或聚焦后按 Enter / Space) | 本次页面隐藏气泡 |
91
+ | 刷新页面 | 气泡再次出现,位置保持上次拖到的位置 |
92
+ | 插件页关闭该包的开关 | 气泡立即消失(HMR 生效时无需刷新) |
93
+ | 插件页卸载该包 | 彻底移除,不再出现 |
94
+
95
+ ## 自定义
96
+
97
+ 所有可改的东西都在两三个文件里,改完保存即可(开发模式自动热重载;正式安装需要重装或重启 DSH 后生效)。
98
+
99
+ ### 1. 改问候语
100
+
101
+ 编辑 `client.js` 中 `apply()` 里的字典(`zh` / `en` 两处):
102
+
103
+ ```js
104
+ zh: { greeting: '你好,腾盛', dismiss: '关闭问候气泡' },
105
+ en: { greeting: '你好,腾盛', dismiss: 'Dismiss greeting' },
106
+ ```
107
+
108
+ 问候语刻意在两种语言下保持一致(它是这个插件固定的“签名语”),只有关闭按钮的提示文字跟随界面语言。想让英文界面显示英文问候,把 `en.greeting` 改成 `Hello, Tengsheng` 即可。
109
+
110
+ ### 2. 改默认位置 / 拖动记忆
111
+
112
+ 默认位置在 `client.js` 的 `.dsh-greeting-bubble` 里:
113
+
114
+ ```css
115
+ right: calc(20px + env(safe-area-inset-right, 0px));
116
+ bottom: calc(84px + env(safe-area-inset-bottom, 0px)); /* 输入框发送按钮上方 */
117
+ ```
118
+
119
+ 改成 `left` / `top` 就能换角;把 `20px` 调大即离边更远。`bottom` 不要低于 `84px`:DSH 的发送按钮在输入卡右下角,贴近底边会在窄窗口下盖住它。
120
+
121
+ 拖动后的位置保存在 localStorage 的 `dsh-greeting-bubble:position:v1` 键里。想恢复默认位置,在浏览器控制台执行:
122
+
123
+ ```js
124
+ localStorage.removeItem('dsh-greeting-bubble:position:v1')
125
+ ```
126
+
127
+ 然后刷新页面即可。
128
+
129
+ ### 3. 改视觉
130
+
131
+ - 圆角、描边、阴影:`--dsw-radius-lg`、`--dsw-elevation-stroke-color`、`--dsw-elevation-prominent`,与 DSH 原生浮层一致;
132
+ - 底/字色:`--dsw-alias-bg-layer-3`、`--dsw-alias-label-primary`,自动跟随亮/暗主题;
133
+ - 尺寸与字号:`.dsh-greeting-bubble` 的 `font-size`、`gap`、`padding`。
134
+
135
+ ### 4. 改成“只问候一次”(可选)
136
+
137
+ 默认每次页面加载都会出现。如果希望用户关闭后永久不再出现,在组件里加一个 `localStorage` 开关,例如:
138
+
139
+ ```js
140
+ function GreetingBubble({ t }) {
141
+ const KEY = 'dsh-greeting-bubble:dismissed';
142
+ const [dismissed, setDismissed] = React.useState(() => {
143
+ try { return window.localStorage.getItem(KEY) === '1'; } catch { return false; }
144
+ });
145
+ if (dismissed) return null;
146
+ const close = () => {
147
+ try { window.localStorage.setItem(KEY, '1'); } catch {}
148
+ setDismissed(true);
149
+ };
150
+ // …把 onClick: () => setDismissed(true) 换成 onClick: close
151
+ }
152
+ ```
153
+
154
+ 清除 `localStorage` 里这个键即可让问候重新出现。
155
+
156
+ ### 5. 改图标、名称、描述
157
+
158
+ - 图标:`icon.svg`(36×36,纯几何、无文字);
159
+ - 插件页显示的名称与说明:`locale/zh.json`、`locale/en.json` 的 `meta.title` / `meta.description`;
160
+ - 详情页大图:`docs/preview.svg`(由 `docs/DETAIL.md` 引用)。
161
+
162
+ ## 工作原理(完整流程)
163
+
164
+ 插件是一个 **DSH bundle(组合包)**,由一个 Host 插件行 + 一个浏览器端模块组成。整条链路如下:
165
+
166
+ ```text
167
+ package.json
168
+ ├─ dsh.bundle.patch → cordis.patch.yml 往 profile 的 Loader 插入一行插件
169
+ └─ dsh.client → ./client.js 声明浏览器半(platform: web)
170
+
171
+ 安装(插件页 / plugin_manager)
172
+ → pnpm 把包装进 profile,并在 dsh.profile.bundles 里选中该 bundle
173
+ → Loader 挂载插件行:index.js 的 apply()(空实现,Host 端零开销)
174
+ → Host 的 client-modules 扫描已启用条目,把 ./client 变成 /plugins 下的浏览器模块
175
+ → 浏览器模块表执行 window.__ModuleLoader__.load({ id, factory })
176
+ → factory(require) 取出 react,返回 Cordis 插件 { inject, apply }
177
+ → apply():
178
+ ctx.effect(() => ctx.locale.register(NS, { zh, en })) // 注册文案
179
+ ctx.slots.inject('shell.overlay', () => // 等浮层槽出现
180
+ ctx.slots.register({ name: 'shell.overlay', id, order, locale }, GreetingBubble))
181
+ → 浮层渲染气泡;点 × → 组件内 useState → 返回 null
182
+ → 停用/卸载 → Loader 行移除 → slots 注册被 dispose → 气泡消失
183
+ ```
184
+
185
+ 几个关键设计点:
186
+
187
+ 1. **渲染位置选 `shell.overlay`**:这是 `@deepseek-ai/dsh-client-ui-layout` 声明的整帧浮层(`position: absolute; inset: 0; z-index: 20; pointer-events: none`),位于所有列之上、列滚动容器之外,适合徽标、Toast、状态胶囊这类覆盖层。注册时用一个新 `id`(`greeting-bubble`)就是**追加**一条,不会替换自带的条目。
188
+ 2. **浮层穿透、气泡可交互**:浮层本身 `pointer-events: none`,它的直接子元素默认 `auto`。插件根节点设为 `none`;气泡卡片设回 `auto`——它必须接收指针事件才能拖动。因此只有气泡这一块会接住点击,浮层的其余区域完全穿透。
189
+ 3. **拖动实现**:`pointerdown` 时记录起始坐标与气泡矩形并 `setPointerCapture`,`pointermove` 按位移计算新坐标、限制在可视区内,`pointerup` 保存到 `localStorage` 并释放捕获;窗口缩放时也会把气泡夹回屏幕内(`ResizeObserver` 不需要,监听 `resize` 即可)。
190
+ 4. **高度避让**:默认距底 `84px`,位于输入卡发送按钮(34px 圆钮)之上;发送按钮始终露出来,不被问候语遮挡。拖动后以用户选择为准。
191
+ 5. **生命周期归 Cordis 管**:所有注册都放在 `ctx.effect` / `ctx.slots.inject` 里。`slots.inject` 会在槽声明存在时注册、声明消失时注销;插件停用或卸载时整个 fiber 被销毁,气泡和字典一起被清理,不需要手写 DOM 清理。
192
+ 6. **工厂无副作用**:`client.js` 顶层只调用 `__ModuleLoader__.load`,真正的注册发生在 `apply()`;模块体不碰 DOM、不开定时器。
193
+ 7. **样式走主题变量**:气泡用 `--dsw-alias-bg-layer-3`、`--dsw-alias-border-l3`、`--dsw-alias-label-primary`、`--dsw-alias-interactive-bg-hover` 等 token,亮/暗主题自动切换;组件内的 `<style>` 随组件卸载一起移除。
194
+ 8. **文案走 locale**:`locale: NS` 让框架把 `t` 注入组件,切换界面语言时文案实时更新,无需重载。
195
+ 9. **Host 端为空**:`index.js` 只导出 `export function apply() {}`。插件不注册工具、不发请求、不写会话日志,因此对模型和会话完全透明。
196
+
197
+ ## 文件结构
198
+
199
+ ```text
200
+ dsh-plugin-greeting-bubble/
201
+ ├─ package.json # 包清单:bundle patch + dsh.client + 导出/打包清单
202
+ ├─ index.js # Host 半:空 apply()
203
+ ├─ client.js # 浏览器半:React 气泡 + slot 注册 + 文案
204
+ ├─ cordis.patch.yml # 往 Loader 插入 id 为 greeting-bubble 的插件行
205
+ ├─ icon.svg # 插件图标(36×36,原创几何图形)
206
+ ├─ locale/
207
+ │ ├─ zh.json # 插件页中文标题/描述/详情文档路径
208
+ │ └─ en.json # 英文标题/描述/详情文档路径
209
+ ├─ docs/
210
+ │ ├─ DETAIL.md # 英文详情页文档(只含一张特性图)
211
+ │ ├─ DETAIL.zh.md # 中文详情页文档(同一张图,中文替代文本)
212
+ │ └─ preview.svg # 特性图(640×300,无文字)
213
+ ├─ test/
214
+ │ └─ smoke.mjs # 离线冒烟测试(不随包发布)
215
+ ├─ UPLOAD.md # 上传到 GitHub 的逐步说明(维护者用)
216
+ ├─ README.md
217
+ ├─ LICENSE
218
+ └─ .gitignore
219
+ ```
220
+
221
+ ## 本地开发与测试
222
+
223
+ ```powershell
224
+ # 1. 语法检查(需要 Node.js 18+)
225
+ node --check index.js
226
+ node --check client.js
227
+
228
+ # 2. 离线冒烟测试:用假的 window/React/Cordis 上下文执行 client.js,
229
+ # 校验模块 id、注册参数、字典内容,并渲染一次组件
230
+ node test/smoke.mjs
231
+ ```
232
+
233
+ 开发循环:
234
+
235
+ 1. 修改 `client.js` 等文件;
236
+ 2. 让 DSH 重新加载该插件(插件页关闭再打开开关,或重启 DSH);
237
+ 3. 刷新页面查看效果。安装后的包被替换时,DSH 需要重启才能加载新的 JavaScript 模块代。
238
+
239
+ 排查“气泡没出现”:
240
+
241
+ - 插件页确认 bundle 已安装且开关为开;
242
+ - 打开浏览器开发者工具控制台,搜索 `slot entry crashed`(如果组件抛错,会记录在这里);
243
+ - 确认 DSH 版本包含 `shell.overlay` 槽(0.2.x 起);
244
+ - 确认界面语言/主题没有影响(气泡应始终显示,直到点 ×)。
245
+
246
+ ## 兼容性与限制
247
+
248
+ - 面向 **DSH Web 客户端**(`dsh.client.platform: web`):桌面版窗口和浏览器版都适用;CLI / headless 模式没有界面,插件不产生任何效果。
249
+ - 依赖 `shell.overlay` 槽;更老的 DSH 版本没有该槽时,插件会安静地不显示,不会报错。
250
+ - 每次页面加载都会出现一次,不记忆关闭状态(如需记忆见[自定义](#自定义))。
251
+ - 浮层位于整帧之上:气泡默认在右下角、输入框上方(距右 20px、距底 84px),可以拖到任意位置;拖动后位置记在 localStorage 里(`dsh-greeting-bubble:position:v1`)。气泡本体需要接收拖动事件,所以它所在的那一小块会接住点击,其余区域不受影响。
252
+ - 问候语固定为中文,在任何界面语言下都不翻译;只有关闭按钮的提示文字跟随语言。
253
+ - 插件只在本地运行,不访问网络。
254
+
255
+ ## English
256
+
257
+ A tiny DeepSeek Harness Web UI plugin that shows a “你好,腾盛” speech bubble near the bottom-right corner after the page loads. Click × to dismiss it; it returns on the next page load. The bubble can be dragged anywhere, and its position is remembered in localStorage.
258
+
259
+ - Install: **Plugins → Add plugin** → `dsh-plugin-greeting-bubble` (npm), or `https://github.com/liwei169/dsh-plugin-greeting-bubble` (GitHub).
260
+ - It registers one entry into the frame-wide `shell.overlay` slot, uses `--dsw-alias-*` theme tokens, localizes its close label, and keeps every registration inside `ctx.effect` / `ctx.slots.inject` so disabling the bundle removes the bubble again.
261
+ - Dragging uses pointer capture, clamps to the viewport, and saves the dropped position under `dsh-greeting-bubble:position:v1`.
262
+ - No network access, no data collection, no model-facing behavior.
263
+
264
+ Tested with DeepSeek Harness 0.2.2-rc.5.
265
+
266
+ ## License
267
+
268
+ [MIT](LICENSE) © 2026 腾盛
package/client.js ADDED
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Browser half of dsh-plugin-greeting-bubble.
3
+ *
4
+ * Loaded lazily by the DSH client module table: this file only registers a
5
+ * factory. The factory returns a Cordis plugin whose `apply` owns every live
6
+ * resource through `ctx.effect` / `ctx.slots.inject`, so disabling or removing
7
+ * the bundle removes the bubble again without a reload.
8
+ *
9
+ * Rendering surface: the `shell.overlay` list slot declared by
10
+ * `@deepseek-ai/dsh-client-ui-layout`. It is a frame-wide layer above every
11
+ * column, so the bubble floats over the whole app without moving any host
12
+ * control. Registering a fresh `id` adds an entry beside the shipped ones
13
+ * instead of replacing them.
14
+ *
15
+ * The bubble is draggable: pointer capture keeps the drag smooth, the card is
16
+ * clamped to the viewport, and the chosen spot is remembered in localStorage
17
+ * under `POSITION_KEY`.
18
+ */
19
+ window.__ModuleLoader__.load({
20
+ id: 'dsh-plugin-greeting-bubble',
21
+ factory(require) {
22
+ const React = require('react');
23
+ const h = React.createElement;
24
+
25
+ /** Locale namespace owned by this plugin (registered in `apply`). */
26
+ const NS = 'greetingBubble';
27
+
28
+ /** Where the reader last dropped the bubble, as viewport px. */
29
+ const POSITION_KEY = 'dsh-greeting-bubble:position:v1';
30
+
31
+ /** Read the remembered spot; a corrupt or absent value means "default". */
32
+ function readPosition() {
33
+ try {
34
+ const raw = window.localStorage.getItem(POSITION_KEY);
35
+ if (!raw) return null;
36
+ const value = JSON.parse(raw);
37
+ if (typeof value?.x === 'number' && typeof value?.y === 'number') {
38
+ return { x: value.x, y: value.y };
39
+ }
40
+ } catch {
41
+ // Private mode, blocked storage, or malformed JSON: fall through.
42
+ }
43
+ return null;
44
+ }
45
+
46
+ /** Persist the dropped spot; failures must never break the bubble. */
47
+ function writePosition(position) {
48
+ try {
49
+ window.localStorage.setItem(POSITION_KEY, JSON.stringify(position));
50
+ } catch {
51
+ // Storage unavailable: position simply does not survive the reload.
52
+ }
53
+ }
54
+
55
+ /** Keep a value inside [min, max], tolerating a viewport smaller than the card. */
56
+ function clamp(value, min, max) {
57
+ return Math.max(min, Math.min(value, Math.max(min, max)));
58
+ }
59
+
60
+ /**
61
+ * Component-local stylesheet; unmounting the entry removes it with the
62
+ * node.
63
+ *
64
+ * Placement notes:
65
+ * - The default spot is 84px above the bottom edge, which clears the
66
+ * composer's 34px send button and its card padding.
67
+ * - Once dragged, the card switches to explicit `left`/`top` coordinates
68
+ * and the reader's choice is remembered.
69
+ * - The card now receives pointer events itself (it must, to be dragged);
70
+ * only the layer around it stays click-through.
71
+ * - Radii and elevation reuse the host tokens, so the bubble reads as one
72
+ * of the app's own floating surfaces in both themes.
73
+ */
74
+ const STYLES = `
75
+ .dsh-greeting-layer {
76
+ position: absolute;
77
+ inset: 0;
78
+ pointer-events: none;
79
+ }
80
+ .dsh-greeting-bubble {
81
+ position: absolute;
82
+ right: calc(20px + env(safe-area-inset-right, 0px));
83
+ bottom: calc(84px + env(safe-area-inset-bottom, 0px));
84
+ z-index: 1;
85
+ display: flex;
86
+ align-items: center;
87
+ gap: 8px;
88
+ box-sizing: border-box;
89
+ max-width: min(320px, calc(100vw - 40px));
90
+ padding: 8px 6px 8px 12px;
91
+ border: 0;
92
+ --dsw-elevation-stroke-color: var(--dsw-alias-border-l3);
93
+ border-radius: var(--dsw-radius-lg, 16px);
94
+ background: var(--dsw-alias-bg-layer-3);
95
+ color: var(--dsw-alias-label-primary);
96
+ box-shadow: var(--dsw-elevation-prominent, 0 4px 16px rgba(0, 0, 0, 0.12));
97
+ font-size: 13px;
98
+ line-height: 20px;
99
+ cursor: grab;
100
+ touch-action: none;
101
+ user-select: none;
102
+ pointer-events: auto;
103
+ animation: dsh-greeting-in 320ms cubic-bezier(0.22, 0.8, 0.24, 1) 350ms both;
104
+ }
105
+ .dsh-greeting-bubble[data-dragging] {
106
+ cursor: grabbing;
107
+ }
108
+ .dsh-greeting-wave {
109
+ flex: none;
110
+ font-size: 16px;
111
+ line-height: 1;
112
+ }
113
+ .dsh-greeting-text {
114
+ min-width: 0;
115
+ overflow-wrap: anywhere;
116
+ }
117
+ .dsh-greeting-close {
118
+ flex: none;
119
+ display: inline-flex;
120
+ align-items: center;
121
+ justify-content: center;
122
+ width: 26px;
123
+ height: 26px;
124
+ padding: 0;
125
+ border: 0;
126
+ border-radius: var(--dsw-radius-sm, 8px);
127
+ background: transparent;
128
+ color: var(--dsw-alias-label-tertiary);
129
+ cursor: pointer;
130
+ pointer-events: auto;
131
+ }
132
+ .dsh-greeting-close:hover {
133
+ background: var(--dsw-alias-interactive-bg-hover);
134
+ color: var(--dsw-alias-label-secondary);
135
+ }
136
+ .dsh-greeting-close:focus-visible {
137
+ outline: var(--dsw-focus-ring-width, 2px) solid
138
+ var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
139
+ outline-offset: 1px;
140
+ }
141
+ @keyframes dsh-greeting-in {
142
+ from {
143
+ opacity: 0;
144
+ transform: translateY(10px) scale(0.96);
145
+ }
146
+ to {
147
+ opacity: 1;
148
+ transform: translateY(0) scale(1);
149
+ }
150
+ }
151
+ @media (prefers-reduced-motion: reduce) {
152
+ .dsh-greeting-bubble {
153
+ animation: none;
154
+ }
155
+ }
156
+ `;
157
+
158
+ /**
159
+ * The greeting bubble itself.
160
+ *
161
+ * @param props - the framework `t` seat bound to {@link NS}.
162
+ * @returns the bubble, or null once the reader dismissed it.
163
+ */
164
+ function GreetingBubble({ t }) {
165
+ const [dismissed, setDismissed] = React.useState(false);
166
+ const [position, setPosition] = React.useState(readPosition);
167
+ const [dragging, setDragging] = React.useState(false);
168
+ const bubbleRef = React.useRef(null);
169
+ const dragRef = React.useRef(null);
170
+
171
+ // Keep a remembered spot on screen when the window shrinks.
172
+ React.useEffect(() => {
173
+ function handleResize() {
174
+ setPosition((current) => {
175
+ const element = bubbleRef.current;
176
+ if (current === null || element === null) return current;
177
+ const x = clamp(current.x, 0, window.innerWidth - element.offsetWidth);
178
+ const y = clamp(current.y, 0, window.innerHeight - element.offsetHeight);
179
+ return x === current.x && y === current.y ? current : { x, y };
180
+ });
181
+ }
182
+ window.addEventListener('resize', handleResize);
183
+ return () => { window.removeEventListener('resize', handleResize); };
184
+ }, []);
185
+
186
+ if (dismissed) return null;
187
+ const text = typeof t === 'function' ? t('greeting') : '你好,腾盛';
188
+ const dismissLabel = typeof t === 'function' ? t('dismiss') : '关闭问候气泡';
189
+
190
+ /** Start a drag: switch to absolute coordinates and capture the pointer. */
191
+ function handlePointerDown(event) {
192
+ if (event.button !== undefined && event.button !== 0) return;
193
+ if (event.target && event.target.closest && event.target.closest('button')) return;
194
+ const element = bubbleRef.current;
195
+ if (!element) return;
196
+ const rect = element.getBoundingClientRect();
197
+ dragRef.current = {
198
+ pointerId: event.pointerId,
199
+ startX: event.clientX,
200
+ startY: event.clientY,
201
+ left: rect.left,
202
+ top: rect.top,
203
+ width: rect.width,
204
+ height: rect.height,
205
+ };
206
+ setPosition({ x: rect.left, y: rect.top });
207
+ setDragging(true);
208
+ if (typeof element.setPointerCapture === 'function') {
209
+ element.setPointerCapture(event.pointerId);
210
+ }
211
+ event.preventDefault();
212
+ }
213
+
214
+ /** Move within the viewport while the pointer is captured. */
215
+ function handlePointerMove(event) {
216
+ const drag = dragRef.current;
217
+ if (drag === null || event.pointerId !== drag.pointerId) return;
218
+ const x = drag.left + event.clientX - drag.startX;
219
+ const y = drag.top + event.clientY - drag.startY;
220
+ setPosition({
221
+ x: clamp(x, 0, window.innerWidth - drag.width),
222
+ y: clamp(y, 0, window.innerHeight - drag.height),
223
+ });
224
+ }
225
+
226
+ /** Finish a drag, clamp once more, and persist the dropped spot. */
227
+ function handlePointerUp(event) {
228
+ const drag = dragRef.current;
229
+ if (drag === null || event.pointerId !== drag.pointerId) return;
230
+ dragRef.current = null;
231
+ setDragging(false);
232
+ const element = bubbleRef.current;
233
+ if (!element) return;
234
+ const rect = element.getBoundingClientRect();
235
+ const dropped = {
236
+ x: Math.round(clamp(rect.left, 0, window.innerWidth - rect.width)),
237
+ y: Math.round(clamp(rect.top, 0, window.innerHeight - rect.height)),
238
+ };
239
+ setPosition(dropped);
240
+ writePosition(dropped);
241
+ }
242
+
243
+ return h(
244
+ 'div',
245
+ { className: 'dsh-greeting-layer', style: { position: 'absolute', inset: 0, pointerEvents: 'none' } },
246
+ h('style', { key: 'styles' }, STYLES),
247
+ h(
248
+ 'div',
249
+ {
250
+ key: 'bubble',
251
+ ref: bubbleRef,
252
+ className: 'dsh-greeting-bubble',
253
+ 'data-dragging': dragging ? '' : undefined,
254
+ style: position === null
255
+ ? undefined
256
+ : { left: position.x, top: position.y, right: 'auto', bottom: 'auto' },
257
+ onPointerDown: handlePointerDown,
258
+ onPointerMove: handlePointerMove,
259
+ onPointerUp: handlePointerUp,
260
+ onPointerCancel: handlePointerUp,
261
+ },
262
+ h('span', { className: 'dsh-greeting-wave', 'aria-hidden': 'true' }, '👋'),
263
+ // `lang` pins the reading voice for this fixed Chinese phrase; the
264
+ // status role lives on the text so the dismiss button stays outside
265
+ // the live region.
266
+ h('span', { className: 'dsh-greeting-text', role: 'status', lang: 'zh-CN' }, text),
267
+ h(
268
+ 'button',
269
+ {
270
+ className: 'dsh-greeting-close',
271
+ type: 'button',
272
+ title: dismissLabel,
273
+ 'aria-label': dismissLabel,
274
+ onClick: () => { setDismissed(true); },
275
+ },
276
+ h(
277
+ 'svg',
278
+ { width: 13, height: 13, viewBox: '0 0 12 12', 'aria-hidden': 'true' },
279
+ h('path', {
280
+ d: 'M2.5 2.5l7 7M9.5 2.5l-7 7',
281
+ fill: 'none',
282
+ stroke: 'currentColor',
283
+ strokeWidth: 1.4,
284
+ strokeLinecap: 'round',
285
+ }),
286
+ ),
287
+ ),
288
+ ),
289
+ );
290
+ }
291
+
292
+ return {
293
+ inject: ['slots', 'locale'],
294
+ /**
295
+ * Register the plugin's dictionary and its single overlay entry.
296
+ * @param ctx - client plugin context.
297
+ */
298
+ apply(ctx) {
299
+ ctx.effect(
300
+ () => ctx.locale.register(NS, {
301
+ // The greeting is the plugin's fixed signature phrase, so it stays
302
+ // identical in every locale; only the control labels are localized.
303
+ zh: { greeting: '你好,腾盛', dismiss: '关闭问候气泡' },
304
+ en: { greeting: '你好,腾盛', dismiss: 'Dismiss greeting' },
305
+ }),
306
+ 'greeting-bubble: dictionaries',
307
+ );
308
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({
309
+ name: 'shell.overlay',
310
+ id: 'greeting-bubble',
311
+ order: 50,
312
+ locale: NS,
313
+ }, GreetingBubble));
314
+ },
315
+ };
316
+ },
317
+ });
@@ -0,0 +1,8 @@
1
+ # Registers the browser-only greeting-bubble plugin row.
2
+ #
3
+ # `name` is this package's own name (it resolves from the profile that installs
4
+ # the bundle). `id` is the unique Loader entry id shown in the plugin inventory
5
+ # and used by profile patches to enable or disable the row.
6
+ - insert:
7
+ - id: greeting-bubble
8
+ name: dsh-plugin-greeting-bubble
package/docs/DETAIL.md ADDED
@@ -0,0 +1 @@
1
+ ![A greeting bubble in the bottom-right corner of the window](preview.svg)
@@ -0,0 +1 @@
1
+ ![窗口右下角、输入框上方的问候气泡](preview.svg)
@@ -0,0 +1,27 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300">
2
+ <rect x="40" y="24" width="560" height="252" rx="16" fill="none" stroke="#c3cdda" stroke-width="2"/>
3
+ <path d="M40 58h560" stroke="#d7dee8" stroke-width="2"/>
4
+ <circle cx="62" cy="41" r="4" fill="#cfd8e3"/>
5
+ <circle cx="80" cy="41" r="4" fill="#cfd8e3"/>
6
+ <circle cx="98" cy="41" r="4" fill="#cfd8e3"/>
7
+ <path d="M176 58v218" stroke="#d7dee8" stroke-width="2"/>
8
+ <rect x="56" y="80" width="96" height="8" rx="4" fill="#dfe6ef"/>
9
+ <rect x="56" y="102" width="96" height="8" rx="4" fill="#dfe6ef"/>
10
+ <rect x="56" y="124" width="96" height="8" rx="4" fill="#dfe6ef"/>
11
+ <rect x="204" y="84" width="220" height="54" rx="12" fill="#f2f5f9"/>
12
+ <rect x="220" y="98" width="140" height="8" rx="4" fill="#dbe3ee"/>
13
+ <rect x="220" y="114" width="96" height="7" rx="3.5" fill="#e6ebf3"/>
14
+ <rect x="204" y="212" width="332" height="44" rx="14" fill="#f5f7fa" stroke="#dbe3ec" stroke-width="2"/>
15
+ <rect x="220" y="228" width="120" height="8" rx="4" fill="#dbe3ee"/>
16
+ <circle cx="512" cy="234" r="13" fill="#b9cbe4"/>
17
+ <path d="M512 240v-11m-5 5 5-5 5 5" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
18
+ <rect x="388" y="148" width="196" height="58" rx="16" fill="#eef4fc" stroke="#b7c9de" stroke-width="2"/>
19
+ <rect x="404.5" y="164" width="3.5" height="12" rx="1.75" fill="#F2994A"/>
20
+ <rect x="409" y="162" width="3.5" height="14" rx="1.75" fill="#F2994A"/>
21
+ <rect x="413.5" y="165" width="3.5" height="11" rx="1.75" fill="#F2994A"/>
22
+ <path d="M404 174h13v7a4 4 0 0 1-4 4h-5a4 4 0 0 1-4-4z" fill="#F2994A"/>
23
+ <rect x="400" y="175" width="5" height="4.5" rx="2" fill="#F2994A"/>
24
+ <rect x="428" y="170" width="100" height="8" rx="4" fill="#93a9c0"/>
25
+ <rect x="428" y="184" width="62" height="6" rx="3" fill="#c3d1e0"/>
26
+ <path d="M552 162l7 7M559 162l-7 7" fill="none" stroke="#8fa3ba" stroke-width="2" stroke-linecap="round"/>
27
+ </svg>
package/icon.svg ADDED
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
2
+ <path d="M11 23.5v8l8.5-8z" fill="#F2994A"/>
3
+ <rect x="3.5" y="3.5" width="29" height="21.5" rx="7.5" fill="#F2994A"/>
4
+ <circle cx="13.8" cy="11.5" r="1.9" fill="#FFFFFF"/>
5
+ <circle cx="22.2" cy="11.5" r="1.9" fill="#FFFFFF"/>
6
+ <path d="M12.5 15.6c0 3.2 11 3.2 11 0" fill="none" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round"/>
7
+ </svg>
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Host half of the greeting-bubble bundle.
3
+ *
4
+ * The whole feature lives in the browser half (`client.js`): the Host row only
5
+ * keeps the Loader entry alive so the client module system serves the bundle
6
+ * and the browser mounts it into `shell.overlay`. Nothing runs on the Host, so
7
+ * the plugin adds no model-facing tools, no requests, and no session state.
8
+ */
9
+ export function apply() {}
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Greeting bubble",
4
+ "description": "Shows a “你好,腾盛” speech bubble near the bottom-right corner of the window, just above the message composer, after the page loads. Drag the bubble anywhere; its position is remembered for the next visit. Click × to dismiss it; it appears again on the next page load. The greeting stays Chinese in every interface language; only the close-button label is localized. The plugin makes no network requests, collects no data, and changes nothing else in the app. Disable or remove the bundle under Plugins to remove it.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "右下角问候气泡",
4
+ "description": "页面加载后,在窗口右下角、输入框上方弹出「你好,腾盛」问候气泡。按住气泡可以拖到任意位置,位置会记住,下次打开仍在原处。点气泡上的 × 即可关闭,下次页面加载时会再次出现。问候语在任何界面语言下都保持中文,只有关闭按钮的提示文字跟随界面语言。插件不联网、不收集数据,除气泡外不改变任何界面。在「插件」页停用或移除本插件即可彻底去掉。",
5
+ "detail": "docs/DETAIL.zh.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "dsh-plugin-greeting-bubble",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "description": "Shows a “你好,腾盛” speech bubble in the bottom-right corner of the DeepSeek Harness Web GUI.",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "keywords": [
11
+ "dsh",
12
+ "dsh-plugin",
13
+ "deepseek-harness",
14
+ "web-ui",
15
+ "greeting"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/liwei169/dsh-plugin-greeting-bubble.git"
20
+ },
21
+ "homepage": "https://github.com/liwei169/dsh-plugin-greeting-bubble#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/liwei169/dsh-plugin-greeting-bubble/issues"
24
+ },
25
+ "exports": {
26
+ ".": "./index.js",
27
+ "./client": "./client.js",
28
+ "./locale/*.json": "./locale/*.json",
29
+ "./icon": "./icon.svg",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "index.js",
34
+ "client.js",
35
+ "cordis.patch.yml",
36
+ "locale/*.json",
37
+ "docs",
38
+ "icon.svg"
39
+ ],
40
+ "dsh": {
41
+ "bundle": {
42
+ "patch": "./cordis.patch.yml"
43
+ },
44
+ "client": {
45
+ "platform": "web",
46
+ "immediately": true,
47
+ "inject": [
48
+ "@deepseek-ai/dsh-client-ui-layout"
49
+ ]
50
+ }
51
+ }
6
52
  }