dsh-todo-board 0.4.1

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/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "dsh-todo-board",
3
+ "version": "0.4.1",
4
+ "description": "跨会话 TODO 板:右上角浮窗、按工作目录分组、可拖动排序;每条待办可选「提醒 / 自动续跑 / 自动新开会话」三档执行模式,可附图片(派发时作为真正的图片发给模型),可设定本地时间到点才执行,双勾选(AI 完成 / 用户验收)。AI 完成一项后自动查找同目录下一条未完成待办并继续执行。",
5
+ "private": false,
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "sueqet",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/sueqet/dsh-todo-board.git"
12
+ },
13
+ "homepage": "https://github.com/sueqet/dsh-todo-board#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/sueqet/dsh-todo-board/issues"
16
+ },
17
+ "engines": {
18
+ "node": ">=22.19.0",
19
+ "dsh": ">=0.1.0-rc.6"
20
+ },
21
+ "files": [
22
+ "lib",
23
+ "client",
24
+ "tools",
25
+ "cordis.patch.yml",
26
+ "README.md",
27
+ "CHANGELOG.md",
28
+ "LICENSE"
29
+ ],
30
+ "keywords": [
31
+ "deepseek",
32
+ "deepseek-harness",
33
+ "dsh",
34
+ "dsh-plugin",
35
+ "cordis",
36
+ "todo",
37
+ "todo-list",
38
+ "task-board",
39
+ "待办",
40
+ "定时执行",
41
+ "图片附件",
42
+ "自动接续"
43
+ ],
44
+ "scripts": {
45
+ "check": "node --check lib/index.js && node --check client/client.js",
46
+ "test": "node tools/smoke.mjs"
47
+ },
48
+ "dsh": {
49
+ "category": "extension",
50
+ "displayName": "TODO 板",
51
+ "bundle": {
52
+ "patch": "./cordis.patch.yml"
53
+ },
54
+ "client": {
55
+ "inject": [
56
+ "@deepseek-ai/dsh-client-connection",
57
+ "@deepseek-ai/dsh-client-runtime",
58
+ "@deepseek-ai/dsh-client-locale",
59
+ "@deepseek-ai/dsh-client-ui-settings",
60
+ "@deepseek-ai/dsh-client-ui-theme"
61
+ ],
62
+ "platform": "web"
63
+ }
64
+ },
65
+ "exports": {
66
+ ".": "./lib/index.js",
67
+ "./client": "./client/client.js",
68
+ "./cordis.patch.yml": "./cordis.patch.yml",
69
+ "./package.json": "./package.json"
70
+ },
71
+ "peerDependencies": {
72
+ "@deepseek-ai/cordis": "^4.0.1"
73
+ }
74
+ }
@@ -0,0 +1,254 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Regenerate the marketplace screenshots (assets/screenshot-*.png) from a live
4
+ * DSH web UI. The plugin's panel is rendered by the running server, so this
5
+ * script drives a headless Chromium over the DevTools protocol instead of
6
+ * drawing anything itself — the images are real renders of the real panel.
7
+ *
8
+ * node tools/capture-screenshots.mjs
9
+ *
10
+ * Environment overrides:
11
+ * DSHTB_URL app URL (default http://127.0.0.1:3080)
12
+ * DSHTB_CHROME chromium executable (default Chrome on Windows)
13
+ * DSHTB_OUT output directory (default <repo>/assets)
14
+ * DSHTB_PORT DevTools port (default 9222)
15
+ *
16
+ * The script only reads the page. It never clicks a control that writes to the
17
+ * board, so running it cannot change anybody's tasks. The only state it sets is
18
+ * the panel's localStorage geometry, in a throwaway browser profile.
19
+ */
20
+ import { spawn } from 'node:child_process'
21
+ import { mkdirSync, writeFileSync } from 'node:fs'
22
+ import { dirname, join, resolve } from 'node:path'
23
+ import { tmpdir } from 'node:os'
24
+ import { fileURLToPath } from 'node:url'
25
+
26
+ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
27
+ const OUT = process.env.DSHTB_OUT ? resolve(process.env.DSHTB_OUT) : join(ROOT, 'assets')
28
+ const APP = process.env.DSHTB_URL ?? 'http://127.0.0.1:3080'
29
+ const PORT = Number(process.env.DSHTB_PORT ?? 9222)
30
+ const CHROME =
31
+ process.env.DSHTB_CHROME ??
32
+ 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
33
+ const PROFILE = join(tmpdir(), 'dshtb-shot-profile')
34
+ const VIEW = { width: 1440, height: 900 }
35
+ const LAYOUT_KEY = 'dsh.todoBoard.layout.v1'
36
+
37
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
38
+
39
+ async function jsonOverHttp(path, timeoutMs = 30000) {
40
+ const deadline = Date.now() + timeoutMs
41
+ let last = 'no attempt'
42
+ while (Date.now() < deadline) {
43
+ try {
44
+ const res = await fetch(`http://127.0.0.1:${PORT}${path}`)
45
+ if (res.ok) return await res.json()
46
+ last = `HTTP ${res.status}`
47
+ } catch (err) {
48
+ last = err.message
49
+ }
50
+ await sleep(250)
51
+ }
52
+ throw new Error(`DevTools endpoint :${PORT}${path} unreachable: ${last}`)
53
+ }
54
+
55
+ class Cdp {
56
+ constructor(ws) {
57
+ this.ws = ws
58
+ this.seq = 0
59
+ this.pending = new Map()
60
+ ws.addEventListener('message', (event) => {
61
+ let msg
62
+ try {
63
+ msg = JSON.parse(typeof event.data === 'string' ? event.data : '')
64
+ } catch {
65
+ return
66
+ }
67
+ const waiter = msg.id === undefined ? undefined : this.pending.get(msg.id)
68
+ if (waiter === undefined) return
69
+ this.pending.delete(msg.id)
70
+ if (msg.error) waiter.reject(new Error(`${msg.error.message} (${waiter.method})`))
71
+ else waiter.resolve(msg.result)
72
+ })
73
+ }
74
+
75
+ static async connect(url) {
76
+ const ws = new WebSocket(url)
77
+ await new Promise((resolve_, reject) => {
78
+ ws.addEventListener('open', resolve_, { once: true })
79
+ ws.addEventListener('error', () => reject(new Error('DevTools websocket failed')), {
80
+ once: true,
81
+ })
82
+ })
83
+ return new Cdp(ws)
84
+ }
85
+
86
+ send(method, params = {}, timeoutMs = 30000) {
87
+ const id = ++this.seq
88
+ return new Promise((resolve_, reject) => {
89
+ const timer = setTimeout(() => {
90
+ if (this.pending.delete(id)) reject(new Error(`${method} timed out`))
91
+ }, timeoutMs)
92
+ this.pending.set(id, {
93
+ method,
94
+ resolve: (value) => {
95
+ clearTimeout(timer)
96
+ resolve_(value)
97
+ },
98
+ reject: (err) => {
99
+ clearTimeout(timer)
100
+ reject(err)
101
+ },
102
+ })
103
+ this.ws.send(JSON.stringify({ id, method, params }))
104
+ })
105
+ }
106
+
107
+ async evaluate(expression) {
108
+ const res = await this.send('Runtime.evaluate', {
109
+ expression,
110
+ returnByValue: true,
111
+ awaitPromise: true,
112
+ })
113
+ if (res.exceptionDetails) {
114
+ const text =
115
+ res.exceptionDetails.exception?.description ?? res.exceptionDetails.text ?? 'unknown'
116
+ throw new Error(`evaluate failed: ${text}`)
117
+ }
118
+ return res.result?.value
119
+ }
120
+
121
+ async screenshot(file, clip) {
122
+ const params = { format: 'png' }
123
+ if (clip) {
124
+ params.clip = clip
125
+ params.captureBeyondViewport = true
126
+ }
127
+ const { data } = await this.send('Page.captureScreenshot', params)
128
+ writeFileSync(file, Buffer.from(data, 'base64'))
129
+ return file
130
+ }
131
+ }
132
+
133
+ /** Poll until the todo panel is in the DOM, or give up with diagnostics. */
134
+ async function waitForPanel(cdp, timeoutMs = 45000) {
135
+ const deadline = Date.now() + timeoutMs
136
+ while (Date.now() < deadline) {
137
+ const found = await cdp
138
+ .evaluate("!!document.querySelector('.dshtb-root')")
139
+ .catch(() => false)
140
+ if (found) return true
141
+ await sleep(500)
142
+ }
143
+ return false
144
+ }
145
+
146
+ async function main() {
147
+ const chrome = spawn(
148
+ CHROME,
149
+ [
150
+ '--headless=new',
151
+ '--no-sandbox',
152
+ '--disable-gpu',
153
+ '--hide-scrollbars',
154
+ '--no-first-run',
155
+ '--no-default-browser-check',
156
+ '--disable-extensions',
157
+ '--disable-background-networking',
158
+ `--user-data-dir=${PROFILE}`,
159
+ `--remote-debugging-port=${PORT}`,
160
+ `--window-size=${VIEW.width},${VIEW.height}`,
161
+ 'about:blank',
162
+ ],
163
+ { stdio: 'ignore' },
164
+ )
165
+
166
+ try {
167
+ const version = await jsonOverHttp('/json/version')
168
+ const targets = await jsonOverHttp('/json/list')
169
+ const page = targets.find((t) => t.type === 'page')
170
+ if (page === undefined) throw new Error('no page target in Chromium')
171
+
172
+ const cdp = await Cdp.connect(page.webSocketDebuggerUrl)
173
+ await cdp.send('Page.enable')
174
+ await cdp.send('Runtime.enable')
175
+ await cdp.send('Emulation.setDeviceMetricsOverride', {
176
+ width: VIEW.width,
177
+ height: VIEW.height,
178
+ deviceScaleFactor: 1,
179
+ mobile: false,
180
+ })
181
+
182
+ // First pass: seed the panel geometry, so the shot does not depend on CSS
183
+ // defaults (and never writes anything back to the board).
184
+ await cdp.send('Page.navigate', { url: APP })
185
+ await sleep(2000)
186
+ await cdp.evaluate(
187
+ `(() => {
188
+ const w = 520, h = 660
189
+ const x = Math.max(8, window.innerWidth - w - 28), y = 24
190
+ localStorage.setItem(${JSON.stringify(LAYOUT_KEY)}, JSON.stringify({ x, y, w, h }))
191
+ return true
192
+ })()`,
193
+ )
194
+ await cdp.send('Page.reload', { ignoreCache: false })
195
+
196
+ if (!(await waitForPanel(cdp))) {
197
+ mkdirSync(OUT, { recursive: true })
198
+ const debug = {
199
+ url: APP,
200
+ title: await cdp.evaluate('document.title').catch(() => ''),
201
+ text: await cdp
202
+ .evaluate('(document.body && document.body.innerText || "").slice(0, 1500)')
203
+ .catch(() => ''),
204
+ html: await cdp
205
+ .evaluate('(document.body && document.body.innerHTML || "").slice(0, 2000)')
206
+ .catch(() => ''),
207
+ }
208
+ writeFileSync(join(OUT, 'capture-debug.json'), JSON.stringify(debug, null, 2))
209
+ await cdp.screenshot(join(OUT, 'capture-debug.png')).catch(() => {})
210
+ throw new Error(`panel .dshtb-root never appeared — see ${join(OUT, 'capture-debug.json')}`)
211
+ }
212
+
213
+ // Let the client finish its first data fetch and the entry animation.
214
+ await sleep(2500)
215
+ mkdirSync(OUT, { recursive: true })
216
+
217
+ const wide = await cdp.screenshot(join(OUT, 'screenshot-1.png'))
218
+ const rect = await cdp.evaluate(
219
+ `(() => {
220
+ const el = document.querySelector('.dshtb-root')
221
+ const r = el.getBoundingClientRect()
222
+ return {
223
+ x: Math.max(0, Math.floor(r.x - 10)),
224
+ y: Math.max(0, Math.floor(r.y - 10)),
225
+ width: Math.ceil(r.width + 20),
226
+ height: Math.ceil(r.height + 20),
227
+ }
228
+ })()`,
229
+ )
230
+ const detail = await cdp.screenshot(join(OUT, 'screenshot-2.png'), { ...rect, scale: 2 })
231
+
232
+ console.log(
233
+ JSON.stringify(
234
+ {
235
+ ok: true,
236
+ browser: version.Browser,
237
+ url: APP,
238
+ title: await cdp.evaluate('document.title'),
239
+ panel: rect,
240
+ files: [wide, detail],
241
+ },
242
+ null,
243
+ 2,
244
+ ),
245
+ )
246
+ } finally {
247
+ chrome.kill()
248
+ }
249
+ }
250
+
251
+ main().catch((err) => {
252
+ console.error('capture failed: ' + (err && err.stack ? err.stack : err))
253
+ process.exitCode = 1
254
+ })