dsh-plugin-toolkit 0.20.24 → 0.20.26

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/CHANGELOG.md CHANGED
@@ -1,4 +1,41 @@
1
- ## 0.20.24
1
+ ## 0.20.26
2
+
3
+ - **The published tarball ships `scripts/preview.mjs`, so the command the
4
+ README tells a reader to run exists after install.** `files` listed the
5
+ benchmark and compatibility scripts but not the panel preview, so
6
+ `node scripts/preview.mjs /tmp/panel.html` worked only in a checkout and
7
+ failed with `MODULE_NOT_FOUND` in an installed package. The script is now in
8
+ the published file list. A test requires `npm pack --dry-run --json` to list
9
+ it and installs the packed tarball into a temp prefix, where the installed
10
+ copy must be byte-identical to the repository file.
11
+
12
+ - **Every `node scripts/<name>.mjs` command a shipped README tells a reader to
13
+ run is now gated against the tarball.** The 0.20.12 `files` list shipped the
14
+ benchmark and compatibility scripts but not `scripts/preview.mjs`, and only
15
+ that one path had a dedicated test. A new test extracts every such command
16
+ from `README.md` and `README.zh.md`, compares the paths with
17
+ `npm pack --dry-run --json`, and fails with the omitted path. The 0.20.12 file
18
+ list is kept as a control, so the gate is shown to fail on the bug it closes.
19
+
20
+ ## 0.20.25
21
+
22
+ - **`audit` reads a profile `package.json` saved with a UTF-8 BOM instead of
23
+ calling its bundles unlisted.** The profile reader passed the BOM straight to
24
+ `JSON.parse`, which throws; the catch then returned no bundles, so a plugin
25
+ that `dsh.profile.bundles` really did list was reported as missing and the
26
+ repair said `add it to dsh.profile.bundles` rather than `restart the app`.
27
+ `readProfileBundles` now strips a leading run of U+FEFF through the same
28
+ `stripBom` helper `readManifest` uses. A BOM profile lists its bundles and a
29
+ malformed profile still degrades to no bundles; tests cover one BOM, a
30
+ doubled BOM, the malformed control, and the audit row's restart repair.
31
+
32
+ - **The BOM repair is locked at the CLI boundary.** A test replays the
33
+ six-trial experiment (three BOM profiles, three no-BOM controls), installing
34
+ the same listed plugin and pointing `audit --home` at a fake app graph that
35
+ does not contain it. It requires 6/6 `restart the app once to load it`
36
+ sentences and zero `does not list it`; on 0.20.12 the three BOM trials print
37
+ the unlisted cause and an edit the profile already has. The test spawns the
38
+ real CLI, so a future change that bypasses `readProfileBundles` cannot pass.
2
39
 
3
40
  - **A check run with a conclusion is settled even if GitHub leaves its status
4
41
  at `in_progress`.** On 2026-11-11 GitHub wrote `conclusion: success` and
@@ -22,6 +59,8 @@
22
59
  leave `lib/secret.js` out of the tarball and `doctor` to report it on three
23
60
  consecutive runs, so the check cannot drift from the packer.
24
61
 
62
+ ## 0.20.24
63
+
25
64
  - **A failed `market/<version>` push is named, not a raw exec error.** With
26
65
  `--pr`, a rejected or denied branch push used to surface only as
27
66
  `Command failed: git push -u origin market/<version>` from the exec wrapper.
package/lib/audit.mjs CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  doctor,
17
17
  hostRange,
18
18
  readManifestSource,
19
+ stripBom,
19
20
  version as manifestVersion,
20
21
  } from './doctor.mjs';
21
22
  import { hostCompatibility } from './compat.mjs';
