@skitterbyte/skitterspec 23.23.0 → 23.23.1

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.
@@ -296,6 +296,14 @@ in that order, and stops at the first step that fails:
296
296
  **Then stop: the worktree is kept** (step 7). The branch is what the next
297
297
  `-hotfix.N` is cut from if this deploy fails, so it waits for the deploy.
298
298
 
299
+ **Two hotfixes shipped in one release.** Two hotfixes forked from the same tag
300
+ ship together by rebasing one onto the other and completing the **top** one
301
+ first: its land cuts the release holding both fixes. Then complete the other as
302
+ usual. Its land finds every fix commit already in that release, prints
303
+ `release: already shipped in <tag>`, cuts nothing, and carries only its
304
+ completion. `hotfix finish` takes that release, once it is on `origin`, in
305
+ place of a tag at HEAD.
306
+
299
307
  **A branch-based hotfix** (`> **Base version:** <branch>@<sha>`, from
300
308
  `hotfix.releaseBranch`) runs the same command and the same consent ask — the
301
309
  engine picks the path from the header. What differs is what it does:
@@ -474,6 +482,8 @@ skitterspec spec-env hotfix finish <name>
474
482
 
475
483
  It tears down only when the tree is clean, a release tag is at HEAD and the branch
476
484
  is on `origin` at HEAD, naming every check that fails; there is no `--force`.
485
+ A hotfix whose fix shipped in another hotfix's release passes instead when that
486
+ release is on `origin` and the base has every commit of its branch.
477
487
  Relay a refusal and stop. Report what it removed in `Worktree`.
478
488
 
479
489
 
@@ -312,6 +312,12 @@ config is absent.
312
312
  - Commit the fix to the `hotfix/<slug>` branch (this commit is what gets tagged
313
313
  and cherry-picked). Tick the Fix tasks; add a Changelog line.
314
314
 
315
+ **Shipping two hotfixes in one release.** When two hotfixes forked from the
316
+ same tag need to deploy together, rebase one onto the other and land the top
317
+ one: its release holds both fixes. Then `/spec-complete` the other. Its land
318
+ sees its fix already in that release (`release: already shipped in <tag>`),
319
+ cuts nothing, and carries only its completion to `main`.
320
+
315
321
  **Then refresh the mirror (only if a provider is installed).** The Fix tasks are
316
322
  ticked, so the repo is now the truth about this fix — and this skill can take a
317
323
  bug all the way to green without `/spec-next` ever running. Without a provider this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec",
3
- "version": "23.23.0",
3
+ "version": "23.23.1",
4
4
  "description": "Spec-driven development for Claude Code \u2014 a tracker-free filesystem workflow: lifecycle skills and per-spec isolation. For Linear sync, install @skitterbyte/skitterspec-linear instead.",
