@skitterbyte/skitterspec-azure-boards 2.3.0 → 2.5.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/claude-md-section.md +20 -1
- package/assets/core/azure-boards.config.md +4 -2
- package/assets/core/env.config.json.example +1 -0
- package/assets/core/env.config.md +90 -6
- package/assets/hooks/main-guard.cjs +18 -2
- package/assets/hooks/review-gate.cjs +19 -2
- package/assets/rules/commit-trailers.md +24 -1
- package/assets/rules/spec-planning.md +81 -18
- package/assets/rules/spec-reports.md +1 -1
- package/assets/skills/spec/SKILL.md +55 -2
- package/assets/skills/spec-azure-setup/SKILL.md +23 -1
- package/assets/skills/spec-bug/SKILL.md +36 -3
- package/assets/skills/spec-cancel/SKILL.md +35 -0
- package/assets/skills/spec-claim/SKILL.md +41 -2
- package/assets/skills/spec-complete/SKILL.md +113 -0
- package/assets/skills/spec-hotfix/SKILL.md +51 -4
- package/assets/skills/spec-incident/SKILL.md +22 -0
- package/assets/skills/spec-next/SKILL.md +12 -5
- package/assets/skills/spec-push/SKILL.md +22 -0
- package/assets/skills/spec-review/SKILL.md +32 -0
- package/assets/skills/spec-start/SKILL.md +50 -3
- package/assets/skills/spec-status/SKILL.md +18 -3
- package/assets/skills/spec-sync/SKILL.md +1 -0
- package/assets/skills/spec-to-main/SKILL.md +47 -1
- package/package.json +1 -1
- package/src/cli.js +1091 -39
- package/src/env/base.js +104 -0
- package/src/env/config.js +75 -3
- package/src/env/disposition.js +62 -0
- package/src/env/handoff.js +80 -0
- package/src/env/host.js +262 -0
- package/src/env/hotfix.js +225 -0
- package/src/env/hotfixland.js +103 -9
- package/src/env/inflight.js +95 -0
- package/src/env/integrate.js +130 -4
- package/src/env/mainguard.js +6 -0
- package/src/env/phases.js +28 -0
- package/src/env/provision.js +18 -6
- package/src/env/resolve.js +108 -9
- package/src/env/serve.js +6 -1
- package/src/env/specstate.js +101 -0
- package/src/env/teardown.js +42 -0
- package/src/vendor/azure-boards/cli-sync.js +234 -22
- package/src/vendor/azure-boards/config.js +54 -6
- package/src/vendor/provider-kit/index.js +4 -0
- package/src/vendor/provider-kit/src/apply.js +55 -5
- package/src/vendor/provider-kit/src/assignment.js +78 -1
- package/src/vendor/provider-kit/src/config.js +34 -1
- package/src/vendor/provider-kit/src/list-rows.js +35 -11
- package/src/vendor/provider-kit/src/released.js +14 -1
- package/src/vendor/provider-kit/src/specs.js +4 -2
- package/src/vendor/provider-kit/src/splice.js +64 -0
- package/src/vendor/provider-kit/src/status.js +137 -0
- package/src/vendor/sync-core/index.js +14 -1
- package/src/vendor/sync-core/src/compare.js +81 -6
- package/src/vendor/sync-core/src/normalize.js +50 -7
- package/src/vendor/sync-core/src/push.js +65 -5
- package/src/vendor/sync-core/src/summary.js +257 -0
|
@@ -43,6 +43,10 @@ const {
|
|
|
43
43
|
stampSubIssueId,
|
|
44
44
|
listPhaseFiles,
|
|
45
45
|
normalizeLocal,
|
|
46
|
+
descriptionMode,
|
|
47
|
+
projectionOf,
|
|
48
|
+
ownershipOf,
|
|
49
|
+
writeBase,
|
|
46
50
|
} = require('../sync-core')
|
|
47
51
|
const kit = require('../provider-kit')
|
|
48
52
|
const { BUCKETS, findSpecFolder, currentBranch } = require('../../env/resolve.js')
|
|
@@ -52,7 +56,16 @@ const { resolveListAssignee } = require('../provider-kit/src/list-assignee.js')
|
|
|
52
56
|
const { expandStateArgs, specColumn, specCell } = require('../provider-kit/src/list-rows.js')
|
|
53
57
|
const { IDENTIFIER_RE } = require('../provider-kit/src/released.js')
|
|
54
58
|
|
|
55
|
-
const {
|
|
59
|
+
const {
|
|
60
|
+
loadAzureConfig,
|
|
61
|
+
mergeConfig,
|
|
62
|
+
defaults,
|
|
63
|
+
CONFIG_FILE,
|
|
64
|
+
LIFECYCLE_BUCKETS,
|
|
65
|
+
specKindOf,
|
|
66
|
+
mintTypeFor,
|
|
67
|
+
stateNameFor,
|
|
68
|
+
} = require('./config.js')
|
|
56
69
|
const {
|
|
57
70
|
resolveCredential,
|
|
58
71
|
writeCredential,
|
|
@@ -184,24 +197,23 @@ function stateCheckFailure(config, flags) {
|
|
|
184
197
|
// Apply ops: the kit orchestration with Azure's tracker calls. State is moved
|
|
185
198
|
// by a direct `System.State` write after the create/update, and `transitionTo`
|
|
186
199
|
// is idempotent when the item already sits on the target.
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
//
|
|
201
|
+
// A RESEND IS NOT A MOVE. A plan marks a state `stateResend` when nothing says
|
|
202
|
+
// the spec moved — a state-map change, or a snapshot that was lost — and such a
|
|
203
|
+
// send never drags an item backwards: one sitting in a state this config does
|
|
204
|
+
// not map for its type, or in a later bucket than the target, is left where it
|
|
205
|
+
// is and named. A host's release CI moving finished items on (Resolved → On
|
|
206
|
+
// Prod) is the case this protects. A real bucket move is the repo's transition
|
|
207
|
+
// and is sent as before, backwards or not.
|
|
208
|
+
|
|
209
|
+
// How far through the lifecycle a bucket is. The two finished buckets rank
|
|
210
|
+
// alike: neither is behind the other.
|
|
211
|
+
const BUCKET_RANK = { backlog: 0, 'in-progress': 1, complete: 2, cancelled: 2 }
|
|
199
212
|
function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }) {
|
|
200
213
|
// The mint type for THIS spec's kind (its folder prefix), falling back to
|
|
201
214
|
// the one configured type. The twin search uses the same type, so a bug
|
|
202
215
|
// never refuses over a feature that happens to share its title.
|
|
203
|
-
const mintType =
|
|
204
|
-
(config.azure.workItemTypeByKind && config.azure.workItemTypeByKind[kind]) || config.azure.workItemType
|
|
216
|
+
const mintType = mintTypeFor(config, kind)
|
|
205
217
|
// Push-time extras off the spec's own headers: `Severity:` lands in the
|
|
206
218
|
// built-in field, `Incident:` as a Related link. Neither is a synced field,
|
|
207
219
|
// so neither touches the stored-base hashes.
|
|
@@ -220,17 +232,59 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
220
232
|
// Per-type resolution: statesByType[type] overlays states, and null means
|
|
221
233
|
// "send no state for this bucket" — a deliberate skip, not a gap.
|
|
222
234
|
const stateFor = (bucket, type) => {
|
|
223
|
-
const name =
|
|
235
|
+
const name = stateNameFor(config, bucket, type)
|
|
224
236
|
if (name === null) return null
|
|
225
237
|
if (!name) {
|
|
226
238
|
throw new Error(`no state configured for the "${bucket}" bucket — fix ${CONFIG_FILE} -> states`)
|
|
227
239
|
}
|
|
228
240
|
return name
|
|
229
241
|
}
|
|
230
|
-
|
|
242
|
+
// The bucket a live state means for one type: its own resolution first, then
|
|
243
|
+
// the shared map and its aliases — an item can still sit on the name an
|
|
244
|
+
// earlier map wrote. Null is a state this config does not map at all.
|
|
245
|
+
const bucketOfState = (name, type) => {
|
|
246
|
+
const want = String(name).toLowerCase().trim()
|
|
247
|
+
const same = (n) => typeof n === 'string' && n.toLowerCase().trim() === want
|
|
248
|
+
for (const bucket of LIFECYCLE_BUCKETS) if (same(stateNameFor(config, bucket, type))) return bucket
|
|
249
|
+
for (const bucket of LIFECYCLE_BUCKETS) if (same(config.states[bucket])) return bucket
|
|
250
|
+
for (const bucket of LIFECYCLE_BUCKETS) if (((config.stateAliases || {})[bucket] || []).some(same)) return bucket
|
|
251
|
+
return null
|
|
252
|
+
}
|
|
253
|
+
// Where a state send would take this item, read live: the name it would
|
|
254
|
+
// write, where it sits now, and — for a resend — why it should be left
|
|
255
|
+
// alone (`keep`), or null when it may move.
|
|
256
|
+
const stateDecision = async (idOrIdentifier, bucket, type) => {
|
|
257
|
+
const name = stateFor(bucket, type)
|
|
258
|
+
if (name === null) return { name: null, at: null, keep: null, already: false }
|
|
259
|
+
let item
|
|
260
|
+
try {
|
|
261
|
+
item = await adapter.readIssue(apiId(idOrIdentifier))
|
|
262
|
+
} catch (error) {
|
|
263
|
+
const why = String((error && error.message) || error).split('\n')[0]
|
|
264
|
+
return { name, at: null, keep: `could not read its state (${why})`, already: false }
|
|
265
|
+
}
|
|
266
|
+
const at = item && item.state && item.state.name
|
|
267
|
+
// Cannot tell where it is, so the harmless reading is to leave it.
|
|
268
|
+
if (!at) return { name, at: null, keep: 'could not read its state', already: false }
|
|
269
|
+
if (String(at).toLowerCase().trim() === String(name).toLowerCase().trim()) return { name, at, keep: null, already: true }
|
|
270
|
+
const current = bucketOfState(at, type)
|
|
271
|
+
if (current === null) return { name, at, keep: `at "${at}", a state this config does not map for ${type}`, already: false }
|
|
272
|
+
if (BUCKET_RANK[current] > BUCKET_RANK[bucket]) return { name, at, keep: `at "${at}", later than ${bucket}`, already: false }
|
|
273
|
+
return { name, at, keep: null, already: false }
|
|
274
|
+
}
|
|
275
|
+
const keptLine = (idOrIdentifier, reason) =>
|
|
276
|
+
` state kept: ${asIdentifier(apiId(idOrIdentifier))} ${reason} — a resend leaves it\n`
|
|
277
|
+
const settle = async (idOrIdentifier, bucket, type, resend = null) => {
|
|
231
278
|
if (!bucket) return
|
|
232
279
|
const name = stateFor(bucket, type)
|
|
233
280
|
if (name === null) return
|
|
281
|
+
if (resend) {
|
|
282
|
+
const decision = await stateDecision(idOrIdentifier, bucket, type)
|
|
283
|
+
if (decision.keep) {
|
|
284
|
+
if (out) out.write(keptLine(idOrIdentifier, decision.keep))
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
}
|
|
234
288
|
await adapter.transitionTo(apiId(idOrIdentifier), name)
|
|
235
289
|
}
|
|
236
290
|
// Azure refuses the WHOLE patch over one bad `System.AssignedTo` value
|
|
@@ -267,6 +321,9 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
267
321
|
}
|
|
268
322
|
}
|
|
269
323
|
return {
|
|
324
|
+
stateDecision,
|
|
325
|
+
keptLine,
|
|
326
|
+
mintType,
|
|
270
327
|
prevalidateStates: (buckets) => {
|
|
271
328
|
for (const bucket of buckets) {
|
|
272
329
|
stateFor(bucket, mintType)
|
|
@@ -309,7 +366,7 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
309
366
|
skippingRefusedSeverity(input, (i) => adapter.updateIssue(apiId(existing.identifier), i)),
|
|
310
367
|
)
|
|
311
368
|
}
|
|
312
|
-
await settle(existing.identifier, issue.state, mintType)
|
|
369
|
+
await settle(existing.identifier, issue.state, mintType, issue.stateResend)
|
|
313
370
|
await relateToIncident(existing.identifier)
|
|
314
371
|
},
|
|
315
372
|
mintSubIssue: async (parentId, sub) => {
|
|
@@ -327,7 +384,7 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
327
384
|
if (sub.name != null) updates.title = sub.name
|
|
328
385
|
if (sub.goal != null) updates.description = sub.goal
|
|
329
386
|
if (Object.keys(updates).length) await adapter.updateIssue(apiId(sub.id), updates)
|
|
330
|
-
await settle(sub.id, sub.state, config.azure.childType)
|
|
387
|
+
await settle(sub.id, sub.state, config.azure.childType, sub.stateResend)
|
|
331
388
|
},
|
|
332
389
|
}
|
|
333
390
|
}
|
|
@@ -348,16 +405,30 @@ function apiAdapterFor(config, flags) {
|
|
|
348
405
|
}
|
|
349
406
|
}
|
|
350
407
|
|
|
408
|
+
// `board <spec>` — has Azure Boards finished what this repo has not? The kit's
|
|
409
|
+
// (`provider-kit/src/status.js`): one line on a disagreement, silent otherwise.
|
|
410
|
+
async function specSyncBoard(dir, config, specArg, flags, out) {
|
|
411
|
+
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
412
|
+
if (!snapshotDir) return 1
|
|
413
|
+
const cred = apiAdapterFor(config, flags)
|
|
414
|
+
const credential = kit.resolveTransport(flags, config, cred.ok) === 'mcp' ? { ok: false, error: 'transport = mcp — no API read' } : cred
|
|
415
|
+
return kit.specSyncBoard({ snapshotDir, config, credential, flags, out, tracker: 'Azure Boards', program: PROGRAM })
|
|
416
|
+
}
|
|
417
|
+
|
|
351
418
|
// ---------------------------------------------------------------------------
|
|
352
419
|
// `released [<range>]` — which tickets a commit range contains, off the
|
|
353
420
|
// `Refs:` trailers (kit `src/released.js` owns the parsing rules). Refs are
|
|
354
421
|
// `AB#n`; `KEY-N` trailers from an earlier tracker count as historical.
|
|
422
|
+
// Merge commits are READ, never skipped: a hand merge is where a ticket's only
|
|
423
|
+
// trailer sometimes lives (--no-merges was tried and dropped for exactly that
|
|
424
|
+
// loss). What changes is the counting — a trailer-less merge is transport, not
|
|
425
|
+
// a gap — and %P is what lets ticketsInRange tell the two apart.
|
|
355
426
|
function readCommitRange(dir, range) {
|
|
356
427
|
const { execFileSync } = require('node:child_process')
|
|
357
428
|
const SEP = '\x00SKITTERSPEC\x00'
|
|
358
429
|
let raw
|
|
359
430
|
try {
|
|
360
|
-
raw = execFileSync('git', ['-C', dir, 'log', `--format=%x00SKITTERSPEC%x00%H%n%B%x00END%x00`, '--name-only', range], {
|
|
431
|
+
raw = execFileSync('git', ['-C', dir, 'log', `--format=%x00SKITTERSPEC%x00%H %P%n%B%x00END%x00`, '--name-only', range], {
|
|
361
432
|
encoding: 'utf-8',
|
|
362
433
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
363
434
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -378,9 +449,10 @@ function readCommitRange(dir, range) {
|
|
|
378
449
|
.map((l) => l.trim())
|
|
379
450
|
.filter(Boolean)
|
|
380
451
|
const nl = head.indexOf('\n')
|
|
381
|
-
const
|
|
452
|
+
const idLine = head.slice(0, nl < 0 ? head.length : nl).trim()
|
|
453
|
+
const [sha, ...parents] = idLine.split(/\s+/).filter(Boolean)
|
|
382
454
|
const body = nl < 0 ? '' : head.slice(nl + 1)
|
|
383
|
-
commits.push({ sha, subject: body.split('\n')[0] || '', body, paths })
|
|
455
|
+
commits.push({ sha, isMerge: parents.length > 1, subject: body.split('\n')[0] || '', body, paths })
|
|
384
456
|
}
|
|
385
457
|
return { ok: true, commits }
|
|
386
458
|
}
|
|
@@ -411,6 +483,7 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
411
483
|
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))${t.spec ? ` ${t.spec}` : ''}`)
|
|
412
484
|
if (!report.tickets.length) lines.push(' no referenced tickets')
|
|
413
485
|
if (report.unreferenced) lines.push(` ${report.unreferenced} commit(s) carry no Refs: trailer`)
|
|
486
|
+
if (report.merges) lines.push(` ${report.merges} merge commit(s) — transport, not counted as gaps`)
|
|
414
487
|
if (report.historical) lines.push(` ${report.historical} commit(s) reference an earlier tracker`)
|
|
415
488
|
if (report.ignored) lines.push(` ${report.ignored} bookkeeping commit(s) ignored`)
|
|
416
489
|
out.write(lines.join('\n') + '\n')
|
|
@@ -1103,6 +1176,11 @@ async function specSyncPreserve(dir, config, specArg, flags, out) {
|
|
|
1103
1176
|
return 0
|
|
1104
1177
|
}
|
|
1105
1178
|
if (!identifier) return done(`${path.basename(snapshotDir)} is not linked — nothing to preserve`)
|
|
1179
|
+
// Summary mode splices a block in beside the reporter's text rather than
|
|
1180
|
+
// replacing it, so the original is still in the description itself.
|
|
1181
|
+
if (descriptionMode(config) === 'summary') {
|
|
1182
|
+
return done(`${identifier} — summary mode keeps the original description in place; nothing to preserve`)
|
|
1183
|
+
}
|
|
1106
1184
|
|
|
1107
1185
|
let original = null
|
|
1108
1186
|
if (flags.text) {
|
|
@@ -1321,6 +1399,10 @@ async function specSyncInitConfig(dir, flags, out) {
|
|
|
1321
1399
|
const parsed = { azure: { orgUrl: flags.orgUrl, project: flags.project } }
|
|
1322
1400
|
if (flags.workItemType) parsed.azure.workItemType = flags.workItemType
|
|
1323
1401
|
if (flags.childType) parsed.azure.childType = flags.childType
|
|
1402
|
+
// A NEW config carries a summary, not the spec: written explicitly, so the
|
|
1403
|
+
// file says what the ticket gets. A config that predates the key keeps
|
|
1404
|
+
// pushing the spec (the loader's default), so an upgrade rewrites nothing.
|
|
1405
|
+
parsed.mapping = { description: flags.description || 'summary' }
|
|
1324
1406
|
if (flags.kindTypes && Object.keys(flags.kindTypes).length) parsed.azure.workItemTypeByKind = flags.kindTypes
|
|
1325
1407
|
if (flags.bugTypes || flags.hotfixTypes) {
|
|
1326
1408
|
parsed.intake = {}
|
|
@@ -1426,6 +1508,7 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1426
1508
|
checks.push(row('tracker', 'Azure config', 'broken', 'orgUrl or project is empty', `fix ${CONFIG_FILE}`))
|
|
1427
1509
|
} else {
|
|
1428
1510
|
checks.push(row('tracker', 'Azure config', 'ok', `${loaded.config.azure.project} @ ${loaded.config.azure.orgUrl}`))
|
|
1511
|
+
checks.push(kit.ownershipDoctorRow(loaded.config))
|
|
1429
1512
|
const retired = kit.retiredKeysRow(path.join(dir, CONFIG_FILE), CONFIG_FILE, row)
|
|
1430
1513
|
if (retired) checks.push(retired)
|
|
1431
1514
|
// A worktree forks from a COMMIT, so a config that exists only in the
|
|
@@ -1577,23 +1660,136 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1577
1660
|
}
|
|
1578
1661
|
|
|
1579
1662
|
// ---------------------------------------------------------------------------
|
|
1663
|
+
// `restate <spec> | --all <bucket> [--parents] [--apply]` — bring the states of
|
|
1664
|
+
// already-pushed items up to today's config, read live.
|
|
1665
|
+
//
|
|
1666
|
+
// `plan` sees a state-map change only for items whose snapshot recorded the
|
|
1667
|
+
// name they were sent. Everything pushed before that record existed has
|
|
1668
|
+
// nothing to diff against, so this reads each item's live state instead and
|
|
1669
|
+
// settles it through the same resend guard an apply uses: an item in a state
|
|
1670
|
+
// this config does not map for its type, or in a later bucket, is left and
|
|
1671
|
+
// named. Children only by default — a host's release CI often owns the
|
|
1672
|
+
// parent's states past complete — and `--parents` opts the spec item in.
|
|
1673
|
+
// Dry-run unless `--apply`; on `--apply` the names are recorded into each
|
|
1674
|
+
// spec's existing snapshot, so the next state-map change shows up in `plan`.
|
|
1675
|
+
async function specSyncRestate(dir, config, specArg, flags, out) {
|
|
1676
|
+
const cred = apiAdapterFor(config, flags)
|
|
1677
|
+
if (kit.resolveTransport(flags, config, cred.ok) === 'mcp') {
|
|
1678
|
+
out.write(`${PROGRAM} restate: transport = mcp — this reads every item's live state, so it needs the API. Set credentials and re-run.\n`)
|
|
1679
|
+
return 0
|
|
1680
|
+
}
|
|
1681
|
+
if (!cred.ok) {
|
|
1682
|
+
out.write(`${PROGRAM} restate: ${String(cred.error).split('\n')[0]} — nothing read, nothing written\n`)
|
|
1683
|
+
return 0
|
|
1684
|
+
}
|
|
1685
|
+
let dirs
|
|
1686
|
+
if (flags.all !== undefined) {
|
|
1687
|
+
const bucket = String(flags.all)
|
|
1688
|
+
if (!BUCKETS.includes(bucket)) {
|
|
1689
|
+
out.write(`${PROGRAM} restate --all: not a lifecycle bucket: ${bucket}\n`)
|
|
1690
|
+
return 1
|
|
1691
|
+
}
|
|
1692
|
+
dirs = listSpecs(dir, config)
|
|
1693
|
+
.filter((sp) => sp.bucket === bucket)
|
|
1694
|
+
.map((sp) => resolveSnapshotDir(sp.spec, dir))
|
|
1695
|
+
} else {
|
|
1696
|
+
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
1697
|
+
if (!snapshotDir) return 1
|
|
1698
|
+
dirs = [snapshotDir]
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
const apply = !!flags.apply
|
|
1702
|
+
const overviewFile = (config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
|
|
1703
|
+
const pulled = ownershipOf(config, 'workflowState') === 'pull'
|
|
1704
|
+
const totals = { moved: 0, already: 0, kept: 0 }
|
|
1705
|
+
for (const snapshotDir of dirs) {
|
|
1706
|
+
const spec = path.basename(snapshotDir)
|
|
1707
|
+
const identifier = specHelpers.linkedIdentifier(path.join(snapshotDir, overviewFile), config)
|
|
1708
|
+
if (!identifier) {
|
|
1709
|
+
out.write(`${PROGRAM} restate: ${spec} — not linked, skipped\n`)
|
|
1710
|
+
continue
|
|
1711
|
+
}
|
|
1712
|
+
out.write(`${PROGRAM} restate: ${spec} (${identifier})\n`)
|
|
1713
|
+
const ops = applyOps({ adapter: cred.adapter, config, out: null, kind: specKindOf(snapshotDir), snapshotDir })
|
|
1714
|
+
const projection = projectionOf(snapshotDir, config)
|
|
1715
|
+
const items = []
|
|
1716
|
+
if (flags.parents) {
|
|
1717
|
+
if (pulled) out.write(` ${identifier} left — its state is the tracker's (sync.fieldOwnership.workflowState: pull)\n`)
|
|
1718
|
+
else items.push({ role: 'issue', id: identifier, bucket: projection.status, type: ops.mintType })
|
|
1719
|
+
}
|
|
1720
|
+
for (const sub of projection.subIssues || []) {
|
|
1721
|
+
if (sub && sub.id != null) items.push({ role: 'subIssue', id: sub.id, bucket: sub.state, type: config.azure.childType })
|
|
1722
|
+
}
|
|
1723
|
+
const settled = { subIssues: {} }
|
|
1724
|
+
for (const item of items) {
|
|
1725
|
+
if (!item.bucket) continue
|
|
1726
|
+
const label = asIdentifier(apiId(item.id))
|
|
1727
|
+
const d = await ops.stateDecision(item.id, item.bucket, item.type)
|
|
1728
|
+
if (d.name === null) {
|
|
1729
|
+
out.write(` ${label} — ${item.bucket} sends no state for ${item.type}\n`)
|
|
1730
|
+
continue
|
|
1731
|
+
}
|
|
1732
|
+
if (d.keep) {
|
|
1733
|
+
totals.kept++
|
|
1734
|
+
out.write(ops.keptLine(item.id, d.keep))
|
|
1735
|
+
} else if (d.already) {
|
|
1736
|
+
totals.already++
|
|
1737
|
+
out.write(` ${label} already "${d.name}"\n`)
|
|
1738
|
+
} else {
|
|
1739
|
+
totals.moved++
|
|
1740
|
+
if (apply) await cred.adapter.transitionTo(apiId(item.id), d.name)
|
|
1741
|
+
out.write(` ${label} "${d.at}" → "${d.name}"${apply ? '' : ' (dry run)'}\n`)
|
|
1742
|
+
}
|
|
1743
|
+
if (item.role === 'issue') settled.issue = d.name
|
|
1744
|
+
else settled.subIssues[String(item.id)] = d.name
|
|
1745
|
+
}
|
|
1746
|
+
if (apply) recordStateNames(dir, config, snapshotDir, settled, out)
|
|
1747
|
+
}
|
|
1748
|
+
const verb = apply ? 'moved' : 'would move'
|
|
1749
|
+
out.write(`${PROGRAM} restate: ${totals.moved} ${verb}, ${totals.already} already there, ${totals.kept} left alone\n`)
|
|
1750
|
+
if (!apply && totals.moved) out.write(' dry run — nothing written. Re-run with --apply to move them.\n')
|
|
1751
|
+
return 0
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// Merge the names `restate` settled into the spec's EXISTING snapshot. With no
|
|
1755
|
+
// snapshot nothing is written: a snapshot holding only names would read to
|
|
1756
|
+
// `plan` as every phase unrecorded, and resend all their bodies.
|
|
1757
|
+
function recordStateNames(dir, config, snapshotDir, settled, out) {
|
|
1758
|
+
const identifier = specIdentifier(snapshotDir, config)
|
|
1759
|
+
const base = readBase(dir, identifier, config)
|
|
1760
|
+
if (!base) {
|
|
1761
|
+
out.write(' no snapshot to record names in — the next push records them\n')
|
|
1762
|
+
return
|
|
1763
|
+
}
|
|
1764
|
+
const before = base.stateNames || {}
|
|
1765
|
+
const names = { ...before, subIssues: { ...(before.subIssues || {}), ...settled.subIssues } }
|
|
1766
|
+
if (settled.issue !== undefined) names.issue = settled.issue
|
|
1767
|
+
writeBase(dir, identifier, config, { ...base, stateNames: names })
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1580
1770
|
const USAGE = `Usage: skitterspec-azure-boards spec-sync <subcommand>
|
|
1581
1771
|
|
|
1582
1772
|
normalize <spec> print the local projection as JSON
|
|
1583
1773
|
plan <spec> --workspace-states <f> what a push would change (dry, JSON)
|
|
1584
1774
|
apply <spec> --plan <f> | --all <b> apply a plan over the API
|
|
1775
|
+
restate <spec> | --all <b> resend child states to today's map (dry)
|
|
1776
|
+
[--parents] [--apply] include the spec item; write the moves
|
|
1585
1777
|
stamp <spec> --issue AB#n [--sub r=n] write returned ids into the spec
|
|
1586
1778
|
record <spec> write the last-pushed snapshot
|
|
1587
1779
|
status <spec> [--remote <f>] read-only drift report
|
|
1588
1780
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1781
|
+
splice <spec> --live <f> [--phase <ref>] the body to write over MCP (summary mode)
|
|
1589
1782
|
states [--json] the configured types' state names
|
|
1590
1783
|
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] tracker listing
|
|
1591
1784
|
linked [--json] specs and their linked items (offline)
|
|
1785
|
+
ownership [--json] who owns status and assignee (offline)
|
|
1786
|
+
board <spec> [--json] is the item finished where the spec is not?
|
|
1592
1787
|
ref [<spec>] the Refs: trailer value for this branch
|
|
1593
1788
|
released [<range>] tickets a commit range contains
|
|
1594
1789
|
preserve <spec> [--text <f>] keep an adopted item's original report
|
|
1595
1790
|
comment <spec> --file <f> post a file onto the item as a comment
|
|
1596
1791
|
assign <spec> --to <id> | --release stamp who is building it
|
|
1792
|
+
[--if-unassigned] only when nobody holds the item
|
|
1597
1793
|
whoami [--set <id>] [--unset] who you are on Azure (cached)
|
|
1598
1794
|
users [<query>] search the org's identities
|
|
1599
1795
|
credentials <status|set|unset> the PAT (user-level)
|
|
@@ -1652,16 +1848,27 @@ async function specSync(rest, io = {}) {
|
|
|
1652
1848
|
return specSyncPlan(dir, config, positional[0], flags, out, err)
|
|
1653
1849
|
case 'apply':
|
|
1654
1850
|
return specSyncApply(dir, config, positional[0], flags, out, err)
|
|
1851
|
+
case 'restate':
|
|
1852
|
+
return specSyncRestate(dir, config, positional[0], flags, out)
|
|
1655
1853
|
case 'stamp':
|
|
1656
1854
|
return specSyncStamp(dir, config, positional[0], flags, out)
|
|
1657
1855
|
case 'record':
|
|
1658
1856
|
return specSyncRecord(dir, config, positional[0], out)
|
|
1659
1857
|
case 'status':
|
|
1660
1858
|
return specSyncStatus(dir, config, positional[0], flags, out, err)
|
|
1859
|
+
case 'splice': {
|
|
1860
|
+
const snapshotDir = resolveOrExit(positional[0], dir, err)
|
|
1861
|
+
if (!snapshotDir) return 1
|
|
1862
|
+
return kit.specSyncSplice({ snapshotDir, config, flags, out, err, program: PROGRAM })
|
|
1863
|
+
}
|
|
1661
1864
|
case 'verify':
|
|
1662
1865
|
return specSyncVerify(dir, config, positional[0], flags, out)
|
|
1663
1866
|
case 'linked':
|
|
1664
1867
|
return specSyncLinked(dir, config, flags, out)
|
|
1868
|
+
case 'ownership':
|
|
1869
|
+
return kit.specSyncOwnership(config, flags, out, PROGRAM)
|
|
1870
|
+
case 'board':
|
|
1871
|
+
return specSyncBoard(dir, config, positional[0], flags, out)
|
|
1665
1872
|
case 'states':
|
|
1666
1873
|
return specSyncStates(dir, config, flags, out)
|
|
1667
1874
|
case 'list':
|
|
@@ -1708,6 +1915,9 @@ function parseArgs(args, sub) {
|
|
|
1708
1915
|
'--dir': { kind: 'path', name: 'dirOverride' },
|
|
1709
1916
|
'--plan': { kind: 'path' },
|
|
1710
1917
|
'--stored': { kind: 'path' },
|
|
1918
|
+
'--live': { kind: 'path' },
|
|
1919
|
+
'--description': { kind: 'string' },
|
|
1920
|
+
'--phase': { kind: 'string' },
|
|
1711
1921
|
'--remote': { kind: 'path' },
|
|
1712
1922
|
'--text': { kind: 'path' },
|
|
1713
1923
|
'--file': { kind: 'path' },
|
|
@@ -1725,9 +1935,11 @@ function parseArgs(args, sub) {
|
|
|
1725
1935
|
'--link': { kind: 'list', name: 'links' },
|
|
1726
1936
|
'--stage': { kind: 'string' },
|
|
1727
1937
|
'--apply': { kind: 'boolean' },
|
|
1938
|
+
'--parents': { kind: 'boolean' },
|
|
1728
1939
|
'--to': { kind: 'string' },
|
|
1729
1940
|
'--name': { kind: 'string' },
|
|
1730
1941
|
'--release': { kind: 'boolean' },
|
|
1942
|
+
'--if-unassigned': { kind: 'boolean', name: 'ifUnassigned' },
|
|
1731
1943
|
'--mine': { kind: 'boolean' },
|
|
1732
1944
|
'--next': { kind: 'number' },
|
|
1733
1945
|
'--by': { kind: 'string' },
|
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const { readFileSync } = require('node:fs')
|
|
17
|
-
const { join } = require('node:path')
|
|
17
|
+
const { join, basename } = require('node:path')
|
|
18
18
|
|
|
19
19
|
const kitConfig = require('../provider-kit/src/config.js')
|
|
20
|
+
const { effectiveStates } = require('../sync-core')
|
|
20
21
|
const { dialect, htmlToText, looksLikeHtml } = require('./dialect.js')
|
|
21
22
|
|
|
22
23
|
const CONFIG_FILE = 'specs/.core/azure-boards.config.json'
|
|
23
24
|
|
|
24
25
|
const OWNERSHIP = Object.freeze(['both', 'pull', 'push', 'none'])
|
|
25
26
|
const TASK_MAPPINGS = Object.freeze(['checklist', 'none'])
|
|
26
|
-
const PHASE_MAPPINGS = Object.freeze(['subissue', 'deferred', 'inline'])
|
|
27
|
+
const PHASE_MAPPINGS = Object.freeze(['subissue', 'deferred', 'inline', 'none'])
|
|
27
28
|
const TRANSPORTS = Object.freeze(['api', 'mcp'])
|
|
28
29
|
const DEFAULT_TOKEN_ENV = 'AZURE_DEVOPS_EXT_PAT'
|
|
29
30
|
const DEFAULT_PHASE_MODE = 'subissue'
|
|
@@ -66,7 +67,12 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
66
67
|
// link. `tasks` selects how the phase's checkboxes reach that child's
|
|
67
68
|
// description (markdown checkboxes render natively — still a read-only
|
|
68
69
|
// mirror).
|
|
69
|
-
|
|
70
|
+
// `description`: what the ticket body carries — `spec` (the whole overview)
|
|
71
|
+
// or `summary` (a delimited block beside the team's own text). `spec` is the
|
|
72
|
+
// default so a config written before the key pushes what it always pushed.
|
|
73
|
+
mapping: Object.freeze({ specFolder: 'issue', phases: DEFAULT_PHASE_MODE, tasks: 'checklist', description: 'spec' }),
|
|
74
|
+
// The summary block's delimiters (provisional until chore-delimiter-spike-providers measures this tracker).
|
|
75
|
+
summary: Object.freeze({ delimiter: 'heading' }),
|
|
70
76
|
// Boards STATE names — the spec item's state (from the folder bucket) and
|
|
71
77
|
// each child's state (from the phase emoji) both map through this table.
|
|
72
78
|
// They must match the process's states exactly; the adapter validates at
|
|
@@ -119,11 +125,16 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
119
125
|
sync: Object.freeze({
|
|
120
126
|
baseDir: 'specs/.core/azure-base',
|
|
121
127
|
backupDir: 'specs/.core/azure-backups',
|
|
128
|
+
// The repo owns the spec's CONTENT (`push`); the tracker owns its STATUS and
|
|
129
|
+
// ASSIGNEE (`pull`) — the board is where a team assigns and moves work, so a
|
|
130
|
+
// repo copy is one somebody has to keep in step by hand. Under `pull` the
|
|
131
|
+
// state is sent only as a transition the repo made (a bucket move), and the
|
|
132
|
+
// assignee not at all. Set either back to `"push"` for the repo-owned behaviour.
|
|
122
133
|
fieldOwnership: Object.freeze({
|
|
123
134
|
description: 'push',
|
|
124
135
|
subIssues: 'push',
|
|
125
|
-
workflowState: '
|
|
126
|
-
assignee: '
|
|
136
|
+
workflowState: 'pull',
|
|
137
|
+
assignee: 'pull',
|
|
127
138
|
}),
|
|
128
139
|
localOnlySections: Object.freeze(['State log', 'Changelog', 'Open questions']),
|
|
129
140
|
keyedFields: Object.freeze({}),
|
|
@@ -148,6 +159,7 @@ function defaults() {
|
|
|
148
159
|
return {
|
|
149
160
|
azure: { ...DEFAULT_CONFIG.azure },
|
|
150
161
|
mapping: { ...DEFAULT_CONFIG.mapping },
|
|
162
|
+
summary: { ...DEFAULT_CONFIG.summary },
|
|
151
163
|
states: { ...DEFAULT_CONFIG.states },
|
|
152
164
|
statesByType: {},
|
|
153
165
|
stateAliases: {},
|
|
@@ -178,7 +190,7 @@ function defaults() {
|
|
|
178
190
|
}
|
|
179
191
|
|
|
180
192
|
const { isObject, stringList, assign } = kitConfig
|
|
181
|
-
const { mergeStates, mergeStateOverrides, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
|
|
193
|
+
const { mergeStates, mergeStateOverrides, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields, mergeDescription } =
|
|
182
194
|
kitConfig.makeMergeHelpers({
|
|
183
195
|
configFile: CONFIG_FILE,
|
|
184
196
|
ownership: OWNERSHIP,
|
|
@@ -235,6 +247,7 @@ function mergeConfig(base, parsed) {
|
|
|
235
247
|
}
|
|
236
248
|
mergePhaseMapping(base.mapping, parsed.mapping)
|
|
237
249
|
}
|
|
250
|
+
mergeDescription(base, parsed)
|
|
238
251
|
|
|
239
252
|
mergeStates(base, parsed)
|
|
240
253
|
mergeStateOverrides(base, parsed, 'statesByType')
|
|
@@ -293,6 +306,30 @@ function mergeConfig(base, parsed) {
|
|
|
293
306
|
return base
|
|
294
307
|
}
|
|
295
308
|
|
|
309
|
+
// A spec's KIND, read off its folder prefix — the same convention the
|
|
310
|
+
// lifecycle skills stamp into `> **Type:**`, but greppable with no file read.
|
|
311
|
+
function specKindOf(snapshotDir) {
|
|
312
|
+
const name = basename(String(snapshotDir || ''))
|
|
313
|
+
if (name.startsWith('bug-')) return 'bug'
|
|
314
|
+
if (name.startsWith('hotfix-')) return 'hotfix'
|
|
315
|
+
if (name.startsWith('chore-')) return 'chore'
|
|
316
|
+
if (name.startsWith('issue-')) return 'issue'
|
|
317
|
+
if (name.startsWith('incident-')) return 'incident'
|
|
318
|
+
return 'feature'
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// The work item type a spec of this kind mints, falling back to the one
|
|
322
|
+
// configured type.
|
|
323
|
+
function mintTypeFor(config, kind) {
|
|
324
|
+
return (config.azure.workItemTypeByKind && config.azure.workItemTypeByKind[kind]) || config.azure.workItemType
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// The state a bucket writes for one work item type: statesByType[type] over
|
|
328
|
+
// states. `null` is a deliberate "send no state"; `undefined` is no mapping.
|
|
329
|
+
function stateNameFor(config, bucket, type) {
|
|
330
|
+
return effectiveStates(config, config.statesByType, type)[bucket]
|
|
331
|
+
}
|
|
332
|
+
|
|
296
333
|
// Attach the parts of the provider contract that are code, not JSON: the
|
|
297
334
|
// markdown dialect, and the `provider` block. Azure identifiers all share the
|
|
298
335
|
// constant `AB` prefix (`AB#123`), so unlike Jira's project key there is
|
|
@@ -311,6 +348,14 @@ function withRuntime(config) {
|
|
|
311
348
|
// as markdown or HTML depending on the item's era. Each hook falls back to
|
|
312
349
|
// the flat Linear-like shape, so a pre-reduced payload keeps working.
|
|
313
350
|
config.remote = {
|
|
351
|
+
// The state name a push writes for this bucket, recorded in the snapshot
|
|
352
|
+
// so a state-map change is visible to `plan` (sync-core `stateNames`).
|
|
353
|
+
// Resolved exactly as the apply resolves it: the spec item by its kind's
|
|
354
|
+
// mint type, a phase by `childType`.
|
|
355
|
+
writtenStateName(bucket, role, snapshotDir) {
|
|
356
|
+
const type = role === 'subIssue' ? config.azure.childType : mintTypeFor(config, specKindOf(snapshotDir))
|
|
357
|
+
return stateNameFor(config, bucket, type)
|
|
358
|
+
},
|
|
314
359
|
stateName(item) {
|
|
315
360
|
const st = item && item.fields && item.fields['System.State']
|
|
316
361
|
if (st != null) return typeof st === 'object' ? (st.name != null ? st.name : null) : st
|
|
@@ -380,6 +425,9 @@ function loadAzureConfig(dir = process.cwd()) {
|
|
|
380
425
|
const releaseIgnorePaths = (config) => (config.release && config.release.ignorePaths) || []
|
|
381
426
|
|
|
382
427
|
module.exports = {
|
|
428
|
+
specKindOf,
|
|
429
|
+
mintTypeFor,
|
|
430
|
+
stateNameFor,
|
|
383
431
|
loadAzureConfig,
|
|
384
432
|
mergeConfig,
|
|
385
433
|
defaults,
|
|
@@ -24,6 +24,8 @@ const prompt = require('./src/prompt.js')
|
|
|
24
24
|
const args = require('./src/args.js')
|
|
25
25
|
const adapter = require('./src/adapter.js')
|
|
26
26
|
const apply = require('./src/apply.js')
|
|
27
|
+
const status = require('./src/status.js')
|
|
28
|
+
const splice = require('./src/splice.js')
|
|
27
29
|
|
|
28
30
|
module.exports = {
|
|
29
31
|
...config,
|
|
@@ -38,4 +40,6 @@ module.exports = {
|
|
|
38
40
|
...args,
|
|
39
41
|
...adapter,
|
|
40
42
|
...apply,
|
|
43
|
+
...status,
|
|
44
|
+
...splice,
|
|
41
45
|
}
|