pi-straw-boss 0.80.8 → 0.80.10

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.
@@ -207,7 +207,7 @@ var STANDIN_SOURCE = "straw-boss";
207
207
  var isStandin = (pane) => pane.agent === STANDIN_AGENT || pane.agent === STANDIN_HEAD;
208
208
  var lastSeq = 0;
209
209
  var nextSeq = (now = Date.now()) => lastSeq = Math.max(lastSeq + 1, now * 1e3);
210
- var reportStandin = (api, paneId, message, agent = STANDIN_AGENT) => api("pane.report_agent", { pane_id: paneId, source: STANDIN_SOURCE, agent, state: "idle", message, seq: nextSeq() });
210
+ var reportStandin = (api, paneId, message, agent = STANDIN_AGENT, state = "idle") => api("pane.report_agent", { pane_id: paneId, source: STANDIN_SOURCE, agent, state, message, seq: nextSeq() });
211
211
  var releaseStandin = (api, paneId, agent = STANDIN_AGENT) => api("pane.release_agent", { pane_id: paneId, source: STANDIN_SOURCE, agent, seq: nextSeq() });
212
212
  var isSub = (w) => w.worktree?.is_linked_worktree === true;
213
213
  var parentOf = (all, w) => all.find((p) => !isSub(p) && p.worktree?.repo_key !== void 0 && p.worktree.repo_key === w.worktree?.repo_key);
@@ -3703,8 +3703,11 @@ async function ensureTowerVia(ctx, ask2) {
3703
3703
  }
3704
3704
  }
3705
3705
 
3706
- // src/towerprompt/messages.ts
3707
- function localeOf(env) {
3706
+ // src/locale.ts
3707
+ import { chmodSync as chmodSync4, readFileSync as readFileSync11, realpathSync as realpathSync2, renameSync as renameSync7, rmSync as rmSync11, statSync as statSync6, writeFileSync as writeFileSync8 } from "node:fs";
3708
+ import { join as join11 } from "node:path";
3709
+ var isLocale = (value) => value === "zh-TW" || value === "en";
3710
+ function envLocale(env) {
3708
3711
  const set = env.LC_ALL || env.LC_MESSAGES || env.LANG || systemLanguage();
3709
3712
  return /^zh[_-](tw|hk|mo|hant)/i.test(set) ? "zh-TW" : "en";
3710
3713
  }
@@ -3715,6 +3718,19 @@ function systemLanguage() {
3715
3718
  return "en";
3716
3719
  }
3717
3720
  }
