@joshuafolkken/kit 1.1379.0 → 1.1387.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 (84) hide show
  1. package/.claude/skills/workflow-commands/backlogrun-progress.md +2 -3
  2. package/.claude/skills/workflow-commands/backlogrun-steps.md +2 -4
  3. package/.claude/skills/workflow-commands/retrospective.md +1 -2
  4. package/dist/hooks/batch-guard.js +6 -6
  5. package/dist/hooks/{chunk-RW4XMF47.js → chunk-2YSW3CXH.js} +133 -234
  6. package/dist/hooks/{chunk-4RWRP3FF.js → chunk-DCY2GWHC.js} +5 -5
  7. package/dist/hooks/{chunk-DHSKBAQ2.js → chunk-EAQEGME7.js} +1 -1
  8. package/dist/hooks/{chunk-E7LZL5AN.js → chunk-EBSHN25W.js} +3 -3
  9. package/dist/hooks/{chunk-HGA4EG5S.js → chunk-GJ7JPIHN.js} +15 -15
  10. package/dist/hooks/{chunk-TG2AB3W6.js → chunk-GNDJ7NJ7.js} +88 -501
  11. package/dist/hooks/{chunk-546X4PX3.js → chunk-IYVOLN6A.js} +3 -3
  12. package/dist/hooks/{chunk-NBEAGPS4.js → chunk-J3KSS7II.js} +1 -1
  13. package/dist/hooks/{chunk-7ZM464OW.js → chunk-LMWBRJIP.js} +3 -3
  14. package/dist/hooks/{chunk-TORRSNDJ.js → chunk-SL4GQ2XP.js} +3 -3
  15. package/dist/hooks/{chunk-PV3FWDSQ.js → chunk-STDSEPWU.js} +2 -2
  16. package/dist/hooks/{chunk-YSDAH73S.js → chunk-U32VSRNG.js} +420 -4
  17. package/dist/hooks/{chunk-QARPP36N.js → chunk-WNFJLBXI.js} +3 -3
  18. package/dist/hooks/codex-hook-adapter.js +13 -13
  19. package/dist/hooks/duplicate-read-guard.js +7 -7
  20. package/dist/hooks/format-edited.js +3 -3
  21. package/dist/hooks/inputs.json +213 -212
  22. package/dist/hooks/investigation-guard.js +7 -7
  23. package/dist/hooks/pretool-guard.js +12 -12
  24. package/dist/hooks/session-lang.js +65 -9
  25. package/dist/hooks/stop-guard.js +104 -32
  26. package/dist/josh.js +2 -2
  27. package/package.json +1 -1
  28. package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
  29. package/scripts/backlog/backlog-budget-cli.ts +2 -20
  30. package/scripts/backlog/backlog-budget.ts +72 -109
  31. package/scripts/backlog/backlog-drive-cli.ts +12 -7
  32. package/scripts/backlog/backlog-drive-launch.ts +2 -0
  33. package/scripts/backlog/backlog-drive-owner.ts +72 -5
  34. package/scripts/backlog/backlog-drive.ts +5 -2
  35. package/scripts/backlog/backlog-offer-cli.ts +1 -15
  36. package/scripts/backlog/backlogrun-launch.ts +56 -5
  37. package/scripts/document/document-byte-budget.ts +1 -1
  38. package/scripts/epic/epic-candidate-confirm.ts +1 -1
  39. package/scripts/epic/epic-cross-repo.ts +4 -4
  40. package/scripts/epic/epic-next.ts +1 -1
  41. package/scripts/hooks/stop-guard.ts +20 -9
  42. package/scripts/init/start-plan.ts +15 -4
  43. package/scripts/init/start-steps.ts +31 -3
  44. package/scripts/init/start.ts +20 -13
  45. package/scripts/josh/josh-commands-ai.ts +1 -1
  46. package/scripts/josh/josh-commands-project.ts +1 -1
  47. package/scripts/lane/lane-cli.ts +1 -3
  48. package/scripts/run/board/run-board-header.ts +137 -88
  49. package/scripts/run/board/run-board-labels.ts +18 -17
  50. package/scripts/run/board/run-board-machine.ts +21 -8
  51. package/scripts/run/board/run-board-read.ts +9 -2
  52. package/scripts/run/board/run-board-render.ts +1 -5
  53. package/scripts/run/board/run-board-setup.ts +73 -0
  54. package/scripts/run/board/run-board-span.ts +49 -8
  55. package/scripts/run/board/run-board-status.ts +10 -23
  56. package/scripts/run/board/run-board-tick.ts +11 -2
  57. package/scripts/run/carry/run-carry-added.ts +1 -1
  58. package/scripts/run/carry/run-carry-change.ts +1 -1
  59. package/scripts/run/carry/run-carry-cli.ts +36 -60
  60. package/scripts/run/carry/run-carry-ended.ts +10 -2
  61. package/scripts/run/carry/run-carry.ts +38 -68
  62. package/scripts/run/cut/run-cut.ts +4 -4
  63. package/scripts/run/event/run-event-render.ts +1 -1
  64. package/scripts/run/event/run-event-scope.ts +4 -8
  65. package/scripts/run/event/run-event-setup.ts +47 -0
  66. package/scripts/run/event/run-event-stream-emit.ts +0 -25
  67. package/scripts/run/event/run-event-stream.ts +41 -28
  68. package/scripts/run/merge/run-merge-collect.ts +1 -1
  69. package/scripts/run/merge/run-merge-steps.ts +1 -1
  70. package/scripts/run/progress/run-progress-read.ts +1 -1
  71. package/scripts/run/run-headless.ts +2 -2
  72. package/scripts/run/run-status-cli.ts +1 -5
  73. package/scripts/run/run-step.ts +2 -9
  74. package/scripts/run/run-stop-notify.ts +1 -1
  75. package/scripts/run/run-stranded-detect.ts +61 -15
  76. package/scripts/run/run-stranded.ts +25 -17
  77. package/scripts/run/wake/run-wake-cli.ts +58 -15
  78. package/scripts/run/wake/run-wake-describe.ts +5 -5
  79. package/scripts/run/wake/run-wake-driver.ts +13 -4
  80. package/scripts/run/wake/run-wake-handoff.ts +1 -1
  81. package/scripts/run/wake/run-wake-loop.ts +4 -21
  82. package/scripts/run/wake/run-wake-restart.ts +1 -1
  83. package/scripts/run/wake/run-wake.ts +6 -7
  84. package/scripts/backlog/backlog-idle.ts +0 -88
