@skitterbyte/skitterspec 23.23.2 → 23.23.3

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.
@@ -40,6 +40,15 @@ if (argv[0] === 'init' || (argv[0] === 'update' && !argv.includes('--all'))) {
40
40
  }
41
41
  }
42
42
 
43
+ // Every skill's engine call runs this bin, providers included (#278), so pick
44
+ // up the provider the project configured before anything reads the config.
45
+ require('../src/provider.js').registerConfiguredProvider({
46
+ cwd: process.cwd(),
47
+ envConfig: require('../src/env/config.js'),
48
+ idea: require('../src/idea.js'),
49
+ warn: (line) => console.error(line),
50
+ })
51
+
43
52
  run(argv).catch((err) => {
44
53
  console.error(`skitterspec: ${err.message}`)
45
54
  process.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec",
3
- "version": "23.23.2",
3
+ "version": "23.23.3",
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",
@@ -0,0 +1,92 @@
1
+ 'use strict'
2
+
3
+ // The base `skitterspec` bin, in a project with a ticketing provider set up.
4
+ //
5
+ // Providers stopped answering to `skitterspec` (#278), so the bare name always
6
+ // runs this distribution — and a provider's registrations (the `land.specDocs`
7
+ // default, its env defaults, its idea store) used to happen only in its own
8
+ // bin. Here the base finds the provider the project configured, loads that
9
+ // provider's `src/register.js` from where it is installed, and hands it the
10
+ // base's own engine modules to register on.
11
+
12
+ const { existsSync } = require('node:fs')
13
+ const { dirname, join } = require('node:path')
14
+
15
+ // Each provider: its config file, and where its register module lives — in the
16
+ // published superset (vendored under src/vendor/) and in the workspace source
17
+ // package, tried in that order.
18
+ const PROVIDERS = [
19
+ { name: 'linear', configFile: join('specs', '.core', 'linear.config.json') },
20
+ { name: 'jira', configFile: join('specs', '.core', 'jira.config.json') },
21
+ { name: 'github', configFile: join('specs', '.core', 'github.config.json') },
22
+ { name: 'azure-boards', configFile: join('specs', '.core', 'azure-boards.config.json') },
23
+ ].map((p) => ({
24
+ ...p,
25
+ candidates: [
26
+ [`@skitterbyte/skitterspec-${p.name}`, join('src', 'vendor', p.name, 'register.js')],
27
+ [`@skitterbyte/skitterspec-provider-${p.name}`, join('src', 'register.js')],
28
+ ],
29
+ }))
30
+
31
+ // The nearest directory at or above `from` holding `specs/.core`. A worktree
32
+ // tracks its own, so a spec's worktree answers for itself.
33
+ function projectDir(from) {
34
+ for (let dir = from; ; dir = dirname(dir)) {
35
+ if (existsSync(join(dir, 'specs', '.core'))) return dir
36
+ if (dirname(dir) === dir) return null
37
+ }
38
+ }
39
+
40
+ // Where `name` is installed, looked for beside the base (a global install puts
41
+ // the provider next to it) and then from the project (a local install).
42
+ function resolvePackage(name, paths) {
43
+ try {
44
+ return dirname(require.resolve(`${name}/package.json`, { paths }))
45
+ } catch {
46
+ return null
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Register the provider configured in the project at or above `cwd` on the
52
+ * base engine's `envConfig` and `idea` modules.
53
+ *
54
+ * Returns `{ provider, registered }`: `registered` is `'full'` (its register
55
+ * module ran), `'config'` (not installed — only its config file is registered,
56
+ * so `land.specDocs` still defaults to "branch"), or `null` (nothing done).
57
+ *
58
+ * WHAT WOULD FOOL THIS: two provider config files in one project is a project
59
+ * this cannot read, so nothing is registered and it warns — the base's own
60
+ * behaviour, never a guess between them. A provider installed somewhere Node's
61
+ * resolution cannot see from the base or the project reads as not installed,
62
+ * and the config file alone is still the positive signal for the lane.
63
+ */
64
+ function registerConfiguredProvider({ cwd, envConfig, idea, resolve = resolvePackage, warn = () => {} }) {
65
+ const dir = projectDir(cwd)
66
+ if (!dir) return { provider: null, registered: null }
67
+ const configured = PROVIDERS.filter((p) => existsSync(join(dir, p.configFile)))
68
+ if (configured.length === 0) return { provider: null, registered: null }
69
+ if (configured.length > 1) {
70
+ warn(
71
+ `skitterspec: more than one ticketing provider is configured here (${configured.map((p) => p.configFile).join(', ')}) — registering none`,
72
+ )
73
+ return { provider: null, registered: null }
74
+ }
75
+ const p = configured[0]
76
+ const paths = [__dirname, dir]
77
+ for (const [pkg, rel] of p.candidates) {
78
+ const root = resolve(pkg, paths)
79
+ if (root && existsSync(join(root, rel))) {
80
+ require(join(root, rel)).register({ envConfig, idea })
81
+ return { provider: p.name, registered: 'full' }
82
+ }
83
+ }
84
+ envConfig.setProviderConfigFile(p.configFile)
85
+ warn(
86
+ `skitterspec: ${p.configFile} is here but @skitterbyte/skitterspec-${p.name} is not installed beside this one — ` +
87
+ 'spec docs ride the branch, but install it for its ideas and env defaults',
88
+ )
89
+ return { provider: p.name, registered: 'config' }
90
+ }
91
+
92
+ module.exports = { registerConfiguredProvider, PROVIDERS }