@bensandee/tooling 0.97.0 → 0.99.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/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.99.0"
179
179
  });
180
180
  //#endregion
181
181
  //#region ../cli-kit/src/logger.ts
@@ -1742,16 +1742,17 @@ const FindingHoldsConfigSchema = z.strictObject({
1742
1742
  const LintSweepConfigSchema = z.strictObject({
1743
1743
  enabled: z.boolean().optional().meta({ description: "Whether the agent's lint-warning sweep may open pull requests in this repo (default: on). false disarms it; the repo is then never cloned or measured by it." }),
1744
1744
  minWarnings: z.number().int().nonnegative().optional().meta({ description: "How many oxlint warnings the default branch must carry before the sweep opens a pull request (default 5). Below the floor the warn marker on checks:run is the whole response." }),
1745
- cooldownDays: z.number().int().nonnegative().optional().meta({ description: "Days after a lint-sweep pull request merged or closed before the sweep may open another (default 7): a merged sweep whose declined warnings survive must not re-file them the next morning." })
1745
+ cooldownDays: z.number().int().nonnegative().optional().meta({ description: "Days after a lint-sweep pull request merged or closed before the sweep may open another (default 7): a merged sweep whose declined warnings survive must not re-file them the next morning." }),
1746
+ compatIssues: z.boolean().optional().meta({ description: "Whether the sweep splits expired @compat warnings out of its plan and files one issue per expired id (default: on). false keeps them in the bulk plan with the other warnings." })
1746
1747
  });
1747
- const AgentEgressConfigSchema = z.strictObject({ browseHosts: z.array(z.string().min(1)).optional().meta({ description: "Host patterns this repo's agent containers may fetch from, on top of the hosts every run needs: an exact host (`fastdl.mongodb.org`) or a wildcard over its leftmost label (`*.example.com`). No ports. These join the browse lane, which serves GET and HEAD only." }) });
1748
+ const AgentEgressConfigSchema = z.strictObject({ browseHosts: z.array(z.string().min(1)).optional().meta({ description: "Host patterns this repo's agent containers ask to fetch from, on top of the hosts every run needs: an exact host (`fastdl.mongodb.org`) or a wildcard over its leftmost label (`*.example.com`). No ports. This list is a request the deployment grants, not an opening: its grant mode decides whether a default branch's requests take effect on their own, an admin can refuse a host for this repo, and a host the product or the deployment known-denies is never opened whatever the declaration or the verdict says. What is granted joins the browse lane, which serves GET and HEAD only." }) });
1748
1749
  const AgentConfigSchema = z.strictObject({
1749
1750
  enabled: z.boolean().optional().meta({ description: "The repo's explicit consent to the agent (default false). Only `true`, read from the repo's **default branch**, lets the agent work the repo: claim units, run sweeps, recover orphans, merge, act on a chat proposal or start a new spec. A missing key, `false`, a missing `.tooling.json` or a read that fails all mean not enabled, and the answer is re-read within about a minute. Every other `agent.*` key below has no effect without this one; `repo:sync` warns when the block sets one of them and this key is not `true`. Where this is `true`, `repo:sync` also installs `@bensandee/agent-cli`. `pnpm exec bst setup:agent` sets it to true and runs the sync. Provisioning the agent's labels is not consent, and is never gated by this key." }),
1750
1751
  autonomy: z.boolean().optional().meta({ description: "Retired and ignored -- it armed neither the advance rung nor the sweeps it once did. Advance is now the unit's own `agent-flags/advance` or `agent-flags/autopilot` label, and the trunk-red detector and world-changed retrigger sweep read `agent.trunkRed`. The key is still accepted so an existing config keeps syncing; the agent warns once per launch for a repo that still sets it." }),
1751
1752
  trunkRed: z.boolean().optional().meta({ description: "Whether this repo's trunk-red detector and world-changed retrigger sweep run (default: on). The detector files a tracking issue when the default branch's combined status settles red and labels it agent/spec, and closes that issue with a comment if the branch recovers on its own before a human acts on it. The retrigger sweep re-queues a pull request labelled agent-flags/autopilot parked at a -stuck or -failed terminal when the fact its park recorded stops being true (the default branch went green, or moved past a conflicted base). A missing key means on; false disarms both." }),
1752
1753
  preRunRebase: z.boolean().optional().meta({ description: "Merge the current default branch into the work branch before the container starts (default true) -- for an implement (execute) run, and for a spec or plan rerun on an existing branch. A clean merge or an already-up-to-date branch runs the container as is; a conflicting merge is aborted, recorded on the run's status comment, and the run proceeds on the un-synced branch -- a conflict, timeout or failed merge never fails the run, for any phase. Only the execute phase keeps the two-strike rule: two consecutive conflicting attempts hand the unit to agent/repair before any container runs, while a docs run just tries again on its next slice. Set false to skip the attempt entirely for this repo, in every phase: no fetch, no merge, no abort, and the branch is worked exactly as cloned." }),
1753
1754
  backlog: z.boolean().optional().meta({ description: "Whether the agent may self-trigger backlog runs consuming this repo's .agent/findings/ ledger (default: on wherever the ledger exists, which only happens in a repo whose own review loop wrote it). A backlog run opens a pull request that fixes or refutes the pending findings; false disarms it, leaving the ledger to accumulate for a human. A run starts only once at least three findings are pending or one is older than seven days." }),
1754
- lintSweep: LintSweepConfigSchema.optional().meta({ description: "The lint-warning sweep: a periodic agent job that measures this repo's oxlint warnings on its default branch in a container and, past minWarnings, opens a pull request carrying a generated plan for an agent/implement run to work off." }),
1755
+ lintSweep: LintSweepConfigSchema.optional().meta({ description: "The lint-warning sweep: a periodic agent job that measures this repo's oxlint warnings on its default branch in a container and, past minWarnings, opens a pull request carrying a generated plan for an agent/implement run to work off. Expired @compat warnings leave that plan and each get their own issue instead (see compatIssues)." }),
1755
1756
  priority: z.record(z.string(), z.enum([
1756
1757
  "critical",
1757
1758
  "high",
@@ -1759,7 +1760,7 @@ const AgentConfigSchema = z.strictObject({
1759
1760
  "low"
1760
1761
  ])).optional().meta({ description: "Map this repo's own issue-label names onto the agent's four priority levels, e.g. {\"P1\": \"critical\", \"P4\": \"low\"}. The map UNIONS with the built-in priority/<level> names rather than replacing them, and the agent does not create aliased labels -- the repo owns names the agent did not choose. Priority affects claim order only: it never changes a run's model, effort, or any budget." }),
1761
1762
  triageAnalysis: z.boolean().optional().meta({ description: "Whether the agent may route its own agent-note/human-triage-needed issues through the agent/analyze stage (default: off). Unlike agent.backlog, which defaults on, this defaults off: a backlog run batches every pending finding into one container, while triage routing spends one container per issue -- arming it is the reversible direction, not disarming it." }),
1762
- egress: AgentEgressConfigSchema.optional().meta({ description: "Extra egress hosts this repo's agent containers may reach. `browseHosts` joins the agent's browse lane (GET and HEAD only) on top of the hosts every run needs; the passthrough lane stays agent-owned. Each entry is a host pattern -- an exact host or a *.host wildcard, never a port. Read from the repo's DEFAULT BRANCH, never off a pull request's own tree, so a run can never widen its own egress: the declaration takes effect on the first container started after a human merges it. An entry whose pattern the agent cannot parse refuses the run rather than being dropped. Changing this block holds the pull request from automerge." }),
1763
+ egress: AgentEgressConfigSchema.optional().meta({ description: "Extra egress hosts this repo's agent containers ask to reach -- a request the deployment grants, not an opening of a host. `browseHosts` joins the agent's browse lane (GET and HEAD only) on top of the hosts every run needs; the passthrough lane stays agent-owned. Each entry is a host pattern -- an exact host or a *.host wildcard, never a port. Read from the repo's DEFAULT BRANCH, never off a pull request's own tree, so a run can never widen its own egress: under the default `auto` grant mode the request takes effect on the first container started after a human merges it, and under `approve` it waits for an admin's grant for this repo. A host the product or the deployment known-denies is never opened, whatever the declaration or the verdict says. An entry whose pattern the agent cannot parse refuses the run rather than being dropped. Changing this block holds the pull request from automerge." }),
1763
1764
  findingHolds: FindingHoldsConfigSchema.optional().meta({ description: "Which of a pull request's linked open findings withhold its unattended merge. `rules` is ordered and the first `when` that matches decides; no match falls through to `default`; an absent block is { rules: [], default: true }, so every open linked finding holds by default. Read off the repo's DEFAULT BRANCH, never off the pull request's own tree -- a pull request cannot edit the rule deciding whether it is held. In a `mentions` entry a /.../flags pattern is a regular expression, a literal:<text> pattern is the substring <text> (how to name a path such as /src/utils), and anything else is a case-insensitive substring." }),
1764
1765
  chatIssueRepos: z.array(z.string().regex(REPO_FULL_NAME)).optional().meta({ description: "Repositories with a DIFFERENT owner that a control-panel chat from this repository may file an issue in, each one a full `owner/name`, never a wildcard. A repository with the same owner needs no entry, and an entry grants nothing on its own: the target must have enabled the agent too. Read from the repo's DEFAULT BRANCH at the moment a card is applied, so a pull request cannot widen the reach of its own chat. Like every other `agent.*` key, this has no effect unless `agent.enabled` is true." })
1765
1766
  });
@@ -2037,20 +2038,23 @@ function parseRepositoryUrl(cwd) {
2037
2038
  //#endregion
2038
2039
  //#region ../forgejo/src/errors.ts
2039
2040
  var ForgeAccessError = class extends FatalError {};
2040
- function authHeaders$2(conn) {
2041
+ function authHeaders(conn) {
2041
2042
  return { Authorization: `token ${conn.token}` };
2042
2043
  }
2043
2044
  function jsonHeaders(conn) {
2044
2045
  return {
2045
- ...authHeaders$2(conn),
2046
+ ...authHeaders(conn),
2046
2047
  "Content-Type": "application/json"
2047
2048
  };
2048
2049
  }
2049
2050
  function repoNotFoundMessage(conn) {
2050
2051
  return `Repository ${conn.repository} not found (or the token cannot see it)`;
2051
2052
  }
2053
+ function repoBase(conn) {
2054
+ return `${conn.serverUrl}/api/v1/repos/${conn.repository}`;
2055
+ }
2052
2056
  function issuesBase(conn) {
2053
- return `${conn.serverUrl}/api/v1/repos/${conn.repository}/issues`;
2057
+ return `${repoBase(conn)}/issues`;
2054
2058
  }
2055
2059
  function issueNotFoundMessage(conn, number) {
2056
2060
  return `Issue #${String(number)} not found in ${conn.repository}`;
@@ -2248,6 +2252,14 @@ function loadRegistryHostOverride(cwd) {
2248
2252
  }
2249
2253
  //#endregion
2250
2254
  //#region src/release/docker-bake.ts
2255
+ function escapeBakeTemplate(value) {
2256
+ return value.replace(/\$\{/gu, () => "$${").replace(/%\{/gu, () => "%%{");
2257
+ }
2258
+ function escapeBakeTemplateValues(values) {
2259
+ const escaped = {};
2260
+ for (const [key, value] of Object.entries(values)) escaped[key] = escapeBakeTemplate(value);
2261
+ return escaped;
2262
+ }
2251
2263
  function uniqueTargetName(taken, imageName) {
2252
2264
  const root = imageName.replace(/[^A-Za-z0-9_-]/gu, "_");
2253
2265
  const candidate = (suffix) => suffix === 1 ? root : `${root}_${String(suffix)}`;
@@ -2272,11 +2284,11 @@ function buildBakeDefinition(images) {
2272
2284
  const targets = [];
2273
2285
  for (const { image, target: name } of named) {
2274
2286
  const entry = {
2275
- context: image.context,
2276
- dockerfile: image.dockerfile,
2277
- tags: [`${image.imageName}:latest`],
2278
- args: image.args,
2279
- labels: image.labels
2287
+ context: escapeBakeTemplate(image.context),
2288
+ dockerfile: escapeBakeTemplate(image.dockerfile),
2289
+ tags: [escapeBakeTemplate(`${image.imageName}:latest`)],
2290
+ args: escapeBakeTemplateValues(image.args),
2291
+ labels: escapeBakeTemplateValues(image.labels)
2280
2292
  };
2281
2293
  if (image.bases.length > 0) {
2282
2294
  const contexts = {};
@@ -2727,6 +2739,51 @@ function fetchWithRetry(fetchImpl, policy = DEFAULT_RETRY_POLICY, defaultTimeout
2727
2739
  }
2728
2740
  //#endregion
2729
2741
  //#region src/utils/exec.ts
2742
+ const EXEC_MAX_BUFFER = 67108864;
2743
+ function execCapture$2(file, args, options) {
2744
+ try {
2745
+ return {
2746
+ status: 0,
2747
+ stdout: execFileSync(file, args, {
2748
+ cwd: options.cwd,
2749
+ env: options.env ? {
2750
+ ...process.env,
2751
+ ...options.env
2752
+ } : void 0,
2753
+ input: options.input,
2754
+ encoding: "utf-8",
2755
+ stdio: [
2756
+ options.stdin ?? "pipe",
2757
+ "pipe",
2758
+ "pipe"
2759
+ ],
2760
+ maxBuffer: EXEC_MAX_BUFFER
2761
+ }),
2762
+ stderr: ""
2763
+ };
2764
+ } catch (err) {
2765
+ if (isExecSyncError(err)) return {
2766
+ status: err.status,
2767
+ stdout: err.stdout,
2768
+ stderr: err.stderr
2769
+ };
2770
+ if (options.keepPartialStdoutOnKill && isKilledExecError(err)) {
2771
+ const detail = describeError$1(err);
2772
+ const stderr = err.stderr.trim() === "" ? detail : `${err.stderr}\n${detail}`;
2773
+ return {
2774
+ status: 1,
2775
+ stdout: err.stdout,
2776
+ stderr
2777
+ };
2778
+ }
2779
+ return {
2780
+ status: 1,
2781
+ stdout: "",
2782
+ stderr: describeError$1(err),
2783
+ error: err
2784
+ };
2785
+ }
2786
+ }
2730
2787
  function isExecSyncError(err) {
2731
2788
  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
2789
  }
@@ -3778,6 +3835,15 @@ function sortPackagesByDependency(packages, executor, cwd) {
3778
3835
  }
3779
3836
  return sorted;
3780
3837
  }
3838
+ function refuseDuplicateImageNames(packages) {
3839
+ const dirsByImageName = /* @__PURE__ */ new Map();
3840
+ for (const pkg of packages) {
3841
+ const dirs = dirsByImageName.get(pkg.imageName);
3842
+ if (dirs === void 0) dirsByImageName.set(pkg.imageName, [pkg.dir]);
3843
+ else dirs.push(pkg.dir);
3844
+ }
3845
+ 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`);
3846
+ }
3781
3847
  function detectDockerPackages(executor, cwd, repoName, phase = DOCKER_CHECK_ONLY_PHASE) {
3782
3848
  const { overrides, composeFiles } = loadDockerConfigSlice(executor, cwd);
3783
3849
  const packageDirs = executor.listPackageDirs(cwd);
@@ -3836,6 +3902,7 @@ function detectDockerPackages(executor, cwd, repoName, phase = DOCKER_CHECK_ONLY
3836
3902
  origin: NO_COMPOSE_ORIGIN
3837
3903
  }));
3838
3904
  }
3905
+ refuseDuplicateImageNames(packages);
3839
3906
  return sortPackagesByDependency(packages, executor, cwd);
3840
3907
  }
3841
3908
  function readSinglePackageDocker(executor, cwd, packageDir, repoName) {
@@ -5634,9 +5701,9 @@ function buildManagedDevDeps(ctx) {
5634
5701
  const devDeps = { ...rootDevDeps(ctx.config) };
5635
5702
  if (!isMonorepo) Object.assign(devDeps, perPackageDevDeps(ctx.config));
5636
5703
  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";
5704
+ if (!isWorkspacePackage(ctx, "@bensandee/tooling")) devDeps["@bensandee/tooling"] = "0.99.0";
5638
5705
  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";
5706
+ if (wantsAgentCli(ctx)) devDeps[AGENT_CLI_PACKAGE] = "0.2.0";
5640
5707
  if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = {
5641
5708
  "@changesets/cli": "3.0.3",
5642
5709
  "@release-it/bumper": "8.0.1",
@@ -9558,13 +9625,13 @@ const GIT_GUIDE_BODY = [
9558
9625
  "",
9559
9626
  "## Claiming work by hand",
9560
9627
  "",
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.",
9628
+ "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
9629
  "",
9563
9630
  "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
9631
  "",
9565
9632
  "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
9633
  "",
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.",
9634
+ "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
9635
  "",
9569
9636
  "## Issue linking",
9570
9637
  "",
@@ -10274,7 +10341,7 @@ function reportFailures(failed, command) {
10274
10341
  function generateMigratePrompt(results, config, detected) {
10275
10342
  const sections = [];
10276
10343
  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`);
10344
+ sections.push(`# Migration Prompt\n\n_Generated by \`@bensandee/tooling@0.99.0 repo:sync\` on ${timestamp}_\n`);
10278
10345
  const changed = results.filter((r) => r.action === "created" || r.action === "updated" || r.action === "archived");
10279
10346
  if (changed.length > 0) {
10280
10347
  const items = changed.map((r) => {
@@ -11158,38 +11225,17 @@ function groupSkippedSteps(steps, defined, flagSkip, configSkip) {
11158
11225
  function createRealHealthExecutor(rootDir) {
11159
11226
  return {
11160
11227
  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
- }
11228
+ const result = execCapture$2(file, args, {
11229
+ cwd: options?.cwd ?? rootDir,
11230
+ env: options?.env,
11231
+ input: options?.input,
11232
+ keepPartialStdoutOnKill: false
11233
+ });
11234
+ return {
11235
+ stdout: result.stdout,
11236
+ stderr: result.stderr,
11237
+ exitCode: result.status
11238
+ };
11193
11239
  },
11194
11240
  readFile(rel) {
11195
11241
  const full = path.join(rootDir, rel);
@@ -13616,200 +13662,6 @@ async function runPublishMode(executor, config) {
13616
13662
  };
13617
13663
  }
13618
13664
  //#endregion
13619
- //#region ../forgejo/src/commit-status.ts
13620
- const CombinedStatusSchema = z.object({
13621
- state: z.string(),
13622
- statuses: z.array(z.unknown())
13623
- });
13624
- const CheckEntrySchema = z.object({
13625
- context: z.string().nullish(),
13626
- status: z.string().nullish(),
13627
- description: z.string().nullish(),
13628
- target_url: z.string().nullish(),
13629
- updated_at: z.string().nullish(),
13630
- id: z.number().nullish()
13631
- });
13632
- function isSettledRed(checks) {
13633
- if (!checks.parsed || checks.green || checks.contexts.length === 0) return false;
13634
- if (checks.contexts.some((context) => context.verdict === "pending")) return false;
13635
- return checks.contexts.some((context) => context.verdict === "red");
13636
- }
13637
- const TRAILING_EVENT = / \([^()]+\)$/;
13638
- function classifyVerdict(state) {
13639
- if (state === "success") return "good";
13640
- if (state === "pending") return "pending";
13641
- if (state === "skipped" || state === "neutral") return "skipped";
13642
- return "red";
13643
- }
13644
- function entryKey(entry, index) {
13645
- if (typeof entry.context === "string" && entry.context.length > 0) return entry.context;
13646
- return `#${String(index)}`;
13647
- }
13648
- function updatedAtMillis(value) {
13649
- if (!value) return 0;
13650
- const parsed = Date.parse(value);
13651
- return Number.isNaN(parsed) ? 0 : parsed;
13652
- }
13653
- function dedupeEntries(entries) {
13654
- const byKey = /* @__PURE__ */ new Map();
13655
- entries.forEach((entry, index) => {
13656
- const key = entryKey(entry, index);
13657
- const existing = byKey.get(key);
13658
- if (!existing) {
13659
- byKey.set(key, {
13660
- entry,
13661
- index
13662
- });
13663
- return;
13664
- }
13665
- const existingUpdated = updatedAtMillis(existing.entry.updated_at);
13666
- const candidateUpdated = updatedAtMillis(entry.updated_at);
13667
- if (candidateUpdated > existingUpdated) {
13668
- byKey.set(key, {
13669
- entry,
13670
- index
13671
- });
13672
- return;
13673
- }
13674
- if (candidateUpdated === existingUpdated) {
13675
- const existingId = existing.entry.id ?? -Infinity;
13676
- if ((entry.id ?? -Infinity) > existingId) byKey.set(key, {
13677
- entry,
13678
- index
13679
- });
13680
- }
13681
- });
13682
- const sorted = [...byKey.values()];
13683
- sorted.sort((a, b) => a.index - b.index);
13684
- return sorted;
13685
- }
13686
- async function readCommitChecks(executor, conn, sha) {
13687
- const url = `${conn.serverUrl}/api/v1/repos/${conn.repository}/commits/${sha}/status`;
13688
- const res = await executor.fetch(url, { headers: { Authorization: `token ${conn.token}` } });
13689
- if (!res.ok) await throwForgejoFailure(res, {
13690
- verb: "read commit status",
13691
- resource: sha
13692
- });
13693
- const body = await res.json();
13694
- const parsed = CombinedStatusSchema.safeParse(body);
13695
- if (!parsed.success) return {
13696
- parsed: false,
13697
- state: "",
13698
- green: false,
13699
- contexts: []
13700
- };
13701
- const green = parsed.data.state === "success" && parsed.data.statuses.length > 0;
13702
- const EMPTY_ENTRY = {
13703
- context: null,
13704
- status: null,
13705
- description: null,
13706
- target_url: null,
13707
- updated_at: null,
13708
- id: null
13709
- };
13710
- const contexts = dedupeEntries(parsed.data.statuses.map((raw) => {
13711
- const entryParsed = CheckEntrySchema.safeParse(raw);
13712
- return entryParsed.success ? entryParsed.data : EMPTY_ENTRY;
13713
- })).map(({ entry }) => {
13714
- const context = entry.context ?? "";
13715
- return {
13716
- context,
13717
- name: context.replace(TRAILING_EVENT, ""),
13718
- state: entry.status ?? "",
13719
- verdict: classifyVerdict(entry.status),
13720
- description: entry.description ?? null,
13721
- targetUrl: entry.target_url ?? null,
13722
- updatedAt: entry.updated_at ?? null
13723
- };
13724
- });
13725
- return {
13726
- parsed: true,
13727
- state: parsed.data.state,
13728
- green,
13729
- contexts
13730
- };
13731
- }
13732
- //#endregion
13733
- //#region src/release/publish/unpublished-bump.ts
13734
- async function unpublishedBumpTags(executor, config) {
13735
- const packages = executor.listWorkspacePackages(config.cwd);
13736
- if (packages.length === 0) return [];
13737
- const auth = buildGitAuth(config);
13738
- const listing = executor.exec("git", [
13739
- ...auth.args,
13740
- "ls-remote",
13741
- "--tags",
13742
- auth.url
13743
- ], { cwd: config.cwd });
13744
- if (listing.exitCode !== 0) {
13745
- log$1.warn(`Could not list the remote's tags, so this run does not check for an unpublished version: ${listing.stderr || listing.stdout}`);
13746
- return [];
13747
- }
13748
- const remoteTags = parseRemoteTagTargets(listing.stdout);
13749
- const missing = [];
13750
- const anchors = /* @__PURE__ */ new Set();
13751
- for (const pkg of packages) {
13752
- const family = changesetsTagFamily(pkg.name);
13753
- let newest;
13754
- let below = true;
13755
- for (const [tag, target] of remoteTags) {
13756
- const version = family.versionOfExact(tag);
13757
- if (version === void 0) continue;
13758
- if (compareReleaseVersions(pkg.version, version) !== 1) below = false;
13759
- if (!newest || compareReleaseVersions(version, newest.version) === 1) newest = {
13760
- version,
13761
- commit: target.commit
13762
- };
13763
- }
13764
- if (newest && below) {
13765
- missing.push(family.exact(pkg.version));
13766
- anchors.add(newest.commit);
13767
- }
13768
- }
13769
- if (missing.length === 0) return [];
13770
- debug(config, `Unpublished version guard: remote lacks ${missing.join(", ")}`);
13771
- const commits = mainCommitsSince(executor, config, [...anchors]);
13772
- if (commits.length === 0) return [];
13773
- const conn = {
13774
- serverUrl: config.serverUrl,
13775
- repository: config.repository,
13776
- token: config.token
13777
- };
13778
- for (const sha of commits) try {
13779
- const checks = await readCommitChecks(executor, conn, sha);
13780
- if (!checks.green && !isSettledRed(checks)) {
13781
- debug(config, `Unpublished version guard: ${sha} has not settled (state "${checks.state}") -- its run may still publish`);
13782
- return [];
13783
- }
13784
- } catch (error) {
13785
- log$1.warn(`Could not read the CI status of ${sha}, so this run does not publish ${missing.join(", ")}: ${describeError$1(error)}`);
13786
- return [];
13787
- }
13788
- return missing;
13789
- }
13790
- function mainCommitsSince(executor, config, anchors) {
13791
- const commits = /* @__PURE__ */ new Set();
13792
- for (const anchor of anchors) {
13793
- const range = executor.exec("git", [
13794
- "rev-list",
13795
- "--first-parent",
13796
- "--reverse",
13797
- "HEAD~1",
13798
- `^${anchor}`
13799
- ], { cwd: config.cwd });
13800
- if (range.exitCode !== 0) {
13801
- debug(config, `Unpublished version guard: could not list commits after ${anchor}`);
13802
- return [];
13803
- }
13804
- for (const line of range.stdout.split("\n")) {
13805
- const sha = line.trim();
13806
- if (sha !== "") commits.add(sha);
13807
- }
13808
- }
13809
- if (commits.size === 0) debug(config, "Unpublished version guard: no main commit follows the last release tag");
13810
- return [...commits];
13811
- }
13812
- //#endregion
13813
13665
  //#region ../forgejo/src/user.ts
13814
13666
  const AuthenticatedUserSchema = z.object({
13815
13667
  login: z.string(),
@@ -13817,7 +13669,7 @@ const AuthenticatedUserSchema = z.object({
13817
13669
  });
13818
13670
  async function getAuthenticatedUser(executor, conn, signal = null) {
13819
13671
  const res = await executor.fetch(`${conn.serverUrl}/api/v1/user`, {
13820
- headers: authHeaders$2(conn),
13672
+ headers: authHeaders(conn),
13821
13673
  signal
13822
13674
  });
13823
13675
  if (!res.ok) return {
@@ -13844,12 +13696,6 @@ function sleep(ms) {
13844
13696
  setTimeout(resolve, ms);
13845
13697
  });
13846
13698
  }
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
13699
  //#endregion
13854
13700
  //#region src/release/git-identity.ts
13855
13701
  function ciActorName(platform) {
@@ -14014,22 +13860,10 @@ async function runRelease(config, executor, ciEvent) {
14014
13860
  return publishThenVersion(executor, config);
14015
13861
  }
14016
13862
  if (changesetFiles.length > 0) {
14017
- const unpublished = await unpublishedBumpTags(executor, config);
14018
- if (unpublished.length > 0) {
14019
- log$1.info(`Changesets are pending, but ${unpublished.join(", ")} ${unpublished.length === 1 ? "was" : "were"} never tagged and every main run since the last release tag has finished -- publishing now, then versioning the rest.`);
14020
- debug(config, "Entering publish mode for an earlier unpublished bump, then version mode");
14021
- return publishThenVersion(executor, config);
14022
- }
14023
13863
  debug(config, "Entering version mode");
14024
13864
  return runVersionMode(executor, config);
14025
13865
  }
14026
13866
  if (!bumped) {
14027
- const unpublished = await unpublishedBumpTags(executor, config);
14028
- if (unpublished.length > 0) {
14029
- log$1.info(`HEAD bumped no version, but ${unpublished.join(", ")} ${unpublished.length === 1 ? "was" : "were"} never tagged and every main run since the last release tag has finished -- publishing now.`);
14030
- debug(config, "Entering publish mode for an earlier unpublished bump");
14031
- return runPublishMode(executor, config);
14032
- }
14033
13867
  log$1.info("No changesets, and HEAD bumped no package version -- nothing to release. (Publishing runs on the commit that merges a 'version packages' PR.)");
14034
13868
  debug(config, "Publish guard: HEAD is not a version-bump commit -- skipping publish");
14035
13869
  return { mode: "none" };
@@ -14255,7 +14089,7 @@ const LABELS_MAX_PAGES = 20;
14255
14089
  async function fetchAllForgejoLabels(executor, conn) {
14256
14090
  const labels = [];
14257
14091
  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) });
14092
+ 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
14093
  if (!res.ok) await throwForgejoFailure(res, {
14260
14094
  verb: "list labels",
14261
14095
  resource: conn.repository
@@ -14320,7 +14154,7 @@ async function removeForgejoIssueLabel(executor, conn, number, name, labelIds) {
14320
14154
  const id = await resolveLabelId(executor, conn, name, labelIds);
14321
14155
  const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/labels/${String(id)}`, {
14322
14156
  method: "DELETE",
14323
- headers: authHeaders$2(conn)
14157
+ headers: authHeaders(conn)
14324
14158
  }, { idempotent: true });
14325
14159
  if (!res.ok) await throwForgejoFailure(res, {
14326
14160
  verb: "remove label",
@@ -14380,7 +14214,7 @@ async function listForgejoComments(executor, conn, number, options = {}) {
14380
14214
  limit: String(COMMENTS_PAGE_SIZE),
14381
14215
  page: String(page)
14382
14216
  });
14383
- const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/comments?${params.toString()}`, { headers: authHeaders$2(conn) });
14217
+ const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}/comments?${params.toString()}`, { headers: authHeaders(conn) });
14384
14218
  if (!res.ok) await throwForgejoFailure(res, {
14385
14219
  verb: "list comments",
14386
14220
  resource: `#${String(number)}`
@@ -14474,7 +14308,7 @@ function toIssueSummaries(raw, type = "issues") {
14474
14308
  return type === "issues" ? summaries.filter((s) => !s.isPullRequest) : summaries;
14475
14309
  }
14476
14310
  async function getForgejoIssue(executor, conn, number) {
14477
- const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}`, { headers: authHeaders$2(conn) });
14311
+ const res = await executor.fetch(`${issuesBase(conn)}/${String(number)}`, { headers: authHeaders(conn) });
14478
14312
  if (!res.ok) await throwForgejoFailure(res, {
14479
14313
  verb: "get issue",
14480
14314
  resource: `#${String(number)}`
@@ -14498,7 +14332,7 @@ function issueListParams(type, query) {
14498
14332
  return params;
14499
14333
  }
14500
14334
  async function fetchIssueListPage(executor, conn, params) {
14501
- const res = await executor.fetch(`${issuesBase(conn)}?${params.toString()}`, { headers: authHeaders$2(conn) });
14335
+ const res = await executor.fetch(`${issuesBase(conn)}?${params.toString()}`, { headers: authHeaders(conn) });
14502
14336
  if (!res.ok) await throwForgejoFailure(res, {
14503
14337
  verb: "list issues",
14504
14338
  resource: conn.repository
@@ -14894,11 +14728,15 @@ function groupLabels(names, descriptions) {
14894
14728
  }
14895
14729
  const RUNNING_LABEL = /^agent\/[a-z-]+-running$/;
14896
14730
  const QUEUED_LABEL = /^agent\/[a-z]+$/;
14897
- const HAND_AUTHORED_LABEL = "agent-flags/hand-authored";
14731
+ const HUMAN_DRIVEN_LABEL = "agent-flags/human-driven";
14732
+ const HUMAN_DRIVEN_LABEL_NAMES = [HUMAN_DRIVEN_LABEL, "agent-flags/hand-authored"];
14898
14733
  function liftedFacts(names) {
14734
+ const runLive = names.filter((name) => RUNNING_LABEL.test(name)).toSorted();
14735
+ const heldBy = HUMAN_DRIVEN_LABEL_NAMES.find((name) => names.includes(name)) ?? null;
14899
14736
  return {
14900
- runLive: names.filter((name) => RUNNING_LABEL.test(name)).toSorted(),
14901
- heldByHand: names.includes(HAND_AUTHORED_LABEL)
14737
+ runLive,
14738
+ heldByHand: heldBy !== null,
14739
+ heldBy
14902
14740
  };
14903
14741
  }
14904
14742
  function labelNamesOf(section) {
@@ -14914,7 +14752,7 @@ function ownerOf(names) {
14914
14752
  label: running,
14915
14753
  hold: "running"
14916
14754
  };
14917
- if (names.includes("agent-flags/hand-authored")) return { owner: "person" };
14755
+ if (HUMAN_DRIVEN_LABEL_NAMES.some((name) => names.includes(name))) return { owner: "person" };
14918
14756
  const queued = agent.find((name) => QUEUED_LABEL.test(name));
14919
14757
  if (queued !== void 0) return {
14920
14758
  owner: "agent",
@@ -15013,15 +14851,15 @@ function ownershipOf(report) {
15013
14851
  async function writeClaim(executor, cwd, target, number) {
15014
14852
  try {
15015
14853
  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);
14854
+ const flag = (await fetchAllForgejoLabels(executor, conn)).find((label) => label.name === HUMAN_DRIVEN_LABEL);
15017
14855
  if (flag === void 0) return {
15018
14856
  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.`
14857
+ 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
14858
  };
15021
- await addForgejoIssueLabel(executor, conn, number, HAND_AUTHORED_LABEL, /* @__PURE__ */ new Map([[HAND_AUTHORED_LABEL, flag.id]]));
14859
+ await addForgejoIssueLabel(executor, conn, number, HUMAN_DRIVEN_LABEL, /* @__PURE__ */ new Map([[HUMAN_DRIVEN_LABEL, flag.id]]));
15022
14860
  return {
15023
14861
  outcome: "claimed",
15024
- label: HAND_AUTHORED_LABEL
14862
+ label: HUMAN_DRIVEN_LABEL
15025
14863
  };
15026
14864
  } catch (error) {
15027
14865
  return {
@@ -15324,18 +15162,12 @@ z.object({
15324
15162
  created: z.string()
15325
15163
  });
15326
15164
  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
15165
  function branchNotFoundMessage(conn, branch) {
15334
15166
  return `Branch ${branch} not found in ${conn.repository}`;
15335
15167
  }
15336
15168
  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) });
15169
+ const url = `${repoBase(conn)}/branches/${encodeURIComponent(branch)}`;
15170
+ const res = await executor.fetch(url, { headers: authHeaders(conn) });
15339
15171
  if (res.status === 404) return false;
15340
15172
  if (!res.ok) await throwForgejoFailure(res, {
15341
15173
  verb: "check branch",
@@ -16828,6 +16660,34 @@ function offenderNameByCodepoint(codepoint) {
16828
16660
  return nameByCodepoint.get(codepoint);
16829
16661
  }
16830
16662
  //#endregion
16663
+ //#region src/chars-check/span-lexer.ts
16664
+ var SpanLexer = class {
16665
+ spans = [];
16666
+ spanStart = 0;
16667
+ spanContext;
16668
+ constructor(initialContext) {
16669
+ this.spanContext = initialContext;
16670
+ }
16671
+ flushTo(end, context) {
16672
+ if (context === this.spanContext) return;
16673
+ if (end > this.spanStart) this.spans.push({
16674
+ start: this.spanStart,
16675
+ end,
16676
+ context: this.spanContext
16677
+ });
16678
+ this.spanStart = end;
16679
+ this.spanContext = context;
16680
+ }
16681
+ finish(length) {
16682
+ if (length > this.spanStart) this.spans.push({
16683
+ start: this.spanStart,
16684
+ end: length,
16685
+ context: this.spanContext
16686
+ });
16687
+ return this.spans;
16688
+ }
16689
+ };
16690
+ //#endregion
16831
16691
  //#region src/chars-check/context-js-ts.ts
16832
16692
  const EXPRESSION_START_PUNCTUATION = /* @__PURE__ */ new Set([
16833
16693
  "(",
@@ -16878,7 +16738,7 @@ function isJsxNameStart(ch) {
16878
16738
  function resumeAfterTagClose(stack) {
16879
16739
  return stack[stack.length - 1]?.kind === "jsx-children" ? "jsx-text" : "code";
16880
16740
  }
16881
- var JsTsLexer = class {
16741
+ var JsTsLexer = class extends SpanLexer {
16882
16742
  text;
16883
16743
  jsx;
16884
16744
  n;
@@ -16887,11 +16747,9 @@ var JsTsLexer = class {
16887
16747
  expectsExpression = true;
16888
16748
  regexInClass = false;
16889
16749
  stack = [];
16890
- spans = [];
16891
- spanStart = 0;
16892
- spanContext = "code";
16893
16750
  bailed = false;
16894
16751
  constructor(text, jsx) {
16752
+ super("code");
16895
16753
  this.text = text;
16896
16754
  this.jsx = jsx;
16897
16755
  this.n = text.length;
@@ -16900,13 +16758,9 @@ var JsTsLexer = class {
16900
16758
  while (this.i < this.n && !this.bailed) this.step();
16901
16759
  if (this.bailed) return null;
16902
16760
  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
- });
16761
+ const spans = this.finish(this.n);
16908
16762
  if (this.mode !== "code" || this.stack.length > 0) return null;
16909
- return this.spans;
16763
+ return spans;
16910
16764
  }
16911
16765
  bail() {
16912
16766
  this.bailed = true;
@@ -16914,16 +16768,6 @@ var JsTsLexer = class {
16914
16768
  char(offset = 0) {
16915
16769
  return this.text[this.i + offset] ?? "";
16916
16770
  }
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
16771
  step() {
16928
16772
  switch (this.mode) {
16929
16773
  case "code": return this.stepCode();
@@ -17220,7 +17064,7 @@ const jsxFamily = {
17220
17064
  };
17221
17065
  //#endregion
17222
17066
  //#region src/chars-check/context-kt-java.ts
17223
- var KtJavaLexer = class {
17067
+ var KtJavaLexer = class extends SpanLexer {
17224
17068
  text;
17225
17069
  kotlin;
17226
17070
  rawStringContext;
@@ -17228,11 +17072,9 @@ var KtJavaLexer = class {
17228
17072
  i = 0;
17229
17073
  mode = "code";
17230
17074
  stack = [];
17231
- spans = [];
17232
- spanStart = 0;
17233
- spanContext = "code";
17234
17075
  bailed = false;
17235
17076
  constructor(text, kotlin) {
17077
+ super("code");
17236
17078
  this.text = text;
17237
17079
  this.kotlin = kotlin;
17238
17080
  this.rawStringContext = kotlin ? "raw-string" : "text-block";
@@ -17242,13 +17084,9 @@ var KtJavaLexer = class {
17242
17084
  while (this.i < this.n && !this.bailed) this.step();
17243
17085
  if (this.bailed) return null;
17244
17086
  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
- });
17087
+ const spans = this.finish(this.n);
17250
17088
  if (this.mode !== "code" || this.stack.length > 0) return null;
17251
- return this.spans;
17089
+ return spans;
17252
17090
  }
17253
17091
  bail() {
17254
17092
  this.bailed = true;
@@ -17256,16 +17094,6 @@ var KtJavaLexer = class {
17256
17094
  char(offset = 0) {
17257
17095
  return this.text[this.i + offset] ?? "";
17258
17096
  }
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
17097
  step() {
17270
17098
  switch (this.mode) {
17271
17099
  case "code": return this.stepCode();
@@ -17378,7 +17206,7 @@ const javaFamily = {
17378
17206
  //#region src/chars-check/context-markup.ts
17379
17207
  const TAG_START = /[A-Za-z!?]/;
17380
17208
  const TAG_NAME_CHAR = /[A-Za-z0-9:_-]/;
17381
- var MarkupLexer = class {
17209
+ var MarkupLexer = class extends SpanLexer {
17382
17210
  text;
17383
17211
  html;
17384
17212
  n;
@@ -17387,11 +17215,9 @@ var MarkupLexer = class {
17387
17215
  tagKind = "open";
17388
17216
  pendingTagName = "";
17389
17217
  islandCloseTag = "";
17390
- spans = [];
17391
- spanStart = 0;
17392
- spanContext = "markup-text";
17393
17218
  bailed = false;
17394
17219
  constructor(text, html) {
17220
+ super("markup-text");
17395
17221
  this.text = text;
17396
17222
  this.html = html;
17397
17223
  this.n = text.length;
@@ -17399,13 +17225,9 @@ var MarkupLexer = class {
17399
17225
  run() {
17400
17226
  while (this.i < this.n && !this.bailed) this.step();
17401
17227
  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
- });
17228
+ const spans = this.finish(this.n);
17407
17229
  if (this.mode !== "text") return null;
17408
- return this.spans;
17230
+ return spans;
17409
17231
  }
17410
17232
  bail() {
17411
17233
  this.bailed = true;
@@ -17413,16 +17235,6 @@ var MarkupLexer = class {
17413
17235
  char(offset = 0) {
17414
17236
  return this.text[this.i + offset] ?? "";
17415
17237
  }
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
17238
  step() {
17427
17239
  switch (this.mode) {
17428
17240
  case "text": return this.stepText();
@@ -17598,17 +17410,15 @@ function conditionalParseVerify(tryParse) {
17598
17410
  return tryParse(rewritten);
17599
17411
  };
17600
17412
  }
17601
- var JsonLexer = class {
17413
+ var JsonLexer = class extends SpanLexer {
17602
17414
  text;
17603
17415
  commentsAllowed;
17604
17416
  n;
17605
17417
  i = 0;
17606
17418
  mode = "code";
17607
- spans = [];
17608
- spanStart = 0;
17609
- spanContext = "code";
17610
17419
  bailed = false;
17611
17420
  constructor(text, commentsAllowed) {
17421
+ super("code");
17612
17422
  this.text = text;
17613
17423
  this.commentsAllowed = commentsAllowed;
17614
17424
  this.n = text.length;
@@ -17617,13 +17427,9 @@ var JsonLexer = class {
17617
17427
  while (this.i < this.n && !this.bailed) this.step();
17618
17428
  if (this.bailed) return null;
17619
17429
  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
- });
17430
+ const spans = this.finish(this.n);
17625
17431
  if (this.mode !== "code") return null;
17626
- return this.spans;
17432
+ return spans;
17627
17433
  }
17628
17434
  bail() {
17629
17435
  this.bailed = true;
@@ -17631,16 +17437,6 @@ var JsonLexer = class {
17631
17437
  char(offset = 0) {
17632
17438
  return this.text[this.i + offset] ?? "";
17633
17439
  }
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
17440
  step() {
17645
17441
  switch (this.mode) {
17646
17442
  case "code": return this.stepCode();
@@ -19116,6 +18912,7 @@ function liftedFactsOf(resolved, forgeDown) {
19116
18912
  return {
19117
18913
  runLive: complete || read.runLive.length > 0 ? read.runLive : null,
19118
18914
  heldByHand: complete || read.heldByHand ? read.heldByHand : null,
18915
+ heldBy: complete || read.heldBy !== null ? read.heldBy : null,
19119
18916
  owner: complete || ownership.owner === "agent" ? ownership.owner : null
19120
18917
  };
19121
18918
  }
@@ -19232,6 +19029,7 @@ async function buildWorkStatus(deps, ref) {
19232
19029
  },
19233
19030
  runLive: lifted.runLive,
19234
19031
  heldByHand: lifted.heldByHand,
19032
+ heldBy: lifted.heldBy,
19235
19033
  owner: lifted.owner,
19236
19034
  object: await section(() => objectSection(inputs)),
19237
19035
  docs: await section(() => docsSection(inputs)),
@@ -19305,7 +19103,7 @@ function renderWorkStatus(report, options) {
19305
19103
  const lines = [heading(report.target)];
19306
19104
  for (const label of report.runLive ?? []) lines.push(`RUN LIVE: ${label} -- a run is working this object; do not start another.`);
19307
19105
  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.");
19106
+ if (report.heldBy !== null) lines.push(`HELD BY HAND: ${report.heldBy} -- a human claimed this one; do not drive it.`);
19309
19107
  if (options?.agentEnabled === true && report.owner === "unclaimed") {
19310
19108
  const number = claimableNumber(report);
19311
19109
  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 +19140,7 @@ function renderWorkStatus(report, options) {
19342
19140
  //#endregion
19343
19141
  //#region src/commands/work-start.ts
19344
19142
  function claimLine(result) {
19345
- if (result.outcome === "claimed") return `claim: claimed -- ${result.label ?? "agent-flags/hand-authored"} is on this object.`;
19143
+ if (result.outcome === "claimed") return `claim: claimed -- ${result.label ?? "agent-flags/human-driven"} is on this object.`;
19346
19144
  if (result.outcome === "already-claimed") return "claim: already-claimed -- the flag is already on it; nothing was written.";
19347
19145
  if (result.outcome === "not-agent-repo") return `claim: not-agent-repo -- ${result.reason ?? "nothing was claimed."}`;
19348
19146
  return `claim: ${result.outcome} -- ${result.reason ?? "nothing was claimed."}`;
@@ -19353,7 +19151,7 @@ function claimFailed(result) {
19353
19151
  const workStartCommand = defineCommand({
19354
19152
  meta: {
19355
19153
  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"
19154
+ description: "Claim an issue or pull request for hand work: put agent-flags/human-driven on it so the agent leaves it alone"
19357
19155
  },
19358
19156
  args: {
19359
19157
  ref: {
@@ -19424,7 +19222,7 @@ const workStatusCommand = defineCommand({
19424
19222
  },
19425
19223
  json: {
19426
19224
  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."
19225
+ 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
19226
  },
19429
19227
  verbose: {
19430
19228
  type: "boolean",
@@ -19633,6 +19431,14 @@ z.object({
19633
19431
  })
19634
19432
  });
19635
19433
  //#endregion
19434
+ //#region ../cli-kit/src/env-override.ts
19435
+ function envMsOverride(raw, productionMs) {
19436
+ if (raw === void 0) return productionMs;
19437
+ const parsed = Number(raw.trim());
19438
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) return productionMs;
19439
+ return Math.min(parsed, productionMs);
19440
+ }
19441
+ //#endregion
19636
19442
  //#region src/release/publish/version-merge.ts
19637
19443
  function evaluateVersionPr(state) {
19638
19444
  const label = `PR #${String(state.prNumber)}`;
@@ -20940,11 +20746,10 @@ const releaseAssetsCommand = defineCommand({
20940
20746
  });
20941
20747
  //#endregion
20942
20748
  //#region src/lint-types/executor.ts
20943
- const MAX_BUFFER = 67108864;
20944
20749
  function runViaShim(args, cwd) {
20945
20750
  const result = spawnViaShim("pnpm", args, {
20946
20751
  cwd,
20947
- maxBuffer: MAX_BUFFER,
20752
+ maxBuffer: EXEC_MAX_BUFFER,
20948
20753
  encoding: "utf-8",
20949
20754
  stdio: [
20950
20755
  "ignore",
@@ -20966,34 +20771,17 @@ function runViaShim(args, cwd) {
20966
20771
  }
20967
20772
  function createRealLintTypesExecutor() {
20968
20773
  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
- }
20774
+ const result = execCapture$2("pnpm", args, {
20775
+ cwd,
20776
+ stdin: "ignore",
20777
+ keepPartialStdoutOnKill: false
20778
+ });
20779
+ if (result.error !== void 0 && shouldRetryViaShim(result.error)) return runViaShim(args, cwd);
20780
+ return {
20781
+ stdout: result.stdout,
20782
+ stderr: result.stderr,
20783
+ exitCode: result.status
20784
+ };
20997
20785
  } };
20998
20786
  }
20999
20787
  //#endregion
@@ -21580,7 +21368,7 @@ const HealthStateSchema = z.object({
21580
21368
  Start: z.string(),
21581
21369
  ExitCode: z.number(),
21582
21370
  Output: z.string()
21583
- }))
21371
+ })).nullable().transform((log) => log ?? [])
21584
21372
  });
21585
21373
  const HEALTH_INSPECT_FORMAT = "{{json .State.Health}}";
21586
21374
  function parseHealthState(stdout) {
@@ -23054,47 +22842,17 @@ function deriveRecord(summary, options) {
23054
22842
  //#region src/coverage-tracking/executor.ts
23055
22843
  function createRealCoverageExecutor() {
23056
22844
  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
- }
22845
+ const result = execCapture$2(file, args, {
22846
+ cwd: options?.cwd,
22847
+ env: options?.env,
22848
+ input: options?.input,
22849
+ keepPartialStdoutOnKill: true
22850
+ });
22851
+ return {
22852
+ stdout: result.stdout,
22853
+ stderr: result.stderr,
22854
+ exitCode: result.status
22855
+ };
23098
22856
  } };
23099
22857
  }
23100
22858
  //#endregion
@@ -26051,12 +25809,6 @@ const BranchEntrySchema = z.object({
26051
25809
  });
26052
25810
  const BRANCHES_PAGE_SIZE = 50;
26053
25811
  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
25812
  async function listBranches(executor, conn, options = {}) {
26061
25813
  const signal = options.signal;
26062
25814
  const maxPages = options.maxPages ?? DEFAULT_MAX_PAGES;
@@ -29592,7 +29344,7 @@ async function runCli(config) {
29592
29344
  //#region src/cli-main.ts
29593
29345
  setLogLevel(resolveLogLevel({}));
29594
29346
  setForgejoLogger(log$1);
29595
- const displayVersion = "0.97.0";
29347
+ const displayVersion = "0.99.0";
29596
29348
  const bstSubCommands = {
29597
29349
  "repo:sync": syncCommand,
29598
29350
  "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.99.0",
4
4
  "description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -722,7 +722,7 @@
722
722
  "type": "boolean"
723
723
  },
724
724
  "lintSweep": {
725
- "description": "The lint-warning sweep: a periodic agent job that measures this repo's oxlint warnings on its default branch in a container and, past minWarnings, opens a pull request carrying a generated plan for an agent/implement run to work off.",
725
+ "description": "The lint-warning sweep: a periodic agent job that measures this repo's oxlint warnings on its default branch in a container and, past minWarnings, opens a pull request carrying a generated plan for an agent/implement run to work off. Expired @compat warnings leave that plan and each get their own issue instead (see compatIssues).",
726
726
  "type": "object",
727
727
  "properties": {
728
728
  "enabled": {
@@ -740,6 +740,10 @@
740
740
  "type": "integer",
741
741
  "minimum": 0,
742
742
  "maximum": 9007199254740991
743
+ },
744
+ "compatIssues": {
745
+ "description": "Whether the sweep splits expired @compat warnings out of its plan and files one issue per expired id (default: on). false keeps them in the bulk plan with the other warnings.",
746
+ "type": "boolean"
743
747
  }
744
748
  },
745
749
  "additionalProperties": false
@@ -760,11 +764,11 @@
760
764
  "type": "boolean"
761
765
  },
762
766
  "egress": {
763
- "description": "Extra egress hosts this repo's agent containers may reach. `browseHosts` joins the agent's browse lane (GET and HEAD only) on top of the hosts every run needs; the passthrough lane stays agent-owned. Each entry is a host pattern -- an exact host or a *.host wildcard, never a port. Read from the repo's DEFAULT BRANCH, never off a pull request's own tree, so a run can never widen its own egress: the declaration takes effect on the first container started after a human merges it. An entry whose pattern the agent cannot parse refuses the run rather than being dropped. Changing this block holds the pull request from automerge.",
767
+ "description": "Extra egress hosts this repo's agent containers ask to reach -- a request the deployment grants, not an opening of a host. `browseHosts` joins the agent's browse lane (GET and HEAD only) on top of the hosts every run needs; the passthrough lane stays agent-owned. Each entry is a host pattern -- an exact host or a *.host wildcard, never a port. Read from the repo's DEFAULT BRANCH, never off a pull request's own tree, so a run can never widen its own egress: under the default `auto` grant mode the request takes effect on the first container started after a human merges it, and under `approve` it waits for an admin's grant for this repo. A host the product or the deployment known-denies is never opened, whatever the declaration or the verdict says. An entry whose pattern the agent cannot parse refuses the run rather than being dropped. Changing this block holds the pull request from automerge.",
764
768
  "type": "object",
765
769
  "properties": {
766
770
  "browseHosts": {
767
- "description": "Host patterns this repo's agent containers may fetch from, on top of the hosts every run needs: an exact host (`fastdl.mongodb.org`) or a wildcard over its leftmost label (`*.example.com`). No ports. These join the browse lane, which serves GET and HEAD only.",
771
+ "description": "Host patterns this repo's agent containers ask to fetch from, on top of the hosts every run needs: an exact host (`fastdl.mongodb.org`) or a wildcard over its leftmost label (`*.example.com`). No ports. This list is a request the deployment grants, not an opening: its grant mode decides whether a default branch's requests take effect on their own, an admin can refuse a host for this repo, and a host the product or the deployment known-denies is never opened whatever the declaration or the verdict says. What is granted joins the browse lane, which serves GET and HEAD only.",
768
772
  "type": "array",
769
773
  "items": {
770
774
  "type": "string",