dsh-plugin-toolkit 0.20.21 → 0.20.23

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,44 @@
1
+ ## 0.20.23
2
+
3
+ - **A failed `git push` is reported as the `git` stage, not a raw exec error.**
4
+ When `origin` was unreachable, `release` created the local tag and then let
5
+ the `execFileSync` error escape, so the user saw a command line and stack
6
+ instead of the stage and the tag that still needed pushing. Tag creation and
7
+ the tag push now catch git's failure, return `stage: 'git'`, and print
8
+ `release stopped at git` with the tag, git's own reason, and the fact that
9
+ the tag exists only locally. With `origin` pointed at a missing path the CLI
10
+ exits `1` and leaves `plugin-v<version>` at HEAD; after `git remote set-url
11
+ origin` points at the bare repository, the same working tree re-runs, resumes
12
+ from that tag, pushes it, and exits `0`. A process-level test covers the
13
+ failed push and the corrected retry.
14
+
15
+ - **A retry pushes a tag that exists only locally.** When `release` created
16
+ `plugin-v<version>` and then failed at `git push`, the next run saw the local
17
+ tag at HEAD, took the resume path, skipped both the tag and the push, and
18
+ could report success while the remote still had no tag. The resume path now
19
+ pushes the existing tag before the registry wait. Pushing a tag the remote
20
+ already has at the same commit is a no-op, so repeated retries leave exactly
21
+ one tag on origin. A test reproduces the failed-push state, retries, and
22
+ requires the bare origin to list the tag exactly once; a CLI test starts from
23
+ a local-only tag and requires exit `0` with the tag on origin.
24
+
25
+ ## 0.20.22
26
+
27
+ - **A missing `audit --home` value is refused before the scan, and a later
28
+ `--home` cannot hide it.** The parser used to leave the missing path only in
29
+ the value slot, so a second `--home <dir>` overwrote the typo and the command
30
+ scanned anyway; every missing spelling is now recorded through the rest of
31
+ parsing. `audit --home`, `audit --home --timeout 50`, `audit --home --json`
32
+ and `audit --home --home <dir>` each exit `2` with `--home needs a directory
33
+ path` on stderr and no profile report on stdout, while `audit --home <dir>`
34
+ against the one-declared-plugin fixture still prints its `missing` row and
35
+ exits `1`. The README says a bare `--home` is a usage error, not a request to
36
+ scan `$HOME/.dsh` or a folder named after the next flag. A process-boundary
37
+ test spawns the shipped CLI for all three missing spellings and requires exit
38
+ `2` with no report, then runs the same binary against a checked-in clean home
39
+ and requires exit `0` with its `clean-plugin` row, so the refusal cannot pass
40
+ by breaking every scan.
41
+
1
42
  ## 0.20.21
2
43
 
3
44
  - **`doctor --fix --write` repairs a manifest saved with a UTF-8 BOM.** `doctor`
package/README.md CHANGED
@@ -309,6 +309,12 @@ profile where the app silently skipped a plugin. It exits `0` when every
309
309
  installed plugin is loaded and valid. If no graph was read (`--host` omitted),
310
310
  the loaded column is `?` and only hard failures change the exit code.
311
311
 
312
+ `audit --home <dir>` scans a different profile home; both `~/.dsh` and
313
+ `~\.dsh` expand. A bare `--home`, or one followed by another flag such as
314
+ `--timeout 50` or `--json`, is a missing value rather than a request to scan
315
+ `$HOME/.dsh` or a folder literally named after the flag: the command exits `2`,
316
+ names `--home`, and prints no profile report.
317
+
312
318
  Without `--host` the loaded column is `?`, because guessing would be worse than
313
319
  saying nothing. Only packages that declare a `dsh` field are audited — the rest of
314
320
  `node_modules` is ordinary dependencies, and auditing those is noise.
@@ -972,8 +978,8 @@ The install reports success and nothing shows up. In this order:
972
978
  `release` runs the sequence in the order that fails cheapest first:
973
979
 
974
980
  1. Preflight (`doctor`) — stop before tagging anything.
975
- 2. Refuse to run on a dirty tree. If the tag already exists and points at the current commit, reuse it and resume; if it points somewhere else, stop with the tag's commit and HEAD, and print the `git tag -d` / `git push --delete` recovery.
976
- 3. Create and push the tag, which starts the plugin's release workflow.
981
+ 2. Refuse to run on a dirty tree. If the tag already exists and points at the current commit, reuse it, push it again, and resume; if it points somewhere else, stop with the tag's commit and HEAD, and print the `git tag -d` / `git push --delete` recovery.
982
+ 3. Create and push the tag, which starts the plugin's release workflow. A retry pushes an existing local tag too, so a tag left behind by a failed `git push` still reaches origin.
977
983
  4. Poll the registry until it actually serves that version, reporting each wait.
