@bensandee/tooling 0.97.0 → 0.98.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.
Files changed (2) hide show
  1. package/dist/bin.mjs +194 -237
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -175,7 +175,7 @@ function loadEnvFileForBin(rawArgs, bin, io = processIo) {
175
175
  //#region src/env-file-preload.ts
176
176
  const envFileLoad = loadEnvFileForBin(process.argv.slice(2), {
177
177
  name: "bst",
178
- version: "0.97.0"
178
+ version: "0.98.0"
179
179
  });
180
180
  //#endregion
181
181
  //#region ../cli-kit/src/logger.ts
@@ -2037,20 +2037,23 @@ function parseRepositoryUrl(cwd) {
2037
2037
  //#endregion
2038
2038
  //#region ../forgejo/src/errors.ts
2039
2039
  var ForgeAccessError = class extends FatalError {};
2040
- function authHeaders$2(conn) {
2040
+ function authHeaders(conn) {
2041
2041
  return { Authorization: `token ${conn.token}` };
2042
2042
  }
2043
2043
  function jsonHeaders(conn) {
2044
2044
  return {
2045
- ...authHeaders$2(conn),
2045
+ ...authHeaders(conn),
2046
2046
  "Content-Type": "application/json"
2047
2047
  };
2048
2048
  }
2049
2049
  function repoNotFoundMessage(conn) {
2050
2050
  return `Repository ${conn.repository} not found (or the token cannot see it)`;
2051
2051
  }
2052
+ function repoBase(conn) {
2053
+ return `${conn.serverUrl}/api/v1/repos/${conn.repository}`;
2054
+ }
2052
2055
  function issuesBase(conn) {
2053
- return `${conn.serverUrl}/api/v1/repos/${conn.repository}/issues`;
2056
+ return `${repoBase(conn)}/issues`;
2054
2057
  }
2055
2058
  function issueNotFoundMessage(conn, number) {
2056
2059
  return `Issue #${String(number)} not found in ${conn.repository}`;
@@ -2248,6 +2251,14 @@ function loadRegistryHostOverride(cwd) {
2248
2251
  }
2249
2252
  //#endregion
2250
2253
  //#region src/release/docker-bake.ts
2254
+ function escapeBakeTemplate(value) {
2255
+ return value.replace(/\$\{/gu, () => "$${").replace(/%\{/gu, () => "%%{");
2256
+ }
2257
+ function escapeBakeTemplateValues(values) {
2258
+ const escaped = {};
2259
+ for (const [key, value] of Object.entries(values)) escaped[key] = escapeBakeTemplate(value);
2260
+ return escaped;
2261
+ }
2251
2262
  function uniqueTargetName(taken, imageName) {
2252
2263
  const root = imageName.replace(/[^A-Za-z0-9_-]/gu, "_");
2253
2264
  const candidate = (suffix) => suffix === 1 ? root : `${root}_${String(suffix)}`;
@@ -2272,11 +2283,11 @@ function buildBakeDefinition(images) {
2272
2283
  const targets = [];
2273
2284
  for (const { image, target: name } of named) {
2274
2285
  const entry = {
2275
- context: image.context,
2276
- dockerfile: image.dockerfile,
2277
- tags: [`${image.imageName}:latest`],
2278
- args: image.args,
2279
- labels: image.labels
2286
+ context: escapeBakeTemplate(image.context),
2287
+ dockerfile: escapeBakeTemplate(image.dockerfile),
2288
+ tags: [escapeBakeTemplate(`${image.imageName}:latest`)],
2289
+ args: escapeBakeTemplateValues(image.args),
2290
+ labels: escapeBakeTemplateValues(image.labels)
2280
2291
  };
2281
2292
  if (image.bases.length > 0) {
2282
2293
  const contexts = {};
@@ -2727,6 +2738,51 @@ function fetchWithRetry(fetchImpl, policy = DEFAULT_RETRY_POLICY, defaultTimeout
2727
2738
  }
2728
2739
  //#endregion
2729
2740
  //#region src/utils/exec.ts
2741
+ const EXEC_MAX_BUFFER = 67108864;
2742
+ function execCapture$2(file, args, options) {
2743
+ try {
2744
+ return {
2745
+ status: 0,
2746
+ stdout: execFileSync(file, args, {
2747
+ cwd: options.cwd,
2748
+ env: options.env ? {
2749
+ ...process.env,
2750
+ ...options.env
2751
+ } : void 0,
2752
+ input: options.input,
2753
+ encoding: "utf-8",
2754
+ stdio: [
2755
+ options.stdin ?? "pipe",
2756
+ "pipe",
2757
+ "pipe"
2758
+ ],
2759
+ maxBuffer: EXEC_MAX_BUFFER
2760
+ }),
2761
+ stderr: ""
2762
+ };
2763
+ } catch (err) {
2764
+ if (isExecSyncError(err)) return {
2765
+ status: err.status,
2766
+ stdout: err.stdout,
2767
+ stderr: err.stderr
2768
+ };
2769
+ if (options.keepPartialStdoutOnKill && isKilledExecError(err)) {
2770
+ const detail = describeError$1(err);
2771
+ const stderr = err.stderr.trim() === "" ? detail : `${err.stderr}\n${detail}`;
2772
+ return {
2773
+ status: 1,
2774
+ stdout: err.stdout,
2775
+ stderr
2776
+ };
2777
+ }
2778
+ return {
2779
+ status: 1,
2780
+ stdout: "",
2781
+ stderr: describeError$1(err),
2782
+ error: err
2783
+ };
2784
+ }
2785
+ }
2730
2786
  function isExecSyncError(err) {
2731
2787
  return err instanceof Error && "stdout" in err && typeof err.stdout === "string" && "stderr" in err && typeof err.stderr === "string" && "status" in err && typeof err.status === "number";
2732
2788
  }
@@ -3778,6 +3834,15 @@ function sortPackagesByDependency(packages, executor, cwd) {
3778
3834
  }
3779
3835
  return sorted;
3780
3836
  }
3837
+ function refuseDuplicateImageNames(packages) {
3838
+ const dirsByImageName = /* @__PURE__ */ new Map();
3839
+ for (const pkg of packages) {
3840
+ const dirs = dirsByImageName.get(pkg.imageName);
3841
+ if (dirs === void 0) dirsByImageName.set(pkg.imageName, [pkg.dir]);
3842
+ else dirs.push(pkg.dir);
3843
+ }
3844
+ for (const [imageName, dirs] of dirsByImageName) if (dirs.length > 1) throw new FatalError(`More than one Docker package builds the image name "${imageName}": ${dirs.map((dir) => `"${dir}"`).join(", ")}. They would all build the same tag, so set a distinct "imageName" for one of them under .tooling.json#docker`);
3845
+ }
3781
3846
  function detectDockerPackages(executor, cwd, repoName, phase = DOCKER_CHECK_ONLY_PHASE) {
3782
3847
  const { overrides, composeFiles } = loadDockerConfigSlice(executor, cwd);
3783
3848
  const packageDirs = executor.listPackageDirs(cwd);
@@ -3836,6 +3901,7 @@ function detectDockerPackages(executor, cwd, repoName, phase = DOCKER_CHECK_ONLY
3836
3901
  origin: NO_COMPOSE_ORIGIN
3837
3902
  }));
3838
3903
  }
3904
+ refuseDuplicateImageNames(packages);
3839
3905
  return sortPackagesByDependency(packages, executor, cwd);
3840
3906
  }
3841
3907
  function readSinglePackageDocker(executor, cwd, packageDir, repoName) {
@@ -5634,9 +5700,9 @@ function buildManagedDevDeps(ctx) {
5634
5700
  const devDeps = { ...rootDevDeps(ctx.config) };
5635
5701
  if (!isMonorepo) Object.assign(devDeps, perPackageDevDeps(ctx.config));
5636
5702
  if (ctx.config.stack !== "none") devDeps["@bensandee/config"] = isWorkspacePackage(ctx, "@bensandee/config") ? "workspace:*" : "0.15.0";
5637
- if (!isWorkspacePackage(ctx, "@bensandee/tooling")) devDeps["@bensandee/tooling"] = "0.97.0";
5703
+ if (!isWorkspacePackage(ctx, "@bensandee/tooling")) devDeps["@bensandee/tooling"] = "0.98.0";
5638
5704
  if (ctx.config.useEslintPlugin && ctx.config.stack !== "none") devDeps["@bensandee/eslint-plugin"] = isWorkspacePackage(ctx, "@bensandee/eslint-plugin") ? "workspace:*" : "0.17.0";
5639
- if (wantsAgentCli(ctx)) devDeps[AGENT_CLI_PACKAGE] = "0.1.3";
5705
+ if (wantsAgentCli(ctx)) devDeps[AGENT_CLI_PACKAGE] = "0.2.0";
5640
5706
  if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = {
5641
5707
  "@changesets/cli": "3.0.3",
5642
5708
  "@release-it/bumper": "8.0.1",
@@ -9558,13 +9624,13 @@ const GIT_GUIDE_BODY = [
9558
9624
  "",
9559
9625
  "## Claiming work by hand",
9560
9626
  "",
9561
- "If the bst agent drives this repo, claim an issue or pull request before you work it by hand, so the agent does not start a run beside you: run `pnpm exec bst work:start <n>`. It prints the same orientation `work:status` does and then puts `agent-flags/hand-authored` on the object. It claims only where the repo's default branch sets `agent.enabled: true`, and does nothing anywhere else. **Exit 1 means do not start**: a run is live on the pair, or one is queued on it -- the output names which. An object the agent parked at a terminal such as `agent/implement-blocked` is claimed, since nothing runs there until a person acts. Exit 0 means the pair is yours, whether the command wrote the flag or found it there already.",
9627
+ "If the bst agent drives this repo, claim an issue or pull request before you work it by hand, so the agent does not start a run beside you: run `pnpm exec bst work:start <n>`. It prints the same orientation `work:status` does and then puts `agent-flags/human-driven` on the object. It claims only where the repo's default branch sets `agent.enabled: true`, and does nothing anywhere else. **Exit 1 means do not start**: a run is live on the pair, or one is queued on it -- the output names which. An object the agent parked at a terminal such as `agent/implement-blocked` is claimed, since nothing runs there until a person acts. Exit 0 means the pair is yours, whether the command wrote the flag or found it there already.",
9562
9628
  "",
9563
9629
  "The flag records who is working an object now, not who wrote it. Do not claim an issue or pull request you only file or open for later, even one a person or a coding session wrote by hand: leave it unclaimed so the agent can take it if asked. Claim it when you are about to work it.",
9564
9630
  "",
9565
9631
  "A pull request you open yourself that closes no claimed issue needs its own `pnpm exec bst work:start <n>` once it exists -- the flag on either half of a pair holds both, but there is no pair until something closes something.",
9566
9632
  "",
9567
- "Hand the work back with the control panel's **Release to the agent**, or by removing `agent-flags/hand-authored` from both halves. Removing it does not queue anything: the agent picks the object up on its next cycle only if a label or a comment asks it to.",
9633
+ "Hand the work back with the control panel's **Release to the agent**, or by removing `agent-flags/human-driven` from both halves. Removing it does not queue anything: the agent picks the object up on its next cycle only if a label or a comment asks it to.",
9568
9634
  "",
9569
9635
  "## Issue linking",
9570
9636
  "",
@@ -10274,7 +10340,7 @@ function reportFailures(failed, command) {
10274
10340
  function generateMigratePrompt(results, config, detected) {
10275
10341
  const sections = [];
10276
10342
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
10277
- sections.push(`# Migration Prompt\n\n_Generated by \`@bensandee/tooling@0.97.0 repo:sync\` on ${timestamp}_\n`);
10343
+ sections.push(`# Migration Prompt\n\n_Generated by \`@bensandee/tooling@0.98.0 repo:sync\` on ${timestamp}_\n`);
10278
10344
  const changed = results.filter((r) => r.action === "created" || r.action === "updated" || r.action === "archived");
10279
10345
  if (changed.length > 0) {
10280
10346
  const items = changed.map((r) => {
@@ -11158,38 +11224,17 @@ function groupSkippedSteps(steps, defined, flagSkip, configSkip) {
11158
11224
  function createRealHealthExecutor(rootDir) {
11159
11225
  return {
11160
11226
  exec(file, args, options) {
11161
- try {
11162
- return {
11163
- stdout: execFileSync(file, args, {
11164
- cwd: options?.cwd ?? rootDir,
11165
- env: options?.env ? {
11166
- ...process.env,
11167
- ...options.env
11168
- } : void 0,
11169
- input: options?.input,
11170
- encoding: "utf-8",
11171
- stdio: [
11172
- "pipe",
11173
- "pipe",
11174
- "pipe"
11175
- ],
11176
- maxBuffer: 67108864
11177
- }),
11178
- stderr: "",
11179
- exitCode: 0
11180
- };
11181
- } catch (err) {
11182
- if (isExecSyncError(err)) return {
11183
- stdout: err.stdout,
11184
- stderr: err.stderr,
11185
- exitCode: err.status
11186
- };
11187
- return {
11188
- stdout: "",
11189
- stderr: describeError$1(err),
11190
- exitCode: 1
11191
- };
11192
- }
11227
+ const result = execCapture$2(file, args, {
11228
+ cwd: options?.cwd ?? rootDir,
11229
+ env: options?.env,
11230
+ input: options?.input,
11231
+ keepPartialStdoutOnKill: false
11232
+ });
11233
+ return {
11234
+ stdout: result.stdout,
11235
+ stderr: result.stderr,
11236
+ exitCode: result.status
11237
+ };
11193
11238
  },
11194
11239
  readFile(rel) {
11195
11240
  const full = path.join(rootDir, rel);
@@ -13817,7 +13862,7 @@ const AuthenticatedUserSchema = z.object({
13817
13862
  });
13818
13863
  async function getAuthenticatedUser(executor, conn, signal = null) {
13819
13864
  const res = await executor.fetch(`${conn.serverUrl}/api/v1/user`, {
13820
- headers: authHeaders$2(conn),
13865
+ headers: authHeaders(conn),
13821
13866
  signal
13822
13867
  });
13823
13868
  if (!res.ok) return {
@@ -13844,12 +13889,6 @@ function sleep(ms) {
13844
13889
  setTimeout(resolve, ms);
13845
13890
  });
13846
13891
  }
13847
- function envMsOverride(raw, productionMs) {
13848
- if (raw === void 0) return productionMs;
13849
- const parsed = Number(raw.trim());
13850
- if (!Number.isSafeInteger(parsed) || parsed <= 0) return productionMs;
13851
- return Math.min(parsed, productionMs);
13852
- }
13853
13892
  //#endregion
13854
13893
  //#region src/release/git-identity.ts
13855
13894
  function ciActorName(platform) {
@@ -14255,7 +14294,7 @@ const LABELS_MAX_PAGES = 20;
14255
14294
  async function fetchAllForgejoLabels(executor, conn) {
14256
14295
  const labels = [];
14257
14296
  for (let page = 1; page <= LABELS_MAX_PAGES; page++) {
14258
- const res = await executor.fetch(`${conn.serverUrl}/api/v1/repos/${conn.repository}/labels?limit=${String(LABELS_PAGE_SIZE)}&page=${String(page)}`, { headers: authHeaders$2(conn) });
14297
+ const res = await executor.fetch(`${conn.serverUrl}/api/v1/repos/${conn.repository}/labels?limit=${String(LABELS_PAGE_SIZE)}&page=${String(page)}`, { headers: authHeaders(conn) });
14259
14298
  if (!res.ok) await throwForgejoFailure(res, {
14260
14299
  verb: "list labels",
14261
14300
  resource: conn.repository
@@ -14320,7 +14359,7 @@ async function removeForgejoIssueLabel(executor, conn, number, name, labelIds) {
14320
14359
  const id = await resolveLabelId(executor, conn, name, labelIds);
14321
14360
  const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/labels/${String(id)}`, {
14322
14361
  method: "DELETE",
14323
- headers: authHeaders$2(conn)
14362
+ headers: authHeaders(conn)
14324
14363
  }, { idempotent: true });
14325
14364
  if (!res.ok) await throwForgejoFailure(res, {
14326
14365
  verb: "remove label",
@@ -14380,7 +14419,7 @@ async function listForgejoComments(executor, conn, number, options = {}) {
14380
14419
  limit: String(COMMENTS_PAGE_SIZE),
14381
14420
  page: String(page)
14382
14421
  });
14383
- const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/comments?${params.toString()}`, { headers: authHeaders$2(conn) });
14422
+ const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/comments?${params.toString()}`, { headers: authHeaders(conn) });
14384
14423
  if (!res.ok) await throwForgejoFailure(res, {
14385
14424
  verb: "list comments",
14386
14425
  resource: `#${String(number)}`
@@ -14474,7 +14513,7 @@ function toIssueSummaries(raw, type = "issues") {
14474
14513
  return type === "issues" ? summaries.filter((s) => !s.isPullRequest) : summaries;
14475
14514
  }
14476
14515
  async function getForgejoIssue(executor, conn, number) {
14477
- const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}`, { headers: authHeaders$2(conn) });
14516
+ const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}`, { headers: authHeaders(conn) });
14478
14517
  if (!res.ok) await throwForgejoFailure(res, {
14479
14518
  verb: "get issue",
14480
14519
  resource: `#${String(number)}`
@@ -14498,7 +14537,7 @@ function issueListParams(type, query) {
14498
14537
  return params;
14499
14538
  }
14500
14539
  async function fetchIssueListPage(executor, conn, params) {
14501
- const res = await executor.fetch(`${issuesBase(conn)}?${params.toString()}`, { headers: authHeaders$2(conn) });
14540
+ const res = await executor.fetch(`${issuesBase(conn)}?${params.toString()}`, { headers: authHeaders(conn) });
14502
14541
  if (!res.ok) await throwForgejoFailure(res, {
14503
14542
  verb: "list issues",
14504
14543
  resource: conn.repository
@@ -14894,11 +14933,15 @@ function groupLabels(names, descriptions) {
14894
14933
  }
14895
14934
  const RUNNING_LABEL = /^agent\/[a-z-]+-running$/;
14896
14935
  const QUEUED_LABEL = /^agent\/[a-z]+$/;
14897
- const HAND_AUTHORED_LABEL = "agent-flags/hand-authored";
14936
+ const HUMAN_DRIVEN_LABEL = "agent-flags/human-driven";
14937
+ const HUMAN_DRIVEN_LABEL_NAMES = [HUMAN_DRIVEN_LABEL, "agent-flags/hand-authored"];
14898
14938
  function liftedFacts(names) {
14939
+ const runLive = names.filter((name) => RUNNING_LABEL.test(name)).toSorted();
14940
+ const heldBy = HUMAN_DRIVEN_LABEL_NAMES.find((name) => names.includes(name)) ?? null;
14899
14941
  return {
14900
- runLive: names.filter((name) => RUNNING_LABEL.test(name)).toSorted(),
14901
- heldByHand: names.includes(HAND_AUTHORED_LABEL)
14942
+ runLive,
14943
+ heldByHand: heldBy !== null,
14944
+ heldBy
14902
14945
  };
14903
14946
  }
14904
14947
  function labelNamesOf(section) {
@@ -14914,7 +14957,7 @@ function ownerOf(names) {
14914
14957
  label: running,
14915
14958
  hold: "running"
14916
14959
  };
14917
- if (names.includes("agent-flags/hand-authored")) return { owner: "person" };
14960
+ if (HUMAN_DRIVEN_LABEL_NAMES.some((name) => names.includes(name))) return { owner: "person" };
14918
14961
  const queued = agent.find((name) => QUEUED_LABEL.test(name));
14919
14962
  if (queued !== void 0) return {
14920
14963
  owner: "agent",
@@ -15013,15 +15056,15 @@ function ownershipOf(report) {
15013
15056
  async function writeClaim(executor, cwd, target, number) {
15014
15057
  try {
15015
15058
  const { conn } = requireForgejoTransport(executor, cwd, target, "bst work:start claims work on Forgejo, the forge the agent drives; a GitHub checkout has no agent to hand work to.");
15016
- const flag = (await fetchAllForgejoLabels(executor, conn)).find((label) => label.name === HAND_AUTHORED_LABEL);
15059
+ const flag = (await fetchAllForgejoLabels(executor, conn)).find((label) => label.name === HUMAN_DRIVEN_LABEL);
15017
15060
  if (flag === void 0) return {
15018
15061
  outcome: "failed",
15019
- reason: `The forge has no label named ${HAND_AUTHORED_LABEL}. Provision the agent's labels first with pnpm exec bst-agent agent:labels --repo ${conn.repository}, or the control panel's Provision labels.`
15062
+ reason: `The forge has no label named ${HUMAN_DRIVEN_LABEL}. Provision the agent's labels first with pnpm exec bst-agent agent:labels --repo ${conn.repository}, or the control panel's Provision labels.`
15020
15063
  };
15021
- await addForgejoIssueLabel(executor, conn, number, HAND_AUTHORED_LABEL, /* @__PURE__ */ new Map([[HAND_AUTHORED_LABEL, flag.id]]));
15064
+ await addForgejoIssueLabel(executor, conn, number, HUMAN_DRIVEN_LABEL, /* @__PURE__ */ new Map([[HUMAN_DRIVEN_LABEL, flag.id]]));
15022
15065
  return {
15023
15066
  outcome: "claimed",
15024
- label: HAND_AUTHORED_LABEL
15067
+ label: HUMAN_DRIVEN_LABEL
15025
15068
  };
15026
15069
  } catch (error) {
15027
15070
  return {
@@ -15324,18 +15367,12 @@ z.object({
15324
15367
  created: z.string()
15325
15368
  });
15326
15369
  z.array(z.unknown());
15327
- function repoBase$1(conn) {
15328
- return `${conn.serverUrl}/api/v1/repos/${conn.repository}`;
15329
- }
15330
- function authHeaders$1(conn) {
15331
- return { Authorization: `token ${conn.token}` };
15332
- }
15333
15370
  function branchNotFoundMessage(conn, branch) {
15334
15371
  return `Branch ${branch} not found in ${conn.repository}`;
15335
15372
  }
15336
15373
  async function branchExists(executor, conn, branch) {
15337
- const url = `${repoBase$1(conn)}/branches/${encodeURIComponent(branch)}`;
15338
- const res = await executor.fetch(url, { headers: authHeaders$1(conn) });
15374
+ const url = `${repoBase(conn)}/branches/${encodeURIComponent(branch)}`;
15375
+ const res = await executor.fetch(url, { headers: authHeaders(conn) });
15339
15376
  if (res.status === 404) return false;
15340
15377
  if (!res.ok) await throwForgejoFailure(res, {
15341
15378
  verb: "check branch",
@@ -16828,6 +16865,34 @@ function offenderNameByCodepoint(codepoint) {
16828
16865
  return nameByCodepoint.get(codepoint);
16829
16866
  }
16830
16867
  //#endregion
16868
+ //#region src/chars-check/span-lexer.ts
16869
+ var SpanLexer = class {
16870
+ spans = [];
16871
+ spanStart = 0;
16872
+ spanContext;
16873
+ constructor(initialContext) {
16874
+ this.spanContext = initialContext;
16875
+ }
16876
+ flushTo(end, context) {
16877
+ if (context === this.spanContext) return;
16878
+ if (end > this.spanStart) this.spans.push({
16879
+ start: this.spanStart,
16880
+ end,
16881
+ context: this.spanContext
16882
+ });
16883
+ this.spanStart = end;
16884
+ this.spanContext = context;
16885
+ }
16886
+ finish(length) {
16887
+ if (length > this.spanStart) this.spans.push({
16888
+ start: this.spanStart,
16889
+ end: length,
16890
+ context: this.spanContext
16891
+ });
16892
+ return this.spans;
16893
+ }
16894
+ };
16895
+ //#endregion
16831
16896
  //#region src/chars-check/context-js-ts.ts
16832
16897
  const EXPRESSION_START_PUNCTUATION = /* @__PURE__ */ new Set([
16833
16898
  "(",
@@ -16878,7 +16943,7 @@ function isJsxNameStart(ch) {
16878
16943
  function resumeAfterTagClose(stack) {
16879
16944
  return stack[stack.length - 1]?.kind === "jsx-children" ? "jsx-text" : "code";
16880
16945
  }
16881
- var JsTsLexer = class {
16946
+ var JsTsLexer = class extends SpanLexer {
16882
16947
  text;
16883
16948
  jsx;
16884
16949
  n;
@@ -16887,11 +16952,9 @@ var JsTsLexer = class {
16887
16952
  expectsExpression = true;
16888
16953
  regexInClass = false;
16889
16954
  stack = [];
16890
- spans = [];
16891
- spanStart = 0;
16892
- spanContext = "code";
16893
16955
  bailed = false;
16894
16956
  constructor(text, jsx) {
16957
+ super("code");
16895
16958
  this.text = text;
16896
16959
  this.jsx = jsx;
16897
16960
  this.n = text.length;
@@ -16900,13 +16963,9 @@ var JsTsLexer = class {
16900
16963
  while (this.i < this.n && !this.bailed) this.step();
16901
16964
  if (this.bailed) return null;
16902
16965
  if (this.mode === "line-comment") this.mode = "code";
16903
- if (this.n > this.spanStart) this.spans.push({
16904
- start: this.spanStart,
16905
- end: this.n,
16906
- context: this.spanContext
16907
- });
16966
+ const spans = this.finish(this.n);
16908
16967
  if (this.mode !== "code" || this.stack.length > 0) return null;
16909
- return this.spans;
16968
+ return spans;
16910
16969
  }
16911
16970
  bail() {
16912
16971
  this.bailed = true;
@@ -16914,16 +16973,6 @@ var JsTsLexer = class {
16914
16973
  char(offset = 0) {
16915
16974
  return this.text[this.i + offset] ?? "";
16916
16975
  }
16917
- flushTo(end, context) {
16918
- if (context === this.spanContext) return;
16919
- if (end > this.spanStart) this.spans.push({
16920
- start: this.spanStart,
16921
- end,
16922
- context: this.spanContext
16923
- });
16924
- this.spanStart = end;
16925
- this.spanContext = context;
16926
- }
16927
16976
  step() {
16928
16977
  switch (this.mode) {
16929
16978
  case "code": return this.stepCode();
@@ -17220,7 +17269,7 @@ const jsxFamily = {
17220
17269
  };
17221
17270
  //#endregion
17222
17271
  //#region src/chars-check/context-kt-java.ts
17223
- var KtJavaLexer = class {
17272
+ var KtJavaLexer = class extends SpanLexer {
17224
17273
  text;
17225
17274
  kotlin;
17226
17275
  rawStringContext;
@@ -17228,11 +17277,9 @@ var KtJavaLexer = class {
17228
17277
  i = 0;
17229
17278
  mode = "code";
17230
17279
  stack = [];
17231
- spans = [];
17232
- spanStart = 0;
17233
- spanContext = "code";
17234
17280
  bailed = false;
17235
17281
  constructor(text, kotlin) {
17282
+ super("code");
17236
17283
  this.text = text;
17237
17284
  this.kotlin = kotlin;
17238
17285
  this.rawStringContext = kotlin ? "raw-string" : "text-block";
@@ -17242,13 +17289,9 @@ var KtJavaLexer = class {
17242
17289
  while (this.i < this.n && !this.bailed) this.step();
17243
17290
  if (this.bailed) return null;
17244
17291
  if (this.mode === "line-comment") this.mode = "code";
17245
- if (this.n > this.spanStart) this.spans.push({
17246
- start: this.spanStart,
17247
- end: this.n,
17248
- context: this.spanContext
17249
- });
17292
+ const spans = this.finish(this.n);
17250
17293
  if (this.mode !== "code" || this.stack.length > 0) return null;
17251
- return this.spans;
17294
+ return spans;
17252
17295
  }
17253
17296
  bail() {
17254
17297
  this.bailed = true;
@@ -17256,16 +17299,6 @@ var KtJavaLexer = class {
17256
17299
  char(offset = 0) {
17257
17300
  return this.text[this.i + offset] ?? "";
17258
17301
  }
17259
- flushTo(end, context) {
17260
- if (context === this.spanContext) return;
17261
- if (end > this.spanStart) this.spans.push({
17262
- start: this.spanStart,
17263
- end,
17264
- context: this.spanContext
17265
- });
17266
- this.spanStart = end;
17267
- this.spanContext = context;
17268
- }
17269
17302
  step() {
17270
17303
  switch (this.mode) {
17271
17304
  case "code": return this.stepCode();
@@ -17378,7 +17411,7 @@ const javaFamily = {
17378
17411
  //#region src/chars-check/context-markup.ts
17379
17412
  const TAG_START = /[A-Za-z!?]/;
17380
17413
  const TAG_NAME_CHAR = /[A-Za-z0-9:_-]/;
17381
- var MarkupLexer = class {
17414
+ var MarkupLexer = class extends SpanLexer {
17382
17415
  text;
17383
17416
  html;
17384
17417
  n;
@@ -17387,11 +17420,9 @@ var MarkupLexer = class {
17387
17420
  tagKind = "open";
17388
17421
  pendingTagName = "";
17389
17422
  islandCloseTag = "";
17390
- spans = [];
17391
- spanStart = 0;
17392
- spanContext = "markup-text";
17393
17423
  bailed = false;
17394
17424
  constructor(text, html) {
17425
+ super("markup-text");
17395
17426
  this.text = text;
17396
17427
  this.html = html;
17397
17428
  this.n = text.length;
@@ -17399,13 +17430,9 @@ var MarkupLexer = class {
17399
17430
  run() {
17400
17431
  while (this.i < this.n && !this.bailed) this.step();
17401
17432
  if (this.bailed) return null;
17402
- if (this.n > this.spanStart) this.spans.push({
17403
- start: this.spanStart,
17404
- end: this.n,
17405
- context: this.spanContext
17406
- });
17433
+ const spans = this.finish(this.n);
17407
17434
  if (this.mode !== "text") return null;
17408
- return this.spans;
17435
+ return spans;
17409
17436
  }
17410
17437
  bail() {
17411
17438
  this.bailed = true;
@@ -17413,16 +17440,6 @@ var MarkupLexer = class {
17413
17440
  char(offset = 0) {
17414
17441
  return this.text[this.i + offset] ?? "";
17415
17442
  }
17416
- flushTo(end, context) {
17417
- if (context === this.spanContext) return;
17418
- if (end > this.spanStart) this.spans.push({
17419
- start: this.spanStart,
17420
- end,
17421
- context: this.spanContext
17422
- });
17423
- this.spanStart = end;
17424
- this.spanContext = context;
17425
- }
17426
17443
  step() {
17427
17444
  switch (this.mode) {
17428
17445
  case "text": return this.stepText();
@@ -17598,17 +17615,15 @@ function conditionalParseVerify(tryParse) {
17598
17615
  return tryParse(rewritten);
17599
17616
  };
17600
17617
  }
17601
- var JsonLexer = class {
17618
+ var JsonLexer = class extends SpanLexer {
17602
17619
  text;
17603
17620
  commentsAllowed;
17604
17621
  n;
17605
17622
  i = 0;
17606
17623
  mode = "code";
17607
- spans = [];
17608
- spanStart = 0;
17609
- spanContext = "code";
17610
17624
  bailed = false;
17611
17625
  constructor(text, commentsAllowed) {
17626
+ super("code");
17612
17627
  this.text = text;
17613
17628
  this.commentsAllowed = commentsAllowed;
17614
17629
  this.n = text.length;
@@ -17617,13 +17632,9 @@ var JsonLexer = class {
17617
17632
  while (this.i < this.n && !this.bailed) this.step();
17618
17633
  if (this.bailed) return null;
17619
17634
  if (this.mode === "line-comment") this.mode = "code";
17620
- if (this.n > this.spanStart) this.spans.push({
17621
- start: this.spanStart,
17622
- end: this.n,
17623
- context: this.spanContext
17624
- });
17635
+ const spans = this.finish(this.n);
17625
17636
  if (this.mode !== "code") return null;
17626
- return this.spans;
17637
+ return spans;
17627
17638
  }
17628
17639
  bail() {
17629
17640
  this.bailed = true;
@@ -17631,16 +17642,6 @@ var JsonLexer = class {
17631
17642
  char(offset = 0) {
17632
17643
  return this.text[this.i + offset] ?? "";
17633
17644
  }
17634
- flushTo(end, context) {
17635
- if (context === this.spanContext) return;
17636
- if (end > this.spanStart) this.spans.push({
17637
- start: this.spanStart,
17638
- end,
17639
- context: this.spanContext
17640
- });
17641
- this.spanStart = end;
17642
- this.spanContext = context;
17643
- }
17644
17645
  step() {
17645
17646
  switch (this.mode) {
17646
17647
  case "code": return this.stepCode();
@@ -19116,6 +19117,7 @@ function liftedFactsOf(resolved, forgeDown) {
19116
19117
  return {
19117
19118
  runLive: complete || read.runLive.length > 0 ? read.runLive : null,
19118
19119
  heldByHand: complete || read.heldByHand ? read.heldByHand : null,
19120
+ heldBy: complete || read.heldBy !== null ? read.heldBy : null,
19119
19121
  owner: complete || ownership.owner === "agent" ? ownership.owner : null
19120
19122
  };
19121
19123
  }
@@ -19232,6 +19234,7 @@ async function buildWorkStatus(deps, ref) {
19232
19234
  },
19233
19235
  runLive: lifted.runLive,
19234
19236
  heldByHand: lifted.heldByHand,
19237
+ heldBy: lifted.heldBy,
19235
19238
  owner: lifted.owner,
19236
19239
  object: await section(() => objectSection(inputs)),
19237
19240
  docs: await section(() => docsSection(inputs)),
@@ -19305,7 +19308,7 @@ function renderWorkStatus(report, options) {
19305
19308
  const lines = [heading(report.target)];
19306
19309
  for (const label of report.runLive ?? []) lines.push(`RUN LIVE: ${label} -- a run is working this object; do not start another.`);
19307
19310
  if (report.runLive === null || report.heldByHand === null) lines.push("UNKNOWN: whether a run is live or a human holds this -- not every label could be read.");
19308
- if (report.heldByHand === true) lines.push("HELD BY HAND: agent-flags/hand-authored -- a human claimed this one; do not drive it.");
19311
+ if (report.heldBy !== null) lines.push(`HELD BY HAND: ${report.heldBy} -- a human claimed this one; do not drive it.`);
19309
19312
  if (options?.agentEnabled === true && report.owner === "unclaimed") {
19310
19313
  const number = claimableNumber(report);
19311
19314
  if (number !== null) lines.push(`UNCLAIMED: no agent label and no hand claim -- run \`pnpm exec bst work:start ${String(number)}\` before you work this.`);
@@ -19342,7 +19345,7 @@ function renderWorkStatus(report, options) {
19342
19345
  //#endregion
19343
19346
  //#region src/commands/work-start.ts
19344
19347
  function claimLine(result) {
19345
- if (result.outcome === "claimed") return `claim: claimed -- ${result.label ?? "agent-flags/hand-authored"} is on this object.`;
19348
+ if (result.outcome === "claimed") return `claim: claimed -- ${result.label ?? "agent-flags/human-driven"} is on this object.`;
19346
19349
  if (result.outcome === "already-claimed") return "claim: already-claimed -- the flag is already on it; nothing was written.";
19347
19350
  if (result.outcome === "not-agent-repo") return `claim: not-agent-repo -- ${result.reason ?? "nothing was claimed."}`;
19348
19351
  return `claim: ${result.outcome} -- ${result.reason ?? "nothing was claimed."}`;
@@ -19353,7 +19356,7 @@ function claimFailed(result) {
19353
19356
  const workStartCommand = defineCommand({
19354
19357
  meta: {
19355
19358
  name: "work:start",
19356
- description: "Claim an issue or pull request for hand work: put agent-flags/hand-authored on it so the agent leaves it alone"
19359
+ description: "Claim an issue or pull request for hand work: put agent-flags/human-driven on it so the agent leaves it alone"
19357
19360
  },
19358
19361
  args: {
19359
19362
  ref: {
@@ -19424,7 +19427,7 @@ const workStatusCommand = defineCommand({
19424
19427
  },
19425
19428
  json: {
19426
19429
  type: "boolean",
19427
- description: "Emit one JSON document: target, runLive, heldByHand, owner (agent, person or unclaimed; each null when not every label could be read), and six sections (object, docs, labels, feedback, findings, commits), each {state: ok} with its fields, {state: absent, reason} or {state: unavailable, reason}. The output is advice, not a gate: the feedback cutoff is the newest agent run or review comment on the pull request and is approximate, and review comments on diff lines are not in the thread this reads."
19430
+ description: "Emit one JSON document: target, runLive, heldByHand, heldBy (the hold label the report found, null when none or unread), owner (agent, person or unclaimed; each null when not every label could be read), and six sections (object, docs, labels, feedback, findings, commits), each {state: ok} with its fields, {state: absent, reason} or {state: unavailable, reason}. The output is advice, not a gate: the feedback cutoff is the newest agent run or review comment on the pull request and is approximate, and review comments on diff lines are not in the thread this reads."
19428
19431
  },
19429
19432
  verbose: {
19430
19433
  type: "boolean",
@@ -19633,6 +19636,14 @@ z.object({
19633
19636
  })
19634
19637
  });
19635
19638
  //#endregion
19639
+ //#region ../cli-kit/src/env-override.ts
19640
+ function envMsOverride(raw, productionMs) {
19641
+ if (raw === void 0) return productionMs;
19642
+ const parsed = Number(raw.trim());
19643
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) return productionMs;
19644
+ return Math.min(parsed, productionMs);
19645
+ }
19646
+ //#endregion
19636
19647
  //#region src/release/publish/version-merge.ts
19637
19648
  function evaluateVersionPr(state) {
19638
19649
  const label = `PR #${String(state.prNumber)}`;
@@ -20940,11 +20951,10 @@ const releaseAssetsCommand = defineCommand({
20940
20951
  });
20941
20952
  //#endregion
20942
20953
  //#region src/lint-types/executor.ts
20943
- const MAX_BUFFER = 67108864;
20944
20954
  function runViaShim(args, cwd) {
20945
20955
  const result = spawnViaShim("pnpm", args, {
20946
20956
  cwd,
20947
- maxBuffer: MAX_BUFFER,
20957
+ maxBuffer: EXEC_MAX_BUFFER,
20948
20958
  encoding: "utf-8",
20949
20959
  stdio: [
20950
20960
  "ignore",
@@ -20966,34 +20976,17 @@ function runViaShim(args, cwd) {
20966
20976
  }
20967
20977
  function createRealLintTypesExecutor() {
20968
20978
  return { run(args, cwd) {
20969
- try {
20970
- return {
20971
- stdout: execFileSync("pnpm", args, {
20972
- cwd,
20973
- maxBuffer: MAX_BUFFER,
20974
- encoding: "utf-8",
20975
- stdio: [
20976
- "ignore",
20977
- "pipe",
20978
- "pipe"
20979
- ]
20980
- }),
20981
- stderr: "",
20982
- exitCode: 0
20983
- };
20984
- } catch (err) {
20985
- if (isExecSyncError(err)) return {
20986
- stdout: err.stdout,
20987
- stderr: err.stderr,
20988
- exitCode: err.status
20989
- };
20990
- if (shouldRetryViaShim(err)) return runViaShim(args, cwd);
20991
- return {
20992
- stdout: "",
20993
- stderr: describeError$1(err),
20994
- exitCode: 1
20995
- };
20996
- }
20979
+ const result = execCapture$2("pnpm", args, {
20980
+ cwd,
20981
+ stdin: "ignore",
20982
+ keepPartialStdoutOnKill: false
20983
+ });
20984
+ if (result.error !== void 0 && shouldRetryViaShim(result.error)) return runViaShim(args, cwd);
20985
+ return {
20986
+ stdout: result.stdout,
20987
+ stderr: result.stderr,
20988
+ exitCode: result.status
20989
+ };
20997
20990
  } };
20998
20991
  }
20999
20992
  //#endregion
@@ -21580,7 +21573,7 @@ const HealthStateSchema = z.object({
21580
21573
  Start: z.string(),
21581
21574
  ExitCode: z.number(),
21582
21575
  Output: z.string()
21583
- }))
21576
+ })).nullable().transform((log) => log ?? [])
21584
21577
  });
21585
21578
  const HEALTH_INSPECT_FORMAT = "{{json .State.Health}}";
21586
21579
  function parseHealthState(stdout) {
@@ -23054,47 +23047,17 @@ function deriveRecord(summary, options) {
23054
23047
  //#region src/coverage-tracking/executor.ts
23055
23048
  function createRealCoverageExecutor() {
23056
23049
  return { exec(file, args, options) {
23057
- try {
23058
- return {
23059
- stdout: execFileSync(file, args, {
23060
- cwd: options?.cwd,
23061
- env: options?.env ? {
23062
- ...process.env,
23063
- ...options.env
23064
- } : void 0,
23065
- input: options?.input,
23066
- encoding: "utf-8",
23067
- stdio: [
23068
- "pipe",
23069
- "pipe",
23070
- "pipe"
23071
- ],
23072
- maxBuffer: 67108864
23073
- }),
23074
- stderr: "",
23075
- exitCode: 0
23076
- };
23077
- } catch (err) {
23078
- if (isExecSyncError(err)) return {
23079
- stdout: err.stdout,
23080
- stderr: err.stderr,
23081
- exitCode: err.status
23082
- };
23083
- if (isKilledExecError(err)) {
23084
- const detail = describeError$1(err);
23085
- const stderr = err.stderr.trim() === "" ? detail : `${err.stderr}\n${detail}`;
23086
- return {
23087
- stdout: err.stdout,
23088
- stderr,
23089
- exitCode: 1
23090
- };
23091
- }
23092
- return {
23093
- stdout: "",
23094
- stderr: describeError$1(err),
23095
- exitCode: 1
23096
- };
23097
- }
23050
+ const result = execCapture$2(file, args, {
23051
+ cwd: options?.cwd,
23052
+ env: options?.env,
23053
+ input: options?.input,
23054
+ keepPartialStdoutOnKill: true
23055
+ });
23056
+ return {
23057
+ stdout: result.stdout,
23058
+ stderr: result.stderr,
23059
+ exitCode: result.status
23060
+ };
23098
23061
  } };
23099
23062
  }
23100
23063
  //#endregion
@@ -26051,12 +26014,6 @@ const BranchEntrySchema = z.object({
26051
26014
  });
26052
26015
  const BRANCHES_PAGE_SIZE = 50;
26053
26016
  const DEFAULT_MAX_PAGES = 20;
26054
- function repoBase(conn) {
26055
- return `${conn.serverUrl}/api/v1/repos/${conn.repository}`;
26056
- }
26057
- function authHeaders(conn) {
26058
- return { Authorization: `token ${conn.token}` };
26059
- }
26060
26017
  async function listBranches(executor, conn, options = {}) {
26061
26018
  const signal = options.signal;
26062
26019
  const maxPages = options.maxPages ?? DEFAULT_MAX_PAGES;
@@ -29592,7 +29549,7 @@ async function runCli(config) {
29592
29549
  //#region src/cli-main.ts
29593
29550
  setLogLevel(resolveLogLevel({}));
29594
29551
  setForgejoLogger(log$1);
29595
- const displayVersion = "0.97.0";
29552
+ const displayVersion = "0.98.0";
29596
29553
  const bstSubCommands = {
29597
29554
  "repo:sync": syncCommand,
29598
29555
  "checks:run": runChecksCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensandee/tooling",
3
- "version": "0.97.0",
3
+ "version": "0.98.0",
4
4
  "description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
5
5
  "license": "MIT",
6
6
  "repository": {