@gongfpp/dsh-novel-fish 1.1.0 → 1.2.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +41 -20
  3. package/docs/evidence/settings-reliability.png +0 -0
  4. package/index.json +12 -0
  5. package/lib/client.js +734 -128
  6. package/locale/en.json +15 -0
  7. package/locale/zh.json +15 -0
  8. package/package.json +5 -7
  9. package/screenshots.json +6 -0
  10. package/docs/acceptance.md +0 -42
  11. package/docs/community-markets.md +0 -88
  12. package/docs/compatibility-017.md +0 -70
  13. package/docs/compatibility-101.md +0 -41
  14. package/docs/continuous-reading-020.md +0 -46
  15. package/docs/ebook-tests.md +0 -99
  16. package/docs/evidence/abc-result.json +0 -9
  17. package/docs/evidence/banner-100.png +0 -0
  18. package/docs/evidence/community-market-014-result.json +0 -170
  19. package/docs/evidence/compatibility-017-result.json +0 -65
  20. package/docs/evidence/continuous-reading-020-result.json +0 -72
  21. package/docs/evidence/formats-result.json +0 -12
  22. package/docs/evidence/live-ab.png +0 -0
  23. package/docs/evidence/live-collapsed.png +0 -0
  24. package/docs/evidence/live-disabled.png +0 -0
  25. package/docs/evidence/live-epub.png +0 -0
  26. package/docs/evidence/live-market.png +0 -0
  27. package/docs/evidence/live-resume.png +0 -0
  28. package/docs/evidence/live-unloaded.png +0 -0
  29. package/docs/evidence/long-result.json +0 -11
  30. package/docs/evidence/multi-region-014-result.json +0 -47
  31. package/docs/evidence/native-disclosure-013-result.json +0 -36
  32. package/docs/evidence/native-disclosures-013.png +0 -0
  33. package/docs/evidence/native-open-013.png +0 -0
  34. package/docs/evidence/native-settings-sample.md +0 -11
  35. package/docs/evidence/native-settings-types-015.png +0 -0
  36. package/docs/evidence/npm-market-014-result.json +0 -132
  37. package/docs/evidence/plugin-settings-details.png +0 -0
  38. package/docs/evidence/public-release-014-result.json +0 -51
  39. package/docs/evidence/public-release-015-result.json +0 -36
  40. package/docs/evidence/public-release-result.json +0 -48
  41. package/docs/evidence/reading-demo-100.png +0 -0
  42. package/docs/evidence/reading-two-expansions-110.gif +0 -0
  43. package/docs/evidence/reading-two-expansions-110.json +0 -89
  44. package/docs/evidence/samples-110-capture.json +0 -49
  45. package/docs/evidence/settings-011-result.json +0 -28
  46. package/docs/evidence/settings-011.png +0 -0
  47. package/docs/evidence/settings-100.png +0 -0
  48. package/docs/evidence/settings-110.png +0 -0
  49. package/docs/evidence/settings-chat-011.png +0 -0
  50. package/docs/evidence/type-append-012-result.json +0 -30
  51. package/docs/evidence/type-append-012.png +0 -0
  52. package/docs/evidence/type-settings-012.png +0 -0
  53. package/docs/evidence/unload-result.json +0 -7
  54. package/docs/host-adapter.md +0 -43
  55. package/docs/icon-metadata-021.md +0 -40
  56. package/docs/interaction-paths-020.md +0 -39
  57. package/docs/marketplace.md +0 -42
  58. package/docs/multi-region-update.md +0 -53
  59. package/docs/native-disclosure-update.md +0 -39
  60. package/docs/native-settings-update.md +0 -48
  61. package/docs/plugin-settings-update.md +0 -61
  62. package/docs/release.md +0 -151
  63. package/docs/settings-update.md +0 -49
  64. package/docs/type-append-update.md +0 -50
  65. package/pnpm-workspace.yaml +0 -5
  66. package/scripts/build.mjs +0 -70
  67. package/scripts/check-host-contracts.mjs +0 -247
  68. package/scripts/licenses/path-webpack.txt +0 -28
  69. package/scripts/make-readme-gif.mjs +0 -69
  70. package/scripts/test-browser-samples.mjs +0 -665
  71. package/scripts/test-candidate-books.mjs +0 -71
  72. package/scripts/test-ebook-corpus.mjs +0 -161
  73. package/src/bundled-books.js +0 -42
  74. package/src/chat-adapter.js +0 -278
  75. package/src/client.js +0 -61
  76. package/src/epub.js +0 -166
  77. package/src/novel-content.js +0 -28
  78. package/src/persistence.js +0 -271
  79. package/src/pg-notice.js +0 -19
  80. package/src/segments.js +0 -185
  81. package/src/settings.js +0 -243
  82. package/src/store.js +0 -429
  83. package/src/text-decoding.js +0 -28
  84. package/test/bundled-library.test.js +0 -526
  85. package/test/chat-adapter.test.js +0 -518
  86. package/test/client.test.js +0 -124
  87. package/test/ebooks.test.js +0 -192
  88. package/test/epub.test.js +0 -185
  89. package/test/helpers/host-primitives.js +0 -28
  90. package/test/helpers/memory-storage.js +0 -48
  91. package/test/host-contracts.test.js +0 -32
  92. package/test/import.test.js +0 -102
  93. package/test/persistence.test.js +0 -27
  94. package/test/pg-notice.test.js +0 -109
  95. package/test/release.test.js +0 -87
  96. package/test/segments.test.js +0 -182
  97. package/test/settings.test.js +0 -312
  98. package/test/store.test.js +0 -617
  99. package/test/text-decoding.test.js +0 -49
