@skitterbyte/skitterspec-azure-boards 1.3.0 → 2.1.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 +170 -1
- package/README.md +8 -7
- package/assets/core/SETUP.md +8 -45
- package/assets/core/azure-boards.config.json.example +1 -0
- package/assets/core/azure-boards.config.md +55 -7
- package/assets/core/env.config.md +1 -1
- package/assets/rules/spec-planning.md +35 -12
- package/assets/rules/spec-reports.md +28 -2
- package/assets/skills/no-spec/SKILL.md +2 -2
- package/assets/skills/spec/SKILL.md +31 -8
- package/assets/skills/spec-azure-setup/SKILL.md +5 -1
- package/assets/skills/spec-bug/SKILL.md +2 -2
- package/assets/skills/spec-list/SKILL.md +28 -5
- package/assets/skills/spec-next/SKILL.md +2 -2
- 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/cli.js +108 -3
- package/src/env/resolve.js +11 -4
- package/src/env/review.js +79 -0
- package/src/vendor/azure-boards/api.js +77 -192
- package/src/vendor/azure-boards/cli-sync.js +114 -72
- package/src/vendor/azure-boards/config.js +60 -67
- package/src/vendor/azure-boards/mcp.js +14 -3
- 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 +60 -59
- package/src/vendor/provider-kit/src/releases.js +0 -595
|
@@ -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
|
|
@@ -152,6 +153,7 @@ function specKindOf(snapshotDir) {
|
|
|
152
153
|
const name = path.basename(String(snapshotDir || ''))
|
|
153
154
|
if (name.startsWith('bug-')) return 'bug'
|
|
154
155
|
if (name.startsWith('hotfix-')) return 'hotfix'
|
|
156
|
+
if (name.startsWith('chore-')) return 'chore'
|
|
155
157
|
return 'feature'
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -257,10 +259,8 @@ function apiAdapterFor(config, flags) {
|
|
|
257
259
|
orgUrl: config.azure.orgUrl,
|
|
258
260
|
project: config.azure.project,
|
|
259
261
|
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
262
|
fetch: flags.fetch,
|
|
263
|
+
bodyFieldByType: config.azure.bodyFieldByType,
|
|
264
264
|
}),
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -319,12 +319,13 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
319
319
|
refPattern: AZURE_REF_RE,
|
|
320
320
|
foreignPatterns: foreign.patterns,
|
|
321
321
|
})
|
|
322
|
+
report.tickets = kit.nameTickets(report.tickets, listSpecs(dir, config, { urls: true }))
|
|
322
323
|
if (flags.json) {
|
|
323
324
|
out.write(JSON.stringify(report, null, 2) + '\n')
|
|
324
325
|
return 0
|
|
325
326
|
}
|
|
326
327
|
const lines = [`${PROGRAM} released: ${range} — ${report.total} commit(s)`]
|
|
327
|
-
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))`)
|
|
328
|
+
for (const t of report.tickets) lines.push(` ${t.ref} (${t.commits} commit(s))${t.spec ? ` ${t.spec}` : ''}`)
|
|
328
329
|
if (!report.tickets.length) lines.push(' no referenced tickets')
|
|
329
330
|
if (report.unreferenced) lines.push(` ${report.unreferenced} commit(s) carry no Refs: trailer`)
|
|
330
331
|
if (report.historical) lines.push(` ${report.historical} commit(s) reference an earlier tracker`)
|
|
@@ -333,34 +334,6 @@ function specSyncReleased(dir, config, rangeArg, flags, out) {
|
|
|
333
334
|
return 0
|
|
334
335
|
}
|
|
335
336
|
|
|
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
337
|
// ---------------------------------------------------------------------------
|
|
365
338
|
// Assignment: `assign`, `whoami` and `users` are the kit's
|
|
366
339
|
// (`provider-kit/src/assignment.js`); this is Azure's binding. The id is the
|
|
@@ -390,7 +363,7 @@ const assignment = makeAssignmentCommands({
|
|
|
390
363
|
resolveIdentity: (config, env, deps) => resolveIdentity(config, env, deps),
|
|
391
364
|
resolveCredential: (config, env) => resolveCredential(config, env),
|
|
392
365
|
makeAdapter: (config, cred, flags) =>
|
|
393
|
-
makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch }),
|
|
366
|
+
makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: config.azure.bodyFieldByType }),
|
|
394
367
|
displayNameOf: (u) => displayNameOf(u),
|
|
395
368
|
usersOverMcp: 'search identities with core_get_identity_ids over MCP, or read them off the org\'s Users page',
|
|
396
369
|
})
|
|
@@ -488,7 +461,7 @@ function companionCoverageNote(dir, config, snapshotDir, out) {
|
|
|
488
461
|
const rawField = parsed.branch && parsed.branch.identifierField
|
|
489
462
|
const field = typeof rawField === 'string' && rawField ? rawField : config.fields.identifier
|
|
490
463
|
|
|
491
|
-
const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix)-/, '')
|
|
464
|
+
const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix|chore)-/, '')
|
|
492
465
|
const basePath = `${config.sync.baseDir}/${identifier}.base.json`
|
|
493
466
|
const claimed = patterns.some((p) => {
|
|
494
467
|
if (typeof p !== 'string') return false
|
|
@@ -714,13 +687,9 @@ function specSyncStatus(dir, config, specArg, flags, out, err) {
|
|
|
714
687
|
out.write(`${PROGRAM} status: cannot read --remote: ${error.message}\n`)
|
|
715
688
|
return 1
|
|
716
689
|
}
|
|
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
|
-
}
|
|
690
|
+
// NO STATE LINE, deliberately: skitterspec tells the tracker about its own
|
|
691
|
+
// transitions and never reads a status back. A ticket someone moved there
|
|
692
|
+
// is theirs to have moved, and push resends State only when the spec does.
|
|
724
693
|
// SILENT ON EVERYTHING EXCEPT A POSITIVE ANSWER: `remoteDescriptionEdited`
|
|
725
694
|
// returns null for every cannot-tell, and none of those is evidence.
|
|
726
695
|
if (remoteDescriptionEdited(readBase(dir, identifier, config), remote, config) === true) {
|
|
@@ -833,6 +802,12 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
833
802
|
? `ok${catOf.get(name) ? ` [${catOf.get(name)}]` : ''}`
|
|
834
803
|
: `MISSING from these types${suggestions.get(bucket) ? ` — closest: "${suggestions.get(bucket)}"` : ''}`
|
|
835
804
|
lines.push(` ${bucket.padEnd(bw)} -> ${String(name).padEnd(nw)} ${tail}`)
|
|
805
|
+
// Aliases are read-only, so a missing one never blocks a push — but it
|
|
806
|
+
// reads as nothing, so it is still named.
|
|
807
|
+
for (const alias of stateNamesFor(bucket, config).slice(1)) {
|
|
808
|
+
const here = names.includes(alias)
|
|
809
|
+
lines.push(` ${''.padEnd(bw)} ${String(alias).padEnd(nw)} ${here ? 'also reads as ' + bucket : 'alias MISSING — reads as nothing'}`)
|
|
810
|
+
}
|
|
836
811
|
}
|
|
837
812
|
if (missing.length) lines.push(` remap: ${PROGRAM} init-config --force --state <bucket>="<state>"`)
|
|
838
813
|
out.write(lines.join('\n') + '\n')
|
|
@@ -840,6 +815,15 @@ async function specSyncStates(dir, config, flags, out) {
|
|
|
840
815
|
}
|
|
841
816
|
|
|
842
817
|
async function specSyncList(dir, config, flags, out) {
|
|
818
|
+
// `--next N` is the top of the BACKLOG in the backlog's own order, so it
|
|
819
|
+
// fixes the scope itself — combined with --state or --all one would have to
|
|
820
|
+
// lose, silently. Refused before any transport work, as Linear does.
|
|
821
|
+
const next = Number.isFinite(flags.next) && flags.next > 0 ? flags.next : null
|
|
822
|
+
const scopeFlags = [next !== null && '--next', flags.all === true && '--all', (flags.stateArgs || []).length > 0 && '--state'].filter(Boolean)
|
|
823
|
+
if (scopeFlags.length > 1) {
|
|
824
|
+
out.write(`${PROGRAM} list: ${scopeFlags.join(' and ')} each pick the scope, so they cannot be combined\n`)
|
|
825
|
+
return 1
|
|
826
|
+
}
|
|
843
827
|
const cred = apiAdapterFor(config, flags)
|
|
844
828
|
const transport = kit.resolveTransport(flags, config, cred.ok)
|
|
845
829
|
if (transport === 'mcp' || !cred.ok) {
|
|
@@ -852,20 +836,38 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
852
836
|
out.write(`${PROGRAM} list: no azure.project configured — fix ${CONFIG_FILE}\n`)
|
|
853
837
|
return 1
|
|
854
838
|
}
|
|
839
|
+
const who = await resolveListAssignee({
|
|
840
|
+
flags,
|
|
841
|
+
config,
|
|
842
|
+
env: flags.env || process.env,
|
|
843
|
+
adapter: cred.adapter,
|
|
844
|
+
resolveIdentity,
|
|
845
|
+
displayNameOf,
|
|
846
|
+
tracker: 'Azure DevOps',
|
|
847
|
+
prog: PROGRAM,
|
|
848
|
+
})
|
|
849
|
+
if (who.code != null) {
|
|
850
|
+
out.write(who.lines.join('\n') + '\n')
|
|
851
|
+
return who.code
|
|
852
|
+
}
|
|
853
|
+
const assignee = who.assignee
|
|
855
854
|
let items
|
|
856
855
|
try {
|
|
857
856
|
items = await cred.adapter.searchIssues({
|
|
858
857
|
query: '',
|
|
859
858
|
workItemType: config.azure.workItemType,
|
|
860
|
-
|
|
859
|
+
assignedTo: assignee ? assignee.id : null,
|
|
860
|
+
states: next !== null ? stateNamesFor('backlog', config) : null,
|
|
861
|
+
orderBy: next !== null ? config.azure.backlogOrderField : null,
|
|
862
|
+
limit: next !== null ? next : flags.limit || 50,
|
|
861
863
|
})
|
|
862
|
-
const stateNames = flags.stateArgs
|
|
864
|
+
const stateNames = expandStateArgs(flags.stateArgs, config)
|
|
863
865
|
if (stateNames.length) {
|
|
864
866
|
const want = new Set(stateNames.map((s) => s.toLowerCase()))
|
|
865
867
|
items = items.filter((i) => i.state && want.has(String(i.state.name).toLowerCase()))
|
|
866
|
-
} else if (!flags.all) {
|
|
868
|
+
} else if (!flags.all && next === null) {
|
|
867
869
|
const terminal = new Set(
|
|
868
|
-
[
|
|
870
|
+
[...stateNamesFor('complete', config), ...stateNamesFor('cancelled', config)].map((s) => s.toLowerCase()),
|
|
869
871
|
)
|
|
870
872
|
items = items.filter((i) => !i.state || !terminal.has(String(i.state.name).toLowerCase()))
|
|
871
873
|
}
|
|
@@ -873,26 +875,35 @@ async function specSyncList(dir, config, flags, out) {
|
|
|
873
875
|
out.write(`${PROGRAM} list: ${error.message}\n`)
|
|
874
876
|
return 1
|
|
875
877
|
}
|
|
876
|
-
const linked = new Map(
|
|
878
|
+
const linked = new Map(listSpecsLive(dir, config).filter((s) => s.identifier).map((s) => [s.identifier, s]))
|
|
877
879
|
const rows = items
|
|
878
880
|
.filter((i) => !i.parent)
|
|
879
|
-
.map((i) =>
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
881
|
+
.map((i) => {
|
|
882
|
+
const spec = linked.get(i.identifier) || null
|
|
883
|
+
const state = i.state ? i.state.name : null
|
|
884
|
+
return {
|
|
885
|
+
identifier: i.identifier,
|
|
886
|
+
title: i.title,
|
|
887
|
+
state,
|
|
888
|
+
...specColumn(state, spec, config),
|
|
889
|
+
assignee: i.assignee ? i.assignee.name || i.assignee.email || i.assignee.id : null,
|
|
890
|
+
spec: spec ? spec.spec : null,
|
|
891
|
+
}
|
|
892
|
+
})
|
|
885
893
|
if (flags.json) {
|
|
886
894
|
out.write(JSON.stringify(rows, null, 2) + '\n')
|
|
887
895
|
return 0
|
|
888
896
|
}
|
|
889
897
|
if (!rows.length) {
|
|
890
|
-
out.write(`${PROGRAM} list: nothing matched\n`)
|
|
898
|
+
out.write(`${PROGRAM} list: nothing matched${assignee ? ` for ${assignee.name}` : ''}\n`)
|
|
891
899
|
return 0
|
|
892
900
|
}
|
|
893
|
-
const
|
|
901
|
+
const scope = next !== null ? ` · next ${next} by ${config.azure.backlogOrderField}` : ''
|
|
902
|
+
const lines = [`${PROGRAM} list: ${config.azure.project}${assignee ? ` · assigned to ${assignee.name}` : ''}${scope}`]
|
|
894
903
|
for (const r of rows) {
|
|
895
|
-
lines.push(
|
|
904
|
+
lines.push(
|
|
905
|
+
` ${r.identifier}\t${r.state || '—'}\t${specCell(r)}\t${r.assignee || 'unassigned'}\t${r.title || ''}${r.spec ? ` -> ${r.spec}` : ' (no spec)'}`,
|
|
906
|
+
)
|
|
896
907
|
}
|
|
897
908
|
out.write(lines.join('\n') + '\n')
|
|
898
909
|
return 0
|
|
@@ -1176,7 +1187,7 @@ async function specSyncInitConfig(dir, flags, out) {
|
|
|
1176
1187
|
if (cred.ok) {
|
|
1177
1188
|
const adapter =
|
|
1178
1189
|
flags.adapter ||
|
|
1179
|
-
makeApiAdapter({ orgUrl: merged.azure.orgUrl, project: merged.azure.project, token: cred.token, fetch: flags.fetch })
|
|
1190
|
+
makeApiAdapter({ orgUrl: merged.azure.orgUrl, project: merged.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: merged.azure.bodyFieldByType })
|
|
1180
1191
|
let names = null
|
|
1181
1192
|
try {
|
|
1182
1193
|
names = (await unionStates(adapter, merged)).map((st) => st.name)
|
|
@@ -1244,6 +1255,8 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1244
1255
|
checks.push(row('tracker', 'Azure config', 'broken', 'orgUrl or project is empty', `fix ${CONFIG_FILE}`))
|
|
1245
1256
|
} else {
|
|
1246
1257
|
checks.push(row('tracker', 'Azure config', 'ok', `${loaded.config.azure.project} @ ${loaded.config.azure.orgUrl}`))
|
|
1258
|
+
const retired = kit.retiredKeysRow(path.join(dir, CONFIG_FILE), CONFIG_FILE, row)
|
|
1259
|
+
if (retired) checks.push(retired)
|
|
1247
1260
|
// A worktree forks from a COMMIT, so a config that exists only in the
|
|
1248
1261
|
// working tree is invisible in every spec worktree — where the sync
|
|
1249
1262
|
// skills actually run — and sync there reports itself off with no clue
|
|
@@ -1289,7 +1302,7 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1289
1302
|
if (flags.remoteCheck && cred.ok) {
|
|
1290
1303
|
const adapter =
|
|
1291
1304
|
flags.adapter ||
|
|
1292
|
-
makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch })
|
|
1305
|
+
makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: config.azure.bodyFieldByType })
|
|
1293
1306
|
try {
|
|
1294
1307
|
const viewer = await adapter.readViewer()
|
|
1295
1308
|
checks.push(row('remote', 'Azure reachable', 'ok', viewer ? `as ${viewer.name || viewer.id}` : 'yes'))
|
|
@@ -1308,6 +1321,41 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1308
1321
|
)
|
|
1309
1322
|
: row('states', 'State names', 'ok', 'every configured state exists'),
|
|
1310
1323
|
)
|
|
1324
|
+
// Every mapped type must exist, and carry the body field configured
|
|
1325
|
+
// for it — a missing type fails the first push, and a missing field
|
|
1326
|
+
// silently drops every Bug's body. NO ROW when nothing is mapped: a
|
|
1327
|
+
// line about an unconfigured surface accuses a healthy project.
|
|
1328
|
+
const mappedTypes = [
|
|
1329
|
+
...new Set([
|
|
1330
|
+
...Object.values(config.azure.workItemTypeByKind || {}),
|
|
1331
|
+
...Object.keys(config.azure.bodyFieldByType || {}),
|
|
1332
|
+
]),
|
|
1333
|
+
]
|
|
1334
|
+
if (mappedTypes.length) {
|
|
1335
|
+
const problems = []
|
|
1336
|
+
for (const type of mappedTypes) {
|
|
1337
|
+
const fields = await adapter.listTypeFields(type)
|
|
1338
|
+
if (fields == null) {
|
|
1339
|
+
problems.push(`type "${type}" is not in the project`)
|
|
1340
|
+
continue
|
|
1341
|
+
}
|
|
1342
|
+
const wanted = (config.azure.bodyFieldByType || {})[type]
|
|
1343
|
+
if (wanted && !fields.some((f) => f.toLowerCase() === wanted.toLowerCase())) {
|
|
1344
|
+
problems.push(`type "${type}" has no field ${wanted}`)
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
checks.push(
|
|
1348
|
+
problems.length
|
|
1349
|
+
? row(
|
|
1350
|
+
'types',
|
|
1351
|
+
'Mapped types',
|
|
1352
|
+
'broken',
|
|
1353
|
+
problems.join('; '),
|
|
1354
|
+
`create the type/field in the process, or fix ${CONFIG_FILE} -> azure.workItemTypeByKind / azure.bodyFieldByType`,
|
|
1355
|
+
)
|
|
1356
|
+
: row('types', 'Mapped types', 'ok', 'every mapped type exists and carries its body field'),
|
|
1357
|
+
)
|
|
1358
|
+
}
|
|
1311
1359
|
// The capability probe Decision 8 names: identity search is the op
|
|
1312
1360
|
// that fails first on a narrow token. A 401 here is a WARN, not
|
|
1313
1361
|
// broken — work item sync is whole without it; only `users` search
|
|
@@ -1356,11 +1404,10 @@ const USAGE = `Usage: skitterspec-azure-boards spec-sync <subcommand>
|
|
|
1356
1404
|
status <spec> [--remote <f>] read-only drift report
|
|
1357
1405
|
verify <spec> --stored <f> compare a read-back against the repo
|
|
1358
1406
|
states [--json] the configured types' state names
|
|
1359
|
-
list [--all | --state NAME]
|
|
1407
|
+
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] tracker listing
|
|
1360
1408
|
linked [--json] specs and their linked items (offline)
|
|
1361
1409
|
ref [<spec>] the Refs: trailer value for this branch
|
|
1362
1410
|
released [<range>] tickets a commit range contains
|
|
1363
|
-
release create|deployed|complete <tag> the release work item (CI; --apply)
|
|
1364
1411
|
preserve <spec> [--text <f>] keep an adopted item's original report
|
|
1365
1412
|
assign <spec> --to <id> | --release stamp who is building it
|
|
1366
1413
|
whoami [--set <id>] [--unset] who you are on Azure (cached)
|
|
@@ -1439,16 +1486,8 @@ async function specSync(rest, io = {}) {
|
|
|
1439
1486
|
return specSyncRef(dir, config, positional[0], flags, out, err)
|
|
1440
1487
|
case 'released':
|
|
1441
1488
|
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
|
-
}
|
|
1489
|
+
case 'release':
|
|
1490
|
+
return kit.refuseRemovedVerb(out, PROGRAM, 'release')
|
|
1452
1491
|
case 'preserve':
|
|
1453
1492
|
return specSyncPreserve(dir, config, positional[0], flags, out)
|
|
1454
1493
|
case 'assign':
|
|
@@ -1502,6 +1541,9 @@ function parseArgs(args, sub) {
|
|
|
1502
1541
|
'--to': { kind: 'string' },
|
|
1503
1542
|
'--name': { kind: 'string' },
|
|
1504
1543
|
'--release': { kind: 'boolean' },
|
|
1544
|
+
'--mine': { kind: 'boolean' },
|
|
1545
|
+
'--next': { kind: 'number' },
|
|
1546
|
+
'--by': { kind: 'string' },
|
|
1505
1547
|
'--set': { kind: 'string' },
|
|
1506
1548
|
'--unset': { kind: 'boolean' },
|
|
1507
1549
|
'--stdin': { kind: 'boolean' },
|
|
@@ -41,12 +41,26 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
41
41
|
workItemType: 'Issue',
|
|
42
42
|
childType: 'Task',
|
|
43
43
|
areaPath: '',
|
|
44
|
-
// The
|
|
45
|
-
//
|
|
46
|
-
//
|
|
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',
|
|
48
|
+
// The mint type per SPEC KIND (`feature`/`bug`/`hotfix`/`chore`, from the
|
|
49
|
+
// spec folder's prefix), falling back to `workItemType`. In Agile, Scrum
|
|
50
|
+
// and CMMI a bug is a work item TYPE, so `/spec-bug` minting a User Story
|
|
47
51
|
// files it in the wrong backlog; `{ "bug": "Bug", "hotfix": "Bug" }` is
|
|
48
|
-
// the usual shape there.
|
|
52
|
+
// the usual shape there. `chore` wants a custom inherited type (create
|
|
53
|
+
// `Chore` and its states in the process first); unmapped it falls back to
|
|
54
|
+
// `workItemType`. Empty means one type for everything, as before.
|
|
49
55
|
workItemTypeByKind: Object.freeze({}),
|
|
56
|
+
// The field a TYPE's body is written to and read from, keyed by work item
|
|
57
|
+
// type name — `{ "Bug": "Microsoft.VSTS.TCM.ReproSteps" }` is the shape
|
|
58
|
+
// Agile/Scrum/CMMI want, because their Bug form does not show
|
|
59
|
+
// System.Description at all. Unmapped types keep System.Description. The
|
|
60
|
+
// mapping is symmetric (create, update, read-back, edited-hash compare):
|
|
61
|
+
// a write-only mapping would make `/spec-status` report every Bug as
|
|
62
|
+
// edited. Empty means System.Description everywhere, as before.
|
|
63
|
+
bodyFieldByType: Object.freeze({}),
|
|
50
64
|
}),
|
|
51
65
|
// A spec is a WORK ITEM; each phase a CHILD work item under a hierarchy
|
|
52
66
|
// link. `tasks` selects how the phase's checkboxes reach that child's
|
|
@@ -95,18 +109,8 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
95
109
|
// accuses.
|
|
96
110
|
refs: Object.freeze({ foreignPatterns: Object.freeze([]) }),
|
|
97
111
|
release: Object.freeze({
|
|
98
|
-
stages: Object.freeze([]),
|
|
99
112
|
ignorePaths: Object.freeze(['specs/', 'CHANGELOG.md', 'RELEASES.md']),
|
|
100
113
|
}),
|
|
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
114
|
branch: Object.freeze({ pattern: '{type}/{slug}' }),
|
|
111
115
|
// An env-var NAME, not a value — the official CLI's, so a machine already
|
|
112
116
|
// set up for `az boards` needs nothing new.
|
|
@@ -145,6 +149,7 @@ function defaults() {
|
|
|
145
149
|
azure: { ...DEFAULT_CONFIG.azure },
|
|
146
150
|
mapping: { ...DEFAULT_CONFIG.mapping },
|
|
147
151
|
states: { ...DEFAULT_CONFIG.states },
|
|
152
|
+
stateAliases: {},
|
|
148
153
|
intake: {
|
|
149
154
|
tag: DEFAULT_CONFIG.intake.tag,
|
|
150
155
|
bugTags: [...DEFAULT_CONFIG.intake.bugTags],
|
|
@@ -156,15 +161,8 @@ function defaults() {
|
|
|
156
161
|
fields: { ...DEFAULT_CONFIG.fields },
|
|
157
162
|
refs: { foreignPatterns: [...DEFAULT_CONFIG.refs.foreignPatterns] },
|
|
158
163
|
release: {
|
|
159
|
-
stages: DEFAULT_CONFIG.release.stages.map((s) => ({ ...s })),
|
|
160
164
|
ignorePaths: [...DEFAULT_CONFIG.release.ignorePaths],
|
|
161
165
|
},
|
|
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
166
|
branch: { ...DEFAULT_CONFIG.branch },
|
|
169
167
|
auth: { ...DEFAULT_CONFIG.auth },
|
|
170
168
|
apply: { ...DEFAULT_CONFIG.apply },
|
|
@@ -179,7 +177,7 @@ function defaults() {
|
|
|
179
177
|
}
|
|
180
178
|
|
|
181
179
|
const { isObject, stringList, assign } = kitConfig
|
|
182
|
-
const { mergeFieldOwnership, mergePhaseMapping,
|
|
180
|
+
const { mergeStates, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
|
|
183
181
|
kitConfig.makeMergeHelpers({
|
|
184
182
|
configFile: CONFIG_FILE,
|
|
185
183
|
ownership: OWNERSHIP,
|
|
@@ -187,22 +185,6 @@ const { mergeFieldOwnership, mergePhaseMapping, mergeReleaseStages, mergeRelease
|
|
|
187
185
|
phaseMappings: PHASE_MAPPINGS,
|
|
188
186
|
})
|
|
189
187
|
|
|
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
188
|
/**
|
|
207
189
|
* Merge a parsed config over the defaults. Only known keys are copied (unknown
|
|
208
190
|
* keys ignored for forward-compat). Nested objects are merged field-by-field.
|
|
@@ -216,16 +198,27 @@ function mergeConfig(base, parsed) {
|
|
|
216
198
|
assign(base.azure, parsed.azure, 'workItemType', 'string')
|
|
217
199
|
assign(base.azure, parsed.azure, 'childType', 'string')
|
|
218
200
|
assign(base.azure, parsed.azure, 'areaPath', 'string?')
|
|
201
|
+
assign(base.azure, parsed.azure, 'backlogOrderField', 'string')
|
|
219
202
|
if (isObject(parsed.azure.workItemTypeByKind)) {
|
|
220
203
|
// Only the kinds a spec folder can actually be — an unknown key is
|
|
221
204
|
// dropped rather than carried into `states` validation it can never pass.
|
|
222
205
|
const byKind = {}
|
|
223
|
-
for (const kind of ['feature', 'bug', 'hotfix']) {
|
|
206
|
+
for (const kind of ['feature', 'bug', 'hotfix', 'chore']) {
|
|
224
207
|
const value = parsed.azure.workItemTypeByKind[kind]
|
|
225
208
|
if (typeof value === 'string' && value.trim()) byKind[kind] = value.trim()
|
|
226
209
|
}
|
|
227
210
|
base.azure.workItemTypeByKind = byKind
|
|
228
211
|
}
|
|
212
|
+
if (isObject(parsed.azure.bodyFieldByType)) {
|
|
213
|
+
// Keyed by TYPE name (open — any type a project invents), value a field
|
|
214
|
+
// reference name. Blank values are dropped rather than written as an
|
|
215
|
+
// empty field path.
|
|
216
|
+
const byType = {}
|
|
217
|
+
for (const [type, field] of Object.entries(parsed.azure.bodyFieldByType)) {
|
|
218
|
+
if (typeof field === 'string' && field.trim() && String(type).trim()) byType[String(type).trim()] = field.trim()
|
|
219
|
+
}
|
|
220
|
+
base.azure.bodyFieldByType = byType
|
|
221
|
+
}
|
|
229
222
|
// A trailing slash on the org would double up in every composed URL.
|
|
230
223
|
if (base.azure.orgUrl) base.azure.orgUrl = base.azure.orgUrl.replace(/\/+$/, '')
|
|
231
224
|
}
|
|
@@ -242,11 +235,7 @@ function mergeConfig(base, parsed) {
|
|
|
242
235
|
mergePhaseMapping(base.mapping, parsed.mapping)
|
|
243
236
|
}
|
|
244
237
|
|
|
245
|
-
|
|
246
|
-
for (const key of Object.keys(base.states)) {
|
|
247
|
-
assign(base.states, parsed.states, key, 'string')
|
|
248
|
-
}
|
|
249
|
-
}
|
|
238
|
+
mergeStates(base, parsed)
|
|
250
239
|
|
|
251
240
|
if (isObject(parsed.intake)) {
|
|
252
241
|
assign(base.intake, parsed.intake, 'tag', 'string?')
|
|
@@ -267,16 +256,9 @@ function mergeConfig(base, parsed) {
|
|
|
267
256
|
}
|
|
268
257
|
|
|
269
258
|
if (isObject(parsed.release)) {
|
|
270
|
-
mergeReleaseStages(base.release, parsed.release)
|
|
271
259
|
mergeReleaseIgnorePaths(base.release, parsed.release)
|
|
272
260
|
}
|
|
273
261
|
|
|
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
262
|
|
|
281
263
|
if (isObject(parsed.branch)) {
|
|
282
264
|
assign(base.branch, parsed.branch, 'pattern', 'string')
|
|
@@ -337,16 +319,32 @@ function withRuntime(config) {
|
|
|
337
319
|
},
|
|
338
320
|
description(item) {
|
|
339
321
|
const fields = item && item.fields
|
|
340
|
-
if (fields && typeof fields === 'object'
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
//
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
322
|
+
if (fields && typeof fields === 'object') {
|
|
323
|
+
// The body field hangs off the item's TYPE (azure.bodyFieldByType),
|
|
324
|
+
// same resolution as the adapter's writes — the hash compare must
|
|
325
|
+
// read the field the push wrote or every mapped Bug reads as edited.
|
|
326
|
+
const type = String(fields['System.WorkItemType'] || '').toLowerCase()
|
|
327
|
+
const mapped = Object.entries(config.azure.bodyFieldByType || {}).find(
|
|
328
|
+
([t]) => t.toLowerCase() === type,
|
|
329
|
+
)
|
|
330
|
+
let field = mapped ? mapped[1] : 'System.Description'
|
|
331
|
+
// An empty mapped field falls back to System.Description — an item
|
|
332
|
+
// minted before the mapping holds its body there (same rule as the
|
|
333
|
+
// adapter's read side).
|
|
334
|
+
if (mapped && (fields[field] == null || fields[field] === '') && fields['System.Description'] != null) {
|
|
335
|
+
field = 'System.Description'
|
|
336
|
+
}
|
|
337
|
+
if (field in fields) {
|
|
338
|
+
// null IS an answer on this branch: the field was fetched and the
|
|
339
|
+
// description is genuinely empty — clearing one is an edit, not a
|
|
340
|
+
// cannot-tell.
|
|
341
|
+
const d = fields[field]
|
|
342
|
+
if (d == null) return ''
|
|
343
|
+
const text = String(d)
|
|
344
|
+
const fmt = item.multilineFieldsFormat && item.multilineFieldsFormat[field]
|
|
345
|
+
if (fmt && String(fmt).toLowerCase() === 'markdown') return text
|
|
346
|
+
return looksLikeHtml(text) ? htmlToText(text) : text
|
|
347
|
+
}
|
|
350
348
|
}
|
|
351
349
|
return item && typeof item.description === 'string' ? item.description : undefined
|
|
352
350
|
},
|
|
@@ -376,18 +374,13 @@ function loadAzureConfig(dir = process.cwd()) {
|
|
|
376
374
|
return { config: withRuntime(mergeConfig(base, parsed)), present: true }
|
|
377
375
|
}
|
|
378
376
|
|
|
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
|
|
377
|
+
// The bookkeeping path prefixes `released` ignores.
|
|
383
378
|
const releaseIgnorePaths = (config) => (config.release && config.release.ignorePaths) || []
|
|
384
379
|
|
|
385
380
|
module.exports = {
|
|
386
381
|
loadAzureConfig,
|
|
387
382
|
mergeConfig,
|
|
388
383
|
defaults,
|
|
389
|
-
releaseStages,
|
|
390
|
-
stageFor,
|
|
391
384
|
releaseIgnorePaths,
|
|
392
385
|
DEFAULT_CONFIG,
|
|
393
386
|
CONFIG_FILE,
|
|
@@ -70,7 +70,18 @@ function discoverAzure(toolNames) {
|
|
|
70
70
|
* shapes the engine consumes. Ops the server cannot express are absent — the
|
|
71
71
|
* consumer feature-detects, exactly as with the API adapter's extras.
|
|
72
72
|
*/
|
|
73
|
-
function makeAdapter({ tools, call, orgUrl, project }) {
|
|
73
|
+
function makeAdapter({ tools, call, orgUrl, project, bodyFieldByType = {} }) {
|
|
74
|
+
// Same resolution as the REST adapter: the field a type's body lives in,
|
|
75
|
+
// System.Description unless azure.bodyFieldByType names one, matched
|
|
76
|
+
// case-insensitively. An MCP update cannot resolve the type (the generic
|
|
77
|
+
// update takes raw fields), so only the creates map here; the REST
|
|
78
|
+
// transport is the one that covers updates.
|
|
79
|
+
const bodyFields = Object.entries(bodyFieldByType || {}).map(([t, f]) => [String(t).toLowerCase(), f])
|
|
80
|
+
const bodyFieldFor = (workItemType) => {
|
|
81
|
+
const want = String(workItemType || '').toLowerCase()
|
|
82
|
+
const hit = bodyFields.find(([t]) => t === want)
|
|
83
|
+
return hit ? hit[1] : 'System.Description'
|
|
84
|
+
}
|
|
74
85
|
const org = String(orgUrl || '').replace(/\/+$/, '')
|
|
75
86
|
const urlOf = (id) => (org && project ? `${org}/${encodeURIComponent(project)}/_workitems/edit/${id}` : null)
|
|
76
87
|
const normalize = (raw) => {
|
|
@@ -96,7 +107,7 @@ function makeAdapter({ tools, call, orgUrl, project }) {
|
|
|
96
107
|
action: 'create',
|
|
97
108
|
project,
|
|
98
109
|
workItemType,
|
|
99
|
-
fields: { 'System.Title': title,
|
|
110
|
+
fields: { 'System.Title': title, [bodyFieldFor(workItemType)]: description },
|
|
100
111
|
format: 'markdown',
|
|
101
112
|
}),
|
|
102
113
|
)
|
|
@@ -107,7 +118,7 @@ function makeAdapter({ tools, call, orgUrl, project }) {
|
|
|
107
118
|
project,
|
|
108
119
|
parentId: Number(parentId),
|
|
109
120
|
workItemType: childType,
|
|
110
|
-
fields: { 'System.Title': title,
|
|
121
|
+
fields: { 'System.Title': title, [bodyFieldFor(childType)]: description },
|
|
111
122
|
format: 'markdown',
|
|
112
123
|
}),
|
|
113
124
|
)
|