978
984
  5. Write the index entry with the publish time **the registry reports**, not the local clock. It waits for `time[version]` specifically: the abbreviated registry document has no `time` field, and an entry with a null timestamp is rejected by the market checker.
979
985
  6. With `--pr`: commit that entry on `market/<version>`, push it, and open the pull request. With `--merge` as well: wait for `gh pr checks` to settle, then squash-merge. When the committed index already carries this version with the same publish time there is nothing to commit, so the branch and PR steps are skipped instead of failing at `git commit`. An entry written by an earlier run without `--pr` is still uncommitted, so a later `--pr` run commits it and opens the PR.
@@ -990,7 +996,7 @@ checks settled after 1s (1 look(s))
990
996
  merged
991
997
  ```
992
998
 
993
- Without `--pr` it prints the `git add` / `gh pr create` commands instead of running them; `--dry-run` prints the whole sequence before anything happens. A re-run after a failure is safe: when the tag already points at HEAD it is reused rather than recreated, the release continues with the registry wait, and the same version with the same publish time is a no-op once the index entry is committed. A no-op release prints `<index> already carried <version>; nothing to commit`, exits `0`, leaves `git log -1` unchanged, and creates no `market/<version>` branch, even when `--pr` or `--merge` is passed. A different publish time is not a no-op: the release stops at `index`, names the indexed and registry timestamps in the error, exits `1`, and creates no `market/<version>` branch.
999
+ Without `--pr` it prints the `git add` / `gh pr create` commands instead of running them; `--dry-run` prints the whole sequence before anything happens. A re-run after a failure is safe: when the tag already points at HEAD it is reused rather than recreated, it is pushed again so a local-only tag left by a failed push reaches origin, the release continues with the registry wait, and the same version with the same publish time is a no-op once the index entry is committed. A no-op release prints `<index> already carried <version>; nothing to commit`, exits `0`, leaves `git log -1` unchanged, and creates no `market/<version>` branch, even when `--pr` or `--merge` is passed. A different publish time is not a no-op: the release stops at `index`, names the indexed and registry timestamps in the error, exits `1`, and creates no `market/<version>` branch.
994
1000
 
995
1001
  If that tag points at another commit, the release does not move it. It exits `1`
996
1002
  and names the tag, the commit it points at, HEAD, and the recovery:
@@ -1004,6 +1010,19 @@ Run those two commands when the old tag really was a mistake, then release
1004
1010
  again. A tag at HEAD needs no separate `--resume`: it takes the resume path
1005
1011
  automatically.
1006
1012
 
1013
+ A tag that cannot be pushed is also its own stage, not a raw `git` crash. The
1014
+ release names the tag and git's reason, exits `1`, and leaves the local tag in
1015
+ place:
1016
+
1017
+ ```
1018
+ dsh-plugin release stopped at git
1019
+ ✗ git: could not run `git push origin plugin-v0.4.0`: fatal: '/tmp/missing.git' does not appear to be a git repository; fatal: Could not read from remote repository. The tag is still local; fix the remote and re-run release to push it.
1020
+ ```
1021
+
1022
+ Fix the remote (for example `git remote set-url origin <url>`) and run the same
1023
+ command again. The local tag already points at HEAD, so the re-run resumes and
1024
+ pushes it instead of creating it again.
1025
+
1007
1026
  ### When nothing publishes for you
1008
1027
 
1009
1028
  `release` assumes a tag starts a workflow that publishes. Repositories without
package/lib/cli.mjs CHANGED
@@ -194,9 +194,15 @@ function flags(argv) {
194
194
  // Like every other path flag: a bare `--home` is a missing path, not
195
195
  // permission to swallow the next option. Otherwise `audit --home
196
196
  // --timeout 50` would scan a folder literally named `--timeout` and
197
- // report "no plugins installed" with exit 0.
197
+ // report "no plugins installed" with exit 0. Remember the missing value
198
+ // apart from the value itself, so a later `--home <dir>` cannot overwrite
199
+ // it and turn the same typo into a real scan.
198
200
  const next = argv[index + 1];
199
- parsed.home = next === undefined || next.startsWith('--') === true ? '' : argv[++index];
201
+ if (next === undefined || next.startsWith('--') === true) {
202
+ parsed.homeMissing = true;
203
+ } else {
204
+ parsed.home = argv[++index];
205
+ }
200
206
  }
201
207
  else if (token === '--base') parsed.base = argv[++index];
202
208
  else if (token === '--market') parsed.market = argv[++index];
@@ -548,11 +554,14 @@ export async function run(argv, io = console, deps = {}) {
548
554
  }
549
555
 