3721
+ var configOf = (stateDir) => join11(stateDir, "config.json");
3722
+ function localeSetting(stateDir) {
3723
+ if (!stateDir) return void 0;
3724
+ try {
3725
+ const value = JSON.parse(readFileSync11(configOf(stateDir), "utf8").replace(/^\uFEFF/, ""))?.locale;
3726
+ return isLocale(value) ? value : void 0;
3727
+ } catch {
3728
+ return void 0;
3729
+ }
3730
+ }
3731
+ var localeOf = (env, stateDir) => localeSetting(stateDir) ?? envLocale(env);
3732
+
3733
+ // src/towerprompt/messages.ts
3718
3734
  var EN = {
3719
3735
  title: (label2) => `tower \xB7 ${label2}`,
3720
3736
  head: "head tower",
@@ -3772,8 +3788,8 @@ var textsFor = (locale) => locale === "zh-TW" ? ZH : EN;
3772
3788
 
3773
3789
  // src/board.ts
3774
3790
  import { createHash as createHash6 } from "node:crypto";
3775
- import { chmodSync as chmodSync4, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync11, renameSync as renameSync7, rmSync as rmSync11, statSync as statSync6, writeFileSync as writeFileSync8 } from "node:fs";
3776
- import { join as join11 } from "node:path";
3791
+ import { chmodSync as chmodSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync12, renameSync as renameSync8, rmSync as rmSync12, statSync as statSync7, writeFileSync as writeFileSync9 } from "node:fs";
3792
+ import { join as join12 } from "node:path";
3777
3793
  var BOARD = { now: 120, item: 80, items: 8, label: 40 };
3778
3794
  var ENDED_MS = 30 * 6e4;
3779
3795
  var DEAD_MS = 24 * 36e5;
@@ -3795,9 +3811,9 @@ function cleanText(input) {
3795
3811
  return { now: clean(input.now, BOARD.now), items };
3796
3812
  }
3797
3813
  var safeSession = (session) => SAFE_SESSION.test(session);
3798
- var fileOf2 = (dir, session) => join11(dir, `${session}.json`);
3814
+ var fileOf2 = (dir, session) => join12(dir, `${session}.json`);
3799
3815
  function removeEntry(dir, session) {
3800
- if (safeSession(session)) rmSync11(fileOf2(dir, session), { force: true });
3816
+ if (safeSession(session)) rmSync12(fileOf2(dir, session), { force: true });
3801
3817
  }
3802
3818
  function readEntries(dir) {
3803
3819
  let names = [];
@@ -3809,7 +3825,7 @@ function readEntries(dir) {
3809
3825
  }
3810
3826
  function readOne(dir, name) {
3811
3827
  try {
3812
- const raw = JSON.parse(readFileSync11(join11(dir, name), "utf8"));
3828
+ const raw = JSON.parse(readFileSync12(join12(dir, name), "utf8"));
3813
3829
  const session = name.slice(0, -".json".length);
3814
3830
  if (raw?.v !== 1 || raw.session !== session || !safeSession(session) || typeof raw.updated !== "number" || !Number.isFinite(raw.updated) || typeof raw.now !== "string" || !Array.isArray(raw.items)) return [];
3815
3831
  if (!raw.items.every((i) => typeof i === "object" && i !== null && typeof i.t === "string" && typeof i.done === "boolean")) return [];
@@ -3827,8 +3843,8 @@ function purge(dir, live, now) {
3827
3843
  for (const entry of readEntries(dir)) if (due(entry) && readOne(dir, `${entry.session}.json`).every(due)) removeEntry(dir, entry.session);
3828
3844
  try {
3829
3845
  const known = new Set(readEntries(dir).map((e) => `${e.session}.json`));
3830
- for (const name of readdirSync3(dir)) if (name.endsWith(".json") && !known.has(name) && now - statSync6(join11(dir, name)).mtimeMs > DEAD_MS) rmSync11(join11(dir, name), { force: true });
3831
- for (const name of readdirSync3(dir)) if (name.endsWith(".tmp") && now - statSync6(join11(dir, name)).mtimeMs > DEAD_MS) rmSync11(join11(dir, name), { force: true });
3846
+ for (const name of readdirSync3(dir)) if (name.endsWith(".json") && !known.has(name) && now - statSync7(join12(dir, name)).mtimeMs > DEAD_MS) rmSync12(join12(dir, name), { force: true });
3847
+ for (const name of readdirSync3(dir)) if (name.endsWith(".tmp") && now - statSync7(join12(dir, name)).mtimeMs > DEAD_MS) rmSync12(join12(dir, name), { force: true });
3832
3848
  } catch {
3833
3849
  }
3834
3850
  }
@@ -4394,17 +4410,17 @@ function checkStages(stages) {
4394
4410
  }
4395
4411
 
4396
4412
  // src/train/appsconfig.ts
4397
- import { existsSync as existsSync8, readFileSync as readFileSync12, realpathSync as realpathSync2, statSync as statSync7 } from "node:fs";
4398
- import { basename as basename2, dirname as dirname6, join as join12, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
4413
+ import { existsSync as existsSync8, readFileSync as readFileSync13, realpathSync as realpathSync3, statSync as statSync8 } from "node:fs";
4414
+ import { basename as basename2, dirname as dirname6, join as join13, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
4399
4415
  var MIGRATION = "see docs/how-it-works.md, Moving a project to 0.65.0";
4400
4416
  function gitRoot(dir) {
4401
4417
  for (let d = dir; ; d = dirname6(d)) {
4402
- if (existsSync8(join12(d, ".git"))) return d;
4418
+ if (existsSync8(join13(d, ".git"))) return d;
4403
4419
  if (dirname6(d) === d) return dir;
4404
4420
  }
4405
4421
  }
4406
4422
  function appsFile(dir) {
4407
- const root = gitRoot(dir), first = join12(root, ".straw-boss", "apps.json"), second = join12(root, ".claude", "straw-boss", "apps.json");
4423
+ const root = gitRoot(dir), first = join13(root, ".straw-boss", "apps.json"), second = join13(root, ".claude", "straw-boss", "apps.json");
4408
4424
  const file = existsSync8(first) || !existsSync8(second) ? first : second;
4409
4425
  return { file, exists: existsSync8(file), both: `${first} or ${second}` };
4410
4426
  }
@@ -4412,7 +4428,7 @@ function readApps(dir) {
4412
4428
  const { file, both } = appsFile(dir);
4413
4429
  let text4;
4414
4430
  try {
4415
- text4 = readFileSync12(file, "utf8");
4431
+ text4 = readFileSync13(file, "utf8");
4416
4432
  } catch (error) {
4417
4433
  const missing2 = error.code === "ENOENT";
4418
4434
  return { ok: false, file: missing2 ? both : file, refusal: `${missing2 ? both : file} ${missing2 ? "is not there" : `cannot be read (${error.message})`}, so integration.accept of the app is unknown`, ...missing2 ? { missing: true } : {} };
@@ -4467,15 +4483,15 @@ function projectAppsDir(dir) {
4467
4483
  function repoRoot(dir) {
4468
4484
  const real2 = (path) => {
4469
4485
  try {
4470
- return realpathSync2(path);
4486
+ return realpathSync3(path);
4471
4487
  } catch {
4472
4488
  return resolve2(path);
4473
4489
  }
4474
4490
  };
4475
- const root = gitRoot(dir), dot = join12(root, ".git");
4491
+ const root = gitRoot(dir), dot = join13(root, ".git");
4476
4492
  try {
4477
- if (!statSync7(dot).isFile()) return real2(root);
4478
- const gitdir = resolve2(root, /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))[1].trim()), common = resolve2(gitdir, readFileSync12(join12(gitdir, "commondir"), "utf8").trim());
4493
+ if (!statSync8(dot).isFile()) return real2(root);
4494
+ const gitdir = resolve2(root, /^gitdir:\s*(.+)$/m.exec(readFileSync13(dot, "utf8"))[1].trim()), common = resolve2(gitdir, readFileSync13(join13(gitdir, "commondir"), "utf8").trim());
4479
4495
  return real2(basename2(common) === ".git" ? dirname6(common) : common);
4480
4496
  } catch {
4481
4497
  return real2(root);
@@ -4483,15 +4499,15 @@ function repoRoot(dir) {
4483
4499
  }
4484
4500
  function gitDirs(root) {
4485
4501
  try {
4486
- const dot = join12(root, ".git"), named2 = statSync7(dot).isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))[1].trim() : dot, gitdir = realpathSync2(resolve2(root, named2));
4502
+ const dot = join13(root, ".git"), named2 = statSync8(dot).isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync13(dot, "utf8"))[1].trim() : dot, gitdir = realpathSync3(resolve2(root, named2));
4487
4503
  return [gitdir, commonOf(gitdir)];
4488
4504
  } catch {
4489
4505
  return [];
4490
4506
  }
4491
4507
  }
4492
4508
  function commonOf(gitdir) {
4493
- const file = join12(gitdir, "commondir");
4494
- return existsSync8(file) ? realpathSync2(resolve2(gitdir, readFileSync12(file, "utf8").trim())) : gitdir;
4509
+ const file = join13(gitdir, "commondir");
4510
+ return existsSync8(file) ? realpathSync3(resolve2(gitdir, readFileSync13(file, "utf8").trim())) : gitdir;
4495
4511
  }
4496
4512
  function appRepos(dir, app) {
4497
4513
  const read = readApps(dir), at2 = read.ok ? read.apps.find((a) => a.name === app)?.dir : void 0;
@@ -4502,14 +4518,14 @@ function appRepos(dir, app) {
4502
4518
  const folder = resolve2(root, at2);
4503
4519
  if (!inside2(folder, root)) return [];
4504
4520
  try {
4505
- const real2 = realpathSync2(root), mine = gitDirs(top), allowed = [real2, home, ...mine], within2 = (path) => allowed.some((a) => path === a || inside2(path, a));
4506
- for (let d = realpathSync2(folder); inside2(d, real2); d = dirname6(d)) {
4507
- const dot = join12(d, ".git"), stat = statSync7(dot, { throwIfNoEntry: false });
4521
+ const real2 = realpathSync3(root), mine = gitDirs(top), allowed = [real2, home, ...mine], within2 = (path) => allowed.some((a) => path === a || inside2(path, a));
4522
+ for (let d = realpathSync3(folder); inside2(d, real2); d = dirname6(d)) {
4523
+ const dot = join13(d, ".git"), stat = statSync8(dot, { throwIfNoEntry: false });
4508
4524
  if (!stat) continue;
4509
- const named2 = stat.isDirectory() ? dot : stat.isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))?.[1]?.trim() : void 0;
4525
+ const named2 = stat.isDirectory() ? dot : stat.isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync13(dot, "utf8"))?.[1]?.trim() : void 0;
4510
4526
  if (named2 === void 0) return [];
4511
- const gitdir = realpathSync2(resolve2(d, named2)), common = commonOf(gitdir);
4512
- if (common === mine[1] || !existsSync8(join12(gitdir, "HEAD"))) return [];
4527
+ const gitdir = realpathSync3(resolve2(d, named2)), common = commonOf(gitdir);
4528
+ if (common === mine[1] || !existsSync8(join13(gitdir, "HEAD"))) return [];
4513
4529
  return within2(gitdir) && within2(common) ? [d] : [];
4514
4530
  }
4515
4531
  } catch {
@@ -4527,7 +4543,7 @@ function appLinkPaths(dir, app) {
4527
4543
  function gitmodulesPaths(root) {
4528
4544
  let text4;
4529
4545
  try {
4530
- text4 = readFileSync12(join12(root, ".gitmodules"), "utf8");
4546
+ text4 = readFileSync13(join13(root, ".gitmodules"), "utf8");
4531
4547
  } catch {
4532
4548
  return [];
4533
4549
  }
@@ -4541,7 +4557,7 @@ function checkoutProject(dir) {
4541
4557
  const { file } = appsFile(dir);
4542
4558
  let config;
4543
4559
  try {
4544
- config = JSON.parse(readFileSync12(file, "utf8").replace(/^\uFEFF/, ""));
4560
+ config = JSON.parse(readFileSync13(file, "utf8").replace(/^\uFEFF/, ""));
4545
4561
  } catch (error) {
4546
4562
  return { ok: false, refusal: `sb: ${file} cannot be read (${error.message}), so the project of this checkout is unknown` };
4547
4563
  }
@@ -4552,7 +4568,7 @@ function checkoutProject(dir) {
4552
4568
  }
4553
4569
 
4554
4570
  // src/trainrole.ts
4555
- import { readFileSync as readFileSync13 } from "node:fs";
4571
+ import { readFileSync as readFileSync14 } from "node:fs";
4556
4572
  var TRAIN = "train";
4557
4573
  var DEFAULT_MAX_TRAINS = 3;
4558
4574
  var MAX_TRAINS_CAP = 32;
@@ -4584,7 +4600,7 @@ function readMaxTrains(dir) {
4584
4600
  const { file } = appsFile(dir);
4585
4601
  let text4;
4586
4602
  try {
4587
- text4 = readFileSync13(file, "utf8");
4603
+ text4 = readFileSync14(file, "utf8");
4588
4604
  } catch (error) {
4589
4605
  return error.code === "ENOENT" ? DEFAULT_MAX_TRAINS : { refusal: `${file} cannot be read (${error.message}), so maxTrains is unknown` };
4590
4606
  }
@@ -4614,8 +4630,8 @@ var graphOf = (v) => v === "orchestrator-worker" ? v : v === "fan-out/fan-in" ||
4614
4630
  var dutyOfAgent = (name) => name !== void 0 && Object.hasOwn(AGENT_DUTY, name) ? AGENT_DUTY[name] : void 0;
4615
4631
 
4616
4632
  // src/train/board.ts
4617
- import { chmodSync as chmodSync5, closeSync as closeSync3, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync6, openSync as openSync3, readdirSync as readdirSync4, readSync as readSync2, renameSync as renameSync8, unlinkSync, writeFileSync as writeFileSync9 } from "node:fs";
4618
- import { basename as basename3, dirname as dirname7, join as join13 } from "node:path";
4633
+ import { chmodSync as chmodSync6, closeSync as closeSync3, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync6, openSync as openSync3, readdirSync as readdirSync4, readSync as readSync2, renameSync as renameSync9, unlinkSync, writeFileSync as writeFileSync10 } from "node:fs";
4634
+ import { basename as basename3, dirname as dirname7, join as join14 } from "node:path";
4619
4635
  var MAX_BOARD_BYTES = 64 * 1024;
4620
4636
  var MAX_TRAINS = 64;
4621
4637
  var MAX_STEPS = 256;
@@ -4776,20 +4792,20 @@ var safe = (project, code) => {
4776
4792
  if (!isName(project)) throw new Error(`sb: project "${project}" is not a path-safe name`);
4777
4793
  if (code !== void 0 && !isCode(code)) throw new Error(`sb: code "${code}" is not a train code (YYYY-MM-DD-<letters>)`);
4778
4794
  };
4779
- var trainboardDir = (stateDir) => join13(stateDir, "trainboard");
4780
- var boardPath = (stateDir, project, code) => (safe(project, code), join13(trainboardDir(stateDir), project, code, "board.json"));
4781
- var yardPath = (stateDir, project) => (safe(project), join13(trainboardDir(stateDir), project, "yard.json"));
4782
- var carsDir = (stateDir, project) => (safe(project), join13(trainboardDir(stateDir), project, "cars"));
4795
+ var trainboardDir = (stateDir) => join14(stateDir, "trainboard");
4796
+ var boardPath = (stateDir, project, code) => (safe(project, code), join14(trainboardDir(stateDir), project, code, "board.json"));
4797
+ var yardPath = (stateDir, project) => (safe(project), join14(trainboardDir(stateDir), project, "yard.json"));
4798
+ var carsDir = (stateDir, project) => (safe(project), join14(trainboardDir(stateDir), project, "cars"));
4783
4799
  var counter = 0;
4784
4800
  function writePrivate(file, content, folders) {
4785
4801
  for (const dir of folders) {
4786
4802
  mkdirSync6(dir, { recursive: true, mode: 448 });
4787
- chmodSync5(dir, 448);
4803
+ chmodSync6(dir, 448);
4788
4804
  }
4789
4805
  const temp = `${file}.${process.pid}.${counter++}.tmp`;
4790
4806
  try {
4791
- writeFileSync9(temp, content, { mode: 384, flag: "wx" });
4792
- renameSync8(temp, file);
4807
+ writeFileSync10(temp, content, { mode: 384, flag: "wx" });
4808
+ renameSync9(temp, file);
4793
4809
  } catch (error) {
4794
4810
  try {
4795
4811
  unlinkSync(temp);
@@ -4878,11 +4894,11 @@ var dirs = (path, failed2) => {
4878
4894
  function readTrainboards(stateDir, opts = {}) {
4879
4895
  const root = trainboardDir(stateDir), found = [], unlisted = [];
4880
4896
  const projects = opts.project === void 0 ? dirs(root, unlisted).filter(isName).sort() : isName(opts.project) ? [opts.project] : [];
4881
- for (const project of projects) for (const code of dirs(join13(root, project), unlisted).filter((c) => FOLDER_CODE_RE.test(c)).sort(compareCodes)) found.push({ project, code });
4897
+ for (const project of projects) for (const code of dirs(join14(root, project), unlisted).filter((c) => FOLDER_CODE_RE.test(c)).sort(compareCodes)) found.push({ project, code });
4882
4898
  const max = opts.max ?? MAX_TRAINS;
4883
4899
  const kept = [...found].sort((a, b) => compareCodes(a.code, b.code) || (a.project < b.project ? -1 : a.project > b.project ? 1 : 0)).slice(Math.max(0, found.length - max));
4884
4900
  const trains = kept.sort((a, b) => a.project < b.project ? -1 : a.project > b.project ? 1 : compareCodes(a.code, b.code)).map(({ project, code }) => {
4885
- const file = join13(root, project, code, "board.json");
4901
+ const file = join14(root, project, code, "board.json");
4886
4902
  const read = readBoard(file);
4887
4903
  return { project, code, file, ...read.ok ? read : { ok: false, reason: read.reason.replace(/^cannot read: ENOENT$/, "no board.json") } };
4888
4904
  });
@@ -5139,8 +5155,8 @@ function waitMessage(waits) {
5139
5155
  }
5140
5156
 
5141
5157
  // src/trainboard.ts
5142
- import { chmodSync as chmodSync6, lstatSync as lstatSync5, mkdirSync as mkdirSync7, readdirSync as readdirSync5, renameSync as renameSync9, unlinkSync as unlinkSync2, writeFileSync as writeFileSync10 } from "node:fs";
5143
- import { dirname as dirname8, join as join14 } from "node:path";
5158
+ import { chmodSync as chmodSync7, lstatSync as lstatSync5, mkdirSync as mkdirSync7, readdirSync as readdirSync5, renameSync as renameSync10, unlinkSync as unlinkSync2, writeFileSync as writeFileSync11 } from "node:fs";
5159
+ import { dirname as dirname8, join as join15 } from "node:path";
5144
5160
  var counter2 = 0;
5145
5161
  function writePrivate2(file, text4, root) {
5146
5162
  const folders = [];
@@ -5150,12 +5166,12 @@ function writePrivate2(file, text4, root) {
5150
5166
  }
5151
5167
  for (const dir of folders) {
5152
5168
  mkdirSync7(dir, { recursive: true, mode: 448 });
5153
- chmodSync6(dir, 448);
5169
+ chmodSync7(dir, 448);
5154
5170
  }
5155
5171
  const temp = `${file}.${process.pid}.${counter2++}.tmp`;
5156
5172
  try {
5157
- writeFileSync10(temp, text4, { mode: 384, flag: "wx" });
5158
- renameSync9(temp, file);
5173
+ writeFileSync11(temp, text4, { mode: 384, flag: "wx" });
5174
+ renameSync10(temp, file);
5159
5175
  } catch (error) {
5160
5176
  try {
5161
5177
  unlinkSync2(temp);
@@ -5171,14 +5187,14 @@ var noticeFile = (name) => name.replace(/\.json$/, ".notice.json");
5171
5187
  var plainReason = (list2) => list2.map((r) => r.replace(/^sb: /, "")).join("; ");
5172
5188
  var missing = (reason) => reason === "cannot read: ENOENT";
5173
5189
  function readCar(stateDir, project, name, budget) {
5174
- const dir = carsDir(stateDir, project), read = readJsonFile(join14(dir, name), MAX_CAR_BYTES, budget);
5190
+ const dir = carsDir(stateDir, project), read = readJsonFile(join15(dir, name), MAX_CAR_BYTES, budget);
5175
5191
  if (!read.ok) return missing(read.reason) ? { ok: false, reason: read.reason, gone: true } : { ok: false, reason: read.reason };
5176
5192
  const refusals = validateCarFile(read.value);
5177
5193
  if (refusals.length) return { ok: false, reason: plainReason(refusals) };
5178
5194
  const file = read.value;
5179
5195
  if (file.project !== project) return { ok: false, reason: `project ${file.project} is not the folder's ${project}` };
5180
5196
  if (carFileName(file.app, file.car.head) !== name) return { ok: false, reason: `the file name is not ${carFileName(file.app, file.car.head)}` };
5181
- const notice = readJsonFile(join14(dir, noticeFile(name)), MAX_CAR_BYTES, budget);
5197
+ const notice = readJsonFile(join15(dir, noticeFile(name)), MAX_CAR_BYTES, budget);
5182
5198
  if (!notice.ok) return { ok: true, file, ...missing(notice.reason) ? {} : { noticeProblem: `notice file: ${notice.reason}` } };
5183
5199
  const problems = validateNoticeRecord(notice.value);
5184
5200
  return problems.length ? { ok: true, file, noticeProblem: `notice record: ${problems[0]}` } : { ok: true, file, notice: notice.value };
@@ -5202,7 +5218,7 @@ function listCars(stateDir, project, o = {}) {
5202
5218
  if (names.length > MAX_CAR_NAMES) out.truncated = true, names = names.slice(0, MAX_CAR_NAMES);
5203
5219
  const aged = names.map((name) => {
5204
5220
  try {
5205
- return { name, at: lstatSync5(join14(dir, name)).mtimeMs };
5221
+ return { name, at: lstatSync5(join15(dir, name)).mtimeMs };
5206
5222
  } catch {
5207
5223
  return { name, at: 0 };
5208
5224
  }
@@ -5733,12 +5749,12 @@ function sanitizeReply(kind, status, body, rw) {
5733
5749
 
5734
5750
  // src/server/trainlock.ts
5735
5751
  import { randomUUID } from "node:crypto";
5736
- import { linkSync as linkSync2, mkdirSync as mkdirSync8, readdirSync as readdirSync6, readFileSync as readFileSync14, renameSync as renameSync10, statSync as statSync8, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "node:fs";
5737
- import { join as join15 } from "node:path";
5752
+ import { linkSync as linkSync2, mkdirSync as mkdirSync8, readdirSync as readdirSync6, readFileSync as readFileSync15, renameSync as renameSync11, statSync as statSync9, unlinkSync as unlinkSync3, writeFileSync as writeFileSync12 } from "node:fs";
5753
+ import { join as join16 } from "node:path";
5738
5754
  var LOCK_NAME = /^[a-z0-9-]{1,32}$/;
5739
5755
  var MARKER_MAX_MS2 = 5e3;
5740
- var lockDirOf = (stateDir) => join15(stateDir, "locks");
5741
- var fileOf3 = (dir, name) => join15(dir, `${name}.lock`);
5756
+ var lockDirOf = (stateDir) => join16(stateDir, "locks");
5757
+ var fileOf3 = (dir, name) => join16(dir, `${name}.lock`);
5742
5758
  var check = (name) => {
5743
5759
  if (!LOCK_NAME.test(name)) throw new Error(`sb: lock name "${name}" must be 1 to 32 of a-z, 0-9, -`);
5744
5760
  };
@@ -5762,7 +5778,7 @@ var isHolder = (value) => {
5762
5778
  };
5763
5779
  var readRaw2 = (file) => {
5764
5780
  try {
5765
- return readFileSync14(file, "utf8");
5781
+ return readFileSync15(file, "utf8");
5766
5782
  } catch {
5767
5783
  return void 0;
5768
5784
  }
@@ -5777,7 +5793,7 @@ var parse3 = (raw) => {
5777
5793
  };
5778
5794
  var ageOf = (file, now) => {
5779
5795
  try {
5780
- return now - statSync8(file).mtimeMs;
5796
+ return now - statSync9(file).mtimeMs;
5781
5797
  } catch {
5782
5798
  return 0;
5783
5799
  }
@@ -5805,7 +5821,7 @@ function takeLock2(dir, name, who, deps = {}) {
5805
5821
  const holder = { train: who.train, step: who.step, pid, ...started ? { started } : {}, since: new Date(now()).toISOString() };
5806
5822
  const body = JSON.stringify(holder), file = fileOf3(dir, name);
5807
5823
  const temp = `${file}.${process.pid}.${randomUUID()}.tmp`;
5808
- writeFileSync11(temp, body, { flag: "wx", mode: 384 });
5824
+ writeFileSync12(temp, body, { flag: "wx", mode: 384 });
5809
5825
  const release = () => {
5810
5826
  if (readRaw2(file) === body) {
5811
5827
  try {
@@ -5832,7 +5848,7 @@ function takeLock2(dir, name, who, deps = {}) {
5832
5848
  try {
5833
5849
  if (readRaw2(file) !== raw) continue;
5834
5850
  deps.beforeReplace?.();
5835
- renameSync10(temp, file);
5851
+ renameSync11(temp, file);
5836
5852
  deps.afterReplace?.();
5837
5853
  if (readRaw2(file) === body) return { ok: true, holder, release };
5838
5854
  return { ok: false, holder: parse3(readRaw2(file)), why: "held" };
@@ -5874,7 +5890,7 @@ function enterMarker(dir, name, started, now, deps) {
5874
5890
  }
5875
5891
  return names.flatMap((n) => {
5876
5892
  const m = pattern.exec(n);
5877
- return m ? [{ path: join15(dir, n), n: Number(m[1]) }] : [];
5893
+ return m ? [{ path: join16(dir, n), n: Number(m[1]) }] : [];
5878
5894
  });
5879
5895
  };
5880
5896
  const judge = (markers, except) => {
@@ -5889,10 +5905,10 @@ function enterMarker(dir, name, started, now, deps) {
5889
5905
  };
5890
5906
  const before = list2();
5891
5907
  if (judge(before).alive.length) return void 0;
5892
- const next = Math.max(0, ...before.map((m) => m.n)) + 1, path = join15(dir, `${name}.lock.looking.${next}`);
5908
+ const next = Math.max(0, ...before.map((m) => m.n)) + 1, path = join16(dir, `${name}.lock.looking.${next}`);
5893
5909
  deps.beforeMarker?.();
5894
5910
  const temp = `${path}.${process.pid}.${randomUUID()}.tmp`;
5895
- writeFileSync11(temp, body, { flag: "wx", mode: 384 });
5911
+ writeFileSync12(temp, body, { flag: "wx", mode: 384 });
5896
5912
  try {
5897
5913
  try {
5898
5914
  linkSync2(temp, path);
@@ -5924,16 +5940,16 @@ function enterMarker(dir, name, started, now, deps) {
5924
5940
  // src/server/traingate.ts
5925
5941
  import { spawn as spawn3 } from "node:child_process";
5926
5942
  import { createHash as createHash7, randomBytes as randomBytes11, randomUUID as randomUUID2 } from "node:crypto";
5927
- import { chmodSync as chmodSync7, closeSync as closeSync4, constants as constants4, fstatSync as fstatSync4, lstatSync as lstatSync6, mkdirSync as mkdirSync10, openSync as openSync4, readFileSync as readFileSync16, readSync as readSync3, renameSync as renameSync11, unlinkSync as unlinkSync4, writeFileSync as writeFileSync13 } from "node:fs";
5943
+ import { chmodSync as chmodSync8, closeSync as closeSync4, constants as constants4, fstatSync as fstatSync4, lstatSync as lstatSync6, mkdirSync as mkdirSync10, openSync as openSync4, readFileSync as readFileSync17, readSync as readSync3, renameSync as renameSync12, unlinkSync as unlinkSync4, writeFileSync as writeFileSync14 } from "node:fs";
5928
5944
  import { availableParallelism, homedir as homedir3, loadavg } from "node:os";
5929
- import { basename as basename5, dirname as dirname9, join as join17, resolve as resolve3 } from "node:path";
5945
+ import { basename as basename5, dirname as dirname9, join as join18, resolve as resolve3 } from "node:path";
5930
5946
 
5931
5947
  // src/procs/killguard.ts
5932
- import { mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync15, readlinkSync as readlinkSync3, rmSync as rmSync12, writeFileSync as writeFileSync12 } from "node:fs";
5933
- import { join as join16 } from "node:path";
5948
+ import { mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync16, readlinkSync as readlinkSync3, rmSync as rmSync13, writeFileSync as writeFileSync13 } from "node:fs";
5949
+ import { join as join17 } from "node:path";
5934
5950
 
5935
5951
  // src/procs/cwd.ts
5936
- import { readlinkSync as readlinkSync2, statSync as statSync9 } from "node:fs";
5952
+ import { readlinkSync as readlinkSync2, statSync as statSync10 } from "node:fs";
5937
5953
 
5938
5954
  // src/procs/table.ts
5939
5955
  import { readlinkSync } from "node:fs";
@@ -6043,7 +6059,7 @@ function classifyCwd(cwd, onDisk) {
6043
6059
  }
6044
6060
  function inodeOnDisk(path) {
6045
6061
  try {
6046
- return String(statSync9(path, { bigint: true }).ino);
6062
+ return String(statSync10(path, { bigint: true }).ino);
6047
6063
  } catch {
6048
6064
  return null;
6049
6065
  }
@@ -6063,14 +6079,14 @@ function noteOwned(pid, { proc = process.env, argv = process.argv, startOf: read
6063
6079
  if (pid === void 0 || !Number.isSafeInteger(pid) || pid <= 1 || !inTestRun(proc, argv) || !proc[TEST_ROOT]) return void 0;
6064
6080
  const time = read(pid);
6065
6081
  if (!time) return void 0;
6066
- mkdirSync9(join16(proc[TEST_ROOT], KILLS_DIR), { recursive: true });
6067
- writeFileSync12(join16(proc[TEST_ROOT], KILLS_DIR, String(pid)), `${process.pid}
6082
+ mkdirSync9(join17(proc[TEST_ROOT], KILLS_DIR), { recursive: true });
6083
+ writeFileSync13(join17(proc[TEST_ROOT], KILLS_DIR, String(pid)), `${process.pid}
6068
6084
  ${time}
6069
6085
  `);
6070
6086
  return time;
6071
6087
  }
6072
6088
  function forgetOwned(pid, proc = process.env) {
6073
- if (proc[TEST_ROOT]) rmSync12(join16(proc[TEST_ROOT], KILLS_DIR, String(pid)), { force: true });
6089
+ if (proc[TEST_ROOT]) rmSync13(join17(proc[TEST_ROOT], KILLS_DIR, String(pid)), { force: true });
6074
6090
  }
6075
6091
  function guardSignal(target, signal, { proc = process.env, argv = process.argv, startOf: read = startOf, cwdOf = cwdOfSync } = {}) {
6076
6092
  if (!inTestRun(proc, argv)) return;
@@ -6079,7 +6095,7 @@ function guardSignal(target, signal, { proc = process.env, argv = process.argv,
6079
6095
  if (!Number.isSafeInteger(pid) || pid <= 1) return refuse(`a test run would send ${what}`, proc);
6080
6096
  let noted;
6081
6097
  try {
6082
- noted = readFileSync15(join16(root, KILLS_DIR, String(pid)), "utf8").split("\n")[1]?.trim();
6098
+ noted = readFileSync16(join17(root, KILLS_DIR, String(pid)), "utf8").split("\n")[1]?.trim();
6083
6099
  } catch {
6084
6100
  }
6085
6101
  if (!noted) return refuse(`a test run would send ${what}, a process this test did not start (note it with noteOwned when it does)`, proc);
@@ -6204,7 +6220,7 @@ function readSpec(specFile) {
6204
6220
  if (stat.size > MAX_SPEC_BYTES) return { ok: false, refusals: [`sb: ${file} is more than ${MAX_SPEC_BYTES / 1024} KB`] };
6205
6221
  fd = openSync4(file, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
6206
6222
  if (fstatSync4(fd).size > MAX_SPEC_BYTES) return { ok: false, refusals: [`sb: ${file} is more than ${MAX_SPEC_BYTES / 1024} KB`] };
6207
- raw = readFileSync16(fd, "utf8");
6223
+ raw = readFileSync17(fd, "utf8");
6208
6224
  sb = JSON.parse(raw);
6209
6225
  } catch (error) {
6210
6226
  return { ok: false, refusals: [`sb: cannot read the step file ${file}: ${error.message}`] };
@@ -6285,10 +6301,10 @@ function readGate(file, budget) {
6285
6301
  function writeGate(file, gate) {
6286
6302
  const temp = `${file}.${process.pid}.${randomUUID2()}.tmp`;
6287
6303
  try {
6288
- writeFileSync13(temp, `${JSON.stringify(gate)}
6304
+ writeFileSync14(temp, `${JSON.stringify(gate)}
6289
6305
  `, { mode: 384, flag: "wx" });
6290
- renameSync11(temp, file);
6291
- chmodSync7(file, 384);
6306
+ renameSync12(temp, file);
6307
+ chmodSync8(file, 384);
6292
6308
  } catch (error) {
6293
6309
  try {
6294
6310
  unlinkSync4(temp);
@@ -6303,7 +6319,7 @@ var long = (ms) => {
6303
6319
  return `${h ? `${h}h` : ""}${h || m ? `${m}m` : ""}${s % 60}s`.replace(/^(\d+m)0s$/, "$1");
6304
6320
  };
6305
6321
  var r1 = (x) => Math.round(x * 10) / 10;
6306
- var expand = (path, home) => path === "~" ? home : path.startsWith("~/") ? join17(home, path.slice(2)) : path;
6322
+ var expand = (path, home) => path === "~" ? home : path.startsWith("~/") ? join18(home, path.slice(2)) : path;
6307
6323
  var GONE = /* @__PURE__ */ new Set(["ESRCH", "EPERM"]);
6308
6324
  var killGroup = (pid, signal) => signal === 0 ? process.kill(pid, 0) : sendSignal(pid, signal);
6309
6325
  var realSleep = (ms) => new Promise((done) => setTimeout(done, ms));
@@ -6331,7 +6347,7 @@ async function runGate(specFile, deps) {
6331
6347
  const holds = spec.holds;
6332
6348
  if (d.platform === "win32") return refuse3("train gate needs process groups (macOS or Linux); this computer is Windows", sb, id);
6333
6349
  const home = d.home, cwd = resolve3(expand(String(check2.cwd), home)), logFile = resolve3(cwd, expand(String(check2.log), home));
6334
- const gateFile = join17(dirname9(frozen.file), `gate-${id}.json`);
6350
+ const gateFile = join18(dirname9(frozen.file), `gate-${id}.json`);
6335
6351
  let started = d.startOf(d.pid);
6336
6352
  const began = clock.now();
6337
6353
  const nonce = randomBytes11(16).toString("hex");
@@ -6470,7 +6486,7 @@ async function runGate(specFile, deps) {
6470
6486
  for (; ; ) {
6471
6487
  const l = readLoad();
6472
6488
  const boards = readTrainboards(stateDir, { project, max: d.maxBoards ?? GATE_MAX_BOARDS });
6473
- if (boards.truncated) return refuse3(`more than ${d.maxBoards ?? GATE_MAX_BOARDS} trainboards of project ${project}, so what is held cannot be known; remove the folders of ended trains under ${join17(stateDir, "trainboard", project)}`, sb, id);
6489
+ if (boards.truncated) return refuse3(`more than ${d.maxBoards ?? GATE_MAX_BOARDS} trainboards of project ${project}, so what is held cannot be known; remove the folders of ended trains under ${join18(stateDir, "trainboard", project)}`, sb, id);
6474
6490
  if (boards.unlisted.length) return refuse3(`what trains of project ${project} hold cannot be known: ${boards.unlisted.join("; ")}`, sb, id);
6475
6491
  const trains = boards.trains.map((b) => factsOf(b, { now: clock.now(), alive: d.alive }));
6476
6492
  const step = { id, kind: String(sb.kind), status: "in_progress", round: Number(sb.round), ...holds ? { holds } : {}, ...load ? { load } : {}, ...lockName ? { lock: lockName } : {} };
@@ -6517,7 +6533,7 @@ async function runGate(specFile, deps) {
6517
6533
  if (result2.code !== 0) return finish("failed", result2.signal ? `killed by ${result2.signal} after ${took}` : `exit ${result2.code} in ${took}`, result2.code ?? void 0);
6518
6534
  const verify = check2.verify, expect = check2.expect, poll = check2.poll;
6519
6535
  if (!verify) return finish("passed", `exit 0 in ${took}`, 0);
6520
- const outFile = join17(dirname9(frozen.file), `verify-${id}.out`), until = clock.now() + (poll ? poll.forMin * 6e4 : 0), verifyFrom = clock.now();
6536
+ const outFile = join18(dirname9(frozen.file), `verify-${id}.out`), until = clock.now() + (poll ? poll.forMin * 6e4 : 0), verifyFrom = clock.now();
6521
6537
  const deadline = poll ? until + TRY_GRACE_MS : void 0;
6522
6538
  for (let attempt = 1; ; attempt++) {
6523
6539
  const beat = () => line("verifying", `verifying ${short(clock.now() - verifyFrom)}: ${String(sb.name)} (try ${attempt})`, { tail: tail() });
@@ -89,7 +89,7 @@ import {
89
89
  writeBoard,
90
90
  writeJson,
91
91
  writerAlive
92
- } from "./chunk-4PGRA77L.mjs";
92
+ } from "./chunk-REKH6NRM.mjs";
93
93
 
94
94
  // src/server/cli.ts
95
95
  import { existsSync as existsSync2, realpathSync as realpathSync3 } from "node:fs";
@@ -1970,7 +1970,7 @@ ${USAGE}
1970
1970
  ${USAGE}`);
1971
1971
  const ended = new AbortController();
1972
1972
  (deps.signals ?? ((leave) => ["SIGTERM", "SIGINT", "SIGHUP"].forEach((signal) => process.once(signal, leave))))(() => ended.abort());
1973
- return await runPrompt({ workspace, source: serverSource(ctx, workspace), input: deps.stdin ?? process.stdin, output: deps.stdout ?? process.stdout, locale: localeOf(env), env, signal: ended.signal });
1973
+ return await runPrompt({ workspace, source: serverSource(ctx, workspace), input: deps.stdin ?? process.stdin, output: deps.stdout ?? process.stdout, locale: localeOf(env, slot.stateDir), env, signal: ended.signal });
1974
1974
  }
1975
1975
  async function status2() {
1976
1976
  json(await describe(ctx));