@skitterbyte/skitterspec-azure-boards 3.1.3 → 3.2.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 +4 -0
- package/assets/core/azure-boards.config.md +2 -1
- package/assets/core/env.config.json.example +5 -0
- package/assets/core/env.config.md +20 -1
- package/assets/hooks/run-compact.cjs +162 -0
- package/assets/review/page.html +122 -2
- package/assets/rules/spec-format.md +6 -0
- package/assets/rules/spec-planning.md +9 -0
- package/assets/rules/spec-reports.md +5 -0
- package/assets/skills/spec/SKILL.md +25 -1
- package/assets/skills/spec-bug/SKILL.md +14 -0
- package/assets/skills/spec-complete/SKILL.md +9 -0
- package/assets/skills/spec-diff/SKILL.md +24 -0
- package/assets/skills/spec-hotfix/SKILL.md +14 -0
- package/assets/skills/spec-idea/SKILL.md +6 -0
- package/assets/skills/spec-next/SKILL.md +18 -1
- package/assets/skills/spec-next/autonomous.md +126 -0
- package/assets/skills/spec-reviewed/SKILL.md +2 -1
- package/assets/skills/spec-start/SKILL.md +8 -0
- package/assets/skills/spec-start/isolation.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +267 -2
- package/src/env/config.js +18 -0
- package/src/env/hooks.js +44 -20
- package/src/env/report.js +192 -0
- package/src/env/resolve.js +6 -1
- package/src/env/review.js +14 -2
- package/src/env/run.js +226 -0
- package/src/env/runpage.js +229 -0
- package/src/env/serve.js +47 -4
- package/src/ideacmd.js +5 -2
- package/src/vendor/azure-boards/api.js +13 -0
- package/src/vendor/azure-boards/cli-sync.js +109 -11
- package/src/vendor/azure-boards/config.js +47 -2
- package/src/vendor/provider-kit/src/apply.js +3 -0
- package/src/vendor/sync-core/src/compare.js +32 -1
- package/src/vendor/sync-core/src/normalize.js +3 -2
- package/src/vendor/sync-core/src/push.js +29 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The pages an autonomous run leaves behind (feat-autonomous-run, phase 3):
|
|
5
|
+
*
|
|
6
|
+
* - a SNAPSHOT per phase — that phase's review page, kept as it was when the
|
|
7
|
+
* run committed it (`reviews/<spec>/phase-<n>.html`), read-only;
|
|
8
|
+
* - the RUN INDEX — every snapshot as it lands, with its commit and report,
|
|
9
|
+
* served at `/<token>/<spec>/run` so the run can be read while it goes;
|
|
10
|
+
* - the AGGREGATE that heads the final page — every phase's Notes and
|
|
11
|
+
* Follow-ups, the stops and compactions, in one list.
|
|
12
|
+
*
|
|
13
|
+
* Everything here is built from records the engine already keeps (the run
|
|
14
|
+
* record, the report sidecar) and is escaped on the way out. Nothing reads a
|
|
15
|
+
* diff, and nothing here decides anything.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs')
|
|
19
|
+
const path = require('node:path')
|
|
20
|
+
|
|
21
|
+
const { readReport, reportHtmlFor, CARRIED } = require('./report.js')
|
|
22
|
+
const { readRun, compactionSummary } = require('./run.js')
|
|
23
|
+
|
|
24
|
+
function escapeHtml(s) {
|
|
25
|
+
return String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function inline(text) {
|
|
29
|
+
return escapeHtml(text)
|
|
30
|
+
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
|
31
|
+
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Where a phase's snapshot lives, beside the spec's page. */
|
|
35
|
+
function snapshotPath(outPath, phase) {
|
|
36
|
+
return path.join(outPath.replace(/\.html$/, ''), `phase-${phase}.html`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The state dir is the reviews dir's parent; the run record sits beside it.
|
|
40
|
+
function stateDirOf(outPath) {
|
|
41
|
+
return path.dirname(path.dirname(outPath))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Which phases have a snapshot on disk, ascending. Never throws. */
|
|
45
|
+
function snapshotPhases(outPath) {
|
|
46
|
+
let names
|
|
47
|
+
try {
|
|
48
|
+
names = fs.readdirSync(outPath.replace(/\.html$/, ''))
|
|
49
|
+
} catch {
|
|
50
|
+
return []
|
|
51
|
+
}
|
|
52
|
+
return names
|
|
53
|
+
.map((n) => /^phase-(\d+)\.html$/.exec(n))
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.map((m) => Number(m[1]))
|
|
56
|
+
.sort((a, b) => a - b)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// A value that says nothing — `none`, `—` — is not an item to carry forward.
|
|
60
|
+
const EMPTY = /^(none|—|-|n\/a)\.?$/i
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Every phase's carried rows, in phase order: `[{ phase, field, value, more }]`.
|
|
64
|
+
* Pure.
|
|
65
|
+
*/
|
|
66
|
+
function carriedItems(report) {
|
|
67
|
+
const phases = Object.values((report && report.phases) || {})
|
|
68
|
+
.filter((e) => e && Array.isArray(e.rows))
|
|
69
|
+
.sort((a, b) => (Number(a.phase) || 0) - (Number(b.phase) || 0))
|
|
70
|
+
const out = []
|
|
71
|
+
for (const e of phases) {
|
|
72
|
+
for (const r of e.rows) {
|
|
73
|
+
if (!CARRIED.includes(r.field) || EMPTY.test(String(r.value).trim())) continue
|
|
74
|
+
out.push({ phase: e.phase, field: r.field, value: r.value, more: r.more || [] })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The block that heads the final page. Empty string when the run left nothing
|
|
82
|
+
* to say AND there is no run — so a final page for a spec with no record reads
|
|
83
|
+
* as an ordinary page rather than an empty box.
|
|
84
|
+
*/
|
|
85
|
+
function renderAggregate({ report, run, spec, snapshots = [] }) {
|
|
86
|
+
const items = carriedItems(report)
|
|
87
|
+
const stops = (run && run.stops) || []
|
|
88
|
+
const compacted = compactionSummary(run)
|
|
89
|
+
if (!items.length && !stops.length && !compacted && !snapshots.length && !run) return ''
|
|
90
|
+
const parts = ['<section class="report run-aggregate">', '<h2 class="report-heading">The whole run</h2>']
|
|
91
|
+
const followUps = items.filter((i) => i.field === 'Follow-ups')
|
|
92
|
+
const notes = items.filter((i) => i.field === 'Notes')
|
|
93
|
+
const list = (title, rows) => {
|
|
94
|
+
if (!rows.length) return
|
|
95
|
+
parts.push(`<p class="report-title"><strong>${title}</strong></p>`, '<ul class="run-items">')
|
|
96
|
+
for (const i of rows) {
|
|
97
|
+
const more = i.more.map((m) => `<br>${inline(m)}`).join('')
|
|
98
|
+
parts.push(`<li><span class="run-phase">phase ${escapeHtml(i.phase)}</span> ${inline(i.value)}${more}</li>`)
|
|
99
|
+
}
|
|
100
|
+
parts.push('</ul>')
|
|
101
|
+
}
|
|
102
|
+
list('Follow-ups, bugs and suggestions', followUps)
|
|
103
|
+
list('Notes', notes)
|
|
104
|
+
if (!followUps.length && !notes.length) parts.push('<p class="report-title">No phase recorded a follow-up or a note.</p>')
|
|
105
|
+
if (stops.length) {
|
|
106
|
+
parts.push('<p class="report-title"><strong>Stops</strong></p>', '<ul class="run-items">')
|
|
107
|
+
for (const s of stops) parts.push(`<li><span class="run-phase">phase ${escapeHtml(s.phase)}</span> ${inline(s.reason)}</li>`)
|
|
108
|
+
parts.push('</ul>')
|
|
109
|
+
}
|
|
110
|
+
if (compacted) parts.push(`<p class="report-title">Context ${escapeHtml(compacted)}.</p>`)
|
|
111
|
+
if (snapshots.length) {
|
|
112
|
+
const links = snapshots.map((n) => `<a href="${encodeURIComponent(spec)}/phase-${n}">phase ${n}</a>`).join(' · ')
|
|
113
|
+
parts.push(`<p class="report-title">Each phase as reviewed: ${links} · <a href="${encodeURIComponent(spec)}/run">run index</a></p>`)
|
|
114
|
+
}
|
|
115
|
+
parts.push('</section>')
|
|
116
|
+
return parts.join('\n')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The aggregate for a spec, read from its records. '' on any cannot-tell. */
|
|
120
|
+
function aggregateHtmlFor(outPath, spec) {
|
|
121
|
+
const read = readReport(outPath, spec)
|
|
122
|
+
const run = readRun(stateDirOf(outPath), spec)
|
|
123
|
+
return renderAggregate({
|
|
124
|
+
report: read.corrupt ? null : read.report,
|
|
125
|
+
run: run.corrupt ? null : run.record,
|
|
126
|
+
spec,
|
|
127
|
+
snapshots: snapshotPhases(outPath),
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The run index page — a doorway, styled like the server's index. Pure.
|
|
133
|
+
* `phases` is the union of what the run record and the disk know, so a
|
|
134
|
+
* snapshot written before its `run phase` call still shows.
|
|
135
|
+
*/
|
|
136
|
+
function renderRunIndex({ spec, run = null, report = null, snapshots = [], token = null, project = null }) {
|
|
137
|
+
const prefix = token ? `/${token}` : ''
|
|
138
|
+
const base = `${prefix}/${encodeURIComponent(spec)}`
|
|
139
|
+
const byPhase = new Map()
|
|
140
|
+
for (const p of (run && run.phases) || []) byPhase.set(p.n, { ...p })
|
|
141
|
+
for (const n of snapshots) byPhase.set(n, { n, ...(byPhase.get(n) || {}), snapshot: true })
|
|
142
|
+
const reports = (report && report.phases) || {}
|
|
143
|
+
const rows = [...byPhase.values()]
|
|
144
|
+
.sort((a, b) => a.n - b.n)
|
|
145
|
+
.map((p) => {
|
|
146
|
+
const r = reports[String(p.n)]
|
|
147
|
+
const built = r && r.rows ? r.rows.find((x) => x.field === 'Built') : null
|
|
148
|
+
const link = p.snapshot ? `<a href="${base}/phase-${p.n}">phase ${p.n}</a>` : `phase ${p.n}`
|
|
149
|
+
return (
|
|
150
|
+
`<li>${link}` +
|
|
151
|
+
(p.commit ? `<span class="b">${escapeHtml(String(p.commit).slice(0, 8))}</span>` : '') +
|
|
152
|
+
(built ? `<span class="t">${inline(built.value)}</span>` : '') +
|
|
153
|
+
'</li>'
|
|
154
|
+
)
|
|
155
|
+
})
|
|
156
|
+
const state = run ? (run.active ? `running · ends on <strong>${escapeHtml(run.then)}</strong>` : `ended · ${escapeHtml(run.outcome || run.then)}`) : 'no run recorded'
|
|
157
|
+
const compacted = compactionSummary(run)
|
|
158
|
+
const heading = `${project ? `${escapeHtml(project)} · ` : ''}${escapeHtml(spec)} · run`
|
|
159
|
+
const body = rows.length ? `<ul>\n${rows.join('\n')}\n</ul>` : '<p class="empty">No phase has been committed by this run yet.</p>'
|
|
160
|
+
return `<!doctype html>
|
|
161
|
+
<html lang="en">
|
|
162
|
+
<head>
|
|
163
|
+
<meta charset="utf-8">
|
|
164
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
165
|
+
<title>${heading}</title>
|
|
166
|
+
<style>
|
|
167
|
+
:root { --bg:#fff; --fg:#1a1a1a; --dim:#6b6b6b; --line:#e3e3e3; --link:#0b5fbd }
|
|
168
|
+
@media (prefers-color-scheme: dark) {
|
|
169
|
+
:root:not([data-theme="light"]) { --bg:#16181c; --fg:#e6e6e6; --dim:#9a9a9a; --line:#2c2f36; --link:#7cb7ff }
|
|
170
|
+
}
|
|
171
|
+
* { box-sizing:border-box }
|
|
172
|
+
body { margin:0; padding:2rem 1rem; background:var(--bg); color:var(--fg);
|
|
173
|
+
font:15px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif }
|
|
174
|
+
main { max-width:52rem; margin:0 auto }
|
|
175
|
+
h1 { font-size:1.1rem; margin:0 0 .25rem; font-weight:600 }
|
|
176
|
+
.state { color:var(--dim); margin:0 0 1.25rem }
|
|
177
|
+
ul { list-style:none; margin:0; padding:0 }
|
|
178
|
+
li { display:flex; flex-wrap:wrap; gap:.75rem; align-items:baseline; padding:.7rem 0; border-top:1px solid var(--line) }
|
|
179
|
+
a { color:var(--link); text-decoration:none; font-weight:600 }
|
|
180
|
+
a:hover { text-decoration:underline }
|
|
181
|
+
.b { color:var(--dim); font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.85em }
|
|
182
|
+
.t { flex-basis:100%; color:var(--fg); font-size:.9em; overflow-wrap:anywhere }
|
|
183
|
+
.empty { color:var(--dim) }
|
|
184
|
+
code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace }
|
|
185
|
+
</style>
|
|
186
|
+
</head>
|
|
187
|
+
<body>
|
|
188
|
+
<main>
|
|
189
|
+
<h1>${heading}</h1>
|
|
190
|
+
<p class="state">${state}${compacted ? ` · ${escapeHtml(compacted)}` : ''} · <a href="${base}">current page</a></p>
|
|
191
|
+
${body}
|
|
192
|
+
</main>
|
|
193
|
+
</body>
|
|
194
|
+
</html>
|
|
195
|
+
`
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** The run index for a spec, read from its records. */
|
|
199
|
+
function runIndexFor(outPath, spec, { token = null, project = null } = {}) {
|
|
200
|
+
const read = readReport(outPath, spec)
|
|
201
|
+
const run = readRun(stateDirOf(outPath), spec)
|
|
202
|
+
return renderRunIndex({
|
|
203
|
+
spec,
|
|
204
|
+
run: run.corrupt ? null : run.record,
|
|
205
|
+
report: read.corrupt ? null : read.report,
|
|
206
|
+
snapshots: snapshotPhases(outPath),
|
|
207
|
+
token,
|
|
208
|
+
project,
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* What heads a page, by its button set: the final page carries the whole run;
|
|
214
|
+
* every other page its latest phase report. '' when there is nothing to show.
|
|
215
|
+
*/
|
|
216
|
+
function pageHeadFor(outPath, spec, buttons) {
|
|
217
|
+
return buttons === 'final' ? aggregateHtmlFor(outPath, spec) : reportHtmlFor(outPath, spec)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = {
|
|
221
|
+
pageHeadFor,
|
|
222
|
+
snapshotPath,
|
|
223
|
+
snapshotPhases,
|
|
224
|
+
carriedItems,
|
|
225
|
+
renderAggregate,
|
|
226
|
+
aggregateHtmlFor,
|
|
227
|
+
renderRunIndex,
|
|
228
|
+
runIndexFor,
|
|
229
|
+
}
|
package/src/env/serve.js
CHANGED
|
@@ -30,6 +30,7 @@ const fs = require('node:fs')
|
|
|
30
30
|
const path = require('node:path')
|
|
31
31
|
const crypto = require('node:crypto')
|
|
32
32
|
|
|
33
|
+
const { pageHeadFor, runIndexFor, snapshotPath } = require('./runpage.js')
|
|
33
34
|
const {
|
|
34
35
|
liveWorktreePaths,
|
|
35
36
|
allSpecs,
|
|
@@ -96,6 +97,15 @@ function routeFor(url, { token = null } = {}) {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
if (segments.length === 0) return { kind: 'index' }
|
|
100
|
+
// AN AUTONOMOUS RUN'S PAGES (feat-autonomous-run): `<spec>/run` is the run
|
|
101
|
+
// index, `<spec>/phase-<n>` a kept phase page. Both are reads; anything else
|
|
102
|
+
// two segments deep is not a page.
|
|
103
|
+
if (segments.length === 2) {
|
|
104
|
+
if (segments[1] === 'run') return { kind: 'run', spec: segments[0] }
|
|
105
|
+
const m = /^phase-(\d+)$/.exec(segments[1])
|
|
106
|
+
if (m) return { kind: 'snapshot', spec: segments[0], phase: Number(m[1]) }
|
|
107
|
+
return { kind: 'notfound' }
|
|
108
|
+
}
|
|
99
109
|
if (segments.length > 1) return { kind: 'notfound' }
|
|
100
110
|
// The ta-da page: a window, not a spec. Its query is the window and passed
|
|
101
111
|
// through whole, to be read — and refused if unreadable — by `tada/serve.js`.
|
|
@@ -518,7 +528,9 @@ function receivePass(dir, config, spec, blob) {
|
|
|
518
528
|
* so every `/no-spec` page served over http offered to put nothing in flight,
|
|
519
529
|
* and the pass came back naming a verdict its own skill could not act on.
|
|
520
530
|
*/
|
|
521
|
-
|
|
531
|
+
// `final` too: the run's last render declared it, and a served re-render
|
|
532
|
+
// must keep offering the ending rather than fall back to `Commit`.
|
|
533
|
+
const NARROWING_SETS = ['midrun', 'refresh', 'fix', 'final']
|
|
522
534
|
|
|
523
535
|
function buttonsForView(viewKind, spec, recorded) {
|
|
524
536
|
if (NARROWING_SETS.includes(recorded)) return recorded
|
|
@@ -573,7 +585,7 @@ function renderSpecPage(dir, config, spec, { branch = false } = {}) {
|
|
|
573
585
|
treePath: view.tree,
|
|
574
586
|
})
|
|
575
587
|
return {
|
|
576
|
-
html: renderReviewPage(data, { reviewHtml: renderReviewBlock(data.review) }),
|
|
588
|
+
html: renderReviewPage(data, { reviewHtml: pageHeadFor(out, spec.folder, buttons) + renderReviewBlock(data.review) }),
|
|
577
589
|
totals: data.totals,
|
|
578
590
|
mode: data.mode,
|
|
579
591
|
fellBack: false,
|
|
@@ -680,7 +692,7 @@ function renderSpecPage(dir, config, spec, { branch = false } = {}) {
|
|
|
680
692
|
}
|
|
681
693
|
|
|
682
694
|
return {
|
|
683
|
-
html: renderReviewPage(data, { reviewHtml: renderReviewBlock(data.review) }),
|
|
695
|
+
html: renderReviewPage(data, { reviewHtml: pageHeadFor(reviewOutPath(dir, spec.folder, null), spec.folder, buttons) + renderReviewBlock(data.review) }),
|
|
684
696
|
totals: data.totals,
|
|
685
697
|
mode: data.mode,
|
|
686
698
|
fellBack,
|
|
@@ -815,7 +827,7 @@ function readBody(req, limit = MAX_PASS_BYTES) {
|
|
|
815
827
|
})
|
|
816
828
|
}
|
|
817
829
|
|
|
818
|
-
function createReviewServer({ resolveEntries, resolveEpics = () => [], render, receive = null, passState = null, tada = null, token = null, project = null }) {
|
|
830
|
+
function createReviewServer({ resolveEntries, resolveEpics = () => [], render, receive = null, passState = null, tada = null, runPage = null, snapshot = null, token = null, project = null }) {
|
|
819
831
|
return http.createServer((req, res) => {
|
|
820
832
|
const send = (code, body, type = 'text/html; charset=utf-8') => {
|
|
821
833
|
res.writeHead(code, { 'content-type': type, 'cache-control': 'no-store' })
|
|
@@ -882,6 +894,19 @@ function createReviewServer({ resolveEntries, resolveEpics = () => [], render, r
|
|
|
882
894
|
return
|
|
883
895
|
}
|
|
884
896
|
|
|
897
|
+
// A SERVER BUILT WITHOUT THE HOOKS is an older one, and says not found —
|
|
898
|
+
// the same answer an unknown path gets.
|
|
899
|
+
if (route.kind === 'run' || route.kind === 'snapshot') {
|
|
900
|
+
const hook = route.kind === 'run' ? runPage : snapshot
|
|
901
|
+
if (!hook) return send(404, 'not found', 'text/plain; charset=utf-8')
|
|
902
|
+
try {
|
|
903
|
+
const out = route.kind === 'run' ? hook(route.spec, { token }) : hook(route.spec, route.phase)
|
|
904
|
+
return out && out.html ? send(200, out.html) : send(404, 'not found', 'text/plain; charset=utf-8')
|
|
905
|
+
} catch (err) {
|
|
906
|
+
return send(500, `render failed: ${err.message}`, 'text/plain; charset=utf-8')
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
885
910
|
try {
|
|
886
911
|
if (route.kind === 'index') return send(200, renderIndex(resolveEntries(), { token, epics: resolveEpics(), project }))
|
|
887
912
|
const out = render(route.spec, { branch: route.branch })
|
|
@@ -1105,6 +1130,24 @@ function serverHooks(dir, config) {
|
|
|
1105
1130
|
return renderSpecPage(dir, config, resolveOne(folder), opts)
|
|
1106
1131
|
},
|
|
1107
1132
|
receive: (folder, blob) => receivePass(dir, config, resolveOne(folder), blob),
|
|
1133
|
+
// The run index, built per request from the run record and the report
|
|
1134
|
+
// sidecar; a spec this daemon cannot resolve is a 404, not an empty run.
|
|
1135
|
+
runPage: (folder, { token: t = null } = {}) => {
|
|
1136
|
+
const one = resolveOne(folder)
|
|
1137
|
+
if (!one) return null
|
|
1138
|
+
return { html: runIndexFor(reviewOutPath(dir, one.folder, null), one.folder, { token: t, project: projectName(config) }) }
|
|
1139
|
+
},
|
|
1140
|
+
// A kept phase page is served as written — it is a record of what that
|
|
1141
|
+
// phase looked like, so re-rendering it from today's tree would defeat it.
|
|
1142
|
+
snapshot: (folder, phase) => {
|
|
1143
|
+
const one = resolveOne(folder)
|
|
1144
|
+
if (!one) return null
|
|
1145
|
+
try {
|
|
1146
|
+
return { html: fs.readFileSync(snapshotPath(reviewOutPath(dir, one.folder, null), phase), 'utf8') }
|
|
1147
|
+
} catch {
|
|
1148
|
+
return null
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1108
1151
|
// A spec this daemon cannot resolve is not a pass that was claimed — it is
|
|
1109
1152
|
// a lookup that could not see, so it says nothing rather than reporting the
|
|
1110
1153
|
// comfortable answer. Same rule the engine's own three states follow.
|
package/src/ideacmd.js
CHANGED
|
@@ -26,7 +26,7 @@ const { describeBaseBranch, baseRemote } = require('./env/resolve.js')
|
|
|
26
26
|
const { primaryAnchor } = require('./env/project.js')
|
|
27
27
|
|
|
28
28
|
const USAGE =
|
|
29
|
-
'Usage: skitterspec idea add <text> | list [--count] | drop <id> [--reason <why>] [--json] [--dir <path>]\n'
|
|
29
|
+
'Usage: skitterspec idea add <text> [--product <key>] | list [--count] | drop <id> [--reason <why>] [--json] [--dir <path>]\n'
|
|
30
30
|
|
|
31
31
|
function reader(cwd) {
|
|
32
32
|
return (argv) => {
|
|
@@ -56,7 +56,7 @@ function git(cwd, argv, { input, env } = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function parseArgs(argv) {
|
|
59
|
-
const flags = { json: false, count: false, dir: null, reason: null }
|
|
59
|
+
const flags = { json: false, count: false, dir: null, reason: null, product: null }
|
|
60
60
|
const positional = []
|
|
61
61
|
for (let i = 0; i < argv.length; i++) {
|
|
62
62
|
const a = argv[i]
|
|
@@ -64,6 +64,7 @@ function parseArgs(argv) {
|
|
|
64
64
|
else if (a === '--count') flags.count = true
|
|
65
65
|
else if (a === '--dir') flags.dir = argv[++i]
|
|
66
66
|
else if (a === '--reason') flags.reason = argv[++i]
|
|
67
|
+
else if (a === '--product') flags.product = argv[++i]
|
|
67
68
|
else positional.push(a)
|
|
68
69
|
}
|
|
69
70
|
return { flags, positional }
|
|
@@ -208,6 +209,8 @@ async function fileStore(sub, positional, flags, { cwd, now, out }) {
|
|
|
208
209
|
`idea: ${verb} "${plan.id}" ${sub === 'add' ? 'to' : 'from'} ${ctx.rel} on ${ctx.base} (${commit.slice(0, 7)})`,
|
|
209
210
|
` title: ${plan.entry.title}`,
|
|
210
211
|
` pushed: no — ${push} publishes it`,
|
|
212
|
+
// The file has no products; say so rather than drop the flag in silence.
|
|
213
|
+
...(sub === 'add' && flags.product ? [` product: ${flags.product} not recorded — specs/ideas.md has no products`] : []),
|
|
211
214
|
],
|
|
212
215
|
)
|
|
213
216
|
return 0
|
|
@@ -517,6 +517,19 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
|
|
|
517
517
|
return ((raw && raw.value) || []).map((f) => f.referenceName).filter(Boolean)
|
|
518
518
|
},
|
|
519
519
|
|
|
520
|
+
// Does this area path exist in the project? `true`/`false`, from the
|
|
521
|
+
// Areas classification tree. The first segment is the project's own root
|
|
522
|
+
// area, so it is dropped and the rest walks down from there.
|
|
523
|
+
async areaExists(areaPath) {
|
|
524
|
+
const parts = String(areaPath || '').split('\\').map((p) => p.trim()).filter(Boolean)
|
|
525
|
+
if (!parts.length) return false
|
|
526
|
+
const rest = parts.slice(1).map((p) => encodeURIComponent(p)).join('/')
|
|
527
|
+
const raw = await request('GET', `${projectBase}/wit/classificationnodes/Areas${rest ? '/' + rest : ''}`, {
|
|
528
|
+
allow404: true,
|
|
529
|
+
})
|
|
530
|
+
return raw != null
|
|
531
|
+
},
|
|
532
|
+
|
|
520
533
|
// The authenticated user, from connectionData — the one identity read
|
|
521
534
|
// that needs no scope beyond the PAT being valid (phase 1 spike).
|
|
522
535
|
// A PREVIEW resource: plain 7.1 is refused ("the -preview flag must be
|
|
@@ -66,6 +66,7 @@ const {
|
|
|
66
66
|
specKindOf,
|
|
67
67
|
mintTypeFor,
|
|
68
68
|
stateNameFor,
|
|
69
|
+
productArea,
|
|
69
70
|
} = require('./config.js')
|
|
70
71
|
const {
|
|
71
72
|
resolveCredential,
|
|
@@ -349,7 +350,7 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
349
350
|
description: issue && issue.description != null ? issue.description : undefined,
|
|
350
351
|
assigneeId: issue && issue.assignee ? issue.assignee : undefined,
|
|
351
352
|
workItemType: mintType,
|
|
352
|
-
areaPath: config.azure.areaPath || undefined,
|
|
353
|
+
areaPath: (issue && issue.placement) || config.azure.areaPath || undefined,
|
|
353
354
|
severity: severity != null ? severity : undefined,
|
|
354
355
|
},
|
|
355
356
|
(input) => skippingRefusedSeverity(input, (i) => adapter.createIssue(i)),
|
|
@@ -365,6 +366,7 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
365
366
|
// forwarded whenever the plan carries it, never truthiness-tested.
|
|
366
367
|
if ('assignee' in issue) updates.assigneeId = issue.assignee ?? null
|
|
367
368
|
if (severity != null) updates.severity = severity
|
|
369
|
+
if (issue.placement) updates.areaPath = issue.placement
|
|
368
370
|
if (Object.keys(updates).length) {
|
|
369
371
|
await skippingRefusedAssignee(updates, (input) =>
|
|
370
372
|
skippingRefusedSeverity(input, (i) => adapter.updateIssue(apiId(existing.identifier), i)),
|
|
@@ -378,7 +380,7 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
378
380
|
title: sub.name,
|
|
379
381
|
description: sub.goal != null ? sub.goal : undefined,
|
|
380
382
|
childType: config.azure.childType,
|
|
381
|
-
areaPath: config.azure.areaPath || undefined,
|
|
383
|
+
areaPath: sub.placement || config.azure.areaPath || undefined,
|
|
382
384
|
})
|
|
383
385
|
await settle(created.id, sub.state, config.azure.childType)
|
|
384
386
|
return created
|
|
@@ -387,15 +389,38 @@ function applyOps({ adapter, config, out, kind = 'feature', snapshotDir = null }
|
|
|
387
389
|
const updates = {}
|
|
388
390
|
if (sub.name != null) updates.title = sub.name
|
|
389
391
|
if (sub.goal != null) updates.description = sub.goal
|
|
392
|
+
if (sub.placement) updates.areaPath = sub.placement
|
|
390
393
|
if (Object.keys(updates).length) await adapter.updateIssue(apiId(sub.id), updates)
|
|
391
394
|
await settle(sub.id, sub.state, config.azure.childType, sub.stateResend)
|
|
392
395
|
},
|
|
393
396
|
}
|
|
394
397
|
}
|
|
395
398
|
|
|
399
|
+
// `products` — what a spec's `> **Product:**` may name, read by /spec to know
|
|
400
|
+
// whether to ask, and the area each files into. `default` is where a spec
|
|
401
|
+
// without the header goes once any product is set (null: nothing is placed).
|
|
402
|
+
function specSyncProducts(config, flags, out) {
|
|
403
|
+
const products = Object.entries(config.azure.products || {}).map(([key, p]) => ({ key, areaPath: p.areaPath }))
|
|
404
|
+
const fallback = products.length ? config.azure.areaPath || null : null
|
|
405
|
+
if (flags.json) {
|
|
406
|
+
out.write(JSON.stringify({ products, default: fallback }, null, 2) + '\n')
|
|
407
|
+
return 0
|
|
408
|
+
}
|
|
409
|
+
if (!products.length) {
|
|
410
|
+
out.write(`${PROGRAM} products: none — azure.products is not set, so specs are filed as before\n`)
|
|
411
|
+
return 0
|
|
412
|
+
}
|
|
413
|
+
const lines = [`${PROGRAM} products:`]
|
|
414
|
+
for (const p of products) lines.push(` ${p.key.padEnd(16)} ${p.areaPath}`)
|
|
415
|
+
lines.push(` ${'(no header)'.padEnd(16)} ${fallback || 'the project default area'}`)
|
|
416
|
+
out.write(lines.join('\n') + '\n')
|
|
417
|
+
return 0
|
|
418
|
+
}
|
|
419
|
+
|
|
396
420
|
// `idea add|list|drop` — the store `skitterspec idea` hands Azure Boards: a
|
|
397
421
|
// work item of `azure.workItemType` tagged `intake.ideaTag`, created with NO
|
|
398
|
-
// area path, so it lands at the project root and out of the spec area
|
|
422
|
+
// area path, so it lands at the project root and out of the spec area —
|
|
423
|
+
// unless `--product` names one, which files it in that product's area. `/spec
|
|
399
424
|
// <id>` adopts one like any other item, which is why an adopted one drops out
|
|
400
425
|
// of `list`.
|
|
401
426
|
//
|
|
@@ -419,6 +444,17 @@ async function specSyncIdea(dir, config, positional, flags, out) {
|
|
|
419
444
|
return verb ? 1 : 0
|
|
420
445
|
}
|
|
421
446
|
if (!tag) return refuse('intake.ideaTag is empty — an idea is a work item carrying that tag, so set one')
|
|
447
|
+
// A product files the idea in its area, so each product's stakeholders see
|
|
448
|
+
// their own ideas. Resolved before any call: an unknown product refuses with
|
|
449
|
+
// the text handed back, rather than filing it at the root.
|
|
450
|
+
let area
|
|
451
|
+
if (verb === 'add' && flags.product) {
|
|
452
|
+
try {
|
|
453
|
+
area = productArea(config, flags.product)
|
|
454
|
+
} catch (error) {
|
|
455
|
+
return refuse(`${error.message}; nothing was written`, { text })
|
|
456
|
+
}
|
|
457
|
+
}
|
|
422
458
|
|
|
423
459
|
const cred = apiAdapterFor(config, flags)
|
|
424
460
|
if (kit.resolveTransport(flags, config, cred.ok) === 'mcp' || !cred.ok) {
|
|
@@ -450,9 +486,9 @@ async function specSyncIdea(dir, config, positional, flags, out) {
|
|
|
450
486
|
if (at === -1) return refuse('nothing to capture — give the idea some text')
|
|
451
487
|
const title = lines[at].trim()
|
|
452
488
|
const description = lines.slice(at + 1).join('\n').trim()
|
|
453
|
-
const made = await az.createIssue({ title, description, workItemType: type, tags: [tag] })
|
|
454
|
-
say({ ok: true, store: 'azure-boards', action: 'add', identifier: made.identifier, url: made.url, title }, [
|
|
455
|
-
`${PROGRAM} idea: filed ${made.identifier} "${title}" (${type}, tagged "${tag}", no area path)`,
|
|
489
|
+
const made = await az.createIssue({ title, description, workItemType: type, tags: [tag], ...(area ? { areaPath: area } : {}) })
|
|
490
|
+
say({ ok: true, store: 'azure-boards', action: 'add', identifier: made.identifier, url: made.url, title, areaPath: area || null }, [
|
|
491
|
+
`${PROGRAM} idea: filed ${made.identifier} "${title}" (${type}, tagged "${tag}", ${area ? `in ${area}` : 'no area path'})`,
|
|
456
492
|
` url: ${made.url}`,
|
|
457
493
|
` promote: /spec ${made.identifier}`,
|
|
458
494
|
])
|
|
@@ -686,6 +722,17 @@ function specSyncNormalize(dir, config, specArg, out, err) {
|
|
|
686
722
|
return 0
|
|
687
723
|
}
|
|
688
724
|
|
|
725
|
+
// `push`, with a spec whose product the config cannot place returned as a
|
|
726
|
+
// refusal rather than thrown: it names a fix for the reader, not a crash.
|
|
727
|
+
function planOrRefusal(args) {
|
|
728
|
+
try {
|
|
729
|
+
return push(args)
|
|
730
|
+
} catch (error) {
|
|
731
|
+
if (error && error.placementRefused) return { refused: error.message }
|
|
732
|
+
throw error
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
689
736
|
function specSyncPlan(dir, config, specArg, flags, out, err) {
|
|
690
737
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
691
738
|
if (!snapshotDir) return 1
|
|
@@ -696,7 +743,11 @@ function specSyncPlan(dir, config, specArg, flags, out, err) {
|
|
|
696
743
|
}
|
|
697
744
|
warnToErr(snapshotDir, config, err)
|
|
698
745
|
const identifier = specIdentifier(snapshotDir, config)
|
|
699
|
-
const r =
|
|
746
|
+
const r = planOrRefusal({ dir, snapshotDir, identifier, config })
|
|
747
|
+
if (r.refused) {
|
|
748
|
+
out.write(`${PROGRAM} plan: refusing — ${r.refused}\n`)
|
|
749
|
+
return 1
|
|
750
|
+
}
|
|
700
751
|
if (flags.json || !out.isTTY) {
|
|
701
752
|
out.write(JSON.stringify(r.plan, null, 2) + '\n')
|
|
702
753
|
return 0
|
|
@@ -817,7 +868,12 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
817
868
|
for (const spec of specs) {
|
|
818
869
|
const snapshotDir = resolveSnapshotDir(spec.spec, dir)
|
|
819
870
|
const identifier = specIdentifier(snapshotDir, config)
|
|
820
|
-
const r =
|
|
871
|
+
const r = planOrRefusal({ dir, snapshotDir, identifier, config })
|
|
872
|
+
if (r.refused) {
|
|
873
|
+
failed++
|
|
874
|
+
out.write(`${PROGRAM} apply: ${spec.spec}\n !! ${r.refused}\n`)
|
|
875
|
+
continue
|
|
876
|
+
}
|
|
821
877
|
if (r.empty) continue
|
|
822
878
|
out.write(`${PROGRAM} apply: ${spec.spec}\n`)
|
|
823
879
|
try {
|
|
@@ -842,7 +898,12 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
|
|
|
842
898
|
if (!flags.plan) {
|
|
843
899
|
// --send-held computes its own. After the merge it is normally empty, and
|
|
844
900
|
// that empty plan is what tells apply that run 1 held the state.
|
|
845
|
-
|
|
901
|
+
const r = planOrRefusal({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config })
|
|
902
|
+
if (r.refused) {
|
|
903
|
+
out.write(`${PROGRAM} apply: refusing — ${r.refused}\n`)
|
|
904
|
+
return 1
|
|
905
|
+
}
|
|
906
|
+
plan = r.plan
|
|
846
907
|
} else {
|
|
847
908
|
try {
|
|
848
909
|
plan = JSON.parse(fs.readFileSync(flags.plan, 'utf-8'))
|
|
@@ -971,8 +1032,9 @@ function specSyncStatus(dir, config, specArg, flags, out, err) {
|
|
|
971
1032
|
lines.push(' states: every configured state exists in the project')
|
|
972
1033
|
}
|
|
973
1034
|
|
|
974
|
-
const r =
|
|
975
|
-
if (r.
|
|
1035
|
+
const r = planOrRefusal({ dir, snapshotDir, identifier, config })
|
|
1036
|
+
if (r.refused) lines.push(` push: refused — ${r.refused}`)
|
|
1037
|
+
else if (r.empty) lines.push(' push: in sync — nothing would push')
|
|
976
1038
|
else {
|
|
977
1039
|
const c = r.plan.subIssues.create.length
|
|
978
1040
|
const u = r.plan.subIssues.update.length
|
|
@@ -1760,6 +1822,37 @@ async function specSyncDoctor(dir, flags, out) {
|
|
|
1760
1822
|
: row('types', 'Mapped types', 'ok', 'every mapped type exists and carries its body field'),
|
|
1761
1823
|
)
|
|
1762
1824
|
}
|
|
1825
|
+
// Every product's area path, and the default they fall back to, must
|
|
1826
|
+
// exist — Azure refuses the whole write over an unknown area. NO ROW
|
|
1827
|
+
// when no product is set: a project that places nothing has nothing to
|
|
1828
|
+
// check. An area that could not be asked about is a warning, never a
|
|
1829
|
+
// failure (cannot-tell routes to the harmless branch).
|
|
1830
|
+
const productAreas = Object.values(config.azure.products || {}).map((p) => p.areaPath)
|
|
1831
|
+
if (productAreas.length) {
|
|
1832
|
+
const areas = [...new Set([...productAreas, config.azure.areaPath].filter(Boolean))]
|
|
1833
|
+
const missingAreas = []
|
|
1834
|
+
let unknownArea = null
|
|
1835
|
+
for (const area of areas) {
|
|
1836
|
+
try {
|
|
1837
|
+
if (!(await adapter.areaExists(area))) missingAreas.push(area)
|
|
1838
|
+
} catch (error) {
|
|
1839
|
+
unknownArea = `${area}: ${String((error && error.message) || error).split('\n')[0]}`
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
checks.push(
|
|
1843
|
+
missingAreas.length
|
|
1844
|
+
? row(
|
|
1845
|
+
'areas',
|
|
1846
|
+
'Product areas',
|
|
1847
|
+
'broken',
|
|
1848
|
+
`not in the project: ${missingAreas.join(', ')}`,
|
|
1849
|
+
`create the area under Project settings → Areas, or fix ${CONFIG_FILE} -> azure.products / azure.areaPath`,
|
|
1850
|
+
)
|
|
1851
|
+
: unknownArea
|
|
1852
|
+
? row('areas', 'Product areas', 'warn', `could not check ${unknownArea}`)
|
|
1853
|
+
: row('areas', 'Product areas', 'ok', `every product's area exists (${areas.length})`),
|
|
1854
|
+
)
|
|
1855
|
+
}
|
|
1763
1856
|
// The capability probe Decision 8 names: identity search is the op
|
|
1764
1857
|
// that fails first on a narrow token. A 401 here is a WARN, not
|
|
1765
1858
|
// broken — work item sync is whole without it; only `users` search
|
|
@@ -1922,6 +2015,8 @@ const USAGE = `Usage: skitterspec-azure-boards spec-sync <subcommand>
|
|
|
1922
2015
|
list [--all | --state NAME|BUCKET | --next N] [--mine | --by USER] tracker listing
|
|
1923
2016
|
linked [--json] specs and their linked items (offline)
|
|
1924
2017
|
idea add|list|drop [--json] ideas: work items tagged intake.ideaTag
|
|
2018
|
+
[--product <key>] add: file the idea in that product's area
|
|
2019
|
+
products [--json] the products a spec can name, and their areas
|
|
1925
2020
|
ownership [--json] who owns status and assignee (offline)
|
|
1926
2021
|
board <spec> [--json] is the item finished where the spec is not?
|
|
1927
2022
|
ref [<spec>] the Refs: trailer value for this branch
|
|
@@ -2009,6 +2104,8 @@ async function specSync(rest, io = {}) {
|
|
|
2009
2104
|
return specSyncIdea(dir, config, positional, flags, out)
|
|
2010
2105
|
case 'ownership':
|
|
2011
2106
|
return kit.specSyncOwnership(config, flags, out, PROGRAM)
|
|
2107
|
+
case 'products':
|
|
2108
|
+
return specSyncProducts(config, flags, out)
|
|
2012
2109
|
case 'board':
|
|
2013
2110
|
return specSyncBoard(dir, config, positional[0], flags, out)
|
|
2014
2111
|
case 'states':
|
|
@@ -2086,6 +2183,7 @@ function parseArgs(args, sub) {
|
|
|
2086
2183
|
'--release': { kind: 'boolean' },
|
|
2087
2184
|
'--if-unassigned': { kind: 'boolean', name: 'ifUnassigned' },
|
|
2088
2185
|
'--reason': { kind: 'value' },
|
|
2186
|
+
'--product': { kind: 'string' },
|
|
2089
2187
|
'--count': { kind: 'boolean' },
|
|
2090
2188
|
'--mine': { kind: 'boolean' },
|
|
2091
2189
|
'--next': { kind: 'number' },
|