dsh-milestone 0.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 +21 -0
- package/README.md +72 -0
- package/cordis.patch.yml +6 -0
- package/lib/client.js +209 -0
- package/lib/index.js +10 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-milestone 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
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# dsh-milestone
|
|
2
|
+
|
|
3
|
+
会话里程碑导航条(DeepSeek Harness 插件)。在会话视图右侧渲染一条垂直 scrubber,每个 **user 发言** 对应一个进度点:鼠标悬停预览该条消息的前 80 字,点击平滑跳转到对应位置。
|
|
4
|
+
|
|
5
|
+
> **dsh-plugin** · 适配 DeepSeek Harness (`deepseek-ai/deepseek-harness`) Web UI。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
- **进度点(tick)**:每条真实 user 消息 = 一个 tick,按**真实渲染偏移**定位(非等距),跟随滚动与内容变化实时更新。
|
|
10
|
+
- **悬停预览**:hover 显示该条 user 消息的前 80 字。
|
|
11
|
+
- **点击跳转**:点击 tick 平滑滚动到对应消息(`scrollIntoView`)。
|
|
12
|
+
- 少于 2 条 user 消息时不渲染(无导航价值)。
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
# 本地目录(开发)
|
|
18
|
+
dsh plugin --profile demo add ./dsh-milestone
|
|
19
|
+
|
|
20
|
+
# npm 包(发布后)
|
|
21
|
+
dsh plugin --profile demo add dsh-milestone
|
|
22
|
+
|
|
23
|
+
# GitHub 仓库(需 prepare 脚本 + allowBuilds 许可)
|
|
24
|
+
dsh plugin --profile demo add github:you/dsh-milestone
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
然后 `npx @deepseek-ai/dsh web` 启动 Web UI 即可看到右侧里程碑条。
|
|
28
|
+
|
|
29
|
+
## 开发
|
|
30
|
+
|
|
31
|
+
要求 **Node.js `>= 24`**(官方 harness 要求 `^22.19 || >=24`,本仓库已验证 `24.19.0`)。依赖从 npm 安装(`0.1.0-rc.6` 系列,完整可用)。
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pnpm install
|
|
35
|
+
pnpm run build # 产出 lib/index.js (node half) + lib/client.js (browser half)
|
|
36
|
+
pnpm exec tsc --noEmit # 类型检查
|
|
37
|
+
pnpm run watch # 监听构建
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
构建产物:`lib/index.js`(node half,空 apply)+ `lib/client.js`(browser half,CJS closure,`window.__ModuleLoader__.load` banner)。
|
|
41
|
+
|
|
42
|
+
### 架构
|
|
43
|
+
|
|
44
|
+
双半边插件(Host = Node 进程,Client = 浏览器):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
src/index.ts node half —— 空 apply,让插件进入 host cordis 配置树
|
|
48
|
+
src/client/index.ts browser half —— 两个 slot 注册
|
|
49
|
+
src/client/MilestoneOverlay.tsx shell.overlay entry(root scope)
|
|
50
|
+
└─ 声明 session 子槽 milestone.rail
|
|
51
|
+
└─ 通过 SessionProvider 桥接到会话区
|
|
52
|
+
src/client/MilestoneRail.tsx milestone.rail entry(session scope)
|
|
53
|
+
└─ useSession 读取会话快照
|
|
54
|
+
└─ DOM 锚点定位 + tick 渲染 + 跳转
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
关键机制:
|
|
58
|
+
|
|
59
|
+
- **注入点**:`shell.overlay`(`kind: 'list'`,`scope: 'root'`)——全框架浮动层,附加式、点击穿透,是"悬浮 rail"的唯一正确位置。
|
|
60
|
+
- **会话数据**:通过声明 session-scope 子槽 `milestone.rail`,框架自动注入 `SessionProvider`(`PropsRenderSlots` 从子槽 scope 推导),rail 组件因此拿到 `useSession` / `sessionId`。
|
|
61
|
+
- **消息定位**:`useSession(s => s.chat.order)` + `s.chat.nodes.get(key)` 过滤 `kind === 'user'`;DOM 锚点 `data-chat-anchor-key`(节点 key = `13:input-message<messageId>`),scrollport 为 `[data-conversation-scroll]`。
|
|
62
|
+
- **性能**:行元素按消息列表版本缓存(O(n) 重算);scroll/resize 通过 `requestAnimationFrame` 节流。
|
|
63
|
+
|
|
64
|
+
## 已知限制
|
|
65
|
+
|
|
66
|
+
- 仅覆盖当前已加载的消息窗口(harness 初始加载最近 50 条事件,向上滚动触发 `loadOlder` 分页);rail 会随分页自动更新,但更早的消息需要先滚动加载。
|
|
67
|
+
- preview 从 DOM `textContent` 提取,长消息截断为 80 字。
|
|
68
|
+
- 尚未实现"当前定位"高亮(P1)。
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
package/cordis.patch.yml
ADDED
package/lib/client.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-milestone",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region src/client/MilestoneOverlay.tsx
|
|
10
|
+
/**
|
|
11
|
+
* @param props - runtime share (root kit) + the narrowed renderSlot and the
|
|
12
|
+
* framework-injected SessionProvider for the session child seat.
|
|
13
|
+
*/
|
|
14
|
+
function MilestoneOverlay({ SessionProvider, renderSlot }) {
|
|
15
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionProvider, {
|
|
16
|
+
empty: () => null,
|
|
17
|
+
children: () => renderSlot("milestone.rail", {})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/MilestoneRail.tsx
|
|
22
|
+
/**
|
|
23
|
+
* MilestoneRail: the milestone.rail entry (session scope). It reads the
|
|
24
|
+
* conversation snapshot through `useSession`, finds every user-message row in
|
|
25
|
+
* the chat flow, and renders a fixed right-side vertical scrubber: one tick
|
|
26
|
+
* per user message positioned by real rendered offset, a hover preview of the
|
|
27
|
+
* message text, and click-to-jump via the row's `data-chat-anchor-key` DOM
|
|
28
|
+
* anchor.
|
|
29
|
+
*
|
|
30
|
+
* Scroll positioning mirrors the harness chat view's own flowTop math: a row's
|
|
31
|
+
* content position is its scrollport-relative top plus the current scrollTop,
|
|
32
|
+
* normalized against scrollHeight. Ticks recompute on scroll and on any
|
|
33
|
+
* scrollport/row resize, throttled through requestAnimationFrame. Row elements
|
|
34
|
+
* are cached once per message-list revision (O(n) per recompute, not O(n^2)).
|
|
35
|
+
*/
|
|
36
|
+
const PREVIEW_LENGTH = 80;
|
|
37
|
+
/** Minimum ticks before the rail adds value. */
|
|
38
|
+
const MIN_TICKS = 2;
|
|
39
|
+
/**
|
|
40
|
+
* Find a chat row by its node key, avoiding CSS.escape pitfalls on keys that
|
|
41
|
+
* contain `<`/`>`/`:` (the node key is `12:input-message<messageId>`).
|
|
42
|
+
* Mirrors the harness ChatView's `anchorElement` scan.
|
|
43
|
+
*/
|
|
44
|
+
function findRow(key) {
|
|
45
|
+
for (const row of document.querySelectorAll("[data-chat-anchor-key]")) if (row.dataset.chatAnchorKey === key) return row;
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @param props - session standard kit (useSession, sessionId, useProjection).
|
|
50
|
+
*/
|
|
51
|
+
function MilestoneRail({ useSession }) {
|
|
52
|
+
const order = useSession((s) => s.chat.order);
|
|
53
|
+
const nodes = useSession((s) => s.chat.nodes);
|
|
54
|
+
const userKeys = (0, react.useMemo)(() => order.filter((key) => nodes.get(key)?.kind === "user"), [order, nodes]);
|
|
55
|
+
const [ticks, setTicks] = (0, react.useState)([]);
|
|
56
|
+
const [railBox, setRailBox] = (0, react.useState)(null);
|
|
57
|
+
const [hover, setHover] = (0, react.useState)(null);
|
|
58
|
+
(0, react.useLayoutEffect)(() => {
|
|
59
|
+
if (userKeys.length < MIN_TICKS) {
|
|
60
|
+
setTicks([]);
|
|
61
|
+
setRailBox(null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const scrollport = document.querySelector("[data-conversation-scroll]");
|
|
65
|
+
if (scrollport === null) return;
|
|
66
|
+
const rowCache = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const key of userKeys) {
|
|
68
|
+
const row = findRow(key);
|
|
69
|
+
if (row !== null) rowCache.set(key, row);
|
|
70
|
+
}
|
|
71
|
+
const compute = () => {
|
|
72
|
+
const sp = scrollport.getBoundingClientRect();
|
|
73
|
+
const total = scrollport.scrollHeight;
|
|
74
|
+
const next = [];
|
|
75
|
+
for (const key of userKeys) {
|
|
76
|
+
let row = rowCache.get(key);
|
|
77
|
+
if (row === void 0 || !row.isConnected) {
|
|
78
|
+
const fresh = findRow(key);
|
|
79
|
+
if (fresh === null) continue;
|
|
80
|
+
row = fresh;
|
|
81
|
+
rowCache.set(key, fresh);
|
|
82
|
+
}
|
|
83
|
+
const contentTop = row.getBoundingClientRect().top - sp.top + scrollport.scrollTop;
|
|
84
|
+
const top = total > 0 ? contentTop / total * 100 : 0;
|
|
85
|
+
next.push({
|
|
86
|
+
key,
|
|
87
|
+
top: Math.min(99, Math.max(0, top))
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
setTicks(next);
|
|
91
|
+
setRailBox({
|
|
92
|
+
top: sp.top,
|
|
93
|
+
height: sp.height,
|
|
94
|
+
right: Math.max(4, window.innerWidth - sp.right)
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
compute();
|
|
98
|
+
let raf = 0;
|
|
99
|
+
const schedule = () => {
|
|
100
|
+
cancelAnimationFrame(raf);
|
|
101
|
+
raf = requestAnimationFrame(compute);
|
|
102
|
+
};
|
|
103
|
+
scrollport.addEventListener("scroll", schedule, { passive: true });
|
|
104
|
+
const observer = new ResizeObserver(schedule);
|
|
105
|
+
observer.observe(scrollport);
|
|
106
|
+
for (const row of rowCache.values()) observer.observe(row);
|
|
107
|
+
return () => {
|
|
108
|
+
cancelAnimationFrame(raf);
|
|
109
|
+
scrollport.removeEventListener("scroll", schedule);
|
|
110
|
+
observer.disconnect();
|
|
111
|
+
};
|
|
112
|
+
}, [userKeys]);
|
|
113
|
+
if (railBox === null || ticks.length < MIN_TICKS) return null;
|
|
114
|
+
const jump = (key) => {
|
|
115
|
+
findRow(key)?.scrollIntoView({
|
|
116
|
+
behavior: "smooth",
|
|
117
|
+
block: "start"
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const onEnter = (tick) => {
|
|
121
|
+
const preview = findRow(tick.key)?.textContent?.trim().slice(0, PREVIEW_LENGTH) ?? "";
|
|
122
|
+
setHover({
|
|
123
|
+
key: tick.key,
|
|
124
|
+
preview,
|
|
125
|
+
top: tick.top
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
129
|
+
style: {
|
|
130
|
+
position: "fixed",
|
|
131
|
+
top: railBox.top,
|
|
132
|
+
right: railBox.right,
|
|
133
|
+
height: railBox.height,
|
|
134
|
+
width: 20,
|
|
135
|
+
pointerEvents: "auto",
|
|
136
|
+
zIndex: 100
|
|
137
|
+
},
|
|
138
|
+
"aria-label": "Conversation milestones",
|
|
139
|
+
children: [ticks.map((tick) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
140
|
+
type: "button",
|
|
141
|
+
style: {
|
|
142
|
+
position: "absolute",
|
|
143
|
+
top: `${tick.top}%`,
|
|
144
|
+
right: 6,
|
|
145
|
+
width: 8,
|
|
146
|
+
height: 3,
|
|
147
|
+
borderRadius: 2,
|
|
148
|
+
border: "none",
|
|
149
|
+
padding: 0,
|
|
150
|
+
background: hover?.key === tick.key ? "#4d7cfe" : "rgba(120, 130, 150, 0.5)",
|
|
151
|
+
cursor: "pointer"
|
|
152
|
+
},
|
|
153
|
+
onMouseEnter: () => onEnter(tick),
|
|
154
|
+
onMouseLeave: () => setHover(null),
|
|
155
|
+
onClick: () => jump(tick.key),
|
|
156
|
+
"aria-label": "Jump to user message"
|
|
157
|
+
}, tick.key)), hover !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
158
|
+
style: {
|
|
159
|
+
position: "fixed",
|
|
160
|
+
right: railBox.right + 22,
|
|
161
|
+
top: railBox.top + railBox.height * hover.top / 100,
|
|
162
|
+
transform: "translateY(-50%)",
|
|
163
|
+
maxWidth: 280,
|
|
164
|
+
padding: "8px 10px",
|
|
165
|
+
background: "rgba(20, 24, 32, 0.95)",
|
|
166
|
+
color: "#e6e8ee",
|
|
167
|
+
borderRadius: 6,
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
lineHeight: 1.5,
|
|
170
|
+
whiteSpace: "pre-wrap",
|
|
171
|
+
wordBreak: "break-word",
|
|
172
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.3)",
|
|
173
|
+
zIndex: 101
|
|
174
|
+
},
|
|
175
|
+
children: hover.preview
|
|
176
|
+
})]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/client/index.ts
|
|
181
|
+
/** Required services (cordis fiber inject). */
|
|
182
|
+
const inject = ["slots"];
|
|
183
|
+
/**
|
|
184
|
+
* Register the overlay and rail once their slot declarations are on the
|
|
185
|
+
* ledger. The overlay registers directly against the shipped shell.overlay
|
|
186
|
+
* declaration; the rail registers against our own child declaration, which
|
|
187
|
+
* appears exactly when the overlay entry mounts.
|
|
188
|
+
* @param ctx - client root context.
|
|
189
|
+
*/
|
|
190
|
+
function apply(ctx) {
|
|
191
|
+
ctx.slots.inject("shell.overlay", () => ctx.slots.register({
|
|
192
|
+
name: "shell.overlay",
|
|
193
|
+
id: "milestone",
|
|
194
|
+
order: 100,
|
|
195
|
+
children: { "milestone.rail": {
|
|
196
|
+
kind: "single",
|
|
197
|
+
scope: "session"
|
|
198
|
+
} }
|
|
199
|
+
}, MilestoneOverlay));
|
|
200
|
+
ctx.slots.inject("milestone.rail", () => ctx.slots.register({ name: "milestone.rail" }, MilestoneRail));
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
exports.apply = apply;
|
|
204
|
+
exports.inject = inject;
|
|
205
|
+
return module.exports;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=client.js.map
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* dsh-milestone node half. Pure UI plugin: the empty apply exists so the
|
|
4
|
+
* plugin appears in the host cordis.yml / Loader (load and lifecycle follow
|
|
5
|
+
* the host); the browser half ships via exports["./client"], discovered
|
|
6
|
+
* through the package.json dsh.client declaration.
|
|
7
|
+
*/
|
|
8
|
+
function apply() {}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { apply };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-milestone",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Conversation milestone rail for DeepSeek Harness: a right-side vertical scrubber showing one tick per user message — hover to preview, click to jump.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./client": "./lib/client.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"dsh": {
|
|
13
|
+
"bundle": {
|
|
14
|
+
"patch": "./cordis.patch.yml"
|
|
15
|
+
},
|
|
16
|
+
"client": {
|
|
17
|
+
"inject": [
|
|
18
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
19
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
20
|
+
"@deepseek-ai/dsh-client-ui-layout"
|
|
21
|
+
],
|
|
22
|
+
"platform": "web"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsdown",
|
|
27
|
+
"watch": "tsdown --watch",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "pnpm run build"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"deepseek",
|
|
34
|
+
"harness",
|
|
35
|
+
"dsh",
|
|
36
|
+
"dsh-plugin",
|
|
37
|
+
"conversation",
|
|
38
|
+
"navigation"
|
|
39
|
+
],
|
|
40
|
+
"files": [
|
|
41
|
+
"lib/index.js",
|
|
42
|
+
"lib/client.js",
|
|
43
|
+
"cordis.patch.yml"
|
|
44
|
+
],
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
47
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
|
|
49
|
+
"react": "^18.2.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
53
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.1.0-rc.6",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
|
|
56
|
+
"@types/react": "~18.3.1",
|
|
57
|
+
"react": "^18.2.0",
|
|
58
|
+
"tsdown": "0.22.2",
|
|
59
|
+
"typescript": "^6.0.3"
|
|
60
|
+
}
|
|
61
|
+
}
|