@skitterbyte/skitterspec 23.23.3 → 23.24.1
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/README.md +32 -0
- 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/bin/skitterspec.js +11 -1
- package/package.json +1 -1
- package/src/cli.js +271 -4
- package/src/env/classify.js +61 -6
- package/src/env/config.js +18 -0
- package/src/env/epic.js +1 -1
- package/src/env/epicpage.js +1 -1
- 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 +50 -6
- package/src/ideacmd.js +5 -2
- package/src/provider.js +46 -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,
|
|
@@ -44,7 +45,7 @@ const { renderEpicPage } = require('./epicpage.js')
|
|
|
44
45
|
const { readRegistry } = require('./registry.js')
|
|
45
46
|
const { loadEnvConfig } = require('./config.js')
|
|
46
47
|
const { primaryAnchor, attachProject, projectName, repoRootOf, prefixOf, fromRepoPath, toRepoPath } = require('./project.js')
|
|
47
|
-
const { specDocsIn, classifyDirtyTree, dirtyPaths } = require('./classify.js')
|
|
48
|
+
const { specDocsIn, classifyDirtyTree, dirtyPaths, treeReader } = require('./classify.js')
|
|
48
49
|
const { liveStateFor } = require('./live.js')
|
|
49
50
|
const { preferRemoteBase } = require('./host.js')
|
|
50
51
|
const { ROUTE: TADA_ROUTE, renderServedTada } = require('../tada/serve.js')
|
|
@@ -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`.
|
|
@@ -253,7 +263,8 @@ function docsWorktree(wt, spec, config) {
|
|
|
253
263
|
const paths = dirtyPaths(trimmedGitReader(wt))
|
|
254
264
|
// Cannot tell — not "no documents".
|
|
255
265
|
if (paths === null) return null
|
|
256
|
-
|
|
266
|
+
// An epic's members, written beside it in this same tree, are its documents.
|
|
267
|
+
const { owned, foreign } = classifyDirtyTree(spec, paths, config, { readFile: treeReader(wt) })
|
|
257
268
|
// A TRACKER SNAPSHOT IS NOT SOMEBODY ELSE'S WORK, and requiring a
|
|
258
269
|
// foreign-free tree cost the whole page for the commonest authoring tree
|
|
259
270
|
// there is. The linking push writes `specs/.core/linear-base/<ID>.base.json`
|
|
@@ -518,7 +529,9 @@ function receivePass(dir, config, spec, blob) {
|
|
|
518
529
|
* so every `/no-spec` page served over http offered to put nothing in flight,
|
|
519
530
|
* and the pass came back naming a verdict its own skill could not act on.
|
|
520
531
|
*/
|
|
521
|
-
|
|
532
|
+
// `final` too: the run's last render declared it, and a served re-render
|
|
533
|
+
// must keep offering the ending rather than fall back to `Commit`.
|
|
534
|
+
const NARROWING_SETS = ['midrun', 'refresh', 'fix', 'final']
|
|
522
535
|
|
|
523
536
|
function buttonsForView(viewKind, spec, recorded) {
|
|
524
537
|
if (NARROWING_SETS.includes(recorded)) return recorded
|
|
@@ -573,7 +586,7 @@ function renderSpecPage(dir, config, spec, { branch = false } = {}) {
|
|
|
573
586
|
treePath: view.tree,
|
|
574
587
|
})
|
|
575
588
|
return {
|
|
576
|
-
html: renderReviewPage(data, { reviewHtml: renderReviewBlock(data.review) }),
|
|
589
|
+
html: renderReviewPage(data, { reviewHtml: pageHeadFor(out, spec.folder, buttons) + renderReviewBlock(data.review) }),
|
|
577
590
|
totals: data.totals,
|
|
578
591
|
mode: data.mode,
|
|
579
592
|
fellBack: false,
|
|
@@ -680,7 +693,7 @@ function renderSpecPage(dir, config, spec, { branch = false } = {}) {
|
|
|
680
693
|
}
|
|
681
694
|
|
|
682
695
|
return {
|
|
683
|
-
html: renderReviewPage(data, { reviewHtml: renderReviewBlock(data.review) }),
|
|
696
|
+
html: renderReviewPage(data, { reviewHtml: pageHeadFor(reviewOutPath(dir, spec.folder, null), spec.folder, buttons) + renderReviewBlock(data.review) }),
|
|
684
697
|
totals: data.totals,
|
|
685
698
|
mode: data.mode,
|
|
686
699
|
fellBack,
|
|
@@ -815,7 +828,7 @@ function readBody(req, limit = MAX_PASS_BYTES) {
|
|
|
815
828
|
})
|
|
816
829
|
}
|
|
817
830
|
|
|
818
|
-
function createReviewServer({ resolveEntries, resolveEpics = () => [], render, receive = null, passState = null, tada = null, token = null, project = null }) {
|
|
831
|
+
function createReviewServer({ resolveEntries, resolveEpics = () => [], render, receive = null, passState = null, tada = null, runPage = null, snapshot = null, token = null, project = null }) {
|
|
819
832
|
return http.createServer((req, res) => {
|
|
820
833
|
const send = (code, body, type = 'text/html; charset=utf-8') => {
|
|
821
834
|
res.writeHead(code, { 'content-type': type, 'cache-control': 'no-store' })
|
|
@@ -882,6 +895,19 @@ function createReviewServer({ resolveEntries, resolveEpics = () => [], render, r
|
|
|
882
895
|
return
|
|
883
896
|
}
|
|
884
897
|
|
|
898
|
+
// A SERVER BUILT WITHOUT THE HOOKS is an older one, and says not found —
|
|
899
|
+
// the same answer an unknown path gets.
|
|
900
|
+
if (route.kind === 'run' || route.kind === 'snapshot') {
|
|
901
|
+
const hook = route.kind === 'run' ? runPage : snapshot
|
|
902
|
+
if (!hook) return send(404, 'not found', 'text/plain; charset=utf-8')
|
|
903
|
+
try {
|
|
904
|
+
const out = route.kind === 'run' ? hook(route.spec, { token }) : hook(route.spec, route.phase)
|
|
905
|
+
return out && out.html ? send(200, out.html) : send(404, 'not found', 'text/plain; charset=utf-8')
|
|
906
|
+
} catch (err) {
|
|
907
|
+
return send(500, `render failed: ${err.message}`, 'text/plain; charset=utf-8')
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
885
911
|
try {
|
|
886
912
|
if (route.kind === 'index') return send(200, renderIndex(resolveEntries(), { token, epics: resolveEpics(), project }))
|
|
887
913
|
const out = render(route.spec, { branch: route.branch })
|
|
@@ -1105,6 +1131,24 @@ function serverHooks(dir, config) {
|
|
|
1105
1131
|
return renderSpecPage(dir, config, resolveOne(folder), opts)
|
|
1106
1132
|
},
|
|
1107
1133
|
receive: (folder, blob) => receivePass(dir, config, resolveOne(folder), blob),
|
|
1134
|
+
// The run index, built per request from the run record and the report
|
|
1135
|
+
// sidecar; a spec this daemon cannot resolve is a 404, not an empty run.
|
|
1136
|
+
runPage: (folder, { token: t = null } = {}) => {
|
|
1137
|
+
const one = resolveOne(folder)
|
|
1138
|
+
if (!one) return null
|
|
1139
|
+
return { html: runIndexFor(reviewOutPath(dir, one.folder, null), one.folder, { token: t, project: projectName(config) }) }
|
|
1140
|
+
},
|
|
1141
|
+
// A kept phase page is served as written — it is a record of what that
|
|
1142
|
+
// phase looked like, so re-rendering it from today's tree would defeat it.
|
|
1143
|
+
snapshot: (folder, phase) => {
|
|
1144
|
+
const one = resolveOne(folder)
|
|
1145
|
+
if (!one) return null
|
|
1146
|
+
try {
|
|
1147
|
+
return { html: fs.readFileSync(snapshotPath(reviewOutPath(dir, one.folder, null), phase), 'utf8') }
|
|
1148
|
+
} catch {
|
|
1149
|
+
return null
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1108
1152
|
// A spec this daemon cannot resolve is not a pass that was claimed — it is
|
|
1109
1153
|
// a lookup that could not see, so it says nothing rather than reporting the
|
|
1110
1154
|
// 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
|
package/src/provider.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// provider's `src/register.js` from where it is installed, and hands it the
|
|
10
10
|
// base's own engine modules to register on.
|
|
11
11
|
|
|
12
|
+
const { spawnSync } = require('node:child_process')
|
|
12
13
|
const { existsSync } = require('node:fs')
|
|
13
14
|
const { dirname, join } = require('node:path')
|
|
14
15
|
|
|
@@ -89,4 +90,48 @@ function registerConfiguredProvider({ cwd, envConfig, idea, resolve = resolvePac
|
|
|
89
90
|
return { provider: p.name, registered: 'config' }
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Run a verb the base does not ship (`commands`, e.g. `spec-sync`) on the
|
|
95
|
+
* provider configured in the project at or above `cwd`, through that
|
|
96
|
+
* provider's own bin, so `skitterspec spec-sync …` answers exactly as
|
|
97
|
+
* `skitterspec-<provider> spec-sync …` does — the skills call the bare name.
|
|
98
|
+
*
|
|
99
|
+
* Returns the exit status to use, or `null` when there is nothing to forward
|
|
100
|
+
* and the base should carry on as it would have: a verb it ships, no project,
|
|
101
|
+
* no provider configured, or two of them (registerConfiguredProvider warns).
|
|
102
|
+
*
|
|
103
|
+
* WHAT WOULD FOOL THIS: a provider installed where Node's resolution cannot
|
|
104
|
+
* see it from the base or the project reads as not installed, and the verb is
|
|
105
|
+
* refused naming the package — never run on a guessed provider.
|
|
106
|
+
*/
|
|
107
|
+
function forwardProviderCommand({
|
|
108
|
+
cwd,
|
|
109
|
+
argv,
|
|
110
|
+
commands,
|
|
111
|
+
resolve = resolvePackage,
|
|
112
|
+
warn = () => {},
|
|
113
|
+
spawn = spawnSync,
|
|
114
|
+
}) {
|
|
115
|
+
const [cmd] = argv
|
|
116
|
+
if (!commands.includes(cmd)) return null
|
|
117
|
+
const dir = projectDir(cwd)
|
|
118
|
+
if (!dir) return null
|
|
119
|
+
const configured = PROVIDERS.filter((p) => existsSync(join(dir, p.configFile)))
|
|
120
|
+
if (configured.length !== 1) return null
|
|
121
|
+
const p = configured[0]
|
|
122
|
+
const bin = join('bin', `skitterspec-${p.name}.js`)
|
|
123
|
+
for (const [pkg] of p.candidates) {
|
|
124
|
+
const root = resolve(pkg, [__dirname, dir])
|
|
125
|
+
if (root && existsSync(join(root, bin))) {
|
|
126
|
+
const r = spawn(process.execPath, [join(root, bin), ...argv], { cwd, stdio: 'inherit' })
|
|
127
|
+
return r.status ?? 1
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
warn(
|
|
131
|
+
`skitterspec: ${cmd} needs @skitterbyte/skitterspec-${p.name} installed beside this one — ` +
|
|
132
|
+
`${p.configFile} is here but it is not. Install it alongside @skitterbyte/skitterspec, at the latest of each.`,
|
|
133
|
+
)
|
|
134
|
+
return 1
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = { registerConfiguredProvider, forwardProviderCommand, PROVIDERS }
|