@skitterbyte/skitterspec-azure-boards 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +141 -1
- package/README.md +8 -7
- package/assets/core/SETUP.md +8 -45
- package/assets/core/azure-boards.config.md +53 -6
- package/assets/rules/spec-planning.md +13 -3
- package/assets/skills/spec-azure-setup/SKILL.md +2 -1
- package/assets/skills/spec-list/SKILL.md +28 -5
- package/assets/skills/spec-status/SKILL.md +28 -26
- package/assets/skills/spec-sync/SKILL.md +11 -14
- package/package.json +1 -1
- package/src/vendor/azure-boards/api.js +18 -184
- package/src/vendor/azure-boards/cli-sync.js +73 -68
- package/src/vendor/azure-boards/config.js +9 -52
- package/src/vendor/provider-kit/src/config.js +101 -48
- package/src/vendor/provider-kit/src/list-assignee.js +71 -0
- package/src/vendor/provider-kit/src/list-rows.js +35 -0
- package/src/vendor/provider-kit/src/released.js +27 -77
- package/src/vendor/provider-kit/src/specs.js +89 -7
- package/src/vendor/sync-core/index.js +3 -4
- package/src/vendor/sync-core/src/compare.js +6 -6
- package/src/vendor/sync-core/src/normalize.js +30 -57
- package/src/vendor/provider-kit/src/releases.js +0 -595
|
@@ -68,7 +68,7 @@ function vsspsUrlOf(orgUrl) {
|
|
|
68
68
|
* Wrap credential + org/project into the typed ops the engine uses. Injected
|
|
69
69
|
* `fetch` and `sleep` make every op testable offline.
|
|
70
70
|
*/
|
|
71
|
-
function makeApiAdapter({ orgUrl, project, token,
|
|
71
|
+
function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRetries = MAX_RETRIES }) {
|
|
72
72
|
const doFetch = fetchImpl || globalThis.fetch
|
|
73
73
|
if (typeof doFetch !== 'function') {
|
|
74
74
|
throw new Error('no fetch available — Node 18+ is required for the API transport')
|
|
@@ -350,25 +350,38 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, ticketTag = true,
|
|
|
350
350
|
* matches `readIssue`'s essentials (the twin-mint guard needs identifier +
|
|
351
351
|
* title).
|
|
352
352
|
*/
|
|
353
|
-
|
|
353
|
+
// `assignedTo` is the uniqueName/email `whoami` and `users` return — the
|
|
354
|
+
// value `System.AssignedTo` itself accepts, so WIQL matches it directly.
|
|
355
|
+
//
|
|
356
|
+
// `states` limits to those state names; `orderBy` is a field reference to
|
|
357
|
+
// sort by, ascending — `list --next` passes the backlog's rank field, and
|
|
358
|
+
// WIQL returns ids in that order, which `batchRead` is then made to keep.
|
|
359
|
+
async searchIssues({ query, workItemType, assignedTo = null, states = null, orderBy = null, limit = 50 }) {
|
|
360
|
+
const q = (v) => `'${String(v).replace(/'/g, "''")}'`
|
|
354
361
|
const quoted = String(query || '').replace(/'/g, "''")
|
|
355
362
|
const clauses = [
|
|
356
363
|
'[System.TeamProject] = @project',
|
|
357
|
-
workItemType ? `[System.WorkItemType] =
|
|
364
|
+
workItemType ? `[System.WorkItemType] = ${q(workItemType)}` : null,
|
|
358
365
|
quoted ? `[System.Title] CONTAINS '${quoted}'` : null,
|
|
366
|
+
assignedTo ? `[System.AssignedTo] = ${q(assignedTo)}` : null,
|
|
367
|
+
states && states.length ? `[System.State] IN (${states.map(q).join(', ')})` : null,
|
|
359
368
|
].filter(Boolean)
|
|
369
|
+
const order = orderBy && /^[A-Za-z0-9_.]+$/.test(orderBy) ? ` ORDER BY [${orderBy}] ASC` : ''
|
|
360
370
|
const raw = await request('POST', `${projectBase}/wit/wiql`, {
|
|
361
371
|
query: { $top: limit },
|
|
362
|
-
body: { query: `SELECT [System.Id] FROM WorkItems WHERE ${clauses.join(' AND ')}` },
|
|
372
|
+
body: { query: `SELECT [System.Id] FROM WorkItems WHERE ${clauses.join(' AND ')}${order}` },
|
|
363
373
|
})
|
|
364
374
|
const ids = ((raw && raw.workItems) || []).map((w) => String(w.id))
|
|
365
|
-
const
|
|
375
|
+
const read = await batchRead(ids, ['System.Title', 'System.State', 'System.Parent', 'System.WorkItemType', 'System.AssignedTo'])
|
|
376
|
+
const byId = new Map(read.map((i) => [i.id, i]))
|
|
377
|
+
const items = ids.map((id) => byId.get(id)).filter(Boolean)
|
|
366
378
|
return items.map((i) => ({
|
|
367
379
|
id: i.id,
|
|
368
380
|
identifier: i.identifier,
|
|
369
381
|
title: i.title,
|
|
370
382
|
state: i.state,
|
|
371
383
|
parent: i.parent,
|
|
384
|
+
assignee: i.assignee,
|
|
372
385
|
}))
|
|
373
386
|
},
|
|
374
387
|
|
|
@@ -377,20 +390,6 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, ticketTag = true,
|
|
|
377
390
|
* what `states` validation checks the config against, and what an
|
|
378
391
|
* unknown-state refusal lists.
|
|
379
392
|
*/
|
|
380
|
-
/**
|
|
381
|
-
* The allowed values of `fieldRef` on `workItemType`: `[]` for a field
|
|
382
|
-
* with no picklist (any value goes), null when the type has no such field.
|
|
383
|
-
*/
|
|
384
|
-
async fieldAllowedValues(workItemType, fieldRef) {
|
|
385
|
-
const raw = await request(
|
|
386
|
-
'GET',
|
|
387
|
-
`${projectBase}/wit/workitemtypes/${encodeURIComponent(workItemType)}/fields/${encodeURIComponent(fieldRef)}`,
|
|
388
|
-
{ query: { $expand: 'allowedValues' }, allow404: true },
|
|
389
|
-
)
|
|
390
|
-
if (!raw) return null
|
|
391
|
-
return (raw.allowedValues || []).map(String)
|
|
392
|
-
},
|
|
393
|
-
|
|
394
393
|
async listIssueStates(workItemType) {
|
|
395
394
|
const raw = await request(
|
|
396
395
|
'GET',
|
|
@@ -485,171 +484,6 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, ticketTag = true,
|
|
|
485
484
|
})
|
|
486
485
|
return raw && raw.id != null ? { id: String(raw.id) } : null
|
|
487
486
|
},
|
|
488
|
-
|
|
489
|
-
// --- releases (the kit's release seam, `provider-kit/src/releases.js`) ---
|
|
490
|
-
// Boards has no Releases object, so the carrier is ONE WORK ITEM of
|
|
491
|
-
// `releases.workItemType` per release (spec Decision 12): found by exact
|
|
492
|
-
// title, tickets attached as Related links with one comment each,
|
|
493
|
-
// `deployed` moving the ITEM's state, `complete` closing it.
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* The release work item for a tag, or null. Found by exact-title WIQL
|
|
497
|
-
* under the configured type. TWO hits is a cannot-tell — someone minted a
|
|
498
|
-
* twin by hand — and throws rather than picking one (the kit refuses on a
|
|
499
|
-
* throw, which is the duplicate-safe branch).
|
|
500
|
-
*/
|
|
501
|
-
async releaseFind(tag) {
|
|
502
|
-
const quotedTag = String(tag).replace(/'/g, "''")
|
|
503
|
-
const quotedType = String(releaseType || 'Release').replace(/'/g, "''")
|
|
504
|
-
const raw = await request('POST', `${projectBase}/wit/wiql`, {
|
|
505
|
-
body: {
|
|
506
|
-
query:
|
|
507
|
-
`SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project ` +
|
|
508
|
-
`AND [System.WorkItemType] = '${quotedType}' AND [System.Title] = '${quotedTag}'`,
|
|
509
|
-
},
|
|
510
|
-
})
|
|
511
|
-
const ids = ((raw && raw.workItems) || []).map((w) => w.id)
|
|
512
|
-
if (!ids.length) return null
|
|
513
|
-
if (ids.length > 1) {
|
|
514
|
-
throw new AzureRefusal(
|
|
515
|
-
`${ids.length} "${releaseType || 'Release'}" items are titled "${tag}" (${ids.map(identifierOf).join(', ')}) — cannot tell which is the release`,
|
|
516
|
-
{ status: null },
|
|
517
|
-
)
|
|
518
|
-
}
|
|
519
|
-
const item = await this.readIssue(ids[0])
|
|
520
|
-
return item ? { id: item.id, url: item.url, body: item.description || '', state: item.state, type: item.type } : null
|
|
521
|
-
},
|
|
522
|
-
|
|
523
|
-
async releaseCreate({ tag, name, body }) {
|
|
524
|
-
const created = await this.createIssue({
|
|
525
|
-
title: name || tag,
|
|
526
|
-
description: body,
|
|
527
|
-
workItemType: releaseType || 'Release',
|
|
528
|
-
})
|
|
529
|
-
return { id: created.id, url: created.url, body: body || '' }
|
|
530
|
-
},
|
|
531
|
-
|
|
532
|
-
async releaseUpdate(release, { name, body }) {
|
|
533
|
-
const updates = {}
|
|
534
|
-
if (name != null) updates.title = name
|
|
535
|
-
if (body !== undefined) updates.description = body
|
|
536
|
-
if (Object.keys(updates).length) await this.updateIssue(release.id, updates)
|
|
537
|
-
release.body = body !== undefined ? body : release.body
|
|
538
|
-
return release
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Attach each ticket to the release item as a Related link, commenting
|
|
543
|
-
* once on each NEWLY attached ticket. An existing link counts as
|
|
544
|
-
* `already`, which is what makes a CI retry additive rather than noisy.
|
|
545
|
-
*
|
|
546
|
-
* Then tag each ticket with the release's title (its tag), so the story
|
|
547
|
-
* card shows which release carried it. The tag is checked per ticket,
|
|
548
|
-
* independently of the link, so re-running `create` backfills a release
|
|
549
|
-
* cut before tagging existed — without a second comment.
|
|
550
|
-
*/
|
|
551
|
-
async releaseAttach(release, tickets) {
|
|
552
|
-
const raw = await request('GET', `${projectBase}/wit/workitems/${encodeURIComponent(release.id)}`, {
|
|
553
|
-
query: { $expand: 'relations' },
|
|
554
|
-
})
|
|
555
|
-
const linked = new Set(
|
|
556
|
-
((raw && raw.relations) || [])
|
|
557
|
-
.filter((r) => r && r.rel === 'System.LinkTypes.Related')
|
|
558
|
-
.map((r) => idFromRelationUrl(r.url))
|
|
559
|
-
.filter(Boolean),
|
|
560
|
-
)
|
|
561
|
-
let attached = 0
|
|
562
|
-
let already = 0
|
|
563
|
-
const ids = []
|
|
564
|
-
for (const ticket of tickets || []) {
|
|
565
|
-
const ticketId = String(ticket.ref || '').replace(/^AB#/, '')
|
|
566
|
-
if (!/^\d+$/.test(ticketId)) continue
|
|
567
|
-
ids.push(ticketId)
|
|
568
|
-
if (linked.has(ticketId)) {
|
|
569
|
-
already++
|
|
570
|
-
continue
|
|
571
|
-
}
|
|
572
|
-
await request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(release.id)}`, {
|
|
573
|
-
body: [{ op: 'add', path: '/relations/-', value: { rel: 'System.LinkTypes.Related', url: itemApiUrl(ticketId) } }],
|
|
574
|
-
patch: true,
|
|
575
|
-
})
|
|
576
|
-
await this.createComment(
|
|
577
|
-
ticketId,
|
|
578
|
-
`Included in release **${raw && raw.fields ? raw.fields['System.Title'] : release.id}**` +
|
|
579
|
-
(release.url ? ` — ${release.url}` : ''),
|
|
580
|
-
)
|
|
581
|
-
attached++
|
|
582
|
-
}
|
|
583
|
-
if (!ticketTag) return { attached, already }
|
|
584
|
-
const tag = raw && raw.fields ? raw.fields['System.Title'] : null
|
|
585
|
-
const tagged = tag ? await tagTickets(ids, tag) : 0
|
|
586
|
-
return { attached, already, tagged }
|
|
587
|
-
},
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* `deployed <env>`: the RELEASE ITEM's state moves to the env's configured
|
|
591
|
-
* state — never each ticket's, which is the two-state-machines trap the
|
|
592
|
-
* per-ticket mapping exists to avoid.
|
|
593
|
-
*
|
|
594
|
-
* With `deployedField` set, each attached ticket's field takes the same
|
|
595
|
-
* value, so a story card shows where its release is. The value is checked
|
|
596
|
-
* against every ticket type's allowed values BEFORE anything is written,
|
|
597
|
-
* the release move included: an unknown value or a type without the field
|
|
598
|
-
* refuses with nothing changed. Phase Tasks are never reached — the
|
|
599
|
-
* tickets are the spec items `Refs:` names. `set` is 1 + tickets changed.
|
|
600
|
-
*/
|
|
601
|
-
async releaseStage(release, stateName, tickets) {
|
|
602
|
-
const ids = (tickets || [])
|
|
603
|
-
.map((t) => String(t.ref || '').replace(/^AB#/, ''))
|
|
604
|
-
.filter((id) => /^\d+$/.test(id))
|
|
605
|
-
let pending = []
|
|
606
|
-
if (deployedField && ids.length) {
|
|
607
|
-
const raw = await request('POST', `${projectBase}/wit/workitemsbatch`, {
|
|
608
|
-
body: { ids: ids.map(Number), fields: ['System.WorkItemType', deployedField] },
|
|
609
|
-
})
|
|
610
|
-
const items = (raw && raw.value) || []
|
|
611
|
-
const types = [...new Set(items.map((i) => (i.fields || {})['System.WorkItemType']).filter(Boolean))]
|
|
612
|
-
for (const type of types) {
|
|
613
|
-
const allowed = await this.fieldAllowedValues(type, deployedField)
|
|
614
|
-
if (allowed == null) {
|
|
615
|
-
throw new AzureRefusal(`the "${type}" type has no field "${deployedField}" (releases.deployedField) — nothing written`, { status: null })
|
|
616
|
-
}
|
|
617
|
-
if (allowed.length && !allowed.includes(stateName)) {
|
|
618
|
-
throw new AzureRefusal(
|
|
619
|
-
`"${stateName}" is not an allowed value of ${deployedField} on "${type}" (allows: ${allowed.map((v) => `"${v}"`).join(', ')}) — nothing written`,
|
|
620
|
-
{ status: null },
|
|
621
|
-
)
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
pending = items.filter((i) => (i.fields || {})[deployedField] !== stateName).map((i) => String(i.id))
|
|
625
|
-
}
|
|
626
|
-
await this.transitionTo(release.id, stateName)
|
|
627
|
-
for (const id of pending) {
|
|
628
|
-
await request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(id)}`, {
|
|
629
|
-
body: [{ op: 'add', path: `/fields/${deployedField}`, value: stateName }],
|
|
630
|
-
patch: true,
|
|
631
|
-
})
|
|
632
|
-
}
|
|
633
|
-
return { set: 1 + pending.length }
|
|
634
|
-
},
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Close the release item: the type's own Completed-category state, read at
|
|
638
|
-
* run time because a release type's workflow is process-defined like every
|
|
639
|
-
* other. No Completed state is a named refusal, never a guess.
|
|
640
|
-
*/
|
|
641
|
-
async releaseComplete(release) {
|
|
642
|
-
const states = await this.listIssueStates(release.type || releaseType || 'Release')
|
|
643
|
-
const done = states.find((s) => s.category === 'Completed')
|
|
644
|
-
if (!done) {
|
|
645
|
-
throw new AzureRefusal(
|
|
646
|
-
`the "${release.type || releaseType || 'Release'}" type has no Completed-category state (has: ${states.map((s) => `"${s.name}"`).join(', ') || 'none'})`,
|
|
647
|
-
{ status: null },
|
|
648
|
-
)
|
|
649
|
-
}
|
|
650
|
-
await this.transitionTo(release.id, done.name)
|
|
651
|
-
return release
|
|
652
|
-
},
|
|
653
487
|
}
|
|
654
488
|
}
|
|
655
489
|
|
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
isEmptyPlan,
|
|
35
35
|
validateStates,
|
|
36
36
|
stateSuggestions,
|
|
37
|
-
|
|
37
|
+
stateNamesFor,
|
|
38
38
|
remoteDescriptionEdited,
|
|
39
39
|
writeFrontmatter,
|
|
40
40
|
stampSubIssueId,
|
|
@@ -45,7 +45,8 @@ const kit = require('../provider-kit')
|
|
|
45
45
|
const { BUCKETS, findSpecFolder, currentBranch } = require('../../env/resolve.js')
|
|
46
46
|
|
|
47
47
|
const { makeAssignmentCommands } = require('../provider-kit/src/assignment.js')
|
|
48
|
-
const {
|
|
48
|
+
const { resolveListAssignee } = require('../provider-kit/src/list-assignee.js')
|
|
49
|
+
const { expandStateArgs, specColumn, specCell } = require('../provider-kit/src/list-rows.js')
|
|
49
50
|
const { IDENTIFIER_RE } = require('../provider-kit/src/released.js')
|
|
50
51
|
|
|
51
52
|
const { loadAzureConfig, mergeConfig, defaults, CONFIG_FILE, LIFECYCLE_BUCKETS } = require('./config.js')
|
|
@@ -67,7 +68,7 @@ const BIN = 'skitterspec-azure-boards'
|
|
|
67
68
|
|
|
68
69
|
const PROGRAM = 'spec-sync'
|
|
69
70
|
const specHelpers = kit.makeSpecHelpers({ program: PROGRAM })
|
|
70
|
-
const { resolveSnapshotDir, specIdentifier, listSpecs, resolveOrExit, warnToErr, verifyLines } = specHelpers
|
|
71
|
+
const { resolveSnapshotDir, specIdentifier, listSpecs, listSpecsLive, resolveOrExit, warnToErr, verifyLines } = specHelpers
|
|
71
72
|
|
|
72
73
|
// A work item identifier: the constant AB prefix and a number. A bare number
|
|
73
74
|
// is accepted on input and normalised, so a stamp can be copied from the
|
|
@@ -257,9 +258,6 @@ function apiAdapterFor(config, flags) {
|
|
|
257
258
|
orgUrl: config.azure.orgUrl,
|
|
258
259
|
project: config.azure.project,
|
|
259
260
|
token: cred.token,
|
|
260
|
-
releaseType: (config.releases && config.releases.workItemType) || 'Release',
|
|
261
|
-
ticketTag: !config.releases || config.releases.ticketTag !== false,
|
|
262
|
-
deployedField: (config.releases && config.releases.deployedField) || '',
|
|
263
261
|
fetch: flags.fetch,
|
|
264
262
|
}),
|
|
265
263
|
}
|
|
@@ -319,12 +317,13 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
319
317
|
refPattern: AZURE_REF_RE,
|
|
320
318
|
foreignPatterns: foreign.patterns,
|
|
321
319
|
})
|
|
320
|
+
report.tickets = kit.nameTickets(report.tickets, listSpecs(dir, config, { urls: true }))
|
|
322
321
|
if (flags.json) {
|
|
323
322
|
out.write(JSON.stringify(report, null, 2) + '\n')
|
|
324
323
|
return 0
|
|
325
324
|
}
|
|
326
325
|
const lines = [`${PROGRAM} released: ${range} — ${report.total} commit(s)`]
|
|
327
|
-
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))`)
|
|
326
|
+
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))${t.spec ? ` ${t.spec}` : ''}`)
|
|
328
327
|
if (!report.tickets.length) lines.push(' no referenced tickets')
|
|
329
328
|
if (report.unreferenced) lines.push(` ${report.unreferenced} commit(s) carry no Refs: trailer`)
|
|
330
329
|
if (report.historical) lines.push(` ${report.historical} commit(s) reference an earlier tracker`)
|
|
@@ -333,34 +332,6 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
333
332
|
return 0
|
|
334
333
|
}
|
|
335
334
|
|
|
336
|
-
// ---------------------------------------------------------------------------
|
|
337
|
-
// `release create | deployed | complete` — the kit's release seam
|
|
338
|
-
// (`provider-kit/src/releases.js`), carried by a work item of
|
|
339
|
-
// `releases.workItemType` (spec Decision 12): skitterspec decides the ticket
|
|
340
|
-
// set, the item holds it, `deployed` moves the ITEM's state, `complete`
|
|
341
|
-
// closes it.
|
|
342
|
-
const releases = makeReleaseCommands({
|
|
343
|
-
tracker: 'Azure Boards',
|
|
344
|
-
program: PROGRAM,
|
|
345
|
-
readCommits: (dir, range) => readCommitRange(dir, range),
|
|
346
|
-
ticketOptions: (config) => ({
|
|
347
|
-
ignorePaths: (config.release && config.release.ignorePaths) || [],
|
|
348
|
-
refPattern: AZURE_REF_RE,
|
|
349
|
-
foreignPatterns: foreignPatternsOf(config).patterns,
|
|
350
|
-
}),
|
|
351
|
-
teamKey: () => '',
|
|
352
|
-
listSpecs: (dir, config) => listSpecs(dir, config),
|
|
353
|
-
series: (config) => (config.releases && config.releases.series) || [],
|
|
354
|
-
adapterFor: (config, flags) => apiAdapterFor(config, flags),
|
|
355
|
-
describe: (t) => `${t.ref}${t.title ? ` ${t.title}` : ''}`,
|
|
356
|
-
// The release verbs are CI commands and the engine never calls MCP tools —
|
|
357
|
-
// so over MCP this is impossible, not merely slower, and says so (exit 1).
|
|
358
|
-
impossibleOverMcp: (config, flags) =>
|
|
359
|
-
kit.resolveTransport(flags, config, true) === 'mcp'
|
|
360
|
-
? 'transport = mcp — the release verbs write over the API; set a PAT (CI: a pipeline secret) and re-run'
|
|
361
|
-
: null,
|
|
362
|
-
})
|
|
363
|
-
|
|
364
335
|
// ---------------------------------------------------------------------------
|
|
365
336
|
// Assignment: `assign`, `whoami` and `users` are the kit's
|
|
366
337
|
// (`provider-kit/src/assignment.js`); this is Azure's binding. The id is the
|
|
@@ -714,13 +685,9 @@ function specSyncStatus(dir, config, specArg, flags, out, err) {
|
|
|
714
685
|
out.write(`${PROGRAM} status: cannot read --remote: ${error.message}\n`)
|
|
715
686
|
return 1
|
|
716
687
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
lines.push(` drift: Azure says "${bucket}", the repo says "${local}" (repo wins on next push)`)
|
|
721
|
-
} else if (bucket) {
|
|
722
|
-
lines.push(' drift: none — Azure agrees with the repo')
|
|
723
|
-
}
|
|
688
|
+
// NO STATE LINE, deliberately: skitterspec tells the tracker about its own
|
|
689
|
+
// transitions and never reads a status back. A ticket someone moved there
|
|
690
|
+
// is theirs to have moved, and push resends State only when the spec does.
|
|
724
691
|
// SILENT ON EVERYTHING EXCEPT A POSITIVE ANSWER: `remoteDescriptionEdited`
|
|
725
692
|
// returns null for every cannot-tell, and none of those is evidence.
|
|
726
693
|
if (remoteDescriptionEdited(readBase(dir, identifier, config), remote, config) === true) {
|
|
@@ -833,6 +800,12 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
833
800
|
? `ok${catOf.get(name) ? ` [${catOf.get(name)}]` : ''}`
|
|
834
801
|
: `MISSING from these types${suggestions.get(bucket) ? ` — closest: "${suggestions.get(bucket)}"` : ''}`
|
|
835
802
|
lines.push(` ${bucket.padEnd(bw)} -> ${String(name).padEnd(nw)} ${tail}`)
|
|
803
|
+
// Aliases are read-only, so a missing one never blocks a push — but it
|
|
804
|
+
// reads as nothing, so it is still named.
|
|
805
|
+
for (const alias of stateNamesFor(bucket, config).slice(1)) {
|
|
806
|
+
const here = names.includes(alias)
|
|
807
|
+
lines.push(` ${''.padEnd(bw)} ${String(alias).padEnd(nw)} ${here ? 'also reads as ' + bucket : 'alias MISSING — reads as nothing'}`)
|
|
808
|
+
}
|
|
836
809
|
}
|
|
837
810
|
if (missing.length) lines.push(` remap: ${PROGRAM} init-config --force --state <bucket>="<state>"`)
|
|
838
811
|
out.write(lines.join('\n') + '\n')
|
|
@@ -840,6 +813,15 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
840
813
|
}
|
|
841
814
|
|
|
842
815
|
async function specSyncList(dir, config, flags, out) {
|
|
816
|
+
// `--next N` is the top of the BACKLOG in the backlog's own order, so it
|
|
817
|
+
// fixes the scope itself — combined with --state or --all one would have to
|
|
818
|
+
// lose, silently. Refused before any transport work, as Linear does.
|
|
819
|
+
const next = Number.isFinite(flags.next) && flags.next > 0 ? flags.next : null
|
|
820
|
+
const scopeFlags = [next !== null && '--next', flags.all === true && '--all', (flags.stateArgs || []).length > 0 && '--state'].filter(Boolean)
|
|
821
|
+
if (scopeFlags.length > 1) {
|
|
822
|
+
out.write(`${PROGRAM} list: ${scopeFlags.join(' and ')} each pick the scope, so they cannot be combined\n`)
|
|
823
|
+
return 1
|
|
824
|
+
}
|
|
843
825
|
const cred = apiAdapterFor(config, flags)
|
|
844
826
|
const transport = kit.resolveTransport(flags, config, cred.ok)
|
|
845
827
|
if (transport === 'mcp' || !cred.ok) {
|
|
@@ -852,20 +834,38 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
852
834
|
out.write(`${PROGRAM} list: no azure.project configured — fix ${CONFIG_FILE}\n`)
|
|
853
835
|
return 1
|
|
854
836
|
}
|
|
837
|
+
const who = await resolveListAssignee({
|
|
838
|
+
flags,
|
|
839
|
+
config,
|
|
840
|
+
env: flags.env || process.env,
|
|
841
|
+
adapter: cred.adapter,
|
|
842
|
+
resolveIdentity,
|
|
843
|
+
displayNameOf,
|
|
844
|
+
tracker: 'Azure DevOps',
|
|
845
|
+
prog: PROGRAM,
|
|
846
|
+
})
|
|
847
|
+
if (who.code != null) {
|
|
848
|
+
out.write(who.lines.join('\n') + '\n')
|
|
849
|
+
return who.code
|
|
850
|
+
}
|
|
851
|
+
const assignee = who.assignee
|
|
855
852
|
let items
|
|
856
853
|
try {
|
|
857
854
|
items = await cred.adapter.searchIssues({
|
|
858
855
|
query: '',
|
|
859
856
|
workItemType: config.azure.workItemType,
|
|
860
|
-
|
|
857
|
+
assignedTo: assignee ? assignee.id : null,
|
|
858
|
+
states: next !== null ? stateNamesFor('backlog', config) : null,
|
|
859
|
+
orderBy: next !== null ? config.azure.backlogOrderField : null,
|
|
860
|
+
limit: next !== null ? next : flags.limit || 50,
|
|
861
861
|
})
|
|
862
|
-
const stateNames = flags.stateArgs
|
|
862
|
+
const stateNames = expandStateArgs(flags.stateArgs, config)
|
|
863
863
|
if (stateNames.length) {
|
|
864
864
|
const want = new Set(stateNames.map((s) => s.toLowerCase()))
|
|
865
865
|
items = items.filter((i) => i.state && want.has(String(i.state.name).toLowerCase()))
|
|
866
|
-
} else if (!flags.all) {
|
|
866
|
+
} else if (!flags.all && next === null) {
|
|
867
867
|
const terminal = new Set(
|
|
868
|
-
[
|
|
868
|
+
[...stateNamesFor('complete', config), ...stateNamesFor('cancelled', config)].map((s) => s.toLowerCase()),
|
|
869
869
|
)
|
|
870
870
|
items = items.filter((i) => !i.state || !terminal.has(String(i.state.name).toLowerCase()))
|
|
871
871
|
}
|
|
@@ -873,26 +873,35 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
873
873
|
out.write(`${PROGRAM} list: ${error.message}\n`)
|
|
874
874
|
return 1
|
|
875
875
|
}
|
|
876
|
-
const linked = new Map(
|
|
876
|
+
const linked = new Map(listSpecsLive(dir, config).filter((s) => s.identifier).map((s) => [s.identifier, s]))
|
|
877
877
|
const rows = items
|
|
878
878
|
.filter((i) => !i.parent)
|
|
879
|
-
.map((i) =>
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
879
|
+
.map((i) => {
|
|
880
|
+
const spec = linked.get(i.identifier) || null
|
|
881
|
+
const state = i.state ? i.state.name : null
|
|
882
|
+
return {
|
|
883
|
+
identifier: i.identifier,
|
|
884
|
+
title: i.title,
|
|
885
|
+
state,
|
|
886
|
+
...specColumn(state, spec, config),
|
|
887
|
+
assignee: i.assignee ? i.assignee.name || i.assignee.email || i.assignee.id : null,
|
|
888
|
+
spec: spec ? spec.spec : null,
|
|
889
|
+
}
|
|
890
|
+
})
|
|
885
891
|
if (flags.json) {
|
|
886
892
|
out.write(JSON.stringify(rows, null, 2) + '\n')
|
|
887
893
|
return 0
|
|
888
894
|
}
|
|
889
895
|
if (!rows.length) {
|
|
890
|
-
out.write(`${PROGRAM} list: nothing matched\n`)
|
|
896
|
+
out.write(`${PROGRAM} list: nothing matched${assignee ? ` for ${assignee.name}` : ''}\n`)
|
|
891
897
|
return 0
|
|
892
898
|
}
|
|
893
|
-
const
|
|
899
|
+
const scope = next !== null ? ` · next ${next} by ${config.azure.backlogOrderField}` : ''
|
|
900
|
+
const lines = [`${PROGRAM} list: ${config.azure.project}${assignee ? ` · assigned to ${assignee.name}` : ''}${scope}`]
|
|
894
901
|
for (const r of rows) {
|
|
895
|
-
lines.push(
|
|
902
|
+
lines.push(
|
|
903
|
+
` ${r.identifier}\t${r.state || '—'}\t${specCell(r)}\t${r.assignee || 'unassigned'}\t${r.title || ''}${r.spec ? ` -> ${r.spec}` : ' (no spec)'}`,
|
|
904
|
+
)
|
|
896
905
|
}
|
|
897
906
|
out.write(lines.join('\n') + '\n')
|
|
898
907
|
return 0
|
|
@@ -1244,6 +1253,8 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1244
1253
|
checks.push(row('tracker', 'Azure config', 'broken', 'orgUrl or project is empty', `fix ${CONFIG_FILE}`))
|
|
1245
1254
|
} else {
|
|
1246
1255
|
checks.push(row('tracker', 'Azure config', 'ok', `${loaded.config.azure.project} @ ${loaded.config.azure.orgUrl}`))
|
|
1256
|
+
const retired = kit.retiredKeysRow(path.join(dir, CONFIG_FILE), CONFIG_FILE, row)
|
|
1257
|
+
if (retired) checks.push(retired)
|
|
1247
1258
|
// A worktree forks from a COMMIT, so a config that exists only in the
|
|
1248
1259
|
// working tree is invisible in every spec worktree — where the sync
|
|
1249
1260
|
// skills actually run — and sync there reports itself off with no clue
|
|
@@ -1356,11 +1367,10 @@ const USAGE = `Usage: skitterspec-azure-boards spec-sync <subcommand>
|
|
|
1356
1367
|
status <spec> [--remote <f>] read-only drift report
|
|
1357
1368
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1358
1369
|
states [--json] the configured types' state names
|
|
1359
|
-
list [--all | --state NAME]
|
|
1370
|
+
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] tracker listing
|
|
1360
1371
|
linked [--json] specs and their linked items (offline)
|
|
1361
1372
|
ref [<spec>] the Refs: trailer value for this branch
|
|
1362
1373
|
released [<range>] tickets a commit range contains
|
|
1363
|
-
release create|deployed|complete <tag> the release work item (CI; --apply)
|
|
1364
1374
|
preserve <spec> [--text <f>] keep an adopted item's original report
|
|
1365
1375
|
assign <spec> --to <id> | --release stamp who is building it
|
|
1366
1376
|
whoami [--set <id>] [--unset] who you are on Azure (cached)
|
|
@@ -1439,16 +1449,8 @@ async function specSync(rest, io = {}) {
|
|
|
1439
1449
|
return specSyncRef(dir, config, positional[0], flags, out, err)
|
|
1440
1450
|
case 'released':
|
|
1441
1451
|
return specSyncReleased(dir, config, positional[0], flags, out)
|
|
1442
|
-
case 'release':
|
|
1443
|
-
|
|
1444
|
-
// one silently would re-count that tracker's history as unreferenced.
|
|
1445
|
-
const foreign = foreignPatternsOf(config)
|
|
1446
|
-
if (foreign.bad.length) {
|
|
1447
|
-
out.write(`${PROGRAM} release: refs.foreignPatterns has invalid pattern(s): ${foreign.bad.join(', ')} — fix ${CONFIG_FILE}\n`)
|
|
1448
|
-
return 1
|
|
1449
|
-
}
|
|
1450
|
-
return releases.run(dir, config, positional, flags, out)
|
|
1451
|
-
}
|
|
1452
|
+
case 'release':
|
|
1453
|
+
return kit.refuseRemovedVerb(out, PROGRAM, 'release')
|
|
1452
1454
|
case 'preserve':
|
|
1453
1455
|
return specSyncPreserve(dir, config, positional[0], flags, out)
|
|
1454
1456
|
case 'assign':
|
|
@@ -1502,6 +1504,9 @@ function parseArgs(args, sub) {
|
|
|
1502
1504
|
'--to': { kind: 'string' },
|
|
1503
1505
|
'--name': { kind: 'string' },
|
|
1504
1506
|
'--release': { kind: 'boolean' },
|
|
1507
|
+
'--mine': { kind: 'boolean' },
|
|
1508
|
+
'--next': { kind: 'number' },
|
|
1509
|
+
'--by': { kind: 'string' },
|
|
1505
1510
|
'--set': { kind: 'string' },
|
|
1506
1511
|
'--unset': { kind: 'boolean' },
|
|
1507
1512
|
'--stdin': { kind: 'boolean' },
|
|
@@ -41,6 +41,10 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
41
41
|
workItemType: 'Issue',
|
|
42
42
|
childType: 'Task',
|
|
43
43
|
areaPath: '',
|
|
44
|
+
// The field `list --next` orders the backlog by. StackRank is the rank
|
|
45
|
+
// the Basic, Agile and CMMI backlogs drag-order; a Scrum process ranks by
|
|
46
|
+
// `Microsoft.VSTS.Common.BacklogPriority` instead.
|
|
47
|
+
backlogOrderField: 'Microsoft.VSTS.Common.StackRank',
|
|
44
48
|
// The mint type per SPEC KIND (`feature`/`bug`/`hotfix`, from the spec
|
|
45
49
|
// folder's prefix), falling back to `workItemType`. In Agile, Scrum and
|
|
46
50
|
// CMMI a bug is a work item TYPE, so `/spec-bug` minting a User Story
|
|
@@ -95,18 +99,8 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
95
99
|
// accuses.
|
|
96
100
|
refs: Object.freeze({ foreignPatterns: Object.freeze([]) }),
|
|
97
101
|
release: Object.freeze({
|
|
98
|
-
stages: Object.freeze([]),
|
|
99
102
|
ignorePaths: Object.freeze(['specs/', 'CHANGELOG.md', 'RELEASES.md']),
|
|
100
103
|
}),
|
|
101
|
-
// The release seam's Azure carrier (spec Decision 12): one work item of
|
|
102
|
-
// `workItemType` per release, found by WIQL title lookup, its state moved
|
|
103
|
-
// through `series[].envs`. Phase 5 implements the verbs; the config shape
|
|
104
|
-
// lives here so setup writes one file. `ticketTag` tags each attached ticket
|
|
105
|
-
// with the release tag, so a story card shows which release carried it.
|
|
106
|
-
// `deployedField` is a field reference (e.g. `Custom.Deployed`) that
|
|
107
|
-
// `deployed <env>` sets on each attached ticket to the env's value; empty
|
|
108
|
-
// writes none, since the field has to be added to the process first.
|
|
109
|
-
releases: Object.freeze({ workItemType: 'Release', series: Object.freeze([]), ticketTag: true, deployedField: '' }),
|
|
110
104
|
branch: Object.freeze({ pattern: '{type}/{slug}' }),
|
|
111
105
|
// An env-var NAME, not a value — the official CLI's, so a machine already
|
|
112
106
|
// set up for `az boards` needs nothing new.
|
|
@@ -145,6 +139,7 @@ function defaults() {
|
|
|
145
139
|
azure: { ...DEFAULT_CONFIG.azure },
|
|
146
140
|
mapping: { ...DEFAULT_CONFIG.mapping },
|
|
147
141
|
states: { ...DEFAULT_CONFIG.states },
|
|
142
|
+
stateAliases: {},
|
|
148
143
|
intake: {
|
|
149
144
|
tag: DEFAULT_CONFIG.intake.tag,
|
|
150
145
|
bugTags: [...DEFAULT_CONFIG.intake.bugTags],
|
|
@@ -156,15 +151,8 @@ function defaults() {
|
|
|
156
151
|
fields: { ...DEFAULT_CONFIG.fields },
|
|
157
152
|
refs: { foreignPatterns: [...DEFAULT_CONFIG.refs.foreignPatterns] },
|
|
158
153
|
release: {
|
|
159
|
-
stages: DEFAULT_CONFIG.release.stages.map((s) => ({ ...s })),
|
|
160
154
|
ignorePaths: [...DEFAULT_CONFIG.release.ignorePaths],
|
|
161
155
|
},
|
|
162
|
-
releases: {
|
|
163
|
-
workItemType: DEFAULT_CONFIG.releases.workItemType,
|
|
164
|
-
series: DEFAULT_CONFIG.releases.series.map((s) => ({ ...s })),
|
|
165
|
-
ticketTag: DEFAULT_CONFIG.releases.ticketTag,
|
|
166
|
-
deployedField: DEFAULT_CONFIG.releases.deployedField,
|
|
167
|
-
},
|
|
168
156
|
branch: { ...DEFAULT_CONFIG.branch },
|
|
169
157
|
auth: { ...DEFAULT_CONFIG.auth },
|
|
170
158
|
apply: { ...DEFAULT_CONFIG.apply },
|
|
@@ -179,7 +167,7 @@ function defaults() {
|
|
|
179
167
|
}
|
|
180
168
|
|
|
181
169
|
const { isObject, stringList, assign } = kitConfig
|
|
182
|
-
const { mergeFieldOwnership, mergePhaseMapping,
|
|
170
|
+
const { mergeStates, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
|
|
183
171
|
kitConfig.makeMergeHelpers({
|
|
184
172
|
configFile: CONFIG_FILE,
|
|
185
173
|
ownership: OWNERSHIP,
|
|
@@ -187,22 +175,6 @@ const { mergeFieldOwnership, mergePhaseMapping, mergeReleaseStages, mergeRelease
|
|
|
187
175
|
phaseMappings: PHASE_MAPPINGS,
|
|
188
176
|
})
|
|
189
177
|
|
|
190
|
-
// A release series entry carries the tag prefix it scans and the state each
|
|
191
|
-
// env moves the release item to. Lenient on extras, strict on shape: a series
|
|
192
|
-
// that is not a list of objects is a config error worth naming now.
|
|
193
|
-
function mergeReleaseSeries(base, parsed) {
|
|
194
|
-
if (parsed.series === undefined) return
|
|
195
|
-
if (!Array.isArray(parsed.series) || parsed.series.some((s) => !isObject(s))) {
|
|
196
|
-
throw new Error(`Invalid ${CONFIG_FILE}: releases.series must be a list of objects`)
|
|
197
|
-
}
|
|
198
|
-
base.series = parsed.series.map((s) => ({
|
|
199
|
-
tagPrefix: typeof s.tagPrefix === 'string' ? s.tagPrefix : '',
|
|
200
|
-
envs: isObject(s.envs)
|
|
201
|
-
? Object.fromEntries(Object.entries(s.envs).filter(([, v]) => typeof v === 'string'))
|
|
202
|
-
: {},
|
|
203
|
-
}))
|
|
204
|
-
}
|
|
205
|
-
|
|
206
178
|
/**
|
|
207
179
|
* Merge a parsed config over the defaults. Only known keys are copied (unknown
|
|
208
180
|
* keys ignored for forward-compat). Nested objects are merged field-by-field.
|
|
@@ -216,6 +188,7 @@ function mergeConfig(base, parsed) {
|
|
|
216
188
|
assign(base.azure, parsed.azure, 'workItemType', 'string')
|
|
217
189
|
assign(base.azure, parsed.azure, 'childType', 'string')
|
|
218
190
|
assign(base.azure, parsed.azure, 'areaPath', 'string?')
|
|
191
|
+
assign(base.azure, parsed.azure, 'backlogOrderField', 'string')
|
|
219
192
|
if (isObject(parsed.azure.workItemTypeByKind)) {
|
|
220
193
|
// Only the kinds a spec folder can actually be — an unknown key is
|
|
221
194
|
// dropped rather than carried into `states` validation it can never pass.
|
|
@@ -242,11 +215,7 @@ function mergeConfig(base, parsed) {
|
|
|
242
215
|
mergePhaseMapping(base.mapping, parsed.mapping)
|
|
243
216
|
}
|
|
244
217
|
|
|
245
|
-
|
|
246
|
-
for (const key of Object.keys(base.states)) {
|
|
247
|
-
assign(base.states, parsed.states, key, 'string')
|
|
248
|
-
}
|
|
249
|
-
}
|
|
218
|
+
mergeStates(base, parsed)
|
|
250
219
|
|
|
251
220
|
if (isObject(parsed.intake)) {
|
|
252
221
|
assign(base.intake, parsed.intake, 'tag', 'string?')
|
|
@@ -267,16 +236,9 @@ function mergeConfig(base, parsed) {
|
|
|
267
236
|
}
|
|
268
237
|
|
|
269
238
|
if (isObject(parsed.release)) {
|
|
270
|
-
mergeReleaseStages(base.release, parsed.release)
|
|
271
239
|
mergeReleaseIgnorePaths(base.release, parsed.release)
|
|
272
240
|
}
|
|
273
241
|
|
|
274
|
-
if (isObject(parsed.releases)) {
|
|
275
|
-
assign(base.releases, parsed.releases, 'workItemType', 'string')
|
|
276
|
-
assign(base.releases, parsed.releases, 'ticketTag', 'boolean')
|
|
277
|
-
assign(base.releases, parsed.releases, 'deployedField', 'string?')
|
|
278
|
-
mergeReleaseSeries(base.releases, parsed.releases)
|
|
279
|
-
}
|
|
280
242
|
|
|
281
243
|
if (isObject(parsed.branch)) {
|
|
282
244
|
assign(base.branch, parsed.branch, 'pattern', 'string')
|
|
@@ -376,18 +338,13 @@ function loadAzureConfig(dir = process.cwd()) {
|
|
|
376
338
|
return { config: withRuntime(mergeConfig(base, parsed)), present: true }
|
|
377
339
|
}
|
|
378
340
|
|
|
379
|
-
// The
|
|
380
|
-
// accessors the other providers expose, reading this provider's config.
|
|
381
|
-
const releaseStages = (config) => (config.release && config.release.stages) || []
|
|
382
|
-
const stageFor = (config, key) => releaseStages(config).find((s) => s.key === key) || null
|
|
341
|
+
// The bookkeeping path prefixes `released` ignores.
|
|
383
342
|
const releaseIgnorePaths = (config) => (config.release && config.release.ignorePaths) || []
|
|
384
343
|
|
|
385
344
|
module.exports = {
|
|
386
345
|
loadAzureConfig,
|
|
387
346
|
mergeConfig,
|
|
388
347
|
defaults,
|
|
389
|
-
releaseStages,
|
|
390
|
-
stageFor,
|
|
391
348
|
releaseIgnorePaths,
|
|
392
349
|
DEFAULT_CONFIG,
|
|
393
350
|
CONFIG_FILE,
|