@skitterbyte/skitterspec-azure-boards 2.12.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/azure-boards.config.md +1 -0
- package/assets/rules/spec-planning.md +12 -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-azure-boards.js +8 -0
- package/package.json +1 -1
- package/src/cli.js +33 -1
- package/src/env/config.js +7 -0
- package/src/env/projectguard.js +1 -1
- package/src/idea.js +190 -0
- package/src/ideacmd.js +242 -0
- package/src/tada/todo.js +6 -1
- package/src/vendor/azure-boards/api.js +5 -3
- package/src/vendor/azure-boards/cli-sync.js +144 -11
- package/src/vendor/azure-boards/config.js +4 -0
- package/src/vendor/provider-kit/src/apply.js +90 -5
|
@@ -393,6 +393,112 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
// `idea add|list|drop` — the store `skitterspec idea` hands Azure Boards: a
|
|
397
|
+
// work item of `azure.workItemType` tagged `intake.ideaTag`, created with NO
|
|
398
|
+
// area path, so it lands at the project root and out of the spec area. `/spec
|
|
399
|
+
// <id>` adopts one like any other item, which is why an adopted one drops out
|
|
400
|
+
// of `list`.
|
|
401
|
+
//
|
|
402
|
+
// "Open" is read from the type's own state CATEGORIES, never from a list of
|
|
403
|
+
// state names: Basic, Agile, Scrum and CMMI spell Done and Removed differently.
|
|
404
|
+
// Without the API a capture REFUSES (exit 1) and hands the text back; a listing
|
|
405
|
+
// exits 0 with `count: null`, because zero ideas and "could not ask" differ.
|
|
406
|
+
async function specSyncIdea(dir, config, positional, flags, out) {
|
|
407
|
+
const [verb, ...words] = positional
|
|
408
|
+
const tag = config.intake.ideaTag
|
|
409
|
+
const type = config.azure.workItemType
|
|
410
|
+
const text = words.join(' ')
|
|
411
|
+
const say = (json, lines) => out.write(flags.json ? JSON.stringify(json, null, 2) + '\n' : lines.join('\n') + '\n')
|
|
412
|
+
const refuse = (reason, extra = {}) => {
|
|
413
|
+
const back = verb === 'add' && text ? `\n your idea, so nothing is lost:\n ${text.replace(/\n/g, '\n ')}` : ''
|
|
414
|
+
say({ ok: false, store: 'azure-boards', refused: reason, ...extra }, [`${PROGRAM} idea: ${reason}${back}`])
|
|
415
|
+
return 1
|
|
416
|
+
}
|
|
417
|
+
if (!['add', 'list', 'drop'].includes(verb)) {
|
|
418
|
+
out.write(`Usage: ${PROGRAM} idea add <text> | list [--count] | drop <id> [--reason <why>] [--json]\n`)
|
|
419
|
+
return verb ? 1 : 0
|
|
420
|
+
}
|
|
421
|
+
if (!tag) return refuse('intake.ideaTag is empty — an idea is a work item carrying that tag, so set one')
|
|
422
|
+
|
|
423
|
+
const cred = apiAdapterFor(config, flags)
|
|
424
|
+
if (kit.resolveTransport(flags, config, cred.ok) === 'mcp' || !cred.ok) {
|
|
425
|
+
const why = cred.ok ? 'pass --via api' : cred.error.split('\n')[0]
|
|
426
|
+
if (verb === 'list') {
|
|
427
|
+
say({ store: 'azure-boards', count: null, ideas: null }, [`${PROGRAM} idea: needs the API transport — ${why}`])
|
|
428
|
+
return 0
|
|
429
|
+
}
|
|
430
|
+
return refuse(`needs the API transport — ${why}; nothing was written`, verb === 'add' ? { text } : {})
|
|
431
|
+
}
|
|
432
|
+
const az = cred.adapter
|
|
433
|
+
|
|
434
|
+
const categories = async () => {
|
|
435
|
+
const states = await az.listIssueStates(type)
|
|
436
|
+
const closed = (s) => /^(completed|removed)$/i.test(String(s.category || ''))
|
|
437
|
+
return { open: states.filter((s) => !closed(s)).map((s) => s.name), states }
|
|
438
|
+
}
|
|
439
|
+
const openIdeas = async () => {
|
|
440
|
+
const { open } = await categories()
|
|
441
|
+
const claimed = new Set(listSpecs(dir, config).map((s) => s.identifier).filter(Boolean))
|
|
442
|
+
const items = await az.searchIssues({ workItemType: type, tag, states: open, limit: 200 })
|
|
443
|
+
return items.filter((i) => !claimed.has(i.identifier))
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
try {
|
|
447
|
+
if (verb === 'add') {
|
|
448
|
+
const lines = text.replace(/\r\n/g, '\n').split('\n')
|
|
449
|
+
const at = lines.findIndex((l) => l.trim())
|
|
450
|
+
if (at === -1) return refuse('nothing to capture — give the idea some text')
|
|
451
|
+
const title = lines[at].trim()
|
|
452
|
+
const description = lines.slice(at + 1).join('\n').trim()
|
|
453
|
+
const made = await az.createIssue({ title, description, workItemType: type, tags: [tag] })
|
|
454
|
+
say({ ok: true, store: 'azure-boards', action: 'add', identifier: made.identifier, url: made.url, title }, [
|
|
455
|
+
`${PROGRAM} idea: filed ${made.identifier} "${title}" (${type}, tagged "${tag}", no area path)`,
|
|
456
|
+
` url: ${made.url}`,
|
|
457
|
+
` promote: /spec ${made.identifier}`,
|
|
458
|
+
])
|
|
459
|
+
return 0
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (verb === 'list') {
|
|
463
|
+
const ideas = (await openIdeas()).map((i) => ({ identifier: i.identifier, title: i.title, promote: `/spec ${i.identifier}` }))
|
|
464
|
+
if (flags.count) {
|
|
465
|
+
say({ store: 'azure-boards', count: ideas.length }, [String(ideas.length)])
|
|
466
|
+
return 0
|
|
467
|
+
}
|
|
468
|
+
say(
|
|
469
|
+
{ store: 'azure-boards', tag, ideas },
|
|
470
|
+
ideas.length
|
|
471
|
+
? [`${PROGRAM} idea: "${tag}"`, ...ideas.map((i) => ` ${i.identifier}\t${i.title || ''}`)]
|
|
472
|
+
: [`${PROGRAM} idea: nothing waiting under "${tag}"`],
|
|
473
|
+
)
|
|
474
|
+
return 0
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// drop. Being in the open-ideas listing is the positive signal that the
|
|
478
|
+
// reference IS an idea; anything else is refused and left alone.
|
|
479
|
+
const ref = String(words[0] || '').replace(/^#/, '')
|
|
480
|
+
if (!ref) return refuse('name the idea to drop — `idea list` shows them')
|
|
481
|
+
const item = (await openIdeas()).find((i) => i.id === ref || i.identifier === words[0])
|
|
482
|
+
if (!item) return refuse(`${words[0]} is not an open idea tagged "${tag}" — left alone`)
|
|
483
|
+
const { states } = await categories()
|
|
484
|
+
const target = states.find((s) => /^removed$/i.test(String(s.category || ''))) || states.find((s) => /^completed$/i.test(String(s.category || '')))
|
|
485
|
+
if (!target) return refuse(`${type} has no Removed or Completed state to move the idea to`)
|
|
486
|
+
const why = flags.reason && String(flags.reason).trim() ? String(flags.reason).trim() : 'no reason given'
|
|
487
|
+
await az.createComment(item.id, `Dropped as an idea: ${why}`)
|
|
488
|
+
await az.transitionTo(item.id, target.name)
|
|
489
|
+
say({ ok: true, store: 'azure-boards', action: 'drop', identifier: item.identifier, title: item.title, reason: why }, [
|
|
490
|
+
`${PROGRAM} idea: dropped ${item.identifier} "${item.title || ''}" — moved to ${target.name} (${why})`,
|
|
491
|
+
])
|
|
492
|
+
return 0
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (verb === 'list') {
|
|
495
|
+
say({ store: 'azure-boards', count: null, ideas: null }, [`${PROGRAM} idea: ${error.message}`])
|
|
496
|
+
return 1
|
|
497
|
+
}
|
|
498
|
+
return refuse(`Azure DevOps refused — ${error.message}`, verb === 'add' ? { text } : {})
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
396
502
|
function apiAdapterFor(config, flags) {
|
|
397
503
|
if (flags.adapter) return { ok: true, adapter: flags.adapter }
|
|
398
504
|
const cred = resolveCredential(config, flags.env || process.env)
|
|
@@ -655,10 +761,15 @@ function companionCoverageNote(dir, config, snapshotDir, out) {
|
|
|
655
761
|
}
|
|
656
762
|
|
|
657
763
|
async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
658
|
-
if (!flags.plan && !flags.all) {
|
|
764
|
+
if (!flags.plan && !flags.all && !flags.sendHeld) {
|
|
659
765
|
out.write(`${PROGRAM} apply: pass --plan <file> (from \`plan --json\`), or --all <bucket>\n`)
|
|
660
766
|
return 1
|
|
661
767
|
}
|
|
768
|
+
const held = kit.heldFlags(flags, PROGRAM)
|
|
769
|
+
if (held.error) {
|
|
770
|
+
out.write(held.error + '\n')
|
|
771
|
+
return 1
|
|
772
|
+
}
|
|
662
773
|
const cred = apiAdapterFor(config, flags)
|
|
663
774
|
const transport = kit.resolveTransport(flags, config, cred.ok)
|
|
664
775
|
if (transport === 'mcp') {
|
|
@@ -672,6 +783,8 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
672
783
|
' create/update/add_child), then stamp the returned ids with\n' +
|
|
673
784
|
' `spec-sync stamp` and record with `spec-sync record`.\n',
|
|
674
785
|
)
|
|
786
|
+
const heldNote = kit.heldOverMcp(held, PROGRAM)
|
|
787
|
+
if (heldNote) out.write(heldNote + '\n')
|
|
675
788
|
return 0
|
|
676
789
|
}
|
|
677
790
|
if (!cred.ok) {
|
|
@@ -688,6 +801,8 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
688
801
|
adapter: cred.adapter,
|
|
689
802
|
ops: applyOps({ adapter: cred.adapter, config, out, kind: specKindOf(snapshotDir), snapshotDir }),
|
|
690
803
|
forceNew: !!flags.forceNew,
|
|
804
|
+
holdState: held.holdState,
|
|
805
|
+
sendHeld: held.sendHeld,
|
|
691
806
|
program: PROGRAM,
|
|
692
807
|
})
|
|
693
808
|
|
|
@@ -724,13 +839,19 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
724
839
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
725
840
|
if (!snapshotDir) return 1
|
|
726
841
|
let plan
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
842
|
+
if (!flags.plan) {
|
|
843
|
+
// --send-held computes its own. After the merge it is normally empty, and
|
|
844
|
+
// that empty plan is what tells apply that run 1 held the state.
|
|
845
|
+
plan = push({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config }).plan
|
|
846
|
+
} else {
|
|
847
|
+
try {
|
|
848
|
+
plan = JSON.parse(fs.readFileSync(flags.plan, 'utf-8'))
|
|
849
|
+
} catch (error) {
|
|
850
|
+
out.write(`${PROGRAM} apply: cannot read --plan: ${error.message}\n`)
|
|
851
|
+
return 1
|
|
852
|
+
}
|
|
732
853
|
}
|
|
733
|
-
if (isEmptyPlan(plan)) {
|
|
854
|
+
if (!held.sendHeld && isEmptyPlan(plan)) {
|
|
734
855
|
out.write(`${PROGRAM} apply: empty plan — nothing to do\n`)
|
|
735
856
|
return 0
|
|
736
857
|
}
|
|
@@ -823,10 +944,13 @@ async function specSyncStamp(dir, config, specArg, flags, out) {
|
|
|
823
944
|
return 0
|
|
824
945
|
}
|
|
825
946
|
|
|
826
|
-
function specSyncRecord(dir, config, specArg, out) {
|
|
947
|
+
function specSyncRecord(dir, config, specArg, flags, out) {
|
|
827
948
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
828
949
|
if (!snapshotDir) return 1
|
|
829
|
-
|
|
950
|
+
// --held: the hand-applied twin of `apply --hold-state` — the state was left
|
|
951
|
+
// out on purpose, and is recorded as sent so run 2 rewrites nothing.
|
|
952
|
+
const sent = flags && flags.held ? { issue: true, subIssues: new Set() } : null
|
|
953
|
+
const file = recordPush({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config, sent })
|
|
830
954
|
out.write(`${PROGRAM} record: snapshot written — ${path.relative(dir, file).split(path.sep).join('/')}\n`)
|
|
831
955
|
return 0
|
|
832
956
|
}
|
|
@@ -1786,16 +1910,18 @@ const USAGE = `Usage: skitterspec-azure-boards spec-sync <subcommand>
|
|
|
1786
1910
|
normalize <spec> print the local projection as JSON
|
|
1787
1911
|
plan <spec> --workspace-states <f> what a push would change (dry, JSON)
|
|
1788
1912
|
apply <spec> --plan <f> | --all <b> apply a plan over the API
|
|
1913
|
+
apply <spec> --hold-state | --send-held PR-mode completion: hold Done for run 2, then send it
|
|
1789
1914
|
restate <spec> | --all <b> resend child states to today's map (dry)
|
|
1790
1915
|
[--parents] [--apply] include the spec item; write the moves
|
|
1791
1916
|
stamp <spec> --issue AB#n [--sub r=n] write returned ids into the spec
|
|
1792
|
-
record <spec>
|
|
1917
|
+
record <spec> [--held] write the last-pushed snapshot
|
|
1793
1918
|
status <spec> [--remote <f>] read-only drift report
|
|
1794
1919
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1795
1920
|
splice <spec> --live <f> [--phase <ref>] the body to write over MCP (summary mode)
|
|
1796
1921
|
states [--json] the configured types' state names
|
|
1797
1922
|
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] tracker listing
|
|
1798
1923
|
linked [--json] specs and their linked items (offline)
|
|
1924
|
+
idea add|list|drop [--json] ideas: work items tagged intake.ideaTag
|
|
1799
1925
|
ownership [--json] who owns status and assignee (offline)
|
|
1800
1926
|
board <spec> [--json] is the item finished where the spec is not?
|
|
1801
1927
|
ref [<spec>] the Refs: trailer value for this branch
|
|
@@ -1867,7 +1993,7 @@ async function specSync(rest, io = {}) {
|
|
|
1867
1993
|
case 'stamp':
|
|
1868
1994
|
return specSyncStamp(dir, config, positional[0], flags, out)
|
|
1869
1995
|
case 'record':
|
|
1870
|
-
return specSyncRecord(dir, config, positional[0], out)
|
|
1996
|
+
return specSyncRecord(dir, config, positional[0], flags, out)
|
|
1871
1997
|
case 'status':
|
|
1872
1998
|
return specSyncStatus(dir, config, positional[0], flags, out, err)
|
|
1873
1999
|
case 'splice': {
|
|
@@ -1879,6 +2005,8 @@ async function specSync(rest, io = {}) {
|
|
|
1879
2005
|
return specSyncVerify(dir, config, positional[0], flags, out)
|
|
1880
2006
|
case 'linked':
|
|
1881
2007
|
return specSyncLinked(dir, config, flags, out)
|
|
2008
|
+
case 'idea':
|
|
2009
|
+
return specSyncIdea(dir, config, positional, flags, out)
|
|
1882
2010
|
case 'ownership':
|
|
1883
2011
|
return kit.specSyncOwnership(config, flags, out, PROGRAM)
|
|
1884
2012
|
case 'board':
|
|
@@ -1940,6 +2068,9 @@ function parseArgs(args, sub) {
|
|
|
1940
2068
|
'--via': { kind: 'string' },
|
|
1941
2069
|
'--force': { kind: 'boolean' },
|
|
1942
2070
|
'--force-new': { kind: 'boolean', name: 'forceNew' },
|
|
2071
|
+
'--hold-state': { kind: 'boolean', name: 'holdState' },
|
|
2072
|
+
'--send-held': { kind: 'boolean', name: 'sendHeld' },
|
|
2073
|
+
'--held': { kind: 'boolean' },
|
|
1943
2074
|
'--issue': { kind: 'string' },
|
|
1944
2075
|
'--url': { kind: 'value' },
|
|
1945
2076
|
'--sub': { kind: 'list', name: 'subs' },
|
|
@@ -1954,6 +2085,8 @@ function parseArgs(args, sub) {
|
|
|
1954
2085
|
'--name': { kind: 'string' },
|
|
1955
2086
|
'--release': { kind: 'boolean' },
|
|
1956
2087
|
'--if-unassigned': { kind: 'boolean', name: 'ifUnassigned' },
|
|
2088
|
+
'--reason': { kind: 'value' },
|
|
2089
|
+
'--count': { kind: 'boolean' },
|
|
1957
2090
|
'--mine': { kind: 'boolean' },
|
|
1958
2091
|
'--next': { kind: 'number' },
|
|
1959
2092
|
'--by': { kind: 'string' },
|
|
@@ -93,6 +93,8 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
93
93
|
// lists route nothing, as before.
|
|
94
94
|
intake: Object.freeze({
|
|
95
95
|
tag: '',
|
|
96
|
+
// The tag that marks a work item as an idea (`/spec-idea`).
|
|
97
|
+
ideaTag: 'idea',
|
|
96
98
|
bugTags: Object.freeze(['bug']),
|
|
97
99
|
hotfixTags: Object.freeze([]),
|
|
98
100
|
bugTypes: Object.freeze(['Bug']),
|
|
@@ -165,6 +167,7 @@ function defaults() {
|
|
|
165
167
|
stateAliases: {},
|
|
166
168
|
intake: {
|
|
167
169
|
tag: DEFAULT_CONFIG.intake.tag,
|
|
170
|
+
ideaTag: DEFAULT_CONFIG.intake.ideaTag,
|
|
168
171
|
bugTags: [...DEFAULT_CONFIG.intake.bugTags],
|
|
169
172
|
hotfixTags: [...DEFAULT_CONFIG.intake.hotfixTags],
|
|
170
173
|
bugTypes: [...DEFAULT_CONFIG.intake.bugTypes],
|
|
@@ -254,6 +257,7 @@ function mergeConfig(base, parsed) {
|
|
|
254
257
|
|
|
255
258
|
if (isObject(parsed.intake)) {
|
|
256
259
|
assign(base.intake, parsed.intake, 'tag', 'string?')
|
|
260
|
+
assign(base.intake, parsed.intake, 'ideaTag', 'string?')
|
|
257
261
|
if (Array.isArray(parsed.intake.bugTags)) base.intake.bugTags = stringList(parsed.intake.bugTags)
|
|
258
262
|
if (Array.isArray(parsed.intake.hotfixTags)) base.intake.hotfixTags = stringList(parsed.intake.hotfixTags)
|
|
259
263
|
if (Array.isArray(parsed.intake.bugTypes)) base.intake.bugTypes = stringList(parsed.intake.bugTypes)
|
|
@@ -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 }
|