@skitterbyte/skitterspec-jira 2.11.0 → 2.13.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/core/env.config.md +5 -0
- package/assets/rules/spec-planning.md +12 -0
- package/assets/rules/spec-reports.md +15 -0
- package/assets/skills/spec/SKILL.md +30 -0
- package/assets/skills/spec-cancel/SKILL.md +22 -4
- package/assets/skills/spec-complete/SKILL.md +34 -6
- package/assets/skills/spec-idea/SKILL.md +115 -0
- package/assets/skills/spec-init/SKILL.md +3 -2
- package/assets/skills/spec-review/SKILL.md +22 -4
- package/assets/skills/spec-todo/SKILL.md +3 -0
- package/bin/skitterspec-jira.js +4 -0
- package/package.json +1 -1
- package/src/cli.js +81 -27
- package/src/env/config.js +7 -0
- package/src/env/projectguard.js +1 -1
- package/src/env/review.js +66 -1
- package/src/env/reviewers.js +5 -4
- package/src/env/supervise.js +71 -9
- package/src/idea.js +190 -0
- package/src/ideacmd.js +242 -0
- package/src/tada/todo.js +6 -1
- package/src/vendor/jira/cli-sync.js +33 -11
- package/src/vendor/provider-kit/src/apply.js +90 -5
package/src/cli.js
CHANGED
|
@@ -114,6 +114,8 @@ const {
|
|
|
114
114
|
collectReview,
|
|
115
115
|
reviewTierStack,
|
|
116
116
|
reviewTierLine,
|
|
117
|
+
reviewStackText,
|
|
118
|
+
waitCovers,
|
|
117
119
|
isTailnetAddress,
|
|
118
120
|
tailnetLabel,
|
|
119
121
|
renderReviewPage,
|
|
@@ -377,6 +379,13 @@ Usage:
|
|
|
377
379
|
waiting and gates armed, and today so far. Same
|
|
378
380
|
scope as tada (--here, --all-projects), --json,
|
|
379
381
|
--page [--summary <recap.md>].
|
|
382
|
+
skitterspec idea <cmd> Ideas not specced yet, where the team can see them:
|
|
383
|
+
in the tracker when the provider holds ideas, else
|
|
384
|
+
specs/ideas.md landed on the base branch (never
|
|
385
|
+
pushed — it prints the push). Subcommands:
|
|
386
|
+
add <text> capture one; first line is the title
|
|
387
|
+
list what is waiting (--count, --json)
|
|
388
|
+
drop <id> discard one (--reason <why>)
|
|
380
389
|
skitterspec gating <cmd> Release-gating check (opt-in; needs
|
|
381
390
|
specs/.core/gating.config.json). Subcommands:
|
|
382
391
|
check [spec] report specs with no recorded gating
|
|
@@ -905,6 +914,26 @@ function repoBlockers(repo, specs) {
|
|
|
905
914
|
return readBlockers(reviewsDirFor(repo, config), specs, config.review && config.review.required)
|
|
906
915
|
}
|
|
907
916
|
|
|
917
|
+
/**
|
|
918
|
+
* The home project's waiting ideas, or null when that cannot be told. A
|
|
919
|
+
* provider store asks the network, so the answer is bounded: a slow, failed or
|
|
920
|
+
* refused count is null, and null prints nothing — an idea count is never a
|
|
921
|
+
* reason for the morning report to fail or stall.
|
|
922
|
+
*/
|
|
923
|
+
async function ideaCount(repo) {
|
|
924
|
+
let text = ''
|
|
925
|
+
const sink = { write: (s) => (text += s) }
|
|
926
|
+
try {
|
|
927
|
+
const counted = require('./ideacmd.js').ideaCommand(['list', '--count', '--json'], { cwd: repo, out: sink })
|
|
928
|
+
const timeout = new Promise((resolve) => setTimeout(() => resolve('timeout'), 5000).unref())
|
|
929
|
+
if ((await Promise.race([counted, timeout])) !== 0) return null
|
|
930
|
+
const n = JSON.parse(text).count
|
|
931
|
+
return Number.isInteger(n) ? n : null
|
|
932
|
+
} catch {
|
|
933
|
+
return null
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
908
937
|
/**
|
|
909
938
|
* `skitterspec todo` — the morning half of the ta-da list: where each project
|
|
910
939
|
* was left on the last day with any activity, what is ahead, and what is in
|
|
@@ -931,7 +960,7 @@ async function todoCommand(argv) {
|
|
|
931
960
|
} catch {
|
|
932
961
|
// the folder name stands in, as it does everywhere else
|
|
933
962
|
}
|
|
934
|
-
home = { repo: homeRepo, name, groups: openSpecsIn(homeRepo).map((row) => ({ spec: row.spec, inFlight: row })) }
|
|
963
|
+
home = { repo: homeRepo, name, groups: openSpecsIn(homeRepo).map((row) => ({ spec: row.spec, inFlight: row })), ideas: await ideaCount(homeRepo) }
|
|
935
964
|
}
|
|
936
965
|
|
|
937
966
|
const todo = buildTodo({ leftOff, leftOffDay: day, today: todaySoFar, home, blockersFor: repoBlockers })
|
|
@@ -1000,8 +1029,9 @@ async function serveTadaPage({ window, flags, recap }) {
|
|
|
1000
1029
|
const q = tadaQuery({ ...flags, on: flags.on || (flags.since ? null : localDay(window.since)) })
|
|
1001
1030
|
const withQ = (u) => (u ? `${u}${q}` : u)
|
|
1002
1031
|
const page = { ...served, loopbackUrl: withQ(served.loopbackUrl), url: withQ(served.url), alternates: (served.alternates || []).map(withQ) }
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1032
|
+
const reader = resolveReader(config, process.env)
|
|
1033
|
+
const tiers = reviewTierStack({ served: page, fileUrl: null, publishedUrl: null, config, reader })
|
|
1034
|
+
process.stdout.write(`page: ${humanLabel(window)}\n${reviewStackText(tiers)}`)
|
|
1005
1035
|
return true
|
|
1006
1036
|
}
|
|
1007
1037
|
|
|
@@ -1105,13 +1135,14 @@ function epicPageTiers(inputs, up, epic) {
|
|
|
1105
1135
|
if (!inputs.config) return null
|
|
1106
1136
|
if (!up) return { off: true, start: 'skitterspec spec-env review serve --host 0.0.0.0' }
|
|
1107
1137
|
const served = reviewServedUrls(up, offerableLanAddresses(), epic)
|
|
1108
|
-
|
|
1138
|
+
const reader = resolveReader(inputs.config, process.env)
|
|
1139
|
+
return { tiers: reviewTierStack({ served, fileUrl: null, publishedUrl: null, config: inputs.config, reader }) }
|
|
1109
1140
|
}
|
|
1110
1141
|
|
|
1111
1142
|
function epicPageLines(page) {
|
|
1112
1143
|
if (!page) return ''
|
|
1113
1144
|
if (page.off) return `epic page: no review server running — start it with: ${page.start}\n`
|
|
1114
|
-
return `epic page:\n${page.tiers
|
|
1145
|
+
return `epic page:\n${reviewStackText(page.tiers)}`
|
|
1115
1146
|
}
|
|
1116
1147
|
|
|
1117
1148
|
// The working tree `--here` reads: the project folder of the checkout this
|
|
@@ -4847,7 +4878,8 @@ function reshowStack(dir, config, spec, out) {
|
|
|
4847
4878
|
const cfg = withSpecRemote(config, out)
|
|
4848
4879
|
const up = readRunningReviewServer(dir, cfg)
|
|
4849
4880
|
const served = up ? reviewServedUrls(up, offerableLanAddresses(), spec.folder) : null
|
|
4850
|
-
const
|
|
4881
|
+
const reader = resolveReader(cfg, process.env)
|
|
4882
|
+
const tiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), publishedUrl: readReviewUrl(out), config: cfg, reader })
|
|
4851
4883
|
let live = null
|
|
4852
4884
|
try {
|
|
4853
4885
|
const primaryState = assertPrimaryOnMain(cfg, gitReader(dir))
|
|
@@ -4914,7 +4946,7 @@ async function specEnvReviewWait(dir, config, specArg, flags) {
|
|
|
4914
4946
|
`${rearm ? ` (re-arm ${rearm})` : ''}\n` +
|
|
4915
4947
|
(stack
|
|
4916
4948
|
? ` re-show: banner (re-arm ${rearm})\n` +
|
|
4917
|
-
stack.tiers
|
|
4949
|
+
reviewStackText(stack.tiers) +
|
|
4918
4950
|
(liveStateLine(stack.live) ? `${liveStateLine(stack.live)}\n` : '')
|
|
4919
4951
|
: ''),
|
|
4920
4952
|
)
|
|
@@ -6252,6 +6284,10 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
6252
6284
|
}
|
|
6253
6285
|
}
|
|
6254
6286
|
|
|
6287
|
+
// ONE STACK for both outputs, so `--json` and the text cannot disagree about
|
|
6288
|
+
// which tiers exist — or which one is hidden.
|
|
6289
|
+
const stackTiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), publishedUrl: url, config, reader })
|
|
6290
|
+
|
|
6255
6291
|
if (flags.json) {
|
|
6256
6292
|
process.stdout.write(
|
|
6257
6293
|
JSON.stringify(
|
|
@@ -6278,12 +6314,10 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
6278
6314
|
// The same stack the text prints, so a skill reads the tiers rather
|
|
6279
6315
|
// than parsing prose — and the two can never disagree, because both
|
|
6280
6316
|
// come from `reviewTierStack`.
|
|
6281
|
-
tiers:
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
config,
|
|
6286
|
-
}),
|
|
6317
|
+
tiers: stackTiers,
|
|
6318
|
+
// Which served tiers one wait covers — the holding line's tiers, so a
|
|
6319
|
+
// banner never names a door the stack did not show.
|
|
6320
|
+
covers: waitCovers(stackTiers),
|
|
6287
6321
|
// The same answer `live status --json` gives, from the same function,
|
|
6288
6322
|
// so the page and the command cannot disagree. Always present, unlike
|
|
6289
6323
|
// the tiers' optional keys: `unavailable` is a state a consumer needs
|
|
@@ -6405,19 +6439,12 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
|
|
|
6405
6439
|
// rendering — `reviewTierLine` carries them, which is what puts them
|
|
6406
6440
|
// under `network:` rather than dangling after the stack (they used to
|
|
6407
6441
|
// print below `remote:`, against the comment that placed them).
|
|
6408
|
-
|
|
6409
|
-
served,
|
|
6410
|
-
fileUrl: reviewFileUrl(out),
|
|
6411
|
-
publishedUrl: url,
|
|
6412
|
-
config,
|
|
6413
|
-
})
|
|
6414
|
-
.map((t) => reviewTierLine(t) + '\n')
|
|
6415
|
-
.join('') +
|
|
6442
|
+
reviewStackText(stackTiers) +
|
|
6416
6443
|
// WHICH TIERS THE WAIT COVERS, once, next to the stack. `local` and
|
|
6417
6444
|
// `network` are two doors into one room — the page POSTs to
|
|
6418
6445
|
// `location.pathname`, so both reach this server and this pending store.
|
|
6419
6446
|
// `remote` writes to the artifact's own store, which nothing here can see.
|
|
6420
|
-
|
|
6447
|
+
` the wait covers ${waitCovers(stackTiers).join(' + ')}; a remote verdict needs /spec-reviewed.\n` +
|
|
6421
6448
|
// WHETHER IT IS ALSO RUNNING SOMEWHERE, which is the other way to judge a
|
|
6422
6449
|
// change. `unavailable` prints nothing — see `liveStateLine`.
|
|
6423
6450
|
(liveStateLine(live) ? `${liveStateLine(live)}\n` : '') +
|
|
@@ -6479,6 +6506,10 @@ async function specEnvDev(dir, config, positional) {
|
|
|
6479
6506
|
const out = [`spec-env dev up: ${spec.folder} slot ${slot} (ports from ${plan.portOffset})`]
|
|
6480
6507
|
for (const proc of plan.procs) {
|
|
6481
6508
|
const res = startProcess(proc, { cwd: spec.projectPath, rootDir: dir })
|
|
6509
|
+
if (res.error) {
|
|
6510
|
+
out.push(` ${proc.name}: port ${proc.port} NOT STARTED — ${res.error}`)
|
|
6511
|
+
continue
|
|
6512
|
+
}
|
|
6482
6513
|
let health = ''
|
|
6483
6514
|
if (proc.health) {
|
|
6484
6515
|
health = (await waitHealthy(proc.health)) ? ' health: ok' : ' health: TIMEOUT'
|
|
@@ -6566,8 +6597,9 @@ function proxyProcFor(config, routesFileAbs) {
|
|
|
6566
6597
|
const sdir = stateDirLabel(config)
|
|
6567
6598
|
return {
|
|
6568
6599
|
name: 'proxy',
|
|
6569
|
-
//
|
|
6570
|
-
//
|
|
6600
|
+
// `argv` is what runs — node itself, no shell (bug-review-serve-spawn-sh).
|
|
6601
|
+
// `command` is the same thing for a person to read.
|
|
6602
|
+
argv: [process.execPath, path.join(__dirname, 'env', 'proxy.js'), routesFileAbs],
|
|
6571
6603
|
command: `node ${shellPath(path.join(__dirname, 'env', 'proxy.js'))} ${shellPath(routesFileAbs)}`,
|
|
6572
6604
|
env: {},
|
|
6573
6605
|
logFile: `${sdir}/logs/proxy.log`,
|
|
@@ -6579,8 +6611,15 @@ function proxyProcFor(config, routesFileAbs) {
|
|
|
6579
6611
|
// monorepo developing itself, and a project that installed the package. Naming
|
|
6580
6612
|
// the distribution here is a path, not provider machinery — `init.js` and
|
|
6581
6613
|
// `PROVIDER_COMMANDS` above already know package names by name.
|
|
6614
|
+
//
|
|
6615
|
+
// EVERY DISTRIBUTION, not only the base. A project installs exactly one, and a
|
|
6616
|
+
// superset missing here fell through to `__dirname` — the RUNNING copy — so a
|
|
6617
|
+
// worktree's engine saw the primary's server as executing a different script,
|
|
6618
|
+
// called it stale and stopped it (bug-review-serve-spawn-sh).
|
|
6582
6619
|
const DAEMON_LOCATIONS = [
|
|
6583
|
-
|
|
6620
|
+
...['skitterspec', 'skitterspec-linear', 'skitterspec-jira', 'skitterspec-github', 'skitterspec-azure-boards'].map(
|
|
6621
|
+
(pkg) => path.join('node_modules', '@skitterbyte', pkg, 'src', 'env', 'serve.js'),
|
|
6622
|
+
),
|
|
6584
6623
|
path.join('packages', 'common', 'src', 'env', 'serve.js'),
|
|
6585
6624
|
]
|
|
6586
6625
|
|
|
@@ -6636,8 +6675,10 @@ function serveProcFor(config, settingsFileAbs, { root = null } = {}) {
|
|
|
6636
6675
|
const sdir = stateDirLabel(config)
|
|
6637
6676
|
return {
|
|
6638
6677
|
name: 'review-serve',
|
|
6639
|
-
//
|
|
6640
|
-
//
|
|
6678
|
+
// `argv` is what runs — node itself, no shell. It used to go through
|
|
6679
|
+
// `sh -c`, and a Windows session without Git's bin on PATH has no `sh`
|
|
6680
|
+
// (bug-review-serve-spawn-sh). `command` is the same thing for a person.
|
|
6681
|
+
argv: [process.execPath, daemonScript(root), settingsFileAbs],
|
|
6641
6682
|
command: `node ${shellPath(daemonScript(root))} ${shellPath(settingsFileAbs)}`,
|
|
6642
6683
|
script: daemonScript(root),
|
|
6643
6684
|
env: {},
|
|
@@ -6890,6 +6931,9 @@ async function ensureReviewServer(dir, config, { host = '127.0.0.1', port, resta
|
|
|
6890
6931
|
) + '\n',
|
|
6891
6932
|
)
|
|
6892
6933
|
const res = startProcess(proc, { cwd: dir, rootDir: dir })
|
|
6934
|
+
// Nothing was spawned, so there is nothing to wait for — and the reason is
|
|
6935
|
+
// the only thing worth handing back.
|
|
6936
|
+
if (res.error) return { error: `could not start the server (${res.error})`, port: usePort, replaced, engineWas }
|
|
6893
6937
|
const up = await waitListening([usePort], { host: loopback ? host : '127.0.0.1' })
|
|
6894
6938
|
// A PORT ANSWERING IS NOT PROOF THAT OUR PROCESS IS ANSWERING IT. `waitListening`
|
|
6895
6939
|
// connects, and anything already bound satisfies a connect — so on its own it
|
|
@@ -7034,6 +7078,11 @@ async function specEnvReviewServe(dir, config, flags) {
|
|
|
7034
7078
|
return
|
|
7035
7079
|
}
|
|
7036
7080
|
|
|
7081
|
+
if (started.error) {
|
|
7082
|
+
process.stdout.write(`spec-env review serve: ${started.error} — see ${proc.logFile}\n`)
|
|
7083
|
+
return
|
|
7084
|
+
}
|
|
7085
|
+
|
|
7037
7086
|
const { port, token, loopback } = started
|
|
7038
7087
|
const res = { pid: started.pid }
|
|
7039
7088
|
|
|
@@ -8107,6 +8156,11 @@ async function run(argv) {
|
|
|
8107
8156
|
return
|
|
8108
8157
|
}
|
|
8109
8158
|
|
|
8159
|
+
if (cmd === 'idea') {
|
|
8160
|
+
process.exitCode = await require('./ideacmd.js').ideaCommand(rest)
|
|
8161
|
+
return
|
|
8162
|
+
}
|
|
8163
|
+
|
|
8110
8164
|
if (cmd === 'epic') {
|
|
8111
8165
|
const [sub, ...eArgs] = rest
|
|
8112
8166
|
if (sub === 'status') epicStatusCommand(eArgs)
|
package/src/env/config.js
CHANGED
|
@@ -927,6 +927,12 @@ function setProviderConfigFile(rel) {
|
|
|
927
927
|
providerConfigFile = rel || null
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
+
// Is a ticketing provider registered AND configured in this project? The same
|
|
931
|
+
// signal `land.specDocs` defaults on, so the two cannot disagree.
|
|
932
|
+
function providerConfigured(dir) {
|
|
933
|
+
return Boolean(providerConfigFile) && existsSync(join(dir, providerConfigFile))
|
|
934
|
+
}
|
|
935
|
+
|
|
930
936
|
// An explicit `specDocs` in the file — any value, even one the merge rejected —
|
|
931
937
|
// is the project's decision; a rejected typo stays on the conservative "trunk"
|
|
932
938
|
// rather than being promoted to the provider default.
|
|
@@ -976,6 +982,7 @@ module.exports = {
|
|
|
976
982
|
loadEnvConfig,
|
|
977
983
|
setProviderEnvDefaults,
|
|
978
984
|
setProviderConfigFile,
|
|
985
|
+
providerConfigured,
|
|
979
986
|
resolveServePort,
|
|
980
987
|
derivedServePort,
|
|
981
988
|
servePortRoot,
|
package/src/env/projectguard.js
CHANGED
|
@@ -52,7 +52,7 @@ const GIT_READS = new Set([
|
|
|
52
52
|
|
|
53
53
|
// skitterspec verbs that only read, as `verb` or `verb sub`.
|
|
54
54
|
const ENGINE_READS = new Set([
|
|
55
|
-
'tada', 'todo', 'status', 'help', '--help', '-h', '--version', '-v',
|
|
55
|
+
'tada', 'todo', 'idea list', 'status', 'help', '--help', '-h', '--version', '-v',
|
|
56
56
|
'spec-env status', 'spec-env resolve',
|
|
57
57
|
'epic status', 'epic check', 'gating check', 'spec-sync ownership', 'spec-sync board',
|
|
58
58
|
])
|
package/src/env/review.js
CHANGED
|
@@ -249,11 +249,36 @@ function detectReader(env = {}) {
|
|
|
249
249
|
* being told.
|
|
250
250
|
*/
|
|
251
251
|
function resolveReader(config, env = {}) {
|
|
252
|
+
// THE WRAPPER FIRST, because it is the one thing that knows this machine. A
|
|
253
|
+
// committed `review.reader` speaks for every checkout of the repo; a wrapper
|
|
254
|
+
// that runs the engine inside a VM (`prlctl exec`) speaks for this one, and
|
|
255
|
+
// the VM shows nothing else to detect — no SSH, no session variables.
|
|
256
|
+
const told = String(env.SKITTERSPEC_READER || '').trim().toLowerCase()
|
|
257
|
+
if (told === 'local' || told === 'remote') return { reader: told, why: 'SKITTERSPEC_READER' }
|
|
252
258
|
const setting = (config && config.review && config.review.reader) || 'detect'
|
|
253
259
|
if (setting === 'local' || setting === 'remote') return { reader: setting, why: 'configured' }
|
|
254
260
|
return detectReader(env)
|
|
255
261
|
}
|
|
256
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Whether the reader's browser is on another machine, so `127.0.0.1` is the
|
|
265
|
+
* wrong one — the question that hides the `local` tier.
|
|
266
|
+
*
|
|
267
|
+
* NARROWER THAN `reader === 'remote'`, deliberately. A bridge session is a
|
|
268
|
+
* reader driving this session from elsewhere, but often from a browser on this
|
|
269
|
+
* same machine, where loopback opens fine; and its variable is an undocumented
|
|
270
|
+
* harness internal. Hiding a working link on that guess is the load-bearing
|
|
271
|
+
* detection `detectReader` warns against, so only the signals someone set on
|
|
272
|
+
* purpose count: the wrapper's variable, the committed setting, and SSH.
|
|
273
|
+
*
|
|
274
|
+
* WHAT WOULD FOOL THIS: SSH with a `-L` port forward makes the reader's loopback
|
|
275
|
+
* reach this server, so `ssh` is a strong hint rather than proof —
|
|
276
|
+
* `SKITTERSPEC_READER=local` is the way back, and it outranks it.
|
|
277
|
+
*/
|
|
278
|
+
function readerOffMachine(reader) {
|
|
279
|
+
return Boolean(reader && reader.reader === 'remote' && reader.why !== 'bridge session')
|
|
280
|
+
}
|
|
281
|
+
|
|
257
282
|
/**
|
|
258
283
|
* Collect everything the page needs.
|
|
259
284
|
*
|
|
@@ -721,7 +746,7 @@ function surfacesFor({ live, tiers, buttons = null }) {
|
|
|
721
746
|
* pending store, and one wait covers both. `remote` is a second store, which is
|
|
722
747
|
* why it carries the line saying so.
|
|
723
748
|
*/
|
|
724
|
-
function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
749
|
+
function reviewTierStack({ served, fileUrl, publishedUrl, config, reader = null }) {
|
|
725
750
|
const tiers = []
|
|
726
751
|
const loopbackUrl = served && served.loopbackUrl ? served.loopbackUrl : null
|
|
727
752
|
|
|
@@ -772,9 +797,46 @@ function reviewTierStack({ served, fileUrl, publishedUrl, config }) {
|
|
|
772
797
|
tiers.push({ tier: 'remote', unavailable: true, note: 'publishing is an ask — nothing published yet' })
|
|
773
798
|
}
|
|
774
799
|
|
|
800
|
+
// A READER ON ANOTHER MACHINE gets no `local` door: it points at this
|
|
801
|
+
// machine's loopback, so it hangs and never opens — first in the list, and
|
|
802
|
+
// the one habit reaches for. Hidden only when `network` has a URL to take
|
|
803
|
+
// its place; with none, an empty stack is worse than a dead link that says
|
|
804
|
+
// it is dead, so it stays and says so. Kept in `--json` either way, marked,
|
|
805
|
+
// so the decision is visible rather than an absence.
|
|
806
|
+
if (readerOffMachine(reader)) {
|
|
807
|
+
const network = tiers.find((t) => t.tier === 'network')
|
|
808
|
+
const why = `the reader is on another machine (${reader.why})`
|
|
809
|
+
tiers[0] =
|
|
810
|
+
network && network.url
|
|
811
|
+
? { ...tiers[0], hidden: true, reason: why }
|
|
812
|
+
: { ...tiers[0], note: "not reachable from the reader's machine" }
|
|
813
|
+
}
|
|
814
|
+
|
|
775
815
|
return tiers
|
|
776
816
|
}
|
|
777
817
|
|
|
818
|
+
/**
|
|
819
|
+
* The stack as printed text: every tier the reader can use, one line each,
|
|
820
|
+
* each ending in a newline. A `hidden` tier prints nothing — it is in `--json`
|
|
821
|
+
* for anyone who asks, and absent from the screen a reader clicks from.
|
|
822
|
+
*/
|
|
823
|
+
function reviewStackText(tiers) {
|
|
824
|
+
return tiers
|
|
825
|
+
.filter((t) => !t.hidden)
|
|
826
|
+
.map((t) => reviewTierLine(t) + '\n')
|
|
827
|
+
.join('')
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* The served tiers one wait covers, as the stack shows them. `local` and
|
|
832
|
+
* `network` are two doors into one room; with `local` hidden there is one door,
|
|
833
|
+
* and the line must not name one the reader was never shown.
|
|
834
|
+
*/
|
|
835
|
+
function waitCovers(tiers) {
|
|
836
|
+
const local = tiers.find((t) => t.tier === 'local')
|
|
837
|
+
return local && local.hidden ? ['network'] : ['local', 'network']
|
|
838
|
+
}
|
|
839
|
+
|
|
778
840
|
// One tier as a line, padded so the labels form a column the eye can run down.
|
|
779
841
|
// A tier with alternates renders them as indented `also:` lines of its own —
|
|
780
842
|
// they are PART of the tier, which is what puts them under `network:` rather
|
|
@@ -2632,6 +2694,8 @@ module.exports = {
|
|
|
2632
2694
|
surfacesFor,
|
|
2633
2695
|
reviewTierStack,
|
|
2634
2696
|
reviewTierLine,
|
|
2697
|
+
reviewStackText,
|
|
2698
|
+
waitCovers,
|
|
2635
2699
|
isTailnetAddress,
|
|
2636
2700
|
tailnetLabel,
|
|
2637
2701
|
COMMITTING,
|
|
@@ -2724,6 +2788,7 @@ module.exports = {
|
|
|
2724
2788
|
renderReviewFragment,
|
|
2725
2789
|
detectReader,
|
|
2726
2790
|
resolveReader,
|
|
2791
|
+
readerOffMachine,
|
|
2727
2792
|
CHECK_LEVELS,
|
|
2728
2793
|
loadTemplate,
|
|
2729
2794
|
TEMPLATE_PATH,
|
package/src/env/reviewers.js
CHANGED
|
@@ -32,7 +32,7 @@ const fs = require('node:fs')
|
|
|
32
32
|
const path = require('node:path')
|
|
33
33
|
const crypto = require('node:crypto')
|
|
34
34
|
const { spawn } = require('node:child_process')
|
|
35
|
-
const { signalGroup } = require('./supervise.js')
|
|
35
|
+
const { signalGroup, resolveShell } = require('./supervise.js')
|
|
36
36
|
|
|
37
37
|
const BUNDLED_ADAPTERS = { coderabbit: require('./reviewers/coderabbit.js') }
|
|
38
38
|
|
|
@@ -288,9 +288,10 @@ function runReviewer(entry, ctx) {
|
|
|
288
288
|
// Through a shell, deliberately: the config holds a command LINE, with
|
|
289
289
|
// pipes and quoting the project chose. It is read from a committed config
|
|
290
290
|
// in the project's own repo — the same trust level as a package script.
|
|
291
|
-
// `sh`
|
|
292
|
-
//
|
|
293
|
-
|
|
291
|
+
// Git for Windows' `sh` on Windows, where `/bin/sh` does not exist and no
|
|
292
|
+
// reviewer could run at all (chore-windows-ci) — found off PATH too, and
|
|
293
|
+
// left as a bare `sh` to fail as `did not run` when there is none.
|
|
294
|
+
child = spawnFn(process.platform === 'win32' ? resolveShell() || 'sh' : '/bin/sh', ['-c', rendered], {
|
|
294
295
|
cwd: worktree,
|
|
295
296
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
296
297
|
// THE CHILD LEADS ITS OWN PROCESS GROUP, and the timeout below depends
|
package/src/env/supervise.js
CHANGED
|
@@ -67,11 +67,48 @@ function readPid(pidFileAbs) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The shell a planned `command` runs through, or null when there is none.
|
|
72
|
+
*
|
|
73
|
+
* POSIX: `sh` from PATH, as it always was. Windows: `sh` only exists where Git
|
|
74
|
+
* for Windows put its `bin` on PATH, and a `cmd /c` session (a VM driven from
|
|
75
|
+
* another host, a scheduled task) commonly has Git installed and not on PATH.
|
|
76
|
+
* So PATH first, then Git's own install locations, then the `bin` beside a
|
|
77
|
+
* `git.exe` that IS on PATH (`Git\cmd\git.exe` → `Git\bin\sh.exe`).
|
|
78
|
+
*
|
|
79
|
+
* WHAT WOULD FOOL THIS: Git installed somewhere none of those name — a scoop
|
|
80
|
+
* shim, a portable copy. Then the answer is null, and the caller refuses with
|
|
81
|
+
* a reason rather than spawning something that is not there.
|
|
82
|
+
*/
|
|
83
|
+
function resolveShell({ platform = process.platform, env = process.env, exists = fs.existsSync } = {}) {
|
|
84
|
+
if (platform !== 'win32') return 'sh'
|
|
85
|
+
const w = path.win32
|
|
86
|
+
const dirs = String(env.PATH || env.Path || '').split(';').filter(Boolean)
|
|
87
|
+
const candidates = dirs.map((d) => w.join(d, 'sh.exe'))
|
|
88
|
+
for (const base of [env.ProgramFiles, env.ProgramW6432, env['ProgramFiles(x86)']]) {
|
|
89
|
+
if (base) candidates.push(w.join(base, 'Git', 'bin', 'sh.exe'))
|
|
90
|
+
}
|
|
91
|
+
if (env.LOCALAPPDATA) candidates.push(w.join(env.LOCALAPPDATA, 'Programs', 'Git', 'bin', 'sh.exe'))
|
|
92
|
+
for (const d of dirs) {
|
|
93
|
+
if (exists(w.join(d, 'git.exe'))) candidates.push(w.join(d, '..', 'bin', 'sh.exe'))
|
|
94
|
+
}
|
|
95
|
+
return candidates.find((c) => exists(c)) || null
|
|
96
|
+
}
|
|
97
|
+
|
|
70
98
|
/**
|
|
71
99
|
* Start one planned process detached, appending stdout+stderr to its log and
|
|
72
100
|
* writing its pid file. Idempotent: if the pid file already names a live
|
|
73
101
|
* process, nothing is spawned — returns `{ started: false, pid }`.
|
|
74
102
|
*
|
|
103
|
+
* A proc carrying `argv` is spawned as exactly that, with no shell — the review
|
|
104
|
+
* server and the proxy are `node <script> <file>` and never needed one. A proc
|
|
105
|
+
* carrying only `command` runs through `resolveShell`.
|
|
106
|
+
*
|
|
107
|
+
* NEVER THROWS OVER A SPAWN THAT FAILED. A missing executable is reported as
|
|
108
|
+
* `{ started: false, pid: null, error }` with no pid file written: the ENOENT
|
|
109
|
+
* otherwise arrives as an unhandled 'error' event and takes the CLI down with
|
|
110
|
+
* it (bug-review-serve-spawn-sh).
|
|
111
|
+
*
|
|
75
112
|
* `spawnImpl` is injectable for tests; defaults to child_process.spawn.
|
|
76
113
|
*/
|
|
77
114
|
function startProcess(proc, { cwd, rootDir, spawnImpl = spawn }) {
|
|
@@ -83,19 +120,44 @@ function startProcess(proc, { cwd, rootDir, spawnImpl = spawn }) {
|
|
|
83
120
|
return { started: false, pid: existing, logFile: logAbs, pidFile: pidAbs }
|
|
84
121
|
}
|
|
85
122
|
|
|
123
|
+
const env = { ...process.env, ...proc.env }
|
|
124
|
+
let file
|
|
125
|
+
let args
|
|
126
|
+
if (proc.argv) {
|
|
127
|
+
;[file, ...args] = proc.argv
|
|
128
|
+
} else {
|
|
129
|
+
file = resolveShell({ env })
|
|
130
|
+
args = ['-c', proc.command]
|
|
131
|
+
if (!file) {
|
|
132
|
+
const error = 'no sh found — install Git for Windows or put its bin folder on PATH'
|
|
133
|
+
return { started: false, pid: null, error, logFile: logAbs, pidFile: pidAbs }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
86
137
|
fs.mkdirSync(path.dirname(logAbs), { recursive: true })
|
|
87
138
|
fs.mkdirSync(path.dirname(pidAbs), { recursive: true })
|
|
88
139
|
|
|
89
140
|
const out = fs.openSync(logAbs, 'a')
|
|
90
141
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
142
|
+
let child
|
|
143
|
+
try {
|
|
144
|
+
child = spawnImpl(file, args, {
|
|
145
|
+
cwd,
|
|
146
|
+
env,
|
|
147
|
+
detached: true,
|
|
148
|
+
// No console window per dev server on Windows; nothing anywhere else.
|
|
149
|
+
windowsHide: true,
|
|
150
|
+
stdio: ['ignore', out, out],
|
|
151
|
+
})
|
|
152
|
+
} catch (err) {
|
|
153
|
+
return { started: false, pid: null, error: `spawn ${file}: ${err.message}`, logFile: logAbs, pidFile: pidAbs }
|
|
154
|
+
}
|
|
155
|
+
// A spawn that could not start has no pid, and its error is emitted on the
|
|
156
|
+
// next tick — the listener is what keeps that from being fatal.
|
|
157
|
+
child.on('error', () => {})
|
|
158
|
+
if (!child.pid) {
|
|
159
|
+
return { started: false, pid: null, error: `could not start ${file}`, logFile: logAbs, pidFile: pidAbs }
|
|
160
|
+
}
|
|
99
161
|
child.unref()
|
|
100
162
|
fs.writeFileSync(pidAbs, `${child.pid}\n`)
|
|
101
163
|
return { started: true, pid: child.pid, logFile: logAbs, pidFile: pidAbs }
|
|
@@ -167,4 +229,4 @@ async function waitHealthy(
|
|
|
167
229
|
// therefore kills the wrapper, leaves the server holding its port, and then
|
|
168
230
|
// blames whatever it asserts next. Killing the group is what `stopProcess` does
|
|
169
231
|
// and what a test must do to mean "it died".
|
|
170
|
-
module.exports = { startProcess, stopProcess, waitHealthy, isAlive, readPid, signalGroup }
|
|
232
|
+
module.exports = { startProcess, stopProcess, waitHealthy, isAlive, readPid, signalGroup, resolveShell }
|