@skitterbyte/skitterspec-github 2.11.0 → 2.13.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/assets/core/env.config.md +5 -0
- package/assets/core/github.config.md +1 -0
- package/assets/rules/spec-planning.md +12 -0
- package/assets/rules/spec-reports.md +15 -0
- package/assets/skills/spec/SKILL.md +30 -0
- package/assets/skills/spec-cancel/SKILL.md +22 -4
- package/assets/skills/spec-complete/SKILL.md +34 -6
- package/assets/skills/spec-idea/SKILL.md +115 -0
- package/assets/skills/spec-init/SKILL.md +3 -2
- package/assets/skills/spec-review/SKILL.md +22 -4
- package/assets/skills/spec-todo/SKILL.md +3 -0
- package/bin/skitterspec-github.js +8 -0
- package/package.json +1 -1
- package/src/cli.js +81 -27
- package/src/env/config.js +7 -0
- package/src/env/projectguard.js +1 -1
- package/src/env/review.js +66 -1
- package/src/env/reviewers.js +5 -4
- package/src/env/supervise.js +71 -9
- package/src/idea.js +190 -0
- package/src/ideacmd.js +242 -0
- package/src/tada/todo.js +6 -1
- package/src/vendor/github/cli-sync.js +154 -9
- package/src/vendor/github/config.js +3 -1
- package/src/vendor/provider-kit/src/apply.js +90 -5
|
@@ -413,10 +413,15 @@ function specSyncPlan(dir, config, specArg, flags, out, err) {
|
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
416
|
-
if (!flags.plan && !flags.all) {
|
|
416
|
+
if (!flags.plan && !flags.all && !flags.sendHeld) {
|
|
417
417
|
out.write(`${PROGRAM} apply: pass --plan <file> (from \`plan --json\`), or --all <bucket>\n`)
|
|
418
418
|
return 1
|
|
419
419
|
}
|
|
420
|
+
const held = kit.heldFlags(flags, PROGRAM)
|
|
421
|
+
if (held.error) {
|
|
422
|
+
out.write(held.error + '\n')
|
|
423
|
+
return 1
|
|
424
|
+
}
|
|
420
425
|
const cred = apiAdapterFor(config, flags)
|
|
421
426
|
const transport = kit.resolveTransport(flags, config, cred.ok)
|
|
422
427
|
if (transport === 'mcp') {
|
|
@@ -425,6 +430,8 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
425
430
|
return 1
|
|
426
431
|
}
|
|
427
432
|
out.write(`${PROGRAM} apply: transport = mcp — nothing written by the engine.\n ${APPLY_OVER_MCP}\n`)
|
|
433
|
+
const heldNote = kit.heldOverMcp(held, PROGRAM)
|
|
434
|
+
if (heldNote) out.write(heldNote + '\n')
|
|
428
435
|
return 0
|
|
429
436
|
}
|
|
430
437
|
if (!cred.ok) {
|
|
@@ -446,6 +453,8 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
446
453
|
adapter: cred.adapter,
|
|
447
454
|
ops: applyOps({ adapter: cred.adapter, config, kind: specKindOf(snapshotDir), snapshotDir }),
|
|
448
455
|
forceNew: !!flags.forceNew,
|
|
456
|
+
holdState: held.holdState,
|
|
457
|
+
sendHeld: held.sendHeld,
|
|
449
458
|
program: PROGRAM,
|
|
450
459
|
})
|
|
451
460
|
|
|
@@ -488,13 +497,19 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
488
497
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
489
498
|
if (!snapshotDir) return 1
|
|
490
499
|
let plan
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
500
|
+
if (!flags.plan) {
|
|
501
|
+
// --send-held computes its own. After the merge it is normally empty, and
|
|
502
|
+
// that empty plan is what tells apply that run 1 held the state.
|
|
503
|
+
plan = push({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config }).plan
|
|
504
|
+
} else {
|
|
505
|
+
try {
|
|
506
|
+
plan = JSON.parse(fs.readFileSync(flags.plan, 'utf-8'))
|
|
507
|
+
} catch (error) {
|
|
508
|
+
out.write(`${PROGRAM} apply: cannot read --plan: ${error.message}\n`)
|
|
509
|
+
return 1
|
|
510
|
+
}
|
|
496
511
|
}
|
|
497
|
-
if (isEmptyPlan(plan)) {
|
|
512
|
+
if (!held.sendHeld && isEmptyPlan(plan)) {
|
|
498
513
|
out.write(`${PROGRAM} apply: empty plan — nothing to do\n`)
|
|
499
514
|
return 0
|
|
500
515
|
}
|
|
@@ -586,7 +601,10 @@ function specSyncRecord(dir, config, specArg, flags, out) {
|
|
|
586
601
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
587
602
|
if (!snapshotDir) return 1
|
|
588
603
|
const keepSubIssues = (flags && flags.keepSubIssues) || []
|
|
589
|
-
|
|
604
|
+
// --held: the hand-applied twin of `apply --hold-state` — the state was left
|
|
605
|
+
// out on purpose, and is recorded as sent so run 2 rewrites nothing.
|
|
606
|
+
const sent = flags && flags.held ? { issue: true, subIssues: new Set() } : null
|
|
607
|
+
const file = recordPush({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config, sent, keepSubIssues })
|
|
590
608
|
out.write(`${PROGRAM} record: snapshot written — ${path.relative(dir, file).split(path.sep).join('/')}\n`)
|
|
591
609
|
return 0
|
|
592
610
|
}
|
|
@@ -894,6 +912,10 @@ async function specSyncIntake(dir, config, query, flags, out) {
|
|
|
894
912
|
}
|
|
895
913
|
const claimed = new Set(listSpecs(dir, config).map((s) => s.identifier).filter(Boolean))
|
|
896
914
|
const own = new Set(['spec', 'phase'].flatMap((k) => markersFor(config, k).labels).map((l) => l.toLowerCase()))
|
|
915
|
+
// An idea is the operator's own parked thought, listed by `idea list`; the
|
|
916
|
+
// intake inbox is for what other people filed. Without this an unset
|
|
917
|
+
// `intake.label` (every open issue) would list each idea twice over.
|
|
918
|
+
if (config.intake.ideaLabel) own.add(config.intake.ideaLabel.toLowerCase())
|
|
897
919
|
const want = String(query || '').toLowerCase().trim()
|
|
898
920
|
const bug = new Set((config.intake.bugLabels || []).map((l) => l.toLowerCase()))
|
|
899
921
|
const hot = new Set((config.intake.hotfixLabels || []).map((l) => l.toLowerCase()))
|
|
@@ -922,6 +944,120 @@ async function specSyncIntake(dir, config, query, flags, out) {
|
|
|
922
944
|
return 0
|
|
923
945
|
}
|
|
924
946
|
|
|
947
|
+
// `idea add|list|drop` — the store `skitterspec idea` hands GitHub: an open
|
|
948
|
+
// issue carrying `intake.ideaLabel`, deliberately NEVER added to the board. The
|
|
949
|
+
// board is for specs; a parked thought does not get a column. `/spec #N` adopts
|
|
950
|
+
// one like any other issue, which is why an adopted idea drops out of `list`.
|
|
951
|
+
//
|
|
952
|
+
// Without the API a capture REFUSES (exit 1) and hands the text back with the
|
|
953
|
+
// MCP plan — a write that did not happen must not read as one that did. The
|
|
954
|
+
// listing degrades to one line and exit 0, as intake's does, and `--count`
|
|
955
|
+
// answers null rather than 0: zero ideas and "could not ask" are not the same.
|
|
956
|
+
async function specSyncIdea(dir, config, positional, flags, out) {
|
|
957
|
+
const [verb, ...words] = positional
|
|
958
|
+
const label = config.intake.ideaLabel
|
|
959
|
+
const text = words.join(' ')
|
|
960
|
+
const say = (json, lines) => out.write(flags.json ? JSON.stringify(json, null, 2) + '\n' : lines.join('\n') + '\n')
|
|
961
|
+
const refuse = (reason, extra = {}) => {
|
|
962
|
+
const back = verb === 'add' && text ? `\n your idea, so nothing is lost:\n ${text.replace(/\n/g, '\n ')}` : ''
|
|
963
|
+
say({ ok: false, store: 'github', refused: reason, ...extra }, [`${PROGRAM} idea: ${reason}${back}`])
|
|
964
|
+
return 1
|
|
965
|
+
}
|
|
966
|
+
if (!['add', 'list', 'drop'].includes(verb)) {
|
|
967
|
+
out.write(`Usage: ${PROGRAM} idea add <text> | list [--count] | drop <#N> [--reason <why>] [--json]\n`)
|
|
968
|
+
return verb ? 1 : 0
|
|
969
|
+
}
|
|
970
|
+
if (!label) return refuse('intake.ideaLabel is empty — an idea is an issue carrying that label, so set one')
|
|
971
|
+
|
|
972
|
+
const cred = apiAdapterFor(config, flags)
|
|
973
|
+
if (kit.resolveTransport(flags, config, cred.ok) === 'mcp' || !cred.ok) {
|
|
974
|
+
const why = cred.ok ? 'pass --via api' : cred.error.split('\n')[0]
|
|
975
|
+
if (verb === 'list') {
|
|
976
|
+
say({ store: 'github', count: null, ideas: null }, [
|
|
977
|
+
`${PROGRAM} idea: needs the API transport — ${why}`,
|
|
978
|
+
` (over MCP: list_issues with label "${label}", then drop the ones \`spec-sync linked\` names)`,
|
|
979
|
+
])
|
|
980
|
+
return 0
|
|
981
|
+
}
|
|
982
|
+
const plan =
|
|
983
|
+
verb === 'add'
|
|
984
|
+
? `create_issue with label "${label}" and do NOT add it to the project`
|
|
985
|
+
: `close the issue as not planned, with the reason as a comment`
|
|
986
|
+
return refuse(`needs the API transport — ${why}; nothing was written\n (over MCP: ${plan})`, verb === 'add' ? { text } : {})
|
|
987
|
+
}
|
|
988
|
+
const gh = cred.adapter
|
|
989
|
+
|
|
990
|
+
if (verb === 'add') {
|
|
991
|
+
const lines = text.replace(/\r\n/g, '\n').split('\n')
|
|
992
|
+
const at = lines.findIndex((l) => l.trim())
|
|
993
|
+
if (at === -1) return refuse('nothing to capture — give the idea some text')
|
|
994
|
+
const title = lines[at].trim()
|
|
995
|
+
const body = lines.slice(at + 1).join('\n').trim()
|
|
996
|
+
let made
|
|
997
|
+
try {
|
|
998
|
+
made = await gh.createIssue({ title, description: body, labels: [label] })
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
return refuse(`GitHub refused the idea — ${error.message}`, { text })
|
|
1001
|
+
}
|
|
1002
|
+
say({ ok: true, store: 'github', action: 'add', identifier: made.identifier, url: made.url, title }, [
|
|
1003
|
+
`${PROGRAM} idea: filed ${made.identifier} "${title}" (labelled "${label}", not on the board)`,
|
|
1004
|
+
` url: ${made.url}`,
|
|
1005
|
+
` promote: /spec ${made.identifier}`,
|
|
1006
|
+
])
|
|
1007
|
+
return 0
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
if (verb === 'list') {
|
|
1011
|
+
let issues
|
|
1012
|
+
try {
|
|
1013
|
+
issues = await gh.listIssues({ labels: [label] })
|
|
1014
|
+
} catch (error) {
|
|
1015
|
+
say({ store: 'github', count: null, ideas: null }, [`${PROGRAM} idea: ${error.message}`])
|
|
1016
|
+
return 1
|
|
1017
|
+
}
|
|
1018
|
+
const claimed = new Set(listSpecs(dir, config).map((s) => s.identifier).filter(Boolean))
|
|
1019
|
+
const ideas = issues
|
|
1020
|
+
.filter((i) => !claimed.has(i.identifier))
|
|
1021
|
+
.map((i) => ({ identifier: i.identifier, title: i.title, url: i.url, author: i.author, promote: `/spec ${i.identifier}` }))
|
|
1022
|
+
if (flags.count) {
|
|
1023
|
+
say({ store: 'github', count: ideas.length }, [String(ideas.length)])
|
|
1024
|
+
return 0
|
|
1025
|
+
}
|
|
1026
|
+
const lines = ideas.length
|
|
1027
|
+
? [`${PROGRAM} idea: ${repoLabel(config)} · "${label}"`, ...ideas.map((i) => ` ${i.identifier}\t${i.title || ''}${i.author ? ` (${i.author})` : ''}`)]
|
|
1028
|
+
: [`${PROGRAM} idea: nothing waiting under "${label}"`]
|
|
1029
|
+
say({ store: 'github', label, ideas }, lines)
|
|
1030
|
+
return 0
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// drop
|
|
1034
|
+
const ref = words[0]
|
|
1035
|
+
if (!ref) return refuse('name the idea to drop — `idea list` shows them')
|
|
1036
|
+
let issue
|
|
1037
|
+
try {
|
|
1038
|
+
issue = await gh.readIssue(ref)
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
return refuse(error.message)
|
|
1041
|
+
}
|
|
1042
|
+
if (!issue) return refuse(`no GitHub issue ${ref}`)
|
|
1043
|
+
// Closing an arbitrary issue under the name of an idea is the expensive
|
|
1044
|
+
// mistake here, so the label is the positive signal that it is one.
|
|
1045
|
+
if (!(issue.labels || []).some((l) => String(l).toLowerCase() === label.toLowerCase())) {
|
|
1046
|
+
return refuse(`${issue.identifier || ref} does not carry "${label}" — not an idea, left open`)
|
|
1047
|
+
}
|
|
1048
|
+
const why = flags.reason && String(flags.reason).trim() ? String(flags.reason).trim() : 'no reason given'
|
|
1049
|
+
try {
|
|
1050
|
+
await gh.createComment(ref, `Dropped as an idea: ${why}`)
|
|
1051
|
+
await gh.setIssueOpen(ref, { open: false, reason: 'not_planned' })
|
|
1052
|
+
} catch (error) {
|
|
1053
|
+
return refuse(`GitHub refused the drop — ${error.message}`)
|
|
1054
|
+
}
|
|
1055
|
+
say({ ok: true, store: 'github', action: 'drop', identifier: issue.identifier, title: issue.title, reason: why }, [
|
|
1056
|
+
`${PROGRAM} idea: dropped ${issue.identifier} "${issue.title || ''}" — closed as not planned (${why})`,
|
|
1057
|
+
])
|
|
1058
|
+
return 0
|
|
1059
|
+
}
|
|
1060
|
+
|
|
925
1061
|
// The `Refs:` trailer's source of truth: the ticket for the spec this branch
|
|
926
1062
|
// (or the named spec) belongs to. Bare identifier on stdout ONLY on success —
|
|
927
1063
|
// every no-ref case writes stderr and exits 1, so `$(spec-sync ref)` cannot
|
|
@@ -1493,14 +1629,16 @@ const USAGE = `Usage: ${BIN} spec-sync <subcommand>
|
|
|
1493
1629
|
normalize <spec> print the local projection as JSON
|
|
1494
1630
|
plan <spec> --workspace-states <f> what a push would change (dry, JSON)
|
|
1495
1631
|
apply <spec> --plan <f> | --all <b> apply a plan over the API
|
|
1632
|
+
apply <spec> --hold-state | --send-held PR-mode completion: hold Done for run 2, then send it
|
|
1496
1633
|
stamp <spec> --issue #N [--sub r=#N] write returned numbers into the spec
|
|
1497
|
-
record <spec>
|
|
1634
|
+
record <spec> [--held] write the last-pushed snapshot
|
|
1498
1635
|
status <spec> [--remote <f>] read-only drift report
|
|
1499
1636
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1500
1637
|
splice <spec> --live <f> [--phase <ref>] the body to write over MCP (summary mode)
|
|
1501
1638
|
states [--json] the board's Status options + bucket map
|
|
1502
1639
|
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] the board's issues
|
|
1503
1640
|
intake [query] [--json] issues waiting to become specs
|
|
1641
|
+
idea add|list|drop [--json] ideas: issues labelled intake.ideaLabel, off the board
|
|
1504
1642
|
linked [--json] specs and their linked issues (offline)
|
|
1505
1643
|
ownership [--json] who owns status and assignee (offline)
|
|
1506
1644
|
board <spec> [--json] is the issue finished where the spec is not?
|
|
@@ -1594,6 +1732,8 @@ async function specSync(rest, io = {}) {
|
|
|
1594
1732
|
return specSyncList(dir, config, flags, out)
|
|
1595
1733
|
case 'intake':
|
|
1596
1734
|
return specSyncIntake(dir, config, positional[0], flags, out)
|
|
1735
|
+
case 'idea':
|
|
1736
|
+
return specSyncIdea(dir, config, positional, flags, out)
|
|
1597
1737
|
case 'ref':
|
|
1598
1738
|
return specSyncRef(dir, config, positional[0], flags, out, err)
|
|
1599
1739
|
case 'released':
|
|
@@ -1644,6 +1784,9 @@ function parseArgs(args, sub) {
|
|
|
1644
1784
|
'--via': { kind: 'string' },
|
|
1645
1785
|
'--force': { kind: 'boolean' },
|
|
1646
1786
|
'--force-new': { kind: 'boolean', name: 'forceNew' },
|
|
1787
|
+
'--hold-state': { kind: 'boolean', name: 'holdState' },
|
|
1788
|
+
'--send-held': { kind: 'boolean', name: 'sendHeld' },
|
|
1789
|
+
'--held': { kind: 'boolean' },
|
|
1647
1790
|
'--issue': { kind: 'string' },
|
|
1648
1791
|
'--url': { kind: 'value' },
|
|
1649
1792
|
'--sub': { kind: 'list', name: 'subs' },
|
|
@@ -1660,6 +1803,8 @@ function parseArgs(args, sub) {
|
|
|
1660
1803
|
'--name': { kind: 'value' },
|
|
1661
1804
|
'--release': { kind: 'boolean' },
|
|
1662
1805
|
'--if-unassigned': { kind: 'boolean', name: 'ifUnassigned' },
|
|
1806
|
+
'--reason': { kind: 'value' },
|
|
1807
|
+
'--count': { kind: 'boolean' },
|
|
1663
1808
|
'--mine': { kind: 'boolean' },
|
|
1664
1809
|
'--next': { kind: 'number' },
|
|
1665
1810
|
'--by': { kind: 'string' },
|
|
@@ -92,7 +92,7 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
92
92
|
assigneeId: 'github_assignee_id',
|
|
93
93
|
assigneeName: 'github_assignee_name',
|
|
94
94
|
}),
|
|
95
|
-
intake: Object.freeze({ label: '', bugLabels: Object.freeze(['bug']), hotfixLabels: Object.freeze([]) }),
|
|
95
|
+
intake: Object.freeze({ label: '', ideaLabel: 'idea', bugLabels: Object.freeze(['bug']), hotfixLabels: Object.freeze([]) }),
|
|
96
96
|
release: Object.freeze({ ignorePaths: Object.freeze(['specs/', 'CHANGELOG.md', 'RELEASES.md']) }),
|
|
97
97
|
branch: Object.freeze({ pattern: '{type}/{slug}' }),
|
|
98
98
|
// An env-var NAME, not a value. A classic PAT with `repo` + `project`: the
|
|
@@ -145,6 +145,7 @@ function defaults() {
|
|
|
145
145
|
fields: { ...DEFAULT_CONFIG.fields },
|
|
146
146
|
intake: {
|
|
147
147
|
label: DEFAULT_CONFIG.intake.label,
|
|
148
|
+
ideaLabel: DEFAULT_CONFIG.intake.ideaLabel,
|
|
148
149
|
bugLabels: [...DEFAULT_CONFIG.intake.bugLabels],
|
|
149
150
|
hotfixLabels: [...DEFAULT_CONFIG.intake.hotfixLabels],
|
|
150
151
|
},
|
|
@@ -246,6 +247,7 @@ function mergeConfig(base, parsed) {
|
|
|
246
247
|
|
|
247
248
|
if (isObject(parsed.intake)) {
|
|
248
249
|
assign(base.intake, parsed.intake, 'label', 'string?')
|
|
250
|
+
assign(base.intake, parsed.intake, 'ideaLabel', 'string?')
|
|
249
251
|
if (Array.isArray(parsed.intake.bugLabels)) base.intake.bugLabels = stringList(parsed.intake.bugLabels)
|
|
250
252
|
if (Array.isArray(parsed.intake.hotfixLabels)) base.intake.hotfixLabels = stringList(parsed.intake.hotfixLabels)
|
|
251
253
|
}
|
|
@@ -52,6 +52,7 @@ const path = require('node:path')
|
|
|
52
52
|
const {
|
|
53
53
|
readSnapshot,
|
|
54
54
|
readBase,
|
|
55
|
+
isEmptyPlan,
|
|
55
56
|
projectionOf,
|
|
56
57
|
recordPush,
|
|
57
58
|
writeFrontmatter,
|
|
@@ -85,16 +86,58 @@ async function applySpecPlan(args) {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
async function applyInner({
|
|
89
|
+
async function applyInner({
|
|
90
|
+
dir,
|
|
91
|
+
config,
|
|
92
|
+
snapshotDir,
|
|
93
|
+
plan,
|
|
94
|
+
adapter,
|
|
95
|
+
ops,
|
|
96
|
+
progress,
|
|
97
|
+
forceNew = false,
|
|
98
|
+
holdState = false,
|
|
99
|
+
sendHeld = false,
|
|
100
|
+
program = 'spec-sync',
|
|
101
|
+
}) {
|
|
89
102
|
const fields = fieldsOf(config)
|
|
90
103
|
const helpers = makeSpecHelpers({ program })
|
|
91
104
|
const overviewFile = (config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
|
|
92
105
|
const identifier = helpers.linkedIdentifier(path.join(snapshotDir, overviewFile), config)
|
|
93
106
|
const lines = []
|
|
94
107
|
const result = { issue: null, subIssues: {} }
|
|
108
|
+
|
|
109
|
+
// PR-MODE COMPLETION, `branch` lane (spec bug-pr-complete-snapshot-on-base).
|
|
110
|
+
// Run 1 commits the move to ride the PR, but the Done waits for the merge —
|
|
111
|
+
// and run 2 sends it from the base branch, where no spec branch is left to
|
|
112
|
+
// commit a snapshot to. So run 1 HOLDS the state yet records it as sent, and
|
|
113
|
+
// run 2 SENDS only that state: the snapshot it records is byte-identical to
|
|
114
|
+
// the one the merge brought, and the base branch stays clean.
|
|
115
|
+
if (holdState && sendHeld) throw new Error(`${program} apply: --hold-state and --send-held are two runs, not one`)
|
|
116
|
+
if ((holdState || sendHeld) && !identifier) {
|
|
117
|
+
throw new Error(`${program} apply: an unlinked spec has no transition to hold — push it plainly`)
|
|
118
|
+
}
|
|
119
|
+
let heldState = false
|
|
120
|
+
let fellBack = false
|
|
121
|
+
if (holdState && plan.issue && plan.issue.state != null) {
|
|
122
|
+
const { state, stateResend, ...rest } = plan.issue
|
|
123
|
+
plan = { ...plan, issue: Object.keys(rest).length ? rest : undefined }
|
|
124
|
+
heldState = state
|
|
125
|
+
} else if (sendHeld) {
|
|
126
|
+
// A NON-EMPTY PLAN MEANS RUN 1 HELD NOTHING — it predates the hold, so the
|
|
127
|
+
// whole completion is still unsent. Sending the state alone would strand
|
|
128
|
+
// the rest; apply it all, as before, and say which file that leaves dirty.
|
|
129
|
+
if (isEmptyPlan(plan)) {
|
|
130
|
+
const status = projectionOf(snapshotDir, config).status
|
|
131
|
+
if (status != null) plan = { ...plan, issue: { state: status } }
|
|
132
|
+
} else {
|
|
133
|
+
fellBack = true
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
95
137
|
// Which items this apply carried a state for — the snapshot records today's
|
|
96
|
-
// state name for these and only these (`recordPush`).
|
|
97
|
-
|
|
138
|
+
// state name for these and only these (`recordPush`). A held state counts:
|
|
139
|
+
// run 2 sends it, and what run 2 records has to match what run 1 committed.
|
|
140
|
+
const sent = { issue: !!heldState || !!(plan.issue && plan.issue.state != null), subIssues: new Set() }
|
|
98
141
|
// Handed out immediately, so a throw from anywhere below still reports what
|
|
99
142
|
// had been stamped by the time it happened.
|
|
100
143
|
if (progress) progress.result = result
|
|
@@ -268,7 +311,12 @@ async function applyInner({ dir, config, snapshotDir, plan, adapter, ops, progre
|
|
|
268
311
|
const file = recordPush({ dir, snapshotDir, identifier: helpers.specIdentifier(snapshotDir, config), config, sent, keepSubIssues })
|
|
269
312
|
// A repo path, `/`-separated on every platform — the form every other
|
|
270
313
|
// spec path in this output takes.
|
|
271
|
-
|
|
314
|
+
const snapshotPath = path.relative(dir, file).split(path.sep).join('/')
|
|
315
|
+
lines.push(` snapshot: ${snapshotPath}`)
|
|
316
|
+
if (heldState) lines.push(` state held: ${identifier} → ${heldState} waits for the merge — run 2 sends it with --send-held`)
|
|
317
|
+
if (fellBack) {
|
|
318
|
+
lines.push(` !! nothing was held for ${identifier} — sent the whole plan; ${snapshotPath} now differs from the merged copy`)
|
|
319
|
+
}
|
|
272
320
|
return { result, lines, lost }
|
|
273
321
|
}
|
|
274
322
|
|
|
@@ -304,4 +352,41 @@ function resolvePhaseFileIn(snapshotDir, ref) {
|
|
|
304
352
|
return listPhaseFiles(snapshotDir).find((f) => f.replace(/\.md$/, '') === want) || null
|
|
305
353
|
}
|
|
306
354
|
|
|
307
|
-
|
|
355
|
+
/**
|
|
356
|
+
* `--hold-state` / `--send-held` as every provider's `apply` reads them: one
|
|
357
|
+
* spec, one of the two, never both. Returns `{ holdState, sendHeld }`, or
|
|
358
|
+
* `{ error }` for the provider to print and exit 1 on.
|
|
359
|
+
*/
|
|
360
|
+
function heldFlags(flags, program) {
|
|
361
|
+
const holdState = !!(flags && flags.holdState)
|
|
362
|
+
const sendHeld = !!(flags && flags.sendHeld)
|
|
363
|
+
if (holdState && sendHeld) return { error: `${program} apply: --hold-state and --send-held are two runs, not one` }
|
|
364
|
+
if ((holdState || sendHeld) && flags.all != null) {
|
|
365
|
+
return { error: `${program} apply --all: --hold-state and --send-held act on one spec at a time` }
|
|
366
|
+
}
|
|
367
|
+
return { holdState, sendHeld }
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* What the MCP transport adds to its "nothing written" note, so the hand-applied
|
|
372
|
+
* push ends with the same snapshot the API path would record. Null when neither
|
|
373
|
+
* flag is set.
|
|
374
|
+
*/
|
|
375
|
+
function heldOverMcp({ holdState, sendHeld }, program) {
|
|
376
|
+
if (holdState) {
|
|
377
|
+
return (
|
|
378
|
+
" --hold-state: apply the plan WITHOUT the spec issue's state, then record with\n" +
|
|
379
|
+
` \`${program} record <spec> --held\` — run 2 sends the state after the merge.`
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
if (sendHeld) {
|
|
383
|
+
return (
|
|
384
|
+
" --send-held: if `plan` is empty, send the spec issue's state alone and record\n" +
|
|
385
|
+
' nothing — the merged snapshot already says it. If it is not, run 1 held\n' +
|
|
386
|
+
' nothing: apply it whole and record as usual.'
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
return null
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
module.exports = { applySpecPlan, heldFlags, heldOverMcp }
|