dsh-plugin-toolkit 0.20.6 → 0.20.8

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,26 @@
1
+ ## 0.20.8
2
+
3
+ - **`dsh-plugin release` resumes when the tag already points at HEAD.** A
4
+ publish that stopped after the tag was pushed — at the registry wait, or at a
5
+ later failure — can be re-run: the existing `plugin-v<version>` tag is reused
6
+ rather than recreated, and the release continues with the registry wait and
7
+ the index write. Because a resume creates no tag, the index entry left by the
8
+ previous attempt may be the only uncommitted change and does not block it.
9
+ - **`dsh-plugin release` refuses a tag at another commit and prints the
10
+ recovery.** When `plugin-v<version>` exists but points somewhere other than
11
+ HEAD, the release exits `1` with the tag, the commit it points at, HEAD, and
12
+ the exact `git tag -d` and `git push --delete` commands that remove the stale
13
+ tag before a re-run.
14
+
15
+ ## 0.20.7
16
+
17
+ - **`dsh-plugin release --budget` rejects a value that is not a positive
18
+ number of seconds.** `--budget 8m`, `--budget 0`, `--budget -1` and a
19
+ missing value now stop during flag parsing with `--budget needs a positive
20
+ number of seconds`, exit `2`, and create neither a local nor a remote tag,
21
+ instead of pushing the tag and then waiting on a nonsensical interval. A
22
+ positive value still reaches the registry wait.
23
+
1
24
  ## 0.20.6
2
25
 
3
26
  - **`dsh-plugin doctor` reads `files` globs the way `npm pack` does.** A
package/README.md CHANGED
@@ -903,7 +903,7 @@ The install reports success and nothing shows up. In this order:
903
903
  `release` runs the sequence in the order that fails cheapest first:
904
904
 
905
905
  1. Preflight (`doctor`) — stop before tagging anything.
906
- 2. Refuse to run on a dirty tree, or if the tag already exists.
906
+ 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.
907
907
  3. Create and push the tag, which starts the plugin's release workflow.
908
908
  4. Poll the registry until it actually serves that version, reporting each wait.
909
909
  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.
@@ -921,7 +921,19 @@ checks settled after 1s (1 look(s))
921
921
  merged
