dsh-plugin-toolkit 0.20.17 → 0.20.19
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 +31 -0
- package/README.md +6 -4
- package/lib/cli.mjs +14 -1
- package/lib/verify.mjs +50 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## 0.20.19
|
|
2
|
+
|
|
3
|
+
- **`audit --home` expands `~` and `~\` before the scan, and a bare flag is
|
|
4
|
+
refused.** The local audit resolves its home like every other user-named
|
|
5
|
+
path, so `audit --home '~/.dsh'` and `audit --home '~\.dsh'` read
|
|
6
|
+
`$HOME/.dsh` on cmd and PowerShell instead of a folder literally named `~`.
|
|
7
|
+
A checked-in home with one declared plugin whose `dsh.bundle.patch` names
|
|
8
|
+
`./missing.yml` now pins both spellings through the shipped CLI: each prints
|
|
9
|
+
the `broken` row, names the missing patch, exits `1`, and leaves no `~`
|
|
10
|
+
directory in the working folder; the absolute-path control exits `1` with the
|
|
11
|
+
same row. `--home` with no value exits `2` and says what it needs, rather
|
|
12
|
+
than scanning the current folder and reporting "no plugins installed" with
|
|
13
|
+
exit `0`. `--help` documents the flag.
|
|
14
|
+
|
|
15
|
+
## 0.20.18
|
|
16
|
+
|
|
17
|
+
- **`verify` resolves the installed root the way the loader does.** It used to
|
|
18
|
+
import the file `main` named, so a tarball whose `exports` map had no `.`
|
|
19
|
+
entry passed `verify --no-mount` even though `import("<name>")` failed with
|
|
20
|
+
`ERR_PACKAGE_PATH_NOT_EXPORTED`. The installed copy is now imported by its
|
|
21
|
+
bare package name from a probe module beside it, so Node's own `exports`
|
|
22
|
+
resolution decides. The missing `.` entry is reported as a `root export`
|
|
23
|
+
failure and the command exits `1`; the same fixture with `exports["."]` exits
|
|
24
|
+
`0` and prints `imported its host half`. A package that declares neither
|
|
25
|
+
`exports` nor `main` still has no root module to import, so its success line
|
|
26
|
+
keeps saying the host import was skipped. Two checked-in fixtures
|
|
27
|
+
(`test/fixtures/verify-exports-no-dot` and `verify-exports-dot`) now pin both
|
|
28
|
+
sides through the shipped CLI process, including the exit code, so `npm test`
|
|
29
|
+
fails if the no-`.` tarball ever exits `0` again. The README states that the
|
|
30
|
+
bare specifier, not a file path, is what `verify` imports.
|
|
31
|
+
|
|
1
32
|
## 0.20.17
|
|
2
33
|
|
|
3
34
|
- **`audit` reports a declared bundle whose folder is gone.** When a package
|
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ npx dsh-plugin-toolkit@latest release . --pr --merge
|
|
|
80
80
|
|
|
81
81
|

|
|
82
82
|
|
|
83
|
-
The order matters. Packing first means the check reads the file list npm will publish, not the folder you have. Installing the tarball means the root
|
|
83
|
+
The order matters. Packing first means the check reads the file list npm will publish, not the folder you have. Installing the tarball means the root is imported by its bare specifier — the package name the loader uses — not by a file path taken from `main` or `exports["."]`. Node ignores `main` once `exports` exists, so a package whose `exports` map has no `"."` entry fails with `ERR_PACKAGE_PATH_NOT_EXPORTED` at that step even though the file is present. Mounting means the client bundle is actually executed, in jsdom, with a host that records what it registered.
|
|
84
84
|
|
|
85
85
|
Each step exists because a plugin once got past the step before it and still installed into nothing.
|
|
86
86
|
|
|
@@ -692,9 +692,11 @@ the diff in the terminal.
|
|
|
692
692
|
| `patch file` | The path declared above must be a real file |
|
|
693
693
|
| `client entry` | If `dsh.client` is declared, the bundle has to be there |
|
|
694
694
|
| `files list` | Every path `package.json` points at (`exports`, patch, client) must be covered by `files` |
|
|
695
|
-
| `root export` | The loader imports the bare package name; if that module is missing, is a directory, is the CLI,
|
|
695
|
+
| `root export` | The loader imports the bare package name; if that module is missing, is a directory, is the CLI, exports no `apply`, or the `exports` map has no `.` entry, the row mounts nothing while the install reports success |
|
|
696
696
|
|
|
697
|
-
The `root export` check is a source check, not an install. `doctor` resolves the module the loader imports — `exports["."]` when it is a string or a conditions object (`default`, `import`, `require`, `node`, `module-sync`), otherwise `main` — then checks that the path is a readable regular file, removes comments and the contents of string, template and regex literals, and looks for a real export. A missing file, a directory and an unreadable file are reported as `root export` failures naming the target instead of being skipped or raising a raw `EISDIR`; on a directory the install would have failed at import too. It accepts `export function apply`, `export async function apply`, `export const apply = ...` (also `let` and `var`), `export { apply }` (including `export { helper as apply }`), `exports.apply = ...`, and an `apply` property in `module.exports = { ... }`. A comment such as `// TODO: export function apply() {}` is not an export, and `doctor` never imports or runs the plugin to decide.
|
|
697
|
+
The `root export` check is a source check, not an install. `doctor` resolves the module the loader imports — `exports["."]` when it is a string or a conditions object (`default`, `import`, `require`, `node`, `module-sync`), otherwise `main` — then checks that the path is a readable regular file, removes comments and the contents of string, template and regex literals, and looks for a real export. A missing file, a directory and an unreadable file are reported as `root export` failures naming the target instead of being skipped or raising a raw `EISDIR`; on a directory the install would have failed at import too. It accepts `export function apply`, `export async function apply`, `export const apply = ...` (also `let` and `var`), `export { apply }` (including `export { helper as apply }`), `exports.apply = ...`, and an `apply` property in `module.exports = { ... }`. A comment such as `// TODO: export function apply() {}` is not an export, and `doctor` never imports or runs the plugin to decide.
|
|
698
|
+
|
|
699
|
+
`verify --no-mount` does not reopen the path `doctor` read. It imports the installed package by its bare name, the way the loader does, so Node's `exports` resolution decides. An `exports` map with no `.` entry therefore fails with `ERR_PACKAGE_PATH_NOT_EXPORTED` even when `main` names a working file, and `verify` reports a `root export` failure naming the missing `.` export instead of passing. `verify --no-mount` still runs `doctor` first, so a root the source check already rejects stops at that same check instead of packing. `npm test` spawns the shipped CLI for both commands on the comment-only fixtures and the missing-file, missing-conditions-file, string-root missing-file and directory fixtures, requires every one to exit `1` with a `root export:` line and no raw `EISDIR`, and requires `verify` to report `stopped at doctor` rather than a `pack:` failure. The unmodified scaffold still passes both commands.
|
|
698
700
|
|
|
699
701
|
Exit code is `0` when the plugin can be installed and `1` when it cannot, so it drops into CI unchanged. `doctor --remote` and `audit --remote` run the same manifest and README checks (`name`, `version`, `engines.dsh`, `dsh field`, `files list`, `readme`) against the `package.json` and README GitHub serves, then check the files the manifest points at, so a bad package name or a README with no Requirements heading is reported before a clone or install. The `name` check is pinned at the process boundary: `npm test` expects the shipped CLI to reject a missing, empty and malformed name (`accepted=0/3`) and to accept a valid plain or scoped control.
|
|
700
702
|
|
|
@@ -923,7 +925,7 @@ ok packed 5 file(s), installed the tarball, mounted the panel
|
|
|
923
925
|
My panel This panel came from dsh-plugin init. Clicks: 0
|
|
924
926
|
```
|
|
925
927
|
|
|
926
|
-
It packs, installs that tarball into a throwaway directory, then mounts the bundle **from the installed copy**. A
|
|
928
|
+
It packs, installs that tarball into a throwaway directory, then mounts the bundle **from the installed copy**. The host half is imported by the package's bare name, exactly as the loader imports it, so an `exports` map with no `.` entry fails with `ERR_PACKAGE_PATH_NOT_EXPORTED` even when `main` names a working file; `verify --no-mount` reports that as a `root export` failure naming the missing `.` export. A package that declares neither `exports` nor `main` has no root module at all; there is nothing to import, and the success line says it skipped the host import instead of claiming one ran. When the `files` list drops the panel:
|
|
927
929
|
|
|
928
930
|
```sh
|
|
929
931
|
$ npx dsh-plugin-toolkit verify .
|
package/lib/cli.mjs
CHANGED
|
@@ -56,6 +56,7 @@ export const HELP = `dsh-plugin — preflight and release DeepSeek Harness plugi
|
|
|
56
56
|
|
|
57
57
|
dsh-plugin audit [flags] every installed plugin: valid, and loaded by the running app
|
|
58
58
|
dsh-plugin audit --host http://127.0.0.1:54133
|
|
59
|
+
dsh-plugin audit --home '~/.dsh' the profile home; both tilde spellings expand
|
|
59
60
|
|
|
60
61
|
dsh-plugin audit --remote --from <file> audit a list and print one line per repository
|
|
61
62
|
dsh-plugin audit --remote --from repos.txt
|
|
@@ -107,6 +108,7 @@ Flags
|
|
|
107
108
|
--budget <seconds> how long to wait for npm, a positive number, default 480
|
|
108
109
|
--pr commit the index on a branch, push it, open the pull request
|
|
109
110
|
--merge with --pr: wait for checks, then squash-merge
|
|
111
|
+
--home <dir> with audit: the profile home to scan, default ~/.dsh
|
|
110
112
|
--base <branch> base branch for the pull request, default main
|
|
111
113
|
--name <package-name> with init: the npm name, required
|
|
112
114
|
--title <text> with init: the tab title, default "My panel"
|
|
@@ -188,7 +190,14 @@ function flags(argv) {
|
|
|
188
190
|
else if (token === '--pr') parsed.pr = true;
|
|
189
191
|
else if (token === '--merge') parsed.merge = true;
|
|
190
192
|
else if (token === '--publish') parsed.publish = true;
|
|
191
|
-
else if (token === '--home')
|
|
193
|
+
else if (token === '--home') {
|
|
194
|
+
// Like every other path flag: a bare `--home` is a missing path, not
|
|
195
|
+
// permission to swallow the next option. Otherwise `audit --home
|
|
196
|
+
// --timeout 50` would scan a folder literally named `--timeout` and
|
|
197
|
+
// report "no plugins installed" with exit 0.
|
|
198
|
+
const next = argv[index + 1];
|
|
199
|
+
parsed.home = next === undefined || next.startsWith('--') === true ? '' : argv[++index];
|
|
200
|
+
}
|
|
192
201
|
else if (token === '--base') parsed.base = argv[++index];
|
|
193
202
|
else if (token === '--market') parsed.market = argv[++index];
|
|
194
203
|
else if (token.startsWith('--') === true) throw new Error(`unknown flag ${token}`);
|
|
@@ -540,6 +549,10 @@ export async function run(argv, io = console, deps = {}) {
|
|
|
540
549
|
|
|
541
550
|
if (command === 'audit') {
|
|
542
551
|
const { audit, parseJobs } = await import('./audit.mjs');
|
|
552
|
+
if (options.home !== undefined && String(options.home).trim() === '') {
|
|
553
|
+
io.error('dsh-plugin audit --home needs a directory path');
|
|
554
|
+
return 2;
|
|
555
|
+
}
|
|
543
556
|
if (options.remote !== undefined || options.from !== undefined || options.patchDir !== undefined) {
|
|
544
557
|
let remote = remoteTarget(options);
|
|
545
558
|
let from = options.from;
|
package/lib/verify.mjs
CHANGED
|
@@ -170,6 +170,23 @@ export async function verify({ dir, mount = true }) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Import the installed package exactly as the loader does: `import(name)` from
|
|
175
|
+
* a module that sits beside the installed copy. Resolving the bare specifier
|
|
176
|
+
* here, rather than reading `main` or `exports["."]` ourselves, means Node's
|
|
177
|
+
* own rules decide whether the root is importable. That is what catches an
|
|
178
|
+
* `exports` map with no `.` entry: Node ignores `main` once `exports` exists,
|
|
179
|
+
* so the bare import fails with ERR_PACKAGE_PATH_NOT_EXPORTED while the file
|
|
180
|
+
* `main` names is still present.
|
|
181
|
+
*/
|
|
182
|
+
async function importInstalledRoot(name, scratch) {
|
|
183
|
+
const { pathToFileURL } = await import('node:url');
|
|
184
|
+
const probe = path.join(scratch, 'install', 'verify-root.mjs');
|
|
185
|
+
fs.writeFileSync(probe, `export default await import(${JSON.stringify(name)});\n`);
|
|
186
|
+
const loaded = await import(pathToFileURL(probe).href);
|
|
187
|
+
return loaded.default;
|
|
188
|
+
}
|
|
189
|
+
|
|
173
190
|
/**
|
|
174
191
|
* The part of `verify` that needs the installed copy. It runs inside the
|
|
175
192
|
* scratch directory's try/finally, so every stage here is cleaned up whether
|
|
@@ -207,40 +224,52 @@ async function inspectScratch({ dir, mount, report, packed, scratch }) {
|
|
|
207
224
|
// the same import here is the only way to know the row will have an apply —
|
|
208
225
|
// 0.8.0 shipped a package whose root export was the CLI, installed cleanly,
|
|
209
226
|
// and mounted nothing.
|
|
227
|
+
//
|
|
228
|
+
// Importing the file `main` names would be a different question. Node ignores
|
|
229
|
+
// `main` as soon as a package has an `exports` map, so a map with no `.` entry
|
|
230
|
+
// fails `import(name)` with ERR_PACKAGE_PATH_NOT_EXPORTED even when `main`
|
|
231
|
+
// points at a working module. The probe module below lives beside the
|
|
232
|
+
// installed package, so the bare specifier is resolved by the same algorithm
|
|
233
|
+
// the loader uses, not by the toolkit's own location.
|
|
210
234
|
const rootFile = rootEntry(report.manifest);
|
|
235
|
+
const declaredRoot =
|
|
236
|
+
(report.manifest.exports !== undefined && report.manifest.exports !== null) ||
|
|
237
|
+
typeof report.manifest.main === 'string';
|
|
211
238
|
let hostFace = null;
|
|
212
|
-
// A bundle that inserts a subpath plugin
|
|
213
|
-
// nothing to import. The success line must not claim
|
|
214
|
-
// that was skipped.
|
|
239
|
+
// A bundle that inserts a subpath plugin and declares no root at all needs no
|
|
240
|
+
// root module, so there is nothing to import. The success line must not claim
|
|
241
|
+
// it imported a host half that was skipped.
|
|
215
242
|
let hostImported = false;
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
if (fs.existsSync(absolute) === false) {
|
|
219
|
-
return {
|
|
220
|
-
ok: false,
|
|
221
|
-
stage: 'install',
|
|
222
|
-
failures: [{ check: 'root export', message: `the tarball does not ship ${rootFile}, which package.json points the loader at` }],
|
|
223
|
-
files: packed.files,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
243
|
+
if (declaredRoot === true) {
|
|
244
|
+
let loaded;
|
|
226
245
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
hostImported = true;
|
|
231
|
-
if (typeof loaded.apply !== 'function') {
|
|
246
|
+
loaded = await importInstalledRoot(report.manifest.name, scratch);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (error?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
232
249
|
return {
|
|
233
250
|
ok: false,
|
|
234
251
|
stage: 'install',
|
|
235
|
-
failures: [{
|
|
252
|
+
failures: [{
|
|
253
|
+
check: 'root export',
|
|
254
|
+
message: 'the installed package has no exports["."], so importing its bare name fails with ERR_PACKAGE_PATH_NOT_EXPORTED; add a "." entry that names the module exporting apply',
|
|
255
|
+
}],
|
|
236
256
|
files: packed.files,
|
|
237
257
|
};
|
|
238
258
|
}
|
|
239
|
-
} catch (error) {
|
|
240
259
|
return {
|
|
241
260
|
ok: false,
|
|
242
261
|
stage: 'install',
|
|
243
|
-
failures: [{ check: 'root export', message: `the installed ${rootFile} does not import: ${error.message}` }],
|
|
262
|
+
failures: [{ check: 'root export', message: `the installed ${rootFile ?? report.manifest.name} does not import: ${error.message}` }],
|
|
263
|
+
files: packed.files,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
hostFace = loaded;
|
|
267
|
+
hostImported = true;
|
|
268
|
+
if (typeof loaded.apply !== 'function') {
|
|
269
|
+
return {
|
|
270
|
+
ok: false,
|
|
271
|
+
stage: 'install',
|
|
272
|
+
failures: [{ check: 'root export', message: `the installed ${rootFile ?? report.manifest.name} exports no apply, so the loader's row mounts nothing` }],
|
|
244
273
|
files: packed.files,
|
|
245
274
|
};
|
|
246
275
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.19",
|
|
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": {
|