550
556
  if (command === 'audit') {
551
- const { audit, parseJobs } = await import('./audit.mjs');
552
- if (options.home !== undefined && String(options.home).trim() === '') {
557
+ // Validate the home before importing the scanner, so a missing value is a
558
+ // usage error even if the scan module would have loaded or fallen back to
559
+ // `$HOME/.dsh` and printed a clean report.
560
+ if (options.homeMissing === true || (options.home !== undefined && String(options.home).trim() === '')) {
553
561
  io.error('dsh-plugin audit --home needs a directory path');
554
562
  return 2;
555
563
  }
564
+ const { audit, parseJobs } = await import('./audit.mjs');
556
565
  if (options.remote !== undefined || options.from !== undefined || options.patchDir !== undefined) {
557
566
  let remote = remoteTarget(options);
558
567
  let from = options.from;
package/lib/release.mjs CHANGED
@@ -26,6 +26,25 @@ function git(dir, args) {
26
26
  return runCommand('git', args, { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
27
27
  }
28
28
 
29
+ /**
30
+ * The reason a git command failed, without the thrown command line and stack.
31
+ *
32
+ * A failed push is a step in the release, not a crash: the caller has to name
33
+ * the tag and the remote's answer so the user can fix `origin` and re-run. Six
34
+ * lines keeps git's useful `fatal:` / `remote:` lines and drops the blank lines
35
+ * and trailing advice.
36
+ */
37
+ function gitFailureDetail(error) {
38
+ const text = String(error?.stderr ?? error?.message ?? error ?? '').trim();
39
+ if (text === '') return 'git exited with an error';
40
+ return text
41
+ .split('\n')
42
+ .map((line) => line.trim())
43
+ .filter((line) => line !== '')
44
+ .slice(0, 6)
45
+ .join('; ');
46
+ }
47
+
29
48
  export function tagName(version, prefix = 'plugin-v') {
30
49
  return `${prefix}${version}`;
31
50
  }
@@ -100,6 +119,16 @@ function indexHasChanges(dir, indexFile, run) {
100
119
  }
101
120
  }
102
121
 
122
+ /** True when the repository has a remote with this name. */
123
+ function hasRemote(dir, name, run) {
124
+ try {
125
+ (run ?? ((args) => git(dir, args)))(['remote', 'get-url', name]);
126
+ return true;
127
+ } catch {
128
+ return false;
129
+ }
130
+ }
131
+
103
132
  /** The paths git would carry into the tag, so the message can name them. */
104
133
  export function dirtyPaths(dir, limit = 3, run) {
105
134
  const status = (run ?? ((args) => git(dir, args)))(['status', '--porcelain']);
@@ -188,6 +217,33 @@ export async function release(options) {
188
217
  }],
189
218
  };
190
219
  }
220
+
221
+ // Push the tag even when reusing an existing one. The local tag may be the
222
+ // only copy: the previous attempt can have failed at `git push` after
223
+ // creating it. A push of a tag that is already on the remote at the same
224
+ // commit is a no-op, so this is safe to repeat and is what lets a retry
225
+ // finish the release instead of reporting success while origin still has no
226
+ // tag. A checkout with no origin has nowhere to push, so it keeps the old
227
+ // local resume behavior.
228
+ const pushTag = () => {
229
+ try {
230
+ gitRun(['push', 'origin', tag]);
231
+ return null;
232
+ } catch (error) {
233
+ // Keep the failure in the release's own vocabulary. Letting the raw
234
+ // execFileSync error escape hides both the stage and the fact that the
235
+ // tag now exists only locally, which is exactly what the retry needs.
236
+ return {
237
+ ok: false,
238
+ stage: 'git',
239
+ failures: [{
240
+ check: 'git',
241
+ message: `could not run \`git push origin ${tag}\`: ${gitFailureDetail(error)}. The tag is still local; fix the remote and re-run release to push it.`,
242
+ }],
243
+ };
244
+ }
245
+ };
246
+
191
247
  if (resuming === false) {
192
248
  // A resume does not create a tag, so the clean-tree rule that protects the
193
249
  // tag does not apply: the index write from a previous attempt is allowed to
@@ -202,8 +258,23 @@ export async function release(options) {
202
258
  };
203
259
  }
204
260
 
205
- gitRun(['tag', tag]);
206
- gitRun(['push', 'origin', tag]);
261
+ try {
262
+ gitRun(['tag', tag]);
263
+ } catch (error) {
264
+ return {
265
+ ok: false,
266
+ stage: 'git',
267
+ failures: [{
268
+ check: 'git',
269
+ message: `could not run \`git tag ${tag}\`: ${gitFailureDetail(error)}`,
270
+ }],
271
+ };
272
+ }
273
+ const failedPush = pushTag();
274
+ if (failedPush !== null) return failedPush;
275
+ } else if (hasRemote(root, 'origin', gitRun) === true) {
276
+ const failedPush = pushTag();
277
+ if (failedPush !== null) return failedPush;
207
278
  }
208
279
 
209
280
  // Not every plugin publishes from CI. `--publish` runs the publish here, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.21",
3
+ "version": "0.20.23",
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": {