@@ -6,9 +6,9 @@ import {
6
6
  lane_child_invocation,
7
7
  repo_discovery,
8
8
  repo_origin,
9
- repository_lock,
10
- run_ship_stage
11
- } from "./chunk-YSDAH73S.js";
9
+ run_event_stream,
10
+ run_event_stream_emit
11
+ } from "./chunk-U32VSRNG.js";
12
12
  import {
13
13
  error_text
14
14
  } from "./chunk-CDY4NFQG.js";
@@ -30,10 +30,10 @@ import {
30
30
  time_density_hook,
31
31
  time_shell,
32
32
  time_transcript_line
33
- } from "./chunk-TORRSNDJ.js";
33
+ } from "./chunk-SL4GQ2XP.js";
34
34
  import {
35
35
  lane_child_marker
36
- } from "./chunk-NBEAGPS4.js";
36
+ } from "./chunk-J3KSS7II.js";
37
37
  import {
38
38
  agent_session_environment,
39
39
  backlog_budget,
@@ -41,10 +41,8 @@ import {
41
41
  git_command,
42
42
  has_timed_out,
43
43
  json_value,
44
- process_identity,
45
- run_carry,
46
- stamp_record
47
- } from "./chunk-RW4XMF47.js";
44
+ process_identity
45
+ } from "./chunk-2YSW3CXH.js";
48
46
  import {
49
47
  COMMAND_TIMEOUT_MS,
50
48
  stamp_file
@@ -339,6 +337,23 @@ var session_cite = {
339
337
  text
340
338
  };
341
339
 
340
+ // scripts/josh/stamp-record.ts
341
+ var NONE_READ = { kind: "none" };
342
+ var UNREADABLE_READ = { kind: "unreadable" };
343
+ function is_older_than(iso, max_age_ms, now) {
344
+ const at = Date.parse(iso);
345
+ if (Number.isNaN(at)) return true;
346
+ return now.getTime() - at > max_age_ms;
347
+ }
348
+ function classify(raw, spec, now) {
349
+ if (raw === void 0) return NONE_READ;
350
+ const record = spec.parse(raw);
351
+ if (record === void 0) return UNREADABLE_READ;
352
+ const is_expired3 = is_older_than(spec.timestamp_of(record), spec.max_age_ms, now);
353
+ return { kind: is_expired3 ? "expired" : "carried", record };
354
+ }
355
+ var stamp_record = { classify, is_older_than };
356
+
342
357
  // scripts/run/hold/run-hold.ts
343
358
  import { z } from "zod";
344
359
  var HOLD_PREFIX = "josh-run-hold-";
@@ -350,7 +365,7 @@ var RELEASE_COMMAND = "pnpm josh run:release";
350
365
  var FORCE_RELEASE_COMMAND = `${RELEASE_COMMAND} --force`;
351
366
  var NOT_IDLE = 'that is not "nothing is running here"';
352
367
  var FREE_READ = { kind: "free" };
353
- var UNREADABLE_READ = { kind: "unreadable" };
368
+ var UNREADABLE_READ2 = { kind: "unreadable" };
354
369
  function hold_path(git_directory) {
355
370
  return stamp_file.stamp_path(HOLD_PREFIX, git_directory);
356
371
  }
@@ -386,14 +401,14 @@ function is_owner_gone(hold) {
386
401
  function is_stale(hold, now) {
387
402
  return is_expired(hold, now) || is_owner_gone(hold);
388
403
  }
389
- function classify(raw, now) {
404
+ function classify2(raw, now) {
390
405
  if (raw === void 0) return FREE_READ;
391
406
  const hold = parse_hold(raw);
392
- if (hold === void 0) return UNREADABLE_READ;
407
+ if (hold === void 0) return UNREADABLE_READ2;
393
408
  return { kind: is_stale(hold, now) ? "stale" : "held", hold };
394
409
  }
395
410
  function read_hold(target, now = /* @__PURE__ */ new Date()) {
396
- return classify(stamp_file.read_stamp_text(target), now);
411
+ return classify2(stamp_file.read_stamp_text(target), now);
397
412
  }
398
413
  function session_owner(environment = process.env) {
399
414
  const pid = Number(environment[agent_session_environment.AGENT_PID_KEY]);
@@ -475,7 +490,7 @@ var run_hold = {
475
490
  HOLD_MAX_AGE_MS,
476
491
  RELEASE_COMMAND,
477
492
  UNNUMBERED_ISSUE,
478
- classify,
493
+ classify: classify2,
479
494
  create_halfrun_stop_hold,
480
495
  create_stop_hold,
481
496
  HALFRUN_STOP_FIELDS,
@@ -726,8 +741,8 @@ var run_cut_handoff = {
726
741
  var CUT_PREFIX = "josh-run-cut-";
727
742
  var { PRE_GATE_PHASE, IMPLEMENTATION_PHASE } = agent_role_profile;
728
743
  var IMPLEMENTATION_CONTEXT_THRESHOLD = CONTEXT_CUT_THRESHOLD;
729
- var CUT_MAX_AGE_MS = backlog_budget.WHOLE_RUN_BUDGET_MS;
730
- var CUT_MAX_AGE_HOURS = backlog_budget.WHOLE_RUN_BUDGET_HOURS;
744
+ var CUT_MAX_AGE_MS = backlog_budget.DEFAULT_IDLE_MS;
745
+ var CUT_MAX_AGE_HOURS = backlog_budget.IDLE_WAIT_HOURS;
731
746
  var END_COMMAND = "pnpm josh run:cut --end";
732
747
  var READ_COMMAND = "pnpm josh run:cut --json";
733
748
  var MAX_HANDOFF_BYTES = 8192;
@@ -762,13 +777,13 @@ var CUT_SPEC = {
762
777
  function is_expired2(cut, now) {
763
778
  return stamp_record.is_older_than(cut_at_of(cut), CUT_MAX_AGE_MS, now);
764
779
  }
765
- function classify2(raw, now) {
780
+ function classify3(raw, now) {
766
781
  const read = stamp_record.classify(raw, CUT_SPEC, now);
767
782
  if (!("record" in read)) return read;
768
783
  return { kind: read.kind, cut: read.record };
769
784
  }
770
785
  function read_cut(target, now = /* @__PURE__ */ new Date()) {
771
- return classify2(stamp_file.read_stamp_text(target), now);
786
+ return classify3(stamp_file.read_stamp_text(target), now);
772
787
  }
773
788
  function worktree_git_directory_sync() {
774
789
  return git_common_directory.own();
@@ -891,7 +906,7 @@ var run_cut = {
891
906
  begin_cut,
892
907
  busy_message,
893
908
  carried_cut_sync,
894
- classify: classify2,
909
+ classify: classify3,
895
910
  classify_resume,
896
911
  current_state,
897
912
  cut_path,
@@ -1045,432 +1060,7 @@ var lane_background = {
1045
1060
  // scripts/run/ship/run-ship-detach.ts
1046
1061
  import { randomUUID } from "node:crypto";
1047
1062
  import { setTimeout as sleep } from "node:timers/promises";
1048
-
1049
- // scripts/run/event/run-event-stream.ts
1050
1063
  import { z as z4 } from "zod";
1051
- var EVENT_PREFIX = "josh-run-events-";
1052
- var EVENT_SUFFIX = ".jsonl";
1053
- var EVENT_CAP = 500;
1054
- var FIRST_POSITION = 0;
1055
- var POSITION_INCREMENT = 1;
1056
- var LINE_SEPARATOR = "\n";
1057
- var WORD_SEPARATOR = " ";
1058
- var STAGE_PHASE_INDEX = 2;
1059
- var LOCK_SUFFIX = ".lock";
1060
- var LOCK_WAIT_MS = 5e3;
1061
- var EVENT_KIND = {
1062
- PLAN: "plan",
1063
- CHILD_LAUNCH: "child-launch",
1064
- MERGE: "merge",
1065
- PARK: "park",
1066
- SPLIT: "split",
1067
- OUTAGE: "outage",
1068
- CUT: "cut",
1069
- // A fresh session adopted an implementation cut — `run:cut --resume` answered `resume-impl`. The
1070
- // resume clears the cut record, so without this the `cut` would stay the newest position and
1071
- // `run:step` would keep answering the resume command it had just run.
1072
- RESUME: "resume",
1073
- // The backlog emptied while nothing of the run's own was in flight — the drain. It marks the position
1074
- // at which the end-of-run retrospective is owed, *before* the idle watch opens, so `run:step` fires
1075
- // the retrospective at the drain rather than after the watch runs its course. It is not itself a
1076
- // stop: the run watches on once the retrospective has run, and the real `STOP` follows when the watch
1077
- // expires.
1078
- DRAIN: "drain",
1079
- STOP: "stop",
1080
- PR_OPENED: "pr-opened",
1081
- REVIEW_ROUND: "review-round",
1082
- // The end-of-run retrospective's result, recorded when the run marks the retrospective done. A
1083
- // retrospective that files zero improvements and one that never ran look
1084
- // the same from outside — no new Issue either way — so the result is put on the stream the report is
1085
- // generated from: the issues filed (or that none were), and the candidates dropped with why. It is
1086
- // emitted from the `run:carry --retrospective` close, so marking the retrospective done and recording
1087
- // what it found are one action rather than two the run could do only one of.
1088
- RETROSPECTIVE: "retrospective",
1089
- // Ready backlog work is sitting undispatched while a lane is free and nothing has dispatched for a
1090
- // while. Emitted once per stall episode by the stop-time detector, it is both the dedup marker —
1091
- // `emit_once_since` refuses a second until a `CHILD_LAUNCH` intervenes — and the line a terminal
1092
- // reader following the stream sees. `run:step` reads it as `backlog:next`, so a run that
1093
- // stalled is pointed straight at dispatching the work rather than left waiting.
1094
- STALL: "stall",
1095
- // The run's own driver is gone: the cut handed the budget off, the owner has died, and no supervisor
1096
- // is watching. Emitted once per strand episode by the stop-time detector,
1097
- // exactly as `STALL` is — the newest-event dedup keeps a run polled every stop from notifying more
1098
- // than once, and a terminal reader following the stream sees the line. The strand is the step before
1099
- // the stall: a stalled run still has a driver that could dispatch, a stranded one has none.
1100
- STRANDED: "stranded",
1101
- // One `josh ship` stage starting, succeeding or failing. It is a trace of the
1102
- // composite's progress rather than a position the run is at — the positions a ship leaves behind are
1103
- // the closed issue its `followup` merges, or a detached supervisor's `SHIP_LAUNCH` / `SHIP_STOP` below
1104
- // — so it is one of the `TRACE_KINDS` the last-event read skips.
1105
- SHIP_STAGE: "ship-stage",
1106
- // One progress watcher line — the `at … / next …` heartbeat `run:progress` prints. Printed only to
1107
- // the watcher's own output, a headless successor's heartbeat would be buried in its log after a cut;
1108
- // on the stream it reaches the attached session's relay. It says
1109
- // the run is alive rather than where it is, so it is a trace kind like `SHIP_STAGE`.
1110
- HEARTBEAT: "heartbeat",
1111
- // The post-implementation region handed to a detached `josh ship --detach` supervisor. Unlike a stage
1112
- // trace it is a position: the agent has ended and the
1113
- // supervisor carries the run, so `run:step` answers `wait` until it stops or the issue closes.
1114
- SHIP_LAUNCH: "ship-launch",
1115
- // The supervisor stopped at a failed stage — a red gate, a High/Medium review, a failed push, red CI
1116
- // The position that hands control back: `run:step` prints the command that
1117
- // shows the stopped report, so the agent fixes it and relaunches rather than rebuilding the context.
1118
- SHIP_STOP: "ship-stop",
1119
- // The idle watch's window — when the run began waiting on an empty backlog and when that wait ends
1120
- // `backlog:offer` writes it whenever the window changes, so `run:board` reads
1121
- // the deadline rather than guessing it. It is a trace: `emit_once`'s drain dedup and `run:step`'s
1122
- // position both read past it, so a watching loop never re-marks the drain it is waiting after.
1123
- IDLE: "idle",
1124
- // An Issue the run filed on its way, written by `issue:file`, so a run started from the command line
1125
- // still surfaces what it found — `run:board`'s findings section reads it.
1126
- FILED: "filed",
1127
- // A one-line observation short of an Issue, written with `run:event --append note` and shown in the
1128
- // same section.
1129
- NOTE: "note",
1130
- // A lane child reached a phase no other event marks — its first implementation edit, written by the
1131
- // PreToolUse hook — so `run:board` draws how far the child has got. A trace,
1132
- // like `SHIP_STAGE`: it says where the child's work is, not where the run is.
1133
- LANE_PHASE: "lane-phase",
1134
- // An issue `run:add` put into the live run. The parent's `--wait` watcher
1135
- // ends on it, so the issue takes the next free lane without waiting out the arrival probe's minute. A
1136
- // trace: it says what the run was handed, not where the run is.
1137
- ADD: "add",
1138
- // `josh lane:limit` raised a live run's lane limit. The `--wait` watcher's
1139
- // arrival probe reads it as a wake: the lanes a raise frees are new room for a pool its baseline
1140
- // already holds. A trace: it says the run gained room, not where the run is.
1141
- LANE_LIMIT: "lane-limit"
1142
- };
1143
- var EVENT_KINDS = Object.values(EVENT_KIND);
1144
- var TRACE_KINDS = /* @__PURE__ */ new Set([
1145
- EVENT_KIND.SHIP_STAGE,
1146
- EVENT_KIND.HEARTBEAT,
1147
- EVENT_KIND.IDLE,
1148
- EVENT_KIND.FILED,
1149
- EVENT_KIND.NOTE,
1150
- EVENT_KIND.LANE_PHASE,
1151
- EVENT_KIND.ADD,
1152
- EVENT_KIND.LANE_LIMIT
1153
- ]);
1154
- var DISPOSABLE_KINDS = /* @__PURE__ */ new Set([
1155
- EVENT_KIND.SHIP_STAGE,
1156
- EVENT_KIND.HEARTBEAT,
1157
- EVENT_KIND.IDLE
1158
- ]);
1159
- var event_schema = z4.object({
1160
- pos: z4.number(),
1161
- at: z4.string(),
1162
- kind: z4.string(),
1163
- text: z4.string()
1164
- });
1165
- function is_event_kind(value) {
1166
- return EVENT_KINDS.includes(value);
1167
- }
1168
- function target_of(repository) {
1169
- return stamp_file.stamp_path(EVENT_PREFIX, repository, EVENT_SUFFIX);
1170
- }
1171
- function is_present(event) {
1172
- return event !== void 0;
1173
- }
1174
- function parse_line(line) {
1175
- return event_schema.safeParse(json_value.parse_or_undefined(line)).data;
1176
- }
1177
- function read_events(target) {
1178
- const raw = stamp_file.read_stamp_text(target);
1179
- if (raw === void 0) return [];
1180
- return raw.split(LINE_SEPARATOR).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => parse_line(line)).filter(is_present);
1181
- }
1182
- function last_position(events) {
1183
- return events[events.length - POSITION_INCREMENT]?.pos ?? FIRST_POSITION;
1184
- }
1185
- function issue_of(event) {
1186
- return event.text.split(WORD_SEPARATOR)[FIRST_POSITION] ?? "";
1187
- }
1188
- function newest_stages(events) {
1189
- const newest = /* @__PURE__ */ new Map();
1190
- for (const event of events) {
1191
- if (event.kind === EVENT_KIND.SHIP_STAGE) newest.set(issue_of(event), event);
1192
- }
1193
- return new Set(newest.values());
1194
- }
1195
- function is_stage_start(event) {
1196
- if (event.kind !== EVENT_KIND.SHIP_STAGE) return false;
1197
- return event.text.split(WORD_SEPARATOR)[STAGE_PHASE_INDEX] === run_ship_stage.PHASE.START;
1198
- }
1199
- function is_drawn(event) {
1200
- return event.kind === EVENT_KIND.IDLE || is_stage_start(event);
1201
- }
1202
- function droppable(events) {
1203
- const kept = newest_stages(events);
1204
- const disposable = events.filter((event) => DISPOSABLE_KINDS.has(event.kind) && !kept.has(event));
1205
- return [
1206
- ...disposable.filter((event) => !is_drawn(event)),
1207
- ...disposable.filter((event) => is_drawn(event))
1208
- ];
1209
- }
1210
- function bounded(events) {
1211
- const excess = events.length - EVENT_CAP;
1212
- if (excess <= 0) return events;
1213
- const dropped = new Set(droppable(events).slice(0, excess));
1214
- return events.filter((event) => !dropped.has(event)).slice(-EVENT_CAP);
1215
- }
1216
- function serialize(events) {
1217
- return `${events.map((event) => JSON.stringify(event)).join(LINE_SEPARATOR)}${LINE_SEPARATOR}`;
1218
- }
1219
- function append_held(target, event) {
1220
- const existing = read_events(target);
1221
- const position = last_position(existing) + POSITION_INCREMENT;
1222
- const events = bounded([...existing, { pos: position, ...event }]);
1223
- stamp_file.replace_text_stamp(target, serialize(events));
1224
- return position;
1225
- }
1226
- function append(target, kind, text2, at) {
1227
- if (!is_event_kind(kind)) return { appended: false, position: FIRST_POSITION };
1228
- const lock = `${target}${LOCK_SUFFIX}`;
1229
- const position = repository_lock.with_lock_sync(
1230
- () => append_held(target, { at, kind, text: text2 }),
1231
- lock,
1232
- LOCK_WAIT_MS
1233
- );
1234
- if (position === void 0) {
1235
- const message = `run event stream: gave up waiting for the lock at ${lock}`;
1236
- process.stderr.write(`${message}
1237
- `);
1238
- throw new Error(message);
1239
- }
1240
- return { appended: true, position };
1241
- }
1242
- function read_from(target, position) {
1243
- const events = read_events(target);
1244
- return {
1245
- events: events.filter((event) => event.pos > position),
1246
- next_position: last_position(events)
1247
- };
1248
- }
1249
- function read_last(target) {
1250
- return read_events(target).findLast((event) => !TRACE_KINDS.has(event.kind));
1251
- }
1252
- function has_since(events, kind, reset_kind) {
1253
- const reset_at = events.findLastIndex((event) => event.kind === reset_kind);
1254
- return events.slice(reset_at + POSITION_INCREMENT).some((event) => event.kind === kind);
1255
- }
1256
- var FIELD_SEPARATOR = " \xB7 ";
1257
- function format_event(event) {
1258
- return [event.at, event.kind, event.text].join(FIELD_SEPARATOR);
1259
- }
1260
- var run_event_stream = {
1261
- EVENT_CAP,
1262
- EVENT_KIND,
1263
- EVENT_KINDS,
1264
- TRACE_KINDS,
1265
- append,
1266
- format_event,
1267
- has_since,
1268
- is_stage_start,
1269
- read_events,
1270
- read_from,
1271
- read_last,
1272
- target_of
1273
- };
1274
-
1275
- // scripts/run/event/run-event-scope.ts
1276
- var SINCE_SCOPE = "since";
1277
- var UNKNOWN_SCOPE = "unknown";
1278
- var UNKNOWN_EVENT_SCOPE = { kind: UNKNOWN_SCOPE };
1279
- function moment_of(at) {
1280
- const parsed = Date.parse(at);
1281
- return Number.isNaN(parsed) ? void 0 : parsed;
1282
- }
1283
- function is_within(event, floor) {
1284
- const at = moment_of(event.at);
1285
- return at !== void 0 && at >= floor;
1286
- }
1287
- function scoped_events(events, scope) {
1288
- if (scope.kind === UNKNOWN_SCOPE) return void 0;
1289
- const floor = moment_of(scope.started_at);
1290
- if (floor === void 0) return void 0;
1291
- return events.filter((event) => is_within(event, floor));
1292
- }
1293
- function scope_of(read) {
1294
- if (read.kind === "carried" || read.kind === "expired") {
1295
- return { kind: SINCE_SCOPE, started_at: read.carry.started_at };
1296
- }
1297
- return UNKNOWN_EVENT_SCOPE;
1298
- }
1299
- function last_scoped_event(events, scope) {
1300
- return scoped_events(events, scope)?.findLast(
1301
- (event) => !run_event_stream.TRACE_KINDS.has(event.kind)
1302
- );
1303
- }
1304
- var SHIP_POSITION_KINDS = /* @__PURE__ */ new Set([
1305
- run_event_stream.EVENT_KIND.SHIP_LAUNCH,
1306
- run_event_stream.EVENT_KIND.SHIP_STOP
1307
- ]);
1308
- var KIND = run_event_stream.EVENT_KIND;
1309
- var BATCH_RECORD_KINDS = /* @__PURE__ */ new Set([
1310
- KIND.CHILD_LAUNCH,
1311
- KIND.PARK,
1312
- KIND.SPLIT,
1313
- KIND.RETROSPECTIVE,
1314
- KIND.STRANDED
1315
- ]);
1316
- var ISSUE_REFERENCE = /#(\d+)/u;
1317
- function is_foreign_ship_event(event, issue2) {
1318
- return SHIP_POSITION_KINDS.has(event.kind) && !event.text.startsWith(`${issue_cite.plain(issue2)} `);
1319
- }
1320
- function is_own_ship_event(event, issue2) {
1321
- return SHIP_POSITION_KINDS.has(event.kind) && !is_foreign_ship_event(event, issue2);
1322
- }
1323
- function issue_named(event) {
1324
- return ISSUE_REFERENCE.exec(event.text)?.[1];
1325
- }
1326
- function names_issue(event, issue2) {
1327
- return issue_named(event) === issue2;
1328
- }
1329
- function is_lane_position(event, issue2) {
1330
- return !BATCH_RECORD_KINDS.has(event.kind) && names_issue(event, issue2);
1331
- }
1332
- function since_own_launch(events, issue2) {
1333
- const launch2 = events.findLastIndex(
1334
- (event) => event.kind === KIND.CHILD_LAUNCH && names_issue(event, issue2)
1335
- );
1336
- return events.slice(launch2 + 1);
1337
- }
1338
- function is_foreign_event(event, issue2, is_lane_child) {
1339
- if (is_lane_child) return !is_lane_position(event, issue2);
1340
- return is_foreign_ship_event(event, issue2);
1341
- }
1342
- function last_issue_event(events, scope, issue2, is_lane_child) {
1343
- const attempt = is_lane_child ? since_own_launch(events, issue2) : events;
1344
- const own = attempt.filter((event) => !is_foreign_event(event, issue2, is_lane_child));
1345
- if (scope.kind === SINCE_SCOPE) return last_scoped_event(own, scope);
1346
- return own.findLast((event) => is_own_ship_event(event, issue2));
1347
- }
1348
- var LAUNCH_OR_SETTLE_KINDS = /* @__PURE__ */ new Set([
1349
- KIND.CHILD_LAUNCH,
1350
- KIND.MERGE,
1351
- KIND.PARK,
1352
- KIND.SPLIT
1353
- ]);
1354
- function is_merge_owed(events, scope, issue2) {
1355
- const newest = (scoped_events(events, scope) ?? []).findLast(
1356
- (event) => LAUNCH_OR_SETTLE_KINDS.has(event.kind) && names_issue(event, issue2)
1357
- );
1358
- return newest?.kind === KIND.CHILD_LAUNCH;
1359
- }
1360
- var run_event_scope = {
1361
- UNKNOWN_EVENT_SCOPE,
1362
- is_merge_owed,
1363
- issue_named,
1364
- last_issue_event,
1365
- last_scoped_event,
1366
- moment_of,
1367
- scope_of,
1368
- scoped_events,
1369
- since_own_launch
1370
- };
1371
-
1372
- // scripts/run/event/run-event-stream-emit.ts
1373
- function now_iso() {
1374
- return (/* @__PURE__ */ new Date()).toISOString();
1375
- }
1376
- async function stream_target() {
1377
- const repository = await run_carry.repository_directory();
1378
- return repository === void 0 ? void 0 : run_event_stream.target_of(repository);
1379
- }
1380
- async function emit(kind, text2) {
1381
- try {
1382
- const target = await stream_target();
1383
- if (target === void 0) return;
1384
- run_event_stream.append(target, kind, text2, now_iso());
1385
- } catch {
1386
- }
1387
- }
1388
- async function emit_once(kind, text2) {
1389
- try {
1390
- const target = await stream_target();
1391
- if (target === void 0 || run_event_stream.read_last(target)?.kind === kind) return false;
1392
- return run_event_stream.append(target, kind, text2, now_iso()).appended;
1393
- } catch (error) {
1394
- error_text.trace_swallowed("run_event_stream_emit.emit_once", error);
1395
- return false;
1396
- }
1397
- }
1398
- async function emit_changed(kind, text2) {
1399
- try {
1400
- const target = await stream_target();
1401
- if (target === void 0) return false;
1402
- const newest = run_event_stream.read_events(target).findLast((event) => event.kind === kind);
1403
- if (newest?.text === text2) return false;
1404
- return run_event_stream.append(target, kind, text2, now_iso()).appended;
1405
- } catch (error) {
1406
- error_text.trace_swallowed("run_event_stream_emit.emit_changed", error);
1407
- return false;
1408
- }
1409
- }
1410
- function invocation_events(repository, target) {
1411
- const events = run_event_stream.read_events(target);
1412
- const scope = run_event_scope.scope_of(run_carry.read_carry(run_carry.carry_path(repository)));
1413
- return run_event_scope.scoped_events(events, scope) ?? events;
1414
- }
1415
- async function emit_once_since(kind, text2, reset_kind) {
1416
- try {
1417
- const repository = await run_carry.repository_directory();
1418
- if (repository === void 0) return false;
1419
- const target = run_event_stream.target_of(repository);
1420
- if (run_event_stream.has_since(invocation_events(repository, target), kind, reset_kind)) {
1421
- return false;
1422
- }
1423
- return run_event_stream.append(target, kind, text2, now_iso()).appended;
1424
- } catch (error) {
1425
- error_text.trace_swallowed("run_event_stream_emit.emit_once_since", error);
1426
- return false;
1427
- }
1428
- }
1429
- async function emit_heartbeat(line) {
1430
- await emit(run_event_stream.EVENT_KIND.HEARTBEAT, line);
1431
- }
1432
- async function current_events() {
1433
- try {
1434
- const repository = await run_carry.repository_directory();
1435
- if (repository === void 0) return [];
1436
- const read = run_carry.read_carry(run_carry.carry_path(repository));
1437
- const scope = run_event_scope.scope_of(read);
1438
- const events = run_event_stream.read_events(run_event_stream.target_of(repository));
1439
- return run_event_scope.scoped_events(events, scope) ?? [];
1440
- } catch {
1441
- return [];
1442
- }
1443
- }
1444
- async function invocation_or_all_events() {
1445
- try {
1446
- const repository = await run_carry.repository_directory();
1447
- return repository === void 0 ? [] : invocation_events(repository, run_event_stream.target_of(repository));
1448
- } catch {
1449
- return [];
1450
- }
1451
- }
1452
- async function all_events() {
1453
- try {
1454
- const target = await stream_target();
1455
- return target === void 0 ? [] : run_event_stream.read_events(target);
1456
- } catch {
1457
- return [];
1458
- }
1459
- }
1460
- var run_event_stream_emit = {
1461
- all_events,
1462
- current_events,
1463
- emit,
1464
- emit_changed,
1465
- emit_heartbeat,
1466
- emit_once,
1467
- emit_once_since,
1468
- invocation_or_all_events,
1469
- stream_target
1470
- };
1471
-
1472
- // scripts/run/ship/run-ship-detach.ts
1473
- import { z as z5 } from "zod";
1474
1064
  var LOG_PREFIX = "josh-ship-log-";
1475
1065
  var PID_PREFIX = "josh-ship-pid-";
1476
1066
  var BODY_PREFIX = "josh-ship-notify-";
@@ -1491,14 +1081,14 @@ var RESULT_PREFIX = "josh-ship-result-";
1491
1081
  var RECORD_POLL_MS = 25;
1492
1082
  var RECORD_WAIT_ATTEMPTS = 200;
1493
1083
  var CLAIM_WINDOW_MS = 12e4;
1494
- var ship_record_schema = z5.object({
1495
- pid: z5.number().int().positive().optional(),
1496
- process_start: z5.string().optional(),
1497
- launched_at: z5.number().optional(),
1498
- launcher_pid: z5.number().int().positive().optional(),
1499
- launcher_start: z5.string().optional(),
1500
- launch_id: z5.string(),
1501
- result: z5.enum(["success", "failed"]).optional()
1084
+ var ship_record_schema = z4.object({
1085
+ pid: z4.number().int().positive().optional(),
1086
+ process_start: z4.string().optional(),
1087
+ launched_at: z4.number().optional(),
1088
+ launcher_pid: z4.number().int().positive().optional(),
1089
+ launcher_start: z4.string().optional(),
1090
+ launch_id: z4.string(),
1091
+ result: z4.enum(["success", "failed"]).optional()
1502
1092
  });
1503
1093
  var LAUNCH_MARK = " \xB7 started by process ";
1504
1094
  var HEADER_START = "\n";
@@ -1888,7 +1478,7 @@ var THIRD_PARTY = "third-party";
1888
1478
  var UNKNOWN = "unknown";
1889
1479
  var GH_REPO_ENV_KEY = "GH_REPO";
1890
1480
  var GH_REPO_PATH_SEGMENTS = 2;
1891
- function classify3(session_owner2, target) {
1481
+ function classify4(session_owner2, target) {
1892
1482
  if (session_owner2 === void 0 || target === void 0) return UNKNOWN;
1893
1483
  return session_owner2.toLowerCase() === target.toLowerCase() ? FIRST_PARTY : THIRD_PARTY;
1894
1484
  }
@@ -1912,7 +1502,7 @@ var repo_party = {
1912
1502
  FIRST_PARTY,
1913
1503
  THIRD_PARTY,
1914
1504
  UNKNOWN,
1915
- classify: classify3,
1505
+ classify: classify4,
1916
1506
  current_owner,
1917
1507
  placeholder_owners,
1918
1508
  target_owner
@@ -2031,8 +1621,8 @@ var parse_json = {
2031
1621
  };
2032
1622
 
2033
1623
  // scripts/gh/git-gh-failure.ts
2034
- import { z as z6 } from "zod";
2035
- var error_document_schema = z6.object({ status: z6.union([z6.string(), z6.number()]).optional() }).catch({});
1624
+ import { z as z5 } from "zod";
1625
+ var error_document_schema = z5.object({ status: z5.union([z5.string(), z5.number()]).optional() }).catch({});
2036
1626
  var GH_FAILURE_FIELD = "gh_failure";
2037
1627
  function has_gh_failure(error) {
2038
1628
  return error instanceof Error && Object.hasOwn(error, GH_FAILURE_FIELD);
@@ -2235,7 +1825,7 @@ var git_gh_helpers = {
2235
1825
  };
2236
1826
 
2237
1827
  // scripts/gh/git-gh-issue-rest.ts
2238
- import { z as z7 } from "zod";
1828
+ import { z as z6 } from "zod";
2239
1829
 
2240
1830
  // scripts/gh/git-gh-rest-state.ts
2241
1831
  var MERGED_STATE = "MERGED";
@@ -2244,11 +1834,11 @@ function to_gh_state(state) {
2244
1834
  }
2245
1835
 
2246
1836
  // scripts/gh/git-gh-issue-rest.ts
2247
- var rest_issue_schema = z7.looseObject({
2248
- number: z7.number(),
2249
- issue_dependencies_summary: z7.looseObject({ total_blocked_by: z7.number().optional() }).nullish(),
1837
+ var rest_issue_schema = z6.looseObject({
1838
+ number: z6.number(),
1839
+ issue_dependencies_summary: z6.looseObject({ total_blocked_by: z6.number().optional() }).nullish(),
2250
1840
  // Present only on a pull request, which this endpoint serves as readily as an issue.
2251
- pull_request: z7.looseObject({ merged_at: z7.string().nullish() }).nullish()
1841
+ pull_request: z6.looseObject({ merged_at: z6.string().nullish() }).nullish()
2252
1842
  });
2253
1843
  var REPOSITORY_URL = /\/repos\/([\w.-]+\/[\w.-]+)$/u;
2254
1844
  var REPOSITORY_URL_GROUP = 1;
@@ -2256,7 +1846,7 @@ var BLOCKED_BY_FIELD = "blockedBy";
2256
1846
  var BLOCKED_BY_COUNT_FIELD = "blocked_by_count";
2257
1847
  var STATE_FIELD = "state";
2258
1848
  var BODY_FIELD = "body";
2259
- var FIELD_SEPARATOR2 = ",";
1849
+ var FIELD_SEPARATOR = ",";
2260
1850
  var EMPTY_BODY = "";
2261
1851
  var REST_FIELD_NAMES = /* @__PURE__ */ new Map([
2262
1852
  ["url", "html_url"],
@@ -2270,7 +1860,7 @@ function rest_field_name(field) {
2270
1860
  return REST_FIELD_NAMES.get(field) ?? field;
2271
1861
  }
2272
1862
  function split_fields(fields) {
2273
- return fields.split(FIELD_SEPARATOR2).map((field) => field.trim()).filter((field) => field.length > 0);
1863
+ return fields.split(FIELD_SEPARATOR).map((field) => field.trim()).filter((field) => field.length > 0);
2274
1864
  }
2275
1865
  function to_issue_state(rest, value) {
2276
1866
  if (typeof rest.pull_request?.merged_at === "string") return MERGED_STATE;
@@ -2818,18 +2408,18 @@ var git_gh_issue = {
2818
2408
  // scripts/ci/pr-classification.ts
2819
2409
  import { readFileSync as readFileSync2 } from "node:fs";
2820
2410
  import { fileURLToPath } from "node:url";
2821
- import { z as z8 } from "zod";
2411
+ import { z as z7 } from "zod";
2822
2412
  var CLASSIFICATION_SET = new Set(RELEASE_CLASSIFICATION_NAMES);
2823
2413
  var ISSUE_BUG_LABEL = "bug";
2824
2414
  var DECLARATION_PREFIX = "- \u30EA\u30EA\u30FC\u30B9\u5206\u985E: ";
2825
2415
  var DECLARATION = new RegExp(`^${DECLARATION_PREFIX}(.+)$`, "gmu");
2826
2416
  var LEGACY_LABELS = /* @__PURE__ */ new Set(["semver-major", "semver-minor"]);
2827
- var LABEL = z8.object({ name: z8.string() });
2828
- var USER = z8.object({ login: z8.string() });
2829
- var PULL_REQUEST = z8.object({ number: z8.number(), user: USER });
2830
- var EVENT = z8.object({
2417
+ var LABEL = z7.object({ name: z7.string() });
2418
+ var USER = z7.object({ login: z7.string() });
2419
+ var PULL_REQUEST = z7.object({ number: z7.number(), user: USER });
2420
+ var EVENT = z7.object({
2831
2421
  pull_request: PULL_REQUEST,
2832
- repository: z8.object({ full_name: z8.string() })
2422
+ repository: z7.object({ full_name: z7.string() })
2833
2423
  });
2834
2424
  function classification_error(labels, author) {
2835
2425
  const legacy = labels.filter((label) => LEGACY_LABELS.has(label.toLowerCase()));
@@ -2852,7 +2442,7 @@ function release_candidates(candidates) {
2852
2442
  return candidates.filter((candidate) => candidate !== ENHANCEMENT_LABEL);
2853
2443
  }
2854
2444
  function issue_candidates(issue_json) {
2855
- const issue2 = z8.object({ labels: z8.array(LABEL), body: z8.string().nullable() }).parse(JSON.parse(issue_json));
2445
+ const issue2 = z7.object({ labels: z7.array(LABEL), body: z7.string().nullable() }).parse(JSON.parse(issue_json));
2856
2446
  const names = issue2.labels.map((label) => label.name.toLowerCase());
2857
2447
  const declared = [...(issue2.body ?? "").matchAll(DECLARATION)].map((match) => match[1] ?? "");
2858
2448
  const candidates = [...release_candidates([...names, ...declared].filter(is_classification))];
@@ -2927,30 +2517,30 @@ async function poll_until(is_done, options) {
2927
2517
  var poll = { poll_until, sleep: sleep2 };
2928
2518
 
2929
2519
  // scripts/gh/git-gh-pr.ts
2930
- import { z as z12 } from "zod";
2520
+ import { z as z11 } from "zod";
2931
2521
 
2932
2522
  // scripts/gh/git-gh-pr-rest.ts
2933
- import { z as z9 } from "zod";
2934
- var rest_repo_schema = z9.looseObject({ full_name: z9.string().optional() }).nullish();
2935
- var rest_pull_side_schema = z9.looseObject({ repo: rest_repo_schema });
2936
- var rest_pull_schema = z9.looseObject({
2937
- number: z9.number(),
2938
- html_url: z9.string().optional(),
2939
- body: z9.string().nullish(),
2940
- state: z9.string().optional(),
2941
- merged: z9.boolean().nullish(),
2942
- merged_at: z9.string().nullish(),
2943
- mergeable: z9.boolean().nullish(),
2944
- mergeable_state: z9.string().optional(),
2523
+ import { z as z8 } from "zod";
2524
+ var rest_repo_schema = z8.looseObject({ full_name: z8.string().optional() }).nullish();
2525
+ var rest_pull_side_schema = z8.looseObject({ repo: rest_repo_schema });
2526
+ var rest_pull_schema = z8.looseObject({
2527
+ number: z8.number(),
2528
+ html_url: z8.string().optional(),
2529
+ body: z8.string().nullish(),
2530
+ state: z8.string().optional(),
2531
+ merged: z8.boolean().nullish(),
2532
+ merged_at: z8.string().nullish(),
2533
+ mergeable: z8.boolean().nullish(),
2534
+ mergeable_state: z8.string().optional(),
2945
2535
  // `sha` is the head commit, which is what both halves of the merge-gate rollup are keyed by —
2946
2536
  // REST hangs the check runs and the status contexts off the commit rather than off the pull
2947
2537
  // request.
2948
- head: z9.looseObject({ ref: z9.string().optional(), sha: z9.string().optional(), repo: rest_repo_schema }).nullish(),
2538
+ head: z8.looseObject({ ref: z8.string().optional(), sha: z8.string().optional(), repo: rest_repo_schema }).nullish(),
2949
2539
  base: rest_pull_side_schema.nullish(),
2950
2540
  // `node_id` is what the GraphQL auto-merge mutation addresses a pull request by, and `auto_merge`
2951
2541
  // is `null` until auto-merge is enabled — both read by `git-gh-pr-auto-merge.ts`.
2952
- node_id: z9.string().optional(),
2953
- auto_merge: z9.looseObject({}).nullish()
2542
+ node_id: z8.string().optional(),
2543
+ auto_merge: z8.looseObject({}).nullish()
2954
2544
  });
2955
2545
  var NOT_A_PULL_MESSAGE = "gh api answered something other than a pull request object";
2956
2546
  var NOT_A_PULL_LISTING_MESSAGE = "gh api answered something other than a pull request listing";
@@ -3169,14 +2759,14 @@ var git_gh_pr_read = {
3169
2759
  };
3170
2760
 
3171
2761
  // scripts/gh/git-gh-pr-review.ts
3172
- import { z as z10 } from "zod";
2762
+ import { z as z9 } from "zod";
3173
2763
  var REVIEW_APPROVED = "APPROVED";
3174
2764
  var REVIEW_CHANGES_REQUESTED = "CHANGES_REQUESTED";
3175
2765
  var REVIEW_NONE = "";
3176
2766
  var STATE_CHANGING_REVIEWS = /* @__PURE__ */ new Set([REVIEW_APPROVED, REVIEW_CHANGES_REQUESTED]);
3177
- var rest_review_schema = z10.looseObject({
3178
- state: z10.string().optional(),
3179
- user: z10.looseObject({ login: z10.string().optional() }).nullish()
2767
+ var rest_review_schema = z9.looseObject({
2768
+ state: z9.string().optional(),
2769
+ user: z9.looseObject({ login: z9.string().optional() }).nullish()
3180
2770
  });
3181
2771
  var NOT_A_REVIEW_LISTING = "gh api answered something other than a review listing";
3182
2772
  function parse_rest_reviews(reviews_json) {
@@ -3209,18 +2799,18 @@ function to_review_decision(reviews_json) {
3209
2799
  var git_gh_pr_review = { to_review_decision };
3210
2800
 
3211
2801
  // scripts/gh/git-gh-pr-rollup.ts
3212
- import { z as z11 } from "zod";
2802
+ import { z as z10 } from "zod";
3213
2803
  var STATUS_CONTEXT_TYPE_NAME = "StatusContext";
3214
2804
  var TYPE_NAME_KEY = "__typename";
3215
- var rollup_element_schema = z11.looseObject({});
3216
- var check_runs_page_schema = z11.looseObject({
2805
+ var rollup_element_schema = z10.looseObject({});
2806
+ var check_runs_page_schema = z10.looseObject({
3217
2807
  // Required, not optional: GitHub always names the key, and accepting a page without one would
3218
2808
  // answer an empty rollup — which `git-pr-followup.ts` reports as "this branch has no checks".
3219
- check_runs: z11.array(rollup_element_schema)
2809
+ check_runs: z10.array(rollup_element_schema)
3220
2810
  });
3221
- var id_holder_schema = z11.object({ id: z11.number() });
3222
- var status_page_schema = z11.looseObject({
3223
- statuses: z11.array(rollup_element_schema)
2811
+ var id_holder_schema = z10.object({ id: z10.number() });
2812
+ var status_page_schema = z10.looseObject({
2813
+ statuses: z10.array(rollup_element_schema)
3224
2814
  });
3225
2815
  var NOT_A_CHECK_RUNS_LISTING = "gh api answered something other than a check run listing";
3226
2816
  var NOT_A_STATUS_LISTING = "gh api answered something other than a commit status listing";
@@ -3354,7 +2944,7 @@ var MERGE_READ_BACK_ATTEMPTS = 3;
3354
2944
  var MERGE_READ_BACK_INTERVAL_MS = 1e3;
3355
2945
  var PR_NUMBER_PATTERN = /\/pull\/([1-9]\d*)$/u;
3356
2946
  var LABELS_SEGMENT2 = "/labels";
3357
- var PR_LABELS = z12.array(z12.object({ name: z12.string() }));
2947
+ var PR_LABELS = z11.array(z11.object({ name: z11.string() }));
3358
2948
  async function add_pr_classification(number, label) {
3359
2949
  await git_gh_exec.exec_gh_api({
3360
2950
  path: `${git_gh_api_path.issue_api_path(number)}${LABELS_SEGMENT2}`,
@@ -3703,9 +3293,6 @@ var git_gh_command = {
3703
3293
 
3704
3294
  export {
3705
3295
  bounded_pool,
3706
- run_event_stream,
3707
- run_event_scope,
3708
- run_event_stream_emit,
3709
3296
  shell_segments,
3710
3297
  bash_triggers,
3711
3298
  tail_commands,