dsh-plugin-toolkit 0.20.44 → 0.20.45

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,19 @@
1
+ ## 0.20.45
2
+
3
+ - **The reproducible compatibility sample answers for the DSH version the
4
+ reader runs, not only the canary in the reports.**
5
+ `node scripts/compatibility-sample.mjs --host 0.1.5` replays the frozen
6
+ `L3n3L/dsh-resume@0.1.3` manifest through the shipped CLI and prints the
7
+ `compatible` line the README now shows; the default command still prints and
8
+ checks the documented `incompatible` line. With an explicit `--host` the
9
+ wrapper exits with the replayed command's status, so a CI step can gate on
10
+ `0`/`1`, while an invalid version reaches the CLI's own complete-version
11
+ refusal and exits `2` instead of printing a misleading row.
12
+ `test/readme-compatibility.test.mjs` compares both documented blocks with the
13
+ sample, pins the forwarded statuses, and now invokes the parser with every
14
+ documented compatibility flag so a README flag cannot survive only in the
15
+ help text.
16
+
1
17
  ## 0.20.44
2
18
 
3
19
  - **`audit --home` reports a declared bundle whose `package.json` parses but has
package/README.md CHANGED
@@ -499,9 +499,31 @@ incompatible L3n3L/dsh-resume 0.1.3 (host >=0.1.0-rc.6 <0.2.0-0) [incompatible
499
499
  summary: 1 repository — 0 clean, 1 failing (1 problem), 0 unreadable, 0 rate-limited
500
500
  ```
501
501
 
502
- The verdict comes first: `incompatible` means the range in `package.json` does
502
+ The sample defaults to that canary. Pass `--host` to ask the same frozen 0.1.3
503
+ manifest about the version you actually run; this is the same range against an
504
+ older stable host it accepts:
505
+
506
+ ```sh
507
+ $ node scripts/compatibility-sample.mjs --host 0.1.5
508
+ 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"]
509
+
510
+ summary: 1 repository — 1 clean, 0 failing (0 problems), 0 unreadable, 0 rate-limited
511
+ ```
512
+
513
+ With an explicit `--host` the wrapper exits with the replayed command's status
514
+ (`0` for this compatible line, `1` for a version the range rejects), so it can
515
+ gate a CI step. The default form still exits `0` only after the documented
516
+ incompatible replay exited `1`. An invalid version such as `banana` reaches the
517
+ CLI's own `--host needs a complete DSH version` refusal and exits `2` instead
518
+ of printing a clean-looking row.
519
+
520
+ The line starts with the repository verdict: `clean` when the range accepts the
521
+ host and every check passes, `incompatible` when the range is the failing fact.
522
+ The bracketed `compatibility` field is the direct answer. `incompatible` means
523
+ the range in `package.json` does
503
524
  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:
525
+ An incompatible run exits `1`. The same answer is reproducible without a GitHub
526
+ request:
505
527
  the checked-in snapshot under `examples/compatibility-sample/` keeps the 0.1.3
506
528
  manifest fields that decide compatibility, and its `## Requirements` heading
507
529
  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`.
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.45",
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;