5
5
  "keywords": [
6
6
  "claude",
package/src/cli.js CHANGED
@@ -94,6 +94,7 @@ const {
94
94
  prefixOf,
95
95
  toRepoPath,
96
96
  projectRelative,
97
+ fromRepoPath,
97
98
  projectIn,
98
99
  projectLine,
99
100
  shellPath,
@@ -214,7 +215,7 @@ const {
214
215
  } = require('./env/epic.js')
215
216
  const { nextAction, readNextInputs, actionText } = require('./env/nextaction.js')
216
217
  const { epicTree, workingTree, worktreeOverview, epicsInFlight, memberReaders, epicAnswer } = require('./env/epicread.js')
217
- const { planHotfixLand, planBranchHotfixLand, planBranchHotfixFinish, planHotfixFinish } = require('./env/hotfix.js')
218
+ const { planHotfixLand, planBranchHotfixLand, planBranchHotfixFinish, planHotfixFinish, shippedCandidates } = require('./env/hotfix.js')
218
219
  const { runHotfixLand, describeStep: describeHotfixStep } = require('./env/hotfixland.js')
219
220
  const { planDev } = require('./env/dev.js')
220
221
  const { windowFor, windowLabel, humanLabel, localDay } = require('./tada/window.js')
@@ -3906,6 +3907,47 @@ function hotfixCarry(dir, spec, base, wtGit, released) {
3906
3907
  return { fixCommits, carry }
3907
3908
  }
3908
3909
 
3910
+ /**
3911
+ * The release that already holds this hotfix's fix, when another hotfix's land
3912
+ * cut it: two hotfixes from one tag, one rebased onto the other, and the top
3913
+ * one landed. `{ tag, fixCommits }`, or null.
3914
+ *
3915
+ * The fix commits are `baseRef..branch` minus the commits that touch only spec
3916
+ * documents — the completion committed after the other land is exactly such a
3917
+ * commit. Shipped means EVERY fix commit is in one release on the base's own
3918
+ * line (`shippedCandidates`), by ancestry or by patch (`missingOn`). No fix
3919
+ * commits at all is not "shipped": an empty set is contained in anything.
3920
+ *
3921
+ * WHAT WOULD FOOL IT: a tag on the line that holds the fix but never reached
3922
+ * prod — cut and abandoned, or a deploy that failed with nothing re-cut. The
3923
+ * land still asks the remote for the tag before carrying, and a fix added
3924
+ * after a failed deploy is a commit no tag holds, so it cuts again. A tag list,
3925
+ * prefix or commit git will not read routes to null, which cuts a release as
3926
+ * before (`.claude/rules/negative-checks.md` rule 4).
3927
+ */
3928
+ function hotfixShipped(spec, wtGit, existingTags) {
3929
+ const candidates = shippedCandidates(spec.baseRef, existingTags)
3930
+ if (!candidates.length) return null
3931
+ const listed = wtGit(['rev-list', '--reverse', `${spec.baseRef}..${spec.branch}`])
3932
+ if (!listed) return null
3933
+ const shown = gitReader(spec.projectPath || spec.worktreePath)(['rev-parse', '--show-prefix'])
3934
+ if (shown === null) return null
3935
+ const prefix = shown.replace(/\/$/, '')
3936
+ const fixCommits = listed
3937
+ .split('\n')
3938
+ .map((x) => x.trim())
3939
+ .filter(Boolean)
3940
+ .filter((sha) => {
3941
+ const out = wtGit(['diff-tree', '--no-commit-id', '--name-only', '-r', sha])
3942
+ const files = out ? out.split('\n').map((f) => f.trim()).filter(Boolean) : []
3943
+ // Unreadable or empty (a merge) counts as a fix: it must be contained.
3944
+ return !files.length || !files.every((f) => (fromRepoPath(f, prefix) || '').startsWith('specs/'))
3945
+ })
3946
+ if (!fixCommits.length) return null
3947
+ const tag = candidates.find((t) => missingOn(wtGit, t, fixCommits).length === 0)
3948
+ return tag ? { tag, fixCommits } : null
3949
+ }
3950
+
3909
3951
  function carryFiles(git, commits) {
3910
3952
  const files = new Set()
3911
3953
  for (const sha of commits) {
@@ -3970,9 +4012,32 @@ function hotfixFinish(dir, config, specArg, flags) {
3970
4012
  const lsRemote = wtGit(['ls-remote', '--heads', remote, `refs/heads/${spec.branch}`])
3971
4013
  const remoteHead = lsRemote === null ? undefined : lsRemote ? lsRemote.split(/\s+/)[0] : null
3972
4014
  const registry = readRegistry(dir, config)
4015
+ const tagsAtHead = (wtGit(['tag', '--points-at', 'HEAD']) || '').split('\n').filter(Boolean)
4016
+ // No release at HEAD: the fix may have shipped in another hotfix's release.
4017
+ // That stands in for the tag only once the release is on the remote and the
4018
+ // base has every commit of the branch, so deleting it loses nothing.
4019
+ let shipped = null
4020
+ if (!tagsAtHead.length && config.hotfix.cherryPickMain !== false) {
4021
+ const tagList = wtGit(['tag', '--list'])
4022
+ const found = hotfixShipped(spec, wtGit, tagList === null ? null : tagList.split('\n').map((t) => t.trim()).filter(Boolean))
4023
+ if (found) {
4024
+ const onRemote = wtGit(['ls-remote', '--tags', remote, `refs/tags/${found.tag}`])
4025
+ const git = gitReader(dir)
4026
+ const base = resolveBaseBranch(config, git)
4027
+ const all = (wtGit(['rev-list', `${spec.baseRef}..HEAD`]) || '').split('\n').map((x) => x.trim()).filter(Boolean)
4028
+ const refs = [base, `${remote}/${base}`].filter((r) => git(['rev-parse', '--verify', '--quiet', r]) !== null)
4029
+ shipped = {
4030
+ tag: found.tag,
4031
+ onRemote: onRemote === null ? undefined : Boolean(onRemote),
4032
+ base,
4033
+ carried: all.length > 0 && refs.some((r) => missingOn(git, r, all).length === 0),
4034
+ }
4035
+ }
4036
+ }
3973
4037
  const plan = planHotfixFinish(spec, {
3974
4038
  dirty: status === null || status.length > 0,
3975
- tagsAtHead: (wtGit(['tag', '--points-at', 'HEAD']) || '').split('\n').filter(Boolean),
4039
+ tagsAtHead,
4040
+ shipped,
3976
4041
  head,
3977
4042
  remoteHead,
3978
4043
  remote,
@@ -3997,7 +4062,7 @@ function hotfixFinish(dir, config, specArg, flags) {
3997
4062
  }
3998
4063
  say(`spec-env hotfix finish: ${spec.folder}`)
3999
4064
  say('')
4000
- say(` release: ${plan.releaseTag} (on ${remote} with ${spec.branch})`)
4065
+ say(` release: ${plan.releaseTag} (on ${remote}${plan.shipped ? `; ${spec.branch} carried to ${shipped.base}` : ` with ${spec.branch}`})`)
4001
4066
  say(` removed: ${spec.worktreePath}`)
4002
4067
  say(` deleted: ${spec.branch} (local; ${remote} keeps it)`)
4003
4068
  }
@@ -4133,14 +4198,17 @@ function specEnvHotfix(dir, config, positional, flags) {
4133
4198
  const record = readHotfixRecord(dir, config, spec.folder)
4134
4199
  const atHead = (wtGit(['tag', '--points-at', 'HEAD']) || '').split('\n').map((s) => s.trim())
4135
4200
  const released = record && record.tag && atHead.includes(record.tag) ? record : null
4201
+ // No release of its own, but its fix may have shipped in another hotfix's.
4202
+ const shipped = released ? null : hotfixShipped(spec, wtGit, tagList === null ? null : existingTags)
4136
4203
  // Already published? Asked of the remote itself, for the one tag that could
4137
4204
  // be there. Only a non-empty answer counts: an unreachable remote is "cannot
4138
4205
  // tell", and cannot-tell holds rather than carrying a fix whose deploy tag
4139
4206
  // may not be public (`.claude/rules/negative-checks.md` rule 4).
4140
4207
  const remote = 'origin'
4208
+ const publishing = released || shipped
4141
4209
  const pushed =
4142
- released !== null &&
4143
- Boolean(wtGit(['ls-remote', '--tags', remote, `refs/tags/${released.tag}`]))
4210
+ publishing !== null &&
4211
+ Boolean(wtGit(['ls-remote', '--tags', remote, `refs/tags/${publishing.tag}`]))
4144
4212
 
4145
4213
  const carry = hotfixCarry(dir, spec, base, wtGit, released)
4146
4214
 
@@ -4166,6 +4234,7 @@ function specEnvHotfix(dir, config, positional, flags) {
4166
4234
  extraTargets,
4167
4235
  existingTags,
4168
4236
  released,
4237
+ shipped,
4169
4238
  push: flags.push === true,
4170
4239
  pushed,
4171
4240
  remote,
package/src/env/hotfix.js CHANGED
@@ -110,6 +110,30 @@ function nextHotfixTag(baseTag, existingTags) {
110
110
  return `${base.root}-hotfix.${n + 1}`
111
111
  }
112
112
 
113
+ /**
114
+ * The releases a hotfix forked from `baseRef` could already have shipped in:
115
+ * the later releases on the base's own line — `<root>-hotfix.N` and the
116
+ * patch-bumped `X.Y.(Z+n)` — oldest first, so the first that holds the fix is
117
+ * the one that shipped it. Pre-releases and other minor lines never count.
118
+ *
119
+ * Empty for a base or tag list that cannot be read, which leaves the land to
120
+ * cut a release as it always has (`.claude/rules/negative-checks.md` rule 4).
121
+ */
122
+ function shippedCandidates(baseRef, tags) {
123
+ const base = parseTag(baseRef)
124
+ if (!base || base.suffix || !Array.isArray(tags)) return []
125
+ return tags
126
+ .filter((t) => {
127
+ const p = parseTag(t)
128
+ return (
129
+ p && !p.suffix && p.prefix === base.prefix &&
130
+ p.core[0] === base.core[0] && p.core[1] === base.core[1] &&
131
+ compareTags(t, baseRef) > 0
132
+ )
133
+ })
134
+ .sort(compareTags)
135
+ }
136
+
113
137
  const BUMPS = ['patch', 'hotfix-suffix']
114
138
 
115
139
  // The tag `hotfix.bump` asks for. An unknown strategy throws rather than
@@ -159,7 +183,8 @@ function tagSlug(tag) {
159
183
  * @param {object} config normalised env config (reads `config.hotfix`).
160
184
  * @param {object} ctx { worktreeState:{dirty}, aheadOfBase, fixRange, mainRepoPath,
161
185
  * base, extraTargets: string[], existingTags: string[],
162
- * released?, push?: boolean, pushed?: boolean, remote?,
186
+ * released?, shipped?: { tag }, push?: boolean,
187
+ * pushed?: boolean, remote?,
163
188
  * fixCommits?: string[],
164
189
  * carry?: { strategy: 'inplace'|'worktree'|'dirty', path,
165
190
  * tmpPath?, commits: string[] } }
@@ -224,6 +249,17 @@ function planHotfixLand(spec, config, ctx) {
224
249
  prodTag = c.released.tag
225
250
  taken.add(prodTag)
226
251
  steps.push({ kind: 'release', via: 'recorded', tag: prodTag, release: c.released })
252
+ } else if (c.shipped && c.shipped.tag) {
253
+ // Another hotfix's land already released this one's fix — two hotfixes
254
+ // from one tag, one rebased onto the other and landed on top. Cutting
255
+ // again would deploy a release holding only this fix.
256
+ prodTag = c.shipped.tag
257
+ steps.push({
258
+ kind: 'release',
259
+ via: 'shipped',
260
+ tag: prodTag,
261
+ release: { tag: prodTag, version: prodTag.replace(/^\D*/, ''), baseTag: baseRef, branch, versionCommit: null, pushed: false },
262
+ })
227
263
  } else if (releaseWith) {
228
264
  // The tag is the command's to choose and is unknown until it has run, so
229
265
  // there is nothing to check a collision against here — the command refuses
@@ -587,8 +623,13 @@ function planBranchHotfixFinish(spec, state) {
587
623
  * And DELIBERATELY NO `--force` — the guards are the point of the verb, and
588
624
  * `spec-env down --force` already exists for anyone who means to override them.
589
625
  *
626
+ * ONE OTHER WAY PAST the last two: no tag at HEAD, but the fix
627
+ * shipped in another hotfix's release (`shipped`) — that tag on the remote, and
628
+ * every commit of the branch on the base.
629
+ *
590
630
  * state: { dirty, tagsAtHead: string[], head, remoteHead: string|null|undefined,
591
- * remote, mainRepoPath, hasSlot }
631
+ * remote, mainRepoPath, hasSlot,
632
+ * shipped?: { tag, onRemote: true|false|undefined, base, carried } }
592
633
  * remoteHead: the branch's sha on the remote; null = not there;
593
634
  * undefined = the remote could not be asked.
594
635
  */
@@ -597,15 +638,25 @@ function planHotfixFinish(spec, state) {
597
638
  const remote = s.remote || 'origin'
598
639
  const reasons = []
599
640
  if (s.dirty) reasons.push('the worktree has uncommitted changes')
600
- const releaseTag = (s.tagsAtHead || []).find((t) => parseTag(t) !== null) || null
601
- if (!releaseTag) {
641
+ const atHead = (s.tagsAtHead || []).find((t) => parseTag(t) !== null) || null
642
+ // Shipped in another hotfix's release: its tag on the remote and the whole
643
+ // branch carried to the base are the copies that outlive `branch -D`, so
644
+ // they stand in for both the tag at HEAD and the branch on the remote.
645
+ const shipped = !atHead && s.shipped ? s.shipped : null
646
+ const releaseTag = atHead || (shipped && shipped.tag) || null
647
+ if (shipped) {
648
+ if (shipped.onRemote === undefined) reasons.push(`cannot tell whether ${shipped.tag} is on ${remote} — the remote did not answer`)
649
+ else if (!shipped.onRemote) reasons.push(`${shipped.tag} holds this fix but is not on ${remote} — push it first`)
650
+ if (!shipped.carried) reasons.push(`${shipped.base} does not have every commit of ${spec.branch} — run \`spec-env hotfix land\` to carry them`)
651
+ } else if (!releaseTag) {
602
652
  reasons.push('no release tag at HEAD — run `spec-env hotfix land` first')
603
653
  }
604
- if (s.remoteHead === undefined) {
654
+ // Shipped: the branch itself need not be on the remote — see above.
655
+ if (!shipped && s.remoteHead === undefined) {
605
656
  reasons.push(`cannot tell whether ${spec.branch} is on ${remote} — the remote did not answer`)
606
- } else if (s.remoteHead === null) {
657
+ } else if (!shipped && s.remoteHead === null) {
607
658
  reasons.push(`${spec.branch} is not on ${remote} — push it (\`hotfix land --push\`)`)
608
- } else if (s.head && s.remoteHead !== s.head) {
659
+ } else if (!shipped && s.head && s.remoteHead !== s.head) {
609
660
  reasons.push(`${remote}/${spec.branch} is not at HEAD — push the branch first`)
610
661
  }
611
662
  // A Docker stack has volumes and a slot that only `down` knows how to free.
@@ -618,6 +669,7 @@ function planHotfixFinish(spec, state) {
618
669
  blocked: false,
619
670
  reasons: [],
620
671
  releaseTag,
672
+ shipped: Boolean(shipped),
621
673
  argvs: [
622
674
  ['-C', root, 'worktree', 'remove', spec.worktreePath],
623
675
  // -D, not -d: the branch is never merged into main (see above), and its
@@ -632,6 +684,7 @@ module.exports = {
632
684
  compareTags,
633
685
  nextHotfixTag,
634
686
  nextTag,
687
+ shippedCandidates,
635
688
  BUMPS,
636
689
  tagSlug,
637
690
  planHotfixLand,
@@ -71,6 +71,7 @@ function describeStep(step) {
71
71
  case 'release':
72
72
  if (step.via === 'command') return `release: ${step.command}`
73
73
  if (step.via === 'recorded') return `release: ${step.tag} (cut earlier — not re-run)`
74
+ if (step.via === 'shipped') return `release: already shipped in ${step.tag}`
74
75
  return `release: git tag ${step.tag}${step.at ? ` ${step.at}` : ''}`
75
76
  case 'push': {
76
77
  if (step.via === 'remote') {
@@ -133,7 +134,7 @@ function why(res) {
133
134
  }
134
135
 
135
136
  function runRelease(step, ctx) {
136
- if (step.via === 'recorded') {
137
+ if (step.via === 'recorded' || step.via === 'shipped') {
137
138
  return { outcome: 'skipped', line: describeStep(step), release: step.release }
138
139
  }
139
140
  if (step.via === 'tag') {