@skitterbyte/skitterspec-azure-boards 3.0.0 → 3.1.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.
@@ -295,7 +295,7 @@ be several:
295
295
  dated Changelog line quoting the report.
296
296
  - **Work outside this spec.** For example: a different feature, or a defect in
297
297
  code the spec never touched. Propose the right door with a one-line reason,
298
- confirm first, as `.claude/rules/spec-planning.md`'s kind routing does. A
298
+ confirm first, as `.claude/skills/spec/kind-routing.md` does. A
299
299
  defect goes to `/spec-bug`; new behaviour goes to `/spec`. On a no, carry
300
300
  on with whatever part of the message was this spec's.
301
301
 
@@ -277,7 +277,7 @@ API that moved, a task the code already does. `Spec` carries the status the
277
277
  review leaves it in, which is the answer to "can I start this?".
278
278
 
279
279
  **Where step 4b rendered a page the run is waiting**, so the block omits the
280
- `Review` row and ends on the banner from `.claude/rules/spec-reports.md` — the
280
+ `Review` row and ends on the banner from `.claude/skills/spec-diff/review-wait.md` — the
281
281
  tier stack copied from the engine's own lines, never one link chosen for the
282
282
  reader:
283
283
 
@@ -0,0 +1,90 @@
1
+ # Isolation, worktrees and the live overlay
2
+
3
+ Applies only when `specs/.core/env.config.json` exists. Without it, every skill
4
+ works in the checkout it is standing in.
5
+
6
+ ## Workspace modes (`mode` in `env.config.json`)
7
+
8
+ - **`worktree`** (the default): each spec gets its own checkout, so several can
9
+ be in flight and `main` stays free. `/spec-start` builds the branch there,
10
+ moves the session in with a plain `cd`, and asks whether to build phase 1. The
11
+ primary checkout stays on the base branch, so the base branch still shows an
12
+ in-flight spec under `backlog`. `skitterspec status` reads each worktree's own
13
+ copy.
14
+ - **`checkout`**: the branch is built in the primary checkout, one spec at a
15
+ time, and the build carries straight on. `/spec-connect` and `/spec-live` do
16
+ not apply and say so.
17
+
18
+ **Omit the spec name anywhere** and the engine uses the worktree you are
19
+ standing in, or else the only provisioned spec.
20
+
21
+ ## Per-spec isolation
22
+
23
+ `/spec-start` gives every in-progress spec its own worktree. Docker is a
24
+ per-spec escalation: `> **Stack:** worktree` (the default) or
25
+ `worktree + docker` when the spec touches the database or stateful services.
26
+ `/spec-start` brings up a namespaced stack only for the latter, and starts the
27
+ host **dev servers** (`dev` in `env.config.json`) on the spec's ports.
28
+ `/spec-connect <name>` maps that spec onto your normal `localhost` ports, and
29
+ `/spec-connect main` hands them back. Teardown is part of `/spec-complete` and
30
+ `/spec-cancel`, which drop the spec's test-DB volume and offer to prune orphans
31
+ first.
32
+
33
+ The engine is `skitterspec spec-env
34
+ <up|bootstrap|nospec|main|project|down|prune|dev|connect|integrate|disposition|handoff|hotfix|live|review|stage|checks|status|resolve|resume|base>`.
35
+ `up` plans the fork, and **`bootstrap` runs the worktree's own steps**: seeding
36
+ the gitignored files, the env file, `setup` and the stack. Never reconstruct
37
+ those steps as shell commands.
38
+
39
+ A **hotfix** is the one spec that does not fork from `main`. `/spec-hotfix` forks
40
+ from a release tag, and `/spec-complete` lands it through `spec-env hotfix land`
41
+ (release, push on consent, carry to `main` without the version commit). Its
42
+ worktree stays until the deploy is out and a second `/spec-complete` runs
43
+ `spec-env hotfix finish`.
44
+
45
+ ## The live overlay (`/spec-live`)
46
+
47
+ `/spec-connect` runs a spec's own dev stack. The live overlay instead reuses the
48
+ dev server you already have running. `/spec-live <spec>`, or a bare
49
+ `/spec-live`, rebases the branch onto the base (the fetched remote base under PR
50
+ landing), frees it from its worktree, and checks it out
51
+ **in the primary checkout**, so the running server hot-reloads it. The checked-out branch is the
52
+ lock, so only one spec is live at a time. `/spec-live main` hands the checkout
53
+ back. Fixes made while live commit straight onto the branch, and
54
+ `/spec-complete` knows about live specs and lands them.
55
+
56
+ - It is for **testing** a code-only spec, not for starting work, and no
57
+ lifecycle skill invokes it.
58
+ - It **refuses** stateful specs (`Stack: worktree + docker`, or a branch that
59
+ touches migrations). Use `/spec-connect` and a Docker stack for those.
60
+ - `live.afterSwitch` entries (`{ run, when }`) run in the primary checkout after
61
+ taking and after releasing. The engine runs them itself.
62
+ - The engine is `skitterspec spec-env live <take|release|abort|status>`.
63
+
64
+ ## Authoring a spec off the base branch
65
+
66
+ With isolation, `/spec` grills first, then runs `spec-env up <name> --docs`,
67
+ moves into that worktree and writes the spec there. `--docs` skips `setup` and
68
+ Docker, so the tree costs one `git worktree add`. `/spec-start` later re-runs
69
+ `up` without the flag, and the install happens then.
70
+
71
+ Both committing verdicts on the authoring page (`Commit & Start`, `Commit`)
72
+ commit on the branch, then `spec-env integrate` rebases and fast-forwards, so
73
+ the base gains the spec as one commit. `Commit & Start` keeps the worktree and
74
+ carries into `/spec-start`. `Commit` tears it down. The authoring page arms
75
+ nothing, because a backlog spec owes no phase.
76
+
77
+ **`land.specDocs: "branch"`** (the default once a ticketing provider is
78
+ configured and the key is unset) keeps the spec on its feature branch, to land
79
+ with the work. Both verdicts commit and skip the integrate, plain `Commit` keeps
80
+ the branch and worktree, and the backlog is found through the tracker. Setting
81
+ the key, to either value, always wins.
82
+
83
+ ## Staging one spec and not another
84
+
85
+ `skitterspec spec-env stage [<spec>] [--json]` splits the uncommitted tree you
86
+ are standing in into what belongs to this spec and what does not. **Owned** is
87
+ the spec's folder in any bucket plus each `spec.companionPaths` entry. Code is
88
+ always **foreign**, because the commits this bounds are the lifecycle ones.
89
+ Nothing here refuses. Commit with the pathspec on both `git add` and
90
+ `git commit`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec-azure-boards",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Spec-driven development for Claude Code, with one-way Azure Boards sync — a superset of @skitterbyte/skitterspec: the base filesystem workflow plus /spec-status · /spec-push · /spec-claim and the spec-sync CLI, mirroring specs to Azure DevOps work items with parent/child hierarchy, assignment and a release work item per tag. The repo is canonical; Boards is a generated mirror. Install this OR the base OR one other superset — exactly one.",
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,
@@ -0,0 +1,43 @@
1
+ 'use strict'
2
+
3
+ // Moving a project's conventions out of the old `spec-planning.md`
4
+ // (feat-rules-budget). Before that spec, the typecheck and test commands lived
5
+ // in a "Project conventions (fill this in)" section inside the managed rule.
6
+ // Filling it in made the whole 66k file "customized", so `update` kept it and
7
+ // the host went on loading all of it every session.
8
+ //
9
+ // `split` cuts that section out. `KNOWN` holds the hash of every shipped
10
+ // version with the section cut out, so a file whose ONLY edits were in that
11
+ // section hashes to a known value, and its edits can be carried over to
12
+ // `project-conventions.md` safely. Any other edit is cannot-tell, and the file
13
+ // is kept (`.claude/rules/negative-checks.md` rule 4).
14
+
15
+ const crypto = require('crypto')
16
+
17
+ const HEADING = /^## Project conventions \(fill this in\)[^\n]*\n/m
18
+
19
+ // `{ rest, body }`: `rest` is the file without the section, `body` the
20
+ // section's text below its heading. `null` when the section is not there.
21
+ function split(text) {
22
+ const t = text.replace(/\r\n/g, '\n')
23
+ const m = HEADING.exec(t)
24
+ if (!m) return null
25
+ const from = m.index
26
+ const after = from + m[0].length
27
+ const next = t.slice(after).search(/^## /m)
28
+ const end = next === -1 ? t.length : after + next
29
+ return { rest: t.slice(0, from) + t.slice(end), body: t.slice(after, end).trim() }
30
+ }
31
+
32
+ function strippedHash(text) {
33
+ const parts = split(text)
34
+ return parts && crypto.createHash('sha1').update(parts.rest).digest('hex')
35
+ }
36
+
37
+ let known = null
38
+ function KNOWN() {
39
+ if (!known) known = new Set(require('./spec-planning-history.json').stripped)
40
+ return known
41
+ }
42
+
43
+ module.exports = { split, strippedHash, KNOWN }
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') {
package/src/init.js CHANGED
@@ -10,6 +10,7 @@ const { ensureHooks, removeHooks, HOOKS: GATE_HOOKS } = require('./env/hooks.js'
10
10
  const { repoInfo, expandTokens, describeBaseBranch, baseRemote } = require('./env/resolve.js')
11
11
  const { primaryAnchor } = require('./env/project.js')
12
12
  const { setProjectKeys } = require('./env/projectedit.js')
13
+ const { split, strippedHash, KNOWN } = require('./conventions.js')
13
14
 
14
15
  const ASSETS = path.join(__dirname, '..', 'assets')
15
16
 
@@ -27,6 +28,25 @@ function listSkills() {
27
28
  .sort()
28
29
  }
29
30
 
31
+ // Every file a skill ships, relative to its folder, `SKILL.md` first. A skill's
32
+ // supporting files (`<topic>.md` beside `SKILL.md`) load only when the skill
33
+ // reads them, which is what lets content one skill needs leave the
34
+ // always-loaded rules (feat-rules-budget). Dotfiles are not shipped.
35
+ function listSkillFiles(name) {
36
+ const root = path.join(ASSETS, 'skills', name)
37
+ const out = []
38
+ const walk = (d) => {
39
+ for (const e of fs.readdirSync(d, { withFileTypes: true })) {
40
+ if (e.name.startsWith('.')) continue
41
+ const p = path.join(d, e.name)
42
+ if (e.isDirectory()) walk(p)
43
+ else out.push(path.relative(root, p))
44
+ }
45
+ }
46
+ walk(root)
47
+ return out.sort((a, b) => (a === 'SKILL.md' ? -1 : b === 'SKILL.md' ? 1 : a.localeCompare(b)))
48
+ }
49
+
30
50
  // Slash commands shipped as `assets/commands/*.md`, installed to
31
51
  // `.claude/commands/`. Discovered from the bundled tree exactly like skills, so
32
52
  // each distribution installs precisely what it ships.
@@ -478,7 +498,9 @@ function managedTargets(dir) {
478
498
  abs: targetAbs,
479
499
  bundled: render(fs.readFileSync(path.join(ASSETS, assetRel), 'utf8'), dir),
480
500
  })
481
- for (const name of SKILLS) add(path.join('skills', name, 'SKILL.md'), path.join(dir, '.claude', 'skills', name, 'SKILL.md'))
501
+ for (const name of SKILLS) {
502
+ for (const file of listSkillFiles(name)) add(path.join('skills', name, file), path.join(dir, '.claude', 'skills', name, file))
503
+ }
482
504
  for (const name of COMMANDS)
483
505
  add(path.join('commands', name), path.join(dir, '.claude', 'commands', name), renderCommand)
484
506
  for (const name of RULES) add(path.join('rules', name), path.join(dir, '.claude', 'rules', name))
@@ -686,12 +708,9 @@ function copyAsset(dir, assetRelPath, targetAbs, opts) {
686
708
 
687
709
  function installSkills(dir, opts) {
688
710
  for (const name of SKILLS) {
689
- copyAsset(
690
- dir,
691
- path.join('skills', name, 'SKILL.md'),
692
- path.join(dir, '.claude', 'skills', name, 'SKILL.md'),
693
- opts,
694
- )
711
+ for (const file of listSkillFiles(name)) {
712
+ copyAsset(dir, path.join('skills', name, file), path.join(dir, '.claude', 'skills', name, file), opts)
713
+ }
695
714
  }
696
715
  }
697
716
 
@@ -732,6 +751,99 @@ function installRule(dir, opts) {
732
751
  }
733
752
  }
734
753
 
754
+ // The project's own conventions — its typecheck and test commands — written
755
+ // once from a template and then the project's to edit. It is deliberately NOT
756
+ // a managed file: no manifest entry, never overwritten (not even by
757
+ // `--force`), never pruned, so filling it in trips no hash guard. That is the
758
+ // point of it: the conventions used to live inside the managed
759
+ // `spec-planning.md`, where tailoring them made the whole file "customized".
760
+ const CONVENTIONS_FILE = path.join('.claude', 'rules', 'project-conventions.md')
761
+
762
+ function installConventions(dir) {
763
+ const target = path.join(dir, CONVENTIONS_FILE)
764
+ if (fs.existsSync(target)) return // the project's, whatever it holds
765
+ ensureDir(path.dirname(target))
766
+ fs.writeFileSync(target, fs.readFileSync(path.join(ASSETS, 'project-conventions.md'), 'utf8'))
767
+ report.created.push(rel(dir, target))
768
+ }
769
+
770
+ // A customized `spec-planning.md` from before feat-rules-budget, whose only
771
+ // edits are in its old "Project conventions" section: carry the section into
772
+ // `project-conventions.md` and take the new rule, so the host stops loading
773
+ // 66k of the old one. Runs before the managed loop, which then finds the rule
774
+ // pristine and records it. Under `--force` it still runs first, so a
775
+ // forced update keeps the conventions the force would otherwise overwrite.
776
+ //
777
+ // WHAT WOULD FOOL THIS: an edit that exactly restores some other shipped
778
+ // version's text outside the section. That is still unedited text we shipped,
779
+ // so replacing it loses nothing. Everything else is cannot-tell: the file is
780
+ // kept and a warning says how to finish by hand (negative-checks.md rule 4).
781
+ function migrateConventions(dir, manifest, force) {
782
+ const relPath = '.claude/rules/spec-planning.md'
783
+ const target = managedTargets(dir).find((t) => t.relPath === relPath)
784
+ if (!target) return
785
+ const state = managedState(dir, relPath, manifest, target.bundled)
786
+ if (state !== 'customized' && state !== 'adopted') return
787
+ const onDisk = fs.readFileSync(target.abs, 'utf8')
788
+ const conventions = path.join(dir, CONVENTIONS_FILE)
789
+ const template = fs.readFileSync(path.join(ASSETS, 'project-conventions.md'), 'utf8')
790
+ const parts = split(onDisk)
791
+ const known = parts && KNOWN().has(strippedHash(onDisk))
792
+ const free = !fs.existsSync(conventions) || sameContent(fs.readFileSync(conventions, 'utf8'), template)
793
+ if (!known || !free) {
794
+ if (force) return // --force replaces the file anyway; nothing to advise
795
+ report.warnings.push(
796
+ `${relPath} kept (${Math.round(onDisk.length / 1000)}k chars, edited) — it loads in every session. ` +
797
+ `Move your edits into ${CONVENTIONS_FILE.split(path.sep).join('/')}, then run \`skitterspec update --force\``,
798
+ )
799
+ return
800
+ }
801
+ ensureDir(path.dirname(conventions))
802
+ fs.writeFileSync(conventions, `# Project conventions\n\n${parts.body}\n`)
803
+ report.created.push(`${CONVENTIONS_FILE.split(path.sep).join('/')} (moved from ${relPath})`)
804
+ fs.writeFileSync(target.abs, target.bundled)
805
+ writtenHashes[relPath] = sha1(target.bundled)
806
+ }
807
+
808
+ // What Claude Code loads into EVERY session from this install: each rule under
809
+ // `.claude/rules/` that skitterspec wrote (managed, or the conventions file)
810
+ // and that carries no `paths:` front-matter, plus the managed CLAUDE.md block.
811
+ // The budget test hangs on this (feat-rules-budget).
812
+ //
813
+ // WHAT WOULD FOOL THIS: front-matter it cannot parse. Anything other than a
814
+ // leading `---` block holding a `paths:` key counts as always-loaded, so a
815
+ // cannot-tell over-counts — the direction that fails the budget loudly rather
816
+ // than passing it quietly.
817
+ function hasPathsFrontMatter(text) {
818
+ const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/.exec(text)
819
+ return Boolean(m && /^paths:/m.test(m[1]))
820
+ }
821
+
822
+ function alwaysLoaded(dir) {
823
+ const rows = []
824
+ const rules = [
825
+ ...managedTargets(dir)
826
+ .filter((t) => t.relPath.startsWith('.claude/rules/'))
827
+ .map((t) => t.abs),
828
+ path.join(dir, CONVENTIONS_FILE),
829
+ ]
830
+ for (const abs of [...new Set(rules)]) {
831
+ if (!fs.existsSync(abs)) continue
832
+ const text = fs.readFileSync(abs, 'utf8')
833
+ if (!hasPathsFrontMatter(text)) rows.push({ path: rel(dir, abs), chars: text.length })
834
+ }
835
+ for (const name of ['CLAUDE.md', 'CLAUDE.local.md']) {
836
+ const file = path.join(dir, name)
837
+ if (!fs.existsSync(file)) continue
838
+ const text = fs.readFileSync(file, 'utf8')
839
+ const start = text.indexOf(SPEC_MARKER_START)
840
+ const end = text.indexOf(SPEC_MARKER_END, start)
841
+ if (start === -1 || end === -1) continue
842
+ rows.push({ path: `${name} (skitterspec section)`, chars: end + SPEC_MARKER_END.length - start })
843
+ }
844
+ return { rows, total: rows.reduce((n, r) => n + r.chars, 0) }
845
+ }
846
+
735
847
  // Register the review-gate hook in the project's committed settings, so a
736
848
  // phase that owes a verdict is enforced one level below the skills. Best-effort
737
849
  // in exactly the way `trustWorktreeRoot` is: a settings file we cannot parse is
@@ -1108,7 +1220,9 @@ function resync(dir, { force = false, claudeMd = true, diff = false, local = fal
1108
1220
  resolveScope(dir, local)
1109
1221
  if (scope === 'local') convertCommitted(dir)
1110
1222
  const manifest = readManifest(dir)
1223
+ migrateConventions(dir, manifest, force)
1111
1224
  for (const t of managedTargets(dir)) resyncManagedFile(dir, t, manifest, force)
1225
+ installConventions(dir)
1112
1226
  installFolders(dir)
1113
1227
  removeRetiredFiles(dir)
1114
1228
  pruneRetiredManaged(dir, manifest)
@@ -1359,6 +1473,7 @@ function localManagedPaths(dir) {
1359
1473
  function localExcludes(dir) {
1360
1474
  return [
1361
1475
  ...localManagedPaths(dir),
1476
+ CONVENTIONS_FILE.replace(/\\/g, '/'),
1362
1477
  'CLAUDE.local.md',
1363
1478
  '.claude/settings.local.json',
1364
1479
  MANIFEST_FILE.replace(/\\/g, '/'),
@@ -1376,7 +1491,7 @@ function localExcludes(dir) {
1376
1491
  // and the hooks into a new .claude/settings.json (bug-local-scope-worktree).
1377
1492
  function localSeedFiles(dir) {
1378
1493
  if (readManifest(dir).scope !== 'local') return []
1379
- return [...localManagedPaths(dir), '.claude/settings.local.json', 'CLAUDE.local.md', MANIFEST_FILE.replace(/\\/g, '/')]
1494
+ return [...localManagedPaths(dir), CONVENTIONS_FILE.replace(/\\/g, '/'), '.claude/settings.local.json', 'CLAUDE.local.md', MANIFEST_FILE.replace(/\\/g, '/')]
1380
1495
  }
1381
1496
 
1382
1497
  const EXCLUDE_START = '# >>> skitterspec (local install)'
@@ -1639,8 +1754,10 @@ function switchNames() {
1639
1754
  return [...SKILLS, ...COMMANDS.map((c) => c.replace(/\.md$/, ''))]
1640
1755
  }
1641
1756
 
1757
+ // The conventions file is switched with the rules: it is not managed, but a
1758
+ // disabled install should not go on loading half of itself.
1642
1759
  function ruleExcludes() {
1643
- return RULES.map((r) => `**/.claude/rules/${r}`)
1760
+ return [...RULES, path.basename(CONVENTIONS_FILE)].map((r) => `**/.claude/rules/${r}`)
1644
1761
  }
1645
1762
 
1646
1763
  // The local settings, parsed — `{}` when absent, null when not valid JSON.
@@ -1827,6 +1944,9 @@ function uninstall(dir, { yes = false, inFlight = [], cannotTell = null, log = (
1827
1944
  const targets = new Map()
1828
1945
  for (const t of managedTargets(dir)) targets.set(t.relPath.split(path.sep).join('/'), t.bundled)
1829
1946
  for (const k of Object.keys(manifest.files)) if (!targets.has(k)) targets.set(k, undefined)
1947
+ // The conventions file is not managed, but a local install wrote it: the
1948
+ // untouched template goes, and a filled-in one is parked like an edit.
1949
+ targets.set(CONVENTIONS_FILE.split(path.sep).join('/'), fs.readFileSync(path.join(ASSETS, 'project-conventions.md'), 'utf8'))
1830
1950
  const remove = []
1831
1951
  const keep = []
1832
1952
  const exclude = localExcludeFile(dir)
@@ -1981,6 +2101,7 @@ async function init({ dir, force, claudeMd, mode, isolation, workspaceMode, gati
1981
2101
  installSkills(dir, { force })
1982
2102
  installCommands(dir, { force })
1983
2103
  installRule(dir, { force })
2104
+ installConventions(dir)
1984
2105
  installHooks(dir, { force })
1985
2106
  installFolders(dir)
1986
2107
  removeRetiredFiles(dir)
@@ -2015,6 +2136,9 @@ module.exports = {
2015
2136
  writeManifest,
2016
2137
  managedTargets,
2017
2138
  managedState,
2139
+ alwaysLoaded,
2140
+ CONVENTIONS_FILE,
2141
+ listSkillFiles,
2018
2142
  claudeMdSectionState,
2019
2143
  checkSync,
2020
2144
  isExistingSetup,