@joshuafolkken/kit 1.929.0 → 1.953.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 (83) hide show
  1. package/.claude/skills/workflow-commands/background-commands.md +6 -0
  2. package/.claude/skills/workflow-commands/backlogrun-child.md +1 -1
  3. package/.claude/skills/workflow-commands/backlogrun-lanes.md +4 -3
  4. package/.claude/skills/workflow-commands/observation-filing.md +3 -3
  5. package/.claude/skills/workflow-commands/prerequisite.md +1 -1
  6. package/.github/workflows/ci.yml +26 -8
  7. package/.github/workflows/pr-classification.yml +76 -0
  8. package/README.md +44 -22
  9. package/dist/hooks/batch-guard.js +4 -4
  10. package/dist/hooks/{chunk-GQ3EVWHY.js → chunk-452OKRQX.js} +421 -195
  11. package/dist/hooks/{chunk-2PGRQ62K.js → chunk-EYFJ74MJ.js} +11 -6
  12. package/dist/hooks/{chunk-LCJZE42I.js → chunk-IA7WC4NS.js} +1 -1
  13. package/dist/hooks/{chunk-BNFG2IFK.js → chunk-IBFC25IX.js} +4 -4
  14. package/dist/hooks/{chunk-I3JP3D4A.js → chunk-M4U4YNRE.js} +3 -3
  15. package/dist/hooks/{chunk-NJZSO7BK.js → chunk-NKVLBB65.js} +3 -3
  16. package/dist/hooks/{chunk-SXPTRFPG.js → chunk-O3PEDF3M.js} +1 -1
  17. package/dist/hooks/{chunk-7XQ6TK3R.js → chunk-OM5VDM6F.js} +2 -2
  18. package/dist/hooks/{chunk-ROULPSQC.js → chunk-V7RH56HU.js} +2 -2
  19. package/dist/hooks/{chunk-YO43HEPY.js → chunk-Z5TVZ4AP.js} +237 -235
  20. package/dist/hooks/codex-hook-adapter.js +10 -10
  21. package/dist/hooks/duplicate-read-guard.js +5 -5
  22. package/dist/hooks/format-edited.js +2 -2
  23. package/dist/hooks/investigation-guard.js +5 -5
  24. package/dist/hooks/pretool-guard.js +9 -9
  25. package/dist/hooks/stop-guard.js +9 -3
  26. package/dist/josh.js +11 -6
  27. package/dist/version/index.js +7 -4
  28. package/package.json +13 -1
  29. package/prompts/collaboration-workflow/issue-template.md +1 -1
  30. package/scripts/ci/pr-classification.ts +27 -6
  31. package/scripts/document/document-byte-budget.ts +1 -1
  32. package/scripts/gate/hook-gate-reuse.ts +1 -1
  33. package/scripts/gate/project-checks.ts +45 -15
  34. package/scripts/gate/type-check-command.ts +43 -0
  35. package/scripts/git/constants.ts +4 -0
  36. package/scripts/git/git-command.ts +11 -5
  37. package/scripts/git/git-gh-pr-rollup.ts +56 -16
  38. package/scripts/git/git-staging.ts +6 -4
  39. package/scripts/git/git-stash.ts +73 -1
  40. package/scripts/git/git-worktree.ts +35 -4
  41. package/scripts/git/repository-lock.ts +138 -0
  42. package/scripts/git/stash-orphans.ts +24 -2
  43. package/scripts/git/stash-sweep-lock.ts +30 -0
  44. package/scripts/hooks/stop-guard.ts +2 -0
  45. package/scripts/init/init-actions.ts +3 -2
  46. package/scripts/init/init-logic-migrate.ts +10 -1
  47. package/scripts/init/init-logic-templates.ts +27 -7
  48. package/scripts/init/init-logic-workspace.ts +52 -1
  49. package/scripts/init/init-logic.ts +6 -1
  50. package/scripts/init/init.ts +60 -19
  51. package/scripts/issue/issue-merged.ts +75 -0
  52. package/scripts/issue/measure-rerun-cli.ts +2 -2
  53. package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +10 -0
  54. package/scripts/josh/josh-command-map.ts +1 -0
  55. package/scripts/josh/josh-command-types.ts +0 -3
  56. package/scripts/josh/josh-commands-ai.ts +6 -0
  57. package/scripts/josh/josh-commands-development.ts +5 -5
  58. package/scripts/lint/lint-parallel.ts +19 -18
  59. package/scripts/observations/observation-ledger-home.ts +22 -2
  60. package/scripts/observations/observation-ledger-line.ts +11 -0
  61. package/scripts/observations/observation-ledger-migrate.ts +146 -0
  62. package/scripts/observations/observation-ledger.ts +51 -3
  63. package/scripts/observations/observations-flush.ts +38 -7
  64. package/scripts/review/review-finding-ledger.ts +1 -1
  65. package/scripts/review/review-record-cli.ts +1 -7
  66. package/scripts/rules/delivered-rules.ts +10 -0
  67. package/scripts/rules/lane-background.ts +111 -0
  68. package/scripts/rules/stop-rules.ts +15 -2
  69. package/scripts/run/run-carry-flush.ts +2 -7
  70. package/scripts/run/run-hold-cli.ts +10 -2
  71. package/scripts/run/run-tidy-cli.ts +50 -0
  72. package/scripts/run/run-tidy-lanes.ts +110 -0
  73. package/scripts/run/run-tidy-stashes.ts +160 -0
  74. package/scripts/run/run-tidy.ts +101 -0
  75. package/scripts/safe-chain/ci-installer-pin.ts +90 -0
  76. package/scripts/safe-chain/preinstall-command.ts +39 -0
  77. package/scripts/safe-chain/project-config.ts +55 -10
  78. package/scripts/sync/sync.ts +8 -3
  79. package/scripts/test/pilot-files.ts +0 -1
  80. package/scripts/version/preinstall-version-update.ts +2 -0
  81. package/scripts/version/release-age.ts +11 -6
  82. package/templates/workflows/ci.yml +21 -7
  83. package/tsconfig/base.json +4 -1
@@ -20,6 +20,7 @@ import {
20
20
  has_any_label,
21
21
  has_label_name,
22
22
  has_stderr_field,
23
+ lane_background,
23
24
  lane_park,
24
25
  lane_registry,
25
26
  parse_json_array_or_undefined,
@@ -30,34 +31,35 @@ import {
30
31
  run_cut,
31
32
  run_hold,
32
33
  run_progress_clock,
34
+ run_tail,
33
35
  run_watcher_guard,
34
36
  shell_segments,
35
37
  tail_commands
36
- } from "./chunk-GQ3EVWHY.js";
38
+ } from "./chunk-452OKRQX.js";
37
39
  import {
38
40
  find_local_bin_upwards
39
41
  } from "./chunk-3V37IID6.js";
