dsh-plugin-toolkit 0.20.44 → 0.20.46

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,3 +1,35 @@
1
+ ## 0.20.46
2
+
3
+ - **`index` rejects two plugin entries that share a name before auditing
4
+ either.** The audit resolves a plugin by name, so a second `dup-plugin` entry
5
+ re-read the first entry's versions and printed `ok` for both, even when the
6
+ duplicate was the broken one. The shape pass now groups plugin names by
7
+ position and emits one finding naming every duplicate position
8
+ (`plugins[0], plugins[1]`), so the command exits `1` before the `ok` loop can
9
+ start. Distinct names still audit and print `ok` for each entry. A unique
10
+ plugin may list several versions, and when its second version (`1.0.1`) omits
11
+ `engines.dsh` the command still exits `1` with `1.0.1 no engines.dsh` instead
12
+ of inheriting the clean first version.
13
+ `test/index-duplicate.test.mjs` pins the duplicate finding at the library and
14
+ the shipped CLI, the absence of either `ok` line, and both control paths,
15
+ including the finding for a second version that is missing its range.
16
+
17
+ ## 0.20.45
18
+
19
+ - **The reproducible compatibility sample answers for the DSH version the
20
+ reader runs, not only the canary in the reports.**
21
+ `node scripts/compatibility-sample.mjs --host 0.1.5` replays the frozen
22
+ `L3n3L/dsh-resume@0.1.3` manifest through the shipped CLI and prints the
23
+ `compatible` line the README now shows; the default command still prints and
24
+ checks the documented `incompatible` line. With an explicit `--host` the
25
+ wrapper exits with the replayed command's status, so a CI step can gate on
26
+ `0`/`1`, while an invalid version reaches the CLI's own complete-version
27
+ refusal and exits `2` instead of printing a misleading row.
28
+ `test/readme-compatibility.test.mjs` compares both documented blocks with the
29
+ sample, pins the forwarded statuses, and now invokes the parser with every
30
+ documented compatibility flag so a README flag cannot survive only in the
31
+ help text.
32
+
1
33
  ## 0.20.44
2
34
 
3
35
  - **`audit --home` reports a declared bundle whose `package.json` parses but has
package/README.md CHANGED
@@ -416,8 +416,11 @@ forgets `client.js` passes it and fails only after `npm i`.
416
416
  `engines.dsh` is missing or is not a semver range (a malformed value such as
417
417
  `>=banana`, or a single pinned version such as `0.2.0`, both fail). It also
418
418
  rejects an index it cannot audit: a missing `plugins` or `versions` array, a
419
- plugin entry without a name, a version entry without `version`, and a
420
- non-SemVer `version`. Each failure names the file and the plugin or entry.
419
+ plugin entry without a name, two entries sharing one name, a version entry
420
+ without `version`, and a non-SemVer `version`. Each failure names the file and
421
+ the plugin, entry, or both duplicate positions. A duplicate is rejected before
422
+ any audit, so the second entry cannot inherit the first entry's clean result or
423
+ produce an `ok` line.
421
424
  Pin `version:` if you would rather not track the latest release.
422
425
 
423
426
  ## Check a plugin you have not cloned