@@ -66,7 +67,11 @@ export function readProfileBundles({ home = DEFAULT_HOME, profile } = {}) {
66
67
  const file = path.join(root, 'profiles', profile, 'package.json');
67
68
  if (fs.existsSync(file) === false) return { file, bundles: [] };
68
69
  try {
69
- const manifest = JSON.parse(fs.readFileSync(file, 'utf8'));
70
+ // A profile package.json saved by Notepad starts with a UTF-8 BOM, which
71
+ // JSON.parse rejects. Read it through the same strip `readManifest` uses:
72
+ // otherwise a listed plugin looks unlisted and the repair sends the user
73
+ // back to `dsh.profile.bundles` instead of restarting the app.
74
+ const manifest = JSON.parse(stripBom(fs.readFileSync(file, 'utf8')));
70
75
  const bundles = manifest?.dsh?.profile?.bundles;
71
76
  return { file, bundles: Array.isArray(bundles) ? bundles : [] };
72
77
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.24",
3
+ "version": "0.20.26",
4
4
  "description": "Preflight, release and test DeepSeek Harness plugins: check a folder or any GitHub repository, wait for npm to actually serve the version, and keep the market index honest.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,6 +28,7 @@
28
28
  "docs/ecosystem-audit-2026-11-03.txt",
29
29
  "scripts/benchmark-audit.mjs",
30
30
  "scripts/compatibility-sample.mjs",
31
+ "scripts/preview.mjs",
31
32
  "examples/compatibility-sample/"
32
33
  ],
33
34
  "engines": {
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Render the panel to a static page so its layout can be looked at.
3
+ *
4
+ * The bundle is mounted in jsdom with the same testkit a test would use, and
5
+ * the resulting markup plus the plugin's own stylesheet becomes one HTML file.
6
+ * No browser automation, no screenshot of the real app: this is the panel's
7
+ * markup and its CSS, in the states that matter.
8
+ */
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+ import { createHost, createFetch, mountClient } from '../lib/testkit/index.mjs';
12
+
13
+ const ROOT = path.resolve(import.meta.dirname, '..');
14
+ const out = process.argv[2] ?? '/tmp/kit-preview.html';
15
+
16
+ const result = {
17
+ ok: false,
18
+ dir: '/Users/you/work/my-plugin',
19
+ checks: [
20
+ { check: 'manifest', ok: true, message: 'my-plugin@0.2.0' },
21
+ { check: 'engines.dsh', ok: true, message: '>=0.2.0' },
22
+ { check: 'root export', ok: false, message: 'exports["."] points at the CLI (./bin/cli.mjs), so the loader\'s row has no plugin to apply' },
23
+ { check: 'client declaration', ok: true, message: 'dsh.client platform=web, exports["./client"]=./client.js' },
24
+ { check: 'files list', ok: false, message: 'files does not ship client.js, which package.json points at, so the installed plugin would be missing its own code' },
25
+ { check: 'readme', ok: true, message: 'Requirements section found' },
26
+ ],
27
+ };
28
+
29
+ const CANDIDATES = {
30
+ ok: false,
31
+ kind: 'candidates',
32
+ query: 'dsh-plugin',
33
+ candidates: [
34
+ { fullName: 'tanzhangjia/dsh-plugins-examples', description: 'Example plugins for the DeepSeek Harness', stars: 1, url: 'https://github.com/tanzhangjia/dsh-plugins-examples' },
35
+ { fullName: 'WJDdidi-1/dsh-plugin-example', description: 'A minimal panel plugin', stars: 0, url: 'https://github.com/WJDdidi-1/dsh-plugin-example' },
36
+ { fullName: 'hopefullstack-collab/dsh-plugin-company-example', description: '', stars: 0, url: 'https://github.com/hopefullstack-collab/dsh-plugin-company-example' },
37
+ ],
38
+ };
39
+
40
+ const REPO_RESULT = {
41
+ ...result,
42
+ kind: 'github',
43
+ dir: '/tmp/dsh-toolkit-gh-1a2b/repo',
44
+ repo: { fullName: 'WJDdidi-1/dsh-plugin-example', url: 'https://github.com/WJDdidi-1/dsh-plugin-example' },
45
+ };
46
+
47
+ const states = [
48
+ { name: 'dock collapsed', slot: 'conversation.input.dock', before: async () => {} },
49
+ { name: 'dock open', slot: 'conversation.input.dock', before: async (panel) => { await panel.click('.tk-dock-toggle'); } },
50
+ { name: 'dock result', slot: 'conversation.input.dock', before: async (panel) => { await panel.click('.tk-dock-toggle'); await panel.type('.tk-input', '/Users/you/work/my-plugin'); await panel.click('.tk-button'); } },
51
+ { name: 'dock candidates', slot: 'conversation.input.dock', route: 'search', before: async (panel) => { await panel.click('.tk-dock-toggle'); await panel.type('.tk-input', 'dsh-plugin'); await panel.click('.tk-button'); } },
52
+ { name: 'dock repository', slot: 'conversation.input.dock', route: 'repo', before: async (panel) => { await panel.click('.tk-dock-toggle'); await panel.type('.tk-input', 'WJDdidi-1/dsh-plugin-example'); await panel.click('.tk-button'); } },
53
+ { name: 'tab', slot: undefined, before: async () => {} },
54
+ { name: 'tab result', slot: undefined, before: async (panel) => { await panel.type('.tk-input', '/Users/you/work/my-plugin'); await panel.click('.tk-button'); } },
55
+ ];
56
+
57
+ const sections = [];
58
+ let firstPanel = null; // the injected stylesheet, read while the first panel is alive
59
+ for (const state of states) {
60
+ const panel = await mountClient({
61
+ file: path.join(ROOT, 'client.js'),
62
+ slot: state.slot,
63
+ host: createHost({ locale: { en: {}, zh: {} } }),
64
+ fetch: createFetch({ '/toolkit/check': { body: state.route === 'search' ? CANDIDATES : state.route === 'repo' ? REPO_RESULT : result } }),
65
+ });
66
+ if (firstPanel === null) {
67
+ firstPanel = panel.window.document.getElementById('dsh-plugin-toolkit:styles')?.textContent ?? '';
68
+ }
69
+ await state.before(panel);
70
+ sections.push(`<section class="frame"><h2>${state.name}</h2><div class="stage${state.slot === undefined ? '' : ' dock'}">${panel.html()}</div></section>`);
71
+ await panel.unmount();
72
+ }
73
+
74
+ // The stylesheet the plugin injects, read from the DOM it injected into: parsing
75
+ // the source with a regex silently truncates at the first `;` in a string.
76
+ const css = firstPanel;
77
+
78
+ const page = `<!doctype html><html lang="zh"><head><meta charset="utf-8"><title>dsh-plugin-toolkit preview</title>
79
+ <style>
80
+ :root { --dsw-alias-label-primary:#1f2329; --dsw-alias-label-secondary:#646a73; --dsw-alias-label-tertiary:#8f959e;
81
+ --dsw-alias-border-l1:#e5e6eb; --dsw-alias-border-l2:#d9dbe1; --dsw-alias-bg-body:#fff; --dsw-alias-bg-l1:#f7f8fa;
82
+ --dsw-alias-state-business-primary:#4176e6; --dsw-alias-state-success-primary:#2ea121; --dsw-alias-state-error-primary:#d54941; }
83
+ body { margin:0; padding:32px; background:#eef0f4; font:13px/1.5 -apple-system, "PingFang SC", system-ui, sans-serif; color:#1f2329; }
84
+ .frame { background:#fff; border-radius:12px; padding:20px; margin:0 0 24px; max-width:1120px; }
85
+ .frame h2 { font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:#8f959e; margin:0 0 14px; }
86
+ .stage { border:1px dashed #d9dbe1; border-radius:8px; padding:12px; }
87
+ .stage.dock { padding:0; }
88
+ ${css}
89
+ </style></head><body>${sections.join('\n')}</body></html>`;
90
+
91
+ fs.writeFileSync(out, page);
92
+ console.log(`wrote ${out} (${page.length} bytes)`);