dsh-deepseek-webchat 0.0.0-stage → 0.4.7

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 CHANGED
@@ -1,6 +1,73 @@
1
1
  {
2
2
  "name": "dsh-deepseek-webchat",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.7",
4
+ "description": "Embeds the official chat.deepseek.com web app in a DSH sidebar tab through the desktop shell's native browser guest, binds one DeepSeek conversation per DSH Session, and sends selected DSH context into the DeepSeek composer as a blockquote.",
5
+ "keywords": [
6
+ "dsh",
7
+ "deepseek-harness",
8
+ "deepseek",
9
+ "webchat",
10
+ "sidebar",
11
+ "harness-plugin",
12
+ "plugin"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/Ckarefulon/dsh-deepseek-webchat.git"
17
+ },
18
+ "homepage": "https://github.com/Ckarefulon/dsh-deepseek-webchat#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/Ckarefulon/dsh-deepseek-webchat/issues"
21
+ },
22
+ "author": "Ckarefulon",
23
+ "license": "MIT",
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "type": "module",
29
+ "engines": {
30
+ "node": ">=22",
31
+ "dsh": ">=0.2.0-rc.1"
32
+ },
33
+ "main": "lib/index.js",
34
+ "exports": {
35
+ ".": {
36
+ "default": "./lib/index.js"
37
+ },
38
+ "./client": {
39
+ "default": "./lib/client.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "dsh": {
44
+ "bundle": {
45
+ "patch": "./cordis.patch.yml"
46
+ },
47
+ "client": {
48
+ "platform": "web",
49
+ "inject": [
50
+ "@deepseek-ai/dsh-client-ui-conversation",
51
+ "@deepseek-ai/dsh-client-ui-sidebar-right"
52
+ ]
53
+ }
54
+ },
55
+ "files": [
56
+ "lib/index.js",
57
+ "lib/client.js",
58
+ "src/index.js",
59
+ "src/client/index.js",
60
+ "scripts/build.mjs",
61
+ "scripts/check-client-bundle.mjs",
62
+ "scripts/check-profile-patch.mjs",
63
+ "cordis.patch.yml",
64
+ "README.md",
65
+ "LICENSE"
66
+ ],
67
+ "scripts": {
68
+ "build": "node scripts/build.mjs",
69
+ "test": "node --test",
70
+ "check:bundle": "node scripts/check-client-bundle.mjs .",
71
+ "check:patch": "node scripts/check-profile-patch.mjs"
72
+ }
73
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copy `src/` to `lib/`, byte for byte.
3
+ *
4
+ * The plugin is plain JavaScript ESM, so there is nothing to transpile — but a
5
+ * git-hosted DSH plugin must not need a build step on install, and a
6
+ * `prepare` script is exactly the thing pnpm blocks behind `allowBuilds`. So
7
+ * `lib/` is committed to the repository, and this script exists only so a
8
+ * source edit can be republished in one command:
9
+ *
10
+ * npm run build && git add -A && git commit -m "..." && git push
11
+ *
12
+ * `npm test` checks that the committed `lib/` still matches `src/`, which is
13
+ * what keeps the two from drifting apart.
14
+ *
15
+ * ## Why the output layout is flat
16
+ *
17
+ * `src/client/index.js` becomes `lib/client.js`, not `lib/client/index.js`.
18
+ * This is not cosmetic. DSH resolves a package's browser half by joining the
19
+ * manifest's `exports["./client"]` onto the package root and reading it as an
20
+ * **exact file path** — there is no extension or directory-index fallback
21
+ * (`clientExportOf` in @deepseek-ai/dsh-client-modules). A manifest pointing at
22
+ * `./lib/client.js` while the build writes `./lib/client/index.js` makes the
23
+ * client module registry throw `MissingClientBundleError` during startup, which
24
+ * aborts the whole Host boot: DSH does not open at all.
25
+ *
26
+ * Every package DSH ships uses the flat form (`./lib/client.js`), so this
27
+ * matches the ecosystem as well as the loader.
28
+ */
29
+
30
+ import { cpSync, existsSync, mkdirSync, rmSync, statSync } from 'node:fs'
31
+ import { dirname, join } from 'node:path'
32
+ import { fileURLToPath } from 'node:url'
33
+
34
+ const root = dirname(dirname(fileURLToPath(import.meta.url)))
35
+ const source = join(root, 'src')
36
+ const target = join(root, 'lib')
37
+
38
+ /**
39
+ * Source file → published file, relative to their trees.
40
+ *
41
+ * The mapping is explicit rather than a directory copy precisely because the
42
+ * two trees have different shapes; a recursive copy would silently reintroduce
43
+ * `lib/client/index.js`.
44
+ */
45
+ export const OUTPUTS = [
46
+ { from: 'index.js', to: 'index.js' },
47
+ { from: join('client', 'index.js'), to: 'client.js' },
48
+ ]
49
+
50
+ if (!existsSync(source)) {
51
+ console.error(`build: no source directory at ${source}`)
52
+ process.exit(1)
53
+ }
54
+
55
+ for (const { from } of OUTPUTS) {
56
+ const file = join(source, from)
57
+ if (statSync(file, { throwIfNoEntry: false })?.isFile() !== true) {
58
+ console.error(`build: missing source file ${file}`)
59
+ process.exit(1)
60
+ }
61
+ }
62
+
63
+ // Replace rather than merge, so a file deleted from src/ cannot linger in lib/.
64
+ rmSync(target, { recursive: true, force: true })
65
+ mkdirSync(target, { recursive: true })
66
+ for (const { from, to } of OUTPUTS) {
67
+ cpSync(join(source, from), join(target, to))
68
+ }
69
+
70
+ console.log(`build: copied src/ -> lib/ (${root})`)
71
+ for (const { from, to } of OUTPUTS) console.log(` src/${from} -> lib/${to}`)
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Prove that @deepseek-ai/dsh-client-modules can compose one package's browser
3
+ * half, **without restarting DSH to find out**.
4
+ *
5
+ * `resolveMeta()` joins `exports["./client"]` onto the package root and calls
6
+ * `statSync` on the result — with no extension completion and no directory-index
7
+ * fallback. A missing file throws `MissingClientBundleError`, and because
8
+ * `modules` is a required plugin the whole Host boot aborts: DSH shows
9
+ * "The application could not start or stopped unexpectedly" and never opens.
10
+ *
11
+ * This replicates that resolution verbatim, plus the neighbouring manifest
12
+ * checks, so the failure is reproducible before a restart rather than after one.
13
+ *
14
+ * Usage:
15
+ * node scripts/check-client-bundle.mjs <packageRoot>
16
+ * node scripts/check-client-bundle.mjs . # this repo
17
+ *
18
+ * Exit code 0 when client-modules would compose the package, 1 when it would
19
+ * abort startup.
20
+ */
21
+
22
+ import { existsSync, readFileSync, statSync } from 'node:fs'
23
+ import { dirname, join, resolve } from 'node:path'
24
+
25
+ const arg = process.argv[2]
26
+ if (arg === undefined) {
27
+ console.error('usage: node scripts/check-client-bundle.mjs <packageRoot>')
28
+ process.exit(2)
29
+ }
30
+
31
+ const pkgRoot = resolve(arg)
32
+ const pkgPath = join(pkgRoot, 'package.json')
33
+
34
+ let pkg
35
+ try {
36
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
37
+ } catch (error) {
38
+ console.log(` cannot read ${pkgPath}: ${error.message}`)
39
+ process.exit(1)
40
+ }
41
+
42
+ // --- parseDshClient(): a package without dsh.client is not a graph row at all.
43
+ const decl = pkg.dsh?.client
44
+ if (decl === undefined) {
45
+ console.log(` ${pkg.name}: no dsh.client declaration, so client-modules skips it`)
46
+ process.exit(0)
47
+ }
48
+ if (typeof decl.platform !== 'string') {
49
+ console.log(' FAIL: dsh.client.platform must be a string')
50
+ process.exit(1)
51
+ }
52
+ if (decl.platform !== 'web') {
53
+ console.log(` ${pkg.name}: platform is "${decl.platform}", not "web"; client-modules skips it`)
54
+ process.exit(0)
55
+ }
56
+
57
+ // --- clientExportOf(): the path is read verbatim; no defaulting, no guessing.
58
+ const client = pkg.exports?.['./client']
59
+ if (client === undefined) {
60
+ console.log(' FAIL: declares dsh.client but exports no "./client"')
61
+ process.exit(1)
62
+ }
63
+ const rel = typeof client === 'string' ? client : client.default
64
+ if (typeof rel !== 'string') {
65
+ console.log(' FAIL: exports["./client"] must name a file')
66
+ process.exit(1)
67
+ }
68
+
69
+ // --- the exact line that aborts the boot: join, then statSync, nothing else.
70
+ const clientPath = join(dirname(pkgPath), rel)
71
+ const st = statSync(clientPath, { throwIfNoEntry: false })
72
+ if (st?.isFile() !== true) {
73
+ console.log(' RESULT: MissingClientBundleError — DSH would abort startup')
74
+ console.log(' declared:', rel)
75
+ console.log(' resolved:', clientPath)
76
+ console.log(' This is the whole-file path; extension completion and directory')
77
+ console.log(' indexes are NOT tried. Ship the exact file the manifest names.')
78
+ process.exit(1)
79
+ }
80
+
81
+ const bundle = readFileSync(clientPath, 'utf8')
82
+ const patch = pkg.dsh?.bundle?.patch
83
+ const patchOk = typeof patch !== 'string' || existsSync(join(pkgRoot, patch))
84
+
85
+ // The loader passes `require` only — no `module` — so the factory must declare
86
+ // its own, or the browser half dies with "module is not defined" at load time.
87
+ // The loader passes `require` only — no `module` — so a bundle using the classic
88
+ // shape must declare its own, or it dies with "module is not defined" at load
89
+ // time. Only checked when the bundle uses `module.exports` at all: one written
90
+ // as a bare IIFE returning its value needs no declaration, and several
91
+ // third-party plugins are exactly that. Flagging them would be a false alarm
92
+ // about someone else's working package.
93
+ const usesModuleExports = /module\.exports/.test(bundle)
94
+ const declaresModule = /(?:const|let|var)\s+module\s*=\s*\{\s*exports\s*:\s*\{\s*\}\s*\}/.test(bundle)
95
+ const returnsExports = /return module\.exports/.test(bundle)
96
+ const registersId = bundle.includes(`id: '${pkg.name}'`) || bundle.includes(`id: "${pkg.name}"`)
97
+
98
+ console.log(' packageName :', pkg.name)
99
+ console.log(' version :', pkg.version)
100
+ console.log(' clientPath :', clientPath)
101
+ console.log(' size :', `${st.size} bytes`)
102
+ console.log(' dsh.client :', JSON.stringify({ platform: decl.platform, inject: decl.inject ?? [] }))
103
+ console.log(' bundle patch :', patch, patchOk ? '(present)' : '(MISSING)')
104
+ console.log(' registers id :', registersId)
105
+ console.log(' declares module:', declaresModule)
106
+ console.log(' returns exports:', returnsExports)
107
+ console.log('')
108
+
109
+ const problems = []
110
+ if (!patchOk) problems.push('dsh.bundle.patch points at a file that does not exist')
111
+ if (usesModuleExports && !declaresModule) {
112
+ problems.push('bundle uses module.exports but never declares `var module = { exports: {} }`')
113
+ }
114
+ if (usesModuleExports && !returnsExports) problems.push('bundle does not `return module.exports`')
115
+ if (!registersId) problems.push(`bundle does not register id ${pkg.name}`)
116
+
117
+ if (problems.length > 0) {
118
+ console.log(' RESULT: composes, but the browser half would misbehave:')
119
+ for (const problem of problems) console.log(' -', problem)
120
+ process.exit(1)
121
+ }
122
+
123
+ console.log(' RESULT: client-modules composes this package without MissingClientBundleError')
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Validate a DSH profile patch file the way the loader must: YAML with the
3
+ * `!!js` custom tag treated as an opaque scalar (DSH evaluates those itself,
4
+ * after parsing). Every entry id is printed, so a restored patch can be
5
+ * reviewed before it is trusted — which is exactly what you need after DSH's
6
+ * crash dialog has replaced a full patch with a minimal one.
7
+ *
8
+ * Usage: node scripts/check-profile-patch.mjs <patch.yml>
9
+ *
10
+ * js-yaml is not a dependency of this repo. It is resolved from the DSH
11
+ * installation instead (see resolveYaml), so this stays a dev-only tool with no
12
+ * package.json footprint. Override with DSH_JS_YAML=/path/to/js-yaml if needed.
13
+ */
14
+
15
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
16
+ import { createRequire } from 'node:module'
17
+ import { homedir } from 'node:os'
18
+ import { join, resolve } from 'node:path'
19
+ import { pathToFileURL } from 'node:url'
20
+
21
+ const require = createRequire(import.meta.url)
22
+
23
+ /**
24
+ * Find a js-yaml to parse with, preferring the caller's own resolution and
25
+ * falling back to whatever the DSH profiles already have installed.
26
+ * @returns the module namespace, or null when nothing usable was found.
27
+ */
28
+ async function resolveYaml() {
29
+ const explicit = process.env.DSH_JS_YAML
30
+ if (explicit !== undefined) {
31
+ const path = join(resolve(explicit), 'index.js')
32
+ return existsSync(path) ? import(pathToFileURL(path).href) : null
33
+ }
34
+ // 1. Ordinary resolution: works when run from a directory with node_modules.
35
+ try {
36
+ return await import('js-yaml')
37
+ } catch {}
38
+ // 2. Any DSH profile's installed copy.
39
+ const profiles = join(homedir(), '.dsh', 'profiles')
40
+ if (existsSync(profiles)) {
41
+ for (const name of readdirSync(profiles)) {
42
+ const candidate = join(profiles, name, 'node_modules', 'js-yaml')
43
+ if (!existsSync(candidate)) continue
44
+ try {
45
+ return await import(pathToFileURL(join(candidate, 'index.js')).href)
46
+ } catch {}
47
+ }
48
+ }
49
+ return null
50
+ }
51
+
52
+ const file = process.argv[2]
53
+ if (file === undefined) {
54
+ console.error('usage: node scripts/check-profile-patch.mjs <patch.yml>')
55
+ process.exit(2)
56
+ }
57
+
58
+ const yaml = await resolveYaml()
59
+ if (yaml === null) {
60
+ console.log(' no js-yaml found. Install one, or set DSH_JS_YAML to a js-yaml directory.')
61
+ console.log(' (a DSH profile normally has one at ~/.dsh/profiles/<name>/node_modules/js-yaml)')
62
+ process.exit(2)
63
+ }
64
+
65
+ // `!!js` expressions are evaluated by DSH after parsing; here they stay opaque.
66
+ const jsTag = new yaml.Type('tag:yaml.org,2002:js', {
67
+ kind: 'scalar',
68
+ construct: (data) => ({ __js: data }),
69
+ })
70
+ const schema = yaml.DEFAULT_SCHEMA.extend([jsTag])
71
+
72
+ const path = resolve(file)
73
+ let text
74
+ try {
75
+ text = readFileSync(path, 'utf8')
76
+ } catch (error) {
77
+ console.log(` cannot read ${path}: ${error.message}`)
78
+ process.exit(1)
79
+ }
80
+
81
+ let doc
82
+ try {
83
+ doc = yaml.load(text, { schema })
84
+ } catch (error) {
85
+ console.log(' PARSE FAILED:', error.message)
86
+ process.exit(1)
87
+ }
88
+
89
+ if (!Array.isArray(doc)) {
90
+ console.log(' NOT A TOP-LEVEL ARRAY — DSH expects a list of patch entries')
91
+ process.exit(1)
92
+ }
93
+
94
+ console.log(` ${path}`)
95
+ console.log(` ${text.length} bytes, ${text.split('\n').length} lines`)
96
+ console.log(` parsed ok: ${doc.length} top-level entries`)
97
+
98
+ let inserts = 0
99
+ let malformed = 0
100
+ for (const [index, entry] of doc.entries()) {
101
+ if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) {
102
+ console.log(` [${index}] !! not an object: ${JSON.stringify(entry)}`)
103
+ malformed += 1
104
+ continue
105
+ }
106
+ const kind = entry.insert !== undefined
107
+ ? 'insert'
108
+ : entry.disabled !== undefined
109
+ ? 'disable'
110
+ : entry.remove !== undefined
111
+ ? 'remove'
112
+ : 'override'
113
+ const label = entry.id ?? entry.name ?? ''
114
+ const count = Array.isArray(entry.insert) ? entry.insert.length : 0
115
+ if (kind === 'insert') inserts += count
116
+ console.log(` [${index}] ${kind.padEnd(9)} ${String(label).padEnd(34)}${count ? ` (+${count} rows)` : ''}`)
117
+ }
118
+
119
+ console.log(`\n inserted rows total: ${inserts}`)
120
+ if (malformed > 0) {
121
+ console.log(` ${malformed} malformed entr${malformed === 1 ? 'y' : 'ies'}`)
122
+ process.exit(1)
123
+ }
124
+ console.log(' structure: OK')