40
42
  import {
41
43
  batch_outcome
42
- } from "./chunk-ROULPSQC.js";
44
+ } from "./chunk-V7RH56HU.js";
43
45
  import {
44
46
  investigation_refusal
45
- } from "./chunk-NJZSO7BK.js";
47
+ } from "./chunk-NKVLBB65.js";
46
48
  import {
47
49
  duplicate_read_outcome
48
- } from "./chunk-BNFG2IFK.js";
50
+ } from "./chunk-IBFC25IX.js";
49
51
  import {
50
52
  investigation_reads
51
- } from "./chunk-I3JP3D4A.js";
53
+ } from "./chunk-M4U4YNRE.js";
52
54
  import {
53
55
  lane_guard_policy,
54
56
  time_batch_guard
55
- } from "./chunk-7XQ6TK3R.js";
57
+ } from "./chunk-OM5VDM6F.js";
56
58
  import {
57
59
  hook_decision,
58
60
  lane_child_marker,
59
61
  run_issue_number
60
- } from "./chunk-SXPTRFPG.js";
62
+ } from "./chunk-O3PEDF3M.js";
61
63
  import {
62
64
  PLATFORM_TEMP_ROOT,
63
65
  cost_attribute,
@@ -69,7 +71,7 @@ import {
69
71
  stamp_file,
70
72
  time_density_hook,
71
73
  time_shell
72
- } from "./chunk-2PGRQ62K.js";
74
+ } from "./chunk-EYFJ74MJ.js";
73
75
 
74
76
  // scripts/hooks/pretool-guard.ts
75
77
  import { text } from "node:stream/consumers";
@@ -2124,55 +2126,6 @@ var rule_body_guard = {
2124
2126
  writes_rule_prose
2125
2127
  };
2126
2128
 
2127
- // scripts/rules/run-tail.ts
2128
- var SEGMENT_PREFIX = String.raw`(?:\(\s*)?(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*(?:npx\s+|pnpm\s+(?:exec\s+|run\s+)?)?`;
2129
- var WORD_END = String.raw`(?=\s|$|\))`;
2130
- var PUSH_STEP_SEGMENT = new RegExp(String.raw`^${SEGMENT_PREFIX}josh\s+(?:git|g)${WORD_END}`, "u");
2131
- var CONFIRMED_FLAG = new RegExp(String.raw`(?:^|\s)(?:-y|--yes)${WORD_END}`, "u");
2132
- var SKIPS_THE_PUSH = new RegExp(String.raw`(?:^|\s)--skip-push${WORD_END}`, "u");
2133
- var BACKGROUND_KEY = "run_in_background";
2134
- var QUOTED_SPAN = /"[^"]*"|'[^']*'/gu;
2135
- function flags_of(segment) {
2136
- return segment.replaceAll(QUOTED_SPAN, " ");
2137
- }
2138
- function is_push_step_segment(segment) {
2139
- if (!PUSH_STEP_SEGMENT.test(segment)) return false;
2140
- const flags = flags_of(segment);
2141
- if (SKIPS_THE_PUSH.test(flags)) return false;
2142
- return CONFIRMED_FLAG.test(flags);
2143
- }
2144
- function is_push_step(command) {
2145
- return shell_segments.segments_of(command).some((segment) => is_push_step_segment(segment));
2146
- }
2147
- function is_backgrounded(input) {
2148
- if (!json_value.is_record(input)) return false;
2149
- return input[BACKGROUND_KEY] === true;
2150
- }
2151
- function is_push_step_call(call) {
2152
- if (call.name !== cost_blocks.BASH_TOOL) return false;
2153
- return is_push_step(time_shell.bash_command(call.input));
2154
- }
2155
- function is_backgrounded_push_step(call) {
2156
- if (!is_backgrounded(call.input)) return false;
2157
- return is_push_step_call(call);
2158
- }
2159
- function is_foreground_push_step(call) {
2160
- if (is_backgrounded(call.input)) return false;
2161
- return is_push_step_call(call);
2162
- }
2163
- function decide4() {
2164
- return true;
2165
- }
2166
- var RUN_TAIL_REASON = '\u26D4 run tail: this issues the commit-push-PR step in the foreground, where the harness decides when to stop waiting. Reissue it with `run_in_background` set. In `fullrun #1501` this call was given a 900-second timeout, the harness detached it at its own 600-second cap, and nothing read the output for a further 6m28s \u2014 45m03s of wall clock on about 17 minutes of work (joshuafolkken/kit#1510). **Never give a foreground call a timeout above the harness cap**: the cap decides, not the number. A backgrounded call re-invokes you when it exits, so the completion notification is what resumes the run. **When it arrives, the turn that reads it goes straight through any branch-2 filing and `pnpm josh epic:bundle` to `pnpm josh followup` \u2014 the turn never ends at the push.** CI went green 6m06s before the merge started in that run, and it started only because the person asked; joshuafolkken/kit#1333 had already settled that the merge is issued in the turn the review closes. While the push runs, do the work that writes nothing \u2014 drafting the completion body to a file, deciding the branch-2 disposition. `pnpm josh followup` itself stays in the **foreground** \u2014 nearly every step after it reads its result. But a tail does follow the merge, measured at 3.0 min and 5.9% of a run (joshuafolkken/kit#1462), so empty it beforehand: the steps that read the merge result stay after `followup`, and the rest are composed in the turn that issues it, bar the one exception background-commands.md names. The procedure is `.claude/skills/workflow-commands/background-commands.md`, "A command that can take minutes is issued in the background". **This rule fires on every foreground push, not once per run**, so reissuing the same call in the foreground will be refused again.';
2167
- var run_tail = {
2168
- RUN_TAIL_REASON,
2169
- decide: decide4,
2170
- is_backgrounded_push_step,
2171
- is_foreground_push_step,
2172
- is_push_step,
2173
- is_push_step_call
2174
- };
2175
-
2176
2129
  // scripts/rules/shell-body-trigger.ts
2177
2130
  var FIELD_FLAGS = "(?:-f|-F|--field|--raw-field)";
2178
2131
  var MESSAGE_FLAGS = "(?:--body|--notify-message)";
@@ -2215,7 +2168,7 @@ var BODY_FLAG = new RegExp(
2215
2168
  String.raw`${FIELD_FLAGS}[\s=]*'?"?body=|${MESSAGE_FLAGS}[\s=]|--body-file[\s=]|--notify-message-file[\s=]`,
2216
2169
  "u"
2217
2170
  );
