dsh-spec-collab 0.1.2 → 0.1.3
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/README.md +4 -0
- package/lib/client.js +125 -96
- package/lib/types/client/SpecWorkbench.d.ts.map +1 -1
- package/lib/types/client/api.d.ts.map +1 -1
- package/lib/types/client/browser-uuid.d.ts +7 -0
- package/lib/types/client/browser-uuid.d.ts.map +1 -0
- package/lib/types/client/mount.d.ts.map +1 -1
- package/lib/types/client/sidebar-anchor.d.ts +6 -0
- package/lib/types/client/sidebar-anchor.d.ts.map +1 -0
- package/package.json +8 -8
- package/src/client/SpecWorkbench.tsx +2 -1
- package/src/client/api.ts +2 -1
- package/src/client/browser-uuid.ts +15 -0
- package/src/client/mount.tsx +5 -5
- package/src/client/sidebar-anchor.ts +16 -0
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ DeepSeek Harness 的独立双面插件,用于把产品的原始需求澄清为
|
|
|
7
7
|
|
|
8
8
|
产品边界严格止于 Ready Spec,不包含代码实现、测试用例生成、worktree、MR、部署、发布或交付状态管理。
|
|
9
9
|
|
|
10
|
+
兼容 DeepSeek Harness `v0.1.1-rc.1`。插件可在局域网 HTTP 地址下运行,不依赖浏览器提供 `crypto.randomUUID`;DSH 精简侧栏仅显示“设置”时,也会正常挂载“需求讨论”入口。
|
|
11
|
+
|
|
10
12
|
## 一键安装
|
|
11
13
|
|
|
12
14
|
已有 Node.js 环境时,无需先全局安装 DSH CLI:
|
|
@@ -27,6 +29,8 @@ dsh plugin --profile web add dsh-spec-collab@latest
|
|
|
27
29
|
dsh plugin --profile web update dsh-spec-collab@latest
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
插件已经内置非安全 HTTP 环境所需的 UUID fallback,不需要通过代理向 HTML 注入 `crypto` polyfill。团队部署仍建议使用 HTTPS,并在 DSH 前配置认证。
|
|
33
|
+
|
|
30
34
|
## 核心流程
|
|
31
35
|
|
|
32
36
|
```text
|
package/lib/client.js
CHANGED
|
@@ -42,6 +42,18 @@ window.__ModuleLoader__.load({
|
|
|
42
42
|
//#region src/protocol.ts
|
|
43
43
|
const API_PREFIX = "/api/spec-collab";
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/client/browser-uuid.ts
|
|
46
|
+
function browserUuid(source = globalThis.crypto) {
|
|
47
|
+
if (typeof source?.randomUUID === "function") return source.randomUUID();
|
|
48
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
49
|
+
if (typeof source?.getRandomValues === "function") source.getRandomValues(bytes);
|
|
50
|
+
else for (let index = 0; index < bytes.length; index += 1) bytes[index] = Math.floor(Math.random() * 256);
|
|
51
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
52
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
53
|
+
const hex = [...bytes].map((value) => value.toString(16).padStart(2, "0"));
|
|
54
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
45
57
|
//#region src/client/api.ts
|
|
46
58
|
var SpecApi = class {
|
|
47
59
|
async state() {
|
|
@@ -62,7 +74,7 @@ window.__ModuleLoader__.load({
|
|
|
62
74
|
}
|
|
63
75
|
async action(action) {
|
|
64
76
|
const envelope = {
|
|
65
|
-
requestId:
|
|
77
|
+
requestId: browserUuid(),
|
|
66
78
|
action
|
|
67
79
|
};
|
|
68
80
|
return (await fetch(`${API_PREFIX}/action`, {
|
|
@@ -39153,113 +39165,113 @@ window.__ModuleLoader__.load({
|
|
|
39153
39165
|
document.head.appendChild(tag);
|
|
39154
39166
|
}
|
|
39155
39167
|
var workbench_module_css_default = {
|
|
39156
|
-
"
|
|
39157
|
-
"
|
|
39158
|
-
"conflictDialog": "-kTeaG_conflictDialog",
|
|
39159
|
-
"conflictDiffs": "-kTeaG_conflictDiffs",
|
|
39160
|
-
"checkBlocked": "-kTeaG_checkBlocked",
|
|
39161
|
-
"summaryInput": "-kTeaG_summaryInput",
|
|
39168
|
+
"documents": "-kTeaG_documents",
|
|
39169
|
+
"review": "-kTeaG_review",
|
|
39162
39170
|
"paneClosed": "-kTeaG_paneClosed",
|
|
39163
|
-
"
|
|
39164
|
-
"checklist": "-kTeaG_checklist",
|
|
39165
|
-
"documentButton": "-kTeaG_documentButton",
|
|
39166
|
-
"checkItem": "-kTeaG_checkItem",
|
|
39167
|
-
"empty": "-kTeaG_empty",
|
|
39168
|
-
"notice": "-kTeaG_notice",
|
|
39169
|
-
"conflictActions": "-kTeaG_conflictActions",
|
|
39170
|
-
"pendingReview": "-kTeaG_pendingReview",
|
|
39171
|
-
"conflictColumns": "-kTeaG_conflictColumns",
|
|
39171
|
+
"richEditor": "-kTeaG_richEditor",
|
|
39172
39172
|
"markdownBody": "-kTeaG_markdownBody",
|
|
39173
|
-
"
|
|
39174
|
-
"
|
|
39173
|
+
"notice": "-kTeaG_notice",
|
|
39174
|
+
"editorBody": "-kTeaG_editorBody",
|
|
39175
39175
|
"collapseChat": "-kTeaG_collapseChat",
|
|
39176
|
-
"
|
|
39177
|
-
"
|
|
39178
|
-
"
|
|
39179
|
-
"
|
|
39180
|
-
"
|
|
39181
|
-
"
|
|
39182
|
-
"
|
|
39176
|
+
"view": "-kTeaG_view",
|
|
39177
|
+
"checklist": "-kTeaG_checklist",
|
|
39178
|
+
"chatMessages": "-kTeaG_chatMessages",
|
|
39179
|
+
"mobileSpec": "-kTeaG_mobileSpec",
|
|
39180
|
+
"identity": "-kTeaG_identity",
|
|
39181
|
+
"resizerHidden": "-kTeaG_resizerHidden",
|
|
39182
|
+
"summaryInput": "-kTeaG_summaryInput",
|
|
39183
|
+
"requirementMenu": "-kTeaG_requirementMenu",
|
|
39184
|
+
"run": "-kTeaG_run",
|
|
39185
|
+
"aiConversation": "-kTeaG_aiConversation",
|
|
39186
|
+
"emptyMain": "-kTeaG_emptyMain",
|
|
39187
|
+
"runHistory": "-kTeaG_runHistory",
|
|
39188
|
+
"titleBlock": "-kTeaG_titleBlock",
|
|
39189
|
+
"grid": "-kTeaG_grid",
|
|
39190
|
+
"quickOptions": "-kTeaG_quickOptions",
|
|
39191
|
+
"documentButton": "-kTeaG_documentButton",
|
|
39192
|
+
"headerActions": "-kTeaG_headerActions",
|
|
39183
39193
|
"editorContext": "-kTeaG_editorContext",
|
|
39184
|
-
"
|
|
39185
|
-
"
|
|
39186
|
-
"newThread": "-kTeaG_newThread",
|
|
39194
|
+
"tabBadge": "-kTeaG_tabBadge",
|
|
39195
|
+
"workbench": "-kTeaG_workbench",
|
|
39187
39196
|
"activeMode": "-kTeaG_activeMode",
|
|
39188
|
-
"
|
|
39189
|
-
"unsaved": "-kTeaG_unsaved",
|
|
39190
|
-
"paneActions": "-kTeaG_paneActions",
|
|
39191
|
-
"saveButton": "-kTeaG_saveButton",
|
|
39192
|
-
"dangerButton": "-kTeaG_dangerButton",
|
|
39193
|
-
"threadList": "-kTeaG_threadList",
|
|
39194
|
-
"review": "-kTeaG_review",
|
|
39195
|
-
"selectionPrompt": "-kTeaG_selectionPrompt",
|
|
39196
|
-
"reply": "-kTeaG_reply",
|
|
39197
|
-
"titleBlock": "-kTeaG_titleBlock",
|
|
39198
|
-
"toolbar": "-kTeaG_toolbar",
|
|
39197
|
+
"panelSummary": "-kTeaG_panelSummary",
|
|
39199
39198
|
"patchDetails": "-kTeaG_patchDetails",
|
|
39200
|
-
"
|
|
39201
|
-
"
|
|
39202
|
-
"
|
|
39203
|
-
"
|
|
39204
|
-
"
|
|
39205
|
-
"collapseRight": "-kTeaG_collapseRight",
|
|
39206
|
-
"richEditor": "-kTeaG_richEditor",
|
|
39207
|
-
"headerActions": "-kTeaG_headerActions",
|
|
39199
|
+
"chatError": "-kTeaG_chatError",
|
|
39200
|
+
"humanResponse": "-kTeaG_humanResponse",
|
|
39201
|
+
"responseForm": "-kTeaG_responseForm",
|
|
39202
|
+
"checkItem": "-kTeaG_checkItem",
|
|
39203
|
+
"itemsPanel": "-kTeaG_itemsPanel",
|
|
39208
39204
|
"paneHead": "-kTeaG_paneHead",
|
|
39209
|
-
"
|
|
39210
|
-
"selectedDoc": "-kTeaG_selectedDoc",
|
|
39205
|
+
"versionCompare": "-kTeaG_versionCompare",
|
|
39211
39206
|
"reviewTitle": "-kTeaG_reviewTitle",
|
|
39207
|
+
"conflictActions": "-kTeaG_conflictActions",
|
|
39208
|
+
"panelAction": "-kTeaG_panelAction",
|
|
39209
|
+
"editorPane": "-kTeaG_editorPane",
|
|
39210
|
+
"legacyWarning": "-kTeaG_legacyWarning",
|
|
39211
|
+
"chatToggle": "-kTeaG_chatToggle",
|
|
39212
|
+
"commentAction": "-kTeaG_commentAction",
|
|
39213
|
+
"conflictColumns": "-kTeaG_conflictColumns",
|
|
39214
|
+
"requirementRow": "-kTeaG_requirementRow",
|
|
39215
|
+
"entryActive": "-kTeaG_entryActive",
|
|
39216
|
+
"mobileCollab": "-kTeaG_mobileCollab",
|
|
39217
|
+
"decisionForm": "-kTeaG_decisionForm",
|
|
39212
39218
|
"tabScroller": "-kTeaG_tabScroller",
|
|
39219
|
+
"iconButton": "-kTeaG_iconButton",
|
|
39220
|
+
"checkBlocked": "-kTeaG_checkBlocked",
|
|
39221
|
+
"tabbar": "-kTeaG_tabbar",
|
|
39222
|
+
"conflictDialog": "-kTeaG_conflictDialog",
|
|
39223
|
+
"conflictModal": "-kTeaG_conflictModal",
|
|
39224
|
+
"modal": "-kTeaG_modal",
|
|
39225
|
+
"header": "-kTeaG_header",
|
|
39226
|
+
"footer": "-kTeaG_footer",
|
|
39227
|
+
"mobileViewSwitch": "-kTeaG_mobileViewSwitch",
|
|
39213
39228
|
"aiMessage": "-kTeaG_aiMessage",
|
|
39214
|
-
"
|
|
39215
|
-
"
|
|
39216
|
-
"responseForm": "-kTeaG_responseForm",
|
|
39217
|
-
"checkPassed": "-kTeaG_checkPassed",
|
|
39218
|
-
"downstreamReturn": "-kTeaG_downstreamReturn",
|
|
39219
|
-
"endedReview": "-kTeaG_endedReview",
|
|
39220
|
-
"editorMeta": "-kTeaG_editorMeta",
|
|
39221
|
-
"dangerText": "-kTeaG_dangerText",
|
|
39222
|
-
"run": "-kTeaG_run",
|
|
39223
|
-
"reviewCardBody": "-kTeaG_reviewCardBody",
|
|
39224
|
-
"runHistory": "-kTeaG_runHistory",
|
|
39225
|
-
"quickOptions": "-kTeaG_quickOptions",
|
|
39229
|
+
"paneActions": "-kTeaG_paneActions",
|
|
39230
|
+
"patchAccept": "-kTeaG_patchAccept",
|
|
39226
39231
|
"badges": "-kTeaG_badges",
|
|
39227
|
-
"resizerHidden": "-kTeaG_resizerHidden",
|
|
39228
|
-
"grid": "-kTeaG_grid",
|
|
39229
|
-
"emptyMain": "-kTeaG_emptyMain",
|
|
39230
|
-
"conflictHeader": "-kTeaG_conflictHeader",
|
|
39231
|
-
"checkIcon": "-kTeaG_checkIcon",
|
|
39232
|
-
"versionRow": "-kTeaG_versionRow",
|
|
39233
|
-
"itemsPanel": "-kTeaG_itemsPanel",
|
|
39234
39232
|
"execute": "-kTeaG_execute",
|
|
39235
|
-
"
|
|
39233
|
+
"compareHead": "-kTeaG_compareHead",
|
|
39234
|
+
"compareColumns": "-kTeaG_compareColumns",
|
|
39235
|
+
"cardActions": "-kTeaG_cardActions",
|
|
39236
39236
|
"noticeHidden": "-kTeaG_noticeHidden",
|
|
39237
|
-
"
|
|
39237
|
+
"selectedDoc": "-kTeaG_selectedDoc",
|
|
39238
|
+
"readyHead": "-kTeaG_readyHead",
|
|
39239
|
+
"endedReview": "-kTeaG_endedReview",
|
|
39240
|
+
"preview": "-kTeaG_preview",
|
|
39241
|
+
"entry": "-kTeaG_entry",
|
|
39242
|
+
"reply": "-kTeaG_reply",
|
|
39243
|
+
"editorTitle": "-kTeaG_editorTitle",
|
|
39244
|
+
"checkPassed": "-kTeaG_checkPassed",
|
|
39245
|
+
"selectionPrompt": "-kTeaG_selectionPrompt",
|
|
39246
|
+
"dangerText": "-kTeaG_dangerText",
|
|
39247
|
+
"threadList": "-kTeaG_threadList",
|
|
39248
|
+
"editorMeta": "-kTeaG_editorMeta",
|
|
39249
|
+
"unsaved": "-kTeaG_unsaved",
|
|
39250
|
+
"pendingReview": "-kTeaG_pendingReview",
|
|
39251
|
+
"toolbar": "-kTeaG_toolbar",
|
|
39238
39252
|
"resizer": "-kTeaG_resizer",
|
|
39239
|
-
"
|
|
39240
|
-
"
|
|
39241
|
-
"
|
|
39242
|
-
"legacyWarning": "-kTeaG_legacyWarning",
|
|
39253
|
+
"dangerButton": "-kTeaG_dangerButton",
|
|
39254
|
+
"empty": "-kTeaG_empty",
|
|
39255
|
+
"collapseRight": "-kTeaG_collapseRight",
|
|
39243
39256
|
"reviewCard": "-kTeaG_reviewCard",
|
|
39257
|
+
"reviewField": "-kTeaG_reviewField",
|
|
39258
|
+
"questionField": "-kTeaG_questionField",
|
|
39244
39259
|
"patchPreview": "-kTeaG_patchPreview",
|
|
39245
|
-
"
|
|
39246
|
-
"readyHead": "-kTeaG_readyHead",
|
|
39247
|
-
"versionCompare": "-kTeaG_versionCompare",
|
|
39248
|
-
"editorTitle": "-kTeaG_editorTitle",
|
|
39249
|
-
"tabBadge": "-kTeaG_tabBadge",
|
|
39250
|
-
"humanResponse": "-kTeaG_humanResponse",
|
|
39251
|
-
"mobileViewSwitch": "-kTeaG_mobileViewSwitch",
|
|
39252
|
-
"cardActions": "-kTeaG_cardActions",
|
|
39253
|
-
"missingOptions": "-kTeaG_missingOptions",
|
|
39254
|
-
"panelAction": "-kTeaG_panelAction",
|
|
39255
|
-
"aiConversation": "-kTeaG_aiConversation",
|
|
39256
|
-
"chatToggle": "-kTeaG_chatToggle",
|
|
39260
|
+
"downstreamReturn": "-kTeaG_downstreamReturn",
|
|
39257
39261
|
"itemRow": "-kTeaG_itemRow",
|
|
39258
|
-
"
|
|
39259
|
-
"
|
|
39260
|
-
"
|
|
39261
|
-
"
|
|
39262
|
-
"
|
|
39262
|
+
"missingOptions": "-kTeaG_missingOptions",
|
|
39263
|
+
"reviewDetails": "-kTeaG_reviewDetails",
|
|
39264
|
+
"checkIcon": "-kTeaG_checkIcon",
|
|
39265
|
+
"versionRow": "-kTeaG_versionRow",
|
|
39266
|
+
"conflictHeader": "-kTeaG_conflictHeader",
|
|
39267
|
+
"saveButton": "-kTeaG_saveButton",
|
|
39268
|
+
"userMessage": "-kTeaG_userMessage",
|
|
39269
|
+
"conflictDiffs": "-kTeaG_conflictDiffs",
|
|
39270
|
+
"chatComposer": "-kTeaG_chatComposer",
|
|
39271
|
+
"rowMenuButton": "-kTeaG_rowMenuButton",
|
|
39272
|
+
"newThread": "-kTeaG_newThread",
|
|
39273
|
+
"reviewCardBody": "-kTeaG_reviewCardBody",
|
|
39274
|
+
"evidence": "-kTeaG_evidence"
|
|
39263
39275
|
};
|
|
39264
39276
|
//#endregion
|
|
39265
39277
|
//#region src/client/SpecWorkbench.tsx
|
|
@@ -39282,7 +39294,7 @@ window.__ModuleLoader__.load({
|
|
|
39282
39294
|
] })] });
|
|
39283
39295
|
function newParticipant() {
|
|
39284
39296
|
return {
|
|
39285
|
-
participantId:
|
|
39297
|
+
participantId: browserUuid(),
|
|
39286
39298
|
nickname: "",
|
|
39287
39299
|
role: "product",
|
|
39288
39300
|
kind: "human"
|
|
@@ -41206,6 +41218,23 @@ window.__ModuleLoader__.load({
|
|
|
41206
41218
|
});
|
|
41207
41219
|
}
|
|
41208
41220
|
//#endregion
|
|
41221
|
+
//#region src/client/sidebar-anchor.ts
|
|
41222
|
+
function exactTextButton(document, text) {
|
|
41223
|
+
return [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === text);
|
|
41224
|
+
}
|
|
41225
|
+
function findSidebarAnchor(document) {
|
|
41226
|
+
const skillCenter = document.querySelector("button[aria-label=\"技能中心\"]") ?? exactTextButton(document, "技能中心");
|
|
41227
|
+
if (skillCenter !== void 0 && skillCenter !== null) return {
|
|
41228
|
+
element: skillCenter,
|
|
41229
|
+
placement: "after"
|
|
41230
|
+
};
|
|
41231
|
+
const settings = document.querySelector("button[aria-label=\"设置\"]") ?? exactTextButton(document, "设置");
|
|
41232
|
+
if (settings !== void 0 && settings !== null) return {
|
|
41233
|
+
element: settings,
|
|
41234
|
+
placement: "before"
|
|
41235
|
+
};
|
|
41236
|
+
}
|
|
41237
|
+
//#endregion
|
|
41209
41238
|
//#region src/client/mount.tsx
|
|
41210
41239
|
const ACTIVE = "data-dsh-spec-collab-active";
|
|
41211
41240
|
const VIEW = "[data-dsh-spec-collab-view]";
|
|
@@ -41263,17 +41292,17 @@ window.__ModuleLoader__.load({
|
|
|
41263
41292
|
};
|
|
41264
41293
|
const ensure = () => {
|
|
41265
41294
|
if (row?.isConnected) return;
|
|
41266
|
-
const
|
|
41267
|
-
if (
|
|
41295
|
+
const anchor = findSidebarAnchor(document);
|
|
41296
|
+
if (anchor === void 0) return;
|
|
41268
41297
|
row = document.createElement("button");
|
|
41269
41298
|
row.type = "button";
|
|
41270
41299
|
row.dataset.dshSpecCollabEntry = "";
|
|
41271
|
-
row.className = `${
|
|
41300
|
+
row.className = `${anchor.element.className} ${workbench_module_css_default.entry}`;
|
|
41272
41301
|
row.title = "需求讨论";
|
|
41273
41302
|
row.setAttribute("aria-label", "需求讨论");
|
|
41274
41303
|
row.innerHTML = "<span aria-hidden=\"true\">▤</span><span>需求讨论</span>";
|
|
41275
41304
|
row.addEventListener("click", toggle);
|
|
41276
|
-
|
|
41305
|
+
anchor.element[anchor.placement](row);
|
|
41277
41306
|
};
|
|
41278
41307
|
const observer = new MutationObserver(ensure);
|
|
41279
41308
|
observer.observe(document.body, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAiCvC,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,+BAyItD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/client/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/client/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAEtO,MAAM,WAAW,WAAW;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,mBAAmB,EAAE,CAAC;IAAC,YAAY,EAAE,eAAe,EAAE,CAAA;CAAE;AACvH,qBAAa,OAAO;IACZ,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IAC7B,gBAAgB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAC1D,OAAO,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAClE,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAC3E,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpH,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACrF,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;CACzC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface BrowserCrypto {
|
|
2
|
+
randomUUID?: () => string;
|
|
3
|
+
getRandomValues?: <T extends ArrayBufferView | null>(array: T) => T;
|
|
4
|
+
}
|
|
5
|
+
export declare function browserUuid(source?: BrowserCrypto | undefined): string;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=browser-uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-uuid.d.ts","sourceRoot":"","sources":["../../../src/client/browser-uuid.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;IACzB,eAAe,CAAC,EAAE,CAAC,CAAC,SAAS,eAAe,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;CACpE;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,aAAa,GAAG,SAA6B,GAAG,MAAM,CASzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/client/mount.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/client/mount.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AASvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,IAAI,CAoBvD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAuC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-anchor.d.ts","sourceRoot":"","sources":["../../../src/client/sidebar-anchor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAA;CAC9B;AAMD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS,CAM/E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-spec-collab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "AI-assisted requirement clarification and Git-backed Spec co-creation for DeepSeek Harness, ending at a human-confirmed Ready Spec.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
70
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
71
|
-
"@deepseek-ai/dsh-client-runtime": "^0.1.
|
|
72
|
-
"@deepseek-ai/dsh-host-apiproxy": "^0.1.
|
|
73
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.
|
|
74
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
75
|
-
"@deepseek-ai/dsh-system-prompt": "^0.1.
|
|
76
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
70
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.1-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-host-apiproxy": "^0.1.1-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-tools": "^0.1.1-rc.1",
|
|
77
77
|
"@types/markdown-it": "^14.1.2",
|
|
78
78
|
"@types/node": "^22.20.0",
|
|
79
79
|
"@types/react": "~18.3.1",
|
|
@@ -5,6 +5,7 @@ import '@toast-ui/editor/dist/i18n/zh-cn'
|
|
|
5
5
|
import { InputRule, inputRules } from 'prosemirror-inputrules'
|
|
6
6
|
import type { CollaborationAction, CommentResolution, MyActionItem, ParticipantRole, ParticipantSnapshot, RequirementStage, RequirementVersion, RequirementView, ReviewKind, ReviewWorkspaceSummary, SaveConflict } from '../protocol.ts'
|
|
7
7
|
import type { SpecApi } from './api.ts'
|
|
8
|
+
import { browserUuid } from './browser-uuid.ts'
|
|
8
9
|
import css from './workbench.module.css'
|
|
9
10
|
|
|
10
11
|
const md = new MarkdownIt({ html: false, linkify: true })
|
|
@@ -21,7 +22,7 @@ const markdownShortcutsPlugin = () => ({ wysiwygPlugins: [() => inputRules({ rul
|
|
|
21
22
|
] })] })
|
|
22
23
|
type SideTab = 'review' | 'discussion' | 'patches' | 'decisions' | 'items' | 'versions' | 'ready'
|
|
23
24
|
type CommentAnchor = { quote: string; prefix: string; suffix: string; heading?: string }
|
|
24
|
-
function newParticipant(): ParticipantSnapshot { return { participantId:
|
|
25
|
+
function newParticipant(): ParticipantSnapshot { return { participantId: browserUuid(), nickname: '', role: 'product', kind: 'human' } }
|
|
25
26
|
function loadParticipant(): ParticipantSnapshot { try { const value = JSON.parse(localStorage.getItem('dsh-spec-collab.participant') ?? '') as ParticipantSnapshot; if (value.participantId) return { ...value, kind: 'human' } } catch {} return newParticipant() }
|
|
26
27
|
function stageLabel(stage: RequirementStage): string { return ({ 'product-review': '产品审核', 'product-confirmation': '产品确认', 'joint-review': '产研共审', ready: 'Ready' })[stage] }
|
|
27
28
|
function currentPendingActions(requirement: RequirementView): RequirementView['actionItems'] {
|
package/src/client/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { API_PREFIX, type ActionEnvelope, type ActionResult, type CollaborationAction, type MyActionItem, type ParticipantSnapshot, type RequirementVersion, type RequirementView, type ReviewWorkspaceSummary } from '../protocol.ts'
|
|
2
|
+
import { browserUuid } from './browser-uuid.ts'
|
|
2
3
|
export interface ClientState { revision: number; participants: ParticipantSnapshot[]; requirements: RequirementView[] }
|
|
3
4
|
export class SpecApi {
|
|
4
5
|
async state(): Promise<ClientState> { const response = await fetch(`${API_PREFIX}/state`, { headers: { accept: 'application/json' } }); if (!response.ok) throw new Error(`state request failed (${response.status})`); const state = await response.json() as Partial<ClientState>; return { revision: state.revision ?? 0, participants: state.participants ?? [], requirements: state.requirements ?? [] } }
|
|
5
6
|
async reviewWorkspaces(): Promise<ReviewWorkspaceSummary[]> { const response = await fetch(`${API_PREFIX}/review-workspaces`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; workspaces?: ReviewWorkspaceSummary[]; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载需求工作区失败'); return result.workspaces ?? [] }
|
|
6
|
-
async action(action: CollaborationAction): Promise<ActionResult> { const envelope: ActionEnvelope = { requestId:
|
|
7
|
+
async action(action: CollaborationAction): Promise<ActionResult> { const envelope: ActionEnvelope = { requestId: browserUuid(), action }; const response = await fetch(`${API_PREFIX}/action`, { method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json' }, body: JSON.stringify(envelope) }); return response.json() as Promise<ActionResult> }
|
|
7
8
|
async myItems(participant: ParticipantSnapshot): Promise<MyActionItem[]> { const query = new URLSearchParams({ participantId: participant.participantId, role: participant.role }); const response = await fetch(`${API_PREFIX}/my-items?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; items?: MyActionItem[]; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载我的事项失败'); return result.items ?? [] }
|
|
8
9
|
async version(requirementId: string, commit: string): Promise<RequirementVersion> { const query = new URLSearchParams({ requirementId, commit }); const response = await fetch(`${API_PREFIX}/version?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; version?: RequirementVersion; error?: string }; if (!response.ok || !result.ok || !result.version) throw new Error(result.error ?? '加载历史版本失败'); return result.version }
|
|
9
10
|
async conversation(requirementId: string, sessionId: string): Promise<Array<{ role: 'user' | 'assistant'; text: string }>> { const query = new URLSearchParams({ requirementId, sessionId }); const response = await fetch(`${API_PREFIX}/ai-conversation?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; messages?: Array<{ role: 'user' | 'assistant'; text: string }>; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载 AI 对话失败'); return result.messages ?? [] }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface BrowserCrypto {
|
|
2
|
+
randomUUID?: () => string
|
|
3
|
+
getRandomValues?: <T extends ArrayBufferView | null>(array: T) => T
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function browserUuid(source: BrowserCrypto | undefined = globalThis.crypto): string {
|
|
7
|
+
if (typeof source?.randomUUID === 'function') return source.randomUUID()
|
|
8
|
+
const bytes = new Uint8Array(16)
|
|
9
|
+
if (typeof source?.getRandomValues === 'function') source.getRandomValues(bytes)
|
|
10
|
+
else for (let index = 0; index < bytes.length; index += 1) bytes[index] = Math.floor(Math.random() * 256)
|
|
11
|
+
bytes[6] = (bytes[6]! & 0x0f) | 0x40
|
|
12
|
+
bytes[8] = (bytes[8]! & 0x3f) | 0x80
|
|
13
|
+
const hex = [...bytes].map(value => value.toString(16).padStart(2, '0'))
|
|
14
|
+
return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10).join('')}`
|
|
15
|
+
}
|
package/src/client/mount.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { createRoot } from 'react-dom/client'
|
|
|
3
3
|
import type { SpecApi } from './api.ts'
|
|
4
4
|
import { SpecWorkbench } from './SpecWorkbench.tsx'
|
|
5
5
|
import css from './workbench.module.css'
|
|
6
|
+
import { findSidebarAnchor } from './sidebar-anchor.ts'
|
|
6
7
|
|
|
7
8
|
const ACTIVE = 'data-dsh-spec-collab-active'
|
|
8
9
|
const VIEW = '[data-dsh-spec-collab-view]'
|
|
@@ -53,18 +54,17 @@ export function mountSidebarEntry(): () => void {
|
|
|
53
54
|
}
|
|
54
55
|
const ensure = (): void => {
|
|
55
56
|
if (row?.isConnected) return
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
if (skillCenter === undefined || skillCenter === null) return
|
|
57
|
+
const anchor = findSidebarAnchor(document)
|
|
58
|
+
if (anchor === undefined) return
|
|
59
59
|
row = document.createElement('button')
|
|
60
60
|
row.type = 'button'
|
|
61
61
|
row.dataset.dshSpecCollabEntry = ''
|
|
62
|
-
row.className = `${
|
|
62
|
+
row.className = `${anchor.element.className} ${css.entry!}`
|
|
63
63
|
row.title = '需求讨论'
|
|
64
64
|
row.setAttribute('aria-label', '需求讨论')
|
|
65
65
|
row.innerHTML = '<span aria-hidden="true">▤</span><span>需求讨论</span>'
|
|
66
66
|
row.addEventListener('click', toggle)
|
|
67
|
-
|
|
67
|
+
anchor.element[anchor.placement](row)
|
|
68
68
|
}
|
|
69
69
|
const observer = new MutationObserver(ensure)
|
|
70
70
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SidebarAnchor {
|
|
2
|
+
element: HTMLButtonElement
|
|
3
|
+
placement: 'before' | 'after'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function exactTextButton(document: Document, text: string): HTMLButtonElement | undefined {
|
|
7
|
+
return [...document.querySelectorAll<HTMLButtonElement>('button')].find(button => button.textContent?.trim() === text)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function findSidebarAnchor(document: Document): SidebarAnchor | undefined {
|
|
11
|
+
const skillCenter = document.querySelector<HTMLButtonElement>('button[aria-label="技能中心"]') ?? exactTextButton(document, '技能中心')
|
|
12
|
+
if (skillCenter !== undefined && skillCenter !== null) return { element: skillCenter, placement: 'after' }
|
|
13
|
+
const settings = document.querySelector<HTMLButtonElement>('button[aria-label="设置"]') ?? exactTextButton(document, '设置')
|
|
14
|
+
if (settings !== undefined && settings !== null) return { element: settings, placement: 'before' }
|
|
15
|
+
return undefined
|
|
16
|
+
}
|