@skitterbyte/skitterspec 23.10.0 → 23.11.0

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.
@@ -47,6 +47,15 @@ function planDown(spec, config, flags, ctx) {
47
47
  // can use `-D` — the same question ("are these commits recoverable?"), so the
48
48
  // two must never answer it differently.
49
49
  const landed = Boolean(worktreeState.merged || worktreeState.reachableFromTag)
50
+ // A spec-documents-only branch under `land.specDocs: "branch"` — authored,
51
+ // perhaps pushed, never started (feat-tracker-spec-branches). It holds no
52
+ // code to lose and was never meant to have a PR, and left on the remote it
53
+ // reads as backlog to every check that scans spec branches. `docsOnly` is a
54
+ // positive signal the caller computes from the branch's own range; anything
55
+ // it cannot read stays false, which keeps every guard below as it was.
56
+ const docsLane = Boolean(
57
+ worktreeState.docsOnly && config.land && config.land.specDocs === 'branch',
58
+ )
50
59
 
51
60
  // --- guards (overridable with --force) ---
52
61
  if (!force) {
@@ -69,7 +78,7 @@ function planDown(spec, config, flags, ctx) {
69
78
  // PR and the exit where git's cannot. `--force` bypasses, and still plans
70
79
  // `-d` below, so a genuinely unlanded branch fails loudly rather than
71
80
  // being -D'd.
72
- if (config.land && config.land.strategy === 'pr' && !landed) {
81
+ if (config.land && config.land.strategy === 'pr' && !landed && !docsLane) {
73
82
  const prState = worktreeState.prState
74
83
  const at = worktreeState.prUrl ? ` — see ${worktreeState.prUrl}` : ''
75
84
  if (prState === 'open' || prState === 'draft') {
@@ -188,9 +197,15 @@ function planDown(spec, config, flags, ctx) {
188
197
  // this delete a no-op: `git push --delete` errors with "remote ref does not
189
198
  // exist", which is loud and destroys nothing. The skills report that as
190
199
  // already-gone, never as a failed teardown.
200
+ //
201
+ // The docs lane is the one unlanded branch that may be offered: its remote
202
+ // copy backs up only the spec document being cancelled, and the ticket keeps
203
+ // the record. It is ALWAYS confirm-first — "always" folds the landed delete
204
+ // into the run-blind list, but deleting the last copy of a document is not
205
+ // what that policy was set for.
191
206
  const remoteCommands = []
192
207
  const policy = (config.teardown && config.teardown.deleteRemoteBranch) || 'prompt'
193
- if (spec.branch && landed && worktreeState.remoteBranch && policy !== 'never') {
208
+ if (spec.branch && (landed || docsLane) && worktreeState.remoteBranch && policy !== 'never') {
194
209
  // `remoteBranch` is a short ref like "origin/feat/thing" and the branch name
195
210
  // itself contains slashes, so the remote is what remains once the exact
196
211
  // "/<branch>" suffix is stripped — not the text before the first slash.
@@ -206,7 +221,7 @@ function planDown(spec, config, flags, ctx) {
206
221
  const cmd = `git push ${remote} --delete ${spec.branch}`
207
222
  // "always" is the project saying it never wants to be asked, so the push
208
223
  // joins the run-blind list. Everything else keeps it quarantined.
209
- if (policy === 'always') commands.push(cmd)
224
+ if (policy === 'always' && landed) commands.push(cmd)
210
225
  else remoteCommands.push(cmd)
211
226
  }
212
227
  }
package/src/gating.js CHANGED
@@ -15,6 +15,7 @@
15
15
 
16
16
  const fs = require('node:fs')
17
17
  const path = require('node:path')
18
+ const { preferBranches, branchLabel } = require('./env/specbranches.js')
18
19
 
19
20
  const CONFIG_FILE = path.join('specs', '.core', 'gating.config.json')
20
21
 
@@ -87,6 +88,12 @@ function readGatingField(specPath) {
87
88
  } catch {
88
89
  return { raw: null, kind: 'missing' }
89
90
  }
91
+ return readGatingText(raw)
92
+ }
93
+
94
+ // The same reading over an overview's text — a spec read off its own branch
95
+ // (`env/specbranches.js`) has text and no path on disk.
96
+ function readGatingText(raw) {
90
97
  const m = /^>\s*\*\*Gating:\*\*\s*(.*)$/m.exec(raw)
91
98
  if (!m) return { raw: null, kind: 'missing' }
92
99
  const value = m[1].trim().replace(/^["'`]|["'`]$/g, '')
@@ -130,15 +137,19 @@ function activeSpecs(dir) {
130
137
  * @returns {{configured: boolean, findings: Array<{folder, bucket, kind, raw}>,
131
138
  * checked: number, guidance: string}}
132
139
  */
133
- function checkGating(dir, specs) {
140
+ function checkGating(dir, specs, { branches = [] } = {}) {
134
141
  const { config, present } = loadGatingConfig(dir)
135
142
  if (!present) return { configured: false, findings: [], checked: 0, guidance: '' }
136
- const targets = specs && specs.length ? specs : activeSpecs(dir)
143
+ // Branch copies (`env/specbranches.js`) win over the disk copy of the same
144
+ // spec and add the ones the base branch cannot see; finished buckets are not
145
+ // gating's business either way.
146
+ const active = branches.filter((b) => ACTIVE_BUCKETS.includes(b.bucket))
147
+ const targets = specs && specs.length ? specs : preferBranches(activeSpecs(dir), active)
137
148
  const findings = []
138
149
  for (const spec of targets) {
139
- const { kind, raw } = readGatingField(spec.path)
150
+ const { kind, raw } = spec.ref ? readGatingText(spec.overview) : readGatingField(spec.path)
140
151
  if (kind === 'missing' || kind === 'invalid') {
141
- findings.push({ folder: spec.folder, bucket: spec.bucket, kind, raw })
152
+ findings.push({ folder: spec.folder, bucket: spec.bucket, kind, raw, ...(spec.ref ? { from: branchLabel(spec) } : {}) })
142
153
  }
143
154
  }
144
155
  return { configured: true, findings, checked: targets.length, guidance: config.guidance }
@@ -150,6 +161,7 @@ module.exports = {
150
161
  ACTIVE_BUCKETS,
151
162
  loadGatingConfig,
152
163
  readGatingField,
164
+ readGatingText,
153
165
  activeSpecs,
154
166
  checkGating,
155
167
  }