@skitterbyte/skitterspec-github 1.2.1 → 2.0.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.
- package/MIGRATION.md +141 -1
- package/README.md +9 -7
- package/assets/core/SETUP.md +10 -5
- package/assets/core/github.config.md +54 -4
- package/assets/rules/spec-planning.md +13 -3
- package/assets/rules/spec-reports.md +19 -4
- package/assets/skills/spec-bug/SKILL.md +3 -1
- package/assets/skills/spec-github-setup/SKILL.md +6 -4
- package/assets/skills/spec-hotfix/SKILL.md +3 -1
- package/assets/skills/spec-list/SKILL.md +28 -4
- package/assets/skills/spec-next/SKILL.md +3 -1
- package/assets/skills/spec-status/SKILL.md +28 -27
- package/assets/skills/spec-sync/SKILL.md +13 -4
- package/package.json +1 -1
- package/src/cli.js +6 -25
- package/src/env/review.js +47 -2
- package/src/vendor/github/api.js +86 -108
- package/src/vendor/github/cli-sync.js +87 -81
- package/src/vendor/github/config.js +5 -48
- package/src/vendor/github/mcp.js +1 -5
- package/src/vendor/provider-kit/src/config.js +101 -48
- package/src/vendor/provider-kit/src/list-assignee.js +71 -0
- package/src/vendor/provider-kit/src/list-rows.js +35 -0
- package/src/vendor/provider-kit/src/released.js +27 -77
- package/src/vendor/provider-kit/src/specs.js +89 -7
- package/src/vendor/sync-core/index.js +3 -4
- package/src/vendor/sync-core/src/compare.js +6 -6
- package/src/vendor/sync-core/src/normalize.js +30 -57
- package/src/vendor/provider-kit/src/releases.js +0 -380
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared pieces of `spec-sync list`: what `--state` means, and how a row's
|
|
5
|
+
* board state and its spec's own status are put side by side.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { remoteStateReading, stateNamesFor, LIFECYCLE_BUCKETS } = require('../../sync-core')
|
|
9
|
+
|
|
10
|
+
// `--state` takes a lifecycle bucket as well as a tracker state. A bucket
|
|
11
|
+
// expands to every tracker name it has (`stateNamesFor`, aliases included); any
|
|
12
|
+
// other value is a tracker state, matched as it always was.
|
|
13
|
+
function expandStateArgs(args, config) {
|
|
14
|
+
return (args || []).flatMap((arg) => (LIFECYCLE_BUCKETS.includes(arg) ? stateNamesFor(arg, config) : [arg]))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The spec's status beside the board's, and whether they disagree. A board
|
|
18
|
+
// state that maps to no bucket never disagrees: it is somewhere push does not
|
|
19
|
+
// manage, which is not a claim about the spec. Nor does a row whose spec is not
|
|
20
|
+
// on this machine — there is nothing to disagree WITH.
|
|
21
|
+
function specColumn(stateName, spec, config) {
|
|
22
|
+
const specStatus = spec ? spec.bucket : null
|
|
23
|
+
const seen = stateName == null ? null : remoteStateReading({ state: { name: stateName } }, config)
|
|
24
|
+
const disagrees = Boolean(specStatus && seen && seen.mapped && seen.bucket !== specStatus)
|
|
25
|
+
return { specStatus, disagrees }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The cell itself: `in-progress`, `≠ backlog` when it disagrees, `—` when the
|
|
29
|
+
// spec is not here.
|
|
30
|
+
function specCell({ specStatus, disagrees }) {
|
|
31
|
+
if (!specStatus) return '—'
|
|
32
|
+
return disagrees ? `≠ ${specStatus}` : specStatus
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { expandStateArgs, specColumn, specCell }
|
|
@@ -24,7 +24,7 @@ const IDENTIFIER_RE = /\b[A-Z][A-Z0-9]*-\d+\b/g
|
|
|
24
24
|
// how `owner/repo#123` names ANOTHER repo's issue. Prose is excluded by the
|
|
25
25
|
// trailer anchor (only a `Refs:` line is scanned); the cross-repo form is
|
|
26
26
|
// excluded by the lookbehind, so a ref into some other repo never lands on this
|
|
27
|
-
// one's release
|
|
27
|
+
// one's release.
|
|
28
28
|
const GITHUB_REF_RE = /(?<![\w/.-])#\d+\b/g
|
|
29
29
|
// A `Refs:` trailer line. Anchored, so it is a line of its own — never prose
|
|
30
30
|
// that happens to mention the word.
|
|
@@ -175,95 +175,45 @@ function ticketsInRange(commits, options = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
178
|
+
* Name the spec behind each ticket a range contains, so a consumer can act on
|
|
179
|
+
* a release without a second lookup.
|
|
180
180
|
*
|
|
181
|
-
*
|
|
182
|
-
* be
|
|
181
|
+
* A ref no spec has stamped keeps `spec: null` and `url: null` — never a guess
|
|
182
|
+
* from a similar folder name. It may be tracker-only work, or a typo in a
|
|
183
|
+
* trailer, and a consumer acting on an invented match is worse than one told
|
|
184
|
+
* there was none.
|
|
183
185
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* this repo was never configured for is the worst failure available here.
|
|
187
|
-
* - **unlinked** — the ref is this team's, but no spec in the repo claims it.
|
|
188
|
-
* It may be tracker-only work, or a typo in a trailer. Either way nothing
|
|
189
|
-
* here knows what it is, so it is reported, not moved.
|
|
190
|
-
* - **unfinished** — a spec that has not reached the ceded bucket. Its code
|
|
191
|
-
* really is in the release (it landed via `/spec-to-main`), but push still
|
|
192
|
-
* owns its workflow state and would bounce it straight back. Exactly one
|
|
193
|
-
* writer per issue at any moment beats a visible flip-flop.
|
|
194
|
-
*
|
|
195
|
-
* Pure: it takes the spec list as data, so the rules are testable without a repo.
|
|
186
|
+
* Pure: it takes the spec list as data (`listSpecs` rows), so it is testable
|
|
187
|
+
* without a repo.
|
|
196
188
|
*/
|
|
197
|
-
function
|
|
198
|
-
const
|
|
199
|
-
for (const
|
|
200
|
-
if (
|
|
201
|
-
}
|
|
202
|
-
const key = String(teamKey || '').trim().toUpperCase()
|
|
203
|
-
const movable = []
|
|
204
|
-
const foreign = []
|
|
205
|
-
const unlinked = []
|
|
206
|
-
const unfinished = []
|
|
207
|
-
for (const ticket of tickets || []) {
|
|
208
|
-
const ref = ticket && ticket.ref
|
|
209
|
-
if (!ref) continue
|
|
210
|
-
if (key && !ref.toUpperCase().startsWith(`${key}-`)) {
|
|
211
|
-
foreign.push(ticket)
|
|
212
|
-
} else if (!bucketOf.has(ref)) {
|
|
213
|
-
unlinked.push(ticket)
|
|
214
|
-
} else if (bucketOf.get(ref) !== cededBucket) {
|
|
215
|
-
unfinished.push({ ...ticket, bucket: bucketOf.get(ref) })
|
|
216
|
-
} else {
|
|
217
|
-
movable.push(ticket)
|
|
218
|
-
}
|
|
189
|
+
function nameTickets(tickets, specs) {
|
|
190
|
+
const byRef = new Map()
|
|
191
|
+
for (const s of specs || []) {
|
|
192
|
+
if (s && s.identifier && !byRef.has(s.identifier)) byRef.set(s.identifier, s)
|
|
219
193
|
}
|
|
220
|
-
return
|
|
194
|
+
return (tickets || []).map((t) => {
|
|
195
|
+
const s = byRef.get(t.ref)
|
|
196
|
+
return { ...t, spec: s ? s.spec : null, url: s ? s.url || null : null }
|
|
197
|
+
})
|
|
221
198
|
}
|
|
222
199
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* normal case and says nothing.
|
|
231
|
-
*
|
|
232
|
-
* `lifecycleStates` is the bucket map's own state names, and a state among them
|
|
233
|
-
* means the issue is at its LIFECYCLE position, not on a rung — even when the
|
|
234
|
-
* two names coincide. They routinely do: `states.complete` and a final `prod`
|
|
235
|
-
* rung are both naturally "Done", and without this a spec that had merely been
|
|
236
|
-
* completed would read as already deployed to prod, so its first real deploy
|
|
237
|
-
* would be warned about as a move backwards. Bucket wins over ladder here for
|
|
238
|
-
* the same reason it wins in `bucketForState`.
|
|
239
|
-
*
|
|
240
|
-
* @returns {string|null}
|
|
241
|
-
*/
|
|
242
|
-
function stageOrderWarning(stages, fromState, toKey, lifecycleStates = []) {
|
|
243
|
-
const list = Array.isArray(stages) ? stages : []
|
|
244
|
-
const to = list.findIndex((s) => s && s.key === toKey)
|
|
245
|
-
if (to < 0) return null
|
|
246
|
-
const want = String(fromState || '').toLowerCase().trim()
|
|
247
|
-
if (!want) return null
|
|
248
|
-
const lifecycle = new Set(
|
|
249
|
-
(Array.isArray(lifecycleStates) ? lifecycleStates : [])
|
|
250
|
-
.filter((n) => typeof n === 'string')
|
|
251
|
-
.map((n) => n.toLowerCase().trim()),
|
|
200
|
+
// The answer a removed release verb gives (`release`, `stage`). Exit 1, not a
|
|
201
|
+
// quiet 0: a pipeline still calling one must learn it no longer mirrors
|
|
202
|
+
// anything, rather than go on believing it does.
|
|
203
|
+
function refuseRemovedVerb(out, program, verb) {
|
|
204
|
+
out.write(
|
|
205
|
+
`${program} ${verb}: removed — skitterspec no longer writes release or deploy state; ` +
|
|
206
|
+
`\`${program} released <range> --json\` lists the tickets a range contains, for your own tooling to act on\n`,
|
|
252
207
|
)
|
|
253
|
-
|
|
254
|
-
const from = list.findIndex((s) => s && typeof s.state === 'string' && s.state.toLowerCase().trim() === want)
|
|
255
|
-
if (from < 0) return null
|
|
256
|
-
if (to < from) return `moves back from "${list[from].key}"`
|
|
257
|
-
if (to > from + 1) return `skips ${to - from - 1} rung(s) from "${list[from].key}"`
|
|
258
|
-
return null
|
|
208
|
+
return 1
|
|
259
209
|
}
|
|
260
210
|
|
|
261
211
|
module.exports = {
|
|
262
212
|
ticketsInRange,
|
|
213
|
+
refuseRemovedVerb,
|
|
214
|
+
nameTickets,
|
|
263
215
|
refsInBody,
|
|
264
216
|
onlyIgnoredPaths,
|
|
265
|
-
partitionStageMoves,
|
|
266
|
-
stageOrderWarning,
|
|
267
217
|
IDENTIFIER_RE,
|
|
268
218
|
GITHUB_REF_RE,
|
|
269
219
|
}
|
|
@@ -14,7 +14,16 @@
|
|
|
14
14
|
const fs = require('node:fs')
|
|
15
15
|
const path = require('node:path')
|
|
16
16
|
|
|
17
|
-
const {
|
|
17
|
+
const { execFileSync } = require('node:child_process')
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
BUCKETS,
|
|
21
|
+
findSpecFolder,
|
|
22
|
+
resolveSpec,
|
|
23
|
+
liveWorktreePaths,
|
|
24
|
+
resolvePrimaryCheckout,
|
|
25
|
+
} = require('../../../env/resolve.js')
|
|
26
|
+
const { loadEnvConfig } = require('../../../env/config.js')
|
|
18
27
|
const { readSnapshot, parseFrontmatter, lintPhases, fieldsOf, projectionOf, compareStored } = require('../../sync-core')
|
|
19
28
|
|
|
20
29
|
function makeSpecHelpers({ program = 'spec-sync' } = {}) {
|
|
@@ -45,22 +54,32 @@ function makeSpecHelpers({ program = 'spec-sync' } = {}) {
|
|
|
45
54
|
// Read a spec's stamped identifier without throwing: an unlinked spec, an
|
|
46
55
|
// unreadable file and a spec with no frontmatter all read as `null`.
|
|
47
56
|
function linkedIdentifier(overviewPath, config) {
|
|
48
|
-
|
|
57
|
+
return linkedFields(overviewPath, config).identifier
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The stamped identifier AND url, each `null` when absent. The url is only
|
|
61
|
+
// ever what a push stamped — never built from the identifier, because a url
|
|
62
|
+
// constructed here would be a guess about a tracker's address scheme.
|
|
63
|
+
function linkedFields(overviewPath, config) {
|
|
64
|
+
const fields = fieldsOf(config)
|
|
49
65
|
let raw
|
|
50
66
|
try {
|
|
51
67
|
raw = fs.readFileSync(overviewPath, 'utf-8')
|
|
52
68
|
} catch {
|
|
53
|
-
return null
|
|
69
|
+
return { identifier: null, url: null }
|
|
54
70
|
}
|
|
55
71
|
const { data } = parseFrontmatter(raw)
|
|
56
|
-
return
|
|
72
|
+
return {
|
|
73
|
+
identifier: data[fields.identifier] ? String(data[fields.identifier]) : null,
|
|
74
|
+
url: fields.url && data[fields.url] ? String(data[fields.url]) : null,
|
|
75
|
+
}
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
// Every spec under specs/<bucket>/, paired with the tracker issue it is
|
|
60
79
|
// linked to (`null` when it has never been pushed). Folder specs read
|
|
61
80
|
// `snapshot.overviewFile`; legacy bare `<name>.md` specs read the file
|
|
62
81
|
// itself. Sorted for stable output.
|
|
63
|
-
function listSpecs(dir, config) {
|
|
82
|
+
function listSpecs(dir, config, options = {}) {
|
|
64
83
|
const overviewFile = (config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
|
|
65
84
|
const specs = []
|
|
66
85
|
for (const bucket of BUCKETS) {
|
|
@@ -83,12 +102,75 @@ function makeSpecHelpers({ program = 'spec-sync' } = {}) {
|
|
|
83
102
|
} else {
|
|
84
103
|
continue
|
|
85
104
|
}
|
|
86
|
-
|
|
105
|
+
const linked = linkedFields(overviewPath, config)
|
|
106
|
+
const row = { spec: name, bucket, identifier: linked.identifier }
|
|
107
|
+
// Opt-in, so every listing that never asked for a url keeps its shape.
|
|
108
|
+
if (options.urls) row.url = linked.url
|
|
109
|
+
specs.push(row)
|
|
87
110
|
}
|
|
88
111
|
}
|
|
89
112
|
return specs.sort((a, b) => a.spec.localeCompare(b.spec))
|
|
90
113
|
}
|
|
91
114
|
|
|
115
|
+
// `listSpecs`, but each spec's BUCKET read from where that spec actually
|
|
116
|
+
// lives. `/spec-start` moves a spec to `in-progress/` on its own branch, so
|
|
117
|
+
// on the base branch an in-flight spec still reads `backlog` — and a spec
|
|
118
|
+
// authored in its own worktree and not yet landed is not here at all. Each
|
|
119
|
+
// live worktree is read too, and a spec found in ITS OWN worktree (the path
|
|
120
|
+
// `resolveSpec` names for it) wins over every other copy. `source` says
|
|
121
|
+
// which: `here`, `worktree`, or `other-tree` for a spec only some other
|
|
122
|
+
// worktree carries.
|
|
123
|
+
//
|
|
124
|
+
// WHAT WOULD FOOL THIS: a worktree left behind by a declined teardown is
|
|
125
|
+
// still live, so a finished spec can read from a stale tree. And with no
|
|
126
|
+
// `env.config.json` there is no worktree layout to resolve, so this is
|
|
127
|
+
// exactly `listSpecs` — the current tree's answer, as before.
|
|
128
|
+
function listSpecsLive(dir, config) {
|
|
129
|
+
const here = listSpecs(dir, config).map((s) => ({ ...s, source: 'here' }))
|
|
130
|
+
const git = (args) => {
|
|
131
|
+
try {
|
|
132
|
+
return execFileSync('git', ['-C', dir, ...args], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
|
|
133
|
+
} catch {
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let primary
|
|
138
|
+
let env
|
|
139
|
+
try {
|
|
140
|
+
primary = resolvePrimaryCheckout(dir, git) || dir
|
|
141
|
+
env = loadEnvConfig(primary)
|
|
142
|
+
} catch {
|
|
143
|
+
return here
|
|
144
|
+
}
|
|
145
|
+
if (!env.present) return here
|
|
146
|
+
// Compared as REAL paths: git reports a worktree resolved through
|
|
147
|
+
// symlinks (macOS /var → /private/var) where `resolveSpec` does not.
|
|
148
|
+
const real = (p) => {
|
|
149
|
+
try {
|
|
150
|
+
return fs.realpathSync(p)
|
|
151
|
+
} catch {
|
|
152
|
+
return path.resolve(p)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const self = real(dir)
|
|
156
|
+
const byName = new Map(here.map((s) => [s.spec, s]))
|
|
157
|
+
for (const listed of liveWorktreePaths(git)) {
|
|
158
|
+
const tree = real(listed)
|
|
159
|
+
if (tree === self) continue
|
|
160
|
+
for (const s of listSpecs(tree, config)) {
|
|
161
|
+
let own = null
|
|
162
|
+
try {
|
|
163
|
+
own = real(resolveSpec(s.spec, primary, env.config, { searchDirs: [tree] }).worktreePath)
|
|
164
|
+
} catch {
|
|
165
|
+
own = null
|
|
166
|
+
}
|
|
167
|
+
if (own === tree) byName.set(s.spec, { ...s, source: 'worktree' })
|
|
168
|
+
else if (!byName.has(s.spec)) byName.set(s.spec, { ...s, source: 'other-tree' })
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [...byName.values()].sort((a, b) => a.spec.localeCompare(b.spec))
|
|
172
|
+
}
|
|
173
|
+
|
|
92
174
|
// Resolve a spec argument to its folder, or null with a message on stdout.
|
|
93
175
|
// EVERY failure path here must print and EVERY caller must return a non-zero
|
|
94
176
|
// code: a push skill checks $? before it applies a plan, so a resolve failure
|
|
@@ -160,7 +242,7 @@ function makeSpecHelpers({ program = 'spec-sync' } = {}) {
|
|
|
160
242
|
return lines
|
|
161
243
|
}
|
|
162
244
|
|
|
163
|
-
return { resolveSnapshotDir, specIdentifier, linkedIdentifier, listSpecs, resolveOrExit, warningLines, warnToErr, verifyLines }
|
|
245
|
+
return { resolveSnapshotDir, specIdentifier, linkedIdentifier, listSpecs, listSpecsLive, resolveOrExit, warningLines, warnToErr, verifyLines }
|
|
164
246
|
}
|
|
165
247
|
|
|
166
248
|
module.exports = { makeSpecHelpers }
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* stored matches what was sent — it merges nothing (see `src/verify.js`).
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
const { ownsField, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState,
|
|
16
|
+
const { ownsField, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState, remoteStateReading, stateNamesFor, titleFromText, validateStates, stateSuggestions, phaseModeFor } = require('./src/normalize.js')
|
|
17
17
|
const { planChanges, snapshotOf, isEmptyPlan, hashField, stableStringify, remoteDescriptionEdited, remoteSubIssueEdited } = require('./src/compare.js')
|
|
18
18
|
const { readBase, writeBase } = require('./src/base.js')
|
|
19
19
|
const { push, recordPush, projectionOf } = require('./src/push.js')
|
|
@@ -41,12 +41,11 @@ module.exports = {
|
|
|
41
41
|
push,
|
|
42
42
|
recordPush,
|
|
43
43
|
remoteWorkflowState,
|
|
44
|
+
remoteStateReading,
|
|
45
|
+
stateNamesFor,
|
|
44
46
|
titleFromText,
|
|
45
47
|
validateStates,
|
|
46
48
|
stateSuggestions,
|
|
47
|
-
stageForState,
|
|
48
|
-
remoteStage,
|
|
49
|
-
LADDER_ORIGIN_BUCKET,
|
|
50
49
|
hashField,
|
|
51
50
|
stableStringify,
|
|
52
51
|
readBase,
|
|
@@ -58,12 +58,12 @@ function specIssueHash(p) {
|
|
|
58
58
|
|
|
59
59
|
// Per-field hashes of the same two values.
|
|
60
60
|
//
|
|
61
|
-
// They are hashed SEPARATELY because
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
// description without re-asserting a state
|
|
61
|
+
// They are hashed SEPARATELY because skitterspec tells the tracker about its
|
|
62
|
+
// own transitions and nothing else. The description is resent whenever it
|
|
63
|
+
// changes; the state only when the spec itself moves. Welding the two meant any
|
|
64
|
+
// prose edit re-emitted the state and dragged back an issue someone had moved
|
|
65
|
+
// on the tracker — which is theirs to do. Diffing them apart is what lets a
|
|
66
|
+
// push touch the description without re-asserting a state.
|
|
67
67
|
function specIssueFieldHashes(p, config) {
|
|
68
68
|
const hashes = {
|
|
69
69
|
description: hashField(p.description ?? null),
|
|
@@ -751,39 +751,27 @@ function phasesWithheld(snapshotDir, config) {
|
|
|
751
751
|
|
|
752
752
|
// --- remote projection ------------------------------------------------------
|
|
753
753
|
|
|
754
|
-
//
|
|
755
|
-
//
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (state == null) return null
|
|
763
|
-
const want = String(state).toLowerCase().trim()
|
|
764
|
-
const stages = (config && config.release && config.release.stages) || []
|
|
765
|
-
if (!Array.isArray(stages)) return null
|
|
766
|
-
return stages.find((s) => s && typeof s.state === 'string' && s.state.toLowerCase().trim() === want) || null
|
|
754
|
+
// Every tracker state NAME that means this bucket: the one push writes
|
|
755
|
+
// (`states[bucket]`) first, then its read-only aliases (`stateAliases[bucket]`,
|
|
756
|
+
// from the array form of `states`). Readers use the whole list; writers only
|
|
757
|
+
// ever use `states[bucket]`, so an alias can never be written.
|
|
758
|
+
function stateNamesFor(bucket, config) {
|
|
759
|
+
const primary = config && config.states && config.states[bucket]
|
|
760
|
+
const aliases = (config && config.stateAliases && config.stateAliases[bucket]) || []
|
|
761
|
+
return [primary, ...(Array.isArray(aliases) ? aliases : [])].filter((n) => typeof n === 'string' && n)
|
|
767
762
|
}
|
|
768
763
|
|
|
769
764
|
// Map a remote workflow-state name back to the local lifecycle bucket (the
|
|
770
765
|
// vocabulary `spec_status` uses) via config.states, so local and remote
|
|
771
766
|
// workflowState hash equal when semantically equal. Falls back to a lowercased
|
|
772
767
|
// raw value when the state isn't one of the configured names.
|
|
773
|
-
//
|
|
774
|
-
// A DECLARED DEPLOYMENT STAGE reads as `complete`, deliberately. Without this
|
|
775
|
-
// the fallback lowercases it — "On Test" becomes "on test", which equals no
|
|
776
|
-
// bucket — and every deployed spec reports as drifted forever, for the whole
|
|
777
|
-
// time it sits in the pipeline. The project told us these states are downstream
|
|
778
|
-
// of a finished spec, so they are not a disagreement about where the spec is.
|
|
779
768
|
function bucketForState(state, config) {
|
|
780
769
|
if (state == null) return null
|
|
781
770
|
const states = (config && config.states) || {}
|
|
782
771
|
const want = String(state).toLowerCase().trim()
|
|
783
|
-
for (const
|
|
784
|
-
if (
|
|
772
|
+
for (const bucket of Object.keys(states)) {
|
|
773
|
+
if (stateNamesFor(bucket, config).some((name) => name.toLowerCase().trim() === want)) return bucket
|
|
785
774
|
}
|
|
786
|
-
if (stageForState(state, config)) return LADDER_ORIGIN_BUCKET
|
|
787
775
|
return want
|
|
788
776
|
}
|
|
789
777
|
|
|
@@ -818,11 +806,20 @@ function remoteWorkflowState(issue, config) {
|
|
|
818
806
|
return name != null ? bucketForState(name, config) : null
|
|
819
807
|
}
|
|
820
808
|
|
|
821
|
-
//
|
|
822
|
-
//
|
|
823
|
-
//
|
|
824
|
-
|
|
825
|
-
|
|
809
|
+
// What the drift report needs to know about a remote issue's state: its name,
|
|
810
|
+
// the bucket it maps to, and whether it maps to one at all. Null when the
|
|
811
|
+
// payload carried no state — a cannot-tell, never an answer.
|
|
812
|
+
//
|
|
813
|
+
// AN UNMAPPED STATE IS NOT A DISAGREEMENT. A tracker grows states skitterspec
|
|
814
|
+
// never names ("Blocked", "Next Sprint"), and a ticket a person moved into one
|
|
815
|
+
// is not wrong about the spec — it is somewhere push does not manage, and push
|
|
816
|
+
// will not move it until the spec itself moves. `mapped` is what lets a report
|
|
817
|
+
// say that rather than accuse it.
|
|
818
|
+
function remoteStateReading(issue, config) {
|
|
819
|
+
const name = remoteStateName(issue || {}, config)
|
|
820
|
+
if (name == null) return null
|
|
821
|
+
const bucket = bucketForState(name, config)
|
|
822
|
+
return { name: String(name), bucket, mapped: LIFECYCLE_BUCKETS.includes(bucket) }
|
|
826
823
|
}
|
|
827
824
|
|
|
828
825
|
// A Linear issue title is plain text, so markdown emphasis is noise there — and
|
|
@@ -897,24 +894,16 @@ function titleFromText(text, max = 100) {
|
|
|
897
894
|
return stripTitleMarkup(title)
|
|
898
895
|
}
|
|
899
896
|
|
|
900
|
-
// Every state NAME the config points at: the lifecycle bucket map
|
|
901
|
-
// project's deployment ladder when it declares one. Both reach Linear the same
|
|
902
|
-
// way and fail the same way, so both are checked by the same lookup.
|
|
897
|
+
// Every state NAME the config points at: the lifecycle bucket map.
|
|
903
898
|
function configuredStateNames(config) {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
if (stage && typeof stage.state === 'string') names.push(stage.state)
|
|
908
|
-
}
|
|
909
|
-
return names
|
|
899
|
+
// The WRITTEN names only. An alias is never written, so one the workspace
|
|
900
|
+
// lacks cannot strand a push; `stateSuggestions` still names it in reports.
|
|
901
|
+
return Object.values((config && config.states) || {}).filter((v) => typeof v === 'string')
|
|
910
902
|
}
|
|
911
903
|
|
|
912
904
|
// Which configured state NAMES are absent from the live workspace. The skill
|
|
913
905
|
// fetches the workspace's project-status names over MCP and passes them here;
|
|
914
906
|
// a non-empty result means a typo/rename that Linear would silently no-op.
|
|
915
|
-
//
|
|
916
|
-
// A project with no `release.stages` contributes nothing here, so the ladder
|
|
917
|
-
// cannot make this accuse a config that was fine before it existed.
|
|
918
907
|
function validateStates(config, workspaceStates) {
|
|
919
908
|
const configured = configuredStateNames(config)
|
|
920
909
|
const have = new Set((workspaceStates || []).map((s) => String(s).toLowerCase().trim()))
|
|
@@ -953,21 +942,6 @@ function stateSuggestions(config, workspaceStates) {
|
|
|
953
942
|
const suggestion = names.find((n) => words.includes(n.toLowerCase().trim())) || null
|
|
954
943
|
out.push({ bucket, configured, suggestion, label: `states.${bucket}` })
|
|
955
944
|
}
|
|
956
|
-
// Deployment-ladder rungs, reported the same way. No suggestion is offered:
|
|
957
|
-
// BUCKET_WORDS describes lifecycle vocabulary, and a stage name is the
|
|
958
|
-
// project's own — guessing "On Test" meant "In Progress" would be worse than
|
|
959
|
-
// saying nothing.
|
|
960
|
-
const stages = (config && config.release && config.release.stages) || []
|
|
961
|
-
for (const stage of Array.isArray(stages) ? stages : []) {
|
|
962
|
-
if (!stage || typeof stage.state !== 'string') continue
|
|
963
|
-
if (have.has(stage.state.toLowerCase().trim())) continue
|
|
964
|
-
out.push({
|
|
965
|
-
bucket: null,
|
|
966
|
-
configured: stage.state,
|
|
967
|
-
suggestion: null,
|
|
968
|
-
label: `release.stages[${stage.key}]`,
|
|
969
|
-
})
|
|
970
|
-
}
|
|
971
945
|
return out
|
|
972
946
|
}
|
|
973
947
|
|
|
@@ -991,8 +965,7 @@ module.exports = {
|
|
|
991
965
|
canonicalRemoteStatus,
|
|
992
966
|
bucketForState,
|
|
993
967
|
LIFECYCLE_BUCKETS,
|
|
994
|
-
stageForState,
|
|
995
|
-
remoteStage,
|
|
996
968
|
remoteWorkflowState,
|
|
997
|
-
|
|
969
|
+
remoteStateReading,
|
|
970
|
+
stateNamesFor,
|
|
998
971
|
}
|