@@ -1,247 +0,0 @@
1
- #!/usr/bin/env node
2
- // Read-only, offline probe of an installed DSH build. No server or user profile.
3
- // Usage: node scripts/check-host-contracts.mjs /absolute/path/to/@deepseek-ai/dsh
4
- import assert from 'node:assert/strict'
5
- import { existsSync } from 'node:fs'
6
- import { readFile, readdir } from 'node:fs/promises'
7
- import { isAbsolute, join, dirname } from 'node:path'
8
- import { fileURLToPath } from 'node:url'
9
- import vm from 'node:vm'
10
- import { build } from 'esbuild'
11
- import { JSDOM, VirtualConsole } from 'jsdom'
12
- import { IDBFactory, IDBKeyRange } from 'fake-indexeddb'
13
-
14
- const project = fileURLToPath(new URL('../', import.meta.url))
15
- const host = process.argv[2] ?? process.env.HOST_ROOT
16
- const report = { hostVersion: null, checks: [], claims: null,
17
- claimsMeaning: 'Observed book progress after an untrusted click, not claimPassage invocation count.', limitations: [
18
- 'JSDOM, not a browser: no layout, animation, focus or trusted-user-event proof.',
19
- 'Private host exports are exposed only in memory; host boot/apply and full UI renderer are not started.',
20
- 'Identity ancestors and plugin-manager slot declaration are checked statically; small mounting/context facades are supplied by this probe.',
21
- 'Tool/Bash rows and the plugin-manager page are statically checked, not rendered; settings menus/modal are closed.',
22
- 'Plugin is built in memory from current src/client.js; lib/client.js freshness is not checked.',
23
- 'Only the supplied installation is tested; this is not proof for other or future versions.',
24
- ] }
25
- const check = (name, detail) => report.checks.push({ name, detail })
26
- const read = path => readFile(path, 'utf8')
27
- let dom
28
- try {
29
- assert.ok(host && isAbsolute(host), 'Pass an absolute DSH installation path (or HOST_ROOT).')
30
- report.hostVersion = JSON.parse(await read(join(host, 'package.json'))).version
31
- // Global installs nest the client packages under the dsh package, while a plain
32
- // `npm install @deepseek-ai/dsh` hoists them next to it. Accept both layouts.
33
- const siblingScope = dirname(host)
34
- const packageDir = name => {
35
- const nested = join(host, 'node_modules/@deepseek-ai', `dsh-${name}`)
36
- return existsSync(nested) ? nested : join(siblingScope, `dsh-${name}`)
37
- }
38
- const client = name => read(join(packageDir(name), 'lib/client.js'))
39
- const [chat, tool, conversation, manager] = await Promise.all([
40
- client('client-ui-chat'), client('client-ui-tool'), client('client-ui-conversation'), client('client-ui-plugin-manager'),
41
- ])
42
- for (const [source, markers] of [[chat, ['data-chat-node-key', 'data-chat-flow-kind']],
43
- [tool, ['data-chat-call-id', 'data-tool', 'data-variant', 'data-sample']], [conversation, ['data-conversation-session']]]) {
44
- for (const marker of markers) assert.ok(source.includes(`"${marker}"`), `Missing host DOM marker: ${marker}`)
45
- }
46
- const config = manager.match(/"plugins\.bundle\.config":\s*\{\s*kind:\s*"(\w+)",\s*scope:\s*"(\w+)"/)
47
- assert.ok(config, 'Missing plugins.bundle.config declaration')
48
- assert.equal(config[1], 'keyed')
49
- assert.match(manager, /renderSlot\("plugins\.bundle\.config",\s*\{\s*view:\s*"page"\s*\},\s*\{\s*entryKey:\s*pkg\.name/)
50
- check('static host markers and bundle-config seat', 'chat/tool/conversation markers; keyed config rendered by package name with view=page')
51
-
52
- // Built-in modules live in the shipped web shell, not separate npm packages.
53
- const assets = join(packageDir('web-frontend'), 'dist/assets')
54
- const candidates = (await readdir(assets)).filter(name => /^index-.*\.js$/.test(name))
55
- let entry, frontend, registry
56
- for (const candidate of candidates) {
57
- const source = await read(join(assets, candidate))
58
- const match = source.match(/function\s+([\w$]+)\(\)\s*\{\s*return\s*\{\s*react:/)
59
- if (match && source.includes('"@deepseek-ai/dsh-client-ui-primitives"')) {
60
- entry = join(assets, candidate); frontend = source; registry = match[1]; break
61
- }
62
- }
63
- assert.ok(registry, 'Cannot locate the shipped web static-module registry; probe needs an update')
64
- // Disable only the final application boot block, never component/module code.
65
- const boot = /try\s*\{\s*const\s+[\w$]+\s*=\s*document\.getElementById\("root"\)/
66
- assert.ok(boot.test(frontend), 'Cannot isolate web application boot; refusing to execute shell')
67
- frontend = frontend.replace(boot, match => `if (false) ${match}`)
68
- const errors = []
69
- const virtualConsole = new VirtualConsole()
70
- virtualConsole.on('jsdomError', error => errors.push(error.message))
71
- dom = new JSDOM('<!doctype html><html><head></head><body></body></html>', {
72
- url: 'http://host-contract.invalid/', runScripts: 'outside-only', pretendToBeVisual: true, virtualConsole,
73
- })
74
- Object.assign(dom.window, {
75
- TextEncoder, TextDecoder, URL, Blob, setImmediate, clearImmediate,
76
- indexedDB: new IDBFactory(), IDBKeyRange,
77
- fetch: () => { throw new Error('Network is forbidden in host-contract probe') },
78
- console: { ...console, error: error => { if (error?.message !== 'web app: missing #root') errors.push(String(error)) } },
79
- })
80
- const bundled = await build({ stdin: {
81
- contents: `${frontend}\nglobalThis.__hostContracts = ${registry}();`, resolveDir: dirname(entry), sourcefile: entry,
82
- }, bundle: true, write: false, format: 'iife', logLevel: 'silent' })
83
- vm.runInContext(bundled.outputFiles[0].text, dom.getInternalVMContext(), { filename: entry, timeout: 15000 })
84
- const modules = dom.window.__hostContracts
85
- const React = modules.react, h = React.createElement
86
- const primitives = modules['@deepseek-ai/dsh-client-ui-primitives']
87
- for (const name of ['DisclosureRow', 'TextShimmer', 'Switch', 'Button', 'Input', 'Menu', 'Modal', 'IconChevronDownOutlineRegular']) {
88
- assert.ok(primitives[name], `Missing real primitive ${name}`)
89
- }
90
- const core = new modules['@deepseek-ai/dsh-client-ui-slots'].SlotCore()
91
- const disposers = [], waiting = new Map()
92
- const register = (options, component) => {
93
- const off = core.register(options, component)
94
- disposers.push(off)
95
- for (const [name, callback] of waiting) if (core.spec(name)) { waiting.delete(name); callback() }
96
- return off
97
- }
98
- const ctx = {
99
- slots: { register, registerFactory: (...args) => { const off = core.registerFactory(...args); disposers.push(off); return off },
100
- inject: (name, callback) => core.spec(name) ? callback() : waiting.set(name, callback) },
101
- effect: callback => { const off = callback(); if (typeof off === 'function') disposers.push(off) },
102
- locale: { register: () => () => {}, bind: () => key => key },
103
- }
104
- // These two outer seats belong to much larger application trees. Their declarations
105
- // are checked in the original builds; all subsequent registrations use real SlotCore.
106
- assert.match(chat, /"conversation\.chat\.node":\s*\{\s*kind:\s*"keyed",\s*scope:\s*"session"/)
107
- register({ name: 'root', children: {
108
- 'conversation.chat.node': { kind: 'keyed', scope: 'session' },
109
- 'plugins.bundle.config': { kind: config[1], scope: config[2] },
110
- } }, () => null)
111
- const capture = (source, filename, expose = '') => {
112
- let definition
113
- dom.window.__ModuleLoader__ = { load: value => { definition = value } }
114
- if (expose) {
115
- assert.equal(source.split('return module.exports;').length, 2, 'Unknown host factory return shape')
116
- source = source.replace('return module.exports;', `module.exports.__probe = { ${expose} }; return module.exports;`)
117
- }
118
- vm.runInContext(source, dom.getInternalVMContext(), { filename, timeout: 10000 })
119
- assert.ok(definition?.factory, `No module factory captured from ${filename}`)
120
- const require = name => {
121
- assert.ok(modules[name], `Unexpected host import: ${name}`)
122
- return modules[name]
123
- }
124
- require.asset = path => `http://host-contract.invalid/assets/${path}` // CSS only; never fetched
125
- return definition.factory(require)
126
- }
127
- const hostChat = capture(chat, 'host-chat-client.js', 'registerChatNodeRenderers, ReasoningRow')
128
- hostChat.__probe.registerChatNodeRenderers(ctx, {}, {})
129
- assert.equal(core.spec('conversation.chat.reasoning.body')?.kind, 'single')
130
- assert.ok(core.factory('conversation.chat.reasoning.content'))
131
- const originalBody = core.entriesOfSlot('conversation.chat.reasoning.body')[0]
132
- const plugin = await build({ entryPoints: [join(project, 'src/client.js')], bundle: true, write: false,
133
- loader: { '.epub': 'base64', '.txt': 'base64', '.md': 'text' }, format: 'iife', logLevel: 'silent' })
134
- capture(plugin.outputFiles[0].text, 'novel-client-source.js').apply(ctx)
135
- const body = core.entriesOfSlot('conversation.chat.reasoning.body')[0]
136
- assert.notEqual(body, originalBody, 'Plugin body must shadow, not replace/delete, host body')
137
- assert.ok(core.entries('conversation.chat.reasoning.body').includes(originalBody))
138
- const settings = core.entriesOfSlot('plugins.bundle.config').find(entry => entry.options.key === '@gongfpp/dsh-novel-fish')
139
- assert.ok(settings)
140
- check('real SlotCore registrations', 'host registerChatNodeRenderers + plugin apply; body priority shadowing, content Factory and package-keyed settings')
141
-
142
- const injected = settings.inject()
143
- const state = injected.hooks.novelState
144
- await new Promise((resolve, reject) => {
145
- const timer = setTimeout(() => { off(); reject(new Error('IndexedDB hydration timed out')) }, 3000)
146
- const ready = () => { if (state.getSnapshot().hydrated) { clearTimeout(timer); off(); resolve() } }
147
- const off = state.subscribe(ready); ready()
148
- })
149
- assert.equal(state.getSnapshot().error, null)
150
- await injected.onSetOption('mainTitle', 'Contract title')
151
- await injected.onSetOption('extraTitle', 'Contract summary')
152
- await injected.onSetOption('enabled', false)
153
- const book = await injected.onImportFile({ name: 'contract.txt', arrayBuffer: async () => new TextEncoder().encode('Contract novel passage.').buffer })
154
- await injected.onSelectBook(book.id)
155
- const hooks = sources => Object.fromEntries(Object.entries(sources).map(([key, source]) => [
156
- modules['@deepseek-ai/dsh-client-ui-slots'].standardHookPropName(key),
157
- select => select(React.useSyncExternalStore(source.subscribe, source.getSnapshot)),
158
- ]))
159
- const t = key => key
160
- const slotCalls = []
161
- const renderFactorySlot = (name, props) => {
162
- slotCalls.push({ name, ...props })
163
- const factory = core.factory(name)
164
- assert.ok(factory, `Unknown Factory ${name}`)
165
- return h(factory.component, { ...props, t })
166
- }
167
- function ReasoningProbe() {
168
- const [expanded, setExpanded] = React.useState(false)
169
- return h(hostChat.__probe.ReasoningRow, {
170
- text: 'Native summary\n\nNative reasoning', running: true, t,
171
- usePresentation: select => select({ settledReasoningPreview: true }),
172
- useDisclosure: () => ({ expanded, toggle: () => setExpanded(value => !value) }),
173
- renderSlot: (name, props) => {
174
- assert.equal(name, 'conversation.chat.reasoning.body')
175
- const values = body.inject()
176
- return h(body.component, { ...props, sessionId: 'probe-session', ...hooks(values.hooks), renderFactorySlot, t })
177
- },
178
- })
179
- }
180
- const mount = dom.window.document.createElement('main')
181
- dom.window.document.body.append(mount)
182
- const root = modules['react-dom/client'].createRoot(mount)
183
- const flush = callback => modules['react-dom'].flushSync(callback)
184
- const render = () => flush(() => root.render(h(React.Fragment, null,
185
- h('div', { 'data-conversation-session': 'probe-session' },
186
- h('div', { 'data-chat-flow-kind': 'assistant-step', 'data-chat-node-key': 'probe-node' }, h(ReasoningProbe))),
187
- h(settings.component, { ...injected, ...hooks(injected.hooks), t, view: 'page' }),
188
- )))
189
- render()
190
- await new Promise(resolve => setTimeout(resolve, 25))
191
- const header = mount.querySelector('[data-disclosure-row]')
192
- assert.ok(header)
193
- assert.equal(header.getAttribute('role'), 'button')
194
- assert.equal(header.getAttribute('aria-expanded'), 'false')
195
- const nativeNodes = [...header.querySelectorAll('*')]
196
- const glyphs = [...header.querySelectorAll('svg')]
197
- const nativeGlyphs = glyphs.map(node => node.outerHTML)
198
- assert.ok(glyphs.length > 0)
199
- await injected.onSetOption('enabled', true)
200
- await new Promise(resolve => setTimeout(resolve, 25))
201
- assert.deepEqual([...header.querySelectorAll('*')], nativeNodes, 'Adapter must preserve native elements')
202
- assert.deepEqual(glyphs.map(node => node.outerHTML), nativeGlyphs, 'Adapter must not change native SVGs')
203
- assert.ok(header.textContent.includes('Contract title'))
204
- assert.ok(header.textContent.includes('Contract summary'))
205
- assert.deepEqual([...header.querySelectorAll('[data-shimmer-text]')].map(el => el.getAttribute('data-shimmer-text')), ['Contract title', 'Contract summary'])
206
- assert.equal(mount.querySelectorAll('[data-novel-append]').length, 0)
207
- check('real ReasoningRow / DisclosureRow / TextShimmer', 'plugin changes both native text and shimmer layers on actual shipped components; native SVGs remain')
208
- // This event is intentionally untrusted: it opens React's host row but must never claim a passage.
209
- flush(() => header.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true })))
210
- await new Promise(resolve => setTimeout(resolve, 25))
211
- assert.equal(header.getAttribute('aria-expanded'), 'true')
212
- assert.ok(slotCalls.some(call => call.name === 'conversation.chat.reasoning.content' && call.text === 'Native summary\n\nNative reasoning' && call.running === true))
213
- assert.ok(mount.querySelector('[data-novel-original]').textContent.includes('Native reasoning'))
214
- report.claims = state.getSnapshot().books.find(item => item.id === book.id).progress
215
- assert.equal(report.claims, 0, 'Untrusted DOM click must not advance book progress')
216
- check('untrusted-event guard', 'actual host click expands the row but imported in-memory book progress stays at zero; no trusted input is simulated')
217
- assert.ok(mount.querySelector('[data-novel-settings] button'))
218
- assert.ok(mount.querySelector('[data-novel-settings] input[type="file"]'))
219
- check('real body Factory props and settings primitives', 'host row passes text/running; plugin calls actual MarkdownText Factory; settings mounts with real controls and memory IndexedDB')
220
- await injected.onSetOption('enabled', false)
221
- await new Promise(resolve => setTimeout(resolve, 25))
222
- assert.ok(header.textContent.includes('message.think'), 'Disabling must restore native title')
223
- assert.equal(mount.querySelector('[data-novel-target]'), null)
224
- check('restore on disable', 'native title restored and adapter target marker removed')
225
- // The adapter keeps the native row and only rewrites its text, so it depends on the
226
- // shipped title layers, disclosure row and folding anchors staying put.
227
- const anchors = {
228
- chat: { source: chat, markers: ['data-chat-flow-key', 'data-turn-process-member', 'data-turn-process-hidden', 'data-shimmer-decoration'] },
229
- conversation: { source: conversation, markers: ['data-conversation-session'] },
230
- shell: { source: frontend, markers: ['data-shimmer-text', 'data-disclosure-row'] },
231
- }
232
- for (const [name, { source, markers }] of Object.entries(anchors)) {
233
- for (const marker of markers) assert.ok(source.includes(`"${marker}"`), `Missing ${name} adapter anchor: ${marker}`)
234
- }
235
- check('adapter anchors for title layers and fold state', 'shimmer text/decoration, disclosure row, session identity and turn-process fold markers still ship; ambient DOM rescan has a contract to rescan')
236
- flush(() => root.unmount())
237
- for (const dispose of disposers.reverse()) dispose()
238
- assert.deepEqual(errors, [], 'Unexpected host/JSDOM runtime errors')
239
- report.ok = true
240
- } catch (error) {
241
- report.ok = false
242
- report.error = error.stack ?? String(error)
243
- process.exitCode = 1
244
- } finally {
245
- dom?.window.close()
246
- console.log(JSON.stringify(report, null, 2))
247
- }
@@ -1,28 +0,0 @@
1
- path-webpack 0.0.3
2
- Author: fchasen@gmail.com
3
- Published package license: MIT
4
- Repository: https://github.com/fchasen/path-webpack
5
-
6
- The package README identifies its source as Node.js v7.0.0 lib/path.js.
7
- Source: https://github.com/nodejs/node/blob/v7.0.0/lib/path.js
8
- License: https://github.com/nodejs/node/blob/v7.0.0/LICENSE
9
-
10
- Copyright Node.js contributors. All rights reserved.
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy
13
- of this software and associated documentation files (the "Software"), to
14
- deal in the Software without restriction, including without limitation the
15
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16
- sell copies of the Software, and to permit persons to whom the Software is
17
- furnished to do so, subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in
20
- all copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
- IN THE SOFTWARE.
@@ -1,69 +0,0 @@
1
- // Convert verified native window captures, not a simulated page, into a paced GIF.
2
- // Usage: node scripts/make-readme-gif.mjs /path/to/native-captures
3
- // Requires ffmpeg on PATH. Raw captures stay outside the published evidence.
4
- import { createHash } from 'node:crypto';
5
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
6
- import { resolve, relative } from 'node:path';
7
- import { spawnSync } from 'node:child_process';
8
-
9
- const captures = process.argv[2];
10
- if (!captures) throw new Error('Pass the directory containing native window captures.');
11
- const root = resolve(import.meta.dirname, '..');
12
- const work = resolve(root, 'dist/readme-gif');
13
- const output = resolve(root, 'docs/evidence/reading-two-expansions-110.gif');
14
- const frames = [
15
- [41, 2, 'Both thoughts collapsed'],
16
- [43, 1.2, 'First thought expanded; original reasoning precedes novel'],
17
- [45, 0.7, 'Scroll within the actual conversation'],
18
- [47, 0.5, 'Adjust viewport without altering content'],
19
- [49, 5, 'First thought and first novel passage readable'],
20
- [51, 1.5, 'First thought collapsed'],
21
- [53, 2, 'Second distinct thought expanded; next novel passage'],
22
- [55, 5, 'Scroll to read the second passage'],
23
- [59, 2, 'Second thought collapsed'],
24
- ];
25
- const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
26
- await mkdir(work, { recursive: true });
27
- const provenance = [];
28
- const entries = [];
29
- for (const [id, seconds, action] of frames) {
30
- const file = resolve(captures, `${id}-root_result_content_0.png`);
31
- const bytes = await readFile(file);
32
- if (bytes.toString('hex', 0, 8) !== '89504e470d0a1a0a' ||
33
- bytes.readUInt32BE(16) !== 1567 || bytes.readUInt32BE(20) !== 983) {
34
- throw new Error(`Unexpected native capture dimensions: ${id}`);
35
- }
36
- const escape = value => value.replaceAll("'", "'\\''");
37
- entries.push(`file '${escape(file)}'\nduration ${seconds}`);
38
- provenance.push({ capture: id, sha256: sha256(bytes), seconds, action });
39
- }
40
- const last = resolve(captures, `${frames.at(-1)[0]}-root_result_content_0.png`);
41
- entries.push(`file '${last.replaceAll("'", "'\\''")}'`);
42
- const list = resolve(work, 'frames.ffconcat');
43
- await writeFile(list, `ffconcat version 1.0\n${entries.join('\n')}\n`);
44
- // Opaque removal of unrelated workspace/session names, quota, account and avatar.
45
- // The logo, navigation, current project/session, conversation and composer remain.
46
- const filter = '[0:v]drawbox=x=0:y=541:w=298:h=442:color=0xF8F9FA:t=fill,' +
47
- 'crop=1567:856:0:94,split[a][b];[a]palettegen=stats_mode=full[p];' +
48
- '[b][p]paletteuse=dither=none';
49
- const result = spawnSync('ffmpeg', ['-hide_banner', '-loglevel', 'error', '-y',
50
- '-f', 'concat', '-safe', '0', '-i', list, '-filter_complex', filter,
51
- '-fps_mode', 'vfr', '-loop', '0', output], { encoding: 'utf8' });
52
- if (result.status !== 0) throw new Error(result.stderr || 'ffmpeg failed');
53
- const gif = await readFile(output);
54
- const bundle = await readFile(resolve(root, 'lib/client.js'));
55
- const record = {
56
- capturedOn: '2026-11-07', host: 'DSH Web 0.2.2-alpha.2',
57
- source: 'Actual running DSH GUI, native Cua window captures; not a mock Host.',
58
- method: 'Paced native before/after window frames; not continuous desktop video. No interpolated or fabricated UI frames.',
59
- interaction: 'Expand first thought, scroll, collapse; expand a different thought, scroll, collapse. No model messages sent.',
60
- book: 'Existing user-imported AQ TXT, 98 segments, intentionally preserved by migration. New bundled AQ MD is independently tested.',
61
- crop: { x: 0, y: 94, width: 1567, height: 856 },
62
- redaction: { x: 0, y: 541, width: 298, height: 442, scope: 'Original capture pixels; opaque mask over unrelated sidebar sessions, quota and account.' },
63
- unchanged: 'No rewriting of the reasoning, novel, plugin controls, logo or current project/session.',
64
- frames: provenance,
65
- output: { file: relative(root, output), bytes: gif.length, sha256: sha256(gif), width: 1567, height: 856 },
66
- testedBundle: { bytes: bundle.length, sha256: sha256(bundle) },
67
- };
68
- await writeFile(resolve(root, 'docs/evidence/reading-two-expansions-110.json'), `${JSON.stringify(record, null, 2)}\n`);
69
- console.log(JSON.stringify(record, null, 2));