@skitterbyte/skitterspec-github 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/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 +11 -1
- package/assets/skills/spec-complete/SKILL.md +9 -0
- package/assets/skills/spec-diff/SKILL.md +24 -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/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
|
|
@@ -138,6 +138,9 @@ async function applyInner({
|
|
|
138
138
|
// state name for these and only these (`recordPush`). A held state counts:
|
|
139
139
|
// run 2 sends it, and what run 2 records has to match what run 1 committed.
|
|
140
140
|
const sent = { issue: !!heldState || !!(plan.issue && plan.issue.state != null), subIssues: new Set() }
|
|
141
|
+
// A place rides the plan's issue: on a create it is always written, on an
|
|
142
|
+
// update only when the plan carries it. Recorded only once written.
|
|
143
|
+
sent.placement = !!(plan.issue && plan.issue.placement !== undefined)
|
|
141
144
|
// Handed out immediately, so a throw from anywhere below still reports what
|
|
142
145
|
// had been stamped by the time it happened.
|
|
143
146
|
if (progress) progress.result = result
|
|
@@ -231,6 +231,18 @@ function stateNamesRecord(projection, previous, sent) {
|
|
|
231
231
|
return out
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* The `placement` record for a snapshot: the place this push SENT, or the one
|
|
236
|
+
* the previous snapshot had when this push sent none, or undefined. The same
|
|
237
|
+
* rule as `stateNamesRecord` — recording a place nobody wrote would claim the
|
|
238
|
+
* tracker holds it.
|
|
239
|
+
*/
|
|
240
|
+
function placementRecord(projection, previous, sent) {
|
|
241
|
+
const p = projection || {}
|
|
242
|
+
if (sent && sent.placement && p.placement !== undefined) return p.placement
|
|
243
|
+
return previous && typeof previous.placement === 'string' ? previous.placement : undefined
|
|
244
|
+
}
|
|
245
|
+
|
|
234
246
|
// Has the state an unchanged item maps to moved under it — a state-map edit in
|
|
235
247
|
// the config rather than a move of the spec? Only a RECORDED name can say: an
|
|
236
248
|
// item with none is cannot-tell and plans nothing, so an upgrade or a config
|
|
@@ -304,9 +316,27 @@ function planChanges(projection, snapshot, { linked = false, epic = false } = {}
|
|
|
304
316
|
// is above, and nothing is retired (spec feat-epic-migration, Decision 2).
|
|
305
317
|
if (epic && unclaimed.length) subIssues.retire = unclaimed.slice()
|
|
306
318
|
|
|
319
|
+
// PLACEMENT: where the items belong (Azure's area path). Sent when the
|
|
320
|
+
// project places specs and the place differs from the one last sent. An
|
|
321
|
+
// unrecorded place on a linked spec is sent too: placement only comes into
|
|
322
|
+
// play when the project configures it, so that first push is the move the
|
|
323
|
+
// project asked for, not a guess about someone else's filing.
|
|
324
|
+
const place = p.placement
|
|
325
|
+
const moved = place !== undefined && snap.placement !== place
|
|
326
|
+
if (place !== undefined) for (const c of subIssues.create) c.placement = place
|
|
327
|
+
if (moved) {
|
|
328
|
+
for (const s of p.subIssues || []) {
|
|
329
|
+
if (s.id == null) continue
|
|
330
|
+
const existing = subIssues.update.find((u) => String(u.id) === String(s.id))
|
|
331
|
+
if (existing) existing.placement = place
|
|
332
|
+
else subIssues.update.push({ ref: s.ref, id: s.id, placement: place })
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
307
336
|
const plan = { subIssues }
|
|
308
337
|
if (unstamped.length) plan.unstamped = unstamped
|
|
309
|
-
|
|
338
|
+
let issue = issueChanges(p, snap, { linked })
|
|
339
|
+
if (moved) issue = { ...(issue || {}), placement: place }
|
|
310
340
|
if (issue) plan.issue = issue
|
|
311
341
|
return plan
|
|
312
342
|
}
|
|
@@ -413,6 +443,7 @@ module.exports = {
|
|
|
413
443
|
specIssueFieldHashes,
|
|
414
444
|
snapshotOf,
|
|
415
445
|
stateNamesRecord,
|
|
446
|
+
placementRecord,
|
|
416
447
|
isEmptyPlan,
|
|
417
448
|
hashField,
|
|
418
449
|
stableStringify,
|
|
@@ -436,7 +436,7 @@ function readSnapshot(snapshotDir, config) {
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
// The spec's own `> **Severity:**`, `> **Incident:**`, `> **Epic:**`,
|
|
439
|
-
// `> **Waits on:**` and `> **
|
|
439
|
+
// `> **Waits on:**`, `> **Lanes:**` and `> **Product:**` headers, off the overview's blockquote
|
|
440
440
|
// block. They are PUSH-TIME EXTRAS, deliberately not keys on `normalizeLocal`'s
|
|
441
441
|
// field set: severity lands in a provider-specific home (a field, a label),
|
|
442
442
|
// the incident and epic links as typed relations, and the waits and lanes are
|
|
@@ -448,7 +448,7 @@ function specHeaders(snapshotDir, config) {
|
|
|
448
448
|
try {
|
|
449
449
|
raw = fs.readFileSync(path.join(snapshotDir, overviewFile), 'utf-8')
|
|
450
450
|
} catch {
|
|
451
|
-
return { severity: null, incident: null, epic: null, waitsOn: [], lanes: null }
|
|
451
|
+
return { severity: null, incident: null, epic: null, waitsOn: [], lanes: null, product: null }
|
|
452
452
|
}
|
|
453
453
|
const read = (name) => {
|
|
454
454
|
const m = new RegExp(`^>\\s*\\*\\*${name}:\\*\\*\\s*(.+)$`, 'm').exec(raw)
|
|
@@ -460,6 +460,7 @@ function specHeaders(snapshotDir, config) {
|
|
|
460
460
|
epic: unquote(read('Epic')) || null,
|
|
461
461
|
waitsOn: parseWaitsOn(read('Waits on')),
|
|
462
462
|
lanes: parseLanes(read('Lanes')),
|
|
463
|
+
product: unquote(read('Product')) || null,
|
|
463
464
|
}
|
|
464
465
|
}
|
|
465
466
|
|
|
@@ -20,7 +20,7 @@ const path = require('node:path')
|
|
|
20
20
|
const { normalizeLocal, phasesWithheld, phaseModeFor, ownershipOf, readSnapshot } = require('./normalize.js')
|
|
21
21
|
const { descriptionMode } = require('./summary.js')
|
|
22
22
|
const { fieldsOf } = require('./fields.js')
|
|
23
|
-
const { planChanges, snapshotOf, stateNamesRecord, isEmptyPlan } = require('./compare.js')
|
|
23
|
+
const { planChanges, snapshotOf, stateNamesRecord, placementRecord, isEmptyPlan } = require('./compare.js')
|
|
24
24
|
const { readBase, writeBase } = require('./base.js')
|
|
25
25
|
const { detectLegacyMirror } = require('./legacy.js')
|
|
26
26
|
|
|
@@ -58,9 +58,34 @@ function projectionOf(snapshotDir, config) {
|
|
|
58
58
|
// pulled, and read by name, so it can never reach a hash.
|
|
59
59
|
if (ownershipOf(config, 'workflowState') === 'pull') projection.statePulled = true
|
|
60
60
|
attachStateNames(projection, snapshotDir, config)
|
|
61
|
+
attachPlacement(projection, snapshotDir, config)
|
|
61
62
|
return projection
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
// Where on the tracker this spec's items belong — Azure's area path, from the
|
|
66
|
+
// provider's `config.remote.placement(snapshotDir)` hook: a string when the
|
|
67
|
+
// project places specs, `undefined` when it does not (no hook, or the hook
|
|
68
|
+
// says the feature is not in play). Read by name, so it never reaches a hash:
|
|
69
|
+
// recorded beside them as `placement`, it is what lets a plan see a spec move
|
|
70
|
+
// that no field hash covers. A hook that throws REFUSES the plan — a spec
|
|
71
|
+
// naming a place the project does not have must not be filed somewhere else —
|
|
72
|
+
// but only the plan: the error is carried, not raised, so a status or a list
|
|
73
|
+
// over every spec is not taken down by one spec's bad header.
|
|
74
|
+
function attachPlacement(projection, snapshotDir, config) {
|
|
75
|
+
const hook = config && config.remote && config.remote.placement
|
|
76
|
+
if (typeof hook !== 'function') return
|
|
77
|
+
let value
|
|
78
|
+
try {
|
|
79
|
+
value = hook(snapshotDir)
|
|
80
|
+
} catch (error) {
|
|
81
|
+
// Tagged, so a caller can relay it as the refusal it is rather than a crash.
|
|
82
|
+
if (error && typeof error === 'object') error.placementRefused = true
|
|
83
|
+
Object.defineProperty(projection, 'placementError', { value: error, enumerable: false })
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
if (typeof value === 'string' && value) projection.placement = value
|
|
87
|
+
}
|
|
88
|
+
|
|
64
89
|
// The tracker state NAME each bucket resolves to today, from the provider's
|
|
65
90
|
// `config.remote.writtenStateName(bucket, role, snapshotDir)` hook: a string,
|
|
66
91
|
// `null` for "this bucket sends no state", or `undefined` for cannot-tell — no
|
|
@@ -103,6 +128,7 @@ function isLinked(snapshotDir, config) {
|
|
|
103
128
|
|
|
104
129
|
function push({ dir, snapshotDir, identifier, config }) {
|
|
105
130
|
const projection = projectionOf(snapshotDir, config)
|
|
131
|
+
if (projection.placementError) throw projection.placementError
|
|
106
132
|
const snapshot = readBase(dir, identifier, config)
|
|
107
133
|
const epic = path.basename(String(snapshotDir || '')).startsWith('epic-')
|
|
108
134
|
const plan = planChanges(projection, snapshot, { linked: isLinked(snapshotDir, config), epic })
|
|
@@ -150,6 +176,8 @@ function recordPush({ dir, snapshotDir, identifier, config, sent = null, keepSub
|
|
|
150
176
|
}
|
|
151
177
|
const names = stateNamesRecord(projection, before, sent)
|
|
152
178
|
if (names) snapshot.stateNames = names
|
|
179
|
+
const placement = placementRecord(projection, before, sent)
|
|
180
|
+
if (placement !== undefined) snapshot.placement = placement
|
|
153
181
|
return writeBase(dir, identifier, config, snapshot)
|
|
154
182
|
}
|
|
155
183
|
|