@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
|
@@ -45,7 +45,7 @@ In a project that installs the GitHub superset the binary is
|
|
|
45
45
|
| "link this spec to #1 by hand" | `stamp <spec> --issue #1` |
|
|
46
46
|
| "mirror the whole backlog / every complete spec" | `apply --all <bucket>` — **confirm first** |
|
|
47
47
|
| "what ticket am I on?", writing a commit | `ref` |
|
|
48
|
-
| "what shipped in this release?" | `released` |
|
|
48
|
+
| "what shipped in this release?", "which issues does CI mark deployed?" | `released` — `--json` for a script; recording deploys is the project's own |
|
|
49
49
|
| "is any of this wired up?", "why isn't sync working?" | `doctor` — scaffold, isolation, tracker and credentials in one |
|
|
50
50
|
| "set my GitHub credentials", "am I authenticated?" | `credentials <status\|set\|unset>` |
|
|
51
51
|
| push one spec, or "what would push?" | **defer** — see below |
|
|
@@ -68,7 +68,7 @@ Two front doors to one write path is worse than none:
|
|
|
68
68
|
|
|
69
69
|
- **Push one spec** → `/spec-push`. It owns the transport choice, the
|
|
70
70
|
status-name gate, the plan, the apply, the stamping and the snapshot.
|
|
71
|
-
- **Per-spec
|
|
71
|
+
- **Per-spec status** ("is this spec in sync?", "what would push?") →
|
|
72
72
|
`/spec-status`.
|
|
73
73
|
|
|
74
74
|
Say which skill you're handing to and stop; don't reimplement either.
|
|
@@ -178,8 +178,10 @@ and never write `Refs: none`.
|
|
|
178
178
|
|
|
179
179
|
`released` reports the tickets in a commit range — by default since the most
|
|
180
180
|
recent tag, and it always prints the range it chose so a wrong default is
|
|
181
|
-
visible. It is **read-only**: it does not move anything in GitHub.
|
|
182
|
-
|
|
181
|
+
visible. It is **read-only**: it does not move anything in GitHub. Each issue
|
|
182
|
+
row names the `spec` and `url` behind it (`null` when no spec linked the ref),
|
|
183
|
+
so `--json` is what a project's CI pipes into its own tooling to record a
|
|
184
|
+
release or a deploy. Recording those is the project's job, not skitterspec's.
|
|
183
185
|
|
|
184
186
|
Relay the **unreferenced count** even when it is zero. A chore commit
|
|
185
187
|
legitimately carries no ticket and a *missed* trailer looks identical, so
|
|
@@ -193,6 +195,13 @@ A commit whose changed paths are **all** under `release.ignorePaths` (default
|
|
|
193
195
|
file still counts. Relay the **ignored count** whenever it is non-zero — that is
|
|
194
196
|
the report saying which commits it set aside.
|
|
195
197
|
|
|
198
|
+
## 7b. `release` is retired
|
|
199
|
+
|
|
200
|
+
`spec-sync release` exits 1 naming `released --json`. Recording a release or a
|
|
201
|
+
deploy is the host project's job: point the user at `released --json` (§7) and
|
|
202
|
+
`github.config.md` → "Releases and deploys". Do not re-create the old verbs out
|
|
203
|
+
of `gh` calls on their behalf.
|
|
204
|
+
|
|
196
205
|
## 8. Report
|
|
197
206
|
|
|
198
207
|
Relay the engine's output **above the block**, and name the subcommand you ran
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skitterbyte/skitterspec-github",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Spec-driven development for Claude Code, with one-way GitHub sync — a superset of @skitterbyte/skitterspec: the base filesystem workflow plus /spec-status · /spec-push · /spec-claim and the spec-sync CLI, mirroring specs to GitHub Issues, sub-issues and a Projects v2 board, with GitHub Releases. The repo is canonical; GitHub is a generated mirror. Install this OR the base OR one other superset — exactly one.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
package/src/cli.js
CHANGED
|
@@ -88,6 +88,8 @@ const {
|
|
|
88
88
|
collectReview,
|
|
89
89
|
reviewTierStack,
|
|
90
90
|
reviewTierLine,
|
|
91
|
+
isTailnetAddress,
|
|
92
|
+
tailnetLabel,
|
|
91
93
|
renderReviewPage,
|
|
92
94
|
renderReviewBlock,
|
|
93
95
|
reviewOutPath,
|
|
@@ -4258,6 +4260,10 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
4258
4260
|
// use, and the engine cannot know — that guess failed three separate ways
|
|
4259
4261
|
// in one day. Now every tier is listed, labelled, and either a URL or the
|
|
4260
4262
|
// one command that turns it on.
|
|
4263
|
+
// The runners-up print as `also:` lines inside the network tier's own
|
|
4264
|
+
// rendering — `reviewTierLine` carries them, which is what puts them
|
|
4265
|
+
// under `network:` rather than dangling after the stack (they used to
|
|
4266
|
+
// print below `remote:`, against the comment that placed them).
|
|
4261
4267
|
reviewTierStack({
|
|
4262
4268
|
served,
|
|
4263
4269
|
fileUrl: reviewFileUrl(out),
|
|
@@ -4266,11 +4272,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
4266
4272
|
})
|
|
4267
4273
|
.map((t) => reviewTierLine(t) + '\n')
|
|
4268
4274
|
.join('') +
|
|
4269
|
-
// The runners-up sit UNDER the network tier, because that is what they are
|
|
4270
|
-
// alternatives to — and virtual adapters are gone from them entirely.
|
|
4271
|
-
(served && !served.loopback && (served.alternates || []).length
|
|
4272
|
-
? served.alternates.map((u) => ` also: ${u}${tailnetLabel(u)}\n`).join('')
|
|
4273
|
-
: '') +
|
|
4274
4275
|
// WHICH TIERS THE WAIT COVERS, once, next to the stack. `local` and
|
|
4275
4276
|
// `network` are two doors into one room — the page POSTs to
|
|
4276
4277
|
// `location.pathname`, so both reach this server and this pending store.
|
|
@@ -4583,26 +4584,6 @@ function offerableLanAddresses(nets = require('node:os').networkInterfaces()) {
|
|
|
4583
4584
|
.map((e) => e.address)
|
|
4584
4585
|
}
|
|
4585
4586
|
|
|
4586
|
-
// 100.64.0.0/10 — the CGNAT range Tailscale assigns from.
|
|
4587
|
-
//
|
|
4588
|
-
// WHAT WOULD FOOL THIS: a carrier-grade NAT or another overlay network using
|
|
4589
|
-
// the same range on a utun adapter is offered too. That costs one dud `also:`
|
|
4590
|
-
// line, where filtering it hides the only link a reader off the wifi can open.
|
|
4591
|
-
function isTailnetAddress(address) {
|
|
4592
|
-
const m = /^100\.(\d+)\./.exec(address)
|
|
4593
|
-
return !!m && Number(m[1]) >= 64 && Number(m[1]) <= 127
|
|
4594
|
-
}
|
|
4595
|
-
|
|
4596
|
-
// The suffix on an `also:` line whose host is a tailnet address, so it reads
|
|
4597
|
-
// apart from the LAN one — a reader off the wifi needs to know which to tap.
|
|
4598
|
-
function tailnetLabel(url) {
|
|
4599
|
-
let host = ''
|
|
4600
|
-
try {
|
|
4601
|
-
host = new URL(url).hostname
|
|
4602
|
-
} catch {}
|
|
4603
|
-
return isTailnetAddress(host) ? ' (tailnet)' : ''
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
4587
|
/**
|
|
4607
4588
|
* Bring the review server up, or adopt the one already running.
|
|
4608
4589
|
*
|
package/src/env/review.js
CHANGED
|
@@ -715,7 +715,21 @@ function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
|
715
715
|
if (!config.review.allowNetwork) {
|
|
716
716
|
tiers.push({ tier: 'network', off: true, enable: 'skitterspec spec-env review allow network' })
|
|
717
717
|
} else if (served && !served.loopback && served.url) {
|
|
718
|
-
|
|
718
|
+
// LABELLED HERE, not by the renderer: `--json`'s `tiers` is the stack a
|
|
719
|
+
// skill copies, and an unlabelled alternate made the `(tailnet)` suffix a
|
|
720
|
+
// fact only the text render knew — so the one link a reader off the wifi
|
|
721
|
+
// could open reached the JSON indistinguishable from a second LAN address.
|
|
722
|
+
tiers.push({
|
|
723
|
+
tier: 'network',
|
|
724
|
+
url: served.url,
|
|
725
|
+
alternates: (served.alternates || []).map((u) => {
|
|
726
|
+
let host = ''
|
|
727
|
+
try {
|
|
728
|
+
host = new URL(u).hostname
|
|
729
|
+
} catch {}
|
|
730
|
+
return isTailnetAddress(host) ? { url: u, label: 'tailnet' } : { url: u }
|
|
731
|
+
}),
|
|
732
|
+
})
|
|
719
733
|
} else {
|
|
720
734
|
// Permitted, but there is no address to offer — a machine with no network,
|
|
721
735
|
// or a server that could not take one. Not a problem to report as an error.
|
|
@@ -738,13 +752,42 @@ function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
|
738
752
|
}
|
|
739
753
|
|
|
740
754
|
// One tier as a line, padded so the labels form a column the eye can run down.
|
|
755
|
+
// A tier with alternates renders them as indented `also:` lines of its own —
|
|
756
|
+
// they are PART of the tier, which is what puts them under `network:` rather
|
|
757
|
+
// than dangling after the stack (they used to print below `remote:`, against
|
|
758
|
+
// the comment that placed them).
|
|
741
759
|
function reviewTierLine(t) {
|
|
742
760
|
const label = ` ${t.tier}:`.padEnd(11)
|
|
743
|
-
if (t.url)
|
|
761
|
+
if (t.url) {
|
|
762
|
+
return [
|
|
763
|
+
`${label}${t.url}${t.note ? ` (${t.note})` : ''}`,
|
|
764
|
+
...(t.alternates || []).map((a) => ` also: ${a.url}${a.label ? ` (${a.label})` : ''}`),
|
|
765
|
+
].join('\n')
|
|
766
|
+
}
|
|
744
767
|
if (t.off) return `${label}off — turn on with: ${t.enable}`
|
|
745
768
|
return `${label}— (${t.note})`
|
|
746
769
|
}
|
|
747
770
|
|
|
771
|
+
// 100.64.0.0/10 — the CGNAT range Tailscale assigns from.
|
|
772
|
+
//
|
|
773
|
+
// WHAT WOULD FOOL THIS: a carrier-grade NAT or another overlay network using
|
|
774
|
+
// the same range on a utun adapter is offered too. That costs one dud `also:`
|
|
775
|
+
// line, where filtering it hides the only link a reader off the wifi can open.
|
|
776
|
+
function isTailnetAddress(address) {
|
|
777
|
+
const m = /^100\.(\d+)\./.exec(address)
|
|
778
|
+
return !!m && Number(m[1]) >= 64 && Number(m[1]) <= 127
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// The suffix on an `also:` line whose host is a tailnet address, so it reads
|
|
782
|
+
// apart from the LAN one — a reader off the wifi needs to know which to tap.
|
|
783
|
+
function tailnetLabel(url) {
|
|
784
|
+
let host = ''
|
|
785
|
+
try {
|
|
786
|
+
host = new URL(url).hostname
|
|
787
|
+
} catch {}
|
|
788
|
+
return isTailnetAddress(host) ? ' (tailnet)' : ''
|
|
789
|
+
}
|
|
790
|
+
|
|
748
791
|
|
|
749
792
|
// The verdicts that COMMIT, and are therefore blocked by an open comment. One
|
|
750
793
|
// list, so a fifth verdict cannot become a way around the single refusal this
|
|
@@ -2482,6 +2525,8 @@ module.exports = {
|
|
|
2482
2525
|
surfacesFor,
|
|
2483
2526
|
reviewTierStack,
|
|
2484
2527
|
reviewTierLine,
|
|
2528
|
+
isTailnetAddress,
|
|
2529
|
+
tailnetLabel,
|
|
2485
2530
|
COMMITTING,
|
|
2486
2531
|
BUTTON_SETS,
|
|
2487
2532
|
DEFAULT_BUTTON_SET,
|
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,103 +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
|
-
async releaseCreate({ tag, name, body, prerelease = true }) {
|
|
709
|
-
assertBodyFits(body, `the ${tag} release`)
|
|
710
|
-
// `make_latest: false` while staged: a release still on its way through
|
|
711
|
-
// test must not become the one GitHub shows as Latest.
|
|
712
|
-
const raw = await rest('POST', `${repoPath}/releases`, {
|
|
713
|
-
body: { tag_name: tag, name, body, prerelease, make_latest: prerelease ? 'false' : 'true' },
|
|
714
|
-
})
|
|
715
|
-
return releaseOf(raw)
|
|
716
|
-
},
|
|
717
|
-
|
|
718
|
-
async releaseUpdate(release, { name, body }) {
|
|
719
|
-
assertBodyFits(body, `the ${release.tag} release`)
|
|
720
|
-
const raw = await rest('PATCH', `${repoPath}/releases/${release.id}`, { body: { name, body } })
|
|
721
|
-
Object.assign(release, releaseOf(raw) || {})
|
|
722
|
-
return release
|
|
723
|
-
},
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* Note the release on each issue it carries — one comment per issue, found
|
|
727
|
-
* again by its marker, so a CI retry adds nothing.
|
|
728
|
-
*/
|
|
729
|
-
async releaseAttach(release, tickets) {
|
|
730
|
-
const marker = `<!-- skitterspec:released ${release.tag} -->`
|
|
731
|
-
let attached = 0
|
|
732
|
-
let already = 0
|
|
733
|
-
for (const t of tickets) {
|
|
734
|
-
const comments = await adapter.listComments(t.ref)
|
|
735
|
-
if (comments.some((c) => c.body.includes(marker))) {
|
|
736
|
-
already++
|
|
737
|
-
continue
|
|
738
|
-
}
|
|
739
|
-
await adapter.createComment(t.ref, `Shipped in [${release.tag}](${release.url || ''})\n\n${marker}`)
|
|
740
|
-
attached++
|
|
741
|
-
}
|
|
742
|
-
return { attached, already }
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* Set the board's Deployed option on every issue the release carries. The
|
|
747
|
-
* option is resolved before the first write, so an unknown name refuses
|
|
748
|
-
* with nothing changed.
|
|
749
|
-
*
|
|
750
|
-
* A commit's `Refs:` names the spec issue, never a phase, so the phases are
|
|
751
|
-
* reached through their parent — and only the CLOSED ones. An open phase of
|
|
752
|
-
* a spec landed mid-way (/spec-to-main) has not shipped, and marking it so
|
|
753
|
-
* would be a false Deployed on the board.
|
|
754
|
-
*/
|
|
755
|
-
async releaseStage(release, optionName, tickets) {
|
|
756
|
-
await optionFor(deployedField, optionName)
|
|
757
|
-
const seen = new Set()
|
|
758
|
-
let set = 0
|
|
759
|
-
const stage = async (ref) => {
|
|
760
|
-
if (seen.has(ref)) return
|
|
761
|
-
seen.add(ref)
|
|
762
|
-
const r = await adapter.setFieldOption(ref, deployedField, optionName)
|
|
763
|
-
if (r && r.changed !== false) set++
|
|
764
|
-
}
|
|
765
|
-
for (const t of tickets) {
|
|
766
|
-
await stage(t.ref)
|
|
767
|
-
for (const sub of await adapter.listSubIssues(t.ref)) {
|
|
768
|
-
if (!sub.open) await stage(sub.identifier)
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
return { set }
|
|
772
|
-
},
|
|
773
|
-
|
|
774
|
-
async releaseComplete(release) {
|
|
775
|
-
const raw = await rest('PATCH', `${repoPath}/releases/${release.id}`, { body: { prerelease: false, make_latest: 'true' } })
|
|
776
|
-
Object.assign(release, releaseOf(raw) || {})
|
|
777
|
-
return release
|
|
778
|
-
},
|
|
779
|
-
|
|
780
758
|
async listLabels() {
|
|
781
759
|
const raw = await restAll(`${repoPath}/labels`)
|
|
782
760
|
return raw.map((l) => ({ name: l.name, color: l.color || null }))
|