@skitterbyte/skitterspec 23.24.0 → 23.24.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.
@@ -20,7 +20,7 @@ if (!existsSync(join(__dirname, '..', 'src'))) {
20
20
  process.exit(1)
21
21
  }
22
22
 
23
- const { run } = require('../src/cli.js')
23
+ const { run, PROVIDER_COMMANDS } = require('../src/cli.js')
24
24
 
25
25
  // The check above asks whether src/ exists, which is inert in a workspace source
26
26
  // package — src/ is committed there. That is exactly where the other half of the
@@ -40,6 +40,16 @@ if (argv[0] === 'init' || (argv[0] === 'update' && !argv.includes('--all'))) {
40
40
  }
41
41
  }
42
42
 
43
+ // A verb this base does not ship (spec-sync) goes to the configured provider's
44
+ // own bin, which makes its own registrations — so this runs before ours.
45
+ const forwarded = require('../src/provider.js').forwardProviderCommand({
46
+ cwd: process.cwd(),
47
+ argv,
48
+ commands: Object.keys(PROVIDER_COMMANDS),
49
+ warn: (line) => console.error(line),
50
+ })
51
+ if (forwarded !== null) process.exit(forwarded)
52
+
43
53
  // Every skill's engine call runs this bin, providers included (#278), so pick
44
54
  // up the provider the project configured before anything reads the config.
