@skitterbyte/skitterspec-azure-boards 2.6.1 → 2.7.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/rules/spec-planning.md +45 -7
- package/assets/skills/spec/SKILL.md +37 -6
- package/assets/skills/spec-complete/SKILL.md +29 -0
- package/assets/skills/spec-list/SKILL.md +4 -0
- package/assets/skills/spec-next/SKILL.md +35 -2
- package/assets/skills/spec-push/SKILL.md +10 -0
- package/assets/skills/spec-start/SKILL.md +32 -1
- package/assets/skills/spec-to-main/SKILL.md +10 -0
- package/package.json +1 -1
- package/src/cli.js +294 -4
- package/src/env/epic.js +541 -0
- package/src/env/inflight.js +11 -3
- package/src/env/resolve.js +18 -7
- package/src/env/specstate.js +7 -2
- package/src/vendor/azure-boards/api.js +30 -0
- package/src/vendor/azure-boards/cli-sync.js +28 -16
- package/src/vendor/azure-boards/config.js +9 -2
- package/src/vendor/provider-kit/src/apply.js +24 -0
- package/src/vendor/provider-kit/src/epic-rows.js +44 -0
- package/src/vendor/sync-core/index.js +3 -1
- package/src/vendor/sync-core/src/normalize.js +91 -9
|
@@ -335,6 +335,36 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
|
|
|
335
335
|
return { added: true }
|
|
336
336
|
},
|
|
337
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Make work item `id` a child of `parentId` — an epic member under its epic
|
|
340
|
+
* (spec feat-epics), as a Hierarchy-Reverse relation. Idempotent: an item
|
|
341
|
+
* already under it is left alone. One under another parent is MOVED — the
|
|
342
|
+
* old parent relation removed in the same patch, since an item has one
|
|
343
|
+
* parent. Read back, and refused when Azure holds anything else.
|
|
344
|
+
*/
|
|
345
|
+
async setParent(id, parentId) {
|
|
346
|
+
const raw = await request('GET', `${projectBase}/wit/workitems/${encodeURIComponent(numId(id))}`, {
|
|
347
|
+
query: { $expand: 'relations' },
|
|
348
|
+
allow404: true,
|
|
349
|
+
})
|
|
350
|
+
if (!raw || raw.id == null) throw new Error(`no work item ${identifierOf(numId(id))} to put under ${identifierOf(numId(parentId))}`)
|
|
351
|
+
const want = String(numId(parentId))
|
|
352
|
+
const relations = raw.relations || []
|
|
353
|
+
const at = relations.findIndex((r) => r && r.rel === PARENT_REL)
|
|
354
|
+
if (at !== -1 && String(idFromRelationUrl(relations[at].url)) === want) return { changed: false }
|
|
355
|
+
const ops = []
|
|
356
|
+
if (at !== -1) ops.push({ op: 'remove', path: `/relations/${at}` })
|
|
357
|
+
ops.push({ op: 'add', path: '/relations/-', value: { rel: PARENT_REL, url: itemApiUrl(want) } })
|
|
358
|
+
await request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(numId(id))}`, { body: ops, patch: true })
|
|
359
|
+
const back = await this.readIssue(id)
|
|
360
|
+
if (!back || !back.parent || back.parent.id !== want) {
|
|
361
|
+
throw new Error(
|
|
362
|
+
`${identifierOf(raw.id)} was put under ${identifierOf(want)} but Azure reads it back under ${back && back.parent ? back.parent.identifier : 'no parent'}`,
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
return { changed: true, moved: at !== -1 }
|
|
366
|
+
},
|
|
367
|
+
|
|
338
368
|
async createSubIssue(parentId, { title, description, childType, areaPath }) {
|
|
339
369
|
const ops = itemPatch({ title, description, areaPath }, bodyFieldFor(childType))
|
|
340
370
|
ops.push({
|
|
@@ -53,6 +53,7 @@ const { BUCKETS, findSpecFolder, currentBranch } = require('../../env/resolve.js
|
|
|
53
53
|
|
|
54
54
|
const { makeAssignmentCommands } = require('../provider-kit/src/assignment.js')
|
|
55
55
|
const { resolveListAssignee } = require('../provider-kit/src/list-assignee.js')
|
|
56
|
+
const { epicIdentifiers, epicOf, keepSpecIssues, groupUnderEpics } = require('../provider-kit/src/epic-rows.js')
|
|
56
57
|
const { expandStateArgs, specColumn, specCell } = require('../provider-kit/src/list-rows.js')
|
|
57
58
|
const { IDENTIFIER_RE } = require('../provider-kit/src/released.js')
|
|
58
59
|
|
|
@@ -330,6 +331,9 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
330
331
|
stateFor(bucket, config.azure.childType)
|
|
331
332
|
}
|
|
332
333
|
},
|
|
334
|
+
...(typeof adapter.setParent === 'function'
|
|
335
|
+
? { setParent: (issue, parentIdentifier) => adapter.setParent(apiId(issue.id), apiId(parentIdentifier)) }
|
|
336
|
+
: {}),
|
|
333
337
|
searchTwin: (title) => adapter.searchIssues({ query: title, workItemType: mintType }),
|
|
334
338
|
twinAdvice: (twin, wanted, specName) =>
|
|
335
339
|
`${twin.identifier} is already titled "${wanted}" and no spec claims it — ` +
|
|
@@ -633,7 +637,7 @@ function companionCoverageNote(dir, config, snapshotDir, out) {
|
|
|
633
637
|
const rawField = parsed.branch && parsed.branch.identifierField
|
|
634
638
|
const field = typeof rawField === 'string' && rawField ? rawField : config.fields.identifier
|
|
635
639
|
|
|
636
|
-
const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix|chore|issue|incident)-/, '')
|
|
640
|
+
const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix|chore|issue|incident|epic)-/, '')
|
|
637
641
|
const basePath = `${config.sync.baseDir}/${identifier}.base.json`
|
|
638
642
|
const claimed = patterns.some((p) => {
|
|
639
643
|
if (typeof p !== 'string') return false
|
|
@@ -1079,20 +1083,25 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
1079
1083
|
return 1
|
|
1080
1084
|
}
|
|
1081
1085
|
const linked = new Map(listSpecsLive(dir, config).filter((s) => s.identifier).map((s) => [s.identifier, s]))
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1086
|
+
// An epic's members are children of its Epic, kept and grouped under it
|
|
1087
|
+
// (provider-kit `epic-rows.js`, which names the blind spot). Backlog order
|
|
1088
|
+
// (`--next`) is the order asked for, and is left alone.
|
|
1089
|
+
const epics = epicIdentifiers([...linked.values()])
|
|
1090
|
+
const parentRef = (i) => i.parent.identifier
|
|
1091
|
+
let rows = keepSpecIssues(items, epics, parentRef).map((i) => {
|
|
1092
|
+
const spec = linked.get(i.identifier) || null
|
|
1093
|
+
const state = i.state ? i.state.name : null
|
|
1094
|
+
return {
|
|
1095
|
+
identifier: i.identifier,
|
|
1096
|
+
title: i.title,
|
|
1097
|
+
state,
|
|
1098
|
+
...specColumn(state, spec, config),
|
|
1099
|
+
assignee: i.assignee ? i.assignee.name || i.assignee.email || i.assignee.id : null,
|
|
1100
|
+
spec: spec ? spec.spec : null,
|
|
1101
|
+
...(epicOf(i, epics, parentRef) ? { epic: epicOf(i, epics, parentRef) } : {}),
|
|
1102
|
+
}
|
|
1103
|
+
})
|
|
1104
|
+
if (next === null) rows = groupUnderEpics(rows)
|
|
1096
1105
|
if (flags.json) {
|
|
1097
1106
|
out.write(JSON.stringify(rows, null, 2) + '\n')
|
|
1098
1107
|
return 0
|
|
@@ -1103,9 +1112,12 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
1103
1112
|
}
|
|
1104
1113
|
const scope = next !== null ? ` · next ${next} by ${config.azure.backlogOrderField}` : ''
|
|
1105
1114
|
const lines = [`${PROGRAM} list: ${config.azure.project}${assignee ? ` · assigned to ${assignee.name}` : ''}${scope}`]
|
|
1115
|
+
const shown = new Set(rows.map((r) => r.identifier))
|
|
1106
1116
|
for (const r of rows) {
|
|
1117
|
+
const lead = r.epic && shown.has(r.epic) ? ' ' : ' '
|
|
1118
|
+
const tail = r.epic && !shown.has(r.epic) ? ` (epic ${r.epic})` : ''
|
|
1107
1119
|
lines.push(
|
|
1108
|
-
|
|
1120
|
+
`${lead}${r.identifier}\t${r.state || '—'}\t${specCell(r)}\t${r.assignee || 'unassigned'}\t${r.title || ''}${r.spec ? ` -> ${r.spec}` : ' (no spec)'}${tail}`,
|
|
1109
1121
|
)
|
|
1110
1122
|
}
|
|
1111
1123
|
out.write(lines.join('\n') + '\n')
|
|
@@ -216,7 +216,7 @@ function mergeConfig(base, parsed) {
|
|
|
216
216
|
// Only the kinds a spec folder can actually be — an unknown key is
|
|
217
217
|
// dropped rather than carried into `states` validation it can never pass.
|
|
218
218
|
const byKind = {}
|
|
219
|
-
for (const kind of ['feature', 'bug', 'hotfix', 'chore', 'issue', 'incident']) {
|
|
219
|
+
for (const kind of ['feature', 'bug', 'hotfix', 'chore', 'issue', 'incident', 'epic']) {
|
|
220
220
|
const value = parsed.azure.workItemTypeByKind[kind]
|
|
221
221
|
if (typeof value === 'string' && value.trim()) byKind[kind] = value.trim()
|
|
222
222
|
}
|
|
@@ -315,13 +315,20 @@ function specKindOf(snapshotDir) {
|
|
|
315
315
|
if (name.startsWith('chore-')) return 'chore'
|
|
316
316
|
if (name.startsWith('issue-')) return 'issue'
|
|
317
317
|
if (name.startsWith('incident-')) return 'incident'
|
|
318
|
+
if (name.startsWith('epic-')) return 'epic'
|
|
318
319
|
return 'feature'
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
// The work item type a spec of this kind mints, falling back to the one
|
|
322
323
|
// configured type.
|
|
323
324
|
function mintTypeFor(config, kind) {
|
|
324
|
-
|
|
325
|
+
// An epic mints as the process's own Epic type unless the project maps it
|
|
326
|
+
// elsewhere — every Azure process ships one, and it is what makes the epic
|
|
327
|
+
// its members' parent in the backlog hierarchy (spec feat-epics).
|
|
328
|
+
return (
|
|
329
|
+
(config.azure.workItemTypeByKind && config.azure.workItemTypeByKind[kind]) ||
|
|
330
|
+
(kind === 'epic' ? 'Epic' : config.azure.workItemType)
|
|
331
|
+
)
|
|
325
332
|
}
|
|
326
333
|
|
|
327
334
|
// The state a bucket writes for one work item type: statesByType[type] over
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
* - `remoteEditedLine(identifier)` the someone-else-edited warning
|
|
38
38
|
* - `twinAdvice(twin, title, specName)` the refusal message for a twin
|
|
39
39
|
* - `afterIssue(issue)` optional; → a report line or null
|
|
40
|
+
* - `setParent(issue, parentIdentifier)` optional; make the spec issue a
|
|
41
|
+
* child of its epic's → `{ changed }`.
|
|
42
|
+
* Absent means this tracker cannot
|
|
43
|
+
* express it, and the push says so.
|
|
40
44
|
*/
|
|
41
45
|
|
|
42
46
|
const path = require('node:path')
|
|
@@ -54,6 +58,7 @@ const {
|
|
|
54
58
|
listPhaseFiles,
|
|
55
59
|
descriptionMode,
|
|
56
60
|
spliceBlock,
|
|
61
|
+
linkedEpic,
|
|
57
62
|
} = require('../../sync-core')
|
|
58
63
|
const { makeSpecHelpers } = require('./specs.js')
|
|
59
64
|
|
|
@@ -163,6 +168,25 @@ async function applyInner({ dir, config, snapshotDir, plan, adapter, ops, progre
|
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
|
|
171
|
+
// An epic member's issue is a child of its epic's (spec feat-epics,
|
|
172
|
+
// Decision 6). Never fatal and never a mint: an epic not linked yet is named
|
|
173
|
+
// and skipped, and a tracker with no way to say "parent" says so.
|
|
174
|
+
const epic = result.issue ? linkedEpic(snapshotDir, config) : null
|
|
175
|
+
if (epic) {
|
|
176
|
+
if (!epic.identifier) {
|
|
177
|
+
lines.push(` !! epic ${epic.name} is not linked yet — parent skipped (push the epic first)`)
|
|
178
|
+
} else if (typeof ops.setParent !== 'function') {
|
|
179
|
+
lines.push(` epic ${epic.identifier}: this tracker cannot express a parent here — skipped`)
|
|
180
|
+
} else {
|
|
181
|
+
try {
|
|
182
|
+
const r = await ops.setParent(result.issue, epic.identifier)
|
|
183
|
+
if (r && r.changed) lines.push(` parent set: ${result.issue.identifier} under epic ${epic.identifier}`)
|
|
184
|
+
} catch (error) {
|
|
185
|
+
lines.push(` ?? parent ${epic.identifier}: ${String((error && error.message) || error).split('\n')[0]}`)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
166
190
|
// 4. Sub-issue creates — each stamped as it lands, for the same reason.
|
|
167
191
|
for (const sub of (plan.subIssues && plan.subIssues.create) || []) {
|
|
168
192
|
const created = await ops.mintSubIssue(parentId, sub)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Epic members in a tracker listing (spec feat-epics). A listing keeps only
|
|
5
|
+
* top-level issues because a sub-issue is normally a phase — but an epic's
|
|
6
|
+
* member is a spec that is ALSO a sub-issue, of its epic's issue. These keep
|
|
7
|
+
* such a member and group it under its epic, on a positive signal only: its
|
|
8
|
+
* parent is linked to an `epic-` spec in this checkout.
|
|
9
|
+
*
|
|
10
|
+
* BLIND SPOT: an epic this checkout has no linked copy of reads as an unknown
|
|
11
|
+
* parent, so its members stay filtered out exactly as they were before epics
|
|
12
|
+
* existed — a missing row, never a phase shown as a spec.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The identifiers of the `epic-` specs in a `listSpecs`-shaped array. */
|
|
16
|
+
function epicIdentifiers(specs) {
|
|
17
|
+
return new Set((specs || []).filter((s) => s && s.identifier && /^epic-/.test(s.spec)).map((s) => s.identifier))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The epic an issue is a member of, or null. `parentOf(issue)` gives the
|
|
22
|
+
* parent's identifier in the provider's own spelling.
|
|
23
|
+
*/
|
|
24
|
+
function epicOf(issue, epics, parentOf) {
|
|
25
|
+
const parent = issue && issue.parent ? parentOf(issue) : null
|
|
26
|
+
return parent && epics.has(parent) ? parent : null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Top-level issues, plus the members of a linked epic. */
|
|
30
|
+
function keepSpecIssues(issues, epics, parentOf) {
|
|
31
|
+
return (issues || []).filter((i) => !i.parent || epicOf(i, epics, parentOf))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Rows reordered so each member follows its epic's row. A member whose epic's
|
|
36
|
+
* row is not in the listing keeps its place. Rows carry `epic` when a member.
|
|
37
|
+
*/
|
|
38
|
+
function groupUnderEpics(rows) {
|
|
39
|
+
const listed = new Set(rows.map((r) => r.identifier))
|
|
40
|
+
const under = (id) => rows.filter((r) => r.epic === id)
|
|
41
|
+
return rows.filter((r) => !r.epic || !listed.has(r.epic)).flatMap((r) => [r, ...under(r.identifier)])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { epicIdentifiers, epicOf, keepSpecIssues, groupUnderEpics }
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* stored matches what was sent — it merges nothing (see `src/verify.js`).
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
const { ownsField, ownershipOf, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState, remoteStateReading, stateNamesFor, titleFromText, validateStates, stateSuggestions, effectiveStates, specHeaders, linkedIncident, phaseModeFor } = require('./src/normalize.js')
|
|
16
|
+
const { ownsField, ownershipOf, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState, remoteStateReading, stateNamesFor, titleFromText, validateStates, stateSuggestions, effectiveStates, specHeaders, parseWaitsOn, linkedIncident, linkedEpic, phaseModeFor } = require('./src/normalize.js')
|
|
17
17
|
const { planChanges, snapshotOf, isEmptyPlan, hashField, stableStringify, remoteDescriptionEdited, remoteSubIssueEdited } = require('./src/compare.js')
|
|
18
18
|
const { readBase, writeBase } = require('./src/base.js')
|
|
19
19
|
const { push, recordPush, projectionOf } = require('./src/push.js')
|
|
@@ -50,7 +50,9 @@ module.exports = {
|
|
|
50
50
|
stateSuggestions,
|
|
51
51
|
effectiveStates,
|
|
52
52
|
specHeaders,
|
|
53
|
+
parseWaitsOn,
|
|
53
54
|
linkedIncident,
|
|
55
|
+
linkedEpic,
|
|
54
56
|
hashField,
|
|
55
57
|
stableStringify,
|
|
56
58
|
readBase,
|
|
@@ -435,24 +435,68 @@ function readSnapshot(snapshotDir, config) {
|
|
|
435
435
|
return { frontmatter: data, title, sections, phases, body }
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
// The spec's own `> **Severity
|
|
439
|
-
//
|
|
440
|
-
// keys on `normalizeLocal`'s
|
|
441
|
-
// home (a field, a label)
|
|
442
|
-
//
|
|
438
|
+
// The spec's own `> **Severity:**`, `> **Incident:**`, `> **Epic:**`,
|
|
439
|
+
// `> **Waits on:**` and `> **Lanes:**` headers, off the overview's blockquote
|
|
440
|
+
// block. They are PUSH-TIME EXTRAS, deliberately not keys on `normalizeLocal`'s
|
|
441
|
+
// field set: severity lands in a provider-specific home (a field, a label),
|
|
442
|
+
// the incident and epic links as typed relations, and the waits and lanes are
|
|
443
|
+
// read by `epic status` — none belongs in the synced-field hashes a stored base
|
|
444
|
+
// compares.
|
|
443
445
|
function specHeaders(snapshotDir, config) {
|
|
444
446
|
const overviewFile = (config && config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
|
|
445
447
|
let raw
|
|
446
448
|
try {
|
|
447
449
|
raw = fs.readFileSync(path.join(snapshotDir, overviewFile), 'utf-8')
|
|
448
450
|
} catch {
|
|
449
|
-
return { severity: null, incident: null }
|
|
451
|
+
return { severity: null, incident: null, epic: null, waitsOn: [], lanes: null }
|
|
450
452
|
}
|
|
451
453
|
const read = (name) => {
|
|
452
454
|
const m = new RegExp(`^>\\s*\\*\\*${name}:\\*\\*\\s*(.+)$`, 'm').exec(raw)
|
|
453
455
|
return m ? m[1].trim() : null
|
|
454
456
|
}
|
|
455
|
-
return {
|
|
457
|
+
return {
|
|
458
|
+
severity: read('Severity'),
|
|
459
|
+
incident: read('Incident'),
|
|
460
|
+
epic: unquote(read('Epic')) || null,
|
|
461
|
+
waitsOn: parseWaitsOn(read('Waits on')),
|
|
462
|
+
lanes: parseLanes(read('Lanes')),
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// A header value a hand may have wrapped in backticks, as a spec name usually is.
|
|
467
|
+
function unquote(value) {
|
|
468
|
+
return value == null ? value : value.replace(/^`(.*)`$/, '$1').trim()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// `> **Waits on:** <spec>[ phase N], …` → `[{ spec, phase }]`, `phase` null for
|
|
472
|
+
// a whole-spec wait. `none` (or the `—` placeholder) is an empty list.
|
|
473
|
+
//
|
|
474
|
+
// A MALFORMED ENTRY IS KEPT, never dropped: `{ spec: null, phase: null, raw }`.
|
|
475
|
+
// Dropping it would make a wait nobody can read look like no wait at all, and
|
|
476
|
+
// `epic status` would then call the member ready — the accusation running the
|
|
477
|
+
// wrong way. Kept, it reports as cannot-tell (`.claude/rules/negative-checks.md`).
|
|
478
|
+
function parseWaitsOn(value) {
|
|
479
|
+
if (!value) return []
|
|
480
|
+
const trimmed = value.trim()
|
|
481
|
+
if (/^(none|—|-)$/i.test(trimmed)) return []
|
|
482
|
+
return trimmed
|
|
483
|
+
.split(',')
|
|
484
|
+
.map((part) => part.trim())
|
|
485
|
+
.filter(Boolean)
|
|
486
|
+
.map((part) => {
|
|
487
|
+
const m = /^`?([a-z0-9][a-z0-9._-]*)`?(?:\s+phase\s+(\d+))?$/i.exec(part)
|
|
488
|
+
if (!m) return { spec: null, phase: null, raw: part }
|
|
489
|
+
return { spec: m[1], phase: m[2] ? Number(m[2]) : null, raw: part }
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// `> **Lanes:** N` — a positive whole number, else null. An unreadable cap is
|
|
494
|
+
// no cap, which `epic status` reports as uncapped rather than guessing one.
|
|
495
|
+
function parseLanes(value) {
|
|
496
|
+
if (!value) return null
|
|
497
|
+
const m = /^(\d+)$/.exec(value.trim())
|
|
498
|
+
const n = m ? Number(m[1]) : 0
|
|
499
|
+
return n > 0 ? n : null
|
|
456
500
|
}
|
|
457
501
|
|
|
458
502
|
// Resolve a fix spec's `> **Incident:**` header to the incident spec it names:
|
|
@@ -479,6 +523,39 @@ function linkedIncident(snapshotDir, config) {
|
|
|
479
523
|
return { name: incident, identifier: null, found: false }
|
|
480
524
|
}
|
|
481
525
|
|
|
526
|
+
// A member spec's `> **Epic:**` resolved the way `linkedIncident` resolves its
|
|
527
|
+
// header: the epic's folder in any bucket and its stamped identifier, or
|
|
528
|
+
// `identifier: null` when the epic is not linked yet (report and carry on —
|
|
529
|
+
// never mint the other). No header returns null.
|
|
530
|
+
//
|
|
531
|
+
// A FOLDER NOT ON DISK IS NOT PROOF THE EPIC DOES NOT EXIST, for the reason
|
|
532
|
+
// `linkedIncident` gives: buckets are branch-local truth.
|
|
533
|
+
function linkedEpic(snapshotDir, config) {
|
|
534
|
+
const { epic } = specHeaders(snapshotDir, config)
|
|
535
|
+
if (!epic) return null
|
|
536
|
+
const root = path.resolve(snapshotDir, '..', '..', '..')
|
|
537
|
+
const overviewFile = (config && config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
|
|
538
|
+
for (const bucket of ['in-progress', 'backlog', 'complete', 'cancelled']) {
|
|
539
|
+
const file = path.join(root, 'specs', bucket, epic, overviewFile)
|
|
540
|
+
if (!fs.existsSync(file)) continue
|
|
541
|
+
const { data } = parseFrontmatter(fs.readFileSync(file, 'utf-8'))
|
|
542
|
+
const idField = config && config.fields && config.fields.identifier
|
|
543
|
+
const identifier = idField && data[idField] != null ? String(data[idField]) : null
|
|
544
|
+
return { name: epic, identifier, found: true }
|
|
545
|
+
}
|
|
546
|
+
return { name: epic, identifier: null, found: false }
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// The member's one-line pointer to its epic. Part of the PROJECTION, like the
|
|
550
|
+
// related-incident line, so the stored base, the plan and the tracker hash the
|
|
551
|
+
// same bytes — and so a spec that only GAINS an `Epic:` header still has a
|
|
552
|
+
// change to push, which is what gives the parent link a push to ride on.
|
|
553
|
+
function epicLine(snapshotDir, config) {
|
|
554
|
+
const epic = linkedEpic(snapshotDir, config)
|
|
555
|
+
if (!epic) return ''
|
|
556
|
+
return `\n\nEpic: ${epic.identifier || epic.name}`
|
|
557
|
+
}
|
|
558
|
+
|
|
482
559
|
// The one-line cross-reference a fix spec's body carries to its incident. Part
|
|
483
560
|
// of the PROJECTION (not appended at send time), so the stored base, the plan
|
|
484
561
|
// and what the tracker holds all hash the same bytes — and on GitHub the
|
|
@@ -815,7 +892,8 @@ function normalizeLocal(snapshotDir, config) {
|
|
|
815
892
|
description: summaryMode
|
|
816
893
|
? wrapBlock(
|
|
817
894
|
dialect.flattenTables(dialect.canonicalize(specBlockInner({ snapshotDir, sections, body, phases }))) +
|
|
818
|
-
relatedIncidentLine(snapshotDir, config)
|
|
895
|
+
relatedIncidentLine(snapshotDir, config) +
|
|
896
|
+
epicLine(snapshotDir, config),
|
|
819
897
|
config,
|
|
820
898
|
)
|
|
821
899
|
: withInlinePhases(
|
|
@@ -834,7 +912,9 @@ function normalizeLocal(snapshotDir, config) {
|
|
|
834
912
|
tasksMode,
|
|
835
913
|
config.sync.localOnlySections,
|
|
836
914
|
dialect,
|
|
837
|
-
) +
|
|
915
|
+
) +
|
|
916
|
+
relatedIncidentLine(snapshotDir, config) +
|
|
917
|
+
epicLine(snapshotDir, config),
|
|
838
918
|
// Sub-issue projection: one per phase. `ref` is the phase-file basename — the
|
|
839
919
|
// local handle the push skill stamps a newly-created sub-issue id back into.
|
|
840
920
|
// `state` is the phase's status bucket (from its heading emoji), mapped to a
|
|
@@ -1131,5 +1211,7 @@ module.exports = {
|
|
|
1131
1211
|
remoteStateReading,
|
|
1132
1212
|
stateNamesFor,
|
|
1133
1213
|
specHeaders,
|
|
1214
|
+
parseWaitsOn,
|
|
1134
1215
|
linkedIncident,
|
|
1216
|
+
linkedEpic,
|
|
1135
1217
|
}
|