From 3e7e2799c4cd55435a792643102028a275141bb0 Mon Sep 17 00:00:00 2001 From: wangheng Date: Fri, 4 Dec 2026 09:19:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(diag):=20=E5=A2=9E=E5=8A=A0=E7=8E=B0?= =?UTF-8?q?=E5=9C=BA=E8=AF=8A=E6=96=AD=E4=B8=8A=E6=8A=A5=E9=80=9A=E9=81=93?= =?UTF-8?q?=20(v0.5.3-local.15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 内嵌视图(DS Bot 等)没有 DevTools,无法读取插件运行现场。新增: - 服务端 /api/worktable/diag(需鉴权):把客户端上报的 JSON 追加到 /logs/worktable-diag.log - 客户端 apply() 在 1.5s/5s 各上报一次:href、__ModuleLoader__ 类型、 style[data-dsh-plugin] 数量、.dsh-wt_section/.dsh-wt_edgeStrip 数量、 sidebar/overlayHost 是否存在、body 子元素数、窗口宽度、最近 5 条 window 错误 用途:确认 DS Bot 视图里插件 client 是否加载、哪个座位渲染,据此再修复。 验证:npm run pack 全绿,双资产同源 aafb7ab2…。 --- 01_content/dsh.plugin.json | 2 +- 01_content/lib/client.js | 36 ++++++++++++++++++++++++++++++++- 01_content/lib/index.js | 23 ++++++++++++++++++++- 01_content/package.json | 2 +- 01_content/src/client/index.tsx | 32 +++++++++++++++++++++++++++++ 01_content/src/index.ts | 21 +++++++++++++++++++ 02_process/LOCAL-CHANGES.md | 6 +++--- README.md | 10 ++++----- 8 files changed, 120 insertions(+), 12 deletions(-) diff --git a/01_content/dsh.plugin.json b/01_content/dsh.plugin.json index 54cbefb..880d7e0 100644 --- a/01_content/dsh.plugin.json +++ b/01_content/dsh.plugin.json @@ -1,7 +1,7 @@ { "name": "dsh-worktable", "description": "工作台:DSH 侧边栏的 agent 级项目容器,收纳如 TravelAtlas 等自装项目", - "version": "0.5.3-local.14", + "version": "0.5.3-local.15", "entry": { "name": "dsh-worktable", "inject": [] diff --git a/01_content/lib/client.js b/01_content/lib/client.js index eb6e9b5..eabc950 100644 --- a/01_content/lib/client.js +++ b/01_content/lib/client.js @@ -9233,7 +9233,7 @@ var CHANGELOG_V030 = `\u66F4\u65B0\u516C\u544A \xB7 v0.5.1 \u30103.1 \u6587\u5B57\u4E0E\u7EC6\u8282\u6253\u78E8\u3011\u5168\u5C40\u5B57\u4F53\u4E0E\u5B57\u53F7\u7EDF\u4E00\u4F18\u5316\u3001\u4E0B\u62C9\u9762\u677F\u73BB\u7483\u5316\u4E0E\u5BF9\u9F50\u3001\u83DC\u5355\u70B9\u9009\u540E\u4FDD\u6301\u6253\u5F00\u4FBF\u4E8E\u8FDE\u7EED\u9884\u89C8\u3001\u6309\u94AE\u63CF\u8FB9\u4E0E\u60AC\u505C\u53CD\u9988\u7B49\u4EA4\u4E92\u7EC6\u8282\uFF1B\u540C\u65F6\u4FEE\u590D\u4E86\u591A\u9879\u4F53\u9A8C\u95EE\u9898\uFF08\u7167\u7247\u4E0A\u4F20\u6E05\u6670\u5EA6\u3001\u80CC\u666F\u7F51\u683C\u7EBF\u5728\u7167\u7247\u6A21\u5F0F\u4E0B\u4E0D\u751F\u6548\u3001\u6D45\u8272\u4E3B\u9898\u4E0B\u5DE5\u4F5C\u72B6\u6001\u5149\u6548\u4E0D\u53EF\u89C1\u7B49\uFF09\u3002`; // src/client/updateCheck.ts -var LOCAL_VERSION = false ? "dev" : "0.5.3-local.14"; +var LOCAL_VERSION = false ? "dev" : "0.5.3-local.15"; var UPDATE_API = "/api/worktable/update-check"; var K_UPDATE_CHECK = "dsh.worktable.updateCheck.v1"; var K_LAST_CHECK = "dsh.worktable.lastUpdateCheck.v1"; @@ -24397,6 +24397,40 @@ function WorktableSection(props) { } var inject = ["slots", "locale", "sessions", "conversation", "workspaces"]; function apply(ctx) { + try { + const sendDiag = (tag) => { + try { + void fetch("/api/worktable/diag", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + tag, + href: String(location.href), + loader: typeof window.__ModuleLoader__, + styles: document.querySelectorAll("style[data-dsh-plugin]").length, + sections: document.querySelectorAll(".dsh-wt_section").length, + strips: document.querySelectorAll(".dsh-wt_edgeStrip").length, + sidebar: !!document.querySelector('aside, nav, [class*="SidebarRoot"], [class*="sidebar"]'), + overlayHost: !!document.querySelector("[data-shell-overlay]"), + bodyKids: document.body ? document.body.children.length : -1, + wide: window.innerWidth, + errors: diagErrors.slice(-5) + }) + }); + } catch { + } + }; + const diagErrors = []; + window.addEventListener("error", (e) => { + try { + diagErrors.push(String(e?.message ?? e?.error ?? "error")); + } catch { + } + }); + window.setTimeout(() => sendDiag("t1500"), 1500); + window.setTimeout(() => sendDiag("t5000"), 5e3); + } catch { + } sessionBridge = { sessions: ctx.sessions ?? null, conversation: ctx.conversation ?? null, list: ctx.sessions?.list ?? null, workspaces: ctx.workspaces ?? null }; clientCtx = ctx; try { diff --git a/01_content/lib/index.js b/01_content/lib/index.js index 71e19de..df0d7d8 100644 --- a/01_content/lib/index.js +++ b/01_content/lib/index.js @@ -382,7 +382,7 @@ function resolveDshHomeSafe() { cachedDshHome = baseDshHome(); return cachedDshHome; } -var PLUGIN_VERSION = false ? "dev" : "0.5.3-local.14"; +var PLUGIN_VERSION = false ? "dev" : "0.5.3-local.15"; var name = "dsh-worktable"; var inject = ["webServer", "sessions"]; var HEALTH_PATH = "/api/worktable/health"; @@ -1141,6 +1141,27 @@ function apply(ctx) { } } }); + register({ + kind: "exact", + path: "/api/worktable/diag", + handler: async (req, res) => { + if (req.method !== "POST") { + json(res, 405, { error: "method not allowed" }); + return; + } + try { + const body = await readJsonBody(req); + const line = (/* @__PURE__ */ new Date()).toISOString() + " " + JSON.stringify(body ?? null).slice(0, 4e3); + const fsx = await import("node:fs/promises"); + const dir = pathResolve(resolveDshHomeSafe(), "logs"); + await fsx.mkdir(dir, { recursive: true }); + await fsx.appendFile(pathResolve(dir, "worktable-diag.log"), line + String.fromCharCode(10), "utf8"); + json(res, 200, { ok: true }); + } catch (err) { + json(res, 500, { error: String(err?.message ?? err) }); + } + } + }); setupTerminal(webServer, ctx); } export { diff --git a/01_content/package.json b/01_content/package.json index 5d59c20..d9a4c62 100644 --- a/01_content/package.json +++ b/01_content/package.json @@ -1,7 +1,7 @@ { "name": "dsh-worktable", "description": "工作台 Worktable:DeepSeek Harness 侧边栏的 agent 级项目容器(应用抽屉)", - "version": "0.5.3-local.14", + "version": "0.5.3-local.15", "repository": { "type": "git", "url": "https://github.com/Aisland-SJL/dsh-worktable.git", diff --git a/01_content/src/client/index.tsx b/01_content/src/client/index.tsx index 250cd2d..285d5d4 100644 --- a/01_content/src/client/index.tsx +++ b/01_content/src/client/index.tsx @@ -3572,6 +3572,38 @@ function buildCustomLayoutPrompt(req: string): string { export const inject = ['slots', 'locale', 'sessions', 'conversation', 'workspaces'] export function apply(ctx: any) { + // 现场诊断上报:内嵌视图没有 DevTools,把关键事实 POST 到宿主 /api/worktable/diag, + // 直接落到 /logs/worktable-diag.log。上线稳定后可删。 + try { + const sendDiag = (tag: string) => { + try { + void fetch('/api/worktable/diag', { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ + tag, + href: String(location.href), + loader: typeof (window as any).__ModuleLoader__, + styles: document.querySelectorAll('style[data-dsh-plugin]').length, + sections: document.querySelectorAll('.dsh-wt_section').length, + strips: document.querySelectorAll('.dsh-wt_edgeStrip').length, + sidebar: !!document.querySelector('aside, nav, [class*="SidebarRoot"], [class*="sidebar"]'), + overlayHost: !!document.querySelector('[data-shell-overlay]'), + bodyKids: document.body ? document.body.children.length : -1, + wide: (window as any).innerWidth, + errors: diagErrors.slice(-5), + }), + }) + } catch { /* ignore */ } + } + const diagErrors: string[] = [] + window.addEventListener('error', (e: any) => { + try { diagErrors.push(String(e?.message ?? e?.error ?? 'error')) } catch {} + }) + window.setTimeout(() => sendDiag('t1500'), 1500) + window.setTimeout(() => sendDiag('t5000'), 5000) + } catch { /* ignore */ } + // 自定义窗口 → 宿主会话桥:保存 sessions/conversation/list 服务引用(模块级) sessionBridge = { sessions: ctx.sessions ?? null, conversation: ctx.conversation ?? null, list: ctx.sessions?.list ?? null, workspaces: ctx.workspaces ?? null } clientCtx = ctx diff --git a/01_content/src/index.ts b/01_content/src/index.ts index 74fc4e8..36fa87e 100644 --- a/01_content/src/index.ts +++ b/01_content/src/index.ts @@ -717,6 +717,27 @@ export function apply(ctx: Context) { } }, }) + // 诊断通道:内嵌视图(DS Bot 等)没有 DevTools,客户端把现场信息 POST 到这里落盘, + // 便于直接读 /logs/worktable-diag.log。只在显式上报时写入。 + register({ + kind: 'exact', + path: '/api/worktable/diag', + handler: async (req: any, res: any) => { + if (req.method !== 'POST') { json(res, 405, { error: 'method not allowed' }); return } + try { + const body = await readJsonBody(req) + const line = new Date().toISOString() + ' ' + JSON.stringify(body ?? null).slice(0, 4000) + const fsx = await import('node:fs/promises') + const dir = pathResolve(resolveDshHomeSafe(), 'logs') + await fsx.mkdir(dir, { recursive: true }) + await fsx.appendFile(pathResolve(dir, 'worktable-diag.log'), line + String.fromCharCode(10), 'utf8') + json(res, 200, { ok: true }) + } catch (err: any) { + json(res, 500, { error: String(err?.message ?? err) }) + } + }, + }) + setupTerminal(webServer, ctx) } diff --git a/02_process/LOCAL-CHANGES.md b/02_process/LOCAL-CHANGES.md index 9386616..6871904 100644 --- a/02_process/LOCAL-CHANGES.md +++ b/02_process/LOCAL-CHANGES.md @@ -4,9 +4,9 @@ > 每条标注日期、动机、落点与验证方式。改动在 `01_content/src/`,经 `npm run build` > 产出 `lib/`;发布物由 `npm run pack`(`01_content/release-prep.mjs`)生成。 -当前版本:**0.5.3-local.14**(2026-12-03) -产物:`01_content/dist/v0.5.3-local.14/dsh-worktable.tgz`,488494 字节, -sha256 `c28cba759426a38002c172ff06a37c260ce8eb3c0b3987478c96229f3d7c9551` +当前版本:**0.5.3-local.15**(2026-12-04) +产物:`01_content/dist/v0.5.3-local.15/dsh-worktable.tgz`,488948 字节, +sha256 `aafb7ab2fa6fc94028c0d28c04409668defdd061522aeaaa8b49a2dad0a1f0f5` --- diff --git a/README.md b/README.md index f7131b1..2690322 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > ## 📦 本仓库是内部补丁分发仓,不是上游源码仓 > -> 上游: | 本仓 = 上游 **v0.5.1** + 桌面端状态持久化补丁 + 本项目自用的若干增强(`0.5.3-local.14`)。 +> 上游: | 本仓 = 上游 **v0.5.1** + 桌面端状态持久化补丁 + 本项目自用的若干增强(`0.5.3-local.15`)。 > 下面从「Screenshots」开始的全部内容是上游 README 原文;本地改动逐条记录见 [LOCAL-CHANGES.md](02_process/LOCAL-CHANGES.md)。 ### 要不要装 @@ -16,16 +16,16 @@ ### 安装 -当前版本 **v0.5.3-local.14**: +当前版本 **v0.5.3-local.15**: ```bash -dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download/v0.5.3-local.14/dsh-worktable.tgz" +dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download/v0.5.3-local.15/dsh-worktable.tgz" ``` - **桌面端:先完全退出 Slark,再执行命令**,装完手动重开;不要在宿主运行时安装。 - `--profile web` 按你自己的 profile 名字改。 -- 资产 `dsh-worktable.tgz`,488494 字节,sha256: - `c28cba759426a38002c172ff06a37c260ce8eb3c0b3987478c96229f3d7c9551` +- 资产 `dsh-worktable.tgz`,488948 字节,sha256: + `aafb7ab2fa6fc94028c0d28c04409668defdd061522aeaaa8b49a2dad0a1f0f5` (下载后可 `Get-FileHash dsh-worktable.tgz -Algorithm SHA256` 核对) - 声明兼容的 DSH 版本:`0.2.0-rc.2` / `0.2.1-rc.3` / `0.2.1-rc.5` / `0.2.2-alpha.2`。 宿主不在这个列表里时,安装会被兼容性检查直接拒绝并回滚。