@@ -499,9 +502,31 @@ incompatible L3n3L/dsh-resume 0.1.3 (host >=0.1.0-rc.6 <0.2.0-0) [incompatible
499
502
  summary: 1 repository — 0 clean, 1 failing (1 problem), 0 unreadable, 0 rate-limited
500
503
  ```
501
504
 
502
- The verdict comes first: `incompatible` means the range in `package.json` does
505
+ The sample defaults to that canary. Pass `--host` to ask the same frozen 0.1.3
506
+ manifest about the version you actually run; this is the same range against an
507
+ older stable host it accepts:
508
+
509
+ ```sh
510
+ $ node scripts/compatibility-sample.mjs --host 0.1.5
511
+ clean L3n3L/dsh-resume 0.1.3 (host >=0.1.0-rc.6 <0.2.0-0) [compatible with dsh 0.1.5; declares ">=0.1.0-rc.6 <0.2.0-0"]
512
+
513
+ summary: 1 repository — 1 clean, 0 failing (0 problems), 0 unreadable, 0 rate-limited
514
+ ```
515
+
516
+ With an explicit `--host` the wrapper exits with the replayed command's status
517
+ (`0` for this compatible line, `1` for a version the range rejects), so it can
518
+ gate a CI step. The default form still exits `0` only after the documented
519
+ incompatible replay exited `1`. An invalid version such as `banana` reaches the
520
+ CLI's own `--host needs a complete DSH version` refusal and exits `2` instead
521
+ of printing a clean-looking row.
522
+
523
+ The line starts with the repository verdict: `clean` when the range accepts the
524
+ host and every check passes, `incompatible` when the range is the failing fact.
525
+ The bracketed `compatibility` field is the direct answer. `incompatible` means
526
+ the range in `package.json` does
503
527
  not accept the host, so the installer rejects the plugin before it unpacks it.
504
- This run exits `1`. The same answer is reproducible without a GitHub request:
528
+ An incompatible run exits `1`. The same answer is reproducible without a GitHub
529
+ request:
505
530
  the checked-in snapshot under `examples/compatibility-sample/` keeps the 0.1.3
506
531
  manifest fields that decide compatibility, and its `## Requirements` heading
507
532
  isolates the host-range answer. This command feeds that snapshot through the
@@ -17,3 +17,9 @@ The heading is here on purpose: the sample isolates the host-range verdict, and
17
17
  the remote audit still checks README requirements. Upstream's localized README
18
18
  does not use a `## Requirements` heading, so a live audit of the repository can
19
19
  also add a `readme` failure to the same row.
20
+
21
+ `node scripts/compatibility-sample.mjs` compares this manifest with the
22
+ `0.2.2-alpha.3` canary from the reports. Add `--host <version>` to ask the same
23
+ frozen manifest about the DSH version you run; the wrapper then exits with the
24
+ replayed CLI's status, so `--host 0.1.5` exits `0` and a range-excluding version
25
+ exits `1`.
@@ -37,6 +37,11 @@ function nonEmptyString(value) {
37
37
  * list) or crashed on `plugin.name` and printed a raw TypeError. Every finding
38
38
  * names the plugin and, where one exists, the entry position or version, so a
39
39
  * CI log points at the JSON line to edit instead of at the command.
40
+ *
41
+ * Names have to be unique too. `auditVersions()` resolves a plugin by name, so
42
+ * a second entry with the same name made the audit re-read the first entry and
43
+ * report the duplicate clean. Duplicate names are reported by position, before
44
+ * any `engines.dsh` check can print `ok` for either entry.
40
45
  */
41
46
  export function validateIndex(index) {
42
47
  if (isRecord(index) === false) {
@@ -55,6 +60,7 @@ export function validateIndex(index) {
55
60
  }
56
61
 
57
62
  const findings = [];
63
+ const names = new Map();
58
64
  index.plugins.forEach((plugin, pluginPosition) => {
59
65
  if (isRecord(plugin) === false) {
60
66
  findings.push({ entry: `plugins[${pluginPosition}]`, problem: 'the plugin entry is not an object' });
@@ -62,6 +68,14 @@ export function validateIndex(index) {
62
68
  }
63
69
 
64
70
  const name = nonEmptyString(plugin.name) ? plugin.name : `plugins[${pluginPosition}]`;
71
+ if (nonEmptyString(plugin.name)) {
72
+ // Keep every position so the finding names the entry to delete, not just
73
+ // the one the audit happens to read. A blank or missing name already has
74
+ // its own finding and is not a duplicate.
75
+ const positions = names.get(plugin.name) ?? [];
76
+ positions.push(pluginPosition);
77
+ names.set(plugin.name, positions);
78
+ }
65
79
  if (nonEmptyString(plugin.name) === false) {
66
80
  findings.push({
67
81
  entry: name,
@@ -111,6 +125,17 @@ export function validateIndex(index) {
111
125
  }
112
126
  });
113
127
  });
128
+
129
+ // One finding per repeated name, naming every duplicate position. Auditing a
130
+ // duplicate by name would silently reuse the first entry, so this has to
131
+ // stop the command before the `ok` loop starts.
132
+ for (const [name, positions] of names) {
133
+ if (positions.length < 2) continue;
134
+ findings.push({
135
+ entry: positions.map((position) => `plugins[${position}]`).join(', '),
136
+ problem: `all are named "${name}"; every plugin name must be unique`,
137
+ });
138
+ }
114
139
  return findings;
115
140
  }
116
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.44",
3
+ "version": "0.20.46",
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": {
@@ -12,9 +12,16 @@
12
12
  *
13
13
  * Run: node scripts/compatibility-sample.mjs
14
14
  * node scripts/compatibility-sample.mjs --json
15
+ * node scripts/compatibility-sample.mjs --host 0.1.5
15
16
  *
16
17
  * `--json` replays the same command with the flag CI reads, so the machine
17
18
  * form is checked against the executable too, not just described in prose.
19
+ * `--host` asks the same frozen manifest about another DSH version, so a
20
+ * reader can reproduce the answer for the host they actually run; the default
21
+ * stays the canary from the reports. With an explicit host the script passes
22
+ * the replayed command's exit status through, because that is the status a CI
23
+ * step would gate on. Without it the wrapper exits 0 only after the known
24
+ * incompatible replay exited 1.
18
25
  */
19
26
  import { spawnSync } from 'node:child_process';
20
27
  import fs from 'node:fs';
@@ -27,15 +34,39 @@ const ROOT = path.join(HERE, '..');
27
34
  const SAMPLE = path.join(ROOT, 'examples', 'compatibility-sample');
28
35
  const BIN = path.join(ROOT, 'bin', 'dsh-plugin.mjs');
29
36
  const TARGET = 'L3n3L/dsh-resume';
30
- const HOST = '0.2.2-alpha.3';
31
- const JSON_OUTPUT = process.argv.includes('--json');
37
+ const DEFAULT_HOST = '0.2.2-alpha.3';
32
38
 
33
- const unknown = process.argv.slice(2).filter((argument) => argument !== '--json');
34
- if (unknown.length > 0) {
35
- process.stderr.write(`compatibility-sample: unknown argument ${unknown.join(' ')}; use --json for the machine form\n`);
39
+ function usage(message) {
40
+ process.stderr.write(`compatibility-sample: ${message}\n`);
36
41
  process.exit(2);
37
42
  }
38
43
 
44
+ let JSON_OUTPUT = false;
45
+ let HOST = DEFAULT_HOST;
46
+ let HOST_EXPLICIT = false;
47
+ const args = process.argv.slice(2);
48
+ for (let index = 0; index < args.length; index += 1) {
49
+ const argument = args[index];
50
+ if (argument === '--json') {
51
+ JSON_OUTPUT = true;
52
+ } else if (argument === '--host') {
53
+ const value = args[index + 1];
54
+ if (value === undefined || value.startsWith('--') === true) {
55
+ usage('--host needs a complete DSH version, for example --host 0.2.2');
56
+ }
57
+ HOST = value;
58
+ HOST_EXPLICIT = true;
59
+ index += 1;
60
+ } else if (argument.startsWith('--host=') === true) {
61
+ const value = argument.slice('--host='.length);
62
+ if (value.trim() === '') usage('--host needs a complete DSH version, for example --host 0.2.2');
63
+ HOST = value;
64
+ HOST_EXPLICIT = true;
65
+ } else {
66
+ usage(`unknown argument ${argument}; use --json or --host <version>`);
67
+ }
68
+ }
69
+
39
70
  // A CommonJS preload works on every Node version the package supports; an
40
71
  // `--import` hook would require a newer Node than `engines` promises.
41
72
  const PRELOAD = `
@@ -87,18 +118,39 @@ function replay() {
87
118
  });
88
119
  if (result.error !== undefined) throw result.error;
89
120
  const stderr = String(result.stderr ?? '').trim();
90
- if (result.status !== 1) {
91
- throw new Error(
92
- `the compatibility sample answered ${result.status ?? 'no status'}; the documented incompatible answer exits 1${
93
- stderr === '' ? '' : `\n${stderr}`
94
- }`,
95
- );
121
+ // The CLI validates `--host` at the same boundary a real run uses. Forward
122
+ // that usage refusal instead of turning it into a wrapper stack trace; a
123
+ // typo in the version must not look like a successful replay.
124
+ if (result.status === 2) {
125
+ if (stderr === '') throw new Error('the compatibility sample exited 2 without saying why');
126
+ return { stdout: String(result.stdout ?? ''), stderr, status: 2 };
127
+ }
128
+ if (HOST_EXPLICIT === false) {
129
+ if (result.status !== 1) {
130
+ throw new Error(
131
+ `the compatibility sample answered ${result.status ?? 'no status'}; the documented incompatible answer exits 1${
132
+ stderr === '' ? '' : `\n${stderr}`
133
+ }`,
134
+ );
135
+ }
136
+ if (stderr !== '') throw new Error(`the compatibility sample wrote to stderr:\n${stderr}`);
137
+ // The wrapper's own 0 means the documented incompatible answer was
138
+ // reproduced; the default command is a demonstration, not a gate.
139
+ return { stdout: String(result.stdout ?? ''), stderr: '', status: 0 };
140
+ }
141
+ if (result.status !== 0 && result.status !== 1) {
142
+ throw new Error(`the compatibility sample answered ${result.status ?? 'no status'}${stderr === '' ? '' : `\n${stderr}`}`);
96
143
  }
97
144
  if (stderr !== '') throw new Error(`the compatibility sample wrote to stderr:\n${stderr}`);
98
- return result.stdout;
145
+ // An explicit host is a question whose answer a reader may gate on, so the
146
+ // wrapper exits with the replayed CLI's status.
147
+ return { stdout: String(result.stdout ?? ''), stderr: '', status: result.status };
99
148
  } finally {
100
149
  fs.rmSync(scratch, { recursive: true, force: true });
101
150
  }
102
151
  }
103
152
 
104
- process.stdout.write(replay());
153
+ const replayed = replay();
154
+ if (replayed.stdout !== '') process.stdout.write(replayed.stdout);
155
+ if (replayed.stderr !== '') process.stderr.write(`${replayed.stderr}\n`);
156
+ process.exitCode = replayed.status;