45
55
  require('../src/provider.js').registerConfiguredProvider({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec",
3
- "version": "23.24.0",
3
+ "version": "23.24.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
@@ -204,7 +204,7 @@ const {
204
204
  } = require('./env/reviewers.js')
205
205
  const { planUp, planCheckoutUp, resolveStack, worktreeSteps } = require('./env/provision.js')
206
206
  const { runBootstrap, describeStep } = require('./env/bootstrap.js')
207
- const { classifyDirtyTree, dirtyPaths, specDocsIn } = require('./env/classify.js')
207
+ const { classifyDirtyTree, dirtyPaths, specDocsIn, treeReader } = require('./env/classify.js')
208
208
  const { isGitCommit } = require('./env/commitcmd.js')
209
209
  const { planDown, planDownCheckout } = require('./env/teardown.js')
210
210
  const {
@@ -5343,7 +5343,8 @@ function specEnvStage(dir, config, specArg, flags = {}, invokedFrom = dir) {
5343
5343
  // PROJECT folder in it — what a pathspec is when run from where a session
5344
5344
  // stands. The same thing at the root of a repo (feat-subfolder-project).
5345
5345
  const prefix = prefixOf(config)
5346
- const split = classifyDirtyTree(spec, paths, config)
5346
+ // The same reader the page uses, so an epic stages the members it shows.
5347
+ const split = classifyDirtyTree(spec, paths, config, { readFile: treeReader(tree) })
5347
5348
  const owned = split.owned.map((p) => projectRelative(p, prefix))
5348
5349
  const foreign = split.foreign.map((p) => projectRelative(p, prefix))
5349
5350
  const treeShown = prefix ? projectIn(tree, prefix) : tree
@@ -9006,6 +9007,7 @@ module.exports = {
9006
9007
  run,
9007
9008
  parse,
9008
9009
  HELP,
9010
+ PROVIDER_COMMANDS,
9009
9011
  unknownCommand,
9010
9012
  rankLanAddresses,
9011
9013
  offerableLanAddresses,
@@ -15,9 +15,19 @@
15
15
  * foreign path disqualifies the whole tree.
16
16
  */
17
17
 
18
+ const fs = require('node:fs')
18
19
  const path = require('node:path')
19
- const { BUCKETS, expandTokens, readFrontmatterField } = require('./resolve.js')
20
- const { fromRepoPath, prefixOf } = require('./project.js')
20
+ const { BUCKETS, expandTokens, readFrontmatterField, isEpic } = require('./resolve.js')
21
+ const { fromRepoPath, toRepoPath, prefixOf } = require('./project.js')
22
+
23
+ // The `> **Epic:**` header off an overview, unquoted, or null. The same reading
24
+ // as `epicHeaders` in env/epic.js, kept here so the classifier stays a leaf.
25
+ function epicNamed(text) {
26
+ const m = /^>\s*\*\*Epic:\*\*[ \t]*(.*)$/m.exec(text || '')
27
+ if (!m) return null
28
+ const value = m[1].trim().replace(/^`(.*)`$/, '$1').trim()
29
+ return value || null
30
+ }
21
31
 
22
32
  // git reports repo-relative, forward-slashed paths; an untracked directory comes
23
33
  // back with a trailing slash. Normalise both away so comparisons are exact.
@@ -77,10 +87,23 @@ function expandCompanion(pattern, spec, config) {
77
87
  * (backlog → in-progress), so a tree mid-move is dirty in two buckets at once
78
88
  * and both halves are the same spec's.
79
89
  * - each expandable `spec.companionPaths` entry.
90
+ * - for an EPIC, and only given `readFile`: anything inside another spec's
91
+ * folder whose `00-overview.md`, read from the same tree, carries
92
+ * `> **Epic:** <this epic>`. `/spec` writes an epic WITH its members in one
93
+ * worktree, so those members are the epic's documents being written, not
94
+ * somebody else's work (bug-epic-page-misses-members).
95
+ *
96
+ * WHAT WOULD FOOL THE MEMBER RULE: a member's overview that is not in the tree
97
+ * being read. That reads as null, which is cannot-tell, and cannot-tell stays
98
+ * foreign: a refusal is the safe direction to be wrong in. A spec naming another
99
+ * epic, or none, is foreign as before.
80
100
  *
101
+ * @param {object} [opts]
102
+ * - `readFile` repo-relative path → text, or null. Without it no member is
103
+ * owned, which is the answer every caller had before.
81
104
  * @returns {{owned: string[], foreign: string[]}}
82
105
  */
83
- function classifyDirtyTree(spec, dirtyPaths, config) {
106
+ function classifyDirtyTree(spec, dirtyPaths, config, { readFile = null } = {}) {
84
107
  const owned = []
85
108
  const foreign = []
86
109
  if (!spec) return { owned, foreign: (dirtyPaths || []).map(normalize).filter(Boolean) }
@@ -93,12 +116,30 @@ function classifyDirtyTree(spec, dirtyPaths, config) {
93
116
  }
94
117
 
95
118
  const prefix = prefixOf(config)
119
+ // One read per member folder, however many of its files are dirty.
120
+ const memberFolders = new Map()
121
+ const memberOf = (rel) => {
122
+ if (!readFile || !isEpic(spec.folder) || rel === null) return false
123
+ const m = /^specs\/([^/]+)\/([^/]+)\//.exec(rel)
124
+ if (!m || !BUCKETS.includes(m[1])) return false
125
+ const key = `${m[1]}/${m[2]}`
126
+ if (!memberFolders.has(key)) {
127
+ let text = null
128
+ try {
129
+ text = readFile(toRepoPath(`specs/${key}/00-overview.md`, prefix))
130
+ } catch {
131
+ // unreadable: cannot tell, so not a member
132
+ }
133
+ memberFolders.set(key, epicNamed(text) === spec.folder)
134
+ }
135
+ return memberFolders.get(key)
136
+ }
96
137
  for (const raw of dirtyPaths || []) {
97
138
  const p = normalize(raw)
98
139
  if (!p) continue
99
140
  const rel = fromRepoPath(p, prefix)
100
141
  const inFolder = rel !== null && folders.some((f) => rel === f || rel.startsWith(`${f}/`))
101
- if (inFolder || (rel !== null && companions.has(rel))) owned.push(p)
142
+ if (inFolder || (rel !== null && companions.has(rel)) || memberOf(rel)) owned.push(p)
102
143
  else foreign.push(p)
103
144
  }
104
145
  return { owned, foreign }
@@ -176,9 +217,23 @@ function dirtyPaths(git) {
176
217
  function specDocsIn(tree, spec, config, git) {
177
218
  const paths = dirtyPaths(git)
178
219
  if (paths === null) return { error: 'git could not be read' }
179
- const { owned } = classifyDirtyTree(spec, paths, config)
220
+ const { owned } = classifyDirtyTree(spec, paths, config, { readFile: treeReader(tree) })
180
221
  if (!owned.length) return { empty: true }
181
222
  return { tree, owned }
182
223
  }
183
224
 
184
- module.exports = { classifyDirtyTree, expandCompanion, unquotePath, dirtyPaths, specDocsIn }
225
+ /**
226
+ * `classifyDirtyTree`'s `readFile` for a checkout: repo-relative path → its
227
+ * text in that working tree, or null when it cannot be read (cannot tell).
228
+ */
229
+ function treeReader(root) {
230
+ return (rel) => {
231
+ try {
232
+ return fs.readFileSync(path.join(root, rel), 'utf8')
233
+ } catch {
234
+ return null
235
+ }
236
+ }
237
+ }
238
+
239
+ module.exports = { treeReader, classifyDirtyTree, expandCompanion, unquotePath, dirtyPaths, specDocsIn }
package/src/env/epic.js CHANGED
@@ -419,7 +419,7 @@ function formatEpicStatus(s) {
419
419
  if (!s.found && !s.members.length) {
420
420
  return `no epic named ${s.epic}, and no spec names it as its Epic${s.here ? ` in ${s.here}` : ''}.\n`
421
421
  }
422
- const lanes = s.lanes === null ? 'no lane cap' : `${s.lanes} lanes, ${s.freeLanes} free`
422
+ const lanes = s.lanes === null ? 'no lane cap' : `${s.lanes} ${s.lanes === 1 ? 'lane' : 'lanes'}, ${s.freeLanes} free`
423
423
  const where = s.here ? ` · headers from ${s.here}` : s.found ? '' : ' · epic not on the base branch'
424
424
  const out = []
425
425
  if (!s.members.length) {
@@ -62,7 +62,7 @@ function stepItem(st, freeLanes) {
62
62
  }
63
63
 
64
64
  function renderEpicPage(answer, { refreshSeconds = REFRESH_SECONDS, project = null } = {}) {
65
- const lanes = answer.lanes === null ? 'no lane cap' : `${answer.lanes} lanes, ${answer.freeLanes} free`
65
+ const lanes = answer.lanes === null ? 'no lane cap' : `${answer.lanes} ${answer.lanes === 1 ? 'lane' : 'lanes'}, ${answer.freeLanes} free`
66
66
  const { rows, next } = answer.rows ? { rows: answer.rows, next: answer.next } : epicRows(answer)
67
67
  const { progress, groups, steps } = answer.steps ? answer : epicPlan(answer, { rows, next })
68
68
  const byName = new Map(rows.map((r) => [r.spec, r]))
package/src/env/serve.js CHANGED
@@ -45,7 +45,7 @@ const { renderEpicPage } = require('./epicpage.js')
45
45
  const { readRegistry } = require('./registry.js')
46
46
  const { loadEnvConfig } = require('./config.js')
47
47
  const { primaryAnchor, attachProject, projectName, repoRootOf, prefixOf, fromRepoPath, toRepoPath } = require('./project.js')
48
- const { specDocsIn, classifyDirtyTree, dirtyPaths } = require('./classify.js')
48
+ const { specDocsIn, classifyDirtyTree, dirtyPaths, treeReader } = require('./classify.js')
49
49
  const { liveStateFor } = require('./live.js')
50
50
  const { preferRemoteBase } = require('./host.js')
51
51
  const { ROUTE: TADA_ROUTE, renderServedTada } = require('../tada/serve.js')
@@ -263,7 +263,8 @@ function docsWorktree(wt, spec, config) {
263
263
  const paths = dirtyPaths(trimmedGitReader(wt))
264
264
  // Cannot tell — not "no documents".
265
265
  if (paths === null) return null
266
- const { owned, foreign } = classifyDirtyTree(spec, paths, config)
266
+ // An epic's members, written beside it in this same tree, are its documents.
267
+ const { owned, foreign } = classifyDirtyTree(spec, paths, config, { readFile: treeReader(wt) })
267
268
  // A TRACKER SNAPSHOT IS NOT SOMEBODY ELSE'S WORK, and requiring a
268
269
  // foreign-free tree cost the whole page for the commonest authoring tree
269
270
  // there is. The linking push writes `specs/.core/linear-base/<ID>.base.json`
package/src/provider.js CHANGED
@@ -9,6 +9,7 @@
9
9
  // provider's `src/register.js` from where it is installed, and hands it the
10
10
  // base's own engine modules to register on.
11
11
 
12
+ const { spawnSync } = require('node:child_process')
12
13
  const { existsSync } = require('node:fs')
13
14
  const { dirname, join } = require('node:path')
14
15
 
@@ -89,4 +90,48 @@ function registerConfiguredProvider({ cwd, envConfig, idea, resolve = resolvePac
89
90
  return { provider: p.name, registered: 'config' }
90
91
  }
91
92
 
92
- module.exports = { registerConfiguredProvider, PROVIDERS }
93
+ /**
94
+ * Run a verb the base does not ship (`commands`, e.g. `spec-sync`) on the
95
+ * provider configured in the project at or above `cwd`, through that
96
+ * provider's own bin, so `skitterspec spec-sync …` answers exactly as
97
+ * `skitterspec-<provider> spec-sync …` does — the skills call the bare name.
98
+ *
99
+ * Returns the exit status to use, or `null` when there is nothing to forward
100
+ * and the base should carry on as it would have: a verb it ships, no project,
101
+ * no provider configured, or two of them (registerConfiguredProvider warns).
102
+ *
103
+ * WHAT WOULD FOOL THIS: a provider installed where Node's resolution cannot
104
+ * see it from the base or the project reads as not installed, and the verb is
105
+ * refused naming the package — never run on a guessed provider.
106
+ */
107
+ function forwardProviderCommand({
108
+ cwd,
109
+ argv,
110
+ commands,
111
+ resolve = resolvePackage,
112
+ warn = () => {},
113
+ spawn = spawnSync,
114
+ }) {
115
+ const [cmd] = argv
116
+ if (!commands.includes(cmd)) return null
117
+ const dir = projectDir(cwd)
118
+ if (!dir) return null
119
+ const configured = PROVIDERS.filter((p) => existsSync(join(dir, p.configFile)))
120
+ if (configured.length !== 1) return null
121
+ const p = configured[0]
122
+ const bin = join('bin', `skitterspec-${p.name}.js`)
123
+ for (const [pkg] of p.candidates) {
124
+ const root = resolve(pkg, [__dirname, dir])
125
+ if (root && existsSync(join(root, bin))) {
126
+ const r = spawn(process.execPath, [join(root, bin), ...argv], { cwd, stdio: 'inherit' })
127
+ return r.status ?? 1
128
+ }
129
+ }
130
+ warn(
131
+ `skitterspec: ${cmd} needs @skitterbyte/skitterspec-${p.name} installed beside this one — ` +
132
+ `${p.configFile} is here but it is not. Install it alongside @skitterbyte/skitterspec, at the latest of each.`,
133
+ )
134
+ return 1
135
+ }
136
+
137
+ module.exports = { registerConfiguredProvider, forwardProviderCommand, PROVIDERS }