@skitterbyte/skitterspec-github 1.3.0 → 2.1.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 +170 -1
- package/README.md +9 -7
- package/assets/core/SETUP.md +10 -12
- package/assets/core/env.config.md +1 -1
- package/assets/core/github.config.json.example +2 -1
- package/assets/core/github.config.md +51 -69
- package/assets/rules/spec-planning.md +35 -12
- package/assets/rules/spec-reports.md +28 -2
- package/assets/skills/no-spec/SKILL.md +2 -2
- package/assets/skills/spec/SKILL.md +31 -8
- package/assets/skills/spec-bug/SKILL.md +2 -2
- package/assets/skills/spec-github-setup/SKILL.md +6 -4
- package/assets/skills/spec-list/SKILL.md +28 -4
- package/assets/skills/spec-next/SKILL.md +2 -2
- package/assets/skills/spec-status/SKILL.md +28 -27
- package/assets/skills/spec-sync/SKILL.md +11 -27
- package/package.json +1 -1
- package/src/cli.js +108 -3
- package/src/env/resolve.js +11 -4
- package/src/env/review.js +79 -0
- package/src/vendor/github/api.js +86 -123
- package/src/vendor/github/cli-sync.js +106 -83
- package/src/vendor/github/config.js +21 -58
- 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 +60 -59
- package/src/vendor/provider-kit/src/releases.js +0 -595
package/src/vendor/github/api.js
CHANGED
|
@@ -160,6 +160,7 @@ query($q: String!, $status: String!, $after: String) {
|
|
|
160
160
|
number title url state
|
|
161
161
|
repository { nameWithOwner }
|
|
162
162
|
parent { number }
|
|
163
|
+
assignees(first: 10) { nodes { login name } }
|
|
163
164
|
projectItems(first: 20) {
|
|
164
165
|
nodes {
|
|
165
166
|
id
|
|
@@ -172,6 +173,20 @@ query($q: String!, $status: String!, $after: String) {
|
|
|
172
173
|
}
|
|
173
174
|
}`
|
|
174
175
|
|
|
176
|
+
// The board's items in its own order — what a person drags on the board.
|
|
177
|
+
// Only the position is wanted here; state and title come from `listBoardItems`.
|
|
178
|
+
const BOARD_ORDER = `
|
|
179
|
+
query($id: ID!, $after: String) {
|
|
180
|
+
node(id: $id) {
|
|
181
|
+
... on ProjectV2 {
|
|
182
|
+
items(first: 100, after: $after, orderBy: { field: POSITION, direction: ASC }) {
|
|
183
|
+
pageInfo { hasNextPage endCursor }
|
|
184
|
+
nodes { content { ... on Issue { number repository { nameWithOwner } } } }
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}`
|
|
189
|
+
|
|
175
190
|
const ADD_ITEM = `
|
|
176
191
|
mutation($project: ID!, $content: ID!) {
|
|
177
192
|
addProjectV2ItemById(input: { projectId: $project, contentId: $content }) { item { id } }
|
|
@@ -195,7 +210,6 @@ function makeApiAdapter({
|
|
|
195
210
|
repo,
|
|
196
211
|
project,
|
|
197
212
|
statusField = 'Status',
|
|
198
|
-
deployedField = 'Deployed',
|
|
199
213
|
token,
|
|
200
214
|
apiUrl = API_URL,
|
|
201
215
|
fetch: fetchImpl,
|
|
@@ -377,11 +391,6 @@ function makeApiAdapter({
|
|
|
377
391
|
|
|
378
392
|
let boardCache = null
|
|
379
393
|
|
|
380
|
-
const releaseOf = (raw) =>
|
|
381
|
-
raw && raw.id != null
|
|
382
|
-
? { id: raw.id, tag: raw.tag_name, url: raw.html_url || null, body: raw.body == null ? '' : String(raw.body), prerelease: !!raw.prerelease }
|
|
383
|
-
: null
|
|
384
|
-
|
|
385
394
|
async function resolveBoard() {
|
|
386
395
|
if (boardCache) return boardCache
|
|
387
396
|
if (!project) {
|
|
@@ -435,6 +444,25 @@ function makeApiAdapter({
|
|
|
435
444
|
return { board, field, option }
|
|
436
445
|
}
|
|
437
446
|
|
|
447
|
+
// The one add refusal that means "it is there already". Matched on GitHub's
|
|
448
|
+
// message, because the error carries no type of its own for this case.
|
|
449
|
+
const alreadyOnBoard = (error) =>
|
|
450
|
+
Boolean(error && Array.isArray(error.errors) && error.errors.some((e) => e && /already exists in this project/i.test(e.message || '')))
|
|
451
|
+
|
|
452
|
+
const pause = sleep || ((ms) => new Promise((resolve) => setTimeout(resolve, ms)))
|
|
453
|
+
|
|
454
|
+
// Read the issue until its board item shows, briefly: the auto-add that beat
|
|
455
|
+
// us has written it, but the read side may not show it on the first ask.
|
|
456
|
+
// Null when it never appears.
|
|
457
|
+
async function awaitBoardItem(issue, delays = [0, 500, 1500, 3000]) {
|
|
458
|
+
for (const ms of delays) {
|
|
459
|
+
if (ms) await pause(ms)
|
|
460
|
+
const fresh = await adapter.readIssue(issue.number != null ? issue.number : issue.identifier)
|
|
461
|
+
if (fresh && fresh.boardItemId) return fresh.boardItemId
|
|
462
|
+
}
|
|
463
|
+
return null
|
|
464
|
+
}
|
|
465
|
+
|
|
438
466
|
async function readRaw(ref) {
|
|
439
467
|
const data = await graphql(ISSUE_QUERY, { owner, repo, number: numberOf(ref), status: statusField }, { allowMissing: true })
|
|
440
468
|
return (data.repository && data.repository.issue) || null
|
|
@@ -534,9 +562,16 @@ function makeApiAdapter({
|
|
|
534
562
|
* ago may be missing from one listing. A listing is a convenience; nothing
|
|
535
563
|
* decides on it.
|
|
536
564
|
*/
|
|
537
|
-
|
|
565
|
+
// `assignee` narrows the search to one login — and is how `list --mine`
|
|
566
|
+
// reaches issues no spec has adopted yet, which carry no spec label.
|
|
567
|
+
async listBoardItems({ label = '', assignee = null } = {}) {
|
|
538
568
|
if (!project) throw new GitHubRefusal('no board configured — set github.project to the board number from its URL')
|
|
539
|
-
const q = [
|
|
569
|
+
const q = [
|
|
570
|
+
`repo:${owner}/${repo}`,
|
|
571
|
+
'is:issue',
|
|
572
|
+
label ? `label:"${String(label).replace(/"/g, '')}"` : null,
|
|
573
|
+
assignee ? `assignee:${String(assignee).replace(/[^A-Za-z0-9-]/g, '')}` : null,
|
|
574
|
+
].filter(Boolean).join(' ')
|
|
540
575
|
const out = []
|
|
541
576
|
let after = null
|
|
542
577
|
for (let page = 0; page < MAX_PAGES; page++) {
|
|
@@ -555,6 +590,9 @@ function makeApiAdapter({
|
|
|
555
590
|
open: c.state === 'OPEN',
|
|
556
591
|
state: item.fieldValueByName && item.fieldValueByName.name != null ? { name: item.fieldValueByName.name } : null,
|
|
557
592
|
parent: c.parent && c.parent.number != null ? { id: String(c.parent.number), identifier: identifierOf(c.parent.number) } : null,
|
|
593
|
+
assignees: ((c.assignees && c.assignees.nodes) || [])
|
|
594
|
+
.filter((a) => a && a.login)
|
|
595
|
+
.map((a) => ({ id: a.login, name: a.name || a.login })),
|
|
558
596
|
})
|
|
559
597
|
}
|
|
560
598
|
if (!res.pageInfo || !res.pageInfo.hasNextPage) break
|
|
@@ -563,6 +601,29 @@ function makeApiAdapter({
|
|
|
563
601
|
return out.sort((a, b) => Number(a.id) - Number(b.id))
|
|
564
602
|
},
|
|
565
603
|
|
|
604
|
+
/**
|
|
605
|
+
* This repo's issue numbers in board order (`list --next`). Pages like
|
|
606
|
+
* `listBoardItems`, under the same cap.
|
|
607
|
+
*/
|
|
608
|
+
async listBoardOrder() {
|
|
609
|
+
const board = await resolveBoard()
|
|
610
|
+
const order = []
|
|
611
|
+
let after = null
|
|
612
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
613
|
+
const data = await graphql(BOARD_ORDER, { id: board.id, after })
|
|
614
|
+
const items = (data.node && data.node.items) || { nodes: [], pageInfo: {} }
|
|
615
|
+
for (const n of items.nodes || []) {
|
|
616
|
+
const c = n && n.content
|
|
617
|
+
if (!c || c.number == null) continue
|
|
618
|
+
if (!c.repository || !sameLogin(c.repository.nameWithOwner, `${owner}/${repo}`)) continue
|
|
619
|
+
order.push(String(c.number))
|
|
620
|
+
}
|
|
621
|
+
if (!items.pageInfo || !items.pageInfo.hasNextPage) break
|
|
622
|
+
after = items.pageInfo.endCursor
|
|
623
|
+
}
|
|
624
|
+
return order
|
|
625
|
+
},
|
|
626
|
+
|
|
566
627
|
/**
|
|
567
628
|
* Open issues in this repo carrying every label in `labels` — the intake
|
|
568
629
|
* inbox. Pull requests come back from this endpoint too and are dropped.
|
|
@@ -595,15 +656,29 @@ function makeApiAdapter({
|
|
|
595
656
|
|
|
596
657
|
/**
|
|
597
658
|
* Put the issue on the board. `addProjectV2ItemById` returns the EXISTING
|
|
598
|
-
* item when the issue
|
|
599
|
-
* own
|
|
659
|
+
* item when the issue was already there before the call — but not when the
|
|
660
|
+
* board's own "auto-add sub-issues" workflow is adding it at the same
|
|
661
|
+
* moment, which is exactly when a just-linked child is pushed. That loses
|
|
662
|
+
* the race with `Content already exists in this project`, so on THAT
|
|
663
|
+
* refusal the item is read back rather than the push failing.
|
|
600
664
|
*/
|
|
601
665
|
async addToBoard(issueOrRef) {
|
|
602
666
|
const issue = issueOrRef && issueOrRef.nodeId ? issueOrRef : await adapter.readIssue(issueOrRef)
|
|
603
667
|
if (!issue || !issue.nodeId) throw new GitHubRefusal(`no issue ${JSON.stringify(issueOrRef)} to add to the board`)
|
|
604
668
|
if (issue.boardItemId) return { itemId: issue.boardItemId, added: false }
|
|
605
669
|
const board = await resolveBoard()
|
|
606
|
-
|
|
670
|
+
let data
|
|
671
|
+
try {
|
|
672
|
+
data = await graphql(ADD_ITEM, { project: board.id, content: issue.nodeId })
|
|
673
|
+
} catch (error) {
|
|
674
|
+
if (!alreadyOnBoard(error)) throw error
|
|
675
|
+
const itemId = await awaitBoardItem(issue)
|
|
676
|
+
// WHAT WOULD FOOL THIS: GitHub's read side lagging its write side for
|
|
677
|
+
// longer than the backoff. That is a cannot-tell, so the original
|
|
678
|
+
// refusal is re-raised rather than an item id guessed at.
|
|
679
|
+
if (!itemId) throw error
|
|
680
|
+
return { itemId, added: false }
|
|
681
|
+
}
|
|
607
682
|
const item = data.addProjectV2ItemById && data.addProjectV2ItemById.item
|
|
608
683
|
if (!item || !item.id) throw new GitHubRefusal(`GitHub did not return a board item for ${issue.identifier}`)
|
|
609
684
|
return { itemId: item.id, added: true }
|
|
@@ -680,118 +755,6 @@ function makeApiAdapter({
|
|
|
680
755
|
throw new GitHubRefusal(`GitHub answered ${res.status} when asked whether ${login} is assignable`, { status: res.status })
|
|
681
756
|
},
|
|
682
757
|
|
|
683
|
-
// --- releases (the kit's release seam, `provider-kit/src/releases.js`) ---
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Is the tag on GitHub? Asked before a create because GitHub, handed a
|
|
687
|
-
* `tag_name` it lacks, CREATES the tag at the default branch's head — a
|
|
688
|
-
* release pointing at a commit nobody tagged. 200 yes, 404 no; anything
|
|
689
|
-
* else throws (cannot tell).
|
|
690
|
-
*/
|
|
691
|
-
async releaseTagExists(tag) {
|
|
692
|
-
const res = await send('GET', `${base}${repoPath}/git/ref/tags/${encodeURIComponent(tag)}`)
|
|
693
|
-
if (res.status === 200) return true
|
|
694
|
-
if (res.status === 404) return false
|
|
695
|
-
throw new GitHubRefusal(`GitHub answered ${res.status} when asked for tag ${tag}`, { status: res.status })
|
|
696
|
-
},
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* The release for a tag, or null. A 404 is GitHub positively answering
|
|
700
|
-
* "no release for this tag"; any other failure throws, and the kit refuses
|
|
701
|
-
* rather than create on a lookup it could not make.
|
|
702
|
-
*/
|
|
703
|
-
async releaseFind(tag) {
|
|
704
|
-
const raw = await rest('GET', `${repoPath}/releases/tags/${encodeURIComponent(tag)}`, { allow404: true })
|
|
705
|
-
return raw ? releaseOf(raw) : null
|
|
706
|
-
},
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Every release in the repo, for `release reconcile`. Hand-made releases
|
|
710
|
-
* ride through here too — the caller filters to the ones carrying the
|
|
711
|
-
* skitterspec marker and must leave the rest alone.
|
|
712
|
-
*/
|
|
713
|
-
async releaseList() {
|
|
714
|
-
const raw = await restAll(`${repoPath}/releases`)
|
|
715
|
-
return raw.map(releaseOf).filter(Boolean)
|
|
716
|
-
},
|
|
717
|
-
|
|
718
|
-
async releaseCreate({ tag, name, body, prerelease = true }) {
|
|
719
|
-
assertBodyFits(body, `the ${tag} release`)
|
|
720
|
-
// `make_latest: false` while staged: a release still on its way through
|
|
721
|
-
// test must not become the one GitHub shows as Latest.
|
|
722
|
-
const raw = await rest('POST', `${repoPath}/releases`, {
|
|
723
|
-
body: { tag_name: tag, name, body, prerelease, make_latest: prerelease ? 'false' : 'true' },
|
|
724
|
-
})
|
|
725
|
-
return releaseOf(raw)
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
async releaseUpdate(release, { name, body }) {
|
|
729
|
-
assertBodyFits(body, `the ${release.tag} release`)
|
|
730
|
-
const raw = await rest('PATCH', `${repoPath}/releases/${release.id}`, { body: { name, body } })
|
|
731
|
-
Object.assign(release, releaseOf(raw) || {})
|
|
732
|
-
return release
|
|
733
|
-
},
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Note the release on each issue it carries — one comment per issue, found
|
|
737
|
-
* again by its marker, so a CI retry adds nothing.
|
|
738
|
-
*/
|
|
739
|
-
async releaseAttach(release, tickets) {
|
|
740
|
-
const marker = `<!-- skitterspec:released ${release.tag} -->`
|
|
741
|
-
let attached = 0
|
|
742
|
-
let already = 0
|
|
743
|
-
for (const t of tickets) {
|
|
744
|
-
const comments = await adapter.listComments(t.ref)
|
|
745
|
-
if (comments.some((c) => c.body.includes(marker))) {
|
|
746
|
-
already++
|
|
747
|
-
continue
|
|
748
|
-
}
|
|
749
|
-
await adapter.createComment(t.ref, `Shipped in [${release.tag}](${release.url || ''})\n\n${marker}`)
|
|
750
|
-
attached++
|
|
751
|
-
}
|
|
752
|
-
return { attached, already }
|
|
753
|
-
},
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* Set the board's Deployed option on every issue the release carries. The
|
|
757
|
-
* option is resolved before the first write, so an unknown name refuses
|
|
758
|
-
* with nothing changed.
|
|
759
|
-
*
|
|
760
|
-
* A commit's `Refs:` names the spec issue, never a phase, so the phases are
|
|
761
|
-
* reached through their parent — and only the CLOSED ones. An open phase of
|
|
762
|
-
* a spec landed mid-way (/spec-to-main) has not shipped, and marking it so
|
|
763
|
-
* would be a false Deployed on the board.
|
|
764
|
-
*/
|
|
765
|
-
async releaseStage(release, optionName, tickets) {
|
|
766
|
-
await optionFor(deployedField, optionName)
|
|
767
|
-
const seen = new Set()
|
|
768
|
-
let set = 0
|
|
769
|
-
const stage = async (ref) => {
|
|
770
|
-
if (seen.has(ref)) return
|
|
771
|
-
seen.add(ref)
|
|
772
|
-
const r = await adapter.setFieldOption(ref, deployedField, optionName)
|
|
773
|
-
if (r && r.changed !== false) set++
|
|
774
|
-
}
|
|
775
|
-
for (const t of tickets) {
|
|
776
|
-
await stage(t.ref)
|
|
777
|
-
for (const sub of await adapter.listSubIssues(t.ref)) {
|
|
778
|
-
if (!sub.open) await stage(sub.identifier)
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return { set }
|
|
782
|
-
},
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* `latest: false` completes without taking GitHub's "Latest" badge — what
|
|
786
|
-
* reconcile passes for every release but a series' newest, so a backfilled
|
|
787
|
-
* old version cannot steal it from the one that actually is.
|
|
788
|
-
*/
|
|
789
|
-
async releaseComplete(release, { latest = true } = {}) {
|
|
790
|
-
const raw = await rest('PATCH', `${repoPath}/releases/${release.id}`, { body: { prerelease: false, make_latest: latest ? 'true' : 'false' } })
|
|
791
|
-
Object.assign(release, releaseOf(raw) || {})
|
|
792
|
-
return release
|
|
793
|
-
},
|
|
794
|
-
|
|
795
758
|
async listLabels() {
|
|
796
759
|
const raw = await restAll(`${repoPath}/labels`)
|
|
797
760
|
return raw.map((l) => ({ name: l.name, color: l.color || null }))
|
|
@@ -27,7 +27,7 @@ const {
|
|
|
27
27
|
isEmptyPlan,
|
|
28
28
|
validateStates,
|
|
29
29
|
stateSuggestions,
|
|
30
|
-
|
|
30
|
+
stateNamesFor,
|
|
31
31
|
remoteDescriptionEdited,
|
|
32
32
|
writeFrontmatter,
|
|
33
33
|
stampSubIssueId,
|
|
@@ -62,12 +62,13 @@ const { makeApiAdapter } = require('./api.js')
|
|
|
62
62
|
const { APPLY_OVER_MCP } = require('./mcp.js')
|
|
63
63
|
const { resolveIdentity, displayNameOf } = require('./identity.js')
|
|
64
64
|
const { makeAssignmentCommands } = require('../provider-kit/src/assignment.js')
|
|
65
|
-
const {
|
|
65
|
+
const { resolveListAssignee } = require('../provider-kit/src/list-assignee.js')
|
|
66
|
+
const { expandStateArgs, specColumn, specCell } = require('../provider-kit/src/list-rows.js')
|
|
66
67
|
|
|
67
68
|
const PROGRAM = 'spec-sync'
|
|
68
69
|
const BIN = 'skitterspec-github'
|
|
69
70
|
const specHelpers = kit.makeSpecHelpers({ program: PROGRAM })
|
|
70
|
-
const { resolveSnapshotDir, specIdentifier, listSpecs, resolveOrExit, warnToErr, verifyLines } = specHelpers
|
|
71
|
+
const { resolveSnapshotDir, specIdentifier, listSpecs, listSpecsLive, resolveOrExit, warnToErr, verifyLines } = specHelpers
|
|
71
72
|
|
|
72
73
|
// An issue reference as typed: `#123` or `123`. Stamped as `#123`.
|
|
73
74
|
const ID_RE = /^#?\d+$/
|
|
@@ -137,7 +138,17 @@ function stateCheckFailure(config, flags) {
|
|
|
137
138
|
// issue's own open/closed where the bucket calls for it. Both are idempotent —
|
|
138
139
|
// a Status already set is left alone, and the issue is only opened or closed
|
|
139
140
|
// when it is not already.
|
|
140
|
-
|
|
141
|
+
// A spec's KIND, read off its folder prefix — the same convention the
|
|
142
|
+
// lifecycle skills stamp into `> **Type:**`, but greppable with no file read.
|
|
143
|
+
function specKindOf(snapshotDir) {
|
|
144
|
+
const name = path.basename(String(snapshotDir || ''))
|
|
145
|
+
if (name.startsWith('bug-')) return 'bug'
|
|
146
|
+
if (name.startsWith('hotfix-')) return 'hotfix'
|
|
147
|
+
if (name.startsWith('chore-')) return 'chore'
|
|
148
|
+
return 'feature'
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function applyOps({ adapter, config, kind = 'feature' }) {
|
|
141
152
|
const statusFor = (bucket) => {
|
|
142
153
|
const name = config.states && config.states[bucket]
|
|
143
154
|
if (!name) {
|
|
@@ -184,6 +195,13 @@ function applyOps({ adapter, config }) {
|
|
|
184
195
|
}
|
|
185
196
|
const spec = markersFor(config, 'spec')
|
|
186
197
|
const phase = markersFor(config, 'phase')
|
|
198
|
+
// THIS spec's kind label (github.labelsByKind), beside the spec marker.
|
|
199
|
+
// Unmapped kinds add nothing, so an unconfigured project's payloads are
|
|
200
|
+
// byte-identical to before the key existed.
|
|
201
|
+
const kindLabel = (config.github.labelsByKind || {})[kind]
|
|
202
|
+
if (kindLabel && !spec.labels.some((l) => l.toLowerCase() === kindLabel.toLowerCase())) {
|
|
203
|
+
spec.labels = [...spec.labels, kindLabel]
|
|
204
|
+
}
|
|
187
205
|
return {
|
|
188
206
|
prevalidateStates: (buckets) => {
|
|
189
207
|
for (const bucket of buckets) statusFor(bucket)
|
|
@@ -247,8 +265,7 @@ function applyOps({ adapter, config }) {
|
|
|
247
265
|
|
|
248
266
|
function adapterOptions(config) {
|
|
249
267
|
const g = config.github || {}
|
|
250
|
-
|
|
251
|
-
return { owner: g.owner, repo: g.repo, project: g.project, statusField: g.statusField, deployedField }
|
|
268
|
+
return { owner: g.owner, repo: g.repo, project: g.project, statusField: g.statusField }
|
|
252
269
|
}
|
|
253
270
|
|
|
254
271
|
function apiAdapterFor(config, flags) {
|
|
@@ -379,7 +396,7 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
379
396
|
snapshotDir,
|
|
380
397
|
plan,
|
|
381
398
|
adapter: cred.adapter,
|
|
382
|
-
ops: applyOps({ adapter: cred.adapter, config }),
|
|
399
|
+
ops: applyOps({ adapter: cred.adapter, config, kind: specKindOf(snapshotDir) }),
|
|
383
400
|
forceNew: !!flags.forceNew,
|
|
384
401
|
program: PROGRAM,
|
|
385
402
|
})
|
|
@@ -555,13 +572,9 @@ function specSyncStatus(dir, config, specArg, flags, out, err) {
|
|
|
555
572
|
out.write(`${PROGRAM} status: cannot read --remote: ${error.message}\n`)
|
|
556
573
|
return 1
|
|
557
574
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
lines.push(` drift: the board says "${bucket}", the repo says "${local}" (repo wins on next push)`)
|
|
562
|
-
} else if (bucket) {
|
|
563
|
-
lines.push(' drift: none — the board agrees with the repo')
|
|
564
|
-
}
|
|
575
|
+
// NO STATE LINE, deliberately: skitterspec tells the tracker about its own
|
|
576
|
+
// transitions and never reads a status back. A ticket someone moved there
|
|
577
|
+
// is theirs to have moved, and push resends State only when the spec does.
|
|
565
578
|
// SILENT ON EVERYTHING EXCEPT A POSITIVE ANSWER: `remoteDescriptionEdited`
|
|
566
579
|
// returns null for every cannot-tell, and none of those is evidence.
|
|
567
580
|
if (remoteDescriptionEdited(readBase(dir, identifier, config), remote, config) === true) {
|
|
@@ -677,6 +690,12 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
677
690
|
? `ok · ${issue}`
|
|
678
691
|
: `MISSING from the board${suggestions.get(bucket) ? ` — closest: "${suggestions.get(bucket)}"` : ''}`
|
|
679
692
|
lines.push(` ${bucket.padEnd(bw)} -> ${String(name).padEnd(nw)} ${tail}`)
|
|
693
|
+
// Aliases are read-only, so a missing one never blocks a push — but it
|
|
694
|
+
// reads as nothing, so it is still named.
|
|
695
|
+
for (const alias of stateNamesFor(bucket, config).slice(1)) {
|
|
696
|
+
const here = names.includes(alias)
|
|
697
|
+
lines.push(` ${''.padEnd(bw)} ${String(alias).padEnd(nw)} ${here ? 'also reads as ' + bucket : 'alias MISSING — reads as nothing'}`)
|
|
698
|
+
}
|
|
680
699
|
}
|
|
681
700
|
if (missing.length) {
|
|
682
701
|
lines.push(` remap: ${PROGRAM} init-config --force … --state <bucket>="<option>", or add the option on the board`)
|
|
@@ -686,6 +705,14 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
686
705
|
}
|
|
687
706
|
|
|
688
707
|
async function specSyncList(dir, config, flags, out) {
|
|
708
|
+
// `--next N` is the top of the backlog in BOARD order, so it fixes the scope
|
|
709
|
+
// itself; with --state or --all one would have to lose, silently.
|
|
710
|
+
const next = Number.isFinite(flags.next) && flags.next > 0 ? flags.next : null
|
|
711
|
+
const scopeFlags = [next !== null && '--next', flags.all === true && '--all', (flags.stateArgs || []).length > 0 && '--state'].filter(Boolean)
|
|
712
|
+
if (scopeFlags.length > 1) {
|
|
713
|
+
out.write(`${PROGRAM} list: ${scopeFlags.join(' and ')} each pick the scope, so they cannot be combined\n`)
|
|
714
|
+
return 1
|
|
715
|
+
}
|
|
689
716
|
const cred = apiAdapterFor(config, flags)
|
|
690
717
|
const transport = kit.resolveTransport(flags, config, cred.ok)
|
|
691
718
|
if (transport === 'mcp' || !cred.ok) {
|
|
@@ -699,41 +726,83 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
699
726
|
out.write(`${PROGRAM} list: ${gap}\n`)
|
|
700
727
|
return 1
|
|
701
728
|
}
|
|
729
|
+
const who = await resolveListAssignee({
|
|
730
|
+
flags,
|
|
731
|
+
config,
|
|
732
|
+
env: flags.env || process.env,
|
|
733
|
+
adapter: cred.adapter,
|
|
734
|
+
resolveIdentity,
|
|
735
|
+
displayNameOf,
|
|
736
|
+
tracker: 'GitHub',
|
|
737
|
+
prog: PROGRAM,
|
|
738
|
+
})
|
|
739
|
+
if (who.code != null) {
|
|
740
|
+
out.write(who.lines.join('\n') + '\n')
|
|
741
|
+
return who.code
|
|
742
|
+
}
|
|
743
|
+
const assignee = who.assignee
|
|
702
744
|
let issues
|
|
703
745
|
try {
|
|
704
|
-
|
|
705
|
-
|
|
746
|
+
// Filtered by assignee, the spec label is dropped: an issue assigned to
|
|
747
|
+
// someone that no spec has adopted yet carries no spec label, and it is
|
|
748
|
+
// exactly the "what's next" row `--mine` exists for.
|
|
749
|
+
issues = await cred.adapter.listBoardItems(
|
|
750
|
+
assignee ? { assignee: assignee.id } : { label: markersFor(config, 'spec').labels[0] || '' },
|
|
751
|
+
)
|
|
752
|
+
const stateNames = next !== null ? stateNamesFor('backlog', config) : expandStateArgs(flags.stateArgs, config)
|
|
706
753
|
if (stateNames.length) {
|
|
707
754
|
const want = new Set(stateNames.map((s) => s.toLowerCase()))
|
|
708
755
|
issues = issues.filter((i) => i.state && want.has(String(i.state.name).toLowerCase()))
|
|
709
756
|
} else if (!flags.all) {
|
|
710
|
-
|
|
757
|
+
// Open issues, minus any whose Status is a finished bucket's name — an
|
|
758
|
+
// alias such as "Released" is finished work on an issue nobody closed.
|
|
759
|
+
const terminal = new Set(
|
|
760
|
+
[...stateNamesFor('complete', config), ...stateNamesFor('cancelled', config)].map((s) => s.toLowerCase()),
|
|
761
|
+
)
|
|
762
|
+
issues = issues.filter((i) => i.open && !(i.state && terminal.has(String(i.state.name).toLowerCase())))
|
|
763
|
+
}
|
|
764
|
+
if (next !== null) {
|
|
765
|
+
const order = await cred.adapter.listBoardOrder()
|
|
766
|
+
const rank = new Map(order.map((n, i) => [n, i]))
|
|
767
|
+
issues = issues
|
|
768
|
+
.filter((i) => i.open && rank.has(i.id))
|
|
769
|
+
.sort((a, b) => rank.get(a.id) - rank.get(b.id))
|
|
711
770
|
}
|
|
712
771
|
} catch (error) {
|
|
713
772
|
out.write(`${PROGRAM} list: ${error.message}\n`)
|
|
714
773
|
return 1
|
|
715
774
|
}
|
|
716
|
-
const linked = new Map(
|
|
775
|
+
const linked = new Map(listSpecsLive(dir, config).filter((s) => s.identifier).map((s) => [s.identifier, s]))
|
|
717
776
|
const rows = issues
|
|
718
777
|
.filter((i) => !i.parent)
|
|
719
|
-
.slice(0, flags.limit || Infinity)
|
|
720
|
-
.map((i) =>
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
778
|
+
.slice(0, next !== null ? next : flags.limit || Infinity)
|
|
779
|
+
.map((i) => {
|
|
780
|
+
const spec = linked.get(i.identifier) || null
|
|
781
|
+
const state = i.state ? i.state.name : null
|
|
782
|
+
return {
|
|
783
|
+
identifier: i.identifier,
|
|
784
|
+
title: i.title,
|
|
785
|
+
state,
|
|
786
|
+
...specColumn(state, spec, config),
|
|
787
|
+
assignee: (i.assignees || []).map((a) => a.name || a.id).join(', ') || null,
|
|
788
|
+
spec: spec ? spec.spec : null,
|
|
789
|
+
}
|
|
790
|
+
})
|
|
726
791
|
if (flags.json) {
|
|
727
792
|
out.write(JSON.stringify(rows, null, 2) + '\n')
|
|
728
793
|
return 0
|
|
729
794
|
}
|
|
730
795
|
if (!rows.length) {
|
|
731
|
-
out.write(`${PROGRAM} list: nothing matched\n`)
|
|
796
|
+
out.write(`${PROGRAM} list: nothing matched${assignee ? ` for ${assignee.name}` : ''}\n`)
|
|
732
797
|
return 0
|
|
733
798
|
}
|
|
734
|
-
const lines = [
|
|
799
|
+
const lines = [
|
|
800
|
+
`${PROGRAM} list: ${repoLabel(config)} · board ${config.github.project}${assignee ? ` · assigned to ${assignee.name}` : ''}${next !== null ? ` · next ${next} in board order` : ''}`,
|
|
801
|
+
]
|
|
735
802
|
for (const r of rows) {
|
|
736
|
-
lines.push(
|
|
803
|
+
lines.push(
|
|
804
|
+
` ${r.identifier}\t${r.state || '—'}\t${specCell(r)}\t${r.assignee || 'unassigned'}\t${r.title || ''}${r.spec ? ` -> ${r.spec}` : ' (no spec)'}`,
|
|
805
|
+
)
|
|
737
806
|
}
|
|
738
807
|
out.write(lines.join('\n') + '\n')
|
|
739
808
|
return 0
|
|
@@ -888,12 +957,13 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
888
957
|
refPattern: GITHUB_REF_RE,
|
|
889
958
|
foreignPatterns: [IDENTIFIER_RE],
|
|
890
959
|
})
|
|
960
|
+
report.tickets = kit.nameTickets(report.tickets, listSpecs(dir, config, { urls: true }))
|
|
891
961
|
if (flags.json) {
|
|
892
962
|
out.write(JSON.stringify(report, null, 2) + '\n')
|
|
893
963
|
return 0
|
|
894
964
|
}
|
|
895
965
|
const lines = [`${PROGRAM} released: ${range} — ${report.total} commit(s)`]
|
|
896
|
-
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))`)
|
|
966
|
+
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))${t.spec ? ` ${t.spec}` : ''}`)
|
|
897
967
|
if (!report.tickets.length) lines.push(' no referenced issues')
|
|
898
968
|
if (report.unreferenced) lines.push(` ${report.unreferenced} commit(s) carry no Refs: trailer`)
|
|
899
969
|
if (report.historical) lines.push(` ${report.historical} commit(s) reference an earlier tracker (KEY-N)`)
|
|
@@ -902,37 +972,6 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
902
972
|
return 0
|
|
903
973
|
}
|
|
904
974
|
|
|
905
|
-
// ---------------------------------------------------------------------------
|
|
906
|
-
// `release create | deployed | complete` — the kit's release seam
|
|
907
|
-
// (`provider-kit/src/releases.js`) on GitHub Releases plus the board's
|
|
908
|
-
// Deployed field. Run by CI on a tag push; dry unless `--apply`.
|
|
909
|
-
const releases = makeReleaseCommands({
|
|
910
|
-
tracker: 'GitHub',
|
|
911
|
-
program: PROGRAM,
|
|
912
|
-
readCommits: (dir, range) => readCommitRange(dir, range),
|
|
913
|
-
ticketOptions: (config) => ({
|
|
914
|
-
ignorePaths: (config.release && config.release.ignorePaths) || [],
|
|
915
|
-
refPattern: GITHUB_REF_RE,
|
|
916
|
-
foreignPatterns: [IDENTIFIER_RE],
|
|
917
|
-
}),
|
|
918
|
-
teamKey: () => '',
|
|
919
|
-
listSpecs: (dir, config) => listSpecs(dir, config),
|
|
920
|
-
series: (config) => (config.releases && config.releases.series) || [],
|
|
921
|
-
adapterFor: (config, flags) => {
|
|
922
|
-
const got = apiAdapterFor(config, flags)
|
|
923
|
-
if (!got.ok) return got
|
|
924
|
-
const gap = flags.adapter ? null : configGap(config)
|
|
925
|
-
return gap ? { ok: false, error: gap } : got
|
|
926
|
-
},
|
|
927
|
-
describe: (t) => `${t.ref}${t.title ? ` ${t.title}` : ''}`,
|
|
928
|
-
// GitHub's MCP server can READ releases and cannot write one — so over MCP
|
|
929
|
-
// this is impossible, not merely slower, and says so (exit 1).
|
|
930
|
-
impossibleOverMcp: (config, flags) =>
|
|
931
|
-
kit.resolveTransport(flags, config, true) === 'mcp'
|
|
932
|
-
? "transport = mcp — GitHub's MCP server has no release write tool; set a token (CI: a repo secret) and re-run"
|
|
933
|
-
: null,
|
|
934
|
-
})
|
|
935
|
-
|
|
936
975
|
// ---------------------------------------------------------------------------
|
|
937
976
|
// `preserve <spec>` — post the issue's current body back onto the issue as a
|
|
938
977
|
// comment BEFORE the linking push replaces it. Every cannot-tell exits 0: a
|
|
@@ -1219,6 +1258,8 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1219
1258
|
checks.push(row('tracker', 'GitHub config', 'broken', configGap(loaded.config), `fix ${CONFIG_FILE}`))
|
|
1220
1259
|
} else {
|
|
1221
1260
|
checks.push(row('tracker', 'GitHub config', 'ok', `${repoLabel(loaded.config)} · board ${loaded.config.github.project}`))
|
|
1261
|
+
const retired = kit.retiredKeysRow(path.join(dir, CONFIG_FILE), CONFIG_FILE, row)
|
|
1262
|
+
if (retired) checks.push(retired)
|
|
1222
1263
|
// A worktree forks from a COMMIT, so a config that exists only in the
|
|
1223
1264
|
// working tree is invisible in every spec worktree — where the sync
|
|
1224
1265
|
// skills actually run. The positive signal is git tracking the file;
|
|
@@ -1290,26 +1331,6 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1290
1331
|
)
|
|
1291
1332
|
: row('states', 'Board states', 'ok', `every configured state is a "${config.github.statusField}" option`),
|
|
1292
1333
|
)
|
|
1293
|
-
// Releases: the Deployed field and every env option a series names. Only
|
|
1294
|
-
// when a series is configured — a repo that never adopted releases has
|
|
1295
|
-
// nothing to be told about here.
|
|
1296
|
-
const series = (config.releases && config.releases.series) || []
|
|
1297
|
-
if (series.length && adapter.resolveBoard) {
|
|
1298
|
-
const field = config.releases.deployedField
|
|
1299
|
-
const board = await adapter.resolveBoard()
|
|
1300
|
-
const f = board.fields.find((x) => String(x.name).toLowerCase() === String(field).toLowerCase() && x.options)
|
|
1301
|
-
if (!f) {
|
|
1302
|
-
checks.push(row('releases', 'Deployed field', 'broken', `the board has no single-select "${field}"`, `add it on the board, or set releases.deployedField`))
|
|
1303
|
-
} else {
|
|
1304
|
-
const have = new Set(f.options.map((o) => o.name.toLowerCase()))
|
|
1305
|
-
const absent = series.flatMap((s) => Object.values(s.envs || {})).filter((o) => !have.has(o.toLowerCase()))
|
|
1306
|
-
checks.push(
|
|
1307
|
-
absent.length
|
|
1308
|
-
? row('releases', 'Deployed field', 'broken', `"${field}" lacks: ${[...new Set(absent)].join(', ')}`, 'add the options on the board, or fix releases.series envs')
|
|
1309
|
-
: row('releases', 'Deployed field', 'ok', `"${field}" has every env option`),
|
|
1310
|
-
)
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
1334
|
if (adapter.listLabels) {
|
|
1314
1335
|
const have = new Set((await adapter.listLabels()).map((l) => String(l.name).toLowerCase()))
|
|
1315
1336
|
const want = ['spec', 'phase'].flatMap((k) => markersFor(config, k).labels)
|
|
@@ -1353,12 +1374,11 @@ const USAGE = `Usage: ${BIN} spec-sync <subcommand>
|
|
|
1353
1374
|
status <spec> [--remote <f>] read-only drift report
|
|
1354
1375
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1355
1376
|
states [--json] the board's Status options + bucket map
|
|
1356
|
-
list [--all | --state NAME]
|
|
1377
|
+
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] the board's issues
|
|
1357
1378
|
intake [query] [--json] issues waiting to become specs
|
|
1358
1379
|
linked [--json] specs and their linked issues (offline)
|
|
1359
1380
|
ref [<spec>] the Refs: trailer value for this branch
|
|
1360
1381
|
released [<range>] issues a commit range contains
|
|
1361
|
-
release create|deployed|complete <tag> GitHub Release + Deployed field (CI; --apply)
|
|
1362
1382
|
preserve <spec> [--text <f>] keep an adopted issue's original report
|
|
1363
1383
|
assign <spec> --to <login> | --release stamp who is building it
|
|
1364
1384
|
whoami [--set <login>] [--unset] who you are on GitHub (cached)
|
|
@@ -1442,7 +1462,7 @@ async function specSync(rest, io = {}) {
|
|
|
1442
1462
|
case 'preserve':
|
|
1443
1463
|
return specSyncPreserve(dir, config, positional[0], flags, out)
|
|
1444
1464
|
case 'release':
|
|
1445
|
-
return
|
|
1465
|
+
return kit.refuseRemovedVerb(out, PROGRAM, 'release')
|
|
1446
1466
|
case 'assign':
|
|
1447
1467
|
return assignment.assign(dir, config, positional[0], flags, out)
|
|
1448
1468
|
case 'whoami':
|
|
@@ -1493,6 +1513,9 @@ function parseArgs(args, sub) {
|
|
|
1493
1513
|
'--to': { kind: 'string' },
|
|
1494
1514
|
'--name': { kind: 'value' },
|
|
1495
1515
|
'--release': { kind: 'boolean' },
|
|
1516
|
+
'--mine': { kind: 'boolean' },
|
|
1517
|
+
'--next': { kind: 'number' },
|
|
1518
|
+
'--by': { kind: 'string' },
|
|
1496
1519
|
'--set': { kind: 'string' },
|
|
1497
1520
|
'--unset': { kind: 'boolean' },
|
|
1498
1521
|
'--cursor': { kind: 'string' },
|