922
922
  ```
923
923
 
924
- 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: the same version with the same publish time is a no-op.
924
+ 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.
925
+
926
+ If that tag points at another commit, the release does not move it. It exits `1`
927
+ and names the tag, the commit it points at, HEAD, and the recovery:
928
+
929
+ ```
930
+ dsh-plugin release stopped at tag
931
+ ✗ tag: plugin-v0.4.0 already exists and does not point at HEAD: tag plugin-v0.4.0 is at <tag-sha>, HEAD is <head-sha>. Delete the stale tag with `git tag -d plugin-v0.4.0` and `git push --delete origin plugin-v0.4.0`, then re-run release.
932
+ ```
933
+
934
+ Run those two commands when the old tag really was a mistake, then release
935
+ again. A tag at HEAD needs no separate `--resume`: it takes the resume path
936
+ automatically.
925
937
 
926
938
  ### When nothing publishes for you
927
939
 
@@ -965,8 +977,18 @@ Honest list, so nobody plans around a feature that does not exist:
965
977
  ## Changelog
966
978
 
967
979
  [`CHANGELOG.md`](CHANGELOG.md) lists what changed in each release, including
968
- the `0.20.6` fixes: `doctor` reads a `files` glob the way `npm pack` does, so a
969
- `"files": ["*.js"]` entry no longer hides a nested `exports["./client"]`, and
980
+ the `0.20.8` fixes: `release` resumes when `plugin-v<version>` already points at
981
+ HEAD — reusing the tag and continuing to the registry wait instead of failing —
982
+ and refuses a tag at another commit, printing the tag, the commit it points at,
983
+ HEAD and the exact `git tag -d` / `git push --delete` recovery commands. A
984
+ resume does not recreate the tag, so an index entry left by the aborted run does
985
+ not block it. The `0.20.7` fix is recorded too: `release --budget` rejects a
986
+ value that is not a positive number of seconds — `8m`, `0`, `-1` or a missing
987
+ value — with exit `2` before
988
+ any local or remote tag is created, instead of pushing the tag and then waiting.
989
+ The `0.20.6` fixes are recorded too: `doctor` reads a `files` glob the way
990
+ `npm pack` does, so a `"files": ["*.js"]` entry no longer hides a nested
991
+ `exports["./client"]`, and
970
992
  `doctor --remote`/`audit --remote` apply the same files-list check instead of
971
993
  printing `clean`. The `0.20.5` fixes are recorded too: `doctor` reads a
972
994
  `package.json` saved with a UTF-8 BOM instead of failing with a bare
package/lib/cli.mjs CHANGED
@@ -100,7 +100,7 @@ Flags
100
100
  --market <dir> with release: a checkout of the repository that holds the index
101
101
  --publish with release: run npm publish here, for repos without a publish workflow
102
102
  --tag-prefix <prefix> default plugin-v
103
- --budget <seconds> how long to wait for npm, default 480
103
+ --budget <seconds> how long to wait for npm, a positive number, default 480
104
104
  --pr commit the index on a branch, push it, open the pull request
105
105
  --merge with --pr: wait for checks, then squash-merge
106
106
  --base <branch> base branch for the pull request, default main
@@ -127,7 +127,18 @@ function flags(argv) {
127
127
  else if (token === '--log') parsed.log = argv[++index];
128
128
  else if (token === '--index') parsed.index = argv[++index];
129
129
  else if (token === '--tag-prefix') parsed.tagPrefix = argv[++index];
130
- else if (token === '--budget') parsed.budget = Number(argv[++index]);
130
+ else if (token === '--budget') {
131
+ // A budget of `8m`, `0`, or `-1` is not a wait, and by the time the
132
+ // registry loop notices, the tag is already pushed. Validate the flag
133
+ // here, before any command can reach `git tag`.
134
+ const raw = argv[++index];
135
+ const seconds = Number(raw);
136
+ if (raw === undefined || String(raw).trim() === '' || Number.isFinite(seconds) === false || seconds <= 0) {
137
+ parsed.budgetError = raw;
138
+ } else {
139
+ parsed.budget = seconds;
140
+ }
141
+ }
131
142
  else if (token === '--slot') parsed.slot = argv[++index];
132
143
  else if (token === '--surface') parsed.surface = argv[++index];
133
144
  else if (token === '--html') parsed.html = true;
@@ -200,6 +211,14 @@ export async function run(argv, io = console, deps = {}) {
200
211
  const options = flags(rest);
201
212
  const dir = path.resolve(options.positional[0] ?? '.');
202
213
 
214
+ // `--budget` is validated while parsing, so an invalid value stops here:
215
+ // before the release sequence reads the manifest, tags, or pushes anything.
216
+ if (Object.prototype.hasOwnProperty.call(options, 'budgetError') === true) {
217
+ const got = options.budgetError === undefined ? 'nothing' : JSON.stringify(options.budgetError);
218
+ io.error(`dsh-plugin: --budget needs a positive number of seconds, got ${got}`);
219
+ return 2;
220
+ }
221
+
203
222
  if (command === undefined || command === 'help' || command === '--help') {
204
223
  io.log(HELP);
205
224
  return 0;
package/lib/release.mjs CHANGED
@@ -38,6 +38,44 @@ export function tagExists(dir, tag, run) {
38
38
  }
39
39
  }
40
40
 
41
+ /** The commit a tag names, or null when it cannot be resolved. */
42
+ export function tagCommit(dir, tag, run) {
43
+ const runGit = run ?? ((args) => git(dir, args));
44
+ try {
45
+ // `^{commit}` resolves an annotated tag to the commit it points at.
46
+ return runGit(['rev-parse', `refs/tags/${tag}^{commit}`]);
47
+ } catch {
48
+ try {
49
+ return runGit(['rev-parse', `refs/tags/${tag}`]);
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+ }
55
+
56
+ /** The current HEAD commit, or null when it cannot be resolved. */
57
+ export function headCommit(dir, run) {
58
+ const runGit = run ?? ((args) => git(dir, args));
59
+ try {
60
+ return runGit(['rev-parse', 'HEAD']);
61
+ } catch {
62
+ return null;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * True when the tag exists and names the same commit as HEAD. A re-run after a
68
+ * failure has to be able to finish the release without moving the tag: the tag
69
+ * is what started the publish, so recreating it would be both unnecessary and
70
+ * wrong.
71
+ */
72
+ export function tagPointsAtHead(dir, tag, run) {
73
+ const runGit = run ?? ((args) => git(dir, args));
74
+ const head = headCommit(dir, runGit);
75
+ if (head === null) return false;
76
+ return tagCommit(dir, tag, runGit) === head;
77
+ }
78
+
41
79
  export function workingTreeIsClean(dir, run) {
42
80
  return (run ?? ((args) => git(dir, args)))(['status', '--porcelain']) === '';
43
81
  }
@@ -110,21 +148,41 @@ export async function release(options) {
110
148
  const version = report.manifest.version;
111
149
  const tag = tagName(version, tagPrefix);
112
150
 
113
- if (tagExists(dir, tag, gitRun) === true) {
114
- return { ok: false, stage: 'tag', failures: [{ check: 'tag', message: `${tag} already exists` }] };
115
- }
116
- if (workingTreeIsClean(dir, gitRun) === false) {
117
- const dirty = dirtyPaths(dir, 3, gitRun);
118
- const listed = dirty.length > 0 ? ` (${dirty.join(', ')})` : '';
151
+ const resuming = tagExists(dir, tag, gitRun) === true;
152
+ if (resuming === true && tagPointsAtHead(dir, tag, gitRun) === false) {
153
+ // A tag at another commit is not a resume: moving it would rewrite what the
154
+ // earlier release published. Name where it points, where HEAD is, and the
155
+ // exact commands that remove it so the next attempt can tag this commit.
156
+ const target = tagCommit(dir, tag, gitRun);
157
+ const head = headCommit(dir, gitRun);
158
+ const targetText = target ?? 'an unknown commit';
159
+ const headText = head ?? 'an unknown commit';
119
160
  return {
120
161
  ok: false,
121
- stage: 'git',
122
- failures: [{ check: 'git', message: `the working tree has uncommitted changes${listed}` }],
162
+ stage: 'tag',
163
+ failures: [{
164
+ check: 'tag',
165
+ message: `${tag} already exists and does not point at HEAD: tag ${tag} is at ${targetText}, HEAD is ${headText}. Delete the stale tag with \`git tag -d ${tag}\` and \`git push --delete origin ${tag}\`, then re-run release.`,
166
+ }],
123
167
  };
124
168
  }
169
+ if (resuming === false) {
170
+ // A resume does not create a tag, so the clean-tree rule that protects the
171
+ // tag does not apply: the index write from a previous attempt is allowed to
172
+ // be the only uncommitted change.
173
+ if (workingTreeIsClean(dir, gitRun) === false) {
174
+ const dirty = dirtyPaths(dir, 3, gitRun);
175
+ const listed = dirty.length > 0 ? ` (${dirty.join(', ')})` : '';
176
+ return {
177
+ ok: false,
178
+ stage: 'git',
179
+ failures: [{ check: 'git', message: `the working tree has uncommitted changes${listed}` }],
180
+ };
181
+ }
125
182
 
126
- gitRun(['tag', tag]);
127
- gitRun(['push', 'origin', tag]);
183
+ gitRun(['tag', tag]);
184
+ gitRun(['push', 'origin', tag]);
185
+ }
128
186
 
129
187
  // Not every plugin publishes from CI. `--publish` runs the publish here, so
130
188
  // the same command covers both kinds of repository.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.6",
3
+ "version": "0.20.8",
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": {