2218
- var QUOTED_SPAN2 = /"[^"]*"|'[^']*'/gu;
2171
+ var QUOTED_SPAN = /"[^"]*"|'[^']*'/gu;
2219
2172
  function inline_body_literals(command) {
2220
2173
  return Array.from(
2221
2174
  command.matchAll(INLINE_BODY_VALUE),
@@ -2224,7 +2177,7 @@ function inline_body_literals(command) {
2224
2177
  }
2225
2178
  function is_safe_body_form(command) {
2226
2179
  if (ANSI_C_BODY.test(command.replaceAll(DOUBLE_QUOTED_SPAN, " "))) return true;
2227
- const flags = command.replaceAll(QUOTED_SPAN2, " ");
2180
+ const flags = command.replaceAll(QUOTED_SPAN, " ");
2228
2181
  if (FILE_FLAG.test(flags) || FIELD_FILE_REFERENCE.test(flags)) return true;
2229
2182
  return inline_body_literals(command).some((literal) => is_body_already_in_a_file(literal));
2230
2183
  }
@@ -2232,7 +2185,7 @@ function keeps_body_safe(command) {
2232
2185
  return is_safe_body_form(command) && !is_shell_evaluated_body(command);
2233
2186
  }
2234
2187
  function carries_a_body(command) {
2235
- if (BODY_FLAG.test(command.replaceAll(QUOTED_SPAN2, " "))) return true;
2188
+ if (BODY_FLAG.test(command.replaceAll(QUOTED_SPAN, " "))) return true;
2236
2189
  return inline_body_literals(command).length > 0;
2237
2190
  }
2238
2191
  var SHELL_BODY_REASON = "\u26D4 shell-evaluated body: this command carries a body inline in double quotes, and that body contains a backtick or a `$`, so the shell runs it \u2014 the text is executed rather than merely mangled (joshuafolkken/kit#1198). Write the body to a file and pass it by path: `pnpm josh issue:comment <N> --body-file <path>`, `pnpm josh followup --notify-message-file <path>`, or `--body-file <path>` wherever offered. `$'\u2026'` quoting is the other safe form; the rule and the trigger's blind spots are in `prompts/collaboration-workflow/shell-body.md`. Reissue this call once the body is in a file \u2014 it fires once per run and cannot repeat on the call in hand.";
@@ -2255,6 +2208,7 @@ import path5 from "node:path";
2255
2208
  var SKIP_MARKER = "\u2014 skipping";
2256
2209
 
2257
2210
  // scripts/gate/project-checks.ts
2211
+ import { z as z5 } from "zod";
2258
2212
  var PACKAGE_JSON = "package.json";
2259
2213
  var IGNORED_DIRS = /* @__PURE__ */ new Set([
2260
2214
  "node_modules",
@@ -2288,6 +2242,8 @@ var CSPELL_CONFIGS = [
2288
2242
  "cspell.yaml"
2289
2243
  ];
2290
2244
  var TYPE_CONFIGS = ["tsconfig.json", "jsconfig.json"];
2245
+ var DEPENDENCY_FIELDS = ["dependencies", "devDependencies"];
2246
+ var object_schema = z5.record(z5.string(), z5.unknown());
2291
2247
  function project_root(directory) {
2292
2248
  let current = directory;
2293
2249
  while (!existsSync3(path5.join(current, PACKAGE_JSON))) {
@@ -2318,15 +2274,29 @@ function is_static_manifest(manifest) {
2318
2274
  if (typeof josh !== "object" || josh === null || !("profile" in josh)) return false;
2319
2275
  return josh.profile === "static";
2320
2276
  }
2321
- function is_static(directory) {
2277
+ function read_manifest(directory) {
2322
2278
  try {
2323
2279
  const manifest_path = path5.join(project_root(directory), PACKAGE_JSON);
2324
- const manifest = JSON.parse(readFileSync5(manifest_path, "utf8"));
2325
- return is_static_manifest(manifest);
2280
+ return JSON.parse(readFileSync5(manifest_path, "utf8"));
2326
2281
  } catch {
2327
- return false;
2282
+ return void 0;
2328
2283
  }
2329
2284
  }
2285
+ function is_static(directory) {
2286
+ return is_static_manifest(read_manifest(directory));
2287
+ }
2288
+ function is_declared(directory, package_name) {
2289
+ const manifest = object_schema.safeParse(read_manifest(directory));
2290
+ if (!manifest.success) return false;
2291
+ return DEPENDENCY_FIELDS.some((field) => {
2292
+ const dependencies = object_schema.safeParse(manifest.data[field]);
2293
+ return dependencies.success && Object.hasOwn(dependencies.data, package_name);
2294
+ });
2295
+ }
2296
+ function missing_tool_reason(directory, package_name, bin_name) {
2297
+ if (has_bin(directory, bin_name) || is_declared(directory, package_name)) return void 0;
2298
+ return `${package_name} is not installed`;
2299
+ }
2330
2300
  function skip_notice(check3, reason) {
2331
2301
  return `josh ${check3}: ${reason} ${SKIP_MARKER} ${check3}.`;
2332
2302
  }
@@ -2334,21 +2304,18 @@ function type_check_skip_reason(directory) {
2334
2304
  if (!is_static(directory)) return void 0;
2335
2305
  if (!has_files(directory, TYPE_FILES)) return "no TypeScript files were found";
2336
2306
  if (!has_config(directory, TYPE_CONFIGS)) return "no TypeScript configuration was found";
2337
- if (!has_bin(directory, "tsc")) return "typescript is not installed";
2338
- return void 0;
2307
+ return missing_tool_reason(directory, "typescript", "tsc");
2339
2308
  }
2340
2309
  function prettier_skip_reason(directory) {
2341
2310
  if (!is_static(directory)) return void 0;
2342
2311
  if (!has_files(directory, WEB_FILES)) return "no HTML, CSS or JavaScript files were found";
2343
- if (!has_bin(directory, "prettier")) return "prettier is not installed";
2344
- return void 0;
2312
+ return missing_tool_reason(directory, "prettier", "prettier");
2345
2313
  }
2346
2314
  function eslint_skip_reason(directory) {
2347
2315
  if (!is_static(directory)) return void 0;
2348
2316
  if (!has_files(directory, SCRIPT_FILES)) return "no JavaScript or TypeScript files were found";
2349
2317
  if (!has_config(directory, ESLINT_CONFIGS)) return "no ESLint configuration was found";
2350
- if (!has_bin(directory, "eslint")) return "eslint is not installed";
2351
- return void 0;
2318
+ return missing_tool_reason(directory, "eslint", "eslint");
2352
2319
  }
2353
2320
  var project_checks = {
2354
2321
  CSPELL_CONFIGS,
@@ -2677,6 +2644,15 @@ var DELIVERED_RULES = [
2677
2644
  // verdict is `required`; in the hermetic non-repo suite the git read fails to `exempt`, so
2678
2645
  // `test-declared` claims nothing and the "exactly one rule" invariant over `run-tail`'s fixture holds.
2679
2646
  test_declared_commit.ROW,
2647
+ // **The long-running josh command a lane child backgrounds and loses** (joshuafolkken/kit#2704). A
2648
+ // headless child's background tasks die with its turn, so a backgrounded `josh gate` / `git` /
2649
+ // `followup` is killed before it reports; this refuses the launch and hands back `josh ship
2650
+ // --detach`, whose supervisor outlives the turn. **Listed before `run-tail`, whose push it claims in
2651
+ // a child**: that row answers a foreground push with "reissue it backgrounded", the reissue this row
2652
+ // refuses, so a child is sent to the detached ship on its first refusal instead of through both.
2653
+ // Outside a child it claims nothing. A backgrounded bare `josh git` also trips `josh-git-bare`
2654
+ // below; this row wins, and `ship --detach` satisfies both. It fires on every occurrence.
2655
+ lane_background.ROW,
2680
2656
  // **The one row whose trigger reads a field of the input beside the command**, so it supplies its
2681
2657
  // own tool-name check rather than going through `on_bash_command`: a push step already issued with
2682
2658
  // `run_in_background` is the rule obeyed, and refusing it would charge a run for doing the right
@@ -2888,12 +2864,12 @@ function is_first_delivery(tail, call, delivered_at_ms, run2) {
2888
2864
  return delivered_at_ms === hook_decision.NEVER_MS && !will_batch_guard_refuse(tail, call, run2);
2889
2865
  }
2890
2866
  function delivery_decision(rule) {
2891
- const { decide: decide7, already_satisfied } = rule;
2892
- if (decide7 === void 0 && already_satisfied === void 0) return is_first_delivery;
2867
+ const { decide: decide6, already_satisfied } = rule;
2868
+ if (decide6 === void 0 && already_satisfied === void 0) return is_first_delivery;
2893
2869
  return function should_block(tail, call, delivered_at_ms, run2) {
2894
2870
  if (already_satisfied?.(tail, call) === true) return false;
2895
- if (decide7 === void 0) return is_first_delivery(tail, call, delivered_at_ms, run2);
2896
- return decide7(call, run2, !will_batch_guard_refuse(tail, call, run2), delivered_at_ms);
2871
+ if (decide6 === void 0) return is_first_delivery(tail, call, delivered_at_ms, run2);
2872
+ return decide6(call, run2, !will_batch_guard_refuse(tail, call, run2), delivered_at_ms);
2897
2873
  };
2898
2874
  }
2899
2875
  function guard_of(rule) {
@@ -2949,7 +2925,7 @@ var delivered_rules = {
2949
2925
  };
2950
2926
 
2951
2927
  // scripts/run/run-watcher-hook.ts
2952
- import { z as z16 } from "zod";
2928
+ import { z as z17 } from "zod";
2953
2929
 
2954
2930
  // scripts/run/run-progress-read.ts
2955
2931
  import { loadavg } from "node:os";
@@ -2983,7 +2959,7 @@ var git_gh_helpers = {
2983
2959
  };
2984
2960
 
2985
2961
  // scripts/git/git-gh-issue-rest.ts
2986
- import { z as z6 } from "zod";
2962
+ import { z as z7 } from "zod";
2987
2963
 
2988
2964
  // scripts/git/git-gh-rest-state.ts
2989
2965
  var MERGED_STATE = "MERGED";
@@ -2992,80 +2968,80 @@ function to_gh_state(state) {
2992
2968
  }
2993
2969
 
2994
2970
  // scripts/git/schemas.ts
2995
- import { z as z5 } from "zod";
2996
- var package_name_schema = z5.object({ name: z5.string().min(1) });
2997
- var rollup_item_schema = z5.looseObject({
2971
+ import { z as z6 } from "zod";
2972
+ var package_name_schema = z6.object({ name: z6.string().min(1) });
2973
+ var rollup_item_schema = z6.looseObject({
2998
2974
  // eslint-disable-next-line @typescript-eslint/naming-convention -- GraphQL field name from GitHub API
2999
- __typename: z5.string().optional(),
3000
- state: z5.string().optional(),
3001
- status: z5.string().optional(),
3002
- conclusion: z5.string().optional(),
3003
- name: z5.string().optional(),
3004
- context: z5.string().optional()
2975
+ __typename: z6.string().optional(),
2976
+ state: z6.string().optional(),
2977
+ status: z6.string().optional(),
2978
+ conclusion: z6.string().optional(),
2979
+ name: z6.string().optional(),
2980
+ context: z6.string().optional()
3005
2981
  });
3006
- var pr_raw_schema = z5.object({
3007
- statusCheckRollup: z5.array(rollup_item_schema).optional(),
3008
- mergeStateStatus: z5.string().optional(),
3009
- reviewDecision: z5.string().optional()
2982
+ var pr_raw_schema = z6.object({
2983
+ statusCheckRollup: z6.array(rollup_item_schema).optional(),
2984
+ mergeStateStatus: z6.string().optional(),
2985
+ reviewDecision: z6.string().optional()
3010
2986
  });
3011
- var pull_comment_schema = z5.object({
3012
- body: z5.string().optional(),
3013
- html_url: z5.string().optional(),
3014
- user: z5.object({ login: z5.string().optional() }).optional()
2987
+ var pull_comment_schema = z6.object({
2988
+ body: z6.string().optional(),
2989
+ html_url: z6.string().optional(),
2990
+ user: z6.object({ login: z6.string().optional() }).optional()
3015
2991
  });
3016
- var ai_review_pull_comment_schema = z5.object({
3017
- body: z5.string().optional(),
3018
- url: z5.string().optional(),
3019
- author: z5.object({ login: z5.string().optional() }).optional()
2992
+ var ai_review_pull_comment_schema = z6.object({
2993
+ body: z6.string().optional(),
2994
+ url: z6.string().optional(),
2995
+ author: z6.object({ login: z6.string().optional() }).optional()
3020
2996
  });
3021
- var pr_info_schema = z5.object({
3022
- mergeable: z5.union([z5.boolean(), z5.string()]).nullable().optional(),
3023
- mergeStateStatus: z5.string().nullable().optional(),
3024
- state: z5.string().optional()
2997
+ var pr_info_schema = z6.object({
2998
+ mergeable: z6.union([z6.boolean(), z6.string()]).nullable().optional(),
2999
+ mergeStateStatus: z6.string().nullable().optional(),
3000
+ state: z6.string().optional()
3025
3001
  });
3026
- var epic_issue_schema = z5.object({
3027
- number: z5.number(),
3028
- body: z5.string().optional()
3002
+ var epic_issue_schema = z6.object({
3003
+ number: z6.number(),
3004
+ body: z6.string().optional()
3029
3005
  });
3030
- var blocking_issue_schema = z5.object({
3031
- number: z5.number(),
3032
- state: z5.string().optional(),
3033
- repository_url: z5.string().optional()
3006
+ var blocking_issue_schema = z6.object({
3007
+ number: z6.number(),
3008
+ state: z6.string().optional(),
3009
+ repository_url: z6.string().optional()
3034
3010
  });
3035
- var blocked_by_schema = z5.object({
3036
- nodes: z5.array(blocking_issue_schema).default([]),
3037
- totalCount: z5.number().optional()
3011
+ var blocked_by_schema = z6.object({
3012
+ nodes: z6.array(blocking_issue_schema).default([]),
3013
+ totalCount: z6.number().optional()
3038
3014
  }).optional();
3039
- var epic_child_schema = z5.object({
3040
- state: z5.string().optional(),
3015
+ var epic_child_schema = z6.object({
3016
+ state: z6.string().optional(),
3041
3017
  blockedBy: blocked_by_schema
3042
3018
  });
3043
- var rest_comment_schema = z5.looseObject({
3044
- body: z5.string().nullish(),
3045
- html_url: z5.string().optional(),
3046
- user: z5.looseObject({ login: z5.string().optional() }).nullish()
3019
+ var rest_comment_schema = z6.looseObject({
3020
+ body: z6.string().nullish(),
3021
+ html_url: z6.string().optional(),
3022
+ user: z6.looseObject({ login: z6.string().optional() }).nullish()
3047
3023
  });
3048
- var issue_label_schema = z5.object({ name: z5.string() });
3049
- var epic_subject_schema = z5.object({
3050
- number: z5.number(),
3051
- state: z5.string().optional(),
3052
- labels: z5.array(issue_label_schema).optional(),
3053
- body: z5.string().optional()
3024
+ var issue_label_schema = z6.object({ name: z6.string() });
3025
+ var epic_subject_schema = z6.object({
3026
+ number: z6.number(),
3027
+ state: z6.string().optional(),
3028
+ labels: z6.array(issue_label_schema).optional(),
3029
+ body: z6.string().optional()
3054
3030
  });
3055
- var open_issue_schema = z5.object({
3056
- number: z5.number(),
3057
- title: z5.string(),
3058
- labels: z5.array(issue_label_schema).optional(),
3059
- createdAt: z5.string(),
3031
+ var open_issue_schema = z6.object({
3032
+ number: z6.number(),
3033
+ title: z6.string(),
3034
+ labels: z6.array(issue_label_schema).optional(),
3035
+ createdAt: z6.string(),
3060
3036
  blockedBy: blocked_by_schema
3061
3037
  });
3062
3038
 
3063
3039
  // scripts/git/git-gh-issue-rest.ts
3064
- var rest_issue_schema = z6.looseObject({
3065
- number: z6.number(),
3066
- issue_dependencies_summary: z6.looseObject({ total_blocked_by: z6.number().optional() }).nullish(),
3040
+ var rest_issue_schema = z7.looseObject({
3041
+ number: z7.number(),
3042
+ issue_dependencies_summary: z7.looseObject({ total_blocked_by: z7.number().optional() }).nullish(),
3067
3043
  // Present only on a pull request, which this endpoint serves as readily as an issue.
3068
- pull_request: z6.looseObject({ merged_at: z6.string().nullish() }).nullish()
3044
+ pull_request: z7.looseObject({ merged_at: z7.string().nullish() }).nullish()
3069
3045
  });
3070
3046
  var REPOSITORY_URL = /\/repos\/([\w.-]+\/[\w.-]+)$/u;
3071
3047
  var REPOSITORY_URL_GROUP = 1;
@@ -3599,7 +3575,8 @@ var git_gh_issue = {
3599
3575
  // scripts/ci/pr-classification.ts
3600
3576
  import { readFileSync as readFileSync6 } from "node:fs";
3601
3577
  import { fileURLToPath as fileURLToPath2 } from "node:url";
3602
- import { z as z7 } from "zod";
3578
+ import { execaSync } from "execa";
3579
+ import { z as z8 } from "zod";
3603
3580
  var BUGFIX = "bugfix";
3604
3581
  var BREAKING = "breaking-change";
3605
3582
  var CLASSIFICATION_LABELS2 = [
@@ -3613,11 +3590,12 @@ var CLASSIFICATION_SET = new Set(CLASSIFICATION_LABELS2);
3613
3590
  var ISSUE_BUG_LABEL = "bug";
3614
3591
  var DECLARATION = /^- リリース分類: (.+)$/gmu;
3615
3592
  var LEGACY_LABELS = /* @__PURE__ */ new Set(["semver-major", "semver-minor"]);
3616
- var LABEL = z7.object({ name: z7.string() });
3617
- var USER = z7.object({ login: z7.string() });
3618
- var PULL_REQUEST = z7.object({ user: USER, labels: z7.array(LABEL) });
3619
- var EVENT = z7.object({
3620
- pull_request: PULL_REQUEST
3593
+ var LABEL = z8.object({ name: z8.string() });
3594
+ var USER = z8.object({ login: z8.string() });
3595
+ var PULL_REQUEST = z8.object({ number: z8.number(), user: USER });
3596
+ var EVENT = z8.object({
3597
+ pull_request: PULL_REQUEST,
3598
+ repository: z8.object({ full_name: z8.string() })
3621
3599
  });
3622
3600
  function classification_error(labels, author) {
3623
3601
  const legacy = labels.filter((label) => LEGACY_LABELS.has(label.toLowerCase()));
@@ -3637,7 +3615,7 @@ function release_candidates(candidates) {
3637
3615
  return candidates.filter((candidate) => candidate !== "enhancement");
3638
3616
  }
3639
3617
  function issue_candidates(issue_json) {
3640
- const issue = z7.object({ labels: z7.array(LABEL), body: z7.string().nullable() }).parse(JSON.parse(issue_json));
3618
+ const issue = z8.object({ labels: z8.array(LABEL), body: z8.string().nullable() }).parse(JSON.parse(issue_json));
3641
3619
  const names = issue.labels.map((label) => label.name.toLowerCase());
3642
3620
  const declared = [...(issue.body ?? "").matchAll(DECLARATION)].map((match) => match[1] ?? "");
3643
3621
  const candidates = [...release_candidates([...names, ...declared].filter(is_classification))];
@@ -3659,12 +3637,21 @@ function select_issue_classification(issue_json) {
3659
3637
  }
3660
3638
  return label;
3661
3639
  }
3662
- function check_event(event_path) {
3663
- const event = EVENT.parse(JSON.parse(readFileSync6(event_path, "utf8")));
3664
- return classification_error(
3665
- event.pull_request.labels.map((label) => label.name),
3666
- event.pull_request.user.login
3640
+ function fetch_current_labels(repository, pull_number) {
3641
+ const result = execaSync(
3642
+ "gh",
3643
+ ["api", `repos/${repository}/issues/${String(pull_number)}/labels`, "--jq", ".[].name"],
3644
+ { reject: false }
3667
3645
  );
3646
+ if (result.exitCode !== 0) {
3647
+ throw new Error(`Could not read the pull request labels: ${result.stderr}`);
3648
+ }
3649
+ return result.stdout.split("\n").filter((name) => name !== "");
3650
+ }
3651
+ function check_event(event_path, read_labels = fetch_current_labels) {
3652
+ const event = EVENT.parse(JSON.parse(readFileSync6(event_path, "utf8")));
3653
+ const labels = read_labels(event.repository.full_name, event.pull_request.number);
3654
+ return classification_error(labels, event.pull_request.user.login);
3668
3655
  }
3669
3656
  if (process.argv[1] === fileURLToPath2(import.meta.url)) {
3670
3657
  const event_path = process.env["GITHUB_EVENT_PATH"];
@@ -3702,31 +3689,31 @@ async function poll_until(is_done, options) {
3702
3689
  var poll = { poll_until, sleep };
3703
3690
 
3704
3691
  // scripts/git/git-gh-pr.ts
3705
- import { z as z11 } from "zod";
3692
+ import { z as z12 } from "zod";
3706
3693
 
3707
3694
  // scripts/git/git-gh-pr-rest.ts
3708
- import { z as z8 } from "zod";
3709
- var rest_repo_schema = z8.looseObject({ full_name: z8.string().optional() }).nullish();
3710
- var rest_pull_side_schema = z8.looseObject({ repo: rest_repo_schema });
3711
- var rest_pull_schema = z8.looseObject({
3712
- number: z8.number(),
3713
- html_url: z8.string().optional(),
3714
- body: z8.string().nullish(),
3715
- state: z8.string().optional(),
3716
- merged: z8.boolean().nullish(),
3717
- merged_at: z8.string().nullish(),
3718
- mergeable: z8.boolean().nullish(),
3719
- mergeable_state: z8.string().optional(),
3695
+ import { z as z9 } from "zod";
3696
+ var rest_repo_schema = z9.looseObject({ full_name: z9.string().optional() }).nullish();
3697
+ var rest_pull_side_schema = z9.looseObject({ repo: rest_repo_schema });
3698
+ var rest_pull_schema = z9.looseObject({
3699
+ number: z9.number(),
3700
+ html_url: z9.string().optional(),
3701
+ body: z9.string().nullish(),
3702
+ state: z9.string().optional(),
3703
+ merged: z9.boolean().nullish(),
3704
+ merged_at: z9.string().nullish(),
3705
+ mergeable: z9.boolean().nullish(),
3706
+ mergeable_state: z9.string().optional(),
3720
3707
  // `sha` is the head commit, which is what both halves of the merge-gate rollup are keyed by —
3721
3708
  // REST hangs the check runs and the status contexts off the commit rather than off the pull
3722
3709
  // request (joshuafolkken/kit#1028).
3723
- head: z8.looseObject({ ref: z8.string().optional(), sha: z8.string().optional(), repo: rest_repo_schema }).nullish(),
3710
+ head: z9.looseObject({ ref: z9.string().optional(), sha: z9.string().optional(), repo: rest_repo_schema }).nullish(),
3724
3711
  base: rest_pull_side_schema.nullish(),
3725
3712
  // `node_id` is what the GraphQL auto-merge mutation addresses a pull request by, and `auto_merge`
3726
3713
  // is `null` until auto-merge is enabled — both read by `git-gh-pr-auto-merge.ts`
3727
3714
  // (joshuafolkken/kit#2497).
3728
- node_id: z8.string().optional(),
3729
- auto_merge: z8.looseObject({}).nullish()
3715
+ node_id: z9.string().optional(),
3716
+ auto_merge: z9.looseObject({}).nullish()
3730
3717
  });
3731
3718
  var NOT_A_PULL_MESSAGE = "gh api answered something other than a pull request object";
3732
3719
  var NOT_A_PULL_LISTING_MESSAGE = "gh api answered something other than a pull request listing";
@@ -3926,14 +3913,14 @@ var git_gh_pr_read = {
3926
3913
  };
3927
3914
 
3928
3915
  // scripts/git/git-gh-pr-review.ts
3929
- import { z as z9 } from "zod";
3916
+ import { z as z10 } from "zod";
3930
3917
  var REVIEW_APPROVED = "APPROVED";
3931
3918
  var REVIEW_CHANGES_REQUESTED = "CHANGES_REQUESTED";
3932
3919
  var REVIEW_NONE = "";
3933
3920
  var STATE_CHANGING_REVIEWS = /* @__PURE__ */ new Set([REVIEW_APPROVED, REVIEW_CHANGES_REQUESTED]);
3934
- var rest_review_schema = z9.looseObject({
3935
- state: z9.string().optional(),
3936
- user: z9.looseObject({ login: z9.string().optional() }).nullish()
3921
+ var rest_review_schema = z10.looseObject({
3922
+ state: z10.string().optional(),
3923
+ user: z10.looseObject({ login: z10.string().optional() }).nullish()
3937
3924
  });
3938
3925
  var NOT_A_REVIEW_LISTING = "gh api answered something other than a review listing";
3939
3926
  function parse_rest_reviews(reviews_json) {
@@ -3966,18 +3953,18 @@ function to_review_decision(reviews_json) {
3966
3953
  var git_gh_pr_review = { to_review_decision, parse_rest_reviews };
3967
3954
 
3968
3955
  // scripts/git/git-gh-pr-rollup.ts
3969
- import { z as z10 } from "zod";
3956
+ import { z as z11 } from "zod";
3970
3957
  var STATUS_CONTEXT_TYPE_NAME = "StatusContext";
3971
3958
  var TYPE_NAME_KEY = "__typename";
3972
- var rollup_element_schema = z10.looseObject({});
3973
- var check_runs_page_schema = z10.looseObject({
3959
+ var rollup_element_schema = z11.looseObject({});
3960
+ var check_runs_page_schema = z11.looseObject({
3974
3961
  // Required, not optional: GitHub always names the key, and accepting a page without one would
3975
3962
  // answer an empty rollup — which `git-pr-followup.ts` reports as "this branch has no checks".
3976
- check_runs: z10.array(rollup_element_schema)
3963
+ check_runs: z11.array(rollup_element_schema)
3977
3964
  });
3978
- var check_run_app_schema = z10.object({ id: z10.number() });
3979
- var status_page_schema = z10.looseObject({
3980
- statuses: z10.array(rollup_element_schema)
3965
+ var id_holder_schema = z11.object({ id: z11.number() });
3966
+ var status_page_schema = z11.looseObject({
3967
+ statuses: z11.array(rollup_element_schema)
3981
3968
  });
3982
3969
  var NOT_A_CHECK_RUNS_LISTING = "gh api answered something other than a check run listing";
3983
3970
  var NOT_A_STATUS_LISTING = "gh api answered something other than a commit status listing";
@@ -3986,31 +3973,46 @@ function read_pages(raw_json, schema, message) {
3986
3973
  if (pages === void 0) throw new Error(message);
3987
3974
  return pages;
3988
3975
  }
3976
+ var NO_SUITE = -1;
3977
+ function read_id(value) {
3978
+ const parsed = id_holder_schema.safeParse(value);
3979
+ return parsed.success ? parsed.data.id : void 0;
3980
+ }
3989
3981
  function check_run_group_key(run2) {
3990
- const { name, app: raw_app } = run2;
3982
+ const { name, app } = run2;
3991
3983
  if (typeof name !== "string") return void 0;
3992
- const app = check_run_app_schema.safeParse(raw_app);
3993
- return JSON.stringify([name, app.success ? app.data.id : void 0]);
3984
+ return JSON.stringify([name, read_id(app)]);
3985
+ }
3986
+ function read_rank(run2) {
3987
+ const id = read_id(run2);
3988
+ if (id === void 0) return void 0;
3989
+ return { suite: read_id(run2["check_suite"]) ?? NO_SUITE, run: id };
3990
+ }
3991
+ function is_ranked_above(candidate, current) {
3992
+ if (candidate.suite !== current.suite) return candidate.suite > current.suite;
3993
+ return candidate.run > current.run;
3994
3994
  }
3995
- function remember_newest_run(run2, latest_ids) {
3995
+ function should_replace(previous, rank) {
3996
+ const previous_rank = previous === void 0 ? void 0 : read_rank(previous);
3997
+ return previous_rank === void 0 || is_ranked_above(rank, previous_rank);
3998
+ }
3999
+ function remember_newest_run(run2, newest) {
3996
4000
  const key = check_run_group_key(run2);
3997
- const { id } = run2;
3998
- if (key === void 0 || typeof id !== "number") return;
3999
- const previous_id = latest_ids.get(key);
4000
- if (previous_id === void 0 || id > previous_id) latest_ids.set(key, id);
4001
+ const rank = read_rank(run2);
4002
+ if (key === void 0 || rank === void 0) return;
4003
+ if (should_replace(newest.get(key), rank)) newest.set(key, run2);
4001
4004
  }
4002
- function is_newest_run(run2, latest_ids) {
4005
+ function is_newest_run(run2, newest) {
4003
4006
  const key = check_run_group_key(run2);
4004
- const { id } = run2;
4005
- if (key === void 0 || typeof id !== "number") return true;
4006
- return id === latest_ids.get(key);
4007
+ if (key === void 0 || read_rank(run2) === void 0) return true;
4008
+ return newest.get(key) === run2;
4007
4009
  }
4008
4010
  function to_check_run_items(check_runs_json) {
4009
4011
  const pages = read_pages(check_runs_json, check_runs_page_schema, NOT_A_CHECK_RUNS_LISTING);
4010
4012
  const runs = pages.flatMap((page) => page.check_runs);
4011
- const latest_ids = /* @__PURE__ */ new Map();
4012
- for (const run2 of runs) remember_newest_run(run2, latest_ids);
4013
- return runs.filter((run2) => is_newest_run(run2, latest_ids));
4013
+ const newest = /* @__PURE__ */ new Map();
4014
+ for (const run2 of runs) remember_newest_run(run2, newest);
4015
+ return runs.filter((run2) => is_newest_run(run2, newest));
4014
4016
  }
4015
4017
  function to_status_context_items(status_json) {
4016
4018
  const pages = read_pages(status_json, status_page_schema, NOT_A_STATUS_LISTING);
@@ -4098,7 +4100,7 @@ var MERGE_READ_BACK_ATTEMPTS = 3;
4098
4100
  var MERGE_READ_BACK_INTERVAL_MS = 1e3;
4099
4101
  var PR_NUMBER_PATTERN = /\/pull\/([1-9]\d*)$/u;
4100
4102
  var LABELS_SEGMENT2 = "/labels";
4101
- var PR_LABELS = z11.array(z11.object({ name: z11.string() }));
4103
+ var PR_LABELS = z12.array(z12.object({ name: z12.string() }));
4102
4104
  async function add_pr_classification(number, label) {
4103
4105
  await git_gh_exec.exec_gh_api({
4104
4106
  path: `${git_gh_api_path.issue_api_path(number)}${LABELS_SEGMENT2}`,
@@ -4688,24 +4690,24 @@ import path6 from "node:path";
4688
4690
  import { setTimeout as sleep2 } from "node:timers/promises";
4689
4691
 
4690
4692
  // scripts/agent/agent-event.ts
4691
- import { z as z13 } from "zod";
4693
+ import { z as z14 } from "zod";
4692
4694
 
4693
4695
  // scripts/agent/claude-result-event.ts
4694
- import { z as z12 } from "zod";
4695
- var RESULT_EVENT_SCHEMA = z12.looseObject({
4696
- type: z12.literal("result"),
4697
- is_error: z12.unknown().optional(),
4698
- subtype: z12.unknown().optional(),
4699
- num_turns: z12.unknown().optional(),
4700
- permission_denials: z12.unknown().optional(),
4701
- result: z12.unknown().optional(),
4702
- session_id: z12.unknown().optional(),
4703
- usage: z12.unknown().optional()
4696
+ import { z as z13 } from "zod";
4697
+ var RESULT_EVENT_SCHEMA = z13.looseObject({
4698
+ type: z13.literal("result"),
4699
+ is_error: z13.unknown().optional(),
4700
+ subtype: z13.unknown().optional(),
4701
+ num_turns: z13.unknown().optional(),
4702
+ permission_denials: z13.unknown().optional(),
4703
+ result: z13.unknown().optional(),
4704
+ session_id: z13.unknown().optional(),
4705
+ usage: z13.unknown().optional()
4704
4706
  });
4705
- var USAGE_SCHEMA = z12.looseObject({
4706
- input_tokens: z12.unknown().optional(),
4707
- cache_read_input_tokens: z12.unknown().optional(),
4708
- output_tokens: z12.unknown().optional()
4707
+ var USAGE_SCHEMA = z13.looseObject({
4708
+ input_tokens: z13.unknown().optional(),
4709
+ cache_read_input_tokens: z13.unknown().optional(),
4710
+ output_tokens: z13.unknown().optional()
4709
4711
  });
4710
4712
  function usable_reason(value) {
4711
4713
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
@@ -4744,31 +4746,31 @@ function decode2(value) {
4744
4746
  var claude_result_event = { decode: decode2 };
4745
4747
 
4746
4748
  // scripts/agent/agent-event.ts
4747
- var TEXT_BLOCK_SCHEMA = z13.looseObject({ type: z13.literal("text"), text: z13.string() });
4748
- var CLAUDE_MESSAGE_SCHEMA = z13.looseObject({ content: z13.array(z13.unknown()).optional() });
4749
- var CLAUDE_INIT_SCHEMA = z13.looseObject({ type: z13.literal("system"), subtype: z13.literal("init") });
4750
- var CLAUDE_ASSISTANT_SCHEMA = z13.looseObject({
4751
- type: z13.literal("assistant"),
4749
+ var TEXT_BLOCK_SCHEMA = z14.looseObject({ type: z14.literal("text"), text: z14.string() });
4750
+ var CLAUDE_MESSAGE_SCHEMA = z14.looseObject({ content: z14.array(z14.unknown()).optional() });
4751
+ var CLAUDE_INIT_SCHEMA = z14.looseObject({ type: z14.literal("system"), subtype: z14.literal("init") });
4752
+ var CLAUDE_ASSISTANT_SCHEMA = z14.looseObject({
4753
+ type: z14.literal("assistant"),
4752
4754
  message: CLAUDE_MESSAGE_SCHEMA
4753
4755
  });
4754
- var USAGE_SCHEMA2 = z13.looseObject({
4755
- input_tokens: z13.number().optional(),
4756
- cached_input_tokens: z13.number().optional(),
4757
- output_tokens: z13.number().optional()
4756
+ var USAGE_SCHEMA2 = z14.looseObject({
4757
+ input_tokens: z14.number().optional(),
4758
+ cached_input_tokens: z14.number().optional(),
4759
+ output_tokens: z14.number().optional()
4758
4760
  });
4759
- var CODEX_START_SCHEMA = z13.looseObject({ type: z13.enum(["thread.started", "turn.started"]) });
4760
- var CODEX_PROGRESS_SCHEMA = z13.looseObject({
4761
- type: z13.enum(["item.started", "item.updated", "item.completed"]),
4762
- item: z13.looseObject({ type: z13.string(), text: z13.string().optional() }).optional()
4761
+ var CODEX_START_SCHEMA = z14.looseObject({ type: z14.enum(["thread.started", "turn.started"]) });
4762
+ var CODEX_PROGRESS_SCHEMA = z14.looseObject({
4763
+ type: z14.enum(["item.started", "item.updated", "item.completed"]),
4764
+ item: z14.looseObject({ type: z14.string(), text: z14.string().optional() }).optional()
4763
4765
  });
4764
- var CODEX_COMPLETE_SCHEMA = z13.looseObject({
4765
- type: z13.literal("turn.completed"),
4766
+ var CODEX_COMPLETE_SCHEMA = z14.looseObject({
4767
+ type: z14.literal("turn.completed"),
4766
4768
  usage: USAGE_SCHEMA2.optional()
4767
4769
  });
4768
- var CODEX_FAILURE_SCHEMA = z13.looseObject({
4769
- type: z13.enum(["turn.failed", "error"]),
4770
- error: z13.looseObject({ message: z13.string().optional() }).optional(),
4771
- message: z13.string().optional()
4770
+ var CODEX_FAILURE_SCHEMA = z14.looseObject({
4771
+ type: z14.enum(["turn.failed", "error"]),
4772
+ error: z14.looseObject({ message: z14.string().optional() }).optional(),
4773
+ message: z14.string().optional()
4772
4774
  });
4773
4775
  var EMPTY_STATE = {
4774
4776
  provider: void 0,
@@ -4866,7 +4868,7 @@ function describe(state) {
4866
4868
  var agent_event = { describe, read };
4867
4869
 
4868
4870
  // scripts/issue/issue-state.ts
4869
- import { z as z14 } from "zod";
4871
+ import { z as z15 } from "zod";
4870
4872
  var NO_LABELS = "(none)";
4871
4873
  var LABEL_SEPARATOR = ", ";
4872
4874
  var STATE_LABEL = "state: ";
@@ -4876,9 +4878,9 @@ var YES = "yes";
4876
4878
  var NO = "no";
4877
4879
  var ISSUE_LABEL = "issue: ";
4878
4880
  var HUMAN_REVIEW_LABELS = /* @__PURE__ */ new Set([NEEDS_HUMAN_REVIEW_LABEL]);
4879
- var label_schema = z14.looseObject({ name: z14.string() });
4880
- var issue_state_schema = z14.looseObject({
4881
- state: z14.string(),
4881
+ var label_schema = z15.looseObject({ name: z15.string() });
4882
+ var issue_state_schema = z15.looseObject({
4883
+ state: z15.string(),
4882
4884
  labels: label_schema.array().optional()
4883
4885
  });
4884
4886
  function parse_issue_state(json) {
@@ -4976,7 +4978,7 @@ function to_advice(verdict, has_work_to_stash) {
4976
4978
  if (verdict === UNDETERMINED_VERDICT) return UNDETERMINED_ADVICE;
4977
4979
  return has_work_to_stash ? STOPPED_DIRTY_ADVICE : STOPPED_CLEAN_ADVICE;
4978
4980
  }
4979
- function decide5(traces) {
4981
+ function decide4(traces) {
4980
4982
  const verdict = to_verdict(traces);
4981
4983
  const has_work_to_stash = verdict === STOPPED_VERDICT && traces.is_tree_dirty;
4982
4984
  return {
@@ -5075,11 +5077,11 @@ async function read_traces(request) {
5075
5077
  }
5076
5078
  async function check(request) {
5077
5079
  run_issue_number.require_issue_number(request.issue);
5078
- return decide5(await read_traces(request));
5080
+ return decide4(await read_traces(request));
5079
5081
  }
5080
5082
  var run_liveness = {
5081
5083
  check,
5082
- decide: decide5,
5084
+ decide: decide4,
5083
5085
  describe_agent_state,
5084
5086
  read_child_settled,
5085
5087
  read_agent_state,
@@ -5150,7 +5152,7 @@ var lane_report = {
5150
5152
  };
5151
5153
 
5152
5154
  // scripts/run/run-preflight.ts
5153
- import { z as z15 } from "zod";
5155
+ import { z as z16 } from "zod";
5154
5156
  var CLEAN_VERDICT = "clean";
5155
5157
  var RECLAIM_VERDICT = "reclaim";
5156
5158
  var RESUME_VERDICT = "resume";
@@ -5160,7 +5162,7 @@ var OPEN_PR = "open";
5160
5162
  var MERGED_PR = "merged";
5161
5163
  var CLOSED_PR = "closed";
5162
5164
  var NO_CHILD_WORK = { branch_name: void 0, pr_state: NO_PR };
5163
- var pr_info_schema2 = z15.object({ state: z15.string().optional() });
5165
+ var pr_info_schema2 = z16.object({ state: z16.string().optional() });
5164
5166
  var GH_PR_STATES = /* @__PURE__ */ new Map([
5165
5167
  ["CLOSED", CLOSED_PR],
5166
5168
  ["MERGED", MERGED_PR],
@@ -5229,7 +5231,7 @@ function to_advice2(verdict, issue, tree) {
5229
5231
  if (verdict === PARK_VERDICT) return PARK_ADVICE;
5230
5232
  return CLEAN_ADVICE;
5231
5233
  }
5232
- function decide6(tree, child, issue) {
5234
+ function decide5(tree, child, issue) {
5233
5235
  const verdict = to_verdict2(tree, child);
5234
5236
  return {
5235
5237
  advice: to_advice2(verdict, issue, tree),
@@ -5298,8 +5300,8 @@ async function read_child_state(issue) {
5298
5300
  async function check2(issue) {
5299
5301
  require_issue_number(issue);
5300
5302
  const tree = await read_tree_state();
5301
- if (needs_reclaim(tree)) return decide6(tree, NO_CHILD_WORK, issue);
5302
- return decide6(tree, await read_child_state(issue), issue);
5303
+ if (needs_reclaim(tree)) return decide5(tree, NO_CHILD_WORK, issue);
5304
+ return decide5(tree, await read_child_state(issue), issue);
5303
5305
  }
5304
5306
  var run_preflight = {
5305
5307
  CLEAN_ADVICE,
@@ -5314,7 +5316,7 @@ var run_preflight = {
5314
5316
  MERGED_PR,
5315
5317
  STASH_LABEL_PREFIX,
5316
5318
  check: check2,
5317
- decide: decide6,
5319
+ decide: decide5,
5318
5320
  read_child_state,
5319
5321
  read_pr_state: read_pr_state2,
5320
5322
  to_pr_state: to_pr_state2
@@ -5414,7 +5416,7 @@ var run_progress_read = {
5414
5416
  // scripts/run/run-watcher-hook.ts
5415
5417
  var SWITCH_ENV_KEY2 = "JOSH_WATCHER_GUARD";
5416
5418
  var STAMP_PREFIX2 = "josh-watcher-guard-";
5417
- var payload_schema = z16.object({ transcript_path: z16.string().min(1) });
5419
+ var payload_schema = z17.object({ transcript_path: z17.string().min(1) });
5418
5420
  function transcript_of(raw_payload) {
5419
5421
  try {
5420
5422
  const parsed = payload_schema.safeParse(JSON.parse(raw_payload));