@skitterbyte/skitterspec-jira 2.16.0 → 2.17.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/src/cli.js CHANGED
@@ -103,6 +103,9 @@ const {
103
103
  readReceipt,
104
104
  writeReceipt,
105
105
  clearReceipt,
106
+ readLastLive,
107
+ writeLastLive,
108
+ clearLastLive,
106
109
  summarizeReceipt,
107
110
  migrationsHit,
108
111
  depsChanged,
@@ -127,15 +130,9 @@ const {
127
130
  renderReviewBlock,
128
131
  reviewOutPath,
129
132
  reviewFileUrl,
130
- reviewUrlPath,
131
- reviewPublishPath,
132
133
  readReviewUrl,
133
- readRemoteAllow,
134
- writeRemoteAllow,
135
- withSpecRemote,
136
134
  publishedPageNotice,
137
135
  reviewServerNotice,
138
- renderReviewFragment,
139
136
  resolveReader,
140
137
  writeReviewPage,
141
138
  reviewNotesPath,
@@ -1065,7 +1062,7 @@ async function serveTadaPage({ window, flags, recap }) {
1065
1062
  const withQ = (u) => (u ? `${u}${q}` : u)
1066
1063
  const page = { ...served, loopbackUrl: withQ(served.loopbackUrl), url: withQ(served.url), alternates: (served.alternates || []).map(withQ) }
1067
1064
  const reader = resolveReader(config, process.env, process.platform)
1068
- const tiers = reviewTierStack({ served: page, fileUrl: null, publishedUrl: null, config, reader })
1065
+ const tiers = reviewTierStack({ served: page, fileUrl: null, config, reader })
1069
1066
  process.stdout.write(`page: ${humanLabel(window)}\n${reviewStackText(tiers)}`)
1070
1067
  return true
1071
1068
  }
@@ -1171,7 +1168,7 @@ function epicPageTiers(inputs, up, epic) {
1171
1168
  if (!up) return { off: true, start: 'skitterspec spec-env review serve --host 0.0.0.0' }
1172
1169
  const served = reviewServedUrls(up, offerableLanAddresses(), epic)
1173
1170
  const reader = resolveReader(inputs.config, process.env, process.platform)
1174
- return { tiers: reviewTierStack({ served, fileUrl: null, publishedUrl: null, config: inputs.config, reader }) }
1171
+ return { tiers: reviewTierStack({ served, fileUrl: null, config: inputs.config, reader }) }
1175
1172
  }
1176
1173
 
1177
1174
  function epicPageLines(page) {
@@ -2763,6 +2760,10 @@ function specEnvDown(dir, config, specArg, flags) {
2763
2760
  writeRegistry(dir, config, next)
2764
2761
  }
2765
2762
 
2763
+ // A torn-down spec is no longer anything a bare resolve should name.
2764
+ const last = readLastLive(dir, config)
2765
+ if (last && last.spec === spec.folder) clearLastLive(dir, config)
2766
+
2766
2767
  const out = []
2767
2768
  out.push(
2768
2769
  `spec-env down: ${spec.folder}` +
@@ -2887,47 +2888,73 @@ function volumeCreatedAt(names) {
2887
2888
  * `soleProvisionedSpec` below is a thin wrapper that turns the two empty-handed
2888
2889
  * cases into the exact errors every other subcommand already relies on.
2889
2890
  */
2890
- function provisionedSpecChoice(dir, config, cwd = process.cwd()) {
2891
+ function provisionedSpecChoice(dir, config, cwd = process.cwd(), { lastLive = true } = {}) {
2891
2892
  const worktreePaths = liveWorktreePaths(gitReader(dir))
2892
2893
  const provisioned = allSpecs(dir, config, worktreePaths, speclessMap(dir, config))
2893
- .map((s) => ({ folder: s.folder, wt: path.resolve(s.worktreePath) }))
2894
+ .map((s) => ({ folder: s.folder, wt: path.resolve(s.worktreePath), project: s.projectPath }))
2894
2895
  // The primary checkout is itself in `git worktree list`; a spec is
2895
2896
  // provisioned only when it has its OWN worktree, separate from it.
2896
2897
  .filter((s) => s.wt !== dir && worktreePaths.has(s.wt))
2897
2898
  .sort((a, b) => a.folder.localeCompare(b.folder))
2899
+ // The project folder, which is what `resolve` prints as `worktree:` and what
2900
+ // `/spec-next --worktree` is checked against — the worktree root only differs
2901
+ // when the project sits below the git root.
2902
+ const worktrees = provisioned.map((s) => ({ spec: s.folder, worktree: s.project }))
2898
2903
 
2899
2904
  // 1. Standing inside a spec's worktree names it outright. Deepest match wins,
2900
2905
  // so a nested worktree is not shadowed by an ancestor one.
2901
- let here
2902
- try {
2903
- here = fs.realpathSync.native(path.resolve(cwd))
2904
- } catch {
2905
- here = path.resolve(cwd)
2906
+ const real = (p) => {
2907
+ try {
2908
+ return fs.realpathSync.native(path.resolve(p))
2909
+ } catch {
2910
+ return path.resolve(p)
2911
+ }
2906
2912
  }
2913
+ const here = real(cwd)
2907
2914
  const inside = provisioned
2908
2915
  .filter((s) => here === s.wt || here.startsWith(s.wt + path.sep))
2909
2916
  .sort((a, b) => b.wt.length - a.wt.length)[0]
2910
- if (inside) return { folder: inside.folder }
2917
+ if (inside) return { folder: inside.folder, via: 'here', worktrees }
2911
2918
 
2912
- // 2. Otherwise only an unambiguous set answers.
2913
- if (provisioned.length === 1) return { folder: provisioned[0].folder }
2914
- return { candidates: provisioned.map((s) => s.folder) }
2919
+ // 2. From the primary checkout, the spec `live release` last handed back
2920
+ // (bug-live-release-forgets-spec) — only while it is still provisioned, so
2921
+ // a record outliving its worktree falls through as cannot-tell. Nowhere
2922
+ // else: the record is this checkout's, and says nothing about other cwds.
2923
+ const primary = real(dir)
2924
+ if (lastLive && (here === primary || here.startsWith(primary + path.sep))) {
2925
+ const record = readLastLive(dir, config)
2926
+ const hit = record && provisioned.find((s) => s.folder === record.spec)
2927
+ if (hit) return { folder: hit.folder, via: 'last-live', worktrees }
2928
+ }
2929
+
2930
+ // 3. Otherwise only an unambiguous set answers.
2931
+ if (provisioned.length === 1) return { folder: provisioned[0].folder, via: 'sole', worktrees }
2932
+ return { candidates: provisioned.map((s) => s.folder), worktrees }
2915
2933
  }
2916
2934
 
2917
2935
  function soleProvisionedSpec(dir, config, cwd = process.cwd()) {
2918
- const { folder, candidates } = provisionedSpecChoice(dir, config, cwd)
2919
- if (folder) return folder
2920
- if (!candidates.length) {
2921
- throw new Error(
2922
- 'no spec given, and no spec has a worktree — name one explicitly, or run ' +
2923
- '/spec-start to provision it.',
2924
- )
2925
- }
2926
- throw new Error(
2927
- `no spec given, and ${candidates.length} specs have worktrees — name the one ` +
2928
- `you mean, or run this from inside one:\n` +
2929
- candidates.map((f, i) => ` ${i + 1}. ${f}`).join('\n'),
2930
- )
2936
+ return provisionedSpecChoiceOrThrow(dir, config, cwd).folder
2937
+ }
2938
+
2939
+ // `provisionedSpecChoice`, with the two empty-handed cases turned into the
2940
+ // errors every subcommand relies on. Each carries `reason` ('ambiguous' |
2941
+ // 'none') and the worktrees, so `resolve --json` can report it as data.
2942
+ function provisionedSpecChoiceOrThrow(dir, config, cwd = process.cwd()) {
2943
+ const choice = provisionedSpecChoice(dir, config, cwd)
2944
+ if (choice.folder) return choice
2945
+ const err = !choice.candidates.length
2946
+ ? new Error(
2947
+ 'no spec given, and no spec has a worktree — name one explicitly, or run ' +
2948
+ '/spec-start to provision it.',
2949
+ )
2950
+ : new Error(
2951
+ `no spec given, and ${choice.candidates.length} specs have worktrees — name the one ` +
2952
+ `you mean, or run this from inside one:\n` +
2953
+ choice.worktrees.map((w, i) => ` ${i + 1}. ${w.spec} (${w.worktree})`).join('\n'),
2954
+ )
2955
+ err.reason = choice.candidates.length ? 'ambiguous' : 'none'
2956
+ err.candidates = choice.worktrees
2957
+ throw err
2931
2958
  }
2932
2959
 
2933
2960
  // Resolve a spec argument the ONE way every spec-env subcommand resolves it:
@@ -4496,14 +4523,60 @@ function assertPrimaryClean(dir, config, r) {
4496
4523
  }
4497
4524
 
4498
4525
  // Print the resolved identity/coordinates for a single spec.
4526
+ const RESOLVED_VIA = {
4527
+ here: 'the worktree you are standing in',
4528
+ 'last-live': 'last live on this checkout',
4529
+ sole: 'the only spec provisioned',
4530
+ }
4531
+
4499
4532
  function specEnvResolve(dir, config, specArg, flags = {}) {
4533
+ // Bare, say HOW it resolved as well as what: a caller standing in the primary
4534
+ // checkout cannot see which rung answered. `--json` also reports the two
4535
+ // empty-handed cases as data — `ambiguous` and `none` call for different
4536
+ // next steps, and a skill should not tell them apart by an Error's wording.
4537
+ let via = 'named'
4538
+ if (!specArg) {
4539
+ try {
4540
+ const choice = provisionedSpecChoiceOrThrow(dir, config)
4541
+ specArg = choice.folder
4542
+ via = choice.via
4543
+ } catch (err) {
4544
+ if (!flags.json || !err.reason) throw err
4545
+ process.stdout.write(
4546
+ JSON.stringify({ ok: false, reason: err.reason, error: err.message, candidates: err.candidates }, null, 2) +
4547
+ '\n',
4548
+ )
4549
+ return
4550
+ }
4551
+ }
4500
4552
  const r = resolveSpecWithWorktree(dir, config, specArg)
4501
4553
  if (flags.recordPrimary) return recordPrimary(dir, config, r)
4502
4554
  if (flags.assertPrimaryClean) return assertPrimaryClean(dir, config, r)
4555
+ if (flags.json) {
4556
+ process.stdout.write(
4557
+ JSON.stringify(
4558
+ {
4559
+ ok: true,
4560
+ spec: r.folder,
4561
+ via,
4562
+ bucket: r.specless ? null : r.bucket,
4563
+ type: r.type,
4564
+ slug: r.slug,
4565
+ branch: r.branch,
4566
+ worktree: r.projectPath,
4567
+ project: r.projectName,
4568
+ },
4569
+ null,
4570
+ 2,
4571
+ ) + '\n',
4572
+ )
4573
+ return
4574
+ }
4503
4575
  process.stdout.write(
4504
4576
  // A specless branch has no bucket because it has no document — say that
4505
4577
  // rather than printing `(null)`, which reads as a lookup that failed.
4506
4578
  `spec: ${r.folder} (${r.specless ? 'no spec' : r.bucket})\n` +
4579
+ (RESOLVED_VIA[via] ? `via: ${RESOLVED_VIA[via]}\n` : '') +
4507
4580
  `type/slug: ${r.type} / ${r.slug}\n` +
4508
4581
  `branch: ${r.branch}\n` +
4509
4582
  `worktree: ${r.projectPath}\n` +
@@ -5121,11 +5194,11 @@ function readRunningReviewServer(dir, config) {
5121
5194
  * the same functions, with nothing rendered and nothing started.
5122
5195
  */
5123
5196
  function reshowStack(dir, config, spec, out) {
5124
- const cfg = withSpecRemote(config, out)
5197
+ const cfg = config
5125
5198
  const up = readRunningReviewServer(dir, cfg)
5126
5199
  const served = up ? reviewServedUrls(up, offerableLanAddresses(), spec.folder) : null
5127
5200
  const reader = resolveReader(cfg, process.env, process.platform)
5128
- const tiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), publishedUrl: readReviewUrl(out), config: cfg, reader })
5201
+ const tiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), config: cfg, reader })
5129
5202
  let live = null
5130
5203
  try {
5131
5204
  const primaryState = assertPrimaryOnMain(cfg, gitReader(dir))
@@ -5444,101 +5517,74 @@ function specEnvReviewGate(dir, config, specArg, flags, invokedFrom = dir) {
5444
5517
  }
5445
5518
 
5446
5519
  /**
5447
- * `review allow <network|remote> [<spec>] [--off | --set <on|off|>] [--project]`
5448
- * — permit or withdraw a review tier.
5449
- *
5450
- * TWO SCOPES, because the two tiers are different kinds of decision.
5520
+ * `review allow network [--off | --set <on|off|>]` — permit or withdraw the
5521
+ * served tiers beyond loopback.
5451
5522
  *
5452
5523
  * `network` is a BIND, and one server binds for every spec at once — so it is a
5453
- * project setting and lives in the committed `env.config.json`.
5524
+ * project setting and lives in the committed `env.config.json`. `remote` is the
5525
+ * tailnet address of that same server, so this one switch covers it too.
5454
5526
  *
5455
- * `remote` PERMITS PUBLISHING, which sends one spec's diff to a third party. It
5456
- * was project-wide too, and that was bug-remote-review-toggle: typed from a
5457
- * worktree with a review waiting, it dirtied the base branch's committed config
5458
- * and permitted every other spec in the repo to publish as well. So it is now
5459
- * PER SPEC — a sidecar in the gitignored review store, layered over the
5460
- * committed key by `withSpecRemote`. `--project` keeps the committed write for
5461
- * a team that wants it everywhere.
5527
+ * `allow remote` used to permit publishing the review as a claude.ai page,
5528
+ * per spec. That tier is retired (feat-tailnet-remote-tier), and the verb
5529
+ * refuses by name rather than quietly doing the network thing: a person who
5530
+ * typed it wanted something specific, and should hear where it went.
5462
5531
  *
5463
- * THE COMMITTED WRITE IS NARROW: it reads, sets one key under `review`, and
5464
- * writes back with two-space indent. It never reorders, never adds a key nobody
5465
- * asked for, and never touches another section.
5532
+ * THE WRITE IS NARROW: it reads, sets one key under `review`, and writes back
5533
+ * with two-space indent. It never reorders, never adds a key nobody asked for,
5534
+ * and never touches another section.
5466
5535
  *
5467
5536
  * WHAT WOULD FOOL THIS: a config indented with anything other than two spaces
5468
- * IS reformatted by the committed write — cosmetic, but worth knowing before it
5469
- * shows up in someone's diff. A config with comments already fails to load, so
5470
- * there is no comment-preserving case to protect.
5537
+ * IS reformatted by the write — cosmetic, but worth knowing before it shows up
5538
+ * in someone's diff. A config with comments already fails to load, so there is
5539
+ * no comment-preserving case to protect.
5471
5540
  */
5472
- function specEnvReviewAllow(dir, config, tier, specArg, flags) {
5473
- const TIERS = { network: 'allowNetwork', remote: 'allowRemote' }
5474
- const key = TIERS[String(tier || '').trim()]
5475
- if (!key) {
5541
+ function specEnvReviewAllow(dir, config, tier, _specArg, flags) {
5542
+ const said = String(tier || '').trim()
5543
+ if (said === 'remote') {
5544
+ process.stdout.write(
5545
+ 'spec-env review allow: remote is no longer a setting — publishing the review was retired.\n' +
5546
+ ' `remote:` is now the tailnet address of the review server, on whenever network is.\n' +
5547
+ ' Nothing changed.\n',
5548
+ )
5549
+ process.exitCode = 1
5550
+ return
5551
+ }
5552
+ if (said !== 'network') {
5476
5553
  // Refused by name, never coerced to a default: silently permitting the
5477
5554
  // wrong tier is the one outcome worth more than a round trip.
5478
5555
  process.stdout.write(
5479
- `spec-env review allow: ${JSON.stringify(tier || '')} is not a tier — ` +
5480
- `one of ${Object.keys(TIERS).join(', ')}. Nothing changed.\n`,
5556
+ `spec-env review allow: ${JSON.stringify(tier || '')} is not a tier — network is the one ` +
5557
+ 'setting. Nothing changed.\n',
5481
5558
  )
5482
5559
  process.exitCode = 1
5483
5560
  return
5484
5561
  }
5562
+ const key = 'allowNetwork'
5485
5563
 
5486
- // WHICH SPEC, for the per-spec scope — resolved before anything is read, so a
5487
- // refusal changes nothing. An unknown name throws rather than falling back:
5488
- // permitting the wrong spec to publish looks exactly like permitting the
5489
- // right one.
5490
- const perSpec = key === 'allowRemote' && !flags.project
5491
- let spec = null
5492
- let out = null
5493
- if (perSpec) {
5494
- try {
5495
- spec = resolveSpecWithWorktree(dir, config, specArg)
5496
- } catch (err) {
5497
- process.stdout.write(
5498
- `spec-env review allow: ${err.message}\n` +
5499
- ' remote is permitted per spec — name it, or run this from its worktree.\n' +
5500
- ' --project permits every spec instead (writes the committed env.config.json).\n' +
5501
- ' Nothing changed.\n',
5502
- )
5503
- process.exitCode = 1
5504
- return
5505
- }
5506
- out = reviewOutPath(dir, spec.folder, null)
5507
- }
5508
-
5509
- // What the tier is now, through the same precedence the render uses — so a
5510
- // toggle means "the other thing the render showed".
5511
5564
  const file = path.resolve(dir, 'specs/.core/env.config.json')
5512
- const committed = () => {
5565
+ const current = () => {
5513
5566
  try {
5514
5567
  const now = JSON.parse(fs.readFileSync(file, 'utf8'))
5515
- return now.review && now.review[key] !== undefined ? now.review[key] : config.review[key]
5568
+ return Boolean(now.review && now.review[key] !== undefined ? now.review[key] : config.review[key])
5516
5569
  } catch {
5517
- return config.review[key]
5570
+ return Boolean(config.review[key])
5518
5571
  }
5519
5572
  }
5520
- const current = () => {
5521
- if (perSpec) {
5522
- const own = readRemoteAllow(out)
5523
- if (own !== null) return own
5524
- }
5525
- return Boolean(committed())
5526
- }
5527
5573
 
5528
- // THREE WAYS TO SAY WHAT THE TIER SHOULD BE. Bare `allow <tier>` turns it ON
5574
+ // THREE WAYS TO SAY WHAT THE TIER SHOULD BE. Bare `allow network` turns it ON
5529
5575
  // and `--off` turns it off, exactly as they always have. `--set` exists
5530
5576
  // because a SLASH COMMAND can only make one static substitution: the word the
5531
5577
  // person typed reaches the engine as a word. An EMPTY value toggles.
5532
5578
  let on = !flags.off
5533
5579
  if (flags.set !== undefined) {
5534
- const said = String(flags.set).trim().toLowerCase()
5535
- if (said === '') {
5580
+ const state = String(flags.set).trim().toLowerCase()
5581
+ if (state === '') {
5536
5582
  on = !current()
5537
- } else if (said === 'on' || said === 'off') {
5538
- on = said === 'on'
5583
+ } else if (state === 'on' || state === 'off') {
5584
+ on = state === 'on'
5539
5585
  } else {
5540
5586
  // Refused by name, like an unknown tier. The wrong default here opens a
5541
- // port or permits a publish.
5587
+ // port.
5542
5588
  process.stdout.write(
5543
5589
  `spec-env review allow: ${JSON.stringify(String(flags.set))} is not a state — ` +
5544
5590
  'one of on, off, or nothing at all to toggle. Nothing changed.\n',
@@ -5549,76 +5595,35 @@ function specEnvReviewAllow(dir, config, tier, specArg, flags) {
5549
5595
  }
5550
5596
 
5551
5597
  const before = current()
5552
- let wrote
5553
- if (perSpec) {
5554
- wrote = writeRemoteAllow(out, on)
5555
- } else {
5556
- let parsed
5557
- try {
5558
- parsed = JSON.parse(fs.readFileSync(file, 'utf8'))
5559
- } catch (err) {
5560
- // Cannot tell what is in there, so write nothing. Reachable only if the
5561
- // file changes between `loadEnvConfig` and here — that load already
5562
- // refuses an unparseable config.
5563
- process.stdout.write(
5564
- `spec-env review allow: ${file} could not be read as JSON (${err.message}) — ` +
5565
- 'nothing changed.\n',
5566
- )
5567
- process.exitCode = 1
5568
- return
5569
- }
5570
- parsed.review = { ...(parsed.review || {}), [key]: on }
5571
- fs.writeFileSync(file, JSON.stringify(parsed, null, 2) + '\n')
5572
- wrote = file
5598
+ let parsed
5599
+ try {
5600
+ parsed = JSON.parse(fs.readFileSync(file, 'utf8'))
5601
+ } catch (err) {
5602
+ // Cannot tell what is in there, so write nothing. Reachable only if the
5603
+ // file changes between `loadEnvConfig` and here — that load already
5604
+ // refuses an unparseable config.
5605
+ process.stdout.write(
5606
+ `spec-env review allow: ${file} could not be read as JSON (${err.message}) — ` +
5607
+ 'nothing changed.\n',
5608
+ )
5609
+ process.exitCode = 1
5610
+ return
5573
5611
  }
5612
+ parsed.review = { ...(parsed.review || {}), [key]: on }
5613
+ fs.writeFileSync(file, JSON.stringify(parsed, null, 2) + '\n')
5574
5614
 
5575
5615
  const lines = [
5576
- `spec-env review allow: ${tier} reviews${spec ? ` for ${spec.folder}` : ''} are now ${on ? 'ON' : 'OFF'}` +
5577
- (before === on ? ' (unchanged)' : ''),
5616
+ `spec-env review allow: network reviews are now ${on ? 'ON' : 'OFF'}` + (before === on ? ' (unchanged)' : ''),
5578
5617
  // THE ABSOLUTE PATH. `dir` is re-anchored to the primary checkout, so run
5579
5618
  // from a worktree this writes in a different tree — and a relative path
5580
5619
  // reads as the tree you are standing in.
5581
- ` wrote: ${wrote}`,
5620
+ ` wrote: ${file}`,
5621
+ ' that is the primary checkout, whichever tree you ran this from, and the file is',
5622
+ ' COMMITTED — so it changes for everyone who pulls, and leaves that tree dirty.',
5623
+ on
5624
+ ? ' the next render binds every interface, so the page opens on your phone and your tailnet.'
5625
+ : ' the next render binds 127.0.0.1 only, reachable from this machine.',
5582
5626
  ]
5583
- if (perSpec) {
5584
- lines.push(' this spec only, in the gitignored review store — the committed config is untouched.')
5585
- } else {
5586
- lines.push(
5587
- ' that is the primary checkout, whichever tree you ran this from, and the file is',
5588
- ' COMMITTED — so it changes for everyone who pulls, and leaves that tree dirty.',
5589
- )
5590
- }
5591
- if (key === 'allowNetwork') {
5592
- lines.push(
5593
- on
5594
- ? ' the next render binds every interface, so the page opens on your phone.'
5595
- : ' the next render binds 127.0.0.1 only, reachable from this machine.',
5596
- )
5597
- } else if (!on) {
5598
- lines.push(
5599
- ' publishing is no longer permitted; any page already published stays up.\n' +
5600
- ' turn it back on with: /spec-remote-review',
5601
- )
5602
- } else {
5603
- lines.push(
5604
- ' a published page cannot be deleted by skitterspec,\n' +
5605
- ' and a verdict there needs /spec-reviewed.\n' +
5606
- ' turn it back off with: /spec-remote-review',
5607
- )
5608
- // THE REVIEW IT WAS TYPED FOR. The banner names this command beside a page
5609
- // the reader cannot reach, so turning remote on is the ask to publish THAT
5610
- // page — and saying nothing about it left the reader with no link at all.
5611
- // A page on disk is the positive signal; with none there is nothing to
5612
- // publish, and nothing is named.
5613
- if (spec && fs.existsSync(out)) {
5614
- lines.push(
5615
- ` review: ${spec.folder} has a page — publish it and re-show the stack`,
5616
- ` publish: skitterspec spec-env review ${spec.folder} --publish-copy`,
5617
- )
5618
- } else {
5619
- lines.push(' this PERMITS publishing; it publishes nothing.')
5620
- }
5621
- }
5622
5627
  process.stdout.write(lines.join('\n') + '\n')
5623
5628
  }
5624
5629
 
@@ -5730,9 +5735,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
5730
5735
  // CHECKOUT, keyed by the spec's folder name; not one byte of it comes from
5731
5736
  // the worktree. `--out` moves the page and its sidecars together.
5732
5737
  const out = reviewOutPath(dir, spec.folder, flags.out)
5733
- // This spec's own remote permission over the project default — a
5734
- // per-worktree decision, never the committed config (bug-remote-review-toggle).
5735
- config = withSpecRemote(config, out)
5736
5738
 
5737
5739
  // The other half of a confirmation: a pass the operator says is not theirs.
5738
5740
  // Left in the store it is reported on every render until they stop reading the
@@ -6451,21 +6453,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6451
6453
  /* the page is the artefact; this is a note for the daemon */
6452
6454
  }
6453
6455
 
6454
- // The publish-ready copy, ONLY when asked. An ordinary render must not pay for
6455
- // a second copy of the whole diff on disk for a path most renders never take.
6456
- let publishCopy = null
6457
- if (flags.publishCopy) {
6458
- publishCopy = reviewPublishPath(out)
6459
- writeReviewPage(
6460
- publishCopy,
6461
- renderReviewFragment(data, { reviewHtml: renderReviewBlock(data.review) }),
6462
- )
6463
- }
6464
-
6465
- // Read, never written, and never interpreted: the engine cannot publish, and
6466
- // names this file only so the skill that can never has to build a path.
6467
- const urlFile = reviewUrlPath(out)
6468
- const url = readReviewUrl(out)
6469
6456
 
6470
6457
  // Resolved before the --json early return, so both outputs agree.
6471
6458
  const reader = resolveReader(config, process.env, process.platform)
@@ -6537,7 +6524,7 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6537
6524
 
6538
6525
  // ONE STACK for both outputs, so `--json` and the text cannot disagree about
6539
6526
  // which tiers exist — or which one is hidden.
6540
- const stackTiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), publishedUrl: url, config, reader })
6527
+ const stackTiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), config, reader })
6541
6528
 
6542
6529
  if (flags.json) {
6543
6530
  process.stdout.write(
@@ -6559,7 +6546,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6559
6546
  // project folder.
6560
6547
  ...(docs ? { docs: { paths: docs.owned.map((p) => projectRelative(p, prefixOf(config))) } } : {}),
6561
6548
  out,
6562
- publishCopy,
6563
6549
  reader: reader.reader,
6564
6550
  readerWhy: reader.why,
6565
6551
  served,
@@ -6580,8 +6566,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6580
6566
  ...(served ? {} : noServeBecause ? { notServed: noServeBecause } : {}),
6581
6567
  ...(serverSaid ? { server: serverSaid } : {}),
6582
6568
  fileUrl: reviewFileUrl(out),
6583
- urlFile,
6584
- url,
6585
6569
  notesFile: reviewNotesPath(out),
6586
6570
  // Absent stays absent, exactly as it is in the page payload: the
6587
6571
  // committing set is what a caller that did not ask always got, so
@@ -6688,16 +6672,15 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6688
6672
  // use, and the engine cannot know — that guess failed three separate ways
6689
6673
  // in one day. Now every tier is listed, labelled, and either a URL or the
6690
6674
  // one command that turns it on.
6691
- // The runners-up print as `also:` lines inside the network tier's own
6692
- // rendering — `reviewTierLine` carries them, which is what puts them
6693
- // under `network:` rather than dangling after the stack (they used to
6694
- // print below `remote:`, against the comment that placed them).
6675
+ // Any runners-up print as `also:` lines inside their tier's own
6676
+ // rendering — `reviewTierLine` carries them.
6695
6677
  reviewStackText(stackTiers) +
6696
- // WHICH TIERS THE WAIT COVERS, once, next to the stack. `local` and
6697
- // `network` are two doors into one room — the page POSTs to
6698
- // `location.pathname`, so both reach this server and this pending store.
6699
- // `remote` writes to the artifact's own store, which nothing here can see.
6700
- ` the wait covers ${waitCovers(stackTiers).join(' + ')}; a remote verdict needs /spec-reviewed.\n` +
6678
+ // WHICH TIERS THE WAIT COVERS, once, next to the stack. Every served door
6679
+ // is one room — the page POSTs to `location.pathname`, so each reaches
6680
+ // this server and this pending store.
6681
+ // Nothing at all for a `file://` page: there is no door to watch, and
6682
+ // the `not served:` line below says why.
6683
+ (waitCovers(stackTiers).length ? ` the wait covers ${waitCovers(stackTiers).join(' + ')}.\n` : '') +
6701
6684
  // WHETHER IT IS ALSO RUNNING SOMEWHERE, which is the other way to judge a
6702
6685
  // change. `unavailable` prints nothing — see `liveStateLine`.
6703
6686
  (liveStateLine(live) ? `${liveStateLine(live)}\n` : '') +
@@ -6711,9 +6694,6 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
6711
6694
  // One line, and only when something was actually done on the reader's
6712
6695
  // behalf. An action nobody asked for is reported, not hidden.
6713
6696
  (serverSaid ? ` ${serverSaid}\n` : '') +
6714
- // Named on its own line so the skill never has to build the path itself.
6715
- (publishCopy ? ` publish: ${publishCopy}\n` : '') +
6716
- (url ? ` published: ${url}\n` : '') +
6717
6697
  (t.files === 0 ? ' nothing to review — no changes found.\n' : ''),
6718
6698
  )
6719
6699
  }
@@ -7663,7 +7643,9 @@ function bareLive(dir, config) {
7663
7643
  return { action: 'status', specArg: undefined }
7664
7644
  }
7665
7645
 
7666
- const choice = provisionedSpecChoice(dir, config)
7646
+ // The last-live record is a hint for READING which spec you mean, never for a
7647
+ // bare command that switches a branch on it — that stays one possible meaning.
7648
+ const choice = provisionedSpecChoice(dir, config, process.cwd(), { lastLive: false })
7667
7649
  if (!choice.folder) {
7668
7650
  // Several worktrees is the only cannot-tell the status report does not
7669
7651
  // explain — it reports on the repo, not on what you might have meant. With
@@ -7835,6 +7817,9 @@ async function specEnvLiveTake(dir, config, specArg, flags = {}) {
7835
7817
  return
7836
7818
  }
7837
7819
  const receipt = writeReceipt(dir, config, plan.receipt)
7820
+ // Another spec is now the one on this checkout; the last release no longer is.
7821
+ const last = readLastLive(dir, config)
7822
+ if (last && last.spec !== spec.folder) clearLastLive(dir, config)
7838
7823
 
7839
7824
  const out = [`spec-env live take: ${spec.folder} is live on the primary checkout`]
7840
7825
  out.push('')
@@ -7906,10 +7891,17 @@ async function specEnvLiveRelease(dir, config, specArg) {
7906
7891
  }
7907
7892
  if (worktreeExists) runGit(spec.worktreePath, ['switch', spec.branch])
7908
7893
  clearReceipt(dir, config)
7894
+ // Remembered so a bare resolve from here still names this spec — the session
7895
+ // is now standing in the primary checkout, which says nothing on its own.
7896
+ writeLastLive(dir, config, { spec: spec.folder, worktree: spec.projectPath })
7909
7897
 
7910
7898
  process.stdout.write(
7911
7899
  `spec-env live release: ${spec.folder} released — primary back on ${base}, ` +
7912
7900
  `${spec.branch} re-isolated to its worktree.\n` +
7901
+ // The project folder, not the worktree root: it is what `/spec-next
7902
+ // --worktree` checks against `resolve`'s own `worktree:` line.
7903
+ ` worktree: ${spec.projectPath}\n` +
7904
+ ` next: /spec-next --worktree ${shellPath(spec.projectPath)}\n` +
7913
7905
  runAfterSwitch(plan.afterSwitch).lines.map((l) => `${l}\n`).join('') +
7914
7906
  plan.warnings.map((w) => ` ! ${w}\n`).join(''),
7915
7907
  )
@@ -8127,19 +8119,17 @@ async function specEnv(rest) {
8127
8119
  else if (args[i] === '--stop') flags.stop = true
8128
8120
  else if (args[i] === '--rotate-token') flags.rotateToken = true
8129
8121
  else if (args[i] === '--off') flags.off = true
8130
- else if (args[i] === '--project') flags.project = true
8131
8122
  else if (args[i] === '--status') flags.status = true
8132
8123
  else if (args[i] === '--port') flags.port = args[++i]
8133
8124
  else if (args[i] === '--host') flags.host = args[++i]
8134
- else if (args[i] === '--publish-copy') flags.publishCopy = true
8135
8125
  else if (args[i] === '--buttons') flags.buttons = args[++i]
8136
8126
  else if (args[i] === '--out') flags.out = args[++i]
8137
8127
  else if (args[i] === '--review') flags.review = args[++i]
8138
8128
  else if (args[i] === '--run-reviewers') flags.runReviewers = true
8139
8129
  else if (args[i] === '--notes') flags.notes = args[++i]
8140
8130
  else if (args[i] === '--verdict') flags.verdict = args[++i]
8141
- // `--set` keeps an EMPTY STRING rather than coercing it away: empty is the
8142
- // bare `/spec-remote-review`, and it means toggle. `??` so a missing value
8131
+ // `--set` keeps an EMPTY STRING rather than coercing it away: empty means
8132
+ // toggle. `??` so a missing value
8143
8133
  // at the end of argv is still the empty form rather than `undefined`, which
8144
8134
  // would read as the flag never having been passed.
8145
8135
  else if (args[i] === '--set') flags.set = args[++i] ?? ''
@@ -8382,7 +8372,7 @@ async function specEnvDispatch(sub, dir, config, positional, flags, present, inv
8382
8372
  `Usage: skitterspec spec-env <${SPEC_ENV_VERBS.join('|')}> [spec] [--keep-volumes] [--force] [--also <tag>] [--older-than <days>] [--branch] [--out <file>] [--review <json>] [--run-reviewers] [--notes <json>] [--verdict <word>] [--resolve <json>] [--outcome <text>] [--claim <code>] [--drop <code>] [--buttons <set>] [--json] [--record-primary] [--assert-primary-clean]\n` +
8383
8373
  ' review serve [--port <n>] [--host <addr>] [--stop] [--status] serve every diff locally\n' +
8384
8374
  ' review serve --rotate-token mint a new URL token; every handed-out link dies\n' +
8385
- ' review allow <network|remote> [<spec>] [--off] [--project] permit a review tier\n' +
8375
+ ' review allow network [--off] permit the network and tailnet tiers\n' +
8386
8376
  ' (network: env.config.json; remote: this spec only)\n' +
8387
8377
  ' review arm [spec] [--phase <n>] a phase ended — its diff now owes a verdict\n' +
8388
8378
  ' review gate [spec] [--check] [--json] is one owed? --check exits